@kerebron/extension-odt 0.4.5 → 0.4.6
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/esm/{extension-odt/src/ExtensionOdt.d.ts → ExtensionOdt.d.ts} +1 -1
- package/esm/ExtensionOdt.d.ts.map +1 -0
- package/esm/{extension-odt/src/ExtensionOdt.js → ExtensionOdt.js} +1 -1
- package/esm/OdtParser.d.ts.map +1 -0
- package/esm/lists.d.ts.map +1 -0
- package/esm/node_handlers/basic_node_handlers.d.ts.map +1 -0
- package/esm/node_handlers/list_node_handlers.d.ts.map +1 -0
- package/esm/node_handlers/table_node_handlers.d.ts.map +1 -0
- package/esm/postprocess/convertCodeParagraphsToCodeBlocks.d.ts.map +1 -0
- package/esm/postprocess/fixContinuedLists.d.ts.map +1 -0
- package/esm/postprocess/postProcess.d.ts.map +1 -0
- package/esm/postprocess/removeUnusedBookmarks.d.ts.map +1 -0
- package/package.json +6 -7
- package/esm/editor/src/CoreEditor.d.ts +0 -40
- package/esm/editor/src/CoreEditor.d.ts.map +0 -1
- package/esm/editor/src/CoreEditor.js +0 -252
- package/esm/editor/src/DummyEditorView.d.ts +0 -60
- package/esm/editor/src/DummyEditorView.d.ts.map +0 -1
- package/esm/editor/src/DummyEditorView.js +0 -277
- package/esm/editor/src/Extension.d.ts +0 -31
- package/esm/editor/src/Extension.d.ts.map +0 -1
- package/esm/editor/src/Extension.js +0 -53
- package/esm/editor/src/ExtensionManager.d.ts +0 -32
- package/esm/editor/src/ExtensionManager.d.ts.map +0 -1
- package/esm/editor/src/ExtensionManager.js +0 -260
- package/esm/editor/src/Mark.d.ts +0 -23
- package/esm/editor/src/Mark.d.ts.map +0 -1
- package/esm/editor/src/Mark.js +0 -51
- package/esm/editor/src/Node.d.ts +0 -32
- package/esm/editor/src/Node.d.ts.map +0 -1
- package/esm/editor/src/Node.js +0 -60
- package/esm/editor/src/commands/CommandManager.d.ts +0 -23
- package/esm/editor/src/commands/CommandManager.d.ts.map +0 -1
- package/esm/editor/src/commands/CommandManager.js +0 -118
- package/esm/editor/src/commands/baseCommandFactories.d.ts +0 -3
- package/esm/editor/src/commands/baseCommandFactories.d.ts.map +0 -1
- package/esm/editor/src/commands/baseCommandFactories.js +0 -836
- package/esm/editor/src/commands/createChainableState.d.ts +0 -3
- package/esm/editor/src/commands/createChainableState.d.ts.map +0 -1
- package/esm/editor/src/commands/createChainableState.js +0 -29
- package/esm/editor/src/commands/keyCommandFactories.d.ts +0 -3
- package/esm/editor/src/commands/keyCommandFactories.d.ts.map +0 -1
- package/esm/editor/src/commands/keyCommandFactories.js +0 -10
- package/esm/editor/src/commands/mod.d.ts +0 -7
- package/esm/editor/src/commands/mod.d.ts.map +0 -1
- package/esm/editor/src/commands/mod.js +0 -76
- package/esm/editor/src/commands/replaceCommandFactories.d.ts +0 -3
- package/esm/editor/src/commands/replaceCommandFactories.d.ts.map +0 -1
- package/esm/editor/src/commands/replaceCommandFactories.js +0 -94
- package/esm/editor/src/commands/types.d.ts +0 -18
- package/esm/editor/src/commands/types.d.ts.map +0 -1
- package/esm/editor/src/commands/types.js +0 -1
- package/esm/editor/src/mod.d.ts +0 -9
- package/esm/editor/src/mod.d.ts.map +0 -1
- package/esm/editor/src/mod.js +0 -8
- package/esm/editor/src/nodeToTreeString.d.ts +0 -10
- package/esm/editor/src/nodeToTreeString.d.ts.map +0 -1
- package/esm/editor/src/nodeToTreeString.js +0 -74
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts +0 -6
- package/esm/editor/src/plugins/TrackSelecionPlugin.d.ts.map +0 -1
- package/esm/editor/src/plugins/TrackSelecionPlugin.js +0 -24
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts +0 -23
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.d.ts.map +0 -1
- package/esm/editor/src/plugins/input-rules/InputRulesPlugin.js +0 -163
- package/esm/editor/src/plugins/keymap/keymap.d.ts +0 -11
- package/esm/editor/src/plugins/keymap/keymap.d.ts.map +0 -1
- package/esm/editor/src/plugins/keymap/keymap.js +0 -125
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts +0 -4
- package/esm/editor/src/plugins/keymap/w3c-keyname.d.ts.map +0 -1
- package/esm/editor/src/plugins/keymap/w3c-keyname.js +0 -124
- package/esm/editor/src/types.d.ts +0 -52
- package/esm/editor/src/types.d.ts.map +0 -1
- package/esm/editor/src/types.js +0 -1
- package/esm/editor/src/ui.d.ts +0 -15
- package/esm/editor/src/ui.d.ts.map +0 -1
- package/esm/editor/src/ui.js +0 -16
- package/esm/editor/src/utilities/SmartOutput.d.ts +0 -41
- package/esm/editor/src/utilities/SmartOutput.d.ts.map +0 -1
- package/esm/editor/src/utilities/SmartOutput.js +0 -228
- package/esm/editor/src/utilities/createNodeFromContent.d.ts +0 -9
- package/esm/editor/src/utilities/createNodeFromContent.d.ts.map +0 -1
- package/esm/editor/src/utilities/createNodeFromContent.js +0 -32
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts +0 -9
- package/esm/editor/src/utilities/getHtmlAttributes.d.ts.map +0 -1
- package/esm/editor/src/utilities/getHtmlAttributes.js +0 -47
- package/esm/extension-odt/src/ExtensionOdt.d.ts.map +0 -1
- package/esm/extension-odt/src/OdtParser.d.ts.map +0 -1
- package/esm/extension-odt/src/lists.d.ts.map +0 -1
- package/esm/extension-odt/src/node_handlers/basic_node_handlers.d.ts.map +0 -1
- package/esm/extension-odt/src/node_handlers/list_node_handlers.d.ts.map +0 -1
- package/esm/extension-odt/src/node_handlers/table_node_handlers.d.ts.map +0 -1
- package/esm/extension-odt/src/postprocess/convertCodeParagraphsToCodeBlocks.d.ts.map +0 -1
- package/esm/extension-odt/src/postprocess/fixContinuedLists.d.ts.map +0 -1
- package/esm/extension-odt/src/postprocess/postProcess.d.ts.map +0 -1
- package/esm/extension-odt/src/postprocess/removeUnusedBookmarks.d.ts.map +0 -1
- /package/esm/{extension-odt/src/OdtParser.d.ts → OdtParser.d.ts} +0 -0
- /package/esm/{extension-odt/src/OdtParser.js → OdtParser.js} +0 -0
- /package/esm/{extension-odt/src/lists.d.ts → lists.d.ts} +0 -0
- /package/esm/{extension-odt/src/lists.js → lists.js} +0 -0
- /package/esm/{extension-odt/src/node_handlers → node_handlers}/basic_node_handlers.d.ts +0 -0
- /package/esm/{extension-odt/src/node_handlers → node_handlers}/basic_node_handlers.js +0 -0
- /package/esm/{extension-odt/src/node_handlers → node_handlers}/list_node_handlers.d.ts +0 -0
- /package/esm/{extension-odt/src/node_handlers → node_handlers}/list_node_handlers.js +0 -0
- /package/esm/{extension-odt/src/node_handlers → node_handlers}/table_node_handlers.d.ts +0 -0
- /package/esm/{extension-odt/src/node_handlers → node_handlers}/table_node_handlers.js +0 -0
- /package/esm/{extension-odt/src/postprocess → postprocess}/convertCodeParagraphsToCodeBlocks.d.ts +0 -0
- /package/esm/{extension-odt/src/postprocess → postprocess}/convertCodeParagraphsToCodeBlocks.js +0 -0
- /package/esm/{extension-odt/src/postprocess → postprocess}/fixContinuedLists.d.ts +0 -0
- /package/esm/{extension-odt/src/postprocess → postprocess}/fixContinuedLists.js +0 -0
- /package/esm/{extension-odt/src/postprocess → postprocess}/postProcess.d.ts +0 -0
- /package/esm/{extension-odt/src/postprocess → postprocess}/postProcess.js +0 -0
- /package/esm/{extension-odt/src/postprocess → postprocess}/removeUnusedBookmarks.d.ts +0 -0
- /package/esm/{extension-odt/src/postprocess → postprocess}/removeUnusedBookmarks.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Schema } from 'prosemirror-model';
|
|
2
|
-
import { type Converter, type CoreEditor, Extension } from '
|
|
2
|
+
import { type Converter, type CoreEditor, Extension } from '@kerebron/editor';
|
|
3
3
|
export interface OdtConfig {
|
|
4
4
|
linkFromRewriter?(href: string): string;
|
|
5
5
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExtensionOdt.d.ts","sourceRoot":"","sources":["../src/ExtensionOdt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEtD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAM9E,MAAM,WAAW,SAAS;IACxB,gBAAgB,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACzC;AAED,qBAAa,YAAa,SAAQ,SAAS;IACzC,IAAI,SAAS;gBAED,MAAM,GAAE,SAAc;IAIzB,aAAa,CACpB,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,GACb,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;CAiD7B"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Extension } from '
|
|
1
|
+
import { Extension } from '@kerebron/editor';
|
|
2
2
|
import { parse_content, parse_styles, unzip } from '@kerebron/odt-wasm';
|
|
3
3
|
import { OdtParser } from './OdtParser.js';
|
|
4
4
|
import { getDefaultsPostProcessFilters } from './postprocess/postProcess.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OdtParser.d.ts","sourceRoot":"","sources":["../src/OdtParser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAOvD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAIzC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;AAErE,UAAU,SAAS;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,KAAK;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;A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EAAE,CAAM;IAEvB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAoC;IAC9E,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,gBAAgB,SAAO;CACxB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic_node_handlers.d.ts","sourceRoot":"","sources":["../../src/node_handlers/basic_node_handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAEhF,wBAAgB,sBAAsB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAiEpE;AAED,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CA2FnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list_node_handlers.d.ts","sourceRoot":"","sources":["../../src/node_handlers/list_node_handlers.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,SAAS,EAEV,MAAM,iBAAiB,CAAC;AAEzB,wBAAgB,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CA0HhE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table_node_handlers.d.ts","sourceRoot":"","sources":["../../src/node_handlers/table_node_handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,WAAW,EAAmB,MAAM,iBAAiB,CAAC;AAEhF,wBAAgB,qBAAqB,IAAI,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAyBnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"convertCodeParagraphsToCodeBlocks.d.ts","sourceRoot":"","sources":["../../src/postprocess/convertCodeParagraphsToCodeBlocks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAe,MAAM,mBAAmB,CAAC;AA8BzD,eAAO,MAAM,iCAAiC,EAAE,OAoF/C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixContinuedLists.d.ts","sourceRoot":"","sources":["../../src/postprocess/fixContinuedLists.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AA4D5C,eAAO,MAAM,iBAAiB,EAAE,OAmD/B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postProcess.d.ts","sourceRoot":"","sources":["../../src/postprocess/postProcess.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAM5C,wBAAgB,6BAA6B,IAAI,KAAK,CAAC,OAAO,CAAC,CAM9D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeUnusedBookmarks.d.ts","sourceRoot":"","sources":["../../src/postprocess/removeUnusedBookmarks.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,eAAO,MAAM,qBAAqB,EAAE,OAgCnC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kerebron/extension-odt",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"module": "./esm/
|
|
5
|
+
"module": "./esm/ExtensionOdt.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": {
|
|
8
|
-
"import": "./esm/
|
|
8
|
+
"import": "./esm/ExtensionOdt.js"
|
|
9
9
|
}
|
|
10
10
|
},
|
|
11
11
|
"scripts": {},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@kerebron/
|
|
13
|
+
"@kerebron/editor": "0.4.6",
|
|
14
|
+
"@kerebron/odt-wasm": "0.4.6",
|
|
14
15
|
"prosemirror-model": "1.25.3",
|
|
15
|
-
"prosemirror-state": "1.4.3"
|
|
16
|
-
"prosemirror-transform": "1.10.4",
|
|
17
|
-
"prosemirror-view": "1.40.0"
|
|
16
|
+
"prosemirror-state": "1.4.3"
|
|
18
17
|
},
|
|
19
18
|
"devDependencies": {
|
|
20
19
|
"@types/node": "^20.9.0"
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
import { Node as ProseMirrorNode, Schema } from 'prosemirror-model';
|
|
3
|
-
import type { EditorConfig, JSONContent } from './types.js';
|
|
4
|
-
import { EditorState, Transaction } from 'prosemirror-state';
|
|
5
|
-
import { DummyEditorView } from './DummyEditorView.js';
|
|
6
|
-
import { ChainedCommands } from './commands/mod.js';
|
|
7
|
-
import { Extension } from './Extension.js';
|
|
8
|
-
import { EditorUi } from './ui.js';
|
|
9
|
-
export declare class CoreEditor extends EventTarget {
|
|
10
|
-
readonly config: Partial<EditorConfig>;
|
|
11
|
-
private extensionManager;
|
|
12
|
-
private commandManager;
|
|
13
|
-
view: EditorView | DummyEditorView;
|
|
14
|
-
state: EditorState;
|
|
15
|
-
ui: EditorUi;
|
|
16
|
-
constructor(config?: Partial<EditorConfig>);
|
|
17
|
-
getExtension<T extends Extension>(name: string): T | undefined;
|
|
18
|
-
get schema(): Schema<any, any>;
|
|
19
|
-
get run(): {
|
|
20
|
-
[key: string]: (...args: any[]) => boolean;
|
|
21
|
-
};
|
|
22
|
-
get commandFactories(): {
|
|
23
|
-
[key: string]: import("./commands/types.js").CommandFactory;
|
|
24
|
-
};
|
|
25
|
-
chain(): ChainedCommands;
|
|
26
|
-
can(): ChainedCommands;
|
|
27
|
-
private createView;
|
|
28
|
-
dispatchTransaction(transaction: Transaction): void;
|
|
29
|
-
private setupPlugins;
|
|
30
|
-
clearDocument(): void;
|
|
31
|
-
setDocument(content: any): void;
|
|
32
|
-
getDocument(): ProseMirrorNode;
|
|
33
|
-
loadDocument(mediaType: string, content: Uint8Array): Promise<void>;
|
|
34
|
-
saveDocument(mediaType: string): Promise<Uint8Array>;
|
|
35
|
-
getJSON(): JSONContent;
|
|
36
|
-
clone(options?: Partial<EditorConfig>): CoreEditor;
|
|
37
|
-
debug(doc?: ProseMirrorNode): void;
|
|
38
|
-
destroy(): void;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=CoreEditor.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CoreEditor.d.ts","sourceRoot":"","sources":["../../../src/editor/src/CoreEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAGpE,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG7D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAc9C,qBAAa,UAAW,SAAQ,WAAW;IACzC,SAAgB,MAAM,EAAE,OAAO,CAAC,YAAY,CAAC,CAG3C;IACF,OAAO,CAAC,gBAAgB,CAAmB;IAC3C,OAAO,CAAC,cAAc,CAAiB;IAChC,IAAI,EAAG,UAAU,GAAG,eAAe,CAAC;IACpC,KAAK,EAAG,WAAW,CAAC;IACpB,EAAE,EAAE,QAAQ,CAAmB;gBAE1B,MAAM,GAAE,OAAO,CAAC,YAAY,CAAM;IA+B9C,YAAY,CAAC,CAAC,SAAS,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS;IAI9D,IAAW,MAAM,qBAEhB;IAED,IAAW,GAAG;;MAEb;IAED,IAAW,gBAAgB;;MAE1B;IAEM,KAAK,IAAI,eAAe;IAIxB,GAAG,IAAI,eAAe;IAI7B,OAAO,CAAC,UAAU;IA8CX,mBAAmB,CAAC,WAAW,EAAE,WAAW;IAsBnD,OAAO,CAAC,YAAY;IAcb,aAAa;IASb,WAAW,CAAC,OAAO,EAAE,GAAG;IAyBxB,WAAW;IAIL,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU;IA0BnD,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAY1D,OAAO,IAAI,WAAW;IAItB,KAAK,CAAC,OAAO,GAAE,OAAO,CAAC,YAAY,CAAM,GAAG,UAAU;IAOtD,KAAK,CAAC,GAAG,CAAC,EAAE,eAAe;IAO3B,OAAO;CAOf"}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
import { EditorView } from 'prosemirror-view';
|
|
2
|
-
import { Node as ProseMirrorNode } from 'prosemirror-model';
|
|
3
|
-
import { ExtensionManager } from './ExtensionManager.js';
|
|
4
|
-
import { EditorState } from 'prosemirror-state';
|
|
5
|
-
import { CommandManager } from './commands/CommandManager.js';
|
|
6
|
-
import { nodeToTreeString } from './nodeToTreeString.js';
|
|
7
|
-
import { DummyEditorView } from './DummyEditorView.js';
|
|
8
|
-
import { createNodeFromObject } from './utilities/createNodeFromContent.js';
|
|
9
|
-
import { defaultUi } from './ui.js';
|
|
10
|
-
function ensureDocSchema(doc, schema) {
|
|
11
|
-
if (doc.type.schema === schema) {
|
|
12
|
-
return doc;
|
|
13
|
-
}
|
|
14
|
-
const json = doc.toJSON();
|
|
15
|
-
return ProseMirrorNode.fromJSON(schema, json);
|
|
16
|
-
}
|
|
17
|
-
export class CoreEditor extends EventTarget {
|
|
18
|
-
constructor(config = {}) {
|
|
19
|
-
super();
|
|
20
|
-
Object.defineProperty(this, "config", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: {
|
|
25
|
-
element: undefined,
|
|
26
|
-
extensions: [],
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(this, "extensionManager", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
configurable: true,
|
|
32
|
-
writable: true,
|
|
33
|
-
value: void 0
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(this, "commandManager", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
configurable: true,
|
|
38
|
-
writable: true,
|
|
39
|
-
value: void 0
|
|
40
|
-
});
|
|
41
|
-
Object.defineProperty(this, "view", {
|
|
42
|
-
enumerable: true,
|
|
43
|
-
configurable: true,
|
|
44
|
-
writable: true,
|
|
45
|
-
value: void 0
|
|
46
|
-
});
|
|
47
|
-
Object.defineProperty(this, "state", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: void 0
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "ui", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: defaultUi(this)
|
|
58
|
-
});
|
|
59
|
-
this.config = {
|
|
60
|
-
...this.config,
|
|
61
|
-
...config,
|
|
62
|
-
};
|
|
63
|
-
this.commandManager = new CommandManager(this);
|
|
64
|
-
this.extensionManager = new ExtensionManager(this.config.extensions || [], this, this.commandManager);
|
|
65
|
-
this.extensionManager.created();
|
|
66
|
-
// const content = this.options.content ? this.options.content : {
|
|
67
|
-
// type: this.extensionManager.schema.topNodeType.name,
|
|
68
|
-
// content: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC,
|
|
69
|
-
// };
|
|
70
|
-
const content = this.config.content
|
|
71
|
-
? this.config.content
|
|
72
|
-
: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC;
|
|
73
|
-
this.createView(content);
|
|
74
|
-
this.setupPlugins();
|
|
75
|
-
}
|
|
76
|
-
getExtension(name) {
|
|
77
|
-
return this.extensionManager.getExtension(name);
|
|
78
|
-
}
|
|
79
|
-
get schema() {
|
|
80
|
-
return this.extensionManager.schema;
|
|
81
|
-
}
|
|
82
|
-
get run() {
|
|
83
|
-
return this.commandManager.run;
|
|
84
|
-
}
|
|
85
|
-
get commandFactories() {
|
|
86
|
-
return this.commandManager.commandFactories;
|
|
87
|
-
}
|
|
88
|
-
chain() {
|
|
89
|
-
return this.commandManager.createChain();
|
|
90
|
-
}
|
|
91
|
-
can() {
|
|
92
|
-
return this.commandManager.createCan();
|
|
93
|
-
}
|
|
94
|
-
createView(content) {
|
|
95
|
-
const doc = createNodeFromObject(content, this.schema);
|
|
96
|
-
this.state = EditorState.create({ doc });
|
|
97
|
-
if (this.config.element) {
|
|
98
|
-
const view = new EditorView(this.config.element, {
|
|
99
|
-
state: this.state,
|
|
100
|
-
attributes: {
|
|
101
|
-
class: 'kb-editor',
|
|
102
|
-
},
|
|
103
|
-
dispatchTransaction: (tx) => this.dispatchTransaction(tx),
|
|
104
|
-
});
|
|
105
|
-
this.view = view;
|
|
106
|
-
const parent = this.config.element.parentNode;
|
|
107
|
-
if (parent) {
|
|
108
|
-
const observer = new MutationObserver((mutations) => {
|
|
109
|
-
for (const mutation of mutations) {
|
|
110
|
-
for (const removedNode of mutation.removedNodes) {
|
|
111
|
-
if (removedNode.contains(view.dom)) {
|
|
112
|
-
// Editor DOM was removed
|
|
113
|
-
observer.disconnect(); // Prevent multiple calls
|
|
114
|
-
view.destroy();
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
this.view = new DummyEditorView({
|
|
124
|
-
state: this.state,
|
|
125
|
-
dispatchTransaction: (tx) => this.dispatchTransaction(tx),
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
const event = new CustomEvent('doc:loaded', {
|
|
129
|
-
detail: {
|
|
130
|
-
editor: this,
|
|
131
|
-
doc,
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
this.dispatchEvent(event);
|
|
135
|
-
}
|
|
136
|
-
dispatchTransaction(transaction) {
|
|
137
|
-
this.state = this.state.apply(transaction);
|
|
138
|
-
if (this.view) {
|
|
139
|
-
this.view.updateState(this.state);
|
|
140
|
-
const event = new CustomEvent('transaction', {
|
|
141
|
-
detail: {
|
|
142
|
-
editor: this,
|
|
143
|
-
transaction,
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
this.dispatchEvent(event);
|
|
147
|
-
}
|
|
148
|
-
if (transaction.docChanged) {
|
|
149
|
-
const event = new CustomEvent('changed', {
|
|
150
|
-
detail: {
|
|
151
|
-
editor: this,
|
|
152
|
-
},
|
|
153
|
-
});
|
|
154
|
-
this.dispatchEvent(event);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
setupPlugins() {
|
|
158
|
-
this.state = this.state.reconfigure({
|
|
159
|
-
plugins: this.extensionManager.plugins,
|
|
160
|
-
});
|
|
161
|
-
if (this.view) {
|
|
162
|
-
this.view.updateState(this.state);
|
|
163
|
-
this.view.setProps({
|
|
164
|
-
nodeViews: this.extensionManager.nodeViews,
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
clearDocument() {
|
|
169
|
-
const content = {
|
|
170
|
-
type: this.extensionManager.schema.topNodeType.name,
|
|
171
|
-
content: this.extensionManager.schema.topNodeType.spec.EMPTY_DOC.content,
|
|
172
|
-
};
|
|
173
|
-
this.setDocument(content);
|
|
174
|
-
}
|
|
175
|
-
setDocument(content) {
|
|
176
|
-
let doc = createNodeFromObject(content, this.schema, {
|
|
177
|
-
errorOnInvalidContent: true,
|
|
178
|
-
});
|
|
179
|
-
doc = ensureDocSchema(doc, this.schema);
|
|
180
|
-
this.state = EditorState.create({
|
|
181
|
-
doc,
|
|
182
|
-
plugins: this.state.plugins,
|
|
183
|
-
storedMarks: this.state.storedMarks,
|
|
184
|
-
});
|
|
185
|
-
if (this.view) {
|
|
186
|
-
this.view.updateState(this.state);
|
|
187
|
-
}
|
|
188
|
-
const event = new CustomEvent('doc:loaded', {
|
|
189
|
-
detail: {
|
|
190
|
-
editor: this,
|
|
191
|
-
doc,
|
|
192
|
-
},
|
|
193
|
-
});
|
|
194
|
-
this.dispatchEvent(event);
|
|
195
|
-
}
|
|
196
|
-
getDocument() {
|
|
197
|
-
return this.state.doc;
|
|
198
|
-
}
|
|
199
|
-
async loadDocument(mediaType, content) {
|
|
200
|
-
const converter = this.extensionManager.converters[mediaType];
|
|
201
|
-
if (!converter) {
|
|
202
|
-
throw new Error('Converter not found for: ' + mediaType);
|
|
203
|
-
}
|
|
204
|
-
const doc = await converter.toDoc(content);
|
|
205
|
-
this.state = EditorState.create({
|
|
206
|
-
doc,
|
|
207
|
-
plugins: this.state.plugins,
|
|
208
|
-
storedMarks: this.state.storedMarks,
|
|
209
|
-
});
|
|
210
|
-
if (this.view) {
|
|
211
|
-
this.view.updateState(this.state);
|
|
212
|
-
}
|
|
213
|
-
const event = new CustomEvent('doc:loaded', {
|
|
214
|
-
detail: {
|
|
215
|
-
editor: this,
|
|
216
|
-
doc,
|
|
217
|
-
},
|
|
218
|
-
});
|
|
219
|
-
this.dispatchEvent(event);
|
|
220
|
-
}
|
|
221
|
-
async saveDocument(mediaType) {
|
|
222
|
-
const converter = this.extensionManager.converters[mediaType];
|
|
223
|
-
if (!converter) {
|
|
224
|
-
throw new Error('Converter not found for: ' + mediaType);
|
|
225
|
-
}
|
|
226
|
-
const json = this.state.doc.toJSON();
|
|
227
|
-
const clonedDoc = ProseMirrorNode.fromJSON(this.state.schema, json);
|
|
228
|
-
return await converter.fromDoc(clonedDoc);
|
|
229
|
-
}
|
|
230
|
-
getJSON() {
|
|
231
|
-
return this.state.doc.toJSON();
|
|
232
|
-
}
|
|
233
|
-
clone(options = {}) {
|
|
234
|
-
return new CoreEditor({
|
|
235
|
-
...options,
|
|
236
|
-
extensions: [...(this.config.extensions || [])],
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
debug(doc) {
|
|
240
|
-
if (!doc) {
|
|
241
|
-
doc = this.state.doc;
|
|
242
|
-
}
|
|
243
|
-
console.debug(nodeToTreeString(doc));
|
|
244
|
-
}
|
|
245
|
-
destroy() {
|
|
246
|
-
const event = new CustomEvent('beforeDestroy', {
|
|
247
|
-
detail: {},
|
|
248
|
-
});
|
|
249
|
-
this.dispatchEvent(event);
|
|
250
|
-
this.view.destroy();
|
|
251
|
-
}
|
|
252
|
-
}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { EditorState, Plugin, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { Mark, Node } from 'prosemirror-model';
|
|
3
|
-
import { EditorView, MarkView, NodeView } from 'prosemirror-view';
|
|
4
|
-
import { Decoration, DecorationSource } from 'prosemirror-view';
|
|
5
|
-
export declare class DummyEditorView {
|
|
6
|
-
private _props;
|
|
7
|
-
private directPlugins;
|
|
8
|
-
private nodeViews;
|
|
9
|
-
private prevDirectPlugins;
|
|
10
|
-
private pluginViews;
|
|
11
|
-
state: EditorState;
|
|
12
|
-
constructor(props: DirectEditorProps);
|
|
13
|
-
editable: boolean;
|
|
14
|
-
get composing(): boolean;
|
|
15
|
-
get dom(): {
|
|
16
|
-
addEventListener(): void;
|
|
17
|
-
removeEventListener(): void;
|
|
18
|
-
};
|
|
19
|
-
get props(): DirectEditorProps;
|
|
20
|
-
update(props: DirectEditorProps): void;
|
|
21
|
-
setProps(props: Partial<DirectEditorProps>): void;
|
|
22
|
-
updateState(state: EditorState): void;
|
|
23
|
-
private updateStateInner;
|
|
24
|
-
scrollToSelection(): void;
|
|
25
|
-
private destroyPluginViews;
|
|
26
|
-
private updatePluginViews;
|
|
27
|
-
someProp<PropName extends keyof EditorProps, Result>(propName: PropName, f: (value: NonNullable<EditorProps[PropName]>) => Result): Result | undefined;
|
|
28
|
-
someProp<PropName extends keyof EditorProps>(propName: PropName): NonNullable<EditorProps[PropName]> | undefined;
|
|
29
|
-
hasFocus(): boolean;
|
|
30
|
-
focus(): void;
|
|
31
|
-
destroy(): void;
|
|
32
|
-
get isDestroyed(): boolean;
|
|
33
|
-
dispatchEvent(event: Event): void;
|
|
34
|
-
dispatch: (tr: Transaction) => void;
|
|
35
|
-
}
|
|
36
|
-
export type NodeViewConstructor = (node: Node, view: EditorView, getPos: () => number | undefined, decorations: readonly Decoration[], innerDecorations: DecorationSource) => NodeView;
|
|
37
|
-
export type MarkViewConstructor = (mark: Mark, view: EditorView, inline: boolean) => MarkView;
|
|
38
|
-
export interface DOMEventMap extends HTMLElementEventMap {
|
|
39
|
-
[event: string]: any;
|
|
40
|
-
}
|
|
41
|
-
export interface EditorProps<P = any> {
|
|
42
|
-
nodeViews?: {
|
|
43
|
-
[node: string]: NodeViewConstructor;
|
|
44
|
-
};
|
|
45
|
-
markViews?: {
|
|
46
|
-
[mark: string]: MarkViewConstructor;
|
|
47
|
-
};
|
|
48
|
-
editable?: (this: P, state: EditorState) => boolean;
|
|
49
|
-
attributes?: {
|
|
50
|
-
[name: string]: string;
|
|
51
|
-
} | ((state: EditorState) => {
|
|
52
|
-
[name: string]: string;
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
export interface DirectEditorProps extends EditorProps {
|
|
56
|
-
state: EditorState;
|
|
57
|
-
plugins?: readonly Plugin[];
|
|
58
|
-
dispatchTransaction?: (tr: Transaction) => void;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=DummyEditorView.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DummyEditorView.d.ts","sourceRoot":"","sources":["../../../src/editor/src/DummyEditorView.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,WAAW,EACX,MAAM,EAEN,WAAW,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAA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