@mnykj/wangeditoroptimize-core 1.0.0
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/README.md +13 -0
- package/dist/core/src/config/index.d.ts +13 -0
- package/dist/core/src/config/interface.d.ts +58 -0
- package/dist/core/src/config/register.d.ts +12 -0
- package/dist/core/src/constants/index.d.ts +1 -0
- package/dist/core/src/constants/svg.d.ts +12 -0
- package/dist/core/src/create/bind-node-relation.d.ts +15 -0
- package/dist/core/src/create/create-editor.d.ts +21 -0
- package/dist/core/src/create/create-toolbar.d.ts +14 -0
- package/dist/core/src/create/helper.d.ts +30 -0
- package/dist/core/src/create/index.d.ts +7 -0
- package/dist/core/src/editor/dom-editor.d.ts +143 -0
- package/dist/core/src/editor/interface.d.ts +67 -0
- package/dist/core/src/editor/plugins/with-config.d.ts +6 -0
- package/dist/core/src/editor/plugins/with-content.d.ts +6 -0
- package/dist/core/src/editor/plugins/with-dom.d.ts +9 -0
- package/dist/core/src/editor/plugins/with-emitter.d.ts +6 -0
- package/dist/core/src/editor/plugins/with-event-data.d.ts +6 -0
- package/dist/core/src/editor/plugins/with-max-length.d.ts +6 -0
- package/dist/core/src/editor/plugins/with-selection.d.ts +6 -0
- package/dist/core/src/i18n/index.d.ts +26 -0
- package/dist/core/src/index.d.ts +33 -0
- package/dist/core/src/menus/bar/HoverBar.d.ts +47 -0
- package/dist/core/src/menus/bar/Toolbar.d.ts +33 -0
- package/dist/core/src/menus/bar-item/BaseButton.d.ts +24 -0
- package/dist/core/src/menus/bar-item/DropPanelButton.d.ts +14 -0
- package/dist/core/src/menus/bar-item/GroupButton.d.ts +17 -0
- package/dist/core/src/menus/bar-item/ModalButton.d.ts +25 -0
- package/dist/core/src/menus/bar-item/Select.d.ts +22 -0
- package/dist/core/src/menus/bar-item/SimpleButton.d.ts +11 -0
- package/dist/core/src/menus/bar-item/index.d.ts +24 -0
- package/dist/core/src/menus/bar-item/tooltip.d.ts +6 -0
- package/dist/core/src/menus/helpers/helpers.d.ts +18 -0
- package/dist/core/src/menus/helpers/position.d.ts +36 -0
- package/dist/core/src/menus/index.d.ts +9 -0
- package/dist/core/src/menus/interface.d.ts +64 -0
- package/dist/core/src/menus/panel-and-modal/BaseClass.d.ts +26 -0
- package/dist/core/src/menus/panel-and-modal/DropPanel.d.ts +14 -0
- package/dist/core/src/menus/panel-and-modal/Modal.d.ts +44 -0
- package/dist/core/src/menus/panel-and-modal/SelectList.d.ts +20 -0
- package/dist/core/src/menus/register.d.ts +21 -0
- package/dist/core/src/parse-html/helper.d.ts +10 -0
- package/dist/core/src/parse-html/index.d.ts +35 -0
- package/dist/core/src/parse-html/parse-common-elem-html.d.ts +15 -0
- package/dist/core/src/parse-html/parse-elem-html.d.ts +15 -0
- package/dist/core/src/parse-html/parse-text-elem-html.d.ts +15 -0
- package/dist/core/src/render/element/getRenderElem.d.ts +11 -0
- package/dist/core/src/render/element/renderElement.d.ts +9 -0
- package/dist/core/src/render/element/renderStyle.d.ts +13 -0
- package/dist/core/src/render/helper.d.ts +6 -0
- package/dist/core/src/render/index.d.ts +27 -0
- package/dist/core/src/render/node2Vnode.d.ts +15 -0
- package/dist/core/src/render/text/genVnode.d.ts +9 -0
- package/dist/core/src/render/text/renderStyle.d.ts +13 -0
- package/dist/core/src/render/text/renderText.d.ts +9 -0
- package/dist/core/src/text-area/TextArea.d.ts +47 -0
- package/dist/core/src/text-area/event-handlers/beforeInput.d.ts +8 -0
- package/dist/core/src/text-area/event-handlers/blur.d.ts +8 -0
- package/dist/core/src/text-area/event-handlers/click.d.ts +8 -0
- package/dist/core/src/text-area/event-handlers/composition.d.ts +27 -0
- package/dist/core/src/text-area/event-handlers/copy.d.ts +8 -0
- package/dist/core/src/text-area/event-handlers/cut.d.ts +8 -0
- package/dist/core/src/text-area/event-handlers/drag.d.ts +9 -0
- package/dist/core/src/text-area/event-handlers/drop.d.ts +8 -0
- package/dist/core/src/text-area/event-handlers/focus.d.ts +8 -0
- package/dist/core/src/text-area/event-handlers/index.d.ts +35 -0
- package/dist/core/src/text-area/event-handlers/keydown.d.ts +8 -0
- package/dist/core/src/text-area/event-handlers/keypress.d.ts +8 -0
- package/dist/core/src/text-area/event-handlers/paste.d.ts +8 -0
- package/dist/core/src/text-area/helpers.d.ts +26 -0
- package/dist/core/src/text-area/place-holder.d.ts +18 -0
- package/dist/core/src/text-area/syncSelection.d.ts +19 -0
- package/dist/core/src/text-area/update-view.d.ts +13 -0
- package/dist/core/src/to-html/elem2html.d.ts +8 -0
- package/dist/core/src/to-html/index.d.ts +32 -0
- package/dist/core/src/to-html/node2html.d.ts +8 -0
- package/dist/core/src/to-html/text2html.d.ts +8 -0
- package/dist/core/src/upload/createUploader.d.ts +8 -0
- package/dist/core/src/upload/index.d.ts +7 -0
- package/dist/core/src/upload/interface.d.ts +28 -0
- package/dist/core/src/utils/block-helpers.d.ts +19 -0
- package/dist/core/src/utils/dom.d.ts +98 -0
- package/dist/core/src/utils/hotkeys.d.ts +35 -0
- package/dist/core/src/utils/key.d.ts +11 -0
- package/dist/core/src/utils/line.d.ts +14 -0
- package/dist/core/src/utils/pin-scroll.d.ts +12 -0
- package/dist/core/src/utils/ua.d.ts +14 -0
- package/dist/core/src/utils/util.d.ts +27 -0
- package/dist/core/src/utils/vdom.d.ts +34 -0
- package/dist/core/src/utils/weak-maps.d.ts +56 -0
- package/dist/css/style.css +1 -0
- package/dist/index.esm.js +12914 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 处理 click 事件
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../../editor/interface';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
7
|
+
declare function handleOnClick(event: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
8
|
+
export default handleOnClick;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 监听 composition 事件
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../../editor/interface';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
7
|
+
/**
|
|
8
|
+
* composition start 事件
|
|
9
|
+
* @param e event
|
|
10
|
+
* @param textarea textarea
|
|
11
|
+
* @param editor editor
|
|
12
|
+
*/
|
|
13
|
+
export declare function handleCompositionStart(e: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
14
|
+
/**
|
|
15
|
+
* composition update 事件
|
|
16
|
+
* @param e event
|
|
17
|
+
* @param textarea textarea
|
|
18
|
+
* @param editor editor
|
|
19
|
+
*/
|
|
20
|
+
export declare function handleCompositionUpdate(event: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
21
|
+
/**
|
|
22
|
+
* composition end 事件
|
|
23
|
+
* @param e event
|
|
24
|
+
* @param textarea textarea
|
|
25
|
+
* @param editor editor
|
|
26
|
+
*/
|
|
27
|
+
export declare function handleCompositionEnd(e: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 处理 copy 事件
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../../editor/interface';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
7
|
+
declare function handleOnCopy(e: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
8
|
+
export default handleOnCopy;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 处理 cut 事件
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../../editor/interface';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
7
|
+
declare function handleOnCut(e: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
8
|
+
export default handleOnCut;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 处理 dragover 事件
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../../editor/interface';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
7
|
+
export declare function handleOnDragstart(e: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
8
|
+
export declare function handleOnDragover(event: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
9
|
+
export declare function handleOnDragend(e: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 处理 drop 事件
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../../editor/interface';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
7
|
+
declare function handleOnDrop(e: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
8
|
+
export default handleOnDrop;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 处理 onfocus 事件
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../../editor/interface';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
7
|
+
declare function handleOnFocus(event: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
8
|
+
export default handleOnFocus;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description textarea event handlers entry
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import handleBeforeInput from './beforeInput';
|
|
6
|
+
import handleOnBlur from './blur';
|
|
7
|
+
import handleOnFocus from './focus';
|
|
8
|
+
import handleOnClick from './click';
|
|
9
|
+
import { handleCompositionStart, handleCompositionEnd, handleCompositionUpdate } from './composition';
|
|
10
|
+
import handleOnKeydown from './keydown';
|
|
11
|
+
import handleKeypress from './keypress';
|
|
12
|
+
import handleOnCopy from './copy';
|
|
13
|
+
import handleOnCut from './cut';
|
|
14
|
+
import handleOnPaste from './paste';
|
|
15
|
+
import { handleOnDragover, handleOnDragstart, handleOnDragend } from './drag';
|
|
16
|
+
import handleOnDrop from './drop';
|
|
17
|
+
declare const eventConf: {
|
|
18
|
+
beforeinput: typeof handleBeforeInput;
|
|
19
|
+
blur: typeof handleOnBlur;
|
|
20
|
+
focus: typeof handleOnFocus;
|
|
21
|
+
click: typeof handleOnClick;
|
|
22
|
+
compositionstart: typeof handleCompositionStart;
|
|
23
|
+
compositionend: typeof handleCompositionEnd;
|
|
24
|
+
compositionupdate: typeof handleCompositionUpdate;
|
|
25
|
+
keydown: typeof handleOnKeydown;
|
|
26
|
+
keypress: typeof handleKeypress;
|
|
27
|
+
copy: typeof handleOnCopy;
|
|
28
|
+
cut: typeof handleOnCut;
|
|
29
|
+
paste: typeof handleOnPaste;
|
|
30
|
+
dragover: typeof handleOnDragover;
|
|
31
|
+
dragstart: typeof handleOnDragstart;
|
|
32
|
+
dragend: typeof handleOnDragend;
|
|
33
|
+
drop: typeof handleOnDrop;
|
|
34
|
+
};
|
|
35
|
+
export default eventConf;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 监听 onKeydown 事件
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../../editor/interface';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
7
|
+
declare function handleOnKeydown(e: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
8
|
+
export default handleOnKeydown;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 监听 keypress 事件
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../../editor/interface';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
7
|
+
declare function handleKeypress(event: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
8
|
+
export default handleKeypress;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 处理 paste 事件
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../../editor/interface';
|
|
6
|
+
import TextArea from '../TextArea';
|
|
7
|
+
declare function handleOnPaste(e: Event, textarea: TextArea, editor: IDomEditor): void;
|
|
8
|
+
export default handleOnPaste;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description textarea helper fns
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { DOMRange, DOMNode } from '../utils/dom';
|
|
6
|
+
import { IDomEditor } from '../editor/interface';
|
|
7
|
+
/**
|
|
8
|
+
* Check if two DOM range objects are equal.
|
|
9
|
+
*/
|
|
10
|
+
export declare const isRangeEqual: (a: DOMRange, b: DOMRange) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Check if the target is editable and in the editor.
|
|
13
|
+
*/
|
|
14
|
+
export declare function hasEditableTarget(editor: IDomEditor, target: EventTarget | null): target is DOMNode;
|
|
15
|
+
/**
|
|
16
|
+
* Check if the target is inside void and in an non-readonly editor.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isTargetInsideNonReadonlyVoid(editor: IDomEditor, target: EventTarget | null): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Check if the target is in the editor.
|
|
21
|
+
*/
|
|
22
|
+
export declare function hasTarget(editor: IDomEditor, target: EventTarget | null): target is DOMNode;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a DOM event is overrode by a handler.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isDOMEventHandled(event: Event, handler?: (event: Event) => void | boolean): boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 显示/隐藏 placeholder
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../editor/interface';
|
|
6
|
+
import TextArea from './TextArea';
|
|
7
|
+
/**
|
|
8
|
+
* 处理 placeholder
|
|
9
|
+
* @param textarea textarea
|
|
10
|
+
* @param editor editor
|
|
11
|
+
*/
|
|
12
|
+
export declare function handlePlaceholder(textarea: TextArea, editor: IDomEditor): void;
|
|
13
|
+
/**
|
|
14
|
+
* 隐藏 placeholder (如拼音输入 compositionStart 时,要先隐藏,等 compositionEnd 时再判断是否显示)
|
|
15
|
+
* @param textarea textarea
|
|
16
|
+
* @param editor editor
|
|
17
|
+
*/
|
|
18
|
+
export declare function hidePlaceholder(textarea: TextArea, editor: IDomEditor): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 同步 selection
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../editor/interface';
|
|
6
|
+
import TextArea from './TextArea';
|
|
7
|
+
/**
|
|
8
|
+
* editor onchange 时,将 editor selection 同步给 DOM
|
|
9
|
+
* @param textarea textarea
|
|
10
|
+
* @param editor editor
|
|
11
|
+
* @param focus 是否强制更新选区
|
|
12
|
+
*/
|
|
13
|
+
export declare function editorSelectionToDOM(textarea: TextArea, editor: IDomEditor, focus?: boolean): void;
|
|
14
|
+
/**
|
|
15
|
+
* DOM selection change 时,把 DOM selection 同步给 slate
|
|
16
|
+
* @param textarea textarea
|
|
17
|
+
* @param editor editor
|
|
18
|
+
*/
|
|
19
|
+
export declare function DOMSelectionToEditor(textarea: TextArea, editor: IDomEditor): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description patch textarea view
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { IDomEditor } from '../editor/interface';
|
|
6
|
+
import TextArea from './TextArea';
|
|
7
|
+
/**
|
|
8
|
+
* 获取 editor.children 渲染 DOM
|
|
9
|
+
* @param textarea textarea
|
|
10
|
+
* @param editor editor
|
|
11
|
+
*/
|
|
12
|
+
declare function updateView(textarea: TextArea, editor: IDomEditor): void;
|
|
13
|
+
export default updateView;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description to-html entry
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { Element as SlateElement, Descendant } from 'slate';
|
|
6
|
+
import { IDomEditor } from '../editor/interface';
|
|
7
|
+
export declare type styleToHtmlFnType = (node: Descendant, elemHtml: string) => string;
|
|
8
|
+
export declare const STYLE_TO_HTML_FN_LIST: styleToHtmlFnType[];
|
|
9
|
+
/**
|
|
10
|
+
* 注册 toHtml 处理文本样式的函数
|
|
11
|
+
* @param fn 处理 toHtml 文本样式的函数
|
|
12
|
+
*/
|
|
13
|
+
export declare function registerStyleToHtmlHandler(fn: styleToHtmlFnType): void;
|
|
14
|
+
interface IElemToHtmlRes {
|
|
15
|
+
html: string;
|
|
16
|
+
prefix?: string;
|
|
17
|
+
suffix?: string;
|
|
18
|
+
}
|
|
19
|
+
export declare type ElemToHtmlFnType = (elemNode: SlateElement, childrenHtml: string, editor?: IDomEditor) => string | IElemToHtmlRes;
|
|
20
|
+
export declare const ELEM_TO_HTML_CONF: {
|
|
21
|
+
[key: string]: ElemToHtmlFnType;
|
|
22
|
+
};
|
|
23
|
+
export interface IElemToHtmlConf {
|
|
24
|
+
type: string;
|
|
25
|
+
elemToHtml: ElemToHtmlFnType;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 注册 elem to html 函数
|
|
29
|
+
* @param conf { type, elemToHtml } ,type 即 node.type
|
|
30
|
+
*/
|
|
31
|
+
export declare function registerElemToHtmlConf(conf: IElemToHtmlConf): void;
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description upload interface
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { UppyFile } from '@uppy/core';
|
|
6
|
+
declare type FilesType = {
|
|
7
|
+
[key: string]: UppyFile<{}, {}>;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* 配置参考 https://uppy.io/docs/uppy/
|
|
11
|
+
*/
|
|
12
|
+
export interface IUploadConfig {
|
|
13
|
+
server: string;
|
|
14
|
+
fieldName?: string;
|
|
15
|
+
maxFileSize?: number;
|
|
16
|
+
maxNumberOfFiles?: number;
|
|
17
|
+
meta?: Record<string, unknown>;
|
|
18
|
+
metaWithUrl: boolean;
|
|
19
|
+
headers?: Headers | ((file: UppyFile<Record<string, unknown>, Record<string, unknown>>) => Headers) | undefined;
|
|
20
|
+
withCredentials?: boolean;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
onBeforeUpload?: (files: FilesType) => boolean | FilesType;
|
|
23
|
+
onSuccess: (file: UppyFile<{}, {}>, response: any) => void;
|
|
24
|
+
onProgress?: (progress: number) => void;
|
|
25
|
+
onFailed: (file: UppyFile<{}, {}>, response: any) => void;
|
|
26
|
+
onError: (file: UppyFile<{}, {}>, error: any, res: any) => void;
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 顶级块:上方空行 / 原位删除留空段
|
|
3
|
+
*/
|
|
4
|
+
import { Element, Node, Path } from 'slate';
|
|
5
|
+
import { IDomEditor } from '../editor/interface';
|
|
6
|
+
export declare function getEditorNodeAtPath(editor: IDomEditor, path: Path): Node | null;
|
|
7
|
+
export declare function isBlankParagraphNode(node: Node | null): boolean;
|
|
8
|
+
export declare function genEmptyParagraph(editor?: IDomEditor): Element;
|
|
9
|
+
/** 在指定顶级块上方插入空行并选中 */
|
|
10
|
+
export declare function insertEmptyLineAboveAtPath(editor: IDomEditor, path: Path): boolean;
|
|
11
|
+
/** 紧挨当前块上方是否有可删的空段落 */
|
|
12
|
+
export declare function canRemoveEmptyLineAboveBlock(editor: IDomEditor, blockPath: Path): boolean;
|
|
13
|
+
/** 删除紧挨当前块上方的空行,光标仍留在当前块内 */
|
|
14
|
+
export declare function removeEmptyLineAboveTopLevelBlock(editor: IDomEditor, blockPath: Path): boolean;
|
|
15
|
+
/** 整块删除后:在原位保留一个空白行,光标放到开头 */
|
|
16
|
+
export declare function replaceBlockWithEmptyLine(editor: IDomEditor, path: Path, node: Node): boolean;
|
|
17
|
+
/** 将块类型改为 paragraph(取消引用等) */
|
|
18
|
+
export declare function setBlockToParagraph(editor: IDomEditor, path: Path): boolean;
|
|
19
|
+
export declare function resolveElemPath(editor: IDomEditor, elem: Node): Path | null;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description DOM 操作 part1 - DOM7 文档 https://framework7.io/docs/dom7.html
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import $, { Dom7Array } from 'dom7';
|
|
6
|
+
export { Dom7Array } from 'dom7';
|
|
7
|
+
export default $;
|
|
8
|
+
import DOMNode = globalThis.Node;
|
|
9
|
+
import DOMComment = globalThis.Comment;
|
|
10
|
+
import DOMElement = globalThis.Element;
|
|
11
|
+
import DOMText = globalThis.Text;
|
|
12
|
+
import DOMRange = globalThis.Range;
|
|
13
|
+
import DOMSelection = globalThis.Selection;
|
|
14
|
+
import DOMStaticRange = globalThis.StaticRange;
|
|
15
|
+
export { DOMNode, DOMComment, DOMElement, DOMText, DOMRange, DOMSelection, DOMStaticRange };
|
|
16
|
+
export declare type DOMPoint = [Node, number];
|
|
17
|
+
/**
|
|
18
|
+
* Returns the host window of a DOM node
|
|
19
|
+
*/
|
|
20
|
+
export declare const getDefaultView: (value: any) => Window | null;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a DOM node is a comment node.
|
|
23
|
+
*/
|
|
24
|
+
export declare const isDOMComment: (value: any) => value is DOMComment;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a DOM node is an element node.
|
|
27
|
+
*/
|
|
28
|
+
export declare const isDOMElement: (value: any) => value is DOMElement;
|
|
29
|
+
/**
|
|
30
|
+
* Check if a value is a DOM node.
|
|
31
|
+
*/
|
|
32
|
+
export declare const isDOMNode: (value: any) => value is DOMNode;
|
|
33
|
+
/**
|
|
34
|
+
* Check if a value is a DOM selection.
|
|
35
|
+
*/
|
|
36
|
+
export declare const isDOMSelection: (value: any) => value is DOMSelection;
|
|
37
|
+
/**
|
|
38
|
+
* Check if a DOM node is an element node.
|
|
39
|
+
*/
|
|
40
|
+
export declare const isDOMText: (value: any) => value is DOMText;
|
|
41
|
+
/**
|
|
42
|
+
* Checks whether a paste event is a plaintext-only event.
|
|
43
|
+
*/
|
|
44
|
+
export declare const isPlainTextOnlyPaste: (event: ClipboardEvent) => boolean | null;
|
|
45
|
+
/**
|
|
46
|
+
* Normalize a DOM point so that it always refers to a text node.
|
|
47
|
+
*/
|
|
48
|
+
export declare const normalizeDOMPoint: (domPoint: DOMPoint) => DOMPoint;
|
|
49
|
+
/**
|
|
50
|
+
* Determines wether the active element is nested within a shadowRoot
|
|
51
|
+
*/
|
|
52
|
+
export declare const hasShadowRoot: () => boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Get the element with the specified id
|
|
55
|
+
*/
|
|
56
|
+
export declare const getElementById: (id: string) => null | HTMLElement;
|
|
57
|
+
/**
|
|
58
|
+
* Get the nearest editable child and index at `index` in a `parent`, preferring `direction`.
|
|
59
|
+
*/
|
|
60
|
+
export declare const getEditableChildAndIndex: (parent: DOMElement, index: number, direction: 'forward' | 'backward') => [DOMNode, number];
|
|
61
|
+
/**
|
|
62
|
+
* Get the nearest editable child at `index` in a `parent`, preferring
|
|
63
|
+
* `direction`.
|
|
64
|
+
*/
|
|
65
|
+
export declare const getEditableChild: (parent: DOMElement, index: number, direction: 'forward' | 'backward') => DOMNode;
|
|
66
|
+
/**
|
|
67
|
+
* Get a plaintext representation of the content of a node, accounting for block
|
|
68
|
+
* elements which get a newline appended.
|
|
69
|
+
*
|
|
70
|
+
* The domNode must be attached to the DOM.
|
|
71
|
+
*/
|
|
72
|
+
export declare const getPlainText: (domNode: DOMNode) => string;
|
|
73
|
+
/**
|
|
74
|
+
* 在下级节点中找到第一个 void elem
|
|
75
|
+
* @param elem elem
|
|
76
|
+
*/
|
|
77
|
+
export declare function getFirstVoidChild(elem: DOMElement): DOMElement | null;
|
|
78
|
+
/**
|
|
79
|
+
* 遍历一个 elem 内所有的 text node ,执行函数
|
|
80
|
+
* @param elem elem
|
|
81
|
+
* @param handler handler
|
|
82
|
+
*/
|
|
83
|
+
export declare function walkTextNodes(elem: DOMElement, handler: (textNode: DOMNode, parent: DOMElement) => void): void;
|
|
84
|
+
export declare enum NodeType {
|
|
85
|
+
ELEMENT_NODE = 1,
|
|
86
|
+
TEXT_NODE = 3,
|
|
87
|
+
CDATA_SECTION_NODE = 4,
|
|
88
|
+
PROCESSING_INSTRUCTION_NODE = 7,
|
|
89
|
+
COMMENT_NODE = 8,
|
|
90
|
+
DOCUMENT_NODE = 9,
|
|
91
|
+
DOCUMENT_TYPE_NODE = 10,
|
|
92
|
+
DOCUMENT_FRAGMENT_NODE = 11
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 获取 tagName lower-case
|
|
96
|
+
* @param $elem $elem
|
|
97
|
+
*/
|
|
98
|
+
export declare function getTagName($elem: Dom7Array): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 快捷键
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
declare const _default: {
|
|
6
|
+
isBold: (event: KeyboardEvent) => boolean;
|
|
7
|
+
isCompose: (event: KeyboardEvent) => boolean;
|
|
8
|
+
isMoveBackward: (event: KeyboardEvent) => boolean;
|
|
9
|
+
isMoveForward: (event: KeyboardEvent) => boolean;
|
|
10
|
+
isDeleteBackward: (event: KeyboardEvent) => boolean;
|
|
11
|
+
isDeleteForward: (event: KeyboardEvent) => boolean;
|
|
12
|
+
isDeleteLineBackward: (event: KeyboardEvent) => boolean;
|
|
13
|
+
isDeleteLineForward: (event: KeyboardEvent) => boolean;
|
|
14
|
+
isDeleteWordBackward: (event: KeyboardEvent) => boolean;
|
|
15
|
+
isDeleteWordForward: (event: KeyboardEvent) => boolean;
|
|
16
|
+
isExtendBackward: (event: KeyboardEvent) => boolean;
|
|
17
|
+
isExtendForward: (event: KeyboardEvent) => boolean;
|
|
18
|
+
isExtendLineBackward: (event: KeyboardEvent) => boolean;
|
|
19
|
+
isExtendLineForward: (event: KeyboardEvent) => boolean;
|
|
20
|
+
isItalic: (event: KeyboardEvent) => boolean;
|
|
21
|
+
isMoveLineBackward: (event: KeyboardEvent) => boolean;
|
|
22
|
+
isMoveLineForward: (event: KeyboardEvent) => boolean;
|
|
23
|
+
isMoveWordBackward: (event: KeyboardEvent) => boolean;
|
|
24
|
+
isMoveWordForward: (event: KeyboardEvent) => boolean;
|
|
25
|
+
isRedo: (event: KeyboardEvent) => boolean;
|
|
26
|
+
isSplitBlock: (event: KeyboardEvent) => boolean;
|
|
27
|
+
isTransposeCharacter: (event: KeyboardEvent) => boolean;
|
|
28
|
+
isUndo: (event: KeyboardEvent) => boolean;
|
|
29
|
+
isTab: (event: KeyboardEvent) => boolean;
|
|
30
|
+
isSelectAll: (event: KeyboardEvent) => boolean;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Hotkeys.
|
|
34
|
+
*/
|
|
35
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An auto-incrementing identifier for keys.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* A class that keeps track of a key string. We use a full class here because we
|
|
6
|
+
* want to be able to use them as keys in `WeakMap` objects.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Key {
|
|
9
|
+
id: string;
|
|
10
|
+
constructor();
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Utilities for single-line deletion
|
|
3
|
+
*/
|
|
4
|
+
import { Range } from 'slate';
|
|
5
|
+
import { IDomEditor } from '../editor/interface';
|
|
6
|
+
/**
|
|
7
|
+
* A helper utility that returns the end portion of a `Range`
|
|
8
|
+
* which is located on a single line.
|
|
9
|
+
*
|
|
10
|
+
* @param {Editor} editor The editor object to compare against
|
|
11
|
+
* @param {Range} parentRange The parent range to compare against
|
|
12
|
+
* @returns {Range} A valid portion of the parentRange which is one a single line
|
|
13
|
+
*/
|
|
14
|
+
export declare const findCurrentLineRange: (editor: IDomEditor, parentRange: Range) => Range;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 编辑操作时钉住滚动位置,避免块操作把视口拽飞
|
|
3
|
+
*/
|
|
4
|
+
import { IDomEditor } from '../editor/interface';
|
|
5
|
+
/**
|
|
6
|
+
* 查找编辑器相关滚动容器:.w-e-scroll → .editor-content(yunkee)→ 可滚动祖先
|
|
7
|
+
*/
|
|
8
|
+
export declare function findEditorScrollParent(editor: IDomEditor): HTMLElement | null;
|
|
9
|
+
/**
|
|
10
|
+
* 执行 fn 期间保持滚动位置
|
|
11
|
+
*/
|
|
12
|
+
export declare function pinEditorScrollDuring(editor: IDomEditor, fn: () => void, scrollParent?: HTMLElement | null): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 通过 UA 判断浏览器
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
export declare const IS_IOS: false;
|
|
6
|
+
export declare const IS_APPLE: boolean;
|
|
7
|
+
export declare const IS_FIREFOX: boolean;
|
|
8
|
+
export declare const IS_FIREFOX_LEGACY: boolean;
|
|
9
|
+
export declare const IS_SAFARI: boolean;
|
|
10
|
+
export declare const IS_EDGE_LEGACY: boolean;
|
|
11
|
+
export declare const IS_CHROME_LEGACY: boolean;
|
|
12
|
+
export declare const IS_CHROME: boolean;
|
|
13
|
+
export declare const IS_QQBROWSER: boolean;
|
|
14
|
+
export declare const HAS_BEFORE_INPUT_SUPPORT: boolean;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 工具函数
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 获取随机数字符串
|
|
7
|
+
* @param prefix 前缀
|
|
8
|
+
* @returns 随机数字符串
|
|
9
|
+
*/
|
|
10
|
+
export declare function genRandomStr(prefix?: string): string;
|
|
11
|
+
export declare function promiseResolveThen(fn: Function): void;
|
|
12
|
+
/**
|
|
13
|
+
* 追加 url query 参数
|
|
14
|
+
* @param url url
|
|
15
|
+
* @param data data
|
|
16
|
+
*/
|
|
17
|
+
export declare function addQueryToUrl(url: string, data: object): string;
|
|
18
|
+
/**
|
|
19
|
+
* 替换 html 特殊字符,如 > 替换为 >
|
|
20
|
+
* @param str html str
|
|
21
|
+
*/
|
|
22
|
+
export declare function replaceHtmlSpecialSymbols(str: string): string;
|
|
23
|
+
/**
|
|
24
|
+
*【反转】替换 html 特殊字符,如 > 替换为 >
|
|
25
|
+
* @param str html str
|
|
26
|
+
*/
|
|
27
|
+
export declare function deReplaceHtmlSpecialSymbols(str: string): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description vdom 相关方法
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { VNode, VNodeStyle, Props, Dataset } from 'snabbdom';
|
|
6
|
+
export declare type PatchFn = (oldVnode: VNode | Element, vnode: VNode) => VNode;
|
|
7
|
+
/**
|
|
8
|
+
* 创建 snabbdom patch
|
|
9
|
+
* @returns snabbdom patch 函数
|
|
10
|
+
*/
|
|
11
|
+
export declare function genPatchFn(): PatchFn;
|
|
12
|
+
/**
|
|
13
|
+
* 整理 vnode.data ,将暴露出来的零散属性(如 id className data-xxx)放在 data.props 或 data.dataset
|
|
14
|
+
* @param vnode vnode
|
|
15
|
+
*/
|
|
16
|
+
export declare function normalizeVnodeData(vnode: VNode): void;
|
|
17
|
+
/**
|
|
18
|
+
* 给 vnode 添加 prop
|
|
19
|
+
* @param vnode vnode
|
|
20
|
+
* @param newProp { key: val }
|
|
21
|
+
*/
|
|
22
|
+
export declare function addVnodeProp(vnode: VNode, newProp: Props): void;
|
|
23
|
+
/**
|
|
24
|
+
* 给 vnode 添加 dataset
|
|
25
|
+
* @param vnode vnode
|
|
26
|
+
* @param newDataset { key: val }
|
|
27
|
+
*/
|
|
28
|
+
export declare function addVnodeDataset(vnode: VNode, newDataset: Dataset): void;
|
|
29
|
+
/**
|
|
30
|
+
* 给 vnode 添加样式
|
|
31
|
+
* @param vnode vnode
|
|
32
|
+
* @param newStyle { key: val }
|
|
33
|
+
*/
|
|
34
|
+
export declare function addVnodeStyle(vnode: VNode, newStyle: VNodeStyle): void;
|