@lobehub/editor 3.1.1 → 3.2.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.
|
@@ -37,7 +37,7 @@ import JSONDataSource from "../data-source/json-data-source";
|
|
|
37
37
|
import TextDataSource from "../data-source/text-data-source";
|
|
38
38
|
import { patchBreakLine, registerBreakLineClick } from "../node/ElementDOMSlot";
|
|
39
39
|
import { CursorNode, registerCursorNode } from "../node/cursor";
|
|
40
|
-
import { $isCursorInQuote, $isCursorInTable, createBlockNode } from "../utils";
|
|
40
|
+
import { $isCursorInQuote, $isCursorInTable, createBlockNode, sampleReader } from "../utils";
|
|
41
41
|
import { registerMDReader } from "./mdReader";
|
|
42
42
|
import { registerHeaderBackspace, registerLastElement, registerRichKeydown } from "./register";
|
|
43
43
|
patchBreakLine();
|
|
@@ -400,8 +400,13 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
400
400
|
}
|
|
401
401
|
return false;
|
|
402
402
|
});
|
|
403
|
-
litexmlService.registerXMLReader('
|
|
404
|
-
|
|
403
|
+
litexmlService.registerXMLReader('b', sampleReader.bind(this, TEXT_TYPE_TO_FORMAT['bold']));
|
|
404
|
+
litexmlService.registerXMLReader('strong', sampleReader.bind(this, TEXT_TYPE_TO_FORMAT['bold']));
|
|
405
|
+
litexmlService.registerXMLReader('i', sampleReader.bind(this, TEXT_TYPE_TO_FORMAT['italic']));
|
|
406
|
+
litexmlService.registerXMLReader('emphasis', sampleReader.bind(this, TEXT_TYPE_TO_FORMAT['italic']));
|
|
407
|
+
litexmlService.registerXMLReader('u', sampleReader.bind(this, TEXT_TYPE_TO_FORMAT['underline']));
|
|
408
|
+
litexmlService.registerXMLReader('ins', sampleReader.bind(this, TEXT_TYPE_TO_FORMAT['underline']));
|
|
409
|
+
litexmlService.registerXMLReader('span', function (xmlElement, children) {
|
|
405
410
|
var bold = xmlElement.getAttribute('bold');
|
|
406
411
|
var italic = xmlElement.getAttribute('italic');
|
|
407
412
|
var underline = xmlElement.getAttribute('underline');
|
|
@@ -427,12 +432,12 @@ export var CommonPlugin = (_class = /*#__PURE__*/function (_KernelPlugin) {
|
|
|
427
432
|
if (superscript === 'true') {
|
|
428
433
|
format |= TEXT_TYPE_TO_FORMAT['superscript'];
|
|
429
434
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
style: ''
|
|
435
|
+
children.forEach(function (child) {
|
|
436
|
+
if (INodeHelper.isTextNode(child)) {
|
|
437
|
+
child.format = (child.format || 0) | format;
|
|
438
|
+
}
|
|
435
439
|
});
|
|
440
|
+
return children;
|
|
436
441
|
});
|
|
437
442
|
litexmlService.registerXMLWriter('quote', function (node, ctx) {
|
|
438
443
|
if ($isQuoteNode(node)) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ElementNode } from 'lexical';
|
|
2
2
|
import type { ElementTransformer } from "../../markdown/service/transformers";
|
|
3
|
+
export declare const sampleReader: (format: number, xmlElement: Element, children: any[]) => any[];
|
|
3
4
|
export declare const createBlockNode: (createNode: (match: Array<string>, parentNode: ElementNode) => ElementNode) => ElementTransformer['replace'];
|
|
4
5
|
/**
|
|
5
6
|
* Returns the root's text content.
|
|
@@ -7,6 +7,15 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
7
7
|
import { $isQuoteNode } from '@lexical/rich-text';
|
|
8
8
|
import { $isTableCellNode, $isTableNode } from '@lexical/table';
|
|
9
9
|
import { $getRoot, $isDecoratorNode, $isElementNode, $isParagraphNode, $isRangeSelection, $isTextNode } from 'lexical';
|
|
10
|
+
import { INodeHelper } from "../../../editor-kernel/inode/helper";
|
|
11
|
+
export var sampleReader = function sampleReader(format, xmlElement, children) {
|
|
12
|
+
children.forEach(function (child) {
|
|
13
|
+
if (INodeHelper.isTextNode(child)) {
|
|
14
|
+
child.format = (child.format || 0) | format;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
return children;
|
|
18
|
+
};
|
|
10
19
|
export var createBlockNode = function createBlockNode(createNode) {
|
|
11
20
|
return function (parentNode, children, match, isImport) {
|
|
12
21
|
var node = createNode(match, parentNode);
|
|
@@ -218,10 +218,14 @@ var LitexmlDataSource = /*#__PURE__*/function (_DataSource) {
|
|
|
218
218
|
var result = reader(xmlElement, children);
|
|
219
219
|
if (result !== false) {
|
|
220
220
|
if (Array.isArray(result)) {
|
|
221
|
+
if (result.length > 0) {
|
|
222
|
+
var attrId = xmlElement.getAttribute('id');
|
|
223
|
+
result[0].id = attrId ? charToId(attrId) : undefined;
|
|
224
|
+
}
|
|
221
225
|
INodeHelper.appendChild.apply(INodeHelper, [parentNode].concat(_toConsumableArray(result)));
|
|
222
226
|
} else if (result) {
|
|
223
|
-
var
|
|
224
|
-
result.id =
|
|
227
|
+
var _attrId = xmlElement.getAttribute('id');
|
|
228
|
+
result.id = _attrId ? charToId(_attrId) : undefined;
|
|
225
229
|
INodeHelper.appendChild(parentNode, result);
|
|
226
230
|
}
|
|
227
231
|
return; // Custom reader handled it
|
package/package.json
CHANGED