@lobehub/editor 1.31.2 → 1.33.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/es/const/hotkey.js +1 -1
- package/es/editor-kernel/kernel.d.ts +4 -4
- package/es/editor-kernel/kernel.js +6 -2
- package/es/editor-kernel/react/PortalContainer.d.ts +11 -0
- package/es/editor-kernel/react/PortalContainer.js +32 -0
- package/es/editor-kernel/react/index.d.ts +1 -0
- package/es/editor-kernel/react/index.js +1 -0
- package/es/editor-kernel/react/useDecorators.js +3 -2
- package/es/editor-kernel/utils.d.ts +7 -1
- package/es/editor-kernel/utils.js +34 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/plugins/common/plugin/register.js +37 -2
- package/es/plugins/file/node/FileNode.js +12 -2
- package/es/plugins/hr/node/HorizontalRuleNode.js +12 -2
- package/es/plugins/image/node/block-image-node.js +1 -1
- package/es/plugins/image/plugin/index.js +33 -3
- package/es/plugins/image/react/components/Image.js +1 -1
- package/es/plugins/inode/index.d.ts +3 -0
- package/es/plugins/inode/index.js +3 -0
- package/es/plugins/inode/plugin/index.d.ts +16 -0
- package/es/plugins/inode/plugin/index.js +49 -0
- package/es/plugins/inode/react/index.d.ts +3 -0
- package/es/plugins/inode/react/index.js +22 -0
- package/es/plugins/inode/service/index.d.ts +25 -0
- package/es/plugins/inode/service/index.js +49 -0
- package/es/plugins/link/node/LinkNode.js +2 -0
- package/es/plugins/link-highlight/node/link-highlight.js +1 -0
- package/es/plugins/litexml/command/diffCommand.d.ts +10 -0
- package/es/plugins/litexml/command/diffCommand.js +47 -0
- package/es/plugins/litexml/command/index.d.ts +19 -0
- package/es/plugins/litexml/command/index.js +286 -45
- package/es/plugins/litexml/data-source/litexml-data-source.d.ts +3 -1
- package/es/plugins/litexml/data-source/litexml-data-source.js +10 -3
- package/es/plugins/litexml/index.d.ts +1 -1
- package/es/plugins/litexml/index.js +1 -1
- package/es/plugins/litexml/node/DiffNode.d.ts +26 -0
- package/es/plugins/litexml/node/DiffNode.js +164 -0
- package/es/plugins/litexml/plugin/index.d.ts +4 -0
- package/es/plugins/litexml/plugin/index.js +23 -4
- package/es/plugins/litexml/react/DiffNodeToolbar.d.ts +10 -0
- package/es/plugins/litexml/react/DiffNodeToolbar.js +47 -0
- package/es/plugins/litexml/react/index.js +16 -1
- package/es/plugins/litexml/react/style.d.ts +1 -0
- package/es/plugins/litexml/react/style.js +8 -0
- package/es/plugins/litexml/utils/index.d.ts +3 -0
- package/es/plugins/litexml/utils/index.js +47 -0
- package/es/plugins/markdown/data-source/markdown-data-source.d.ts +3 -1
- package/es/plugins/markdown/data-source/markdown-data-source.js +5 -1
- package/es/plugins/markdown/plugin/index.js +3 -2
- package/es/plugins/markdown/react/index.js +2 -0
- package/es/plugins/math/node/index.js +24 -4
- package/es/plugins/mention/node/MentionNode.js +12 -2
- package/es/types/kernel.d.ts +8 -3
- package/package.json +2 -2
package/es/const/hotkey.js
CHANGED
|
@@ -40,7 +40,7 @@ export var HOTKEYS_REGISTRATION = [{
|
|
|
40
40
|
scopes: [HotkeyScopeEnum.Format, HotkeyScopeEnum.Plugin]
|
|
41
41
|
}, {
|
|
42
42
|
id: HotkeyEnum.Link,
|
|
43
|
-
keys: combineKeys([KeyEnum.Mod, 'k']),
|
|
43
|
+
keys: combineKeys([KeyEnum.Mod, KeyEnum.Shift, 'k']),
|
|
44
44
|
priority: COMMAND_PRIORITY_EDITOR,
|
|
45
45
|
scopes: [HotkeyScopeEnum.Format, HotkeyScopeEnum.Plugin]
|
|
46
46
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { HistoryState } from '@lexical/history';
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
|
-
import { CommandListener, CommandListenerPriority, CommandPayloadType,
|
|
3
|
+
import { CommandListener, CommandListenerPriority, CommandPayloadType, LexicalCommand, LexicalEditor, LexicalNodeConfig } from 'lexical';
|
|
4
4
|
import { HotkeyId } from "../types/hotkey";
|
|
5
|
-
import { IEditor, IEditorKernel, IEditorPluginConstructor, IPlugin, IServiceID } from "../types/kernel";
|
|
5
|
+
import { IDecorator, IEditor, IEditorKernel, IEditorPluginConstructor, IPlugin, IServiceID } from "../types/kernel";
|
|
6
6
|
import { ILocaleKeys } from "../types/locale";
|
|
7
7
|
import { HotkeyOptions, HotkeysEvent } from "../utils/hotkey/registerHotkey";
|
|
8
8
|
import DataSource from './data-source';
|
|
@@ -45,8 +45,8 @@ export declare class Kernel extends EventEmitter implements IEditorKernel {
|
|
|
45
45
|
blur(): void;
|
|
46
46
|
getDocument(type: string): DataSource | undefined;
|
|
47
47
|
getSelectionDocument(type: string): unknown | null;
|
|
48
|
-
registerDecorator(name: string, decorator:
|
|
49
|
-
getDecorator(name: string):
|
|
48
|
+
registerDecorator(name: string, decorator: IDecorator): this;
|
|
49
|
+
getDecorator(name: string): IDecorator | undefined;
|
|
50
50
|
/**
|
|
51
51
|
* Unregister a decorator
|
|
52
52
|
* @param name Decorator name
|
|
@@ -29,7 +29,7 @@ import { createDebugLogger } from "../utils/debug";
|
|
|
29
29
|
import { getHotkeyById, registerHotkey as _registerHotkey } from "../utils/hotkey/registerHotkey";
|
|
30
30
|
import { registerEvent } from "./event";
|
|
31
31
|
import { KernelPlugin } from "./plugin";
|
|
32
|
-
import { createEmptyEditorState, noop } from "./utils";
|
|
32
|
+
import { EDITOR_THEME_KEY, createEmptyEditorState, generateEditorId, noop, registerEditorKernel, unregisterEditorKernel } from "./utils";
|
|
33
33
|
templateSettings.interpolate = /{{([\S\s]+?)}}/g;
|
|
34
34
|
export var Kernel = /*#__PURE__*/function (_EventEmitter) {
|
|
35
35
|
_inherits(Kernel, _EventEmitter);
|
|
@@ -43,7 +43,7 @@ export var Kernel = /*#__PURE__*/function (_EventEmitter) {
|
|
|
43
43
|
_defineProperty(_assertThisInitialized(_this), "pluginsConfig", new Map());
|
|
44
44
|
_defineProperty(_assertThisInitialized(_this), "pluginsInstances", []);
|
|
45
45
|
_defineProperty(_assertThisInitialized(_this), "nodes", []);
|
|
46
|
-
_defineProperty(_assertThisInitialized(_this), "themes", {});
|
|
46
|
+
_defineProperty(_assertThisInitialized(_this), "themes", _defineProperty({}, EDITOR_THEME_KEY, generateEditorId()));
|
|
47
47
|
// Used to store theme configuration
|
|
48
48
|
_defineProperty(_assertThisInitialized(_this), "decorators", {});
|
|
49
49
|
_defineProperty(_assertThisInitialized(_this), "serviceMap", new Map());
|
|
@@ -127,6 +127,7 @@ export var Kernel = /*#__PURE__*/function (_EventEmitter) {
|
|
|
127
127
|
key: "destroy",
|
|
128
128
|
value: function destroy() {
|
|
129
129
|
var _this$editor2;
|
|
130
|
+
unregisterEditorKernel(this.themes[EDITOR_THEME_KEY]);
|
|
130
131
|
this.logger.info("\uD83D\uDDD1\uFE0F Destroying editor with ".concat(this.pluginsInstances.length, " plugins"));
|
|
131
132
|
(_this$editor2 = this.editor) === null || _this$editor2 === void 0 || _this$editor2.setEditorState(createEmptyEditorState());
|
|
132
133
|
this.dataTypeMap.clear();
|
|
@@ -140,6 +141,8 @@ export var Kernel = /*#__PURE__*/function (_EventEmitter) {
|
|
|
140
141
|
this.serviceMap.clear();
|
|
141
142
|
// Clear decorators to prevent memory leaks
|
|
142
143
|
this.decorators = {};
|
|
144
|
+
// Clear themes
|
|
145
|
+
this.themes = {};
|
|
143
146
|
this.logger.info('✅ Editor destroyed');
|
|
144
147
|
}
|
|
145
148
|
}, {
|
|
@@ -178,6 +181,7 @@ export var Kernel = /*#__PURE__*/function (_EventEmitter) {
|
|
|
178
181
|
}
|
|
179
182
|
}
|
|
180
183
|
this.logger.info("\uD83D\uDCDD Creating editor with ".concat(this.nodes.length, " nodes"));
|
|
184
|
+
registerEditorKernel(this.themes[EDITOR_THEME_KEY], this);
|
|
181
185
|
var editor = this.editor = createEditor({
|
|
182
186
|
// @ts-expect-error Inject into lexical editor instance
|
|
183
187
|
__kernel: this,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LexicalEditor, LexicalNode } from 'lexical';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export interface PortalContainerProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
className?: string;
|
|
6
|
+
editor: LexicalEditor;
|
|
7
|
+
node: LexicalNode;
|
|
8
|
+
style?: React.CSSProperties;
|
|
9
|
+
}
|
|
10
|
+
export declare const LexicalPortalContainer: React.ForwardRefExoticComponent<PortalContainerProps & React.RefAttributes<HTMLDivElement | null>>;
|
|
11
|
+
export default LexicalPortalContainer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
export var LexicalPortalContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
4
|
+
var editor = _ref.editor,
|
|
5
|
+
node = _ref.node,
|
|
6
|
+
children = _ref.children;
|
|
7
|
+
var divRef = useRef(null);
|
|
8
|
+
useImperativeHandle(ref, function () {
|
|
9
|
+
return divRef.current;
|
|
10
|
+
}, []);
|
|
11
|
+
useEffect(function () {
|
|
12
|
+
return function () {
|
|
13
|
+
if (divRef.current) {
|
|
14
|
+
// @ts-expect-error not error
|
|
15
|
+
delete divRef.current["__lexicalKey_".concat(editor._key)];
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}, [editor, node]);
|
|
19
|
+
return /*#__PURE__*/_jsx("div", {
|
|
20
|
+
ref: function ref(dom) {
|
|
21
|
+
divRef.current = dom;
|
|
22
|
+
if (dom) {
|
|
23
|
+
var prop = "__lexicalKey_".concat(editor._key);
|
|
24
|
+
// @ts-expect-error not error
|
|
25
|
+
dom[prop] = node.getKey();
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
children: children
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
LexicalPortalContainer.displayName = 'LexicalPortalContainer';
|
|
32
|
+
export default LexicalPortalContainer;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { LexicalErrorBoundary } from './LexicalErrorBoundary';
|
|
2
|
+
export { LexicalPortalContainer } from './PortalContainer';
|
|
2
3
|
export { useLexicalComposerContext } from './react-context';
|
|
3
4
|
export { ReactEditor } from './react-editor';
|
|
4
5
|
export { useLexicalEditor } from './useLexicalEditor';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { LexicalErrorBoundary } from "./LexicalErrorBoundary";
|
|
2
|
+
export { LexicalPortalContainer } from "./PortalContainer";
|
|
2
3
|
export { useLexicalComposerContext } from "./react-context";
|
|
3
4
|
export { ReactEditor } from "./react-editor";
|
|
4
5
|
export { useLexicalEditor } from "./useLexicalEditor";
|
|
@@ -59,6 +59,7 @@ export function useDecorators(editor, ErrorBoundary) {
|
|
|
59
59
|
for (var _i = 0, _decoratorKeys = decoratorKeys; _i < _decoratorKeys.length; _i++) {
|
|
60
60
|
var _editor$getLexicalEdi3;
|
|
61
61
|
var nodeKey = _decoratorKeys[_i];
|
|
62
|
+
var decorator = decorators[nodeKey];
|
|
62
63
|
var reactDecorator = /*#__PURE__*/_jsx(ErrorBoundary, {
|
|
63
64
|
onError: function onError(e) {
|
|
64
65
|
var _editor$getLexicalEdi2;
|
|
@@ -66,12 +67,12 @@ export function useDecorators(editor, ErrorBoundary) {
|
|
|
66
67
|
},
|
|
67
68
|
children: /*#__PURE__*/_jsx(Suspense, {
|
|
68
69
|
fallback: null,
|
|
69
|
-
children:
|
|
70
|
+
children: 'render' in decorator ? decorator.render : decorator
|
|
70
71
|
})
|
|
71
72
|
});
|
|
72
73
|
var element = (_editor$getLexicalEdi3 = editor.getLexicalEditor()) === null || _editor$getLexicalEdi3 === void 0 ? void 0 : _editor$getLexicalEdi3.getElementByKey(nodeKey);
|
|
73
74
|
if (element !== null && element !== undefined) {
|
|
74
|
-
decoratedPortals.push( /*#__PURE__*/createPortal(reactDecorator, element, nodeKey));
|
|
75
|
+
decoratedPortals.push( /*#__PURE__*/createPortal(reactDecorator, 'queryDOM' in decorator ? decorator.queryDOM(element) : element, nodeKey));
|
|
75
76
|
}
|
|
76
77
|
}
|
|
77
78
|
return decoratedPortals;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementNode, LexicalEditor, LexicalNode, NodeKey } from 'lexical';
|
|
1
|
+
import { EditorConfig, ElementNode, LexicalEditor, LexicalNode, NodeKey } from 'lexical';
|
|
2
2
|
import type { IEditorKernel, IServiceID } from "../types";
|
|
3
3
|
export declare const DOM_ELEMENT_TYPE = 1;
|
|
4
4
|
export declare const DOM_TEXT_TYPE = 3;
|
|
@@ -23,6 +23,11 @@ export declare function isDocumentFragment(x: unknown): x is DocumentFragment;
|
|
|
23
23
|
export declare function getParentElement(node: Node): HTMLElement | null;
|
|
24
24
|
export declare function $getNearestNodeFromDOMNode(startingDOM: Node, editor: LexicalEditor, editorState?: ReturnType<LexicalEditor['getEditorState']>): LexicalNode | null;
|
|
25
25
|
export declare function getKernelFromEditor(editor: LexicalEditor): IEditorKernel;
|
|
26
|
+
export declare const EDITOR_THEME_KEY = "__editorId";
|
|
27
|
+
export declare function generateEditorId(): string;
|
|
28
|
+
export declare function registerEditorKernel(id: string, kernel: IEditorKernel): void;
|
|
29
|
+
export declare function unregisterEditorKernel(id: string): void;
|
|
30
|
+
export declare function getKernelFromEditorConfig(config: EditorConfig): IEditorKernel | null;
|
|
26
31
|
/**
|
|
27
32
|
*
|
|
28
33
|
* @param nodeA
|
|
@@ -33,3 +38,4 @@ export declare function compareNodeOrder(nodeA: LexicalNode, nodeB: LexicalNode)
|
|
|
33
38
|
export declare function $closest(node: LexicalNode | ElementNode | null, test: (node: LexicalNode) => boolean): LexicalNode | null;
|
|
34
39
|
export declare function $closestNodeType(node: LexicalNode | ElementNode | null, type: string | string[]): LexicalNode | null;
|
|
35
40
|
export declare function moment(): Promise<unknown>;
|
|
41
|
+
export declare function reconcileDecorator(activeEditor: LexicalEditor, key: NodeKey, decorator: unknown): void;
|
|
@@ -69,6 +69,23 @@ export function getKernelFromEditor(editor) {
|
|
|
69
69
|
// @ts-expect-error __kernel is injected into the lexical editor instance
|
|
70
70
|
return ((_editor$_createEditor = editor._createEditorArgs) === null || _editor$_createEditor === void 0 ? void 0 : _editor$_createEditor.__kernel) || editor._kernel;
|
|
71
71
|
}
|
|
72
|
+
var EditorId = 0;
|
|
73
|
+
export var EDITOR_THEME_KEY = '__editorId';
|
|
74
|
+
export function generateEditorId() {
|
|
75
|
+
EditorId += 1;
|
|
76
|
+
return "editor-".concat(EditorId);
|
|
77
|
+
}
|
|
78
|
+
var EditorMap = new Map();
|
|
79
|
+
export function registerEditorKernel(id, kernel) {
|
|
80
|
+
EditorMap.set(id, kernel);
|
|
81
|
+
}
|
|
82
|
+
export function unregisterEditorKernel(id) {
|
|
83
|
+
EditorMap.delete(id);
|
|
84
|
+
}
|
|
85
|
+
export function getKernelFromEditorConfig(config) {
|
|
86
|
+
var id = config.theme[EDITOR_THEME_KEY];
|
|
87
|
+
return EditorMap.get(id) || null;
|
|
88
|
+
}
|
|
72
89
|
|
|
73
90
|
/**
|
|
74
91
|
*
|
|
@@ -130,4 +147,21 @@ export function moment() {
|
|
|
130
147
|
return resolve(true);
|
|
131
148
|
});
|
|
132
149
|
});
|
|
150
|
+
}
|
|
151
|
+
function cloneDecorators(editor) {
|
|
152
|
+
var currentDecorators = editor._decorators;
|
|
153
|
+
var pendingDecorators = Object.assign({}, currentDecorators);
|
|
154
|
+
editor._pendingDecorators = pendingDecorators;
|
|
155
|
+
return pendingDecorators;
|
|
156
|
+
}
|
|
157
|
+
export function reconcileDecorator(activeEditor, key, decorator) {
|
|
158
|
+
var pendingDecorators = activeEditor._pendingDecorators;
|
|
159
|
+
var currentDecorators = activeEditor._decorators;
|
|
160
|
+
if (pendingDecorators === null) {
|
|
161
|
+
if (currentDecorators[key] === decorator) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
pendingDecorators = cloneDecorators(activeEditor);
|
|
165
|
+
}
|
|
166
|
+
pendingDecorators[key] = decorator;
|
|
133
167
|
}
|
package/es/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './plugins/common';
|
|
|
7
7
|
export * from './plugins/file';
|
|
8
8
|
export * from './plugins/hr';
|
|
9
9
|
export * from './plugins/image';
|
|
10
|
+
export * from './plugins/inode';
|
|
10
11
|
export * from './plugins/link';
|
|
11
12
|
export * from './plugins/link-highlight';
|
|
12
13
|
export * from './plugins/list';
|
package/es/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./plugins/common";
|
|
|
7
7
|
export * from "./plugins/file";
|
|
8
8
|
export * from "./plugins/hr";
|
|
9
9
|
export * from "./plugins/image";
|
|
10
|
+
export * from "./plugins/inode";
|
|
10
11
|
export * from "./plugins/link";
|
|
11
12
|
export * from "./plugins/link-highlight";
|
|
12
13
|
export * from "./plugins/list";
|
|
@@ -3,9 +3,10 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
|
|
|
3
3
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
4
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
5
|
import { $isCodeHighlightNode, $isCodeNode } from '@lexical/code';
|
|
6
|
-
import { $isHeadingNode } from '@lexical/rich-text';
|
|
6
|
+
import { $isHeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
7
7
|
import { mergeRegister } from '@lexical/utils';
|
|
8
|
-
import { $createNodeSelection, $createParagraphNode, $getRoot, $getSelection, $isDecoratorNode, $isElementNode, $isLineBreakNode, $isNodeSelection, $isRangeSelection, $isRootOrShadowRoot, $isTextNode, $setSelection, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_NORMAL, FORMAT_TEXT_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, REDO_COMMAND, UNDO_COMMAND } from 'lexical';
|
|
8
|
+
import { $createNodeSelection, $createParagraphNode, $getRoot, $getSelection, $isDecoratorNode, $isElementNode, $isLineBreakNode, $isNodeSelection, $isRangeSelection, $isRootOrShadowRoot, $isTextNode, $setSelection, COMMAND_PRIORITY_EDITOR, COMMAND_PRIORITY_LOW, COMMAND_PRIORITY_NORMAL, FORMAT_TEXT_COMMAND, KEY_ARROW_DOWN_COMMAND, KEY_ARROW_RIGHT_COMMAND, KEY_ARROW_UP_COMMAND, KEY_BACKSPACE_COMMAND, REDO_COMMAND, UNDO_COMMAND } from 'lexical';
|
|
9
|
+
import { $closest } from "../../../editor-kernel";
|
|
9
10
|
import { HotkeyEnum } from "../../../types/hotkey";
|
|
10
11
|
function resolveElement(element, isBackward, focusOffset) {
|
|
11
12
|
var parent = element.getParent();
|
|
@@ -246,6 +247,40 @@ export function registerRichKeydown(editor, kernel, options) {
|
|
|
246
247
|
}
|
|
247
248
|
return false;
|
|
248
249
|
}, COMMAND_PRIORITY_EDITOR), kernel.registerHighCommand(KEY_ARROW_DOWN_COMMAND, function (event) {
|
|
250
|
+
var selection = $getSelection();
|
|
251
|
+
if ($isRangeSelection(selection)) {
|
|
252
|
+
if (!selection.isCollapsed()) {
|
|
253
|
+
return false;
|
|
254
|
+
}
|
|
255
|
+
var focusNode = selection.focus.getNode();
|
|
256
|
+
var quotaNode = $closest(focusNode, function (node) {
|
|
257
|
+
return node.getType() === QuoteNode.getType();
|
|
258
|
+
});
|
|
259
|
+
if (!quotaNode) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
if (quotaNode.getNextSibling()) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
var lastChild = quotaNode.getLastChild();
|
|
266
|
+
if (!lastChild) {
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
if (!$closest(focusNode, function (node) {
|
|
270
|
+
return node === lastChild;
|
|
271
|
+
})) {
|
|
272
|
+
return false;
|
|
273
|
+
}
|
|
274
|
+
event.preventDefault();
|
|
275
|
+
editor.update(function () {
|
|
276
|
+
var paragraph = $createParagraphNode();
|
|
277
|
+
quotaNode.insertAfter(paragraph);
|
|
278
|
+
paragraph.select();
|
|
279
|
+
});
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
}, COMMAND_PRIORITY_LOW), kernel.registerHighCommand(KEY_ARROW_DOWN_COMMAND, function (event) {
|
|
249
284
|
var selection = $getSelection();
|
|
250
285
|
if ($isNodeSelection(selection)) {
|
|
251
286
|
// If selection is on a node, let's try and move selection
|
|
@@ -123,8 +123,18 @@ export var FileNode = /*#__PURE__*/function (_DecoratorNode) {
|
|
|
123
123
|
}, {
|
|
124
124
|
key: "decorate",
|
|
125
125
|
value: function decorate(editor) {
|
|
126
|
-
var _getKernelFromEditor
|
|
127
|
-
|
|
126
|
+
var _getKernelFromEditor;
|
|
127
|
+
var decorator = (_getKernelFromEditor = getKernelFromEditor(editor)) === null || _getKernelFromEditor === void 0 ? void 0 : _getKernelFromEditor.getDecorator('file');
|
|
128
|
+
if (!decorator) {
|
|
129
|
+
return null;
|
|
130
|
+
}
|
|
131
|
+
if (typeof decorator === 'function') {
|
|
132
|
+
return decorator(this, editor);
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
queryDOM: decorator.queryDOM,
|
|
136
|
+
render: decorator.render(this, editor)
|
|
137
|
+
};
|
|
128
138
|
}
|
|
129
139
|
}], [{
|
|
130
140
|
key: "getType",
|
|
@@ -54,8 +54,18 @@ export var HorizontalRuleNode = /*#__PURE__*/function (_DecoratorNode) {
|
|
|
54
54
|
}, {
|
|
55
55
|
key: "decorate",
|
|
56
56
|
value: function decorate(editor) {
|
|
57
|
-
var _getKernelFromEditor
|
|
58
|
-
|
|
57
|
+
var _getKernelFromEditor;
|
|
58
|
+
var decorator = (_getKernelFromEditor = getKernelFromEditor(editor)) === null || _getKernelFromEditor === void 0 ? void 0 : _getKernelFromEditor.getDecorator('horizontalrule');
|
|
59
|
+
if (!decorator) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
if (typeof decorator === 'function') {
|
|
63
|
+
return decorator(this, editor);
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
queryDOM: decorator.queryDOM,
|
|
67
|
+
render: decorator.render(this, editor)
|
|
68
|
+
};
|
|
59
69
|
}
|
|
60
70
|
}], [{
|
|
61
71
|
key: "getType",
|
|
@@ -174,7 +174,7 @@ export function $createBlockImageNode(_ref) {
|
|
|
174
174
|
var altText = _ref.altText,
|
|
175
175
|
height = _ref.height,
|
|
176
176
|
_ref$maxWidth = _ref.maxWidth,
|
|
177
|
-
maxWidth = _ref$maxWidth === void 0 ?
|
|
177
|
+
maxWidth = _ref$maxWidth === void 0 ? 4200 : _ref$maxWidth,
|
|
178
178
|
src = _ref.src,
|
|
179
179
|
width = _ref.width,
|
|
180
180
|
key = _ref.key;
|
|
@@ -18,6 +18,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
18
18
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
19
|
import { INodeHelper } from "../../../editor-kernel/inode/helper";
|
|
20
20
|
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
21
|
+
import { INodeService } from "../../inode";
|
|
21
22
|
import { ILitexmlService } from "../../litexml";
|
|
22
23
|
import { IMarkdownShortCutService } from "../../markdown/service/shortcut";
|
|
23
24
|
import { IUploadService, UPLOAD_PRIORITY_HIGH } from "../../upload";
|
|
@@ -45,9 +46,10 @@ export var ImagePlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
45
46
|
key: "onInit",
|
|
46
47
|
value: function onInit(editor) {
|
|
47
48
|
var _this$config;
|
|
48
|
-
this.register(registerImageCommand(editor, this.config.handleUpload, (_this$config = this.config) === null || _this$config === void 0 ? void 0 : _this$config.defaultBlockImage));
|
|
49
|
+
this.register(registerImageCommand(editor, this.config.handleUpload, ((_this$config = this.config) === null || _this$config === void 0 ? void 0 : _this$config.defaultBlockImage) !== false));
|
|
49
50
|
this.registerMarkdown();
|
|
50
51
|
this.registerLiteXml();
|
|
52
|
+
this.registerINode();
|
|
51
53
|
this.registerUpload(editor);
|
|
52
54
|
}
|
|
53
55
|
}, {
|
|
@@ -70,7 +72,7 @@ export var ImagePlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
70
72
|
case 2:
|
|
71
73
|
imageWidth = _context.sent;
|
|
72
74
|
return _context.abrupt("return", editor.dispatchCommand(INSERT_IMAGE_COMMAND, {
|
|
73
|
-
block: (_this2$config = _this2.config) === null || _this2$config === void 0 ? void 0 : _this2$config.defaultBlockImage,
|
|
75
|
+
block: ((_this2$config = _this2.config) === null || _this2$config === void 0 ? void 0 : _this2$config.defaultBlockImage) !== false,
|
|
74
76
|
file: file,
|
|
75
77
|
maxWidth: imageWidth,
|
|
76
78
|
range: range
|
|
@@ -145,6 +147,8 @@ export var ImagePlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
145
147
|
}, {
|
|
146
148
|
key: "registerMarkdown",
|
|
147
149
|
value: function registerMarkdown() {
|
|
150
|
+
var _this$config2;
|
|
151
|
+
var defaultBlockImage = ((_this$config2 = this.config) === null || _this$config2 === void 0 ? void 0 : _this$config2.defaultBlockImage) !== false;
|
|
148
152
|
var markdownService = this.kernel.requireService(IMarkdownShortCutService);
|
|
149
153
|
if (!markdownService) {
|
|
150
154
|
return;
|
|
@@ -162,7 +166,7 @@ export var ImagePlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
162
166
|
markdownService.registerMarkdownReader('image', function (node) {
|
|
163
167
|
var altText = node.alt;
|
|
164
168
|
var src = node.url;
|
|
165
|
-
return INodeHelper.createTypeNode(ImageNode.getType(), {
|
|
169
|
+
return INodeHelper.createTypeNode(defaultBlockImage ? BlockImageNode.getType() : ImageNode.getType(), {
|
|
166
170
|
altText: altText,
|
|
167
171
|
showCaption: false,
|
|
168
172
|
src: src,
|
|
@@ -170,6 +174,32 @@ export var ImagePlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
170
174
|
});
|
|
171
175
|
});
|
|
172
176
|
}
|
|
177
|
+
}, {
|
|
178
|
+
key: "registerINode",
|
|
179
|
+
value: function registerINode() {
|
|
180
|
+
var service = this.kernel.requireService(INodeService);
|
|
181
|
+
if (!service) {
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
service.registerProcessNodeTree(function (_ref2) {
|
|
185
|
+
var root = _ref2.root;
|
|
186
|
+
// Process the root node
|
|
187
|
+
var loopNodes = function loopNodes(node) {
|
|
188
|
+
if ('children' in node && Array.isArray(node.children)) {
|
|
189
|
+
if (node.type === 'paragraph' && node.children.length === 1 && node.children[0].type === BlockImageNode.getType()) {
|
|
190
|
+
return node.children[0];
|
|
191
|
+
}
|
|
192
|
+
node.children = node.children.map(function (child) {
|
|
193
|
+
return loopNodes(child);
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return node;
|
|
197
|
+
};
|
|
198
|
+
root.children = root.children.map(function (child) {
|
|
199
|
+
return loopNodes(child);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
}
|
|
173
203
|
}, {
|
|
174
204
|
key: "getImageWidth",
|
|
175
205
|
value: function getImageWidth(file) {
|
|
@@ -212,7 +212,7 @@ var Image = /*#__PURE__*/memo(function (_ref) {
|
|
|
212
212
|
children: [children, showScaleInfo && isSelected && scale !== 1 && /*#__PURE__*/_jsxs("div", {
|
|
213
213
|
className: styles.scaleInfo,
|
|
214
214
|
children: [Math.round(scale * 100), "%"]
|
|
215
|
-
}), isHovered && /*#__PURE__*/_jsxs(_Fragment, {
|
|
215
|
+
}), isHovered && node.status === 'uploaded' && /*#__PURE__*/_jsxs(_Fragment, {
|
|
216
216
|
children: [/*#__PURE__*/_jsx(ResizeHandle, {
|
|
217
217
|
imageRef: imageRef,
|
|
218
218
|
isBlock: isBlock,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { IEditorPluginConstructor } from "../../../types";
|
|
2
|
+
/**
|
|
3
|
+
* NodePluginOptions - Configuration options for the Node plugin
|
|
4
|
+
*/
|
|
5
|
+
export interface INodePluginOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Enable or disable the node data source
|
|
8
|
+
* @default true
|
|
9
|
+
*/
|
|
10
|
+
enabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* LitexmlPlugin - A plugin that provides XML-based data source support
|
|
14
|
+
* Allows converting between Lexical editor state and XML format
|
|
15
|
+
*/
|
|
16
|
+
export declare const INodePlugin: IEditorPluginConstructor<INodePluginOptions>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var _class;
|
|
2
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
7
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
8
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
9
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
10
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
11
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
+
import { KernelPlugin } from "../../../editor-kernel/plugin";
|
|
17
|
+
import { INodeService, NodeService } from "../service";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* NodePluginOptions - Configuration options for the Node plugin
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* LitexmlPlugin - A plugin that provides XML-based data source support
|
|
25
|
+
* Allows converting between Lexical editor state and XML format
|
|
26
|
+
*/
|
|
27
|
+
export var INodePlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
28
|
+
_inherits(INodePlugin, _KernelPlugin);
|
|
29
|
+
var _super = _createSuper(INodePlugin);
|
|
30
|
+
function INodePlugin(kernel, config) {
|
|
31
|
+
var _this;
|
|
32
|
+
_classCallCheck(this, INodePlugin);
|
|
33
|
+
_this = _super.call(this);
|
|
34
|
+
|
|
35
|
+
// Create and register the Node service
|
|
36
|
+
_this.kernel = kernel;
|
|
37
|
+
_this.config = config;
|
|
38
|
+
var nodeService = new NodeService();
|
|
39
|
+
kernel.registerService(INodeService, nodeService);
|
|
40
|
+
return _this;
|
|
41
|
+
}
|
|
42
|
+
_createClass(INodePlugin, [{
|
|
43
|
+
key: "onInit",
|
|
44
|
+
value: function onInit() {
|
|
45
|
+
// Plugin initialization logic can be added here if needed
|
|
46
|
+
}
|
|
47
|
+
}]);
|
|
48
|
+
return INodePlugin;
|
|
49
|
+
}(KernelPlugin), _defineProperty(_class, "pluginName", 'INodePlugin'), _class);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
4
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
5
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
8
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
|
+
import { useLayoutEffect } from 'react';
|
|
10
|
+
import { useLexicalComposerContext } from "../../../editor-kernel/react";
|
|
11
|
+
import { INodePlugin } from "../plugin";
|
|
12
|
+
export var ReactNodePlugin = function ReactNodePlugin() {
|
|
13
|
+
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
14
|
+
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
15
|
+
editor = _useLexicalComposerCo2[0];
|
|
16
|
+
useLayoutEffect(function () {
|
|
17
|
+
editor.registerPlugin(INodePlugin);
|
|
18
|
+
}, [editor]);
|
|
19
|
+
return null;
|
|
20
|
+
};
|
|
21
|
+
ReactNodePlugin.displayName = 'ReactNodePlugin';
|
|
22
|
+
export default ReactNodePlugin;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IRootNode } from "../../../editor-kernel/inode";
|
|
2
|
+
export interface INodeService {
|
|
3
|
+
processNodeTree(inode: {
|
|
4
|
+
root: IRootNode;
|
|
5
|
+
}): void;
|
|
6
|
+
registerProcessNodeTree(process: (inode: {
|
|
7
|
+
root: IRootNode;
|
|
8
|
+
}) => void): void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Service ID for Node service
|
|
12
|
+
*/
|
|
13
|
+
export declare const INodeService: import("../../../types").IServiceID<INodeService>;
|
|
14
|
+
/**
|
|
15
|
+
* Default implementation of INodeService
|
|
16
|
+
*/
|
|
17
|
+
export declare class NodeService implements INodeService {
|
|
18
|
+
private processNodeTreeHandlers;
|
|
19
|
+
registerProcessNodeTree(process: (inode: {
|
|
20
|
+
root: IRootNode;
|
|
21
|
+
}) => void): void;
|
|
22
|
+
processNodeTree(inode: {
|
|
23
|
+
root: IRootNode;
|
|
24
|
+
}): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
import { genServiceId } from "../../../editor-kernel";
|
|
12
|
+
/**
|
|
13
|
+
* Service ID for Node service
|
|
14
|
+
*/
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-redeclare, no-redeclare
|
|
16
|
+
export var INodeService = genServiceId('INodeService');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Default implementation of INodeService
|
|
20
|
+
*/
|
|
21
|
+
export var NodeService = /*#__PURE__*/function () {
|
|
22
|
+
function NodeService() {
|
|
23
|
+
_classCallCheck(this, NodeService);
|
|
24
|
+
_defineProperty(this, "processNodeTreeHandlers", []);
|
|
25
|
+
}
|
|
26
|
+
_createClass(NodeService, [{
|
|
27
|
+
key: "registerProcessNodeTree",
|
|
28
|
+
value: function registerProcessNodeTree(process) {
|
|
29
|
+
this.processNodeTreeHandlers.push(process);
|
|
30
|
+
}
|
|
31
|
+
}, {
|
|
32
|
+
key: "processNodeTree",
|
|
33
|
+
value: function processNodeTree(inode) {
|
|
34
|
+
var _iterator = _createForOfIteratorHelper(this.processNodeTreeHandlers),
|
|
35
|
+
_step;
|
|
36
|
+
try {
|
|
37
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
38
|
+
var handler = _step.value;
|
|
39
|
+
handler(inode);
|
|
40
|
+
}
|
|
41
|
+
} catch (err) {
|
|
42
|
+
_iterator.e(err);
|
|
43
|
+
} finally {
|
|
44
|
+
_iterator.f();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}]);
|
|
48
|
+
return NodeService;
|
|
49
|
+
}();
|