platejs 54.0.0-beta.3 → 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/dist/{AIChatRequestContext-DY104TqL.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
- package/dist/{BaseSuggestionPlugin-Deo6n6Fs.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +4 -4
- package/dist/{PlateStatic-CJX5bKuv.d.ts → PlateStatic-D3Cb-QwH.d.ts} +3 -3
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/react/index.d.ts +9 -9
- package/dist/authored/index.d.ts +3 -3
- package/dist/code-block/codemirror/index.d.ts +1 -1
- package/dist/{combobox-DAOYWuvC.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
- package/dist/{comparison-types-Dt-unJZY-DCddmbSD.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +1 -1
- package/dist/compiler/index.d.ts +2 -2
- package/dist/{core-ClHasORr.d.ts → core-BqR-fEDp.d.ts} +65 -26
- package/dist/diff/index.d.ts +2 -2
- package/dist/docs/api/core/plate-controller.md +1 -1
- package/dist/docs/api/core.md +45 -5
- package/dist/docs/api/dom.md +4 -7
- package/dist/docs/api/react-hooks.md +40 -22
- package/dist/docs/authored-changes.md +4 -2
- package/dist/docs/block-placeholder.md +4 -2
- package/dist/docs/board.md +57 -4
- package/dist/docs/comment.md +2 -2
- package/dist/docs/document-model.md +15 -3
- package/dist/docs/editor.md +50 -4
- package/dist/docs/llms.txt +1 -1
- package/dist/docs/markdown.md +97 -9
- package/dist/docs/plugin-input-rules.md +62 -3
- package/dist/docx/export/index.d.ts +3 -3
- package/dist/docx/export/lib/exportDocx.js +18 -13
- package/dist/docx/export/lib/internal/xml-builder.js +11 -16
- package/dist/docx/export/lib/reviewProjection.js +43 -3
- 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 -1
- package/dist/excalidraw/index.d.ts +3 -3
- package/dist/excalidraw/react/index.d.ts +3 -3
- package/dist/facade.js +2 -2
- package/dist/features/board/index.d.ts +1 -1
- package/dist/features/callout/index.d.ts +3 -3
- 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 -3
- package/dist/features/details/index.d.ts +3 -3
- package/dist/features/details/lib/BaseDetailsPlugin.js +15 -2
- package/dist/features/field/index.d.ts +2 -2
- package/dist/features/field/index.js +4 -2
- package/dist/features/field/lib/BaseFieldPlugin.js +51 -105
- package/dist/features/field/lib/applyFieldValues.js +188 -0
- package/dist/features/field/lib/fieldRules.internal.js +169 -7
- package/dist/features/find/index.d.ts +3 -3
- package/dist/features/footnote/index.d.ts +1 -1
- package/dist/features/ink/index.d.ts +1 -1
- package/dist/features/ink/lib/inkGone.internal.js +6 -6
- package/dist/features/ink/lib/inkPlaces.internal.js +8 -9
- package/dist/features/layout/index.d.ts +1 -1
- package/dist/features/lint/index.d.ts +3 -3
- package/dist/features/media/index.d.ts +2 -2
- package/dist/features/media/index.js +2 -2
- package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +200 -2
- package/dist/features/mention/index.d.ts +5 -5
- 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 +50 -7
- package/dist/features/toc/index.d.ts +1 -1
- package/dist/features/upload/index.d.ts +1 -1
- 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-cg_cWsaN.d.ts → htmlTypes-eT2ZGDAj.d.ts} +1 -1
- package/dist/hyperscript/index.d.ts +1 -1
- package/dist/{index-D3-2iM1b.d.ts → index-B33E1CRJ.d.ts} +291 -4
- package/dist/{index-DKOFvteF.d.ts → index-B7moSod7.d.ts} +1 -1
- package/dist/{index-C9DiGDVj.d.ts → index-B8-5Sr7I.d.ts} +2 -2
- package/dist/{index-CzLwBZpY.d.ts → index-B8QJDAmG.d.ts} +2 -2
- package/dist/{index-Cmuluh6f.d.ts → index-BTx5oK7k.d.ts} +1 -1
- package/dist/{index-DPWyk3lG-DOYwohXO.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
- package/dist/{index-DpltOCot-A2b3p3Eb.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +75 -27
- package/dist/{index-C6ql9pKw.d.ts → index-BXwU9QH6.d.ts} +2 -2
- package/dist/{index-CLsEe3LY.d.ts → index-BkwR-5hH.d.ts} +3 -3
- package/dist/{index-BZWFoUXt.d.ts → index-BsV2McRr.d.ts} +5 -5
- package/dist/{index-DQnjqtQa.d.ts → index-C9Fu-P4E.d.ts} +116 -21
- package/dist/{index-oIJAZxc2.d.ts → index-Ca48r1ng.d.ts} +3 -3
- package/dist/{index-Do9pj1GK.d.ts → index-Cob_iBdu.d.ts} +47 -6
- package/dist/{index-C1_JIhL4.d.ts → index-CpY7Xnxw.d.ts} +4 -4
- package/dist/{index-baQOK89E.d.ts → index-DNQXzU-X.d.ts} +1 -1
- package/dist/{index-8WO2vI0U.d.ts → index-DPowErHa.d.ts} +18 -20
- package/dist/{index-B5mYEawV.d.ts → index-DShbzec2.d.ts} +5 -6
- package/dist/{index-C35V_hj0.d.ts → index-DYdObeFQ.d.ts} +3 -3
- package/dist/{index-HPYawTae-BCUQLEWF.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +1 -1
- package/dist/{index-CdOLsPaW.d.ts → index-DwWQVwQt.d.ts} +3 -5
- package/dist/{index-r7yb77Wy.d.ts → index-JWgwL5l3.d.ts} +5 -3
- package/dist/{index-CktYvOgk.d.ts → index-M781pyx9.d.ts} +4 -4
- package/dist/{index-C0POz7rg.d.ts → index-d7io3MzC.d.ts} +3 -3
- package/dist/index.d.ts +4 -4
- package/dist/lib/plugins/element-id/ElementIdPlugin.js +6 -16
- package/dist/lib/plugins/input-rules/InputRulesPlugin.js +73 -14
- package/dist/markdown/index.d.ts +2 -2
- package/dist/markdown/index.js +2 -1
- package/dist/markdown/lib/MarkdownPlugin.js +8 -12
- package/dist/markdown/lib/RawHtmlPlugin.js +4 -2
- package/dist/markdown/lib/internal/markdownConversion.js +7 -4
- package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
- package/dist/markdown/lib/internal/markdownRawHtml.js +40 -1
- package/dist/markdown/lib/internal/markdownTags.js +7 -1
- package/dist/math/index.d.ts +3 -3
- package/dist/math/react/index.d.ts +4 -4
- 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 +2 -2
- package/dist/react/components/EditorContentView.internal.js +26 -16
- package/dist/react/components/Plate.js +13 -20
- package/dist/react/features/board/boardExport.internal.js +470 -0
- package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
- package/dist/react/features/board/boardView.internal.js +11 -6
- package/dist/react/features/board/index.d.ts +50 -6
- package/dist/react/features/callout/index.d.ts +3 -3
- package/dist/react/features/combobox/index.d.ts +5 -5
- package/dist/react/features/comments/index.d.ts +6 -6
- package/dist/react/features/date/index.d.ts +4 -4
- package/dist/react/features/details/index.d.ts +4 -4
- package/dist/react/features/field/FieldPlugin.js +5 -4
- package/dist/react/features/field/index.d.ts +19 -16
- package/dist/react/features/footnote/index.d.ts +7 -7
- package/dist/react/features/format-painter/index.d.ts +4 -4
- package/dist/react/features/ink/index.d.ts +5 -9
- package/dist/react/features/ink/inkPlacement.internal.js +2 -1
- package/dist/react/features/layout/index.d.ts +5 -5
- package/dist/react/features/media/index.d.ts +5 -5
- package/dist/react/features/mention/index.d.ts +6 -6
- package/dist/react/features/suggestion/index.d.ts +6 -6
- package/dist/react/features/table/index.d.ts +7 -6
- 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 +5 -5
- package/dist/react/index.d.ts +6 -6
- package/dist/react/internal/plate-context.js +20 -11
- package/dist/react/stores/plate/useEditorSelector.js +22 -9
- package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
- package/dist/react/virtualized.d.ts +2 -2
- package/dist/{source-aUwpNnAw.d.ts → source-BGohy8vH.d.ts} +3 -3
- package/dist/static/index.d.ts +5 -5
- package/dist/tabbable/index.d.ts +1 -1
- package/dist/tabbable/react/index.d.ts +3 -3
- package/dist/testing/index.d.ts +2 -2
- package/dist/yjs/index.d.ts +1 -1
- package/dist/yjs/react/index.d.ts +5 -5
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PointApi, RangeApi, editorCommands } from "../../../facade.js";
|
|
1
|
+
import { PointApi, RangeApi, attachTransactionSpecAfterCommit, editorCommands, getActiveCommandEditor, readEditorCommitHistoryEntry, reportEditorLifecycleError, runEditorObserver } from "../../../facade.js";
|
|
2
2
|
import { domCommands } from "../../../dom/plite-dom.internal.js";
|
|
3
3
|
import { getPlateRuntime } from "../../../internal/plugin/compilePlateModel.js";
|
|
4
4
|
import { createPlatePluginPortal } from "../../plugin/createPluginContext.internal.js";
|
|
@@ -8,8 +8,30 @@ import { isInputRuleVetoed } from "./inputRuleVeto.internal.js";
|
|
|
8
8
|
//#region src/lib/plugins/input-rules/InputRulesPlugin.ts
|
|
9
9
|
const insertsAtCaret = (at, selection) => !at || !!selection && (RangeApi.isRange(at) ? RangeApi.equals(at, selection) : PointApi.isPoint(at) && RangeApi.isCollapsed(selection) && PointApi.equals(at, selection.anchor));
|
|
10
10
|
const INPUT_RULE_TAG = "input-rule";
|
|
11
|
+
const PEER_SKIPPED_TAGS = /* @__PURE__ */ new Set(["collaboration", "skip-collab"]);
|
|
12
|
+
const followUpRuleCache = /* @__PURE__ */ new WeakMap();
|
|
13
|
+
const followUpRulesOf = (rules) => {
|
|
14
|
+
let followUps = followUpRuleCache.get(rules);
|
|
15
|
+
if (!followUps) {
|
|
16
|
+
followUps = rules.filter((rule) => rule.followUp !== void 0);
|
|
17
|
+
followUpRuleCache.set(rules, followUps);
|
|
18
|
+
}
|
|
19
|
+
return followUps;
|
|
20
|
+
};
|
|
21
|
+
const isThenable = (value) => (typeof value === "object" || typeof value === "function") && value !== null && typeof value.then === "function";
|
|
11
22
|
const invalidApplyResult = () => /* @__PURE__ */ new Error("An input rule must return undefined or the result of next(...) or decline().");
|
|
12
23
|
const InputRulesPlugin = definePlugin("inputRules", { editOnly: true }).extend(({ editor }) => {
|
|
24
|
+
const refuseThenable = (value, pluginName, message) => {
|
|
25
|
+
new Promise((resolve) => {
|
|
26
|
+
resolve(value);
|
|
27
|
+
}).then(void 0, (error) => reportEditorLifecycleError(Object.freeze({
|
|
28
|
+
cause: error,
|
|
29
|
+
editor,
|
|
30
|
+
phase: "after-commit",
|
|
31
|
+
pluginName
|
|
32
|
+
})));
|
|
33
|
+
throw new Error(message);
|
|
34
|
+
};
|
|
13
35
|
const createCachedGetter = (compute) => {
|
|
14
36
|
let hasValue = false;
|
|
15
37
|
let value;
|
|
@@ -69,6 +91,7 @@ const InputRulesPlugin = definePlugin("inputRules", { editOnly: true }).extend((
|
|
|
69
91
|
return value;
|
|
70
92
|
});
|
|
71
93
|
return {
|
|
94
|
+
key: state.key,
|
|
72
95
|
plugin,
|
|
73
96
|
read: state
|
|
74
97
|
};
|
|
@@ -160,11 +183,9 @@ const InputRulesPlugin = definePlugin("inputRules", { editOnly: true }).extend((
|
|
|
160
183
|
text: input.getData("text/plain") || null,
|
|
161
184
|
...selectionContext
|
|
162
185
|
};
|
|
163
|
-
|
|
164
|
-
for (const rule of rules) {
|
|
165
|
-
context.plugin = rule.plugin;
|
|
186
|
+
const resolveRule = (rule, ruleContext) => {
|
|
166
187
|
const { enabled } = rule;
|
|
167
|
-
if (typeof enabled === "function" && !enabled(
|
|
188
|
+
if (typeof enabled === "function" && !enabled(ruleContext)) return;
|
|
168
189
|
if (rule.mimeTypes?.length && !rule.mimeTypes.some((type) => {
|
|
169
190
|
if (type === "Files") return (input.files?.length ?? 0) > 0;
|
|
170
191
|
if (dataTypes.has(type)) return true;
|
|
@@ -173,18 +194,55 @@ const InputRulesPlugin = definePlugin("inputRules", { editOnly: true }).extend((
|
|
|
173
194
|
} catch {
|
|
174
195
|
return false;
|
|
175
196
|
}
|
|
176
|
-
}))
|
|
197
|
+
})) return;
|
|
177
198
|
const { resolve } = rule;
|
|
178
|
-
|
|
199
|
+
return typeof resolve === "function" ? resolve(ruleContext) : true;
|
|
200
|
+
};
|
|
201
|
+
let accepted;
|
|
202
|
+
for (const rule of rules) {
|
|
203
|
+
const { apply } = rule;
|
|
204
|
+
if (!apply) continue;
|
|
205
|
+
context.plugin = rule.plugin;
|
|
206
|
+
const match = resolveRule(rule, context);
|
|
179
207
|
if (match === void 0) continue;
|
|
180
208
|
accepted = {
|
|
181
|
-
|
|
209
|
+
apply,
|
|
182
210
|
match,
|
|
183
211
|
rule
|
|
184
212
|
};
|
|
185
213
|
break;
|
|
186
214
|
}
|
|
187
|
-
|
|
215
|
+
let following;
|
|
216
|
+
for (const rule of followUpRulesOf(rules)) {
|
|
217
|
+
const match = resolveRule(rule, {
|
|
218
|
+
...context,
|
|
219
|
+
plugin: rule.plugin
|
|
220
|
+
});
|
|
221
|
+
if (match === void 0) continue;
|
|
222
|
+
if (isThenable(match)) refuseThenable(match, rule.plugin.name, "An input rule follow-up must resolve synchronously.");
|
|
223
|
+
following = {
|
|
224
|
+
match,
|
|
225
|
+
rule
|
|
226
|
+
};
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
const pastingView = following ? getActiveCommandEditor() : void 0;
|
|
230
|
+
const followed = (result) => {
|
|
231
|
+
if (!following || !pastingView || result === false || result.changes.empty) return result;
|
|
232
|
+
const { match, rule } = following;
|
|
233
|
+
return attachTransactionSpecAfterCommit(result, ({ commit }) => {
|
|
234
|
+
const replacedSelection = commit.tags.includes("replace-range");
|
|
235
|
+
const changedViewRoot = commit.changed.has("document", pastingView.read.view.root());
|
|
236
|
+
if (!readEditorCommitHistoryEntry(editor, commit) || commit.tags.some((tag) => PEER_SKIPPED_TAGS.has(tag)) || replacedSelection || !changedViewRoot || pastingView.read.view.isReadOnly()) return;
|
|
237
|
+
runEditorObserver(editor, "after-commit", () => {
|
|
238
|
+
pastingView.update({ tags: ["history-push"] }, (tx) => {
|
|
239
|
+
const returned = rule.followUp.call(rule, { tx }, match);
|
|
240
|
+
if (isThenable(returned)) refuseThenable(returned, rule.plugin.name, "An input rule follow-up must be synchronous.");
|
|
241
|
+
});
|
|
242
|
+
}, rule.plugin.name);
|
|
243
|
+
});
|
|
244
|
+
};
|
|
245
|
+
if (!accepted) return followed(next());
|
|
188
246
|
let outcome;
|
|
189
247
|
const prefix = state.transaction((tx) => {
|
|
190
248
|
let continued = false;
|
|
@@ -193,18 +251,19 @@ const InputRulesPlugin = definePlugin("inputRules", { editOnly: true }).extend((
|
|
|
193
251
|
continued = true;
|
|
194
252
|
return createInputRuleContinuation(data);
|
|
195
253
|
};
|
|
196
|
-
outcome = accepted.
|
|
197
|
-
...
|
|
254
|
+
outcome = accepted.apply.call(accepted.rule, {
|
|
255
|
+
...context,
|
|
198
256
|
decline: createInputRuleDecline,
|
|
199
257
|
next: ruleNext,
|
|
258
|
+
plugin: accepted.rule.plugin,
|
|
200
259
|
tx
|
|
201
260
|
}, accepted.match);
|
|
202
261
|
if (outcome !== void 0 && !isInputRuleContinuation(outcome) && !isInputRuleDecline(outcome)) throw invalidApplyResult();
|
|
203
262
|
});
|
|
204
|
-
if (outcome === void 0) return prefix;
|
|
205
|
-
if (isInputRuleDecline(outcome)) return next();
|
|
263
|
+
if (outcome === void 0) return followed(prefix);
|
|
264
|
+
if (isInputRuleDecline(outcome)) return followed(next());
|
|
206
265
|
const continuation = outcome;
|
|
207
|
-
return continuation.input === void 0 ? next.after(prefix) : next.after(prefix, continuation.input);
|
|
266
|
+
return followed(continuation.input === void 0 ? next.after(prefix) : next.after(prefix, continuation.input));
|
|
208
267
|
}),
|
|
209
268
|
around(editorCommands.insertBreak, ({ state, next }) => {
|
|
210
269
|
const rules = getPlateRuntime(editor).inputRules.insertBreak;
|
package/dist/markdown/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as
|
|
2
|
-
export { type MarkdownApi, type MarkdownDefinition, type MarkdownDiagnostic, type MarkdownDocumentParseResult, type MarkdownEditor, type MarkdownEditorSerializeOptions, type MarkdownErrorDiagnostic, type MarkdownFrontmatter, type MarkdownModelLocation, type MarkdownParseLimits, type MarkdownParseOptions, type MarkdownParsePolicy, MarkdownPlugin, type MarkdownPluginState, type MarkdownSerializeOptions, type MarkdownSerializePolicy, type MarkdownSerializeResult, type MarkdownSliceParseResult, type MarkdownSourceLocation, type MarkdownSyncPluggable, type MarkdownSyncPlugin, type MarkdownSyncTransformer, type MarkdownWarningDiagnostic, getMarkdownFrontmatter, parseMarkdown, serializeMarkdown };
|
|
1
|
+
import { A as MarkdownWarningDiagnostic, C as MarkdownSerializePolicy, D as MarkdownSyncPluggable, E as MarkdownSourceLocation, O as MarkdownSyncPlugin, S as MarkdownSerializeOptions, T as MarkdownSliceParseResult, _ as MarkdownFrontmatter, a as MarkdownPlugin, b as MarkdownParseOptions, c as serializeMarkdown, f as getMarkdownFrontmatter, g as MarkdownErrorDiagnostic, h as MarkdownEditorSerializeOptions, i as MarkdownEditor, k as MarkdownSyncTransformer, m as MarkdownDocumentParseResult, n as MarkdownApi, o as MarkdownPluginState, p as MarkdownDiagnostic, r as MarkdownDefinition, s as parseMarkdown, t as RawHtmlPlugin, v as MarkdownModelLocation, w as MarkdownSerializeResult, x as MarkdownParsePolicy, y as MarkdownParseLimits } from "../index-Cob_iBdu.js";
|
|
2
|
+
export { type MarkdownApi, type MarkdownDefinition, type MarkdownDiagnostic, type MarkdownDocumentParseResult, type MarkdownEditor, type MarkdownEditorSerializeOptions, type MarkdownErrorDiagnostic, type MarkdownFrontmatter, type MarkdownModelLocation, type MarkdownParseLimits, type MarkdownParseOptions, type MarkdownParsePolicy, MarkdownPlugin, type MarkdownPluginState, type MarkdownSerializeOptions, type MarkdownSerializePolicy, type MarkdownSerializeResult, type MarkdownSliceParseResult, type MarkdownSourceLocation, type MarkdownSyncPluggable, type MarkdownSyncPlugin, type MarkdownSyncTransformer, type MarkdownWarningDiagnostic, RawHtmlPlugin, getMarkdownFrontmatter, parseMarkdown, serializeMarkdown };
|
package/dist/markdown/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { getMarkdownFrontmatter } from "./lib/internal/markdownFrontmatter.js";
|
|
2
|
+
import { RawHtmlPlugin } from "./lib/RawHtmlPlugin.js";
|
|
2
3
|
import { MarkdownPlugin, parseMarkdown, serializeMarkdown } from "./lib/MarkdownPlugin.js";
|
|
3
|
-
export { MarkdownPlugin, getMarkdownFrontmatter, parseMarkdown, serializeMarkdown };
|
|
4
|
+
export { MarkdownPlugin, RawHtmlPlugin, getMarkdownFrontmatter, parseMarkdown, serializeMarkdown };
|
|
@@ -55,19 +55,15 @@ const serializeMarkdownDataTransferSlice = (runtime, slice, state) => {
|
|
|
55
55
|
return result.ok ? result.data : null;
|
|
56
56
|
}
|
|
57
57
|
let failed = false;
|
|
58
|
-
let
|
|
59
|
-
const verbatim = (text) => {
|
|
60
|
-
if (text.trim()) previousKind = "list";
|
|
61
|
-
return text;
|
|
62
|
-
};
|
|
58
|
+
let lastPrintedKind;
|
|
63
59
|
const serialize = (children) => {
|
|
64
|
-
const { lastKind, result } = serializeMarkdownSliceWithRuntime(runtime, toMarkdownBlocks(runtime, children), slice.roots,
|
|
60
|
+
const { lastKind, result } = serializeMarkdownSliceWithRuntime(runtime, toMarkdownBlocks(runtime, children), slice.roots, lastPrintedKind);
|
|
65
61
|
if (!result.ok) {
|
|
66
62
|
failed = true;
|
|
67
63
|
return "";
|
|
68
64
|
}
|
|
69
65
|
const data = writesRawHtml(runtime, runtime.options.plainMarks) ? result.data.replace(/\n+$/, "") : result.data.trimEnd();
|
|
70
|
-
if (data.trim())
|
|
66
|
+
if (data.trim()) lastPrintedKind = lastKind;
|
|
71
67
|
return data;
|
|
72
68
|
};
|
|
73
69
|
const paragraphType = runtime.registry.type(PLUGINS.paragraph) ?? "paragraph";
|
|
@@ -77,15 +73,15 @@ const serializeMarkdownDataTransferSlice = (runtime, slice, state) => {
|
|
|
77
73
|
};
|
|
78
74
|
const serializeOpenNode = (node, openStart, openEnd) => {
|
|
79
75
|
if (openStart === 0 && openEnd === 0 || !ElementApi.isElement(node)) return serialize([node]);
|
|
80
|
-
if (
|
|
81
|
-
const hasOnlyInlineChildren = node.children.every((child) => !ElementApi.isElement(child) || state.schema.isInline(child));
|
|
82
|
-
if (hasOnlyInlineChildren && state.schema.element(node.type)?.slice.preserveContext) return verbatim(NodeApi.string(node));
|
|
83
|
-
if (hasOnlyInlineChildren) return serialize([{
|
|
76
|
+
if (node.children.every((child) => !ElementApi.isElement(child) || state.schema.isInline(child))) return serialize([{
|
|
84
77
|
children: node.children,
|
|
85
78
|
type: paragraphType
|
|
86
79
|
}]);
|
|
87
80
|
const unwrapped = serializeOpenNodes(node.children, Math.max(0, openStart - 1), Math.max(0, openEnd - 1));
|
|
88
|
-
return unwrapped.trim() ? unwrapped :
|
|
81
|
+
return unwrapped.trim() ? unwrapped : serialize(node.children.map((child) => ({
|
|
82
|
+
children: [{ text: NodeApi.string(child) }],
|
|
83
|
+
type: paragraphType
|
|
84
|
+
})));
|
|
89
85
|
};
|
|
90
86
|
const data = slice.content.length === 0 ? "" : `${serializeOpenNodes(slice.content, slice.openStart, slice.openEnd)}\n`;
|
|
91
87
|
return failed ? null : data;
|
|
@@ -3,8 +3,10 @@ import { property } from "../../core.js";
|
|
|
3
3
|
//#region src/markdown/lib/RawHtmlPlugin.ts
|
|
4
4
|
/**
|
|
5
5
|
* Marks text that Markdown import kept from raw HTML, such as a README's
|
|
6
|
-
* centered header or an HTML comment
|
|
7
|
-
*
|
|
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.
|
|
8
10
|
*/
|
|
9
11
|
const RawHtmlPlugin = definePlugin("rawHtml", {
|
|
10
12
|
schema: { mark: {
|
|
@@ -15,8 +15,9 @@ import { DEFAULT_MARKDOWN_PARSE_LIMITS, MarkdownDiagnostics, ReportedMarkdownFai
|
|
|
15
15
|
import { compileMarkdownMappings, getMarkdownMappingsRegistryKey, getRegisteredMarkdownMappings, registerMarkdownMappings } from "./markdownMappings.js";
|
|
16
16
|
import { mdastToSlate } from "../deserializer/mdastToSlate.js";
|
|
17
17
|
import { materializeMarkdownSettings, materializeRemarkPlugins } from "../utils/remarkPlugins.js";
|
|
18
|
+
import { remarkFootnoteDefinitionWriter } from "./markdownFootnoteWriter.js";
|
|
18
19
|
import { keepsReceived, remarkOpenTail } from "./markdownOpenTail.js";
|
|
19
|
-
import { createRawHtmlPlacementDecider, decideRawHtmlBlocks, printsNoText } from "./markdownRawHtml.js";
|
|
20
|
+
import { createRawHtmlPlacementDecider, decideRawHtmlBlocks, printsNoText, readMathSafely, writeMathSafely } from "./markdownRawHtml.js";
|
|
20
21
|
import { allocateMarkdownFootnoteLabels, remarkResolveMarkdownReferences } from "./markdownReferences.js";
|
|
21
22
|
import { cleanMarkdownDestinations } from "./markdownSafety.js";
|
|
22
23
|
import { DEFINITION_SYNTAX, MARKDOWN_DEFINITION, countMarkdownLines, findMarkdownSegmentBoundaries, holdsMarkdownSegmentOpen, readsMarkdownWhole, shiftMarkdownDiagnostic } from "./markdownSegments.js";
|
|
@@ -94,7 +95,7 @@ const getMergedOptionsSerialize = (runtime, options = {}, documentOverride, diag
|
|
|
94
95
|
plainMarks: plain,
|
|
95
96
|
preserveEmptyParagraphs: options.preserveEmptyParagraphs,
|
|
96
97
|
...writesRawHtml(runtime, plain) ? { rawHtml: { decide: createRawHtmlPlacementDecider({
|
|
97
|
-
commonmark:
|
|
98
|
+
commonmark: readCommonMark,
|
|
98
99
|
editor: (source) => getRawHtmlEditorReader(runtime)(source)
|
|
99
100
|
}) } } : {},
|
|
100
101
|
readRoots,
|
|
@@ -106,8 +107,9 @@ const getMergedOptionsSerialize = (runtime, options = {}, documentOverride, diag
|
|
|
106
107
|
value: [...document.children]
|
|
107
108
|
};
|
|
108
109
|
};
|
|
109
|
-
const createMarkdownParser = (runtime, remarkPlugins, openTail) => unified().use(remarkParse).use(remarkSeparateEscapes).use(remarkMarkdownTags, { tags: runtime.formats.tags }).use(remarkResolveMarkdownReferences).use(openTail ? [[remarkOpenTail, openTail]] : []).use(remarkPlugins);
|
|
110
|
+
const createMarkdownParser = (runtime, remarkPlugins, openTail) => unified().use(remarkParse).use(remarkSeparateEscapes).use(remarkMarkdownTags, { tags: runtime.formats.tags }).use(remarkResolveMarkdownReferences).use(openTail ? [[remarkOpenTail, openTail]] : []).use(remarkPlugins).use(() => readMathSafely);
|
|
110
111
|
const COMMONMARK = unified().use(remarkParse).freeze();
|
|
112
|
+
const readCommonMark = (source) => COMMONMARK.parse(source);
|
|
111
113
|
const samePlugins = (cached, remarkPlugins) => cached.remarkPlugins.length === remarkPlugins.length && cached.remarkPlugins.every((plugin, index) => plugin === remarkPlugins[index]);
|
|
112
114
|
const rawHtmlEditorReaders = /* @__PURE__ */ new WeakMap();
|
|
113
115
|
const getRawHtmlEditorReader = (runtime) => {
|
|
@@ -228,7 +230,7 @@ const remarkEscapeDollars = function() {
|
|
|
228
230
|
const createMarkdownStringifier = (context, unwritable) => {
|
|
229
231
|
const app = context.remarkStringifyOptions;
|
|
230
232
|
const { join: appJoin, ...appWithoutJoin } = app ?? {};
|
|
231
|
-
return unified().use(remarkMarkdownTagWriter).use(context.remarkPlugins).use(remarkEscapeDollars).use(function remarkUnwritableNodeWriter() {
|
|
233
|
+
return unified().use(remarkMarkdownTagWriter).use(context.remarkPlugins).use(remarkEscapeDollars).use(remarkFootnoteDefinitionWriter, { read: readCommonMark }).use(function remarkUnwritableNodeWriter() {
|
|
232
234
|
const data = this.data();
|
|
233
235
|
(data.toMarkdownExtensions ??= []).push(unwritable);
|
|
234
236
|
}).use(function remarkRawHtmlJoin() {
|
|
@@ -281,6 +283,7 @@ const encodeMarkdownBody = (context) => {
|
|
|
281
283
|
}));
|
|
282
284
|
const transformed = toRemarkProcessor.runSync(tree);
|
|
283
285
|
writeBareUrlsSafely(transformed);
|
|
286
|
+
writeMathSafely(transformed, readCommonMark);
|
|
284
287
|
const configuredWriters = /* @__PURE__ */ new Set();
|
|
285
288
|
[
|
|
286
289
|
...toRemarkProcessor.data("toMarkdownExtensions") ?? [],
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { decideUrl } from "../../../internal/utils/urlPolicy.js";
|
|
2
|
+
//#region src/markdown/lib/internal/markdownFootnoteWriter.ts
|
|
3
|
+
const DEFINITION_START = /^(\[\^(?:\\.|[^\\\]])*\]:)(?: |\n {4})/;
|
|
4
|
+
const definesRefusedUrl = (node) => node.type === "definition" ? !decideUrl("navigation", node.url).ok : "children" in node && node.children.some(definesRefusedUrl);
|
|
5
|
+
const findHandler = (extensions, name) => {
|
|
6
|
+
let found;
|
|
7
|
+
for (const extension of extensions) {
|
|
8
|
+
found = findHandler(extension.extensions ?? [], name) ?? found;
|
|
9
|
+
found = extension.handlers?.[name] ?? found;
|
|
10
|
+
}
|
|
11
|
+
return found;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* CommonMark without footnotes reads `[^1]: javascript:alert(1)` as a link
|
|
15
|
+
* definition, which turns every `[^1]` into a link to that destination, and
|
|
16
|
+
* the definitions after it, such as a `$$` block's TeX lines, read the same
|
|
17
|
+
* way. A footnote that `read`, the CommonMark reader, reads as defining a URL
|
|
18
|
+
* the navigation policy refuses starts its content after a blank line, which
|
|
19
|
+
* both readers read as the same footnote and CommonMark as indented code.
|
|
20
|
+
*/
|
|
21
|
+
const remarkFootnoteDefinitionWriter = function({ read }) {
|
|
22
|
+
const data = this.data();
|
|
23
|
+
data.toMarkdownExtensions ??= [];
|
|
24
|
+
const extensions = data.toMarkdownExtensions;
|
|
25
|
+
const write = findHandler(extensions, "footnoteDefinition");
|
|
26
|
+
if (!write) return;
|
|
27
|
+
extensions.push({ handlers: { footnoteDefinition: (...args) => {
|
|
28
|
+
const value = write(...args);
|
|
29
|
+
const start = DEFINITION_START.exec(value);
|
|
30
|
+
if (!start || !definesRefusedUrl(read(value))) return value;
|
|
31
|
+
return `${start[1]}\n\n ${value.slice(start[0].length)}`;
|
|
32
|
+
} } });
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { remarkFootnoteDefinitionWriter };
|
|
@@ -68,6 +68,45 @@ const decideRawHtml = (value) => {
|
|
|
68
68
|
}).write(value, true);
|
|
69
69
|
return refusal ? refuse(refusal) : PASS;
|
|
70
70
|
};
|
|
71
|
+
const INLINE_MARKUP_AFTER_LT = /[A-Za-z][A-Za-z\d-]*(?:\s*\/?>|\s+[A-Za-z_:])|\/[A-Za-z][A-Za-z\d-]*\s*>|!(?:--|[A-Za-z]|\[CDATA\[)|\?|[A-Za-z][A-Za-z\d+.-]{1,31}:[^\0- <>]*(?:>|$)/.source;
|
|
72
|
+
const MARKUP_LT = new RegExp(`<(?=${INLINE_MARKUP_AFTER_LT})`, "g");
|
|
73
|
+
const TEXT_LT = new RegExp(`<(?!${INLINE_MARKUP_AFTER_LT})`, "g");
|
|
74
|
+
const TO_END_TAG_LINE = /^([\t ]{0,3})<(?=(?:pre|script|style|textarea)(?:[\s>]|$))/gim;
|
|
75
|
+
const TEX_INDENT = " ";
|
|
76
|
+
const TEXT_LINE = /^(?=.*\S)/gm;
|
|
77
|
+
const INDENTED_TEXT_LINE = /^ {4}(?=.*\S)/gm;
|
|
78
|
+
const isIndentedTex = (value) => {
|
|
79
|
+
const lines = value.split("\n").filter((line) => /\S/.test(line));
|
|
80
|
+
return lines.length > 0 && lines.every((line) => line.startsWith(TEX_INDENT));
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* A reader without math reads `$…$` and a `$$` block as Markdown text, where
|
|
84
|
+
* TeX such as `<img src=x onerror=alert(1)>` is raw HTML and
|
|
85
|
+
* `<javascript:alert(1)>` is a link, and a tag the TeX leaves open takes its
|
|
86
|
+
* `>` from the text after it. TeX whose tags the raw HTML rule refuses writes
|
|
87
|
+
* a space after each `<` that could start a tag, which TeX ignores in math
|
|
88
|
+
* mode. A `$$` block that CommonMark does not read as one paragraph, such as
|
|
89
|
+
* TeX holding a blank line and then `[a]: javascript:alert(1)`, indents each
|
|
90
|
+
* TeX line that holds text by four spaces, so every line reads as paragraph
|
|
91
|
+
* text or indented code.
|
|
92
|
+
*/
|
|
93
|
+
const writeMathSafely = (node, read) => {
|
|
94
|
+
if ((node.type === "math" || node.type === "inlineMath") && node.value.includes("<")) {
|
|
95
|
+
const after = node.type === "math" ? "\n$$" : "$";
|
|
96
|
+
const written = `${node.value}${after}`;
|
|
97
|
+
if (!decideRawHtml(written.replaceAll(TEXT_LT, "<")).ok) node.value = written.replaceAll(MARKUP_LT, "< ").slice(0, -after.length);
|
|
98
|
+
}
|
|
99
|
+
if (node.type === "math") {
|
|
100
|
+
node.value = node.value.replaceAll(TO_END_TAG_LINE, "$1< ");
|
|
101
|
+
const [first, ...rest] = read(`$$\n${node.value}\n$$`).children;
|
|
102
|
+
if (/\S/.test(node.value) && (first?.type !== "paragraph" || rest.length > 0) || isIndentedTex(node.value)) node.value = node.value.replaceAll(TEXT_LINE, TEX_INDENT);
|
|
103
|
+
}
|
|
104
|
+
if ("children" in node) for (const child of node.children) writeMathSafely(child, read);
|
|
105
|
+
};
|
|
106
|
+
const readMathSafely = (node) => {
|
|
107
|
+
if (node.type === "math" && isIndentedTex(node.value)) node.value = node.value.replaceAll(INDENTED_TEXT_LINE, "");
|
|
108
|
+
if ("children" in node) node.children.forEach(readMathSafely);
|
|
109
|
+
};
|
|
71
110
|
const ONE_LINE_CONTAINERS = /* @__PURE__ */ new Set([
|
|
72
111
|
"atxHeading",
|
|
73
112
|
"registeredTag",
|
|
@@ -311,4 +350,4 @@ const decideRawHtmlBlocks = (tree, decide, options) => {
|
|
|
311
350
|
}] : []);
|
|
312
351
|
};
|
|
313
352
|
//#endregion
|
|
314
|
-
export { createRawHtmlPlacementDecider, decideRawHtml, decideRawHtmlBlocks, printsNoText };
|
|
353
|
+
export { createRawHtmlPlacementDecider, decideRawHtml, decideRawHtmlBlocks, printsNoText, readMathSafely, writeMathSafely };
|
|
@@ -633,6 +633,12 @@ const serializeAttributes = (attributes) => attributes.map((attribute) => {
|
|
|
633
633
|
const text = typeof value === "object" ? value.value : value;
|
|
634
634
|
return ` ${name}="${escapeMarkdownTagAttribute(text)}"`;
|
|
635
635
|
}).join("");
|
|
636
|
+
const countTagOpeners = (text) => text.match(/<[!/?A-Za-z]/g)?.length ?? 0;
|
|
637
|
+
const countMarkupTagOpeners = (nodes) => nodes.reduce((count, node) => {
|
|
638
|
+
if (node.type === "html") return count + countTagOpeners(node.value);
|
|
639
|
+
const selfClosing = "children" in node && node.children.length === 0;
|
|
640
|
+
return count + (node.type === "mdxJsxTextElement" ? (selfClosing ? 1 : 2) + countTagOpeners(serializeAttributes(node.attributes)) : 0) + ("children" in node ? countMarkupTagOpeners(node.children) : 0);
|
|
641
|
+
}, 0);
|
|
636
642
|
const toMarkdown = { handlers: {
|
|
637
643
|
mdxJsxFlowElement(node, _parent, state, info) {
|
|
638
644
|
const open = `<${node.name}${serializeAttributes(node.attributes)}`;
|
|
@@ -645,7 +651,7 @@ const toMarkdown = { handlers: {
|
|
|
645
651
|
after: "<",
|
|
646
652
|
before: ">"
|
|
647
653
|
});
|
|
648
|
-
if (!line.includes("\n")) {
|
|
654
|
+
if (!line.includes("\n") && countTagOpeners(line) === countMarkupTagOpeners(only.children)) {
|
|
649
655
|
exit();
|
|
650
656
|
return `${open}>${line}</${node.name}>`;
|
|
651
657
|
}
|
package/dist/math/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../htmlTypes-
|
|
3
|
-
import { Wr as BlockFenceInputRuleMatch, _ as BasePlugin, _t as NodeInsertOptions, d as InferBaseEditorPlugins,
|
|
1
|
+
import { Fo as PluginReference, dn as EditorReadMethodTree, iu as TxDeclaredMethod, ji as ElementOf, ss as PropertyStringDescriptor, su as Value, x as BaseRange } from "../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { Co as PluginReference$1, Eo as PluginSchemaDeclaration, Wr as BlockFenceInputRuleMatch, _ as BasePlugin, _t as NodeInsertOptions, d as InferBaseEditorPlugins, f as InternalBaseEditorWithInstalledPlugins, li as InsertTextInputRule, mt as InternalInstalledSchemaDefinitionsProvider, ti as InsertBreakInputRule, yi as SelectionInputRuleContext } from "../core-BqR-fEDp.js";
|
|
4
4
|
declare const BaseEquationPlugin: BasePlugin<Readonly<{
|
|
5
5
|
formats: true;
|
|
6
6
|
}> & Readonly<{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "../../htmlTypes-
|
|
3
|
-
import { _t as NodeInsertOptions } from "../../core-
|
|
4
|
-
import { At as Plugin } from "../../index-
|
|
1
|
+
import { iu as TxDeclaredMethod, ss as PropertyStringDescriptor } from "../../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { _t as NodeInsertOptions } from "../../core-BqR-fEDp.js";
|
|
4
|
+
import { At as Plugin } from "../../index-DPowErHa.js";
|
|
5
5
|
declare const EquationPlugin: Plugin<Readonly<{
|
|
6
6
|
formats: true;
|
|
7
7
|
}> & Readonly<{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { h as EditorApplicationSchema } from "../htmlTypes-
|
|
3
|
-
import "../core-
|
|
1
|
+
import { $a as Path, Fc as Selection, Fo as PluginReference, H as Descendant, Ht as EditorJsonValue, Tt as EditorDocumentValue, io as PersistedDocumentInput, ps as Range, yr as EditorStateSchemaApi } from "../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import { h as EditorApplicationSchema } from "../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import "../core-BqR-fEDp.js";
|
|
4
4
|
type NamedEditorApplicationSchema = EditorApplicationSchema & Readonly<{
|
|
5
5
|
id: string;
|
|
6
6
|
version: number;
|
|
@@ -75,10 +75,7 @@ const createStageMapper = (schema, before, after) => {
|
|
|
75
75
|
const shapeDocument = (context, document) => {
|
|
76
76
|
const inputs = migratePlateV54Inputs({
|
|
77
77
|
...context,
|
|
78
|
-
document
|
|
79
|
-
...context,
|
|
80
|
-
document
|
|
81
|
-
})
|
|
78
|
+
document
|
|
82
79
|
});
|
|
83
80
|
const profile = migratePlateV54Profile({
|
|
84
81
|
...context,
|
|
@@ -112,8 +109,9 @@ const shapeDocument = (context, document) => {
|
|
|
112
109
|
*/
|
|
113
110
|
const migrateV54 = (context) => {
|
|
114
111
|
const schema = context.target.schema;
|
|
115
|
-
const
|
|
116
|
-
const
|
|
112
|
+
const source = migratePlateV54RetiredMarks(context);
|
|
113
|
+
const legacy = migratePlateV54Suggestions(source);
|
|
114
|
+
const shapedSource = shapeDocument(context, source);
|
|
117
115
|
const { ast, codeBlocks, inputs, profile, urls } = shapedSource;
|
|
118
116
|
const toProfile = createStageMapper(schema, inputs.document, profile);
|
|
119
117
|
const toAst = createStageMapper(schema, profile, ast);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { SelectionApi, TextApi, getCompiledEditorSchemaFromApi, getCompiledPropertyCandidates } from "../facade.js";
|
|
2
2
|
import { V53_RETIRED_TEXT_MARKS } from "./v53-manifest.internal.js";
|
|
3
|
+
import { createPropertyOwnership } from "./migratePlateV54Ownership.internal.js";
|
|
4
|
+
import { isRecord } from "./migratePlateV54Suggestions.internal.js";
|
|
3
5
|
//#region src/migrations/migratePlateV54RetiredMarks.internal.ts
|
|
4
6
|
const undeclaredRetiredMarks = (target) => {
|
|
5
7
|
const compiled = getCompiledEditorSchemaFromApi(target.schema);
|
|
6
8
|
return compiled ? [...V53_RETIRED_TEXT_MARKS].filter((key) => getCompiledPropertyCandidates(compiled, "text", key).length === 0) : [];
|
|
7
9
|
};
|
|
10
|
+
const changedByLegacyUpdate = (properties, key) => Object.entries(properties).some(([name, data]) => (name === "suggestion" || name.startsWith("suggestion_")) && isRecord(data) && [data.properties, data.newProperties].some((changed) => isRecord(changed) && Object.hasOwn(changed, key)));
|
|
8
11
|
const withoutKeys = (properties, keys) => {
|
|
9
12
|
if (!keys.some((key) => Object.hasOwn(properties, key))) return properties;
|
|
10
13
|
const next = { ...properties };
|
|
@@ -15,18 +18,24 @@ const V53_NODE_LISTS = ["caption", "children"];
|
|
|
15
18
|
const migratePlateV54RetiredMarks = ({ document, target }) => {
|
|
16
19
|
const retired = undeclaredRetiredMarks(target);
|
|
17
20
|
if (retired.length === 0) return document;
|
|
18
|
-
const
|
|
19
|
-
|
|
21
|
+
const { ownsProperty } = createPropertyOwnership(target);
|
|
22
|
+
const migrateList = (list, context) => {
|
|
23
|
+
const next = list.map((node) => migrateNode(node, context));
|
|
20
24
|
return next.every((node, index) => node === list[index]) ? list : next;
|
|
21
25
|
};
|
|
22
|
-
const migrateNode = (node) => {
|
|
23
|
-
if (TextApi.isText(node)) return withoutKeys(node, retired);
|
|
26
|
+
const migrateNode = (node, context) => {
|
|
27
|
+
if (TextApi.isText(node)) return withoutKeys(node, retired.filter((key) => !changedByLegacyUpdate(node, key)));
|
|
24
28
|
if (typeof node !== "object" || node === null) return node;
|
|
25
29
|
const record = node;
|
|
30
|
+
const type = String(record.type);
|
|
31
|
+
const childContext = {
|
|
32
|
+
ancestors: [type, ...context.ancestors],
|
|
33
|
+
root: context.root
|
|
34
|
+
};
|
|
26
35
|
const changed = V53_NODE_LISTS.flatMap((key) => {
|
|
27
36
|
const list = record[key];
|
|
28
|
-
if (!Array.isArray(list)) return [];
|
|
29
|
-
const migrated = migrateList(list);
|
|
37
|
+
if (!Array.isArray(list) || key === "caption" && ownsProperty(type, key, context)) return [];
|
|
38
|
+
const migrated = migrateList(list, childContext);
|
|
30
39
|
return migrated === list ? [] : [[key, migrated]];
|
|
31
40
|
});
|
|
32
41
|
return changed.length > 0 ? {
|
|
@@ -34,8 +43,14 @@ const migratePlateV54RetiredMarks = ({ document, target }) => {
|
|
|
34
43
|
...Object.fromEntries(changed)
|
|
35
44
|
} : record;
|
|
36
45
|
};
|
|
37
|
-
const children = migrateList(document.children
|
|
38
|
-
|
|
46
|
+
const children = migrateList(document.children, {
|
|
47
|
+
ancestors: [],
|
|
48
|
+
root: null
|
|
49
|
+
});
|
|
50
|
+
const roots = document.roots ? Object.fromEntries(Object.entries(document.roots).map(([root, rootChildren]) => [root, migrateList(rootChildren, {
|
|
51
|
+
ancestors: [],
|
|
52
|
+
root
|
|
53
|
+
})])) : void 0;
|
|
39
54
|
if (children === document.children && (!roots || Object.entries(roots).every(([root, rootChildren]) => rootChildren === document.roots?.[root]))) return document;
|
|
40
55
|
return {
|
|
41
56
|
...document,
|
|
@@ -59,7 +59,7 @@ const parseSuggestionData = (value, location, keyedId) => {
|
|
|
59
59
|
};
|
|
60
60
|
const legacyKeys = (node) => Object.keys(node).filter((key) => key.startsWith(LEGACY_SUGGESTION_PREFIX));
|
|
61
61
|
const hasLegacyMetadata = (node) => Object.hasOwn(node, "suggestion") || Object.hasOwn(node, "suggestionData") || Object.hasOwn(node, "suggestionTransient") || legacyKeys(node).length > 0;
|
|
62
|
-
const stripLegacyMetadata = (node) => Object.fromEntries(Object.entries(node).filter(([key]) => key !== "suggestion" && !LEGACY_TRANSIENT_KEYS.has(key) && !key.startsWith(
|
|
62
|
+
const stripLegacyMetadata = (node) => Object.fromEntries(Object.entries(node).filter(([key]) => key !== "suggestion" && !LEGACY_TRANSIENT_KEYS.has(key) && !key.startsWith("suggestion_")));
|
|
63
63
|
const validateProposedProperties = (node, data, location) => {
|
|
64
64
|
if (data.type !== "update") return;
|
|
65
65
|
const proposed = data.newProperties ?? {};
|
|
@@ -233,4 +233,4 @@ const migratePlateV54ReplacementText = (nodes, text, location) => {
|
|
|
233
233
|
};
|
|
234
234
|
const migratePlateV54DrawingCodeText = (drawing, code) => markedText(code, reviewMarks(drawing).filter(covers));
|
|
235
235
|
//#endregion
|
|
236
|
-
export { migratePlateV54DrawingCodeText, migratePlateV54ReplacementText, migratePlateV54Suggestions };
|
|
236
|
+
export { LEGACY_SUGGESTION_PREFIX, isRecord, migratePlateV54DrawingCodeText, migratePlateV54ReplacementText, migratePlateV54Suggestions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $a as Path, Ci as Element, Ht as EditorJsonValue, Y as Editor, fr as EditorStateField, ia as NamedRootKey, ji as ElementOf, ps as Range, su as Value, wl as TextOf } from "../index-BXjLmx1n-CXk17buG.js";
|
|
2
2
|
type PagePreset = 'a4' | 'letter';
|
|
3
3
|
type PageMargins = number | Readonly<{
|
|
4
4
|
bottom: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Wn as EditableProps, _n as EditorContentProps } from "../../index-
|
|
1
|
+
import { Ci as Element, ws as RootKey } from "../../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import { Wn as EditableProps, _n as EditorContentProps } from "../../index-DPowErHa.js";
|
|
3
3
|
import { MeasurePagesOptions, NodeFragmentationPlan, NodeFragmentationProvider, PageLayoutBlock, PageLayoutBlockStyle, PageLayoutEngine, PageLayoutEngineInput, PageLayoutEngineOutput, PageLayoutFragment, PageLayoutMode, PageLayoutPage, PageLayoutRun, PageLayoutSize, PageLayoutSnapshot, PageLayoutTextStyle, PageLayoutTypography, PageMargins, PagePreset, PageRect, PageSettings, PageSettingsJson, PageSettingsSource, PretextPageLayoutEngineOptions, createEstimatedPageLayoutEngine, createPretextPageLayoutEngine, measurePages, pageSettingsCodec } from "../index.js";
|
|
4
4
|
import React$1, { CSSProperties, ReactNode, RefObject } from "react";
|
|
5
5
|
declare const usePageLayout: (editableRef: RefObject<HTMLDivElement | null>) => PageLayoutSnapshot | null;
|