@wangeditor-next/video-module 1.4.0 → 2.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/LICENSE +21 -21
- package/README.md +3 -3
- package/dist/basic-modules/src/modules/image/custom-types.d.ts +22 -0
- package/dist/core/src/config/index.d.ts +13 -0
- package/dist/core/src/config/interface.d.ts +270 -0
- package/dist/core/src/config/register.d.ts +12 -0
- package/dist/core/src/config/style-mode.d.ts +8 -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 +10 -0
- package/dist/core/src/create/create-toolbar.d.ts +14 -0
- package/dist/core/src/create/helper.d.ts +37 -0
- package/dist/core/src/create/index.d.ts +7 -0
- package/dist/core/src/editor/dom-editor.d.ts +153 -0
- package/dist/core/src/editor/interface.d.ts +73 -0
- package/dist/core/src/editor/plugins/with-config.d.ts +7 -0
- package/dist/core/src/editor/plugins/with-content.d.ts +7 -0
- package/dist/core/src/editor/plugins/with-dom.d.ts +10 -0
- package/dist/core/src/editor/plugins/with-emitter.d.ts +7 -0
- package/dist/core/src/editor/plugins/with-event-data.d.ts +7 -0
- package/dist/core/src/editor/plugins/with-max-length.d.ts +7 -0
- package/dist/core/src/editor/plugins/with-selection.d.ts +7 -0
- package/dist/core/src/i18n/index.d.ts +32 -0
- package/dist/core/src/index.d.ts +43 -0
- package/dist/core/src/menus/bar/HoverBar.d.ts +48 -0
- package/dist/core/src/menus/bar/Toolbar.d.ts +36 -0
- package/dist/core/src/menus/bar-item/BaseButton.d.ts +26 -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 +65 -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 +15 -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 +16 -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 +15 -0
- package/dist/core/src/render/helper.d.ts +7 -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 +15 -0
- package/dist/core/src/render/text/renderText.d.ts +9 -0
- package/dist/core/src/text-area/TextArea.d.ts +52 -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 +30 -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 +12 -0
- package/dist/core/src/upload/createUppyUploader.d.ts +7 -0
- package/dist/core/src/upload/index.d.ts +9 -0
- package/dist/core/src/upload/interface.d.ts +72 -0
- package/dist/core/src/upload.d.ts +5 -0
- package/dist/core/src/utils/dom.d.ts +103 -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/sanitize-html.d.ts +5 -0
- package/dist/core/src/utils/ua.d.ts +14 -0
- package/dist/core/src/utils/util.d.ts +28 -0
- package/dist/core/src/utils/vdom.d.ts +34 -0
- package/dist/core/src/utils/weak-maps.d.ts +60 -0
- package/dist/css/style.css +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/table-module/src/utils/has-common.d.ts +7 -0
- package/dist/table-module/src/utils/index.d.ts +5 -0
- package/dist/table-module/src/utils/is-of-type.d.ts +6 -0
- package/dist/table-module/src/utils/matrices.d.ts +9 -0
- package/dist/table-module/src/utils/options.d.ts +25 -0
- package/dist/table-module/src/utils/point.d.ts +7 -0
- package/dist/table-module/src/utils/types.d.ts +19 -0
- package/dist/video-module/src/constants/svg.d.ts +12 -0
- package/dist/video-module/src/index.d.ts +8 -0
- package/dist/video-module/src/locale/en.d.ts +21 -0
- package/dist/video-module/src/locale/index.d.ts +5 -0
- package/dist/video-module/src/locale/zh-CN.d.ts +21 -0
- package/dist/video-module/src/module/custom-types.d.ts +23 -0
- package/dist/video-module/src/module/elem-to-html.d.ts +12 -0
- package/dist/video-module/src/module/helper/insert-video.d.ts +12 -0
- package/dist/video-module/src/module/helper/upload-videos.d.ts +6 -0
- package/dist/video-module/src/module/index.d.ts +7 -0
- package/dist/video-module/src/module/menu/EditVideoSizeMenu.d.ts +25 -0
- package/dist/video-module/src/module/menu/EditVideoSrcMenu.d.ts +26 -0
- package/dist/video-module/src/module/menu/InsertVideoMenu.d.ts +25 -0
- package/dist/video-module/src/module/menu/UploadVideoMenu.d.ts +16 -0
- package/dist/video-module/src/module/menu/config.d.ts +25 -0
- package/dist/video-module/src/module/menu/index.d.ts +30 -0
- package/dist/video-module/src/module/parse-elem-html.d.ts +14 -0
- package/dist/video-module/src/module/plugin.d.ts +7 -0
- package/dist/video-module/src/module/pre-parse-html.d.ts +15 -0
- package/dist/video-module/src/module/render-elem.d.ts +13 -0
- package/dist/video-module/src/utils/dom.d.ts +29 -0
- package/dist/video-module/src/utils/util.d.ts +12 -0
- package/package.json +32 -26
- package/CHANGELOG.md +0 -220
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description to-html entry
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { Descendant, Element as SlateElement } from 'slate';
|
|
6
|
+
import { IDomEditor } from '../editor/interface';
|
|
7
|
+
export type styleToHtmlFnType = (node: Descendant, elemHtml: string, editor?: IDomEditor) => 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 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,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description gen uploader
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import type Uppy from '@uppy/core';
|
|
6
|
+
import type { IDomEditor } from '../editor/interface';
|
|
7
|
+
import type { IUploadAdapter, IUploadConfig, IUploader } from './interface';
|
|
8
|
+
type IUploadConfigWithAdapter = IUploadConfig & {
|
|
9
|
+
uploadAdapter: IUploadAdapter;
|
|
10
|
+
};
|
|
11
|
+
declare function createUploader<T extends IUploadConfig>(config: T, editor?: IDomEditor): T extends IUploadConfigWithAdapter ? IUploader : Uppy;
|
|
12
|
+
export default createUploader;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description upload entry
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import createUploader from './createUploader';
|
|
6
|
+
import createUppyUploader from './createUppyUploader';
|
|
7
|
+
import type { IUploadAdapter, IUploadAdapterContext, IUploadConfig, IUploader, IUploadFile, IUploadResultFile } from './interface';
|
|
8
|
+
export { createUploader, createUppyUploader };
|
|
9
|
+
export type { IUploadAdapter, IUploadAdapterContext, IUploadConfig, IUploader, IUploadFile, IUploadResultFile, };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description upload interface
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import type { IDomEditor } from '../editor/interface';
|
|
6
|
+
export type IUploadHeaders = Record<string, string | number>;
|
|
7
|
+
export interface IUploadResultFile {
|
|
8
|
+
name: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
size?: number;
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
}
|
|
13
|
+
export interface IUploadFile {
|
|
14
|
+
name: string;
|
|
15
|
+
type: string;
|
|
16
|
+
size: number;
|
|
17
|
+
data: Blob | File;
|
|
18
|
+
source?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface IUploader {
|
|
21
|
+
addFiles: (files: IUploadFile[]) => void;
|
|
22
|
+
upload: () => Promise<unknown>;
|
|
23
|
+
destroy?: () => void;
|
|
24
|
+
}
|
|
25
|
+
type FilesType = Record<string, any>;
|
|
26
|
+
type InsertFn = (src: string, poster?: string, alt?: string, href?: string) => void | Promise<void>;
|
|
27
|
+
export interface IUploadAdapterContext {
|
|
28
|
+
config: IUploadConfig;
|
|
29
|
+
editor?: IDomEditor;
|
|
30
|
+
}
|
|
31
|
+
export type IUploadAdapter = (context: IUploadAdapterContext) => IUploader;
|
|
32
|
+
interface IBaseUploadConfig {
|
|
33
|
+
fieldName?: string;
|
|
34
|
+
maxFileSize?: number;
|
|
35
|
+
maxNumberOfFiles?: number;
|
|
36
|
+
meta?: Record<string, unknown>;
|
|
37
|
+
metaWithUrl: boolean;
|
|
38
|
+
headers?: IUploadHeaders | ((file: IUploadResultFile) => IUploadHeaders) | undefined;
|
|
39
|
+
withCredentials?: boolean;
|
|
40
|
+
timeout?: number;
|
|
41
|
+
onBeforeUpload?: (files: FilesType) => boolean | FilesType;
|
|
42
|
+
onSuccess: (file: IUploadResultFile, response: any) => void;
|
|
43
|
+
onProgress?: (progress: number) => void;
|
|
44
|
+
onFailed: (file: IUploadResultFile, response: any) => void;
|
|
45
|
+
onError: (file: IUploadResultFile, error: any, res: any) => void;
|
|
46
|
+
allowedFileTypes?: string[];
|
|
47
|
+
customInsert?: (res: any, insertFn: InsertFn) => void;
|
|
48
|
+
customUpload?: (files: File, insertFn: InsertFn, editor: IDomEditor) => void;
|
|
49
|
+
customBrowseAndUpload?: (insertFn: InsertFn) => void;
|
|
50
|
+
uploadAdapter?: IUploadAdapter;
|
|
51
|
+
uppyConfig?: Record<string, any>;
|
|
52
|
+
xhrConfig?: Record<string, any>;
|
|
53
|
+
}
|
|
54
|
+
interface IUploadConfigWithCustomUpload extends IBaseUploadConfig {
|
|
55
|
+
server?: string;
|
|
56
|
+
customUpload: (files: File, insertFn: InsertFn, editor: IDomEditor) => void;
|
|
57
|
+
}
|
|
58
|
+
interface IUploadConfigWithUploadAdapter extends IBaseUploadConfig {
|
|
59
|
+
server?: string;
|
|
60
|
+
uploadAdapter: IUploadAdapter;
|
|
61
|
+
customUpload?: (files: File, insertFn: InsertFn, editor: IDomEditor) => void;
|
|
62
|
+
}
|
|
63
|
+
interface IUploadConfigWithoutCustomUpload extends IBaseUploadConfig {
|
|
64
|
+
server: string;
|
|
65
|
+
customUpload?: never;
|
|
66
|
+
uploadAdapter?: never;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 配置参考 https://uppy.io/docs/uppy/
|
|
70
|
+
*/
|
|
71
|
+
export type IUploadConfig = IUploadConfigWithCustomUpload | IUploadConfigWithUploadAdapter | IUploadConfigWithoutCustomUpload;
|
|
72
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description DOM 操作 part1 - DOM7 文档 https://framework7.io/docs/dom7.html
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import $, { Dom7Array } from 'dom7';
|
|
6
|
+
import DOMNode = globalThis.Node;
|
|
7
|
+
import DOMComment = globalThis.Comment;
|
|
8
|
+
import DOMElement = globalThis.Element;
|
|
9
|
+
import DOMText = globalThis.Text;
|
|
10
|
+
import DOMRange = globalThis.Range;
|
|
11
|
+
import DOMSelection = globalThis.Selection;
|
|
12
|
+
import DOMStaticRange = globalThis.StaticRange;
|
|
13
|
+
export { Dom7Array } from 'dom7';
|
|
14
|
+
export default $;
|
|
15
|
+
export declare enum NodeType {
|
|
16
|
+
ELEMENT_NODE = 1,
|
|
17
|
+
TEXT_NODE = 3,
|
|
18
|
+
CDATA_SECTION_NODE = 4,
|
|
19
|
+
PROCESSING_INSTRUCTION_NODE = 7,
|
|
20
|
+
COMMENT_NODE = 8,
|
|
21
|
+
DOCUMENT_NODE = 9,
|
|
22
|
+
DOCUMENT_TYPE_NODE = 10,
|
|
23
|
+
DOCUMENT_FRAGMENT_NODE = 11
|
|
24
|
+
}
|
|
25
|
+
export declare const isDocument: (value: any) => value is Document;
|
|
26
|
+
export declare const isShadowRoot: (value: any) => value is ShadowRoot;
|
|
27
|
+
export declare const isDataTransfer: (value: any) => value is DataTransfer;
|
|
28
|
+
export declare const isUnprocessedListElement: (el: Element) => boolean;
|
|
29
|
+
export declare const isHTMLElememt: (value: any) => value is HTMLElement;
|
|
30
|
+
export { DOMComment, DOMElement, DOMNode, DOMRange, DOMSelection, DOMStaticRange, DOMText, };
|
|
31
|
+
export type DOMPoint = [Node, number];
|
|
32
|
+
/**
|
|
33
|
+
* Returns the host window of a DOM node
|
|
34
|
+
*/
|
|
35
|
+
export declare const getDefaultView: (value: any) => Window | null;
|
|
36
|
+
/**
|
|
37
|
+
* Check if a value is a DOM node.
|
|
38
|
+
*/
|
|
39
|
+
export declare const isDOMNode: (value: any) => value is DOMNode;
|
|
40
|
+
/**
|
|
41
|
+
* Check if a DOM node is a comment node.
|
|
42
|
+
*/
|
|
43
|
+
export declare const isDOMComment: (value: any) => value is DOMComment;
|
|
44
|
+
/**
|
|
45
|
+
* Check if a DOM node is an element node.
|
|
46
|
+
*/
|
|
47
|
+
export declare const isDOMElement: (value: any) => value is DOMElement;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a value is a DOM selection.
|
|
50
|
+
*/
|
|
51
|
+
export declare const isDOMSelection: (value: any) => value is DOMSelection;
|
|
52
|
+
/**
|
|
53
|
+
* Check if a DOM node is an element node.
|
|
54
|
+
*/
|
|
55
|
+
export declare const isDOMText: (value: any) => value is DOMText;
|
|
56
|
+
/**
|
|
57
|
+
* Checks whether a paste event is a plaintext-only event.
|
|
58
|
+
*/
|
|
59
|
+
export declare const isPlainTextOnlyPaste: (event: ClipboardEvent) => boolean | null;
|
|
60
|
+
/**
|
|
61
|
+
* Normalize a DOM point so that it always refers to a text node.
|
|
62
|
+
*/
|
|
63
|
+
export declare const normalizeDOMPoint: (domPoint: DOMPoint) => DOMPoint;
|
|
64
|
+
/**
|
|
65
|
+
* Determines wether the active element is nested within a shadowRoot
|
|
66
|
+
*/
|
|
67
|
+
export declare const hasShadowRoot: () => boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Get the element with the specified id
|
|
70
|
+
*/
|
|
71
|
+
export declare const getElementById: (id: string) => null | HTMLElement;
|
|
72
|
+
/**
|
|
73
|
+
* Get the nearest editable child and index at `index` in a `parent`, preferring `direction`.
|
|
74
|
+
*/
|
|
75
|
+
export declare const getEditableChildAndIndex: (parent: DOMElement, index: number, direction: "forward" | "backward") => [DOMNode, number];
|
|
76
|
+
/**
|
|
77
|
+
* Get the nearest editable child at `index` in a `parent`, preferring
|
|
78
|
+
* `direction`.
|
|
79
|
+
*/
|
|
80
|
+
export declare const getEditableChild: (parent: DOMElement, index: number, direction: "forward" | "backward") => DOMNode;
|
|
81
|
+
/**
|
|
82
|
+
* Get a plaintext representation of the content of a node, accounting for block
|
|
83
|
+
* elements which get a newline appended.
|
|
84
|
+
*
|
|
85
|
+
* The domNode must be attached to the DOM.
|
|
86
|
+
*/
|
|
87
|
+
export declare const getPlainText: (domNode: DOMNode) => string;
|
|
88
|
+
/**
|
|
89
|
+
* 在下级节点中找到第一个 void elem
|
|
90
|
+
* @param elem elem
|
|
91
|
+
*/
|
|
92
|
+
export declare function getFirstVoidChild(elem: DOMElement): DOMElement | null;
|
|
93
|
+
/**
|
|
94
|
+
* 遍历一个 elem 内所有的 text node ,执行函数
|
|
95
|
+
* @param elem elem
|
|
96
|
+
* @param handler handler
|
|
97
|
+
*/
|
|
98
|
+
export declare function walkTextNodes(elem: DOMElement, handler: (textNode: DOMNode, parent: DOMElement) => void): void;
|
|
99
|
+
/**
|
|
100
|
+
* 获取 tagName lower-case
|
|
101
|
+
* @param $elem $elem
|
|
102
|
+
*/
|
|
103
|
+
export declare function getTagName($elem: Dom7Array): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 快捷键
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Hotkeys.
|
|
7
|
+
*/
|
|
8
|
+
declare const _default: {
|
|
9
|
+
isBold: (event: KeyboardEvent) => boolean;
|
|
10
|
+
isCompose: (event: KeyboardEvent) => boolean;
|
|
11
|
+
isMoveBackward: (event: KeyboardEvent) => boolean;
|
|
12
|
+
isMoveForward: (event: KeyboardEvent) => boolean;
|
|
13
|
+
isDeleteBackward: (event: KeyboardEvent) => boolean;
|
|
14
|
+
isDeleteForward: (event: KeyboardEvent) => boolean;
|
|
15
|
+
isDeleteLineBackward: (event: KeyboardEvent) => boolean;
|
|
16
|
+
isDeleteLineForward: (event: KeyboardEvent) => boolean;
|
|
17
|
+
isDeleteWordBackward: (event: KeyboardEvent) => boolean;
|
|
18
|
+
isDeleteWordForward: (event: KeyboardEvent) => boolean;
|
|
19
|
+
isExtendBackward: (event: KeyboardEvent) => boolean;
|
|
20
|
+
isExtendForward: (event: KeyboardEvent) => boolean;
|
|
21
|
+
isExtendLineBackward: (event: KeyboardEvent) => boolean;
|
|
22
|
+
isExtendLineForward: (event: KeyboardEvent) => boolean;
|
|
23
|
+
isItalic: (event: KeyboardEvent) => boolean;
|
|
24
|
+
isMoveLineBackward: (event: KeyboardEvent) => boolean;
|
|
25
|
+
isMoveLineForward: (event: KeyboardEvent) => boolean;
|
|
26
|
+
isMoveWordBackward: (event: KeyboardEvent) => boolean;
|
|
27
|
+
isMoveWordForward: (event: KeyboardEvent) => boolean;
|
|
28
|
+
isRedo: (event: KeyboardEvent) => boolean;
|
|
29
|
+
isSplitBlock: (event: KeyboardEvent) => boolean;
|
|
30
|
+
isTransposeCharacter: (event: KeyboardEvent) => boolean;
|
|
31
|
+
isUndo: (event: KeyboardEvent) => boolean;
|
|
32
|
+
isTab: (event: KeyboardEvent) => boolean;
|
|
33
|
+
isSelectAll: (event: KeyboardEvent) => boolean;
|
|
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,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 通过 UA 判断浏览器
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
export declare const IS_IOS: boolean;
|
|
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,28 @@
|
|
|
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;
|
|
28
|
+
export declare const toString: (val: unknown) => string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description vdom 相关方法
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { VNode, VNodeStyle, Props, Dataset } from 'snabbdom';
|
|
6
|
+
export 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;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description 对象关联关系(部分参考 slate-react weak-maps.ts)
|
|
3
|
+
* @author wangfupeng
|
|
4
|
+
*/
|
|
5
|
+
import { Emitter } from 'event-emitter';
|
|
6
|
+
import { Ancestor, Editor, Node, Path, Range } from 'slate';
|
|
7
|
+
import { VNode } from 'snabbdom';
|
|
8
|
+
import { IEditorConfig } from '../config/interface';
|
|
9
|
+
import { IDomEditor } from '../editor/interface';
|
|
10
|
+
import HoverBar from '../menus/bar/HoverBar';
|
|
11
|
+
import Toolbar from '../menus/bar/Toolbar';
|
|
12
|
+
import { IBarItem } from '../menus/bar-item/index';
|
|
13
|
+
import PanelAndModal from '../menus/panel-and-modal/BaseClass';
|
|
14
|
+
import TextArea from '../text-area/TextArea';
|
|
15
|
+
import { PatchFn } from '../utils/vdom';
|
|
16
|
+
import { Key } from './key';
|
|
17
|
+
export declare const EDITOR_TO_TEXTAREA: WeakMap<IDomEditor, TextArea>;
|
|
18
|
+
export declare const TEXTAREA_TO_EDITOR: WeakMap<TextArea, IDomEditor>;
|
|
19
|
+
export declare const TOOLBAR_TO_EDITOR: WeakMap<Toolbar, IDomEditor>;
|
|
20
|
+
export declare const EDITOR_TO_TOOLBAR: WeakMap<IDomEditor, Toolbar>;
|
|
21
|
+
export declare const HOVER_BAR_TO_EDITOR: WeakMap<HoverBar, IDomEditor>;
|
|
22
|
+
export declare const EDITOR_TO_HOVER_BAR: WeakMap<IDomEditor, HoverBar>;
|
|
23
|
+
export declare const BAR_ITEM_TO_EDITOR: WeakMap<IBarItem, IDomEditor>;
|
|
24
|
+
export declare const EDITOR_TO_PANEL_AND_MODAL: WeakMap<IDomEditor, Set<PanelAndModal>>;
|
|
25
|
+
export declare const PANEL_OR_MODAL_TO_EDITOR: WeakMap<PanelAndModal, IDomEditor>;
|
|
26
|
+
export declare const EDITOR_TO_CONFIG: WeakMap<IDomEditor, IEditorConfig>;
|
|
27
|
+
export declare const IS_FIRST_PATCH: WeakMap<TextArea, boolean>;
|
|
28
|
+
export declare const TEXTAREA_TO_PATCH_FN: WeakMap<TextArea, PatchFn>;
|
|
29
|
+
export declare const TEXTAREA_TO_VNODE: WeakMap<TextArea, VNode>;
|
|
30
|
+
export declare const NODE_TO_VNODE: WeakMap<Node, [number, VNode]>;
|
|
31
|
+
export declare const NODE_TO_HTML: WeakMap<Node, String>;
|
|
32
|
+
/**
|
|
33
|
+
* Two weak maps that allow us rebuild a path given a node. They are populated
|
|
34
|
+
* at render time such that after a render occurs we can always backtrack.
|
|
35
|
+
*/
|
|
36
|
+
export declare const NODE_TO_INDEX: WeakMap<Node, number>;
|
|
37
|
+
export declare const NODE_TO_PARENT: WeakMap<Node, Ancestor>;
|
|
38
|
+
/**
|
|
39
|
+
* Weak maps that allow us to go between Slate nodes and DOM nodes. These
|
|
40
|
+
* are used to resolve DOM event-related logic into Slate actions.
|
|
41
|
+
*/
|
|
42
|
+
export declare const EDITOR_TO_ELEMENT: WeakMap<Editor, HTMLElement>;
|
|
43
|
+
export declare const EDITOR_TO_PLACEHOLDER: WeakMap<Editor, string>;
|
|
44
|
+
export declare const ELEMENT_TO_NODE: WeakMap<HTMLElement, Node>;
|
|
45
|
+
export declare const KEY_TO_ELEMENT: WeakMap<Key, HTMLElement>;
|
|
46
|
+
export declare const NODE_TO_ELEMENT: WeakMap<Node, HTMLElement>;
|
|
47
|
+
export declare const NODE_TO_KEY: WeakMap<Node, Key>;
|
|
48
|
+
export declare const EDITOR_TO_WINDOW: WeakMap<Editor, Window>;
|
|
49
|
+
/**
|
|
50
|
+
* Weak maps for storing editor-related state.
|
|
51
|
+
*/
|
|
52
|
+
export declare const IS_FOCUSED: WeakMap<Editor, boolean>;
|
|
53
|
+
export declare const IS_DRAGGING: WeakMap<Editor, boolean>;
|
|
54
|
+
export declare const IS_CLICKING: WeakMap<Editor, boolean>;
|
|
55
|
+
export declare const CHANGING_NODE_PATH: WeakMap<Editor, Path>;
|
|
56
|
+
export declare const EDITOR_TO_SELECTION: WeakMap<Editor, Range>;
|
|
57
|
+
export declare const EDITOR_TO_EMITTER: WeakMap<Editor, Emitter>;
|
|
58
|
+
export declare const EDITOR_TO_CAN_PASTE: WeakMap<Editor, boolean>;
|
|
59
|
+
export declare const EDITOR_TO_PENDING_COMPOSITION_END: WeakMap<Editor, boolean>;
|
|
60
|
+
export declare const EDITOR_TO_PENDING_SELECTION: WeakMap<Editor, Range | null>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.w-e-textarea-video-container{background-image:linear-gradient(45deg,#eee 25%,transparent 0,transparent 75%,#eee 0,#eee),linear-gradient(45deg,#eee 25%,#fff 0,#fff 75%,#eee 0,#eee);background-position:0 0,10px 10px;background-size:20px 20px;border:1px dashed var(--w-e-textarea-border-color);border-radius:5px;margin:10px auto 0;overflow:auto;padding:10px 0;text-align:center}.w-e-video-align-left{text-align:left}.w-e-video-align-center{text-align:center}.w-e-video-align-right{text-align:right}.w-e-video-align-justify{text-align:justify}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@wangeditor-next/core"),require("dom7"),require("slate"),require("nanoid"),require("@wangeditor-next/core/upload"),require("snabbdom")):"function"==typeof define&&define.amd?define(["@wangeditor-next/core","dom7","slate","nanoid","@wangeditor-next/core/upload","snabbdom"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).WangEditorVideoModule=t(e.core,e.$,e.slate,e.nanoid,e.upload,e.snabbdom)}(this,function(e,t,o,n,r,i){"use strict";function a(e){return e.length?e[0].tagName.toLowerCase():""}function d(e,o,n,r,i){void 0===o&&(o="auto"),void 0===n&&(n="auto"),void 0===r&&(r={}),void 0===i&&(i=!1);var a=t(e),d=r.width,c=void 0===d?"":d,u=r.height,s=void 0===u?"":u,l=c?'data-w-e-style-width="'.concat(c,'"'):"",v=s?'data-w-e-style-height="'.concat(s,'"'):"";if(a.attr("width",o),a.attr("height",n),i)l&&a.attr("data-w-e-style-width",c),v&&a.attr("data-w-e-style-height",s),a.removeAttr("style");else{var f="";c&&(f+="width: ".concat(c,";")),s&&(f+="height: ".concat(s,";")),a.attr("style",f)}return a[0].outerHTML}e.i18nAddResources("en",{videoModule:{delete:"Delete",uploadVideo:"Upload video",insertVideo:"Insert video",videoSrc:"Video source",videoSrcPlaceHolder:"Video file url, or third-party <iframe>",videoPoster:"Video poster",videoPosterPlaceHolder:"Poster image url",ok:"Ok",editSize:"Edit size",edit:"Edit video",width:"Width",height:"Height"}}),e.i18nAddResources("zh-CN",{videoModule:{delete:"删除视频",uploadVideo:"上传视频",insertVideo:"插入视频",videoSrc:"视频地址",videoSrcPlaceHolder:"视频文件 url 或第三方 <iframe>",videoPoster:"视频封面",videoPosterPlaceHolder:"封面图片 url",ok:"确定",editSize:"修改尺寸",edit:"编辑视频",width:"宽度",height:"高度"}}),t.append&&(t.fn.append=t.append),t.on&&(t.fn.on=t.on),t.focus&&(t.fn.focus=t.focus),t.attr&&(t.fn.attr=t.attr),t.val&&(t.fn.val=t.val),t.html&&(t.fn.html=t.html),t.parent&&(t.fn.parent=t.parent),t.hasClass&&(t.fn.hasClass=t.hasClass),t.empty&&(t.fn.empty=t.empty);var c={type:"video",elemToHtml:function(t,o,n){var r=t,i=r.src,a=void 0===i?"":i,c=r.poster,u=void 0===c?"":c,s=r.width,l=void 0===s?"auto":s,v=r.height,f=void 0===v?"auto":v,p=r.style,h=void 0===p?{}:p,y=r.textAlign,g=void 0===y?"center":y,m=e.getTextStyleMode(n),w=g||"center",b=' data-w-e-text-align="'.concat(w,'"'),M="class"===m?' class="'.concat(function(e){var t=e.trim().toLowerCase();return t&&["left","center","right","justify"].includes(t)?"w-e-video-align-".concat(t):"w-e-video-align-center"}(w),'"').concat(b):' style="text-align: '.concat(w,';"'),S='<div data-w-e-type="video" data-w-e-is-void'.concat(M,">\n");if(0===a.trim().indexOf("<iframe ")){S+=d(a,l,f,h,"class"===m)}else{var x=h.width,I=void 0===x?"":x,E=h.height,V=void 0===E?"":E;if("class"===m){var P=I?' data-w-e-style-width="'.concat(I,'"'):"",N=V?' data-w-e-style-height="'.concat(V,'"'):"";S+='<video poster="'.concat(u,'" controls="true" width="').concat(l,'" height="').concat(f,'"').concat(P).concat(N,'><source src="').concat(a,'" type="video/mp4"/></video>')}else{var T="";I&&(T+="width: ".concat(I,";")),V&&(T+="height: ".concat(V,";")),S+='<video poster="'.concat(u,'" controls="true" width="').concat(l,'" height="').concat(f,'" style="').concat(T,'"><source src="').concat(a,'" type="video/mp4"/></video>')}}return S+="\n</div>"}};var u=function(){return u=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var r in t=arguments[o])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},u.apply(this,arguments)};function s(e,t,o,n){return new(o||(o=Promise))(function(r,i){function a(e){try{c(n.next(e))}catch(e){i(e)}}function d(e){try{c(n.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(a,d)}c((n=n.apply(e,t||[])).next())})}function l(e,t){var o,n,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=d(0),a.throw=d(1),a.return=d(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function d(d){return function(c){return function(d){if(o)throw new TypeError("Generator is already executing.");for(;a&&(a=0,d[0]&&(i=0)),i;)try{if(o=1,n&&(r=2&d[0]?n.return:d[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,d[1])).done)return r;switch(n=0,r&&(d=[2&d[0],r.value]),d[0]){case 0:case 1:r=d;break;case 4:return i.label++,{value:d[1],done:!1};case 5:i.label++,n=d[1],d=[0];continue;case 7:d=i.ops.pop(),i.trys.pop();continue;default:if(!(r=i.trys,(r=r.length>0&&r[r.length-1])||6!==d[0]&&2!==d[0])){i=0;continue}if(3===d[0]&&(!r||d[1]>r[0]&&d[1]<r[3])){i.label=d[1];break}if(6===d[0]&&i.label<r[1]){i.label=r[1],r=d;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(d);break}r[2]&&i.ops.pop(),i.trys.pop();continue}d=t.call(e,i)}catch(e){d=[6,e],n=0}finally{o=r=0}if(5&d[0])throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}([d,c])}}}function v(e){var t="function"==typeof Symbol&&Symbol.iterator,o=t&&e[t],n=0;if(o)return o.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function f(e,t){var o="function"==typeof Symbol&&e[Symbol.iterator];if(!o)return e;var n,r,i=o.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(e){r={error:e}}finally{try{n&&!n.done&&(o=i.return)&&o.call(i)}finally{if(r)throw r.error}}return a}function p(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,o=e[Symbol.asyncIterator];return o?o.call(e):(e=v(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(o){t[o]=e[o]&&function(t){return new Promise(function(n,r){(function(e,t,o,n){Promise.resolve(n).then(function(t){e({value:t,done:o})},t)})(n,r,(t=e[o](t)).done,t.value)})}}}function h(e){return void 0===e&&(e="r"),"".concat(e,"-").concat(n.nanoid())}function y(e){var t={};return e.trim().split(";").forEach(function(e){if(e){var o=f(e.split(":"),2),n=o[0],r=o[1];n&&r&&(t[n.trim()]=r.trim())}}),t}function g(){return h("w-e-insert-video")}"function"==typeof SuppressedError&&SuppressedError;var m=function(){function n(){this.title=e.t("videoModule.editSize"),this.tag="button",this.showModal=!0,this.modalWidth=320,this.$content=null,this.widthInputId=g(),this.heightInputId=g(),this.buttonId=g()}return n.prototype.getSelectedVideoNode=function(t){return e.DomEditor.getSelectedNodeByType(t,"video")},n.prototype.getValue=function(e){return""},n.prototype.isActive=function(e){return!1},n.prototype.exec=function(e,t){},n.prototype.isDisabled=function(e){return null==e.selection||null==this.getSelectedVideoNode(e)},n.prototype.getModalPositionNode=function(e){return this.getSelectedVideoNode(e)},n.prototype.getModalContentElem=function(n){var r=this,i=r.widthInputId,a=r.heightInputId,d=r.buttonId,c=f(e.genModalInputElems(e.t("videoModule.width"),i,"auto"),2),s=c[0],l=c[1],v=t(l),p=f(e.genModalInputElems(e.t("videoModule.height"),a,"auto"),2),h=p[0],y=p[1],g=t(y),m=f(e.genModalButtonElems(d,e.t("videoModule.ok")),1)[0],w=this.getSelectedVideoNode(n);if(null==this.$content){var b=t("<div></div>");b.on("click","#".concat(d),function(t){t.preventDefault();var r=b.find("#".concat(i)).val().trim(),d=b.find("#".concat(a)).val().trim(),c=function(e){return/^\d+(\.\d+)?%$/.test(e)},s=function(e){return/^\d+(\.\d+)?$/.test(e)},l="auto",v="auto";c(r)?l=r:s(r)&&(l="".concat(parseInt(r,10),"px")),c(d)?v=d:s(d)&&(v="".concat(parseInt(d,10),"px"));var f=w.style,p=void 0===f?{}:f;n.restoreSelection();var h={style:u(u({},p),{width:l,height:v})};o.Transforms.setNodes(n,h,{match:function(t){return e.DomEditor.checkNodeType(t,"video")}}),n.hidePanelOrModal()}),this.$content=b}var M=this.$content;if(M.empty(),M.append(s),M.append(h),M.append(m),null==w)return M[0];var S=w.style,x=void 0===S?{}:S,I=x.width,E=void 0===I?"":I,V=x.height,P=void 0===V?"":V;return v.val(E),g.val(P),setTimeout(function(){v.focus()}),M[0]},n}();function w(){return h("w-e-edit-video")}var b=function(){function n(){this.title=e.t("videoModule.edit"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M864 0a160 160 0 0 1 128 256l-64 64-224-224 64-64c26.752-20.096 59.968-32 96-32zM64 736l-64 288 288-64 592-592-224-224L64 736z m651.584-372.416l-448 448-55.168-55.168 448-448 55.168 55.168z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=300,this.$content=null,this.srcInputId=w(),this.posterInputId=w(),this.buttonId=w()}return n.prototype.getSelectedVideoNode=function(t){return e.DomEditor.getSelectedNodeByType(t,"video")},n.prototype.getValue=function(e){return""},n.prototype.isActive=function(e){return!1},n.prototype.exec=function(e,t){},n.prototype.isDisabled=function(e){return null==e.selection||null==this.getSelectedVideoNode(e)},n.prototype.getModalPositionNode=function(e){return this.getSelectedVideoNode(e)},n.prototype.getModalContentElem=function(n){var r=this,i=this,a=i.srcInputId,d=i.posterInputId,c=i.buttonId,u=f(e.genModalInputElems(e.t("videoModule.videoSrc"),a,e.t("videoModule.videoSrcPlaceHolder")),2),v=u[0],p=u[1],y=f(e.genModalInputElems(e.t("videoModule.videoPoster"),d,e.t("videoModule.videoPosterPlaceHolder")),2),g=y[0],m=y[1],w=t(p),b=t(m),M=f(e.genModalButtonElems(c,e.t("videoModule.ok")),1)[0];if(null==this.$content){var S=t("<div></div>");S.on("click","#".concat(c),function(t){return s(r,void 0,void 0,function(){var r,i,c,u;return l(this,function(s){return t.preventDefault(),r=S.find("#".concat(a)).val().trim(),i=S.find("#".concat(d)).val().trim(),c=h("video-"),u={src:r,poster:i,key:c},n.restoreSelection(),o.Transforms.setNodes(n,u,{match:function(t){return e.DomEditor.checkNodeType(t,"video")}}),n.hidePanelOrModal(),[2]})})}),this.$content=S}var x=this.$content;x.empty(),x.append(v),x.append(g),x.append(M);var I=this.getSelectedVideoNode(n);if(null==I)return x[0];var E=I.src,V=void 0===E?"":E,P=I.poster,N=void 0===P?"":P;return w.val(V),b.val(N),setTimeout(function(){w.focus()}),x[0]},n}();function M(t,n){return s(this,arguments,void 0,function(t,n,r,i,a){var d,c,u,s,v,f,p;return void 0===r&&(r=""),void 0===i&&(i=""),void 0===a&&(a=""),l(this,function(l){switch(l.label){case 0:return n?(t.restoreSelection(),d=t.getMenuConfig("insertVideo"),c=d.onInsertedVideo,u=d.checkVideo,s=d.parseVideoSrc,[4,u(n,r)]):[2];case 1:return"string"==typeof(v=l.sent())?(t.alert(v,"error"),[2]):null==v?[2]:[4,s(n)];case 2:return 0!==(f=l.sent()).trim().indexOf("<iframe ")&&(f=f.replace(/</g,"<").replace(/>/g,">")),p={type:"video",src:f,poster:r,children:[{text:""}],style:{width:i,height:a}},Promise.resolve().then(function(){e.DomEditor.isSelectedEmptyParagraph(t)&&o.Transforms.removeNodes(t,{mode:"highest"}),o.Transforms.insertNodes(t,p,{mode:"highest"})}),c(p),[2]}})})}function S(){return h("w-e-insert-video")}var x=function(){function n(){this.title=e.t("videoModule.insertVideo"),this.iconSvg='<svg viewBox="0 0 1024 1024"><path d="M981.184 160.096C837.568 139.456 678.848 128 512 128S186.432 139.456 42.816 160.096C15.296 267.808 0 386.848 0 512s15.264 244.16 42.816 351.904C186.464 884.544 345.152 896 512 896s325.568-11.456 469.184-32.096C1008.704 756.192 1024 637.152 1024 512s-15.264-244.16-42.816-351.904zM384 704V320l320 192-320 192z"></path></svg>',this.tag="button",this.showModal=!0,this.modalWidth=320,this.$content=null,this.srcInputId=S(),this.posterInputId=S(),this.buttonId=S()}return n.prototype.getValue=function(e){return""},n.prototype.isActive=function(e){return!1},n.prototype.exec=function(e,t){},n.prototype.isDisabled=function(t){var n=t.selection;return null==n||(!o.Range.isCollapsed(n)||!!e.DomEditor.getSelectedElems(t).some(function(o){var n=e.DomEditor.getNodeType(o);return"pre"===n||("list-item"===n||!!t.isVoid(o))}))},n.prototype.getModalPositionNode=function(e){return null},n.prototype.getModalContentElem=function(o){var n=this,r=this,i=r.srcInputId,a=r.posterInputId,d=r.buttonId,c=f(e.genModalInputElems(e.t("videoModule.videoSrc"),i,e.t("videoModule.videoSrcPlaceHolder")),2),u=c[0],v=c[1],p=f(e.genModalInputElems(e.t("videoModule.videoPoster"),a,e.t("videoModule.videoPosterPlaceHolder")),2),h=p[0],y=p[1],g=t(v),m=t(y),w=f(e.genModalButtonElems(d,e.t("videoModule.ok")),1)[0];if(null==this.$content){var b=t("<div></div>");b.on("click","#".concat(d),function(e){return s(n,void 0,void 0,function(){var t,n;return l(this,function(r){switch(r.label){case 0:return e.preventDefault(),t=b.find("#".concat(i)).val().trim(),n=b.find("#".concat(a)).val().trim(),[4,M(o,t,n)];case 1:return r.sent(),o.hidePanelOrModal(),[2]}})})}),this.$content=b}var S=this.$content;return S.empty(),S.append(u),S.append(h),S.append(w),g.val(""),m.val(""),setTimeout(function(){g.focus()}),S[0]},n}();function I(e){return e.getMenuConfig("uploadVideo")}var E=new WeakMap;function V(e,t){return s(this,void 0,void 0,function(){var o,n;return l(this,function(i){switch(i.label){case 0:return o=function(e){var t=E.get(e);if(null!=t)return t;var o=I(e),n=o.onSuccess,i=o.onProgress,a=o.onFailed,d=o.customInsert,c=o.onError;return t=r.createUploader(u(u({},o),{onProgress:function(t){e.showProgressBar(t),i&&i(t)},onSuccess:function(t,o){if(d)return d(o,function(t,o){return M(e,t,o)}),void n(t,o);var r=o.errno,i=void 0===r?1:r,c=o.data,u=void 0===c?{}:c;if(0===i){var s=u.url,l=void 0===s?"":s,v=u.poster;M(e,l,void 0===v?"":v),n(t,o)}else a(t,o)},onError:function(e,t,o){c(e,t,o)}}),e),E.set(e,t),t}(e),n=t.map(function(e){return{name:e.name,type:e.type,size:e.size,data:e}}),o.addFiles(n),[4,o.upload()];case 1:return i.sent(),[2]}})})}var P=function(){function n(){this.title=e.t("videoModule.uploadVideo"),this.iconSvg='<svg viewBox="0 0 1056 1024"><path d="M805.902261 521.819882a251.441452 251.441452 0 0 0-251.011972 246.600033 251.051015 251.051015 0 1 0 502.023944 8.823877 253.237463 253.237463 0 0 0-251.011972-255.42391z m59.463561 240.001647v129.898403h-116.701631v-129.898403h-44.041298l101.279368-103.504859 101.279368 103.504859z" p-id="6802"></path><path d="M788.254507 0.000781H99.094092A98.663439 98.663439 0 0 0 0.001171 99.093701v590.067495a98.663439 98.663439 0 0 0 99.092921 99.092921h411.7549a266.434235 266.434235 0 0 1-2.186448-41.815807 275.843767 275.843767 0 0 1 275.180024-270.729042 270.650955 270.650955 0 0 1 103.504859 19.834201V99.093701A101.51363 101.51363 0 0 0 788.254507 0.000781zM295.054441 640.747004V147.507894l394.146189 246.600033z"></path></svg>',this.tag="button"}return n.prototype.getValue=function(e){return""},n.prototype.isActive=function(e){return!1},n.prototype.exec=function(e,o){var n=this.getMenuConfig(e),r=n.allowedFileTypes,i=void 0===r?[]:r,a=n.customBrowseAndUpload;if(a)a(function(t,o){return M(e,t,o)});else{var d="";i.length>0&&(d='accept="'.concat(i.join(", "),'"'));var c=t("body"),u=t('<input type="file" '.concat(d," multiple/>"));u.hide(),c.append(u),u.click(),u.on("change",function(){var t=u[0].files;!function(e,t){s(this,void 0,void 0,function(){var o,n,r,i,a,d,c,u,s,v,f,h;return l(this,function(l){switch(l.label){case 0:if(null==t)return[2];o=Array.prototype.slice.call(t),n=[],r=I(e).customUpload,l.label=1;case 1:l.trys.push([1,8,9,14]),i=!0,a=p(o),l.label=2;case 2:return[4,a.next()];case 3:return d=l.sent(),(s=d.done)?[3,7]:(h=d.value,i=!1,c=h,r?[4,r(c,function(t,o){return M(e,t,o)},e)]:[3,5]);case 4:return l.sent(),[3,6];case 5:n.push(c),l.label=6;case 6:return i=!0,[3,2];case 7:return[3,14];case 8:return u=l.sent(),v={error:u},[3,14];case 9:return l.trys.push([9,,12,13]),i||s||!(f=a.return)?[3,11]:[4,f.call(a)];case 10:l.sent(),l.label=11;case 11:return[3,13];case 12:if(v)throw v.error;return[7];case 13:return[7];case 14:return n.length>0?[4,V(e,n)]:[3,16];case 15:l.sent(),l.label=16;case 16:return[2]}})})}(e,t)})}},n.prototype.isDisabled=function(t){var n=t.selection;return null==n||(!o.Range.isCollapsed(n)||!!e.DomEditor.getSelectedElems(t).some(function(o){var n=e.DomEditor.getNodeType(o);return"pre"===n||("list-item"===n||!!t.isVoid(o))}))},n.prototype.getMenuConfig=function(e){return e.getMenuConfig("uploadVideo")},n}();function N(e,t,o,n,r,i){return void 0===t&&(t=""),void 0===o&&(o="auto"),void 0===n&&(n="auto"),void 0===r&&(r={}),void 0===i&&(i="center"),{type:"video",src:e,poster:t,width:o,height:n,style:r,children:[{text:""}],textAlign:i}}function T(e){var t=y(e.attr("style")||"")["text-align"];if(t)return t;var o=(e.attr("data-w-e-text-align")||"").trim();if(o)return o;for(var n=(e.attr("class")||"").trim().split(/\s+/).filter(Boolean),r=0;r<n.length;r+=1){var i=n[r];if(i.startsWith("w-e-video-align-")){var a=i.replace("w-e-video-align-","");if(a)return a}}return"center"}return{renderElems:[{type:"video",renderElem:function(t,o,n){var r,a=t,c=a.src,u=void 0===c?"":c,s=a.poster,l=void 0===s?"":s,v=a.key,f=void 0===v?"":v,p=a.width,h=void 0===p?"auto":p,y=a.height,g=void 0===y?"auto":y,m=a.style,w=void 0===m?{}:m,b=a.textAlign,M=void 0===b?"center":b,S=e.DomEditor.isNodeSelected(n,t);if(0===u.trim().indexOf("<iframe ")){var x=d(u,h,g,w);r=i.jsx("div",{className:"w-e-textarea-video-container","data-selected":S?"true":"",style:{textAlign:M},innerHTML:x})}else{var I=i.jsx("video",{key:f,poster:l,controls:!0,style:w},i.jsx("source",{src:u,type:"video/mp4"}),"Sorry, your browser doesn't support embedded videos.\n 抱歉,浏览器不支持 video 视频");"auto"!==h&&(I.data.width=h),"auto"!==g&&(I.data.height=g),r=i.jsx("div",{className:"w-e-textarea-video-container","data-selected":S?"true":"",style:{textAlign:M}},I)}return i.h("div",{props:{contentEditable:!1},on:{mousedown:function(e){return e.preventDefault()}}},r)}}],elemsToHtml:[c],preParseHtml:[{selector:"iframe,video,p",preParseHtml:function(e){var o=t(e),n=o;if("p"===a(o)){var r=o.children();if(1===r.length){var i=r[0],d=i.tagName.toLowerCase();["iframe","video"].includes(d)&&(n=t(i))}}var c=a(n);if("iframe"!==c&&"video"!==c)return n[0];if("video"===n.parent().attr("data-w-e-type"))return n[0];var u=t('<div data-w-e-type="video" data-w-e-is-void class="w-e-video-align-center" data-w-e-text-align="center"></div>');return u.append(n),u[0]}}],parseElemsHtml:[{selector:'div[data-w-e-type="video"]',parseElemHtml:function(e,o,n){var r=t(e),i="",a="",d="auto",c="auto",u={},s=r.find("iframe");if(s.length>0){d=s.attr("width")||"auto",c=s.attr("height")||"auto",u=y(s.attr("style")||"");var l=s.attr("data-w-e-style-width")||"",v=s.attr("data-w-e-style-height")||"";return!u.width&&l&&(u.width=l),!u.height&&v&&(u.height=v),N(i=s[0].outerHTML,a,d,c,u,T(r))}var f=r.find("video");(i=f.attr("src")||"")||f.length>0&&(i=f.find("source").attr("src")||""),d=f.attr("width")||"auto",c=f.attr("height")||"auto",a=f.attr("poster")||"",u=y(f.attr("style")||"");var p=f.attr("data-w-e-style-width")||"",h=f.attr("data-w-e-style-height")||"";return!u.width&&p&&(u.width=p),!u.height&&h&&(u.height=h),N(i,a,d,c,u,T(r))}}],menus:[{key:"insertVideo",factory:function(){return new x},config:{onInsertedVideo:function(e){},checkVideo:function(e,t){return!0},parseVideoSrc:function(e){return e}}},{key:"uploadVideo",factory:function(){return new P},config:{server:"",fieldName:"wangeditor-uploaded-video",maxFileSize:10485760,maxNumberOfFiles:5,allowedFileTypes:["video/*"],meta:{},metaWithUrl:!1,withCredentials:!1,timeout:3e4,onBeforeUpload:function(e){return e},onProgress:function(e){},onSuccess:function(e,t){},onFailed:function(e,t){console.error("'".concat(e.name,"' upload failed"),t)},onError:function(e,t,o){console.error("'".concat(e.name," upload error"),t,o)}}},{key:"editVideoSize",factory:function(){return new m}},{key:"editVideoSrc",factory:function(){return new b}}],editorPlugin:function(t){var n=t.isVoid,r=t.normalizeNode,i=t;return i.isVoid=function(e){return"video"===e.type||n(e)},i.normalizeNode=function(t){var n=f(t,2),a=n[0],d=n[1];"video"===e.DomEditor.getNodeType(a)&&(e.DomEditor.isLastNode(i,a)&&o.Transforms.insertNodes(i,e.DomEditor.genEmptyParagraph(),{at:[d[0]+1]}));return r([a,d])},i}}});
|
|
2
|
+
//# sourceMappingURL=index.js.map
|