@mnykj/wangeditoroptimize-core 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/src/editor/interface.d.ts +1 -0
- package/dist/core/src/index.d.ts +2 -0
- package/dist/core/src/menus/bar/HoverBar.d.ts +2 -2
- package/dist/core/src/menus/panel-and-modal/SelectList.d.ts +2 -0
- package/dist/core/src/utils/history-batch.d.ts +16 -0
- package/dist/core/src/utils/hotkeys.d.ts +1 -0
- package/dist/core/src/utils/typing-history.d.ts +22 -0
- package/dist/css/style.css +1 -1
- package/dist/index.esm.js +236 -91
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -21,6 +21,7 @@ export interface IDomEditor extends Editor {
|
|
|
21
21
|
getAllMenuKeys: () => string[];
|
|
22
22
|
alert: (info: string, type: AlertType) => void;
|
|
23
23
|
handleTab: () => void;
|
|
24
|
+
handleShiftTab: () => void;
|
|
24
25
|
getHtml: () => string;
|
|
25
26
|
getText: () => string;
|
|
26
27
|
getSelectionText: () => string;
|
package/dist/core/src/index.d.ts
CHANGED
|
@@ -19,6 +19,8 @@ export * from './menus/index';
|
|
|
19
19
|
export * from './upload/index';
|
|
20
20
|
export * from './i18n/index';
|
|
21
21
|
export { pinEditorScrollDuring, findEditorScrollParent } from './utils/pin-scroll';
|
|
22
|
+
export { withIsolatedHistoryBatch, cancelPendingHistorySplit } from './utils/history-batch';
|
|
23
|
+
export { withTypingHistory, markTypingHistoryCompositionStart, markTypingHistoryCompositionEnd, resetTypingHistoryState, } from './utils/typing-history';
|
|
22
24
|
export { getEditorNodeAtPath, isBlankParagraphNode, genEmptyParagraph, insertEmptyLineAboveAtPath, canRemoveEmptyLineAboveBlock, removeEmptyLineAboveTopLevelBlock, replaceBlockWithEmptyLine, setBlockToParagraph, resolveElemPath, } from './utils/block-helpers';
|
|
23
25
|
export interface IModuleConf {
|
|
24
26
|
menus: Array<IRegisterMenuConf>;
|
|
@@ -16,8 +16,8 @@ declare class HoverBar {
|
|
|
16
16
|
};
|
|
17
17
|
hideAndClean(): void;
|
|
18
18
|
/**
|
|
19
|
-
* 判断
|
|
20
|
-
*
|
|
19
|
+
* 判断 SelectList / DropPanel 默认向上还是向下。
|
|
20
|
+
* 色板约 220px、标题列表更高;不再用固定 360px(否则下方够放色板仍强制向上,易被遮挡)。
|
|
21
21
|
*/
|
|
22
22
|
private checkPositionBottom;
|
|
23
23
|
private show;
|
|
@@ -10,6 +10,8 @@ declare class SelectList extends PanelAndModal {
|
|
|
10
10
|
type: string;
|
|
11
11
|
readonly $elem: Dom7Array;
|
|
12
12
|
constructor(editor: IDomEditor, width?: number);
|
|
13
|
+
/** 从点击目标解析 li(点到 span / svg 时也能取到 data-value) */
|
|
14
|
+
static findOptionLi(target: EventTarget | null): Element | null;
|
|
13
15
|
/**
|
|
14
16
|
* 渲染 list
|
|
15
17
|
* @param options select options
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Isolate a user action (e.g. paste) as one undo batch that does not
|
|
3
|
+
* merge with adjacent typing. slate-history 0.66 merges contiguous insert_text
|
|
4
|
+
* forever and has no withNewBatch — this helper emulates that behavior.
|
|
5
|
+
*/
|
|
6
|
+
import { Editor } from 'slate';
|
|
7
|
+
/** Drop a pending post-paste one-shot wrapper (e.g. before programmatic setHtml). */
|
|
8
|
+
export declare function cancelPendingHistorySplit(editor: Editor): void;
|
|
9
|
+
/**
|
|
10
|
+
* Run `fn` as a single undo/redo batch that:
|
|
11
|
+
* 1. Does not merge into the previous history batch
|
|
12
|
+
* 2. Merges all ops produced inside `fn` into one batch
|
|
13
|
+
* 3. Ensures the next content edit after `fn` starts a new batch (so typing
|
|
14
|
+
* after paste is not coalesced with the paste)
|
|
15
|
+
*/
|
|
16
|
+
export declare function withIsolatedHistoryBatch(editor: Editor, fn: () => void): void;
|
|
@@ -27,6 +27,7 @@ declare const _default: {
|
|
|
27
27
|
isTransposeCharacter: (event: KeyboardEvent) => boolean;
|
|
28
28
|
isUndo: (event: KeyboardEvent) => boolean;
|
|
29
29
|
isTab: (event: KeyboardEvent) => boolean;
|
|
30
|
+
isShiftTab: (event: KeyboardEvent) => boolean;
|
|
30
31
|
isSelectAll: (event: KeyboardEvent) => boolean;
|
|
31
32
|
};
|
|
32
33
|
/**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Undo for keyed-in text: each typed character (letter / digit /
|
|
3
|
+
* symbol) is one Ctrl+Z step. Paste is excluded — withIsolatedHistoryBatch
|
|
4
|
+
* forces MERGING so a whole paste stays one batch.
|
|
5
|
+
*
|
|
6
|
+
* IME 上屏多为一次 insert_text(整词)→ 仍是一步。
|
|
7
|
+
* 多字 delete(选区删除)不强制断批,避免拆成多次撤销。
|
|
8
|
+
*
|
|
9
|
+
* Must wrap the editor *outside* slate-history's withHistory.
|
|
10
|
+
*/
|
|
11
|
+
import { Editor } from 'slate';
|
|
12
|
+
/** Clear typing-history bookkeeping (e.g. after programmatic setHtml). */
|
|
13
|
+
export declare function resetTypingHistoryState(editor: Editor): void;
|
|
14
|
+
/** @deprecated no-op; composition 已由 insert_text 断批覆盖 */
|
|
15
|
+
export declare function markTypingHistoryCompositionStart(_editor: Editor): void;
|
|
16
|
+
/** @deprecated no-op; composition 已由 insert_text 断批覆盖 */
|
|
17
|
+
export declare function markTypingHistoryCompositionEnd(_editor: Editor): void;
|
|
18
|
+
/**
|
|
19
|
+
* Plugin: one undo step per typed character (paste excluded via MERGING).
|
|
20
|
+
* Place outside `withHistory`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function withTypingHistory<T extends Editor>(editor: T): T;
|
package/dist/css/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.w-e-text-container *,.w-e-toolbar *{box-sizing:border-box;margin:0;outline:none;padding:0}.w-e-text-container blockquote,.w-e-text-container li,.w-e-text-container p,.w-e-text-container td,.w-e-text-container th,.w-e-toolbar *{line-height:1.5}.w-e-text-container{background-color:var(--w-e-textarea-bg-color);color:var(--w-e-textarea-color);height:100%;position:relative}.w-e-text-container .w-e-scroll{-webkit-overflow-scrolling:touch;height:100%}.w-e-text-container [data-slate-editor]{word-wrap:break-word;border-top:1px solid transparent;min-height:100%;outline:0;padding:0 10px;white-space:pre-wrap}.w-e-text-container [data-slate-editor] p{margin:15px 0}.w-e-text-container [data-slate-editor] h1,.w-e-text-container [data-slate-editor] h2,.w-e-text-container [data-slate-editor] h3,.w-e-text-container [data-slate-editor] h4,.w-e-text-container [data-slate-editor] h5{margin:20px 0}.w-e-text-container [data-slate-editor] img{cursor:default;display:inline!important;max-width:100%;min-height:20px;min-width:20px}.w-e-text-container [data-slate-editor] span{text-indent:0}.w-e-text-container [data-slate-editor] [data-selected=true]{box-shadow:0 0 0 2px var(--w-e-textarea-selected-border-color)}.w-e-text-placeholder{font-style:italic;left:10px;top:17px;width:90%}.w-e-max-length-info,.w-e-text-placeholder{color:var(--w-e-textarea-slight-color);pointer-events:none;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none}.w-e-max-length-info{bottom:.5em;right:1em}.w-e-bar{background-color:var(--w-e-toolbar-bg-color);color:var(--w-e-toolbar-color);font-size:14px;padding:0 5px}.w-e-bar svg{fill:var(--w-e-toolbar-color);height:14px;width:14px}.w-e-bar-show{display:flex}.w-e-bar-hidden{display:none}.w-e-hover-bar{border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 5px #0000001f;position:absolute}.w-e-toolbar{flex-wrap:wrap;position:relative}.w-e-bar-divider{background-color:var(--w-e-toolbar-border-color);display:inline-flex;height:40px;margin:0 5px;width:1px}.w-e-bar-item{display:flex;height:40px;padding:4px;position:relative;text-align:center}.w-e-bar-item,.w-e-bar-item button{align-items:center;justify-content:center}.w-e-bar-item button{background:transparent;border:none;color:var(--w-e-toolbar-color);cursor:pointer;display:inline-flex;height:32px;overflow:hidden;padding:0 8px;white-space:nowrap}.w-e-bar-item button:hover{background-color:var(--w-e-toolbar-active-bg-color);color:var(--w-e-toolbar-active-color)}.w-e-bar-item button .title{margin-left:5px}.w-e-bar-item .active{background-color:var(--w-e-toolbar-active-bg-color);color:var(--w-e-toolbar-active-color)}.w-e-bar-item .disabled{color:var(--w-e-toolbar-disabled-color);cursor:not-allowed}.w-e-bar-item .disabled svg{fill:var(--w-e-toolbar-disabled-color)}.w-e-bar-item .disabled:hover{background-color:var(--w-e-toolbar-bg-color);color:var(--w-e-toolbar-disabled-color)}.w-e-bar-item .disabled:hover svg{fill:var(--w-e-toolbar-disabled-color)}.w-e-menu-tooltip-v5:before{background-color:var(--w-e-toolbar-active-color);border-radius:5px;color:var(--w-e-toolbar-bg-color);content:attr(data-tooltip);font-size:.75em;padding:5px 10px;text-align:center;top:40px;white-space:pre;z-index:1}.w-e-menu-tooltip-v5:after,.w-e-menu-tooltip-v5:before{opacity:0;position:absolute;transition:opacity .6s;visibility:hidden}.w-e-menu-tooltip-v5:after{border:5px solid transparent;border-bottom:5px solid var(--w-e-toolbar-active-color);content:"";top:30px}.w-e-menu-tooltip-v5:hover:after,.w-e-menu-tooltip-v5:hover:before{opacity:1;visibility:visible}.w-e-menu-tooltip-v5.tooltip-right:before{left:100%;top:10px}.w-e-menu-tooltip-v5.tooltip-right:after{border-bottom-color:transparent;border-left-color:transparent;border-right-color:var(--w-e-toolbar-active-color);border-top-color:transparent;left:100%;margin-left:-10px;top:16px}.w-e-bar-item-group .w-e-bar-item-menus-container{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;display:none;left:0;margin-top:40px;position:absolute;top:0;z-index:1}.w-e-bar-item-group:hover .w-e-bar-item-menus-container{display:block}.w-e-select-list{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;left:0;margin-top:40px;max-height:350px;min-width:100px;overflow-y:auto;position:absolute;top:0;z-index:1}.w-e-select-list ul{line-height:1;list-style:none}.w-e-select-list ul .selected{background-color:var(--w-e-toolbar-active-bg-color)}.w-e-select-list ul li{cursor:pointer;padding:7px 0 7px 25px;position:relative;text-align:left;white-space:nowrap}.w-e-select-list ul li:hover{background-color:var(--w-e-toolbar-active-bg-color)}.w-e-select-list ul li svg{left:0;margin-left:5px;margin-top:-7px;position:absolute;top:50%}.w-e-bar-bottom .w-e-select-list{bottom:0;margin-bottom:40px;margin-top:0;top:inherit}.w-e-drop-panel{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;margin-top:40px;min-width:200px;padding:10px;position:absolute;top:0;z-index:1}.w-e-bar-bottom .w-e-drop-panel{bottom:0;margin-bottom:40px;margin-top:0;top:inherit}.w-e-modal{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;color:var(--w-e-toolbar-color);font-size:14px;min-height:40px;min-width:100px;padding:20px 15px 0;position:absolute;text-align:left;z-index:1}.w-e-modal .btn-close{cursor:pointer;line-height:1;padding:5px;position:absolute;right:8px;top:7px}.w-e-modal .btn-close svg{fill:var(--w-e-toolbar-color);height:10px;width:10px}.w-e-modal .babel-container{display:block;margin-bottom:15px}.w-e-modal .babel-container span{display:block;margin-bottom:10px}.w-e-modal .button-container{margin-bottom:15px}.w-e-modal button{background-color:var(--w-e-modal-button-bg-color);cursor:pointer;font-weight:
|
|
1
|
+
.w-e-text-container [data-slate-editor],.w-e-text-container [data-slate-editor] *,.w-e-toolbar *{box-sizing:border-box;margin:0;outline:none;padding:0}.w-e-text-container blockquote,.w-e-text-container li,.w-e-text-container p,.w-e-text-container td,.w-e-text-container th,.w-e-toolbar *{line-height:1.5}.w-e-text-container{background-color:var(--w-e-textarea-bg-color);color:var(--w-e-textarea-color);height:100%;position:relative}.w-e-text-container .w-e-scroll{-webkit-overflow-scrolling:touch;height:100%}.w-e-text-container [data-slate-editor]{word-wrap:break-word;border-top:1px solid transparent;min-height:100%;outline:0;padding:0 10px;white-space:pre-wrap}.w-e-text-container [data-slate-editor] p{margin:15px 0}.w-e-text-container [data-slate-editor] h1,.w-e-text-container [data-slate-editor] h2,.w-e-text-container [data-slate-editor] h3,.w-e-text-container [data-slate-editor] h4,.w-e-text-container [data-slate-editor] h5{margin:20px 0}.w-e-text-container [data-slate-editor] img{cursor:default;display:inline!important;max-width:100%;min-height:20px;min-width:20px}.w-e-text-container [data-slate-editor] span{text-indent:0}.w-e-text-container [data-slate-editor] [data-selected=true]{box-shadow:0 0 0 2px var(--w-e-textarea-selected-border-color)}.w-e-text-placeholder{font-style:italic;left:10px;top:17px;width:90%}.w-e-max-length-info,.w-e-text-placeholder{color:var(--w-e-textarea-slight-color);pointer-events:none;position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none}.w-e-max-length-info{bottom:.5em;right:1em}.w-e-bar{background-color:var(--w-e-toolbar-bg-color);color:var(--w-e-toolbar-color);font-size:14px;padding:0 5px}.w-e-bar svg{fill:var(--w-e-toolbar-color);height:14px;width:14px}.w-e-bar-show{display:flex}.w-e-bar-hidden{display:none}.w-e-hover-bar{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 5px #0000001f;position:absolute}.w-e-hover-bar,.w-e-hover-bar>.w-e-bar-item>button{color:var(--w-e-toolbar-color);font-size:14px;font-weight:400;line-height:1.5}.w-e-hover-bar>.w-e-bar-item>button{background:transparent;border:none;box-shadow:none}.w-e-hover-bar>.w-e-bar-item>button svg{fill:var(--w-e-toolbar-color);flex-shrink:0;height:14px!important;width:14px!important}.w-e-hover-bar>.w-e-bar-item>button.select-button{font-size:14px;font-weight:400;letter-spacing:normal}.w-e-hover-bar>.w-e-bar-item>button.active,.w-e-hover-bar>.w-e-bar-item>button:hover{background-color:var(--w-e-toolbar-active-bg-color);color:var(--w-e-toolbar-active-color)}.w-e-hover-bar>.w-e-bar-item>button.active svg,.w-e-hover-bar>.w-e-bar-item>button:hover svg{fill:var(--w-e-toolbar-active-color)}.w-e-hover-bar .w-e-drop-panel,.w-e-hover-bar .w-e-select-list{background-color:var(--w-e-toolbar-bg-color);color:var(--w-e-toolbar-color);font-size:14px;font-weight:400;line-height:1.5}.w-e-hover-bar .w-e-panel-content-color{color:var(--w-e-toolbar-color);font-size:14px;line-height:1.5;list-style:none;margin:0;padding:0;text-align:left;width:230px}.w-e-hover-bar .w-e-panel-content-color li{box-sizing:border-box;display:inline-block;line-height:normal;list-style:none;margin:0;padding:2px;vertical-align:top}.w-e-hover-bar .w-e-panel-content-color .color-block{box-sizing:border-box;height:17px;width:17px}.w-e-hover-bar .w-e-panel-content-color .clear{display:block;font-size:14px;font-weight:400;line-height:1.5;margin:0 0 5px;padding:2px;width:100%}.w-e-toolbar{flex-wrap:wrap;position:relative}.w-e-bar-divider{background-color:var(--w-e-toolbar-border-color);display:inline-flex;height:40px;margin:0 5px;width:1px}.w-e-bar-item{display:flex;height:40px;padding:4px;position:relative;text-align:center}.w-e-bar-item,.w-e-bar-item button{align-items:center;justify-content:center}.w-e-bar-item button{background:transparent;border:none;color:var(--w-e-toolbar-color);cursor:pointer;display:inline-flex;height:32px;overflow:hidden;padding:0 8px;white-space:nowrap}.w-e-bar-item button:hover{background-color:var(--w-e-toolbar-active-bg-color);color:var(--w-e-toolbar-active-color)}.w-e-bar-item button .title{margin-left:5px}.w-e-bar-item .active{background-color:var(--w-e-toolbar-active-bg-color);color:var(--w-e-toolbar-active-color)}.w-e-bar-item .disabled{color:var(--w-e-toolbar-disabled-color);cursor:not-allowed}.w-e-bar-item .disabled svg{fill:var(--w-e-toolbar-disabled-color)}.w-e-bar-item .disabled:hover{background-color:var(--w-e-toolbar-bg-color);color:var(--w-e-toolbar-disabled-color)}.w-e-bar-item .disabled:hover svg{fill:var(--w-e-toolbar-disabled-color)}.w-e-menu-tooltip-v5:before{background-color:var(--w-e-toolbar-active-color);border-radius:5px;color:var(--w-e-toolbar-bg-color);content:attr(data-tooltip);font-size:.75em;padding:5px 10px;text-align:center;top:40px;white-space:pre;z-index:1}.w-e-menu-tooltip-v5:after,.w-e-menu-tooltip-v5:before{opacity:0;position:absolute;transition:opacity .6s;visibility:hidden}.w-e-menu-tooltip-v5:after{border:5px solid transparent;border-bottom:5px solid var(--w-e-toolbar-active-color);content:"";top:30px}.w-e-menu-tooltip-v5:hover:after,.w-e-menu-tooltip-v5:hover:before{opacity:1;visibility:visible}.w-e-menu-tooltip-v5.tooltip-right:before{left:100%;top:10px}.w-e-menu-tooltip-v5.tooltip-right:after{border-bottom-color:transparent;border-left-color:transparent;border-right-color:var(--w-e-toolbar-active-color);border-top-color:transparent;left:100%;margin-left:-10px;top:16px}.w-e-bar-item-group .w-e-bar-item-menus-container{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;display:none;left:0;margin-top:40px;position:absolute;top:0;z-index:1}.w-e-bar-item-group:hover .w-e-bar-item-menus-container{display:block}.w-e-select-list{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;color:var(--w-e-toolbar-color);font-size:14px;font-weight:400;left:0;line-height:1.5;margin-top:40px;max-height:350px;min-width:100px;overflow-y:auto;position:absolute;top:0;z-index:1}.w-e-select-list ul{line-height:1;list-style:none;margin:0;padding:0}.w-e-select-list ul .selected{background-color:var(--w-e-toolbar-active-bg-color)}.w-e-select-list ul li{box-sizing:border-box;cursor:pointer;font-weight:400;line-height:1.25;padding:7px 0 7px 25px;position:relative;text-align:left;white-space:nowrap}.w-e-select-list ul li span{font-size:inherit;font-weight:inherit;line-height:inherit}.w-e-select-list ul li:hover{background-color:var(--w-e-toolbar-active-bg-color)}.w-e-select-list ul li svg{left:0;margin-left:5px;margin-top:-7px;position:absolute;top:50%}.w-e-bar-bottom .w-e-select-list{bottom:0;margin-bottom:40px;margin-top:0;top:inherit}.w-e-drop-panel{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;margin-top:40px;min-width:200px;padding:10px;position:absolute;top:0;z-index:1}.w-e-bar-bottom .w-e-drop-panel{bottom:0;margin-bottom:40px;margin-top:0;top:inherit}.w-e-modal{background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-toolbar-border-color);border-radius:3px;box-shadow:0 2px 10px #0000001f;color:var(--w-e-toolbar-color);font-family:Inter,Helvetica Neue,Helvetica,PingFang SC,Hiragino Sans GB,Microsoft YaHei,微软雅黑,Arial,sans-serif;font-size:14px;line-height:1.5;min-height:40px;min-width:100px;padding:20px 15px 0;position:absolute;text-align:left;z-index:1}.w-e-modal .btn-close{cursor:pointer;line-height:1;padding:5px;position:absolute;right:8px;top:7px}.w-e-modal .btn-close svg{fill:var(--w-e-toolbar-color);height:10px;width:10px}.w-e-modal .babel-container{display:block;margin-bottom:15px}.w-e-modal .babel-container span{display:block;margin-bottom:10px}.w-e-modal .button-container{margin-bottom:15px}.w-e-modal button{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-color:var(--w-e-modal-button-bg-color);border:1px solid var(--w-e-modal-button-border-color);border-radius:4px;box-sizing:border-box;color:var(--w-e-toolbar-color);cursor:pointer;font-family:inherit;font-size:14px;font-weight:500;height:32px;justify-content:center;outline:none;padding:8px 15px;text-align:center;touch-action:manipulation;transition:all .3s cubic-bezier(.645,.045,.355,1);-webkit-user-select:none;-moz-user-select:none;user-select:none;vertical-align:middle;white-space:nowrap}.w-e-modal button,.w-e-modal button>span{align-items:center;display:inline-flex;line-height:1}.w-e-modal button>span{text-box-trim:trim-both;text-box-edge:cap alphabetic}.w-e-modal input[type=number],.w-e-modal input[type=text],.w-e-modal textarea{font-feature-settings:"tnum";background-color:var(--w-e-toolbar-bg-color);border:1px solid var(--w-e-modal-button-border-color);border-radius:4px;color:var(--w-e-toolbar-color);font-family:inherit;font-size:14px;font-variant:tabular-nums;line-height:1.5;padding:4.5px 11px;transition:all .3s;width:100%}.w-e-modal textarea{min-height:60px}body .w-e-modal,body .w-e-modal *{box-sizing:border-box}.w-e-progress-bar{background-color:var(--w-e-textarea-handler-bg-color);height:1px;position:absolute;transition:width .3s;width:0}.w-e-full-screen-container{bottom:0!important;display:flex!important;flex-direction:column!important;height:100%!important;left:0!important;margin:0!important;padding:0!important;position:fixed;right:0!important;top:0!important;width:100%!important}.w-e-full-screen-container [data-w-e-textarea=true]{flex:1!important}
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Editor, Operation, Path, Node, Range, Element, Text, Transforms, Point, createEditor as createEditor$1 } from 'slate';
|
|
1
|
+
import { Editor, Operation, Path, Node, Range, Element as Element$1, Text, Transforms, Point, createEditor as createEditor$1 } from 'slate';
|
|
2
2
|
import toArray from 'lodash.toarray';
|
|
3
3
|
import $, { css, append, addClass, removeClass, hasClass, on, focus, attr, removeAttr, hide, show, offset, width, height, parent, parents, is as is$5, dataset, val, text, html as html$1, children, remove as remove$1, find as find$1, each, empty as empty$1 } from 'dom7';
|
|
4
4
|
import forEach$1 from 'lodash.foreach';
|
|
@@ -3840,7 +3840,7 @@ var DomEditor = {
|
|
|
3840
3840
|
return Editor.hasPath(editor, anchor.path) && Editor.hasPath(editor, focus.path);
|
|
3841
3841
|
},
|
|
3842
3842
|
getNodeType: function getNodeType(node) {
|
|
3843
|
-
if (Element.isElement(node)) {
|
|
3843
|
+
if (Element$1.isElement(node)) {
|
|
3844
3844
|
return node.type;
|
|
3845
3845
|
}
|
|
3846
3846
|
return '';
|
|
@@ -3864,7 +3864,7 @@ var DomEditor = {
|
|
|
3864
3864
|
var nodeEntry = nodeEntries_1_1.value;
|
|
3865
3865
|
var _b = __read(nodeEntry, 1),
|
|
3866
3866
|
node = _b[0];
|
|
3867
|
-
if (Element.isElement(node)) elems.push(node);
|
|
3867
|
+
if (Element$1.isElement(node)) elems.push(node);
|
|
3868
3868
|
}
|
|
3869
3869
|
} catch (e_2_1) {
|
|
3870
3870
|
e_2 = {
|
|
@@ -3979,7 +3979,7 @@ var DomEditor = {
|
|
|
3979
3979
|
}
|
|
3980
3980
|
var nodeEntries = Editor.nodes(editor, {
|
|
3981
3981
|
match: function match(n) {
|
|
3982
|
-
if (Element.isElement(n)) {
|
|
3982
|
+
if (Element$1.isElement(n)) {
|
|
3983
3983
|
if (!editor.isInline(n)) {
|
|
3984
3984
|
return true;
|
|
3985
3985
|
}
|
|
@@ -5288,7 +5288,7 @@ function textToHtml(textNode, editor) {
|
|
|
5288
5288
|
}
|
|
5289
5289
|
|
|
5290
5290
|
function node2html(node, editor) {
|
|
5291
|
-
if (Element.isElement(node)) {
|
|
5291
|
+
if (Element$1.isElement(node)) {
|
|
5292
5292
|
return elemToHtml(node, editor);
|
|
5293
5293
|
} else {
|
|
5294
5294
|
return textToHtml(node, editor);
|
|
@@ -5971,6 +5971,126 @@ collection('Set', function (init) {
|
|
|
5971
5971
|
var IGNORE_TAGS = new Set(['doctype', '!doctype', 'meta', 'script', 'style', 'link', 'frame', 'iframe', 'title', 'svg'
|
|
5972
5972
|
]);
|
|
5973
5973
|
|
|
5974
|
+
var PENDING_BASE_APPLY = new WeakMap();
|
|
5975
|
+
function restoreBaseApply(e) {
|
|
5976
|
+
var base = PENDING_BASE_APPLY.get(e);
|
|
5977
|
+
if (base) {
|
|
5978
|
+
e.apply = base;
|
|
5979
|
+
PENDING_BASE_APPLY.delete(e);
|
|
5980
|
+
return base;
|
|
5981
|
+
}
|
|
5982
|
+
return e.apply;
|
|
5983
|
+
}
|
|
5984
|
+
function cancelPendingHistorySplit(editor) {
|
|
5985
|
+
restoreBaseApply(editor);
|
|
5986
|
+
}
|
|
5987
|
+
function withIsolatedHistoryBatch(editor, fn) {
|
|
5988
|
+
var e = editor;
|
|
5989
|
+
if (typeof e.undo !== 'function' || !e.history) {
|
|
5990
|
+
fn();
|
|
5991
|
+
return;
|
|
5992
|
+
}
|
|
5993
|
+
var apply = restoreBaseApply(e);
|
|
5994
|
+
var startedBatch = false;
|
|
5995
|
+
e.apply = function (op) {
|
|
5996
|
+
if (!startedBatch) {
|
|
5997
|
+
var undos = e.history.undos;
|
|
5998
|
+
var lenBefore = undos.length;
|
|
5999
|
+
HistoryEditor.withoutMerging(e, function () {
|
|
6000
|
+
apply(op);
|
|
6001
|
+
});
|
|
6002
|
+
if (undos.length > lenBefore) {
|
|
6003
|
+
startedBatch = true;
|
|
6004
|
+
}
|
|
6005
|
+
return;
|
|
6006
|
+
}
|
|
6007
|
+
var prev = HistoryEditor.isMerging(e);
|
|
6008
|
+
MERGING.set(e, true);
|
|
6009
|
+
try {
|
|
6010
|
+
apply(op);
|
|
6011
|
+
} finally {
|
|
6012
|
+
if (prev === undefined) {
|
|
6013
|
+
MERGING.delete(e);
|
|
6014
|
+
} else {
|
|
6015
|
+
MERGING.set(e, prev);
|
|
6016
|
+
}
|
|
6017
|
+
}
|
|
6018
|
+
};
|
|
6019
|
+
try {
|
|
6020
|
+
fn();
|
|
6021
|
+
} finally {
|
|
6022
|
+
e.apply = apply;
|
|
6023
|
+
if (!startedBatch) return;
|
|
6024
|
+
var splitOnce_1 = function splitOnce_1(op) {
|
|
6025
|
+
if (op.type === 'set_selection') {
|
|
6026
|
+
apply(op);
|
|
6027
|
+
return;
|
|
6028
|
+
}
|
|
6029
|
+
if (e.apply === splitOnce_1) {
|
|
6030
|
+
e.apply = apply;
|
|
6031
|
+
}
|
|
6032
|
+
PENDING_BASE_APPLY.delete(e);
|
|
6033
|
+
HistoryEditor.withoutMerging(e, function () {
|
|
6034
|
+
apply(op);
|
|
6035
|
+
});
|
|
6036
|
+
};
|
|
6037
|
+
e.apply = splitOnce_1;
|
|
6038
|
+
PENDING_BASE_APPLY.set(e, apply);
|
|
6039
|
+
}
|
|
6040
|
+
}
|
|
6041
|
+
|
|
6042
|
+
var EDITOR_TO_TYPING_STATE = new WeakMap();
|
|
6043
|
+
function getState(editor) {
|
|
6044
|
+
var state = EDITOR_TO_TYPING_STATE.get(editor);
|
|
6045
|
+
if (!state) {
|
|
6046
|
+
state = {
|
|
6047
|
+
lastContentAt: 0
|
|
6048
|
+
};
|
|
6049
|
+
EDITOR_TO_TYPING_STATE.set(editor, state);
|
|
6050
|
+
}
|
|
6051
|
+
return state;
|
|
6052
|
+
}
|
|
6053
|
+
function shouldSplitTypingBatch(op) {
|
|
6054
|
+
if (op.type === 'insert_text') return true;
|
|
6055
|
+
if (op.type === 'remove_text' && op.text.length === 1) return true;
|
|
6056
|
+
return false;
|
|
6057
|
+
}
|
|
6058
|
+
function resetTypingHistoryState(editor) {
|
|
6059
|
+
EDITOR_TO_TYPING_STATE.delete(editor);
|
|
6060
|
+
}
|
|
6061
|
+
function markTypingHistoryCompositionStart(_editor) {}
|
|
6062
|
+
function markTypingHistoryCompositionEnd(_editor) {}
|
|
6063
|
+
function withTypingHistory(editor) {
|
|
6064
|
+
var e = editor;
|
|
6065
|
+
var apply = e.apply;
|
|
6066
|
+
e.apply = function (op) {
|
|
6067
|
+
if (typeof e.undo !== 'function') {
|
|
6068
|
+
apply(op);
|
|
6069
|
+
return;
|
|
6070
|
+
}
|
|
6071
|
+
var merging = HistoryEditor.isMerging(e);
|
|
6072
|
+
if (merging === true || merging === false) {
|
|
6073
|
+
apply(op);
|
|
6074
|
+
if (op.type === 'insert_text' || op.type === 'remove_text') {
|
|
6075
|
+
getState(e).lastContentAt = Date.now();
|
|
6076
|
+
}
|
|
6077
|
+
return;
|
|
6078
|
+
}
|
|
6079
|
+
if (shouldSplitTypingBatch(op)) {
|
|
6080
|
+
HistoryEditor.withoutMerging(e, function () {
|
|
6081
|
+
apply(op);
|
|
6082
|
+
});
|
|
6083
|
+
getState(e).lastContentAt = Date.now();
|
|
6084
|
+
return;
|
|
6085
|
+
}
|
|
6086
|
+
apply(op);
|
|
6087
|
+
if (op.type !== 'set_selection') {
|
|
6088
|
+
getState(e).lastContentAt = Date.now();
|
|
6089
|
+
}
|
|
6090
|
+
};
|
|
6091
|
+
return e;
|
|
6092
|
+
}
|
|
6093
|
+
|
|
5974
6094
|
function insertElemToEditor(editor, elem) {
|
|
5975
6095
|
if (editor.isInline(elem)) {
|
|
5976
6096
|
editor.insertNode(elem);
|
|
@@ -6136,6 +6256,7 @@ var withContent = function withContent(editor) {
|
|
|
6136
6256
|
e.handleTab = function () {
|
|
6137
6257
|
e.insertText(' ');
|
|
6138
6258
|
};
|
|
6259
|
+
e.handleShiftTab = function () {};
|
|
6139
6260
|
e.getHtml = function () {
|
|
6140
6261
|
var _a = e.children,
|
|
6141
6262
|
children = _a === void 0 ? [] : _a;
|
|
@@ -6171,7 +6292,7 @@ var withContent = function withContent(editor) {
|
|
|
6171
6292
|
var nodeEntry = nodeEntries_1_1.value;
|
|
6172
6293
|
var _b = __read(nodeEntry, 1),
|
|
6173
6294
|
node = _b[0];
|
|
6174
|
-
if (Element.isElement(node)) {
|
|
6295
|
+
if (Element$1.isElement(node)) {
|
|
6175
6296
|
var flag = isPrefix ? node.type.indexOf(type) >= 0 : node.type === type;
|
|
6176
6297
|
if (flag) {
|
|
6177
6298
|
var key = DomEditor.findKey(e, node);
|
|
@@ -6204,7 +6325,7 @@ var withContent = function withContent(editor) {
|
|
|
6204
6325
|
if (children.length > 1) return false;
|
|
6205
6326
|
var firstNode = children[0];
|
|
6206
6327
|
if (firstNode == null) return true;
|
|
6207
|
-
if (Element.isElement(firstNode) && firstNode.type === 'paragraph') {
|
|
6328
|
+
if (Element$1.isElement(firstNode) && firstNode.type === 'paragraph') {
|
|
6208
6329
|
var _b = firstNode.children,
|
|
6209
6330
|
texts = _b === void 0 ? [] : _b;
|
|
6210
6331
|
if (texts.length > 1) return false;
|
|
@@ -6327,28 +6448,40 @@ var withContent = function withContent(editor) {
|
|
|
6327
6448
|
if (html === void 0) {
|
|
6328
6449
|
html = '';
|
|
6329
6450
|
}
|
|
6330
|
-
|
|
6331
|
-
var
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6451
|
+
cancelPendingHistorySplit(e);
|
|
6452
|
+
var applyHtml = function applyHtml() {
|
|
6453
|
+
var isEditorDisabled = e.isDisabled();
|
|
6454
|
+
var isEditorFocused = e.isFocused();
|
|
6455
|
+
var editorSelectionStr = JSON.stringify(e.selection);
|
|
6456
|
+
e.enable();
|
|
6457
|
+
e.focus();
|
|
6458
|
+
e.clear();
|
|
6459
|
+
var newContent = htmlToContent(e, html);
|
|
6460
|
+
Transforms.insertFragment(e, newContent);
|
|
6461
|
+
if (!isEditorFocused) {
|
|
6462
|
+
e.deselect();
|
|
6463
|
+
e.blur();
|
|
6464
|
+
}
|
|
6465
|
+
if (isEditorDisabled) {
|
|
6466
|
+
e.deselect();
|
|
6467
|
+
e.disable();
|
|
6468
|
+
}
|
|
6469
|
+
if (e.isFocused()) {
|
|
6470
|
+
try {
|
|
6471
|
+
e.select(JSON.parse(editorSelectionStr));
|
|
6472
|
+
} catch (ex) {
|
|
6473
|
+
e.select(Editor.start(e, []));
|
|
6474
|
+
}
|
|
6351
6475
|
}
|
|
6476
|
+
};
|
|
6477
|
+
if (typeof e.undo === 'function' && e.history) {
|
|
6478
|
+
HistoryEditor.withoutSaving(e, applyHtml);
|
|
6479
|
+
var history_1 = e.history;
|
|
6480
|
+
history_1.undos = [];
|
|
6481
|
+
history_1.redos = [];
|
|
6482
|
+
resetTypingHistoryState(e);
|
|
6483
|
+
} else {
|
|
6484
|
+
applyHtml();
|
|
6352
6485
|
}
|
|
6353
6486
|
};
|
|
6354
6487
|
return e;
|
|
@@ -6420,47 +6553,49 @@ var withEventData = function withEventData(editor) {
|
|
|
6420
6553
|
return data;
|
|
6421
6554
|
};
|
|
6422
6555
|
e.insertData = function (data) {
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6433
|
-
|
|
6434
|
-
|
|
6435
|
-
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
6442
|
-
var line = lines_1_1.value;
|
|
6443
|
-
if (split) {
|
|
6444
|
-
Transforms.splitNodes(e, {
|
|
6445
|
-
always: true
|
|
6446
|
-
});
|
|
6447
|
-
}
|
|
6448
|
-
insertText(line);
|
|
6449
|
-
split = true;
|
|
6450
|
-
}
|
|
6451
|
-
} catch (e_1_1) {
|
|
6452
|
-
e_1 = {
|
|
6453
|
-
error: e_1_1
|
|
6454
|
-
};
|
|
6455
|
-
} finally {
|
|
6556
|
+
withIsolatedHistoryBatch(e, function () {
|
|
6557
|
+
var e_1, _a;
|
|
6558
|
+
var fragment = data.getData('application/x-slate-fragment');
|
|
6559
|
+
if (fragment) {
|
|
6560
|
+
var decoded = decodeURIComponent(window.atob(fragment));
|
|
6561
|
+
var parsed = JSON.parse(decoded);
|
|
6562
|
+
e.insertFragment(parsed);
|
|
6563
|
+
return;
|
|
6564
|
+
}
|
|
6565
|
+
var text = data.getData('text/plain');
|
|
6566
|
+
var html = data.getData('text/html');
|
|
6567
|
+
if (html) {
|
|
6568
|
+
e.dangerouslyInsertHtml(html);
|
|
6569
|
+
return;
|
|
6570
|
+
}
|
|
6571
|
+
if (text) {
|
|
6572
|
+
var lines = text.split(/\r\n|\r|\n/);
|
|
6573
|
+
var split = false;
|
|
6456
6574
|
try {
|
|
6457
|
-
|
|
6575
|
+
for (var lines_1 = __values(lines), lines_1_1 = lines_1.next(); !lines_1_1.done; lines_1_1 = lines_1.next()) {
|
|
6576
|
+
var line = lines_1_1.value;
|
|
6577
|
+
if (split) {
|
|
6578
|
+
Transforms.splitNodes(e, {
|
|
6579
|
+
always: true
|
|
6580
|
+
});
|
|
6581
|
+
}
|
|
6582
|
+
insertText(line);
|
|
6583
|
+
split = true;
|
|
6584
|
+
}
|
|
6585
|
+
} catch (e_1_1) {
|
|
6586
|
+
e_1 = {
|
|
6587
|
+
error: e_1_1
|
|
6588
|
+
};
|
|
6458
6589
|
} finally {
|
|
6459
|
-
|
|
6590
|
+
try {
|
|
6591
|
+
if (lines_1_1 && !lines_1_1.done && (_a = lines_1.return)) _a.call(lines_1);
|
|
6592
|
+
} finally {
|
|
6593
|
+
if (e_1) throw e_1.error;
|
|
6594
|
+
}
|
|
6460
6595
|
}
|
|
6596
|
+
return;
|
|
6461
6597
|
}
|
|
6462
|
-
|
|
6463
|
-
}
|
|
6598
|
+
});
|
|
6464
6599
|
};
|
|
6465
6600
|
return e;
|
|
6466
6601
|
};
|
|
@@ -6924,8 +7059,8 @@ function getPositionByNode(editor, node, type) {
|
|
|
6924
7059
|
};
|
|
6925
7060
|
var selection = editor.selection;
|
|
6926
7061
|
if (selection == null) return defaultStyle;
|
|
6927
|
-
var isVoidElem = Element.isElement(node) && editor.isVoid(node);
|
|
6928
|
-
var isInlineElem = Element.isElement(node) && editor.isInline(node);
|
|
7062
|
+
var isVoidElem = Element$1.isElement(node) && editor.isVoid(node);
|
|
7063
|
+
var isInlineElem = Element$1.isElement(node) && editor.isInline(node);
|
|
6929
7064
|
var elem = NODE_TO_ELEMENT.get(node);
|
|
6930
7065
|
if (elem == null) return defaultStyle;
|
|
6931
7066
|
var _a = elem.getBoundingClientRect(),
|
|
@@ -7571,7 +7706,7 @@ function node2Vnode(node, index, parent, editor) {
|
|
|
7571
7706
|
NODE_TO_INDEX.set(node, index);
|
|
7572
7707
|
NODE_TO_PARENT.set(node, parent);
|
|
7573
7708
|
var vnode;
|
|
7574
|
-
if (Element.isElement(node)) {
|
|
7709
|
+
if (Element$1.isElement(node)) {
|
|
7575
7710
|
vnode = renderElement(node, editor);
|
|
7576
7711
|
} else {
|
|
7577
7712
|
vnode = renderText(node, parent, editor);
|
|
@@ -8033,7 +8168,7 @@ function handleOnBlur(e, textarea, editor) {
|
|
|
8033
8168
|
}
|
|
8034
8169
|
if (relatedTarget != null && isDOMNode(relatedTarget) && DomEditor.hasDOMNode(editor, relatedTarget)) {
|
|
8035
8170
|
var node = DomEditor.toSlateNode(editor, relatedTarget);
|
|
8036
|
-
if (Element.isElement(node) && !editor.isVoid(node)) {
|
|
8171
|
+
if (Element$1.isElement(node) && !editor.isVoid(node)) {
|
|
8037
8172
|
return;
|
|
8038
8173
|
}
|
|
8039
8174
|
}
|
|
@@ -8122,7 +8257,7 @@ function handleCompositionEnd(e, textarea, editor) {
|
|
|
8122
8257
|
for (var i = 0; i < start.path.length; i++) {
|
|
8123
8258
|
var _b = __read(Editor.node(editor, start.path.slice(0, i + 1)), 1),
|
|
8124
8259
|
node = _b[0];
|
|
8125
|
-
if (Element.isElement(node)) {
|
|
8260
|
+
if (Element$1.isElement(node)) {
|
|
8126
8261
|
if ((IS_SAFARI || IS_FIREFOX) && node.type === 'link' || node.type === 'code') {
|
|
8127
8262
|
DomEditor.setNewKey(paragraph);
|
|
8128
8263
|
break;
|
|
@@ -8177,6 +8312,7 @@ var HOTKEYS = {
|
|
|
8177
8312
|
splitBlock: 'shift?+enter',
|
|
8178
8313
|
undo: 'mod+z',
|
|
8179
8314
|
tab: 'tab',
|
|
8315
|
+
shiftTab: 'shift+tab',
|
|
8180
8316
|
selectAll: 'mod+a'
|
|
8181
8317
|
};
|
|
8182
8318
|
var APPLE_HOTKEYS = {
|
|
@@ -8239,6 +8375,7 @@ var Hotkeys = {
|
|
|
8239
8375
|
isTransposeCharacter: create('transposeCharacter'),
|
|
8240
8376
|
isUndo: create('undo'),
|
|
8241
8377
|
isTab: create('tab'),
|
|
8378
|
+
isShiftTab: create('shiftTab'),
|
|
8242
8379
|
isSelectAll: create('selectAll')
|
|
8243
8380
|
};
|
|
8244
8381
|
|
|
@@ -8271,6 +8408,11 @@ function handleOnKeydown(e, textarea, editor) {
|
|
|
8271
8408
|
if (textarea.isComposing) return;
|
|
8272
8409
|
if (!hasEditableTarget(editor, event.target)) return;
|
|
8273
8410
|
triggerMenuHotKey(editor, event);
|
|
8411
|
+
if (Hotkeys.isShiftTab(event)) {
|
|
8412
|
+
preventDefault(event);
|
|
8413
|
+
editor.handleShiftTab();
|
|
8414
|
+
return;
|
|
8415
|
+
}
|
|
8274
8416
|
if (Hotkeys.isTab(event)) {
|
|
8275
8417
|
preventDefault(event);
|
|
8276
8418
|
editor.handleTab();
|
|
@@ -8464,7 +8606,7 @@ function handleOnKeydown(e, textarea, editor) {
|
|
|
8464
8606
|
if (IS_CHROME || IS_SAFARI) {
|
|
8465
8607
|
if (selection && (Hotkeys.isDeleteBackward(event) || Hotkeys.isDeleteForward(event)) && Range.isCollapsed(selection)) {
|
|
8466
8608
|
var currentNode = Node.parent(editor, selection.anchor.path);
|
|
8467
|
-
if (Element.isElement(currentNode) && Editor.isVoid(editor, currentNode) && Editor.isInline(editor, currentNode)) {
|
|
8609
|
+
if (Element$1.isElement(currentNode) && Editor.isVoid(editor, currentNode) && Editor.isInline(editor, currentNode)) {
|
|
8468
8610
|
event.preventDefault();
|
|
8469
8611
|
Transforms.delete(editor, {
|
|
8470
8612
|
unit: 'block'
|
|
@@ -9149,7 +9291,7 @@ function genModalTextareaElems(labelText, textareaId, placeholder) {
|
|
|
9149
9291
|
}
|
|
9150
9292
|
function genModalButtonElems(buttonId, buttonText) {
|
|
9151
9293
|
var $buttonContainer = $('<div class="button-container"></div>');
|
|
9152
|
-
var $button = $("<button type=\"button\" id=\"" + buttonId + "\">" + buttonText + "</button>");
|
|
9294
|
+
var $button = $("<button type=\"button\" id=\"" + buttonId + "\"><span>" + buttonText + "</span></button>");
|
|
9153
9295
|
$buttonContainer.append($button);
|
|
9154
9296
|
return [$buttonContainer[0], $button[0]];
|
|
9155
9297
|
}
|
|
@@ -9175,7 +9317,7 @@ function (_super) {
|
|
|
9175
9317
|
ModalButton.prototype.getPosition = function () {
|
|
9176
9318
|
var editor = getEditorInstance(this);
|
|
9177
9319
|
var positionNode = this.menu.getModalPositionNode(editor);
|
|
9178
|
-
if (Element.isElement(positionNode)) {
|
|
9320
|
+
if (Element$1.isElement(positionNode)) {
|
|
9179
9321
|
return getPositionByNode(editor, positionNode, 'modal');
|
|
9180
9322
|
}
|
|
9181
9323
|
return getPositionBySelection(editor);
|
|
@@ -9253,6 +9395,10 @@ function (_super) {
|
|
|
9253
9395
|
});
|
|
9254
9396
|
return _this;
|
|
9255
9397
|
}
|
|
9398
|
+
SelectList.findOptionLi = function (target) {
|
|
9399
|
+
if (!(target instanceof Element)) return null;
|
|
9400
|
+
return target.closest('li[data-value]');
|
|
9401
|
+
};
|
|
9256
9402
|
SelectList.prototype.renderList = function (options) {
|
|
9257
9403
|
var $elem = this.$elem;
|
|
9258
9404
|
$elem.empty();
|
|
@@ -9350,11 +9496,11 @@ function () {
|
|
|
9350
9496
|
selectList.appendTo(this.$elem);
|
|
9351
9497
|
selectList.show();
|
|
9352
9498
|
selectList.$elem.on('click', 'li', function (e) {
|
|
9353
|
-
var
|
|
9354
|
-
if (
|
|
9499
|
+
var li = SelectList.findOptionLi(e.target);
|
|
9500
|
+
if (li == null) return;
|
|
9355
9501
|
e.preventDefault();
|
|
9356
|
-
var
|
|
9357
|
-
|
|
9502
|
+
var val = $(li).attr('data-value');
|
|
9503
|
+
if (val == null || val === '') return;
|
|
9358
9504
|
_this.onChange(val);
|
|
9359
9505
|
});
|
|
9360
9506
|
} else {
|
|
@@ -9546,7 +9692,7 @@ function () {
|
|
|
9546
9692
|
if (node != null) {
|
|
9547
9693
|
_this.changeItemsState();
|
|
9548
9694
|
}
|
|
9549
|
-
if (node && Element.isElement(node)) {
|
|
9695
|
+
if (node && Element$1.isElement(node)) {
|
|
9550
9696
|
if (isShow) {
|
|
9551
9697
|
var samePath = _this.isSamePath(node, _this.prevSelectedNode);
|
|
9552
9698
|
if (samePath) {
|
|
@@ -9591,16 +9737,15 @@ function () {
|
|
|
9591
9737
|
};
|
|
9592
9738
|
HoverBar.prototype.checkPositionBottom = function () {
|
|
9593
9739
|
var $elem = this.$elem;
|
|
9594
|
-
var isBottom = false;
|
|
9595
9740
|
var innerHeight = window.innerHeight;
|
|
9596
|
-
|
|
9597
|
-
|
|
9598
|
-
|
|
9599
|
-
if (innerHeight - bottom < minDistance) {
|
|
9600
|
-
isBottom = true;
|
|
9601
|
-
}
|
|
9741
|
+
if (!innerHeight) {
|
|
9742
|
+
$elem.removeClass('w-e-bar-bottom');
|
|
9743
|
+
return;
|
|
9602
9744
|
}
|
|
9603
|
-
|
|
9745
|
+
var rect = $elem[0].getBoundingClientRect();
|
|
9746
|
+
var spaceBelow = Math.max(0, innerHeight - rect.bottom - 8);
|
|
9747
|
+
var panelNeed = 240;
|
|
9748
|
+
if (spaceBelow < panelNeed) {
|
|
9604
9749
|
$elem.addClass('w-e-bar-bottom');
|
|
9605
9750
|
} else {
|
|
9606
9751
|
$elem.removeClass('w-e-bar-bottom');
|
|
@@ -9656,7 +9801,7 @@ function () {
|
|
|
9656
9801
|
var editor = this.getEditorInstance();
|
|
9657
9802
|
var $elem = this.$elem;
|
|
9658
9803
|
$elem.attr('style', '');
|
|
9659
|
-
if (Element.isElement(node)) {
|
|
9804
|
+
if (Element$1.isElement(node)) {
|
|
9660
9805
|
var positionStyle = getPositionByNode(editor, node, 'bar');
|
|
9661
9806
|
$elem.css(positionStyle);
|
|
9662
9807
|
correctPosition(editor, $elem);
|
|
@@ -9786,7 +9931,7 @@ function genToolbarConfig(userConfig) {
|
|
|
9786
9931
|
function bindNodeRelation(node, index, parent, editor) {
|
|
9787
9932
|
NODE_TO_INDEX.set(node, index);
|
|
9788
9933
|
NODE_TO_PARENT.set(node, parent);
|
|
9789
|
-
if (Element.isElement(node)) {
|
|
9934
|
+
if (Element$1.isElement(node)) {
|
|
9790
9935
|
var _a = node.children,
|
|
9791
9936
|
children = _a === void 0 ? [] : _a;
|
|
9792
9937
|
children.forEach(function (child, i) {
|
|
@@ -9812,7 +9957,7 @@ function createEditor (option) {
|
|
|
9812
9957
|
html = option.html,
|
|
9813
9958
|
_c = option.plugins,
|
|
9814
9959
|
plugins = _c === void 0 ? [] : _c;
|
|
9815
|
-
var editor = withHistory(withMaxLength(withEmitter(withSelection(withContent(withConfig(withDOM(withEventData(createEditor$1()))))))));
|
|
9960
|
+
var editor = withTypingHistory(withHistory(withMaxLength(withEmitter(withSelection(withContent(withConfig(withDOM(withEventData(createEditor$1())))))))));
|
|
9816
9961
|
if (selector) {
|
|
9817
9962
|
if (isRepeatedCreateTextarea(editor, selector)) {
|
|
9818
9963
|
throw new Error("Repeated create editor by selector '" + selector + "'");
|
|
@@ -12795,7 +12940,7 @@ function getEditorNodeAtPath(editor, path) {
|
|
|
12795
12940
|
}
|
|
12796
12941
|
}
|
|
12797
12942
|
function isBlankParagraphNode(node) {
|
|
12798
|
-
if (!node || !Element.isElement(node)) return false;
|
|
12943
|
+
if (!node || !Element$1.isElement(node)) return false;
|
|
12799
12944
|
if (node.type !== 'paragraph') return false;
|
|
12800
12945
|
var text = Node.string(node);
|
|
12801
12946
|
return text.replace(/[\u200B\uFEFF\s]/g, '').length === 0;
|
|
@@ -12910,5 +13055,5 @@ function resolveElemPath(editor, elem) {
|
|
|
12910
13055
|
return null;
|
|
12911
13056
|
}
|
|
12912
13057
|
|
|
12913
|
-
export { DomEditor, ELEM_TO_HTML_CONF, PARSE_ELEM_HTML_CONF, PARSE_STYLE_HTML_FN_LIST, PRE_PARSE_HTML_CONF_LIST, RENDER_ELEM_CONF, RENDER_STYLE_HANDLER_LIST, STYLE_TO_HTML_FN_LIST, TEXT_TAGS, Toolbar, canRemoveEmptyLineAboveBlock, createEditor as coreCreateEditor, createToolbar as coreCreateToolbar, createUploader, execMenuByKey, findEditorScrollParent, genEmptyParagraph, genModalButtonElems, genModalInputElems, genModalTextareaElems, getEditorNodeAtPath, i18nAddResources, i18nChangeLanguage, i18nGetResources, insertEmptyLineAboveAtPath, isBlankParagraphNode, pinEditorScrollDuring, registerElemToHtmlConf, registerMenu, registerParseElemHtmlConf, registerParseStyleHtmlHandler, registerPreParseHtmlConf, registerRenderElemConf, registerStyleHandler, registerStyleToHtmlHandler, removeEmptyLineAboveTopLevelBlock, replaceBlockWithEmptyLine, resolveElemPath, setBlockToParagraph, t };
|
|
13058
|
+
export { DomEditor, ELEM_TO_HTML_CONF, PARSE_ELEM_HTML_CONF, PARSE_STYLE_HTML_FN_LIST, PRE_PARSE_HTML_CONF_LIST, RENDER_ELEM_CONF, RENDER_STYLE_HANDLER_LIST, STYLE_TO_HTML_FN_LIST, TEXT_TAGS, Toolbar, canRemoveEmptyLineAboveBlock, cancelPendingHistorySplit, createEditor as coreCreateEditor, createToolbar as coreCreateToolbar, createUploader, execMenuByKey, findEditorScrollParent, genEmptyParagraph, genModalButtonElems, genModalInputElems, genModalTextareaElems, getEditorNodeAtPath, i18nAddResources, i18nChangeLanguage, i18nGetResources, insertEmptyLineAboveAtPath, isBlankParagraphNode, markTypingHistoryCompositionEnd, markTypingHistoryCompositionStart, pinEditorScrollDuring, registerElemToHtmlConf, registerMenu, registerParseElemHtmlConf, registerParseStyleHtmlHandler, registerPreParseHtmlConf, registerRenderElemConf, registerStyleHandler, registerStyleToHtmlHandler, removeEmptyLineAboveTopLevelBlock, replaceBlockWithEmptyLine, resetTypingHistoryState, resolveElemPath, setBlockToParagraph, t, withIsolatedHistoryBatch, withTypingHistory };
|
|
12914
13059
|
//# sourceMappingURL=index.esm.js.map
|