@lobehub/editor 1.4.7 → 1.5.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/editor-kernel/kernel.d.ts +4 -1
- package/es/editor-kernel/kernel.js +56 -1
- package/es/index.d.ts +2 -0
- package/es/index.js +2 -0
- package/es/locale/index.d.ts +7 -0
- package/es/locale/index.js +7 -0
- package/es/plugins/code/command/index.d.ts +3 -0
- package/es/plugins/code/command/index.js +48 -0
- package/es/plugins/code/index.d.ts +3 -0
- package/es/plugins/code/index.js +3 -0
- package/es/plugins/code/node/code.d.ts +19 -0
- package/es/plugins/{common/node/LexicalLineBreakNode.js → code/node/code.js} +93 -95
- package/es/plugins/code/plugin/index.d.ts +5 -0
- package/es/plugins/{common/node/ParagraphNode.js → code/plugin/index.js} +40 -33
- package/es/plugins/code/plugin/registry.d.ts +3 -0
- package/es/plugins/code/plugin/registry.js +48 -0
- package/es/plugins/code/react/CodeReactPlugin.d.ts +4 -0
- package/es/plugins/code/react/CodeReactPlugin.js +31 -0
- package/es/plugins/code/react/index.d.ts +1 -0
- package/es/plugins/code/react/index.js +1 -0
- package/es/plugins/code/react/style.d.ts +3 -0
- package/es/plugins/code/react/style.js +10 -0
- package/es/plugins/code/react/type.d.ts +3 -0
- package/es/plugins/code/react/type.js +1 -0
- package/es/plugins/common/data-source/json-data-source.js +42 -5
- package/es/plugins/common/data-source/text-data-source.js +2 -2
- package/es/plugins/common/index.d.ts +1 -0
- package/es/plugins/common/index.js +1 -0
- package/es/plugins/common/node/ElementDOMSlot.d.ts +3 -5
- package/es/plugins/common/node/ElementDOMSlot.js +29 -56
- package/es/plugins/common/node/cursor.d.ts +12 -0
- package/es/plugins/common/node/cursor.js +303 -0
- package/es/plugins/common/plugin/index.js +5 -9
- package/es/plugins/common/plugin/register.d.ts +3 -1
- package/es/plugins/common/plugin/register.js +46 -13
- package/es/plugins/link/command/index.d.ts +5 -1
- package/es/plugins/link/command/index.js +21 -3
- package/es/plugins/link/react/ReactLinkPlugin.js +6 -9
- package/es/plugins/link/react/components/LinkEdit.d.ts +2 -1
- package/es/plugins/link/react/components/LinkEdit.js +195 -51
- package/es/plugins/link/react/components/LinkToolbar.d.ts +10 -0
- package/es/plugins/link/react/components/LinkToolbar.js +73 -0
- package/es/plugins/link/react/style.d.ts +3 -2
- package/es/plugins/link/react/style.js +8 -5
- package/es/plugins/list/command/index.d.ts +1 -0
- package/es/plugins/list/command/index.js +1 -0
- package/es/plugins/list/plugin/checkList.d.ts +3 -0
- package/es/plugins/list/plugin/checkList.js +167 -0
- package/es/plugins/list/plugin/index.js +9 -2
- package/es/plugins/list/react/style.js +4 -2
- package/es/plugins/markdown/data-source/markdown-data-source.js +5 -1
- package/es/plugins/markdown/service/shortcut.d.ts +3 -3
- package/es/plugins/math/command/index.d.ts +13 -0
- package/es/plugins/math/command/index.js +47 -0
- package/es/plugins/math/index.d.ts +3 -0
- package/es/plugins/math/index.js +3 -0
- package/es/plugins/math/node/index.d.ts +45 -0
- package/es/plugins/math/node/index.js +259 -0
- package/es/plugins/math/plugin/index.d.ts +11 -0
- package/es/plugins/math/plugin/index.js +103 -0
- package/es/plugins/math/react/component/MathEditor.d.ts +10 -0
- package/es/plugins/math/react/component/MathEditor.js +253 -0
- package/es/plugins/math/react/component/MathEditorContainer.d.ts +14 -0
- package/es/plugins/math/react/component/MathEditorContainer.js +60 -0
- package/es/plugins/math/react/component/MathEditorContent.d.ts +26 -0
- package/es/plugins/math/react/component/MathEditorContent.js +163 -0
- package/es/plugins/math/react/component/MathInline.d.ts +10 -0
- package/es/plugins/math/react/component/MathInline.js +105 -0
- package/es/plugins/math/react/component/Placeholder.d.ts +3 -0
- package/es/plugins/math/react/component/Placeholder.js +19 -0
- package/es/plugins/math/react/index.d.ts +3 -0
- package/es/plugins/math/react/index.js +43 -0
- package/es/plugins/math/react/style.d.ts +6 -0
- package/es/plugins/math/react/style.js +16 -0
- package/es/plugins/math/react/type.d.ts +13 -0
- package/es/plugins/math/react/type.js +1 -0
- package/es/plugins/slash/react/ReactSlashPlugin.js +12 -10
- package/es/react/FloatMenu/FloatMenu.d.ts +4 -0
- package/es/react/FloatMenu/FloatMenu.js +49 -0
- package/es/react/FloatMenu/index.d.ts +2 -0
- package/es/react/FloatMenu/index.js +2 -0
- package/es/react/FloatMenu/type.d.ts +19 -0
- package/es/react/FloatMenu/type.js +1 -0
- package/es/react/SlashMenu/SlashMenu.js +32 -48
- package/es/react/SlashMenu/type.d.ts +5 -13
- package/es/react/hooks/useEditorState/index.d.ts +4 -0
- package/es/react/hooks/useEditorState/index.js +40 -4
- package/es/react/index.d.ts +1 -0
- package/es/react/index.js +1 -0
- package/es/types/global.d.ts +4 -0
- package/es/types/kernel.d.ts +26 -1
- package/package.json +2 -1
- package/es/plugins/common/node/LexicalLineBreakNode.d.ts +0 -31
- package/es/plugins/common/node/ParagraphNode.d.ts +0 -7
- package/es/plugins/link/react/components/Toolbar.d.ts +0 -7
- package/es/plugins/link/react/components/Toolbar.js +0 -63
- /package/es/react/{SlashMenu → FloatMenu}/style.d.ts +0 -0
- /package/es/react/{SlashMenu → FloatMenu}/style.js +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
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; } } }; }
|
|
2
|
+
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); }
|
|
3
|
+
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; }
|
|
4
|
+
import { mergeRegister } from '@lexical/utils';
|
|
5
|
+
import { $getNodeByKey, COMMAND_PRIORITY_EDITOR, KEY_DOWN_COMMAND, isModifierMatch } from 'lexical';
|
|
6
|
+
import { CONTROL_OR_META } from "../../../common/sys";
|
|
7
|
+
import { INSERT_CODEINLINE_COMMAND } from "../command";
|
|
8
|
+
import { CodeNode } from "../node/code";
|
|
9
|
+
export function registerCodeInline(editor, kernel) {
|
|
10
|
+
return mergeRegister(editor.registerUpdateListener(function (_ref) {
|
|
11
|
+
var mutatedNodes = _ref.mutatedNodes;
|
|
12
|
+
var codeChanged = mutatedNodes === null || mutatedNodes === void 0 ? void 0 : mutatedNodes.get(CodeNode);
|
|
13
|
+
var keys = (codeChanged === null || codeChanged === void 0 ? void 0 : codeChanged.keys()) || [];
|
|
14
|
+
editor.read(function () {
|
|
15
|
+
var _iterator = _createForOfIteratorHelper(keys),
|
|
16
|
+
_step;
|
|
17
|
+
try {
|
|
18
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
19
|
+
var key = _step.value;
|
|
20
|
+
var node = $getNodeByKey(key);
|
|
21
|
+
if (!node) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
var parent = node.getParent();
|
|
25
|
+
if ((parent === null || parent === void 0 ? void 0 : parent.__last) === key) {
|
|
26
|
+
var codeElement = editor.getElementByKey(key);
|
|
27
|
+
if (!(codeElement !== null && codeElement !== void 0 && codeElement.nextSibling)) {
|
|
28
|
+
parent
|
|
29
|
+
// @ts-expect-error not error
|
|
30
|
+
.getDOMSlot(editor.getElementByKey(parent.getKey())).setManagedLineBreak('decorator');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
} catch (err) {
|
|
35
|
+
_iterator.e(err);
|
|
36
|
+
} finally {
|
|
37
|
+
_iterator.f();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}), kernel.registerHighCommand(KEY_DOWN_COMMAND, function (payload) {
|
|
41
|
+
// ctrl + e
|
|
42
|
+
if (isModifierMatch(payload, CONTROL_OR_META) && payload.code === 'KeyE') {
|
|
43
|
+
payload.preventDefault();
|
|
44
|
+
return editor.dispatchCommand(INSERT_CODEINLINE_COMMAND, undefined);
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}, COMMAND_PRIORITY_EDITOR));
|
|
48
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
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/react-context";
|
|
11
|
+
import { MarkdownPlugin } from "../../markdown";
|
|
12
|
+
import { CodePlugin } from "../plugin";
|
|
13
|
+
import { useStyles } from "./style";
|
|
14
|
+
var ReactCodePlugin = function ReactCodePlugin(_ref) {
|
|
15
|
+
var className = _ref.className;
|
|
16
|
+
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
17
|
+
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
18
|
+
editor = _useLexicalComposerCo2[0];
|
|
19
|
+
var _useStyles = useStyles(),
|
|
20
|
+
cx = _useStyles.cx,
|
|
21
|
+
styles = _useStyles.styles;
|
|
22
|
+
useLayoutEffect(function () {
|
|
23
|
+
editor.registerPlugin(MarkdownPlugin);
|
|
24
|
+
editor.registerPlugin(CodePlugin, {
|
|
25
|
+
theme: cx(styles.codeInline, className)
|
|
26
|
+
});
|
|
27
|
+
}, []);
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
ReactCodePlugin.displayName = 'ReactCodePlugin';
|
|
31
|
+
export default ReactCodePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ReactCodePlugin } from './CodeReactPlugin';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ReactCodePlugin } from "./CodeReactPlugin";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var _templateObject;
|
|
2
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref) {
|
|
5
|
+
var css = _ref.css,
|
|
6
|
+
token = _ref.token;
|
|
7
|
+
return {
|
|
8
|
+
codeInline: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline;\n\n margin-inline: 0.25em;\n padding-block: 0.2em;\n padding-inline: 0.4em;\n border: 1px solid var(--lobe-markdown-border-color);\n border-radius: 0.25em;\n\n font-family: ", ";\n font-size: 0.875em;\n line-height: 1;\n word-break: break-word;\n white-space: break-spaces;\n\n background: ", ";\n "])), token.fontFamilyCode, token.colorFillSecondary)
|
|
9
|
+
};
|
|
10
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
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; }
|
|
5
2
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
3
|
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."); }
|
|
7
4
|
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); }
|
|
8
5
|
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; }
|
|
9
6
|
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; } }
|
|
10
7
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
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; }
|
|
11
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
12
12
|
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); } }
|
|
13
13
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
@@ -22,8 +22,17 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
22
22
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
23
23
|
/* eslint-disable unicorn/no-for-loop */
|
|
24
24
|
import { $isTableSelection } from '@lexical/table';
|
|
25
|
-
import { $getCharacterOffsets, $getNodeByKey, $getSelection, $isElementNode, $isRangeSelection, $isTextNode } from 'lexical';
|
|
25
|
+
import { $getCharacterOffsets, $getNodeByKey, $getSelection, $isElementNode, $isRangeSelection, $isTextNode, IS_CODE } from 'lexical';
|
|
26
26
|
import { DataSource } from "../../../editor-kernel";
|
|
27
|
+
var cursorNode = {
|
|
28
|
+
detail: 0,
|
|
29
|
+
format: 0,
|
|
30
|
+
mode: 'normal',
|
|
31
|
+
style: '',
|
|
32
|
+
text: "\uFEFF",
|
|
33
|
+
type: 'cursor',
|
|
34
|
+
version: 1
|
|
35
|
+
};
|
|
27
36
|
var JSONDataSource = /*#__PURE__*/function (_DataSource) {
|
|
28
37
|
_inherits(JSONDataSource, _DataSource);
|
|
29
38
|
var _super = _createSuper(JSONDataSource);
|
|
@@ -34,7 +43,35 @@ var JSONDataSource = /*#__PURE__*/function (_DataSource) {
|
|
|
34
43
|
_createClass(JSONDataSource, [{
|
|
35
44
|
key: "read",
|
|
36
45
|
value: function read(editor, data) {
|
|
37
|
-
|
|
46
|
+
var dataObj;
|
|
47
|
+
if (typeof data === 'string') {
|
|
48
|
+
dataObj = JSON.parse(data);
|
|
49
|
+
} else {
|
|
50
|
+
dataObj = data;
|
|
51
|
+
}
|
|
52
|
+
var process = function process(node) {
|
|
53
|
+
for (var i = 0; i < node.children.length; i++) {
|
|
54
|
+
var child = node.children[i];
|
|
55
|
+
if ('children' in child && Array.isArray(child.children)) {
|
|
56
|
+
process(child);
|
|
57
|
+
}
|
|
58
|
+
if (child.type === 'text' && 'format' in child && typeof child.format === 'number' && (child.format & IS_CODE) > 0) {
|
|
59
|
+
node.children[i] = {
|
|
60
|
+
children: [_objectSpread(_objectSpread({}, child), {}, {
|
|
61
|
+
format: child.format & ~IS_CODE
|
|
62
|
+
})],
|
|
63
|
+
direction: 'ltr',
|
|
64
|
+
format: '',
|
|
65
|
+
indent: 0,
|
|
66
|
+
type: 'codeInline',
|
|
67
|
+
version: 1
|
|
68
|
+
};
|
|
69
|
+
node.children.splice(i + 1, 0, cursorNode);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
process(dataObj.root);
|
|
74
|
+
editor.setEditorState(editor.parseEditorState(dataObj));
|
|
38
75
|
}
|
|
39
76
|
}, {
|
|
40
77
|
key: "write",
|
|
@@ -47,11 +47,11 @@ var TextDataSource = /*#__PURE__*/function (_DataSource) {
|
|
|
47
47
|
if (options !== null && options !== void 0 && options.selection) {
|
|
48
48
|
return editor.read(function () {
|
|
49
49
|
var selection = $getSelection();
|
|
50
|
-
return selection ? selection.getTextContent() : null;
|
|
50
|
+
return selection ? selection.getTextContent().replaceAll("\uFEFF", '') : null;
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
return editor.getEditorState().read(function () {
|
|
54
|
-
return $getRoot().getTextContent();
|
|
54
|
+
return $getRoot().getTextContent().replaceAll("\uFEFF", '');
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
57
|
}]);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
insertManagedLineBreak(webkitHack: boolean): void;
|
|
5
|
-
}
|
|
1
|
+
import { LexicalEditor } from 'lexical';
|
|
2
|
+
export declare function patchBreakLine(): void;
|
|
3
|
+
export declare function registerBreakLineClick(editor: LexicalEditor): () => void;
|
|
@@ -1,60 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
11
|
-
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); }; }
|
|
12
|
-
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); }
|
|
13
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
14
|
-
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; } }
|
|
15
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
16
|
-
import { ElementDOMSlot } from 'lexical';
|
|
17
|
-
// @ts-ignore
|
|
18
|
-
export var MElementDOMSlot = /*#__PURE__*/function (_ElementDOMSlot) {
|
|
19
|
-
_inherits(MElementDOMSlot, _ElementDOMSlot);
|
|
20
|
-
var _super = _createSuper(MElementDOMSlot);
|
|
21
|
-
function MElementDOMSlot() {
|
|
22
|
-
_classCallCheck(this, MElementDOMSlot);
|
|
23
|
-
return _super.apply(this, arguments);
|
|
1
|
+
import { CAN_USE_DOM, mergeRegister } from '@lexical/utils';
|
|
2
|
+
import { COMMAND_PRIORITY_HIGH, SELECTION_CHANGE_COMMAND } from 'lexical';
|
|
3
|
+
import { $getNodeFromDOMNode } from "../../../editor-kernel/utils";
|
|
4
|
+
export function patchBreakLine() {
|
|
5
|
+
// ignore
|
|
6
|
+
}
|
|
7
|
+
function getElement(node) {
|
|
8
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
9
|
+
return node;
|
|
24
10
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
11
|
+
return node.parentElement;
|
|
12
|
+
}
|
|
13
|
+
export function registerBreakLineClick(editor) {
|
|
14
|
+
return mergeRegister(editor.registerCommand(SELECTION_CHANGE_COMMAND, function () {
|
|
15
|
+
if (CAN_USE_DOM) {
|
|
16
|
+
var sel = document.getSelection();
|
|
17
|
+
if (sel !== null && sel !== void 0 && sel.anchorNode) {
|
|
18
|
+
var node = getElement(sel.anchorNode);
|
|
19
|
+
if (node !== null && node !== void 0 && node.hasAttribute('data-lexical-linebreak') && node.parentElement) {
|
|
20
|
+
var p = node.parentElement;
|
|
21
|
+
editor.update(function () {
|
|
22
|
+
var elem = $getNodeFromDOMNode(p, editor);
|
|
23
|
+
if (elem) {
|
|
24
|
+
elem.selectEnd();
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return true;
|
|
37
28
|
}
|
|
38
|
-
this.removeManagedLineBreak();
|
|
39
|
-
}
|
|
40
|
-
var element = this.element;
|
|
41
|
-
var before = this.before;
|
|
42
|
-
var br = document.createElement('br');
|
|
43
|
-
// eslint-disable-next-line unicorn/prefer-modern-dom-apis
|
|
44
|
-
element.insertBefore(br, before);
|
|
45
|
-
if (webkitHack) {
|
|
46
|
-
var img = document.createElement('img');
|
|
47
|
-
// eslint-disable-next-line unicorn/prefer-dom-node-dataset
|
|
48
|
-
img.setAttribute('data-lexical-linebreak', 'true');
|
|
49
|
-
img.style.cssText = 'display: inline !important; border: 0px !important; margin: 0px !important;';
|
|
50
|
-
img.alt = '';
|
|
51
|
-
// eslint-disable-next-line unicorn/prefer-modern-dom-apis
|
|
52
|
-
element.insertBefore(img, br);
|
|
53
|
-
element.__lexicalLineBreak = img;
|
|
54
|
-
} else {
|
|
55
|
-
element.__lexicalLineBreak = br;
|
|
56
29
|
}
|
|
57
30
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
31
|
+
return false;
|
|
32
|
+
}, COMMAND_PRIORITY_HIGH));
|
|
33
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ElementNode, LexicalEditor, LexicalNode, TextNode } from 'lexical';
|
|
2
|
+
export declare class CardLikeElementNode extends ElementNode {
|
|
3
|
+
isCardLike(): boolean;
|
|
4
|
+
}
|
|
5
|
+
export declare class CursorNode extends TextNode {
|
|
6
|
+
static getType(): string;
|
|
7
|
+
isUnmergeable(): boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function $createCursorNode(): CursorNode;
|
|
10
|
+
export declare function $isCardLikeElementNode(node: LexicalNode | null | undefined): node is CardLikeElementNode;
|
|
11
|
+
export declare function $isCursorNode(node: LexicalNode | null | undefined): node is CursorNode;
|
|
12
|
+
export declare function registerCursorNode(editor: LexicalEditor): () => void;
|