platejs 54.0.0-beta.2 → 54.0.0-beta.4
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/README.md +1 -1
- package/THIRD_PARTY_NOTICES.md +56 -0
- package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +7 -3
- package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-D3Cb-QwH.d.ts} +7 -7
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/react/AIChatPlugin.js +113 -78
- package/dist/ai/react/CopilotPlugin.js +1 -1
- package/dist/ai/react/index.d.ts +23 -16
- package/dist/authored/index.d.ts +4 -4
- package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
- package/dist/code-block/codemirror/index.d.ts +1 -1
- package/dist/{combobox-DkBGgyd3.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
- package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +10 -2
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-BJG8l_mk.d.ts → core-BqR-fEDp.d.ts} +493 -116
- package/dist/diff/index.d.ts +2 -2
- package/dist/docs/ai.md +4 -3
- package/dist/docs/api/core/plate-components.md +0 -19
- package/dist/docs/api/core/plate-controller.md +5 -3
- package/dist/docs/api/core/plate-plugin.md +3 -0
- package/dist/docs/api/core/plate-store.md +3 -3
- package/dist/docs/api/core.md +45 -5
- package/dist/docs/api/dom.md +11 -4
- package/dist/docs/api/editor-transforms.md +2 -1
- package/dist/docs/api/react-hooks.md +45 -13
- package/dist/docs/authored-changes.md +9 -4
- package/dist/docs/basic-blocks.md +42 -29
- package/dist/docs/block-placeholder.md +4 -2
- package/dist/docs/blockquote.md +5 -3
- package/dist/docs/board.md +118 -10
- package/dist/docs/code-block.md +47 -0
- package/dist/docs/comment.md +2 -2
- package/dist/docs/discussion.md +1 -1
- package/dist/docs/document-model.md +15 -3
- package/dist/docs/docx.md +1 -1
- package/dist/docs/dom-coverage.md +5 -0
- package/dist/docs/editor.md +50 -4
- package/dist/docs/examples/editable-voids.md +2 -3
- package/dist/docs/external-text.md +2 -0
- package/dist/docs/field.md +370 -0
- package/dist/docs/find.md +9 -6
- package/dist/docs/form.md +2 -0
- package/dist/docs/heading.md +6 -0
- package/dist/docs/installation/manual.md +0 -4
- package/dist/docs/link.md +3 -3
- package/dist/docs/llms.txt +4 -2
- package/dist/docs/markdown.md +270 -14
- package/dist/docs/plugin-components.md +13 -10
- package/dist/docs/plugin-input-rules.md +66 -15
- package/dist/docs/prompt-editor.md +205 -0
- package/dist/docs/roots.md +8 -6
- package/dist/docs/rtl.md +6 -4
- package/dist/docs/selection.md +7 -4
- package/dist/docs/suggestion.md +1 -1
- package/dist/docs/toolbar.md +26 -30
- package/dist/docs/upload.md +106 -17
- package/dist/docx/export/index.d.ts +3 -3
- package/dist/docx/export/lib/docxStaticComponents.js +12 -2
- package/dist/docx/export/lib/exportDocx.js +46 -17
- package/dist/docx/export/lib/internal/xml-builder.js +11 -16
- package/dist/docx/export/lib/reviewPart.js +1 -1
- package/dist/docx/export/lib/reviewProjection.js +52 -10
- package/dist/docx/import/index.d.ts +4 -4
- package/dist/docx/paste/index.d.ts +4 -4
- package/dist/dom/index.d.ts +1 -6
- package/dist/dom/plite-dom.internal.js +2 -2
- package/dist/excalidraw/index.d.ts +3 -2
- package/dist/excalidraw/react/index.d.ts +3 -2
- package/dist/facade.js +2 -2
- package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
- package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
- package/dist/features/board/index.d.ts +2 -2
- package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
- package/dist/features/board/lib/boardStroke.internal.js +13 -1
- package/dist/features/board/lib/boardTypes.internal.js +16 -0
- package/dist/features/callout/index.d.ts +3 -2
- package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
- package/dist/features/combobox/index.d.ts +2 -2
- package/dist/features/comments/BaseCommentsPlugin.js +33 -17
- package/dist/features/comments/index.d.ts +1 -1
- package/dist/features/date/index.d.ts +3 -2
- package/dist/features/details/index.d.ts +3 -2
- package/dist/features/details/lib/BaseDetailsPlugin.js +25 -12
- package/dist/features/field/index.d.ts +2 -0
- package/dist/features/field/index.js +4 -0
- package/dist/features/field/lib/BaseFieldPlugin.js +360 -0
- package/dist/features/field/lib/applyFieldValues.js +188 -0
- package/dist/features/field/lib/fieldRules.internal.js +204 -0
- package/dist/features/find/index.d.ts +3 -2
- package/dist/features/footnote/index.d.ts +1 -1
- package/dist/features/ink/index.d.ts +1 -1
- package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
- package/dist/features/ink/lib/inkCodec.internal.js +130 -0
- package/dist/features/ink/lib/inkGone.internal.js +229 -48
- package/dist/features/ink/lib/inkPlaces.internal.js +534 -64
- package/dist/features/layout/index.d.ts +1 -1
- package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
- package/dist/features/lint/index.d.ts +3 -2
- package/dist/features/media/index.d.ts +2 -2
- package/dist/features/media/index.js +2 -2
- package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +206 -4
- package/dist/features/mention/index.d.ts +5 -4
- package/dist/features/suggestion/index.d.ts +1 -1
- package/dist/features/table/index.d.ts +1 -1
- package/dist/features/table/lib/BaseTablePlugin.js +64 -15
- package/dist/features/table/lib/internal/selection.js +4 -2
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/upload/index.d.ts +2 -2
- package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
- package/dist/history/index.d.ts +2 -2
- package/dist/html/index.d.ts +3 -3
- package/dist/html/server/index.d.ts +1 -1
- package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-eT2ZGDAj.d.ts} +2 -31
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-DzD6BIFJ.d.ts → index-B33E1CRJ.d.ts} +295 -6
- package/dist/{index-Cl77E9yr.d.ts → index-B7moSod7.d.ts} +2 -2
- package/dist/{index-hsC_sOn2.d.ts → index-B8-5Sr7I.d.ts} +35 -5
- package/dist/{index-BiQerPJS.d.ts → index-B8QJDAmG.d.ts} +2 -2
- package/dist/{index-BBKGrsG3.d.ts → index-BTx5oK7k.d.ts} +1 -1
- package/dist/{index-iaZOhA76.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
- package/dist/{index-BU6k1Aev.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +4781 -4584
- package/dist/{index-kLKMc-pI.d.ts → index-BXwU9QH6.d.ts} +2 -2
- package/dist/{index-DTgaSxKr.d.ts → index-BkwR-5hH.d.ts} +40 -4
- package/dist/{index-Bq3sdm3S.d.ts → index-BsV2McRr.d.ts} +5 -4
- package/dist/index-C9Fu-P4E.d.ts +773 -0
- package/dist/{index-D5W-p9bS.d.ts → index-Ca48r1ng.d.ts} +49 -4
- package/dist/{index-CcZbqPqk.d.ts → index-Cob_iBdu.d.ts} +116 -41
- package/dist/{index-Bxfvicyy.d.ts → index-CpY7Xnxw.d.ts} +4 -3
- package/dist/{index-BkR7-GLI.d.ts → index-DNQXzU-X.d.ts} +2 -2
- package/dist/{index-D1CFXA-i.d.ts → index-DPowErHa.d.ts} +471 -141
- package/dist/{index-DaM37gF6.d.ts → index-DShbzec2.d.ts} +38 -23
- package/dist/{index-DC_MNGyu.d.ts → index-DYdObeFQ.d.ts} +3 -3
- package/dist/{index-Bc2Yg_2j.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +2 -2
- package/dist/{index-CT7miqQN.d.ts → index-DwWQVwQt.d.ts} +29 -11
- package/dist/{index-xdmCBvlT.d.ts → index-JWgwL5l3.d.ts} +5 -2
- package/dist/{index-DLA2DUR2.d.ts → index-M781pyx9.d.ts} +4 -3
- package/dist/{index-DdIRduDG.d.ts → index-d7io3MzC.d.ts} +3 -2
- package/dist/index.d.ts +4 -4
- package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
- package/dist/internal/plugin/OverridePlugin.js +101 -119
- package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
- package/dist/internal/plugin/pastedUploadFiles.js +4 -0
- package/dist/internal/plugin/resolvePlugin.js +1 -1
- package/dist/internal/plugin/resolvePlugins.js +3 -0
- package/dist/internal/plugin/uploadDrafts.js +6 -0
- package/dist/internal/utils/mergePlugins.js +1 -0
- package/dist/lib/plugins/element-id/ElementIdPlugin.js +14 -18
- package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
- package/dist/lib/plugins/html/htmlSafety.js +1 -1
- package/dist/lib/plugins/input-rules/InputRulesPlugin.js +77 -28
- package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +3 -1
- package/dist/markdown/lib/MarkdownPlugin.js +14 -11
- package/dist/markdown/lib/RawHtmlPlugin.js +26 -0
- package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
- package/dist/markdown/lib/internal/markdownConversion.js +776 -74
- package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
- package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
- package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
- package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
- package/dist/markdown/lib/internal/markdownLine.js +5 -3
- package/dist/markdown/lib/internal/markdownMappings.js +19 -7
- package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
- package/dist/markdown/lib/internal/markdownRawHtml.js +353 -0
- package/dist/markdown/lib/internal/markdownSegments.js +57 -48
- package/dist/markdown/lib/internal/markdownTags.js +29 -9
- package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
- package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
- package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
- package/dist/math/index.d.ts +3 -2
- package/dist/math/react/index.d.ts +4 -3
- package/dist/migrations/index.d.ts +3 -3
- package/dist/migrations/migratePlateV54.js +4 -6
- package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
- package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
- package/dist/migrations/v53-manifest.internal.js +4 -0
- package/dist/pagination/index.d.ts +1 -1
- package/dist/pagination/react/index.d.ts +4 -4
- package/dist/react/components/EditorContentView.internal.js +42 -23
- package/dist/react/components/EditorProvider.js +5 -5
- package/dist/react/components/Plate.js +102 -128
- package/dist/react/components/PlateContainer.js +40 -32
- package/dist/react/components/PlateController.js +28 -16
- package/dist/react/components/PlateRoot.internal.js +3 -2
- package/dist/react/core.js +4 -4
- package/dist/react/features/board/BoardSurface.js +116 -87
- package/dist/react/features/board/boardClipboard.internal.js +15 -5
- package/dist/react/features/board/boardExport.internal.js +470 -0
- package/dist/react/features/board/boardGesture.internal.js +6 -3
- package/dist/react/features/board/boardIndex.internal.js +7 -18
- package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
- package/dist/react/features/board/boardPictures.internal.js +19 -13
- package/dist/react/features/board/boardView.internal.js +190 -50
- package/dist/react/features/board/boardVoice.internal.js +10 -11
- package/dist/react/features/board/index.d.ts +108 -18
- package/dist/react/features/callout/index.d.ts +3 -2
- package/dist/react/features/combobox/index.d.ts +8 -8
- package/dist/react/features/comments/index.d.ts +6 -5
- package/dist/react/features/date/index.d.ts +4 -3
- package/dist/react/features/details/index.d.ts +4 -3
- package/dist/react/features/field/FieldPlugin.js +35 -0
- package/dist/react/features/field/index.d.ts +315 -0
- package/dist/react/features/field/index.js +2 -0
- package/dist/react/features/footnote/index.d.ts +7 -6
- package/dist/react/features/format-painter/index.d.ts +4 -3
- package/dist/react/features/ink/InkContent.js +313 -0
- package/dist/react/features/ink/index.d.ts +57 -33
- package/dist/react/features/ink/index.js +2 -2
- package/dist/react/features/ink/inkCapture.internal.js +39 -17
- package/dist/react/features/ink/inkInput.internal.js +1 -1
- package/dist/react/features/ink/inkLayout.internal.js +6 -3
- package/dist/react/features/ink/inkPaint.internal.js +78 -2
- package/dist/react/features/ink/inkPlacement.internal.js +332 -104
- package/dist/react/features/ink/inkWatch.internal.js +7 -5
- package/dist/react/features/layout/index.d.ts +5 -4
- package/dist/react/features/media/index.d.ts +5 -4
- package/dist/react/features/mention/index.d.ts +6 -5
- package/dist/react/features/resizable/Resizable.js +4 -6
- package/dist/react/features/resizable/index.d.ts +5 -5
- package/dist/react/features/suggestion/index.d.ts +6 -5
- package/dist/react/features/table/TablePlugin.js +4 -11
- package/dist/react/features/table/index.d.ts +10 -8
- package/dist/react/features/table/useTableResize.js +10 -1
- package/dist/react/features/toc/index.d.ts +2 -2
- package/dist/react/features/upload/index.d.ts +11 -6
- package/dist/react/index.d.ts +6 -6
- package/dist/react/index.js +4 -4
- package/dist/react/internal/plate-context.js +434 -188
- package/dist/react/plite-react.js +2 -2
- package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
- package/dist/react/stores/plate/useEditor.js +32 -14
- package/dist/react/stores/plate/useEditorHistory.js +55 -0
- package/dist/react/stores/plate/useEditorSelector.js +79 -21
- package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
- package/dist/react/utils/pipeRenderElement.internal.js +1 -1
- package/dist/react/utils/pluginRenderElement.internal.js +1 -1
- package/dist/react/virtualized.d.ts +4 -4
- package/dist/{source-CNKy99Th.d.ts → source-BGohy8vH.d.ts} +4 -4
- package/dist/static/index.d.ts +18 -18
- package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
- package/dist/static/internal/staticPresentation.js +4 -4
- package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
- package/dist/tabbable/index.d.ts +1 -1
- package/dist/tabbable/react/index.d.ts +3 -3
- package/dist/testing/index.d.ts +3 -3
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/react/index.d.ts +6 -6
- package/package.json +20 -2
- package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
- package/dist/react/components/EditorSelectionView.js +0 -40
- package/dist/react/features/ink/InkLayer.js +0 -218
- package/dist/react/internal/createPlateTargetScope.js +0 -62
|
@@ -6,7 +6,7 @@ import { isUrl } from "../../lib/utils/isUrl.js";
|
|
|
6
6
|
import { PLUGINS } from "../../utils/plate-keys.js";
|
|
7
7
|
import { ElementApi, NodeApi, TextApi } from "../../core.js";
|
|
8
8
|
import { markdownMappingsRegistryKey } from "./internal/markdownMappings.js";
|
|
9
|
-
import { createMarkdownOperationRuntime, createMarkdownRuntime, parseMarkdownDocumentWithRuntime, parseMarkdownInlineWithRuntime, parseMarkdownSliceWithRuntime, prepareMarkdownRuntime, serializeMarkdownSliceWithRuntime, serializeMarkdownWithRuntime, withMarkdownRuntime } from "./internal/markdownConversion.js";
|
|
9
|
+
import { createMarkdownOperationRuntime, createMarkdownRuntime, parseMarkdownDocumentWithRuntime, parseMarkdownInlineWithRuntime, parseMarkdownSliceWithRuntime, prepareMarkdownRuntime, serializeMarkdownSliceWithRuntime, serializeMarkdownWithRuntime, withMarkdownRuntime, writesRawHtml } from "./internal/markdownConversion.js";
|
|
10
10
|
//#region src/markdown/lib/MarkdownPlugin.ts
|
|
11
11
|
const shouldParseMarkdown = (data, source) => {
|
|
12
12
|
if (source.getData("text/html")) return false;
|
|
@@ -51,17 +51,20 @@ const toMarkdownBlocks = (runtime, children) => {
|
|
|
51
51
|
};
|
|
52
52
|
const serializeMarkdownDataTransferSlice = (runtime, slice, state) => {
|
|
53
53
|
if (slice.openStart === 0 && slice.openEnd === 0) {
|
|
54
|
-
const result = serializeMarkdownSliceWithRuntime(runtime, toMarkdownBlocks(runtime, slice.content), slice.roots);
|
|
54
|
+
const { result } = serializeMarkdownSliceWithRuntime(runtime, toMarkdownBlocks(runtime, slice.content), slice.roots);
|
|
55
55
|
return result.ok ? result.data : null;
|
|
56
56
|
}
|
|
57
57
|
let failed = false;
|
|
58
|
+
let lastPrintedKind;
|
|
58
59
|
const serialize = (children) => {
|
|
59
|
-
const result = serializeMarkdownSliceWithRuntime(runtime, toMarkdownBlocks(runtime, children), slice.roots);
|
|
60
|
+
const { lastKind, result } = serializeMarkdownSliceWithRuntime(runtime, toMarkdownBlocks(runtime, children), slice.roots, lastPrintedKind);
|
|
60
61
|
if (!result.ok) {
|
|
61
62
|
failed = true;
|
|
62
63
|
return "";
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
+
const data = writesRawHtml(runtime, runtime.options.plainMarks) ? result.data.replace(/\n+$/, "") : result.data.trimEnd();
|
|
66
|
+
if (data.trim()) lastPrintedKind = lastKind;
|
|
67
|
+
return data;
|
|
65
68
|
};
|
|
66
69
|
const paragraphType = runtime.registry.type(PLUGINS.paragraph) ?? "paragraph";
|
|
67
70
|
const serializeOpenNodes = (nodes, openStart, openEnd) => {
|
|
@@ -69,16 +72,16 @@ const serializeMarkdownDataTransferSlice = (runtime, slice, state) => {
|
|
|
69
72
|
return nodes.map((node, index) => serializeOpenNode(node, index === 0 ? openStart : 0, index === lastIndex ? openEnd : 0)).join("\n\n");
|
|
70
73
|
};
|
|
71
74
|
const serializeOpenNode = (node, openStart, openEnd) => {
|
|
72
|
-
if (openStart === 0 && openEnd === 0 || !ElementApi.isElement(node)) return serialize([node])
|
|
73
|
-
if (
|
|
74
|
-
const hasOnlyInlineChildren = node.children.every((child) => !ElementApi.isElement(child) || state.schema.isInline(child));
|
|
75
|
-
if (hasOnlyInlineChildren && state.schema.element(node.type)?.slice.preserveContext) return NodeApi.string(node);
|
|
76
|
-
if (hasOnlyInlineChildren) return serialize([{
|
|
75
|
+
if (openStart === 0 && openEnd === 0 || !ElementApi.isElement(node)) return serialize([node]);
|
|
76
|
+
if (node.children.every((child) => !ElementApi.isElement(child) || state.schema.isInline(child))) return serialize([{
|
|
77
77
|
children: node.children,
|
|
78
78
|
type: paragraphType
|
|
79
|
-
}])
|
|
79
|
+
}]);
|
|
80
80
|
const unwrapped = serializeOpenNodes(node.children, Math.max(0, openStart - 1), Math.max(0, openEnd - 1));
|
|
81
|
-
return unwrapped.trim() ? unwrapped : node.children.map(
|
|
81
|
+
return unwrapped.trim() ? unwrapped : serialize(node.children.map((child) => ({
|
|
82
|
+
children: [{ text: NodeApi.string(child) }],
|
|
83
|
+
type: paragraphType
|
|
84
|
+
})));
|
|
82
85
|
};
|
|
83
86
|
const data = slice.content.length === 0 ? "" : `${serializeOpenNodes(slice.content, slice.openStart, slice.openEnd)}\n`;
|
|
84
87
|
return failed ? null : data;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { definePlugin } from "../../lib/plugin/definePlugin.js";
|
|
2
|
+
import { property } from "../../core.js";
|
|
3
|
+
//#region src/markdown/lib/RawHtmlPlugin.ts
|
|
4
|
+
/**
|
|
5
|
+
* Marks text that Markdown import kept from raw HTML, such as a README's
|
|
6
|
+
* centered header or an HTML comment, so Markdown export writes it back as
|
|
7
|
+
* HTML when its block passes Plate's safety check and as escaped text
|
|
8
|
+
* otherwise. Install it beside `MarkdownPlugin`. Every other format writes the
|
|
9
|
+
* text as plain visible text.
|
|
10
|
+
*/
|
|
11
|
+
const RawHtmlPlugin = definePlugin("rawHtml", {
|
|
12
|
+
schema: { mark: {
|
|
13
|
+
inclusive: false,
|
|
14
|
+
property: property.boolean({
|
|
15
|
+
default: false,
|
|
16
|
+
omitDefault: true
|
|
17
|
+
})
|
|
18
|
+
} },
|
|
19
|
+
formats: ({ defineFormats }) => defineFormats({ html: {
|
|
20
|
+
decode: () => void 0,
|
|
21
|
+
encode: ({ value }) => value ? { tag: "span" } : null,
|
|
22
|
+
match: [{ tag: "span" }]
|
|
23
|
+
} })
|
|
24
|
+
});
|
|
25
|
+
//#endregion
|
|
26
|
+
export { RawHtmlPlugin };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { buildSlateNode } from "./convertNodesDeserialize.js";
|
|
2
2
|
//#region src/markdown/lib/deserializer/mdastToSlate.ts
|
|
3
3
|
const mdastToSlate = (root, options) => {
|
|
4
4
|
root.children = root.children.map((child) => {
|
|
@@ -7,12 +7,22 @@ const mdastToSlate = (root, options) => {
|
|
|
7
7
|
type: "text",
|
|
8
8
|
value: ""
|
|
9
9
|
}],
|
|
10
|
+
position: child.position,
|
|
10
11
|
type: "paragraph"
|
|
11
12
|
};
|
|
12
13
|
return child;
|
|
13
14
|
});
|
|
14
15
|
options.onRootChildren?.(root.children);
|
|
15
|
-
|
|
16
|
+
const marks = {};
|
|
17
|
+
const nodes = [];
|
|
18
|
+
const counts = [];
|
|
19
|
+
root.children.forEach((child, index) => {
|
|
20
|
+
const converted = buildSlateNode(child, marks, options, index === 0 ? options.previousRootSibling ?? null : root.children[index - 1]);
|
|
21
|
+
counts.push(converted.length);
|
|
22
|
+
for (const node of converted) nodes.push(node);
|
|
23
|
+
});
|
|
24
|
+
options.onRootBlocks?.(counts);
|
|
25
|
+
return nodes;
|
|
16
26
|
};
|
|
17
27
|
//#endregion
|
|
18
28
|
export { mdastToSlate };
|