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
|
@@ -96,7 +96,10 @@ const BaseCodeBlockPlugin = definePlugin(PLUGINS.codeBlock, {
|
|
|
96
96
|
max: 1
|
|
97
97
|
}),
|
|
98
98
|
ownsExit: true,
|
|
99
|
-
properties: {
|
|
99
|
+
properties: {
|
|
100
|
+
language: property.string(),
|
|
101
|
+
meta: property.string()
|
|
102
|
+
},
|
|
100
103
|
slice: { preserveContext: true }
|
|
101
104
|
} },
|
|
102
105
|
component: "pre",
|
|
@@ -114,20 +117,23 @@ const BaseCodeBlockPlugin = definePlugin(PLUGINS.codeBlock, {
|
|
|
114
117
|
}
|
|
115
118
|
const languageClass = element.querySelector(":scope > code")?.className.match(CODE_LANGUAGE_CLASS_RE)?.[1];
|
|
116
119
|
const language = element.dataset.language || languageClass || void 0;
|
|
120
|
+
const { meta } = element.dataset;
|
|
117
121
|
const text = restoreTrailingNewlines(readCodeDomText(element), element);
|
|
118
|
-
preserve("data-code-trailing-newlines", "data-language");
|
|
122
|
+
preserve("data-code-trailing-newlines", "data-language", "data-meta");
|
|
119
123
|
return {
|
|
120
124
|
children: [{ text }],
|
|
121
|
-
...language ? { language } : {}
|
|
125
|
+
...language ? { language } : {},
|
|
126
|
+
...meta ? { meta } : {}
|
|
122
127
|
};
|
|
123
128
|
},
|
|
124
129
|
encode: ({ content, node, preserve }) => {
|
|
125
130
|
const trailingNewlines = countTrailingNewlines(NodeApi.string(node));
|
|
126
|
-
preserve("language");
|
|
131
|
+
preserve("language", "meta");
|
|
127
132
|
return {
|
|
128
133
|
attributes: {
|
|
129
134
|
...trailingNewlines > 0 ? { "data-code-trailing-newlines": trailingNewlines } : {},
|
|
130
|
-
"data-language": node.language
|
|
135
|
+
"data-language": node.language,
|
|
136
|
+
"data-meta": node.meta
|
|
131
137
|
},
|
|
132
138
|
children: [{
|
|
133
139
|
children: content,
|
|
@@ -146,13 +152,16 @@ const BaseCodeBlockPlugin = definePlugin(PLUGINS.codeBlock, {
|
|
|
146
152
|
node: "code",
|
|
147
153
|
decode: ({ node }) => ({
|
|
148
154
|
...node.lang ? { language: node.lang } : {},
|
|
155
|
+
...node.meta ? { meta: node.meta } : {},
|
|
149
156
|
children: [{ text: node.value || "" }],
|
|
150
157
|
type
|
|
151
158
|
}),
|
|
152
159
|
encode: ({ node, preserve }) => {
|
|
153
160
|
preserve("language");
|
|
161
|
+
if (node.language) preserve("meta");
|
|
154
162
|
return {
|
|
155
163
|
lang: node.language,
|
|
164
|
+
meta: node.meta,
|
|
156
165
|
type: "code",
|
|
157
166
|
value: NodeApi.string(node)
|
|
158
167
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as ComboboxState, t as ComboboxEditor } from "../../combobox-
|
|
2
|
-
import { n as filterWords, t as FilterWordsOptions } from "../../index-
|
|
1
|
+
import { n as ComboboxState, t as ComboboxEditor } from "../../combobox-Dr0OYZIE.js";
|
|
2
|
+
import { n as filterWords, t as FilterWordsOptions } from "../../index-BTx5oK7k.js";
|
|
3
3
|
export { ComboboxEditor, ComboboxState, FilterWordsOptions, filterWords };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notifyObservers, readDocumentRange, runEditorObserver, subscribeEditorViewState } from "../../facade.js";
|
|
1
|
+
import { notifyObservers, readDocumentRange, runEditorObserver, subscribeEditorViewState, withStoredAuthoredRead } from "../../facade.js";
|
|
2
2
|
import { definePlugin } from "../../lib/plugin/definePlugin.js";
|
|
3
3
|
import { readEditorAuthor } from "../../lib/editor/editorUser.internal.js";
|
|
4
4
|
import { nanoid } from "../../lib/libs/nanoid.js";
|
|
@@ -208,7 +208,10 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
208
208
|
if (observed) return observed.annotations;
|
|
209
209
|
let annotations = passiveIndexes.get(view);
|
|
210
210
|
if (!annotations) {
|
|
211
|
-
annotations = createAnnotationStore(view, () => sourcesByRoot.get(view.read.view.root()) ?? [], {
|
|
211
|
+
annotations = createAnnotationStore(view, () => sourcesByRoot.get(view.read.view.root()) ?? [], {
|
|
212
|
+
hideEmpty: true,
|
|
213
|
+
id: "comments"
|
|
214
|
+
});
|
|
212
215
|
passiveIndexes.set(view, annotations);
|
|
213
216
|
}
|
|
214
217
|
return annotations;
|
|
@@ -260,7 +263,7 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
260
263
|
if (changed && !changed(root)) return;
|
|
261
264
|
group.forEach(({ anchor, id }) => {
|
|
262
265
|
present.add(id);
|
|
263
|
-
const range = anchor.resolve(view);
|
|
266
|
+
const range = textIn(view, anchor.resolve(view));
|
|
264
267
|
if (ranges.has(id) && isEqual(ranges.get(id), range)) return;
|
|
265
268
|
ranges.set(id, range);
|
|
266
269
|
ids.add(id);
|
|
@@ -288,9 +291,17 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
288
291
|
queueChange(() => deliver(listeners, "commit-listener", change));
|
|
289
292
|
};
|
|
290
293
|
changedIds();
|
|
294
|
+
let schema = view.read.schema.identity();
|
|
291
295
|
const stopCommits = view.subscribeCommit((commit) => {
|
|
292
|
-
|
|
293
|
-
|
|
296
|
+
const next = view.read.schema.identity();
|
|
297
|
+
const reconfigured = next !== schema;
|
|
298
|
+
schema = next;
|
|
299
|
+
if (!commit || reconfigured) {
|
|
300
|
+
announce(changedIds(), "editor");
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (!commit.changed.hasAny("document")) return;
|
|
304
|
+
announce(changedIds((root) => commit.changed.has("document", root), commit.changed.hasAny("structure") || commit.changed.hasAny("properties")), "editor");
|
|
294
305
|
});
|
|
295
306
|
const stopProjection = subscribeEditorViewState(view, (change) => {
|
|
296
307
|
if (change === "authored") announce(changedIds(), "editor");
|
|
@@ -410,6 +421,8 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
410
421
|
if (destroyed) return;
|
|
411
422
|
store.set({ activeIds: Object.freeze([...new Set(ids)]) });
|
|
412
423
|
};
|
|
424
|
+
const textIn = (view, range) => range && !view.read.ranges.isEmpty(range) ? range : null;
|
|
425
|
+
const storedText = (anchor) => withStoredAuthoredRead(editor, () => textIn(editor, anchor.resolve()));
|
|
413
426
|
const syncSource = () => {
|
|
414
427
|
sourcesByRoot = /* @__PURE__ */ new Map();
|
|
415
428
|
anchors.forEach((anchor, id) => {
|
|
@@ -451,7 +464,8 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
451
464
|
return range;
|
|
452
465
|
};
|
|
453
466
|
const commandRange = (view, value) => assertTextRange(view, readDocumentRange(value, { view: view.read.view.root() }));
|
|
454
|
-
const
|
|
467
|
+
const rangeIn = (view, anchor) => anchor.root === view.read.view.root() || isPageView(view) ? anchor.resolve(view) : null;
|
|
468
|
+
const resolveIn = (view, anchor) => textIn(view, rangeIn(view, anchor));
|
|
455
469
|
const locationRoot = (location) => {
|
|
456
470
|
if (PathApi.isPath(location)) return void 0;
|
|
457
471
|
return PointApi.isPoint(location) ? location.root : SelectionApi.root(location);
|
|
@@ -640,7 +654,7 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
640
654
|
});
|
|
641
655
|
return result;
|
|
642
656
|
};
|
|
643
|
-
const commitMutation = async (id, operation, proposed, anchor, { afterWrite, isCurrent = () => true } = {}) => {
|
|
657
|
+
const commitMutation = async (id, operation, proposed, anchor, { afterWrite, isCurrent = () => true, allowEmpty = false } = {}) => {
|
|
644
658
|
const previous = threads.get(id) ?? null;
|
|
645
659
|
const generation = generations.get(id) ?? 0;
|
|
646
660
|
if (destroyed || !isCurrent()) return { status: "stale" };
|
|
@@ -656,14 +670,15 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
656
670
|
try {
|
|
657
671
|
let range = null;
|
|
658
672
|
if (location) {
|
|
659
|
-
|
|
673
|
+
const written = () => allowEmpty ? location.resolve() : storedText(location);
|
|
674
|
+
if (written()) {
|
|
660
675
|
rangesAwaitingMutate.set(id, location);
|
|
661
676
|
announceRanges();
|
|
662
677
|
if (isStale()) {
|
|
663
678
|
dropUnwritten();
|
|
664
679
|
return { status: "stale" };
|
|
665
680
|
}
|
|
666
|
-
range =
|
|
681
|
+
range = written();
|
|
667
682
|
}
|
|
668
683
|
if (!range) {
|
|
669
684
|
dropUnwritten();
|
|
@@ -744,7 +759,8 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
744
759
|
afterWrite: (canonical) => {
|
|
745
760
|
value = canonical;
|
|
746
761
|
},
|
|
747
|
-
isCurrent: () => sameThread(threads.get(thread.id) ?? null, transition.previous)
|
|
762
|
+
isCurrent: () => sameThread(threads.get(thread.id) ?? null, transition.previous),
|
|
763
|
+
allowEmpty: true
|
|
748
764
|
});
|
|
749
765
|
if (mutation.status !== "applied") return {
|
|
750
766
|
status: "applied",
|
|
@@ -858,7 +874,7 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
858
874
|
let range;
|
|
859
875
|
if (input.target.type === "range") {
|
|
860
876
|
range = commandRange(commandEditor, input.target.range);
|
|
861
|
-
if (
|
|
877
|
+
if (commandEditor.read.ranges.isEmpty(range)) return null;
|
|
862
878
|
} else if (!input.target.id) return null;
|
|
863
879
|
const createdAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
864
880
|
const userId = readEditorAuthor(commandEditor);
|
|
@@ -922,11 +938,11 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
922
938
|
begin: (at = commandEditor.read.selection()) => {
|
|
923
939
|
if (!at || destroyed) return false;
|
|
924
940
|
let range = commandRange(commandEditor, at);
|
|
925
|
-
if (
|
|
926
|
-
const block = commandEditor.read.nodes.block({ at: range });
|
|
941
|
+
if (commandEditor.read.ranges.isEmpty(range)) {
|
|
942
|
+
const block = commandEditor.read.nodes.block({ at: RangeApi.start(range) });
|
|
927
943
|
range = block ? commandEditor.read.ranges.get(block[0]) ?? null : null;
|
|
928
944
|
}
|
|
929
|
-
if (!range ||
|
|
945
|
+
if (!range || commandEditor.read.ranges.isEmpty(range)) return false;
|
|
930
946
|
const anchor = commandEditor.anchor(range, {
|
|
931
947
|
association: "inward",
|
|
932
948
|
deletion: "nearest"
|
|
@@ -1159,8 +1175,8 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
1159
1175
|
const annotations = root === viewRoot ? viewIndexes.get(commandEditor)?.annotations : void 0;
|
|
1160
1176
|
if (!annotations) return Object.freeze([...anchors].flatMap(([id, anchor]) => {
|
|
1161
1177
|
if (anchor.root !== root || threads.get(id)?.resolution) return [];
|
|
1162
|
-
const range =
|
|
1163
|
-
return range && RangeApi.includes(range, location) ? [id] : [];
|
|
1178
|
+
const range = rangeIn(commandEditor, anchor);
|
|
1179
|
+
return range && RangeApi.includes(range, location) && textIn(commandEditor, range) ? [id] : [];
|
|
1164
1180
|
}));
|
|
1165
1181
|
return Object.freeze([...new Map(nodeKeysAt(commandEditor, location).flatMap((key) => annotations.getAnnotationsAt(key).map((annotation) => [annotation.id, annotation]))).values()].filter(({ id, range }) => !threads.get(id)?.resolution && range && RangeApi.includes(range, location)).sort((left, right) => (sourceOrder.get(left.id) ?? 0) - (sourceOrder.get(right.id) ?? 0)).map(({ id }) => id));
|
|
1166
1182
|
},
|
|
@@ -1171,7 +1187,7 @@ const BaseCommentsPlugin = definePlugin("comments", {
|
|
|
1171
1187
|
if (thread.target.type === "change") return thread.target;
|
|
1172
1188
|
const anchor = anchors.get(id);
|
|
1173
1189
|
const range = anchor && resolveIn(commandEditor, anchor);
|
|
1174
|
-
return range
|
|
1190
|
+
return range ? freezeComment({
|
|
1175
1191
|
type: "range",
|
|
1176
1192
|
status: "attached",
|
|
1177
1193
|
range: structuredClone(range)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { S as SavedComments, _ as CommentsLoadIssue, a as CommentDataValue, b as CreateCommentThreadInput, c as CommentMutationRequest, d as CommentRanges, f as CommentResolution, g as CommentsChange, h as CommentUser, i as CommentDataList, l as CommentMutationResult, m as CommentThread, n as CommentAttachment, o as CommentMessage, p as CommentTarget, r as CommentData, s as CommentMutationDecision, t as BaseCommentsPlugin, u as CommentOperation, v as CommentsPluginState, x as PendingComment, y as CommentsSnapshot } from "../../index-
|
|
1
|
+
import { S as SavedComments, _ as CommentsLoadIssue, a as CommentDataValue, b as CreateCommentThreadInput, c as CommentMutationRequest, d as CommentRanges, f as CommentResolution, g as CommentsChange, h as CommentUser, i as CommentDataList, l as CommentMutationResult, m as CommentThread, n as CommentAttachment, o as CommentMessage, p as CommentTarget, r as CommentData, s as CommentMutationDecision, t as BaseCommentsPlugin, u as CommentOperation, v as CommentsPluginState, x as PendingComment, y as CommentsSnapshot } from "../../index-CpY7Xnxw.js";
|
|
2
2
|
export { BaseCommentsPlugin, CommentAttachment, CommentData, CommentDataList, CommentDataValue, CommentMessage, CommentMutationDecision, CommentMutationRequest, CommentMutationResult, CommentOperation, CommentRanges, CommentResolution, CommentTarget, CommentThread, CommentUser, CommentsChange, CommentsLoadIssue, CommentsPluginState, CommentsSnapshot, CreateCommentThreadInput, PendingComment, SavedComments };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { iu as TxDeclaredMethod, ji as ElementOf, ss as PropertyStringDescriptor } from "../../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { _ as BasePlugin, _t as NodeInsertOptions } from "../../core-BqR-fEDp.js";
|
|
3
4
|
declare const BaseDatePlugin: BasePlugin<Readonly<{
|
|
4
5
|
readonly __pluginWritableProperties: Readonly<{
|
|
5
6
|
descriptor: PropertyStringDescriptor<{
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { As as SchemaContentPrefixSlot, Ca as NodeKey, Ds as SchemaContentDefault, Ht as EditorJsonValue, Ia as NodeSelection, Ji as Location, Ls as SchemaContentRule, iu as TxDeclaredMethod, ji as ElementOf, ts as PropertyJsonDescriptor } from "../../index-BXjLmx1n-CXk17buG.js";
|
|
2
|
+
import "../../htmlTypes-eT2ZGDAj.js";
|
|
3
|
+
import { Co as PluginReference, Qn as HeadingLevel, _ as BasePlugin, ct as BlockInsertOptions, lt as BlockUpsertOptions, xo as PluginDependency } from "../../core-BqR-fEDp.js";
|
|
3
4
|
declare const isSummaryHeadingLevel: (value: unknown) => value is HeadingLevel;
|
|
4
5
|
type BaseDetailsViewState = {
|
|
5
6
|
openKeys: Set<NodeKey>;
|
|
@@ -22,6 +22,18 @@ const getDetailsOfTitle = (state, { path, type }) => {
|
|
|
22
22
|
const title = container?.[0].children[0];
|
|
23
23
|
return title && state.nodes.isContent(title) ? container : void 0;
|
|
24
24
|
};
|
|
25
|
+
const opensTagOrBreaks = (text) => /<[!/?A-Za-z]/.test(text) || text.includes("\n");
|
|
26
|
+
const breaksHeadedLine = (nodes) => nodes.some((node) => {
|
|
27
|
+
if (node.type === "break") return true;
|
|
28
|
+
if (node.type === "html") return node.value.includes("\n");
|
|
29
|
+
if ("value" in node) return opensTagOrBreaks(node.value);
|
|
30
|
+
if ((node.type === "link" || node.type === "image") && (!node.url || /[\0- \u007F]/.test(node.url) || [
|
|
31
|
+
node.url,
|
|
32
|
+
node.title ?? "",
|
|
33
|
+
node.type === "image" ? node.alt ?? "" : ""
|
|
34
|
+
].some(opensTagOrBreaks) || node.type === "link" && node.children.length === 1 && node.children[0]?.type === "text" && [node.url, node.url.replace(/^mailto:/i, "")].includes(node.children[0].value))) return true;
|
|
35
|
+
return "children" in node && breaksHeadedLine(node.children);
|
|
36
|
+
});
|
|
25
37
|
const isSummaryHeadingLevel = (value) => typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= 6;
|
|
26
38
|
const getReleasedTitleProps = (editor, level) => {
|
|
27
39
|
const heading = editor.plugin(BaseHeadingPlugin);
|
|
@@ -88,7 +100,8 @@ const BaseDetailsSummaryPlugin = definePlugin(PLUGINS.detailsSummary, {
|
|
|
88
100
|
},
|
|
89
101
|
encode: ({ encodeNodeAttributes, encodePhrasing, node, preserve, readPlainInline }) => {
|
|
90
102
|
const content = readPlainInline(node.children) === "" ? [] : encodePhrasing(node.children);
|
|
91
|
-
const
|
|
103
|
+
const headed = Boolean(node.level) && !breaksHeadedLine(content);
|
|
104
|
+
const phrasing = headed ? [
|
|
92
105
|
{
|
|
93
106
|
type: "html",
|
|
94
107
|
value: `<h${node.level}>`
|
|
@@ -101,7 +114,7 @@ const BaseDetailsSummaryPlugin = definePlugin(PLUGINS.detailsSummary, {
|
|
|
101
114
|
] : content;
|
|
102
115
|
if (node.level) preserve("level");
|
|
103
116
|
return {
|
|
104
|
-
attributes: encodeNodeAttributes().filter((attribute) => !("name" in attribute && attribute.name === "level")),
|
|
117
|
+
attributes: encodeNodeAttributes().filter((attribute) => !headed || !("name" in attribute && attribute.name === "level")),
|
|
105
118
|
children: phrasing.length > 0 ? [{
|
|
106
119
|
children: phrasing,
|
|
107
120
|
type: "paragraph"
|
|
@@ -346,23 +359,23 @@ const BaseDetailsPlugin = definePlugin(PLUGINS.details, {
|
|
|
346
359
|
if (!details) return next();
|
|
347
360
|
const detailsKey = state.key(details[0]);
|
|
348
361
|
const paragraphType = editor.plugin(BaseParagraphPlugin).schema.type;
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
const point = tx.nodes.get(nextPath) ? tx.points.start(nextPath) : void 0;
|
|
352
|
-
if (point) {
|
|
353
|
-
tx.selection.set(point);
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
362
|
+
const afterDetails = PathApi.next(details[1]);
|
|
363
|
+
const insertParagraphAfterDetails = () => state.transaction((tx) => {
|
|
356
364
|
tx.nodes.insert({
|
|
357
365
|
children: [{ text: "" }],
|
|
358
366
|
type: paragraphType
|
|
359
367
|
}, {
|
|
360
|
-
at:
|
|
368
|
+
at: afterDetails,
|
|
361
369
|
select: true
|
|
362
370
|
});
|
|
363
371
|
});
|
|
364
372
|
if (summary) {
|
|
365
|
-
if (!viewStoreOf(state).get("openKeys").has(detailsKey))
|
|
373
|
+
if (!viewStoreOf(state).get("openKeys").has(detailsKey)) {
|
|
374
|
+
const point = state.nodes.get(afterDetails) ? state.points.start(afterDetails) : void 0;
|
|
375
|
+
return point ? state.transaction((tx) => {
|
|
376
|
+
tx.selection.set(point);
|
|
377
|
+
}) : insertParagraphAfterDetails();
|
|
378
|
+
}
|
|
366
379
|
if (state.points.isEnd(selection.anchor, summary[1])) {
|
|
367
380
|
const firstBodyPoint = state.points.start(details[1].concat(1));
|
|
368
381
|
return state.transaction((tx) => {
|
|
@@ -380,7 +393,7 @@ const BaseDetailsPlugin = definePlugin(PLUGINS.details, {
|
|
|
380
393
|
}
|
|
381
394
|
const block = state.nodes.block({ at: selection });
|
|
382
395
|
const childIndex = block?.[1].at(-1);
|
|
383
|
-
if (block && childIndex === details[0].children.length - 1 && childIndex > 0 && NodeApi.string(block[0]) === "" && state.points.isEnd(selection.anchor, block[1])) return
|
|
396
|
+
if (block && childIndex === details[0].children.length - 1 && childIndex > 0 && NodeApi.string(block[0]) === "" && state.points.isEnd(selection.anchor, block[1])) return insertParagraphAfterDetails();
|
|
384
397
|
return next();
|
|
385
398
|
}),
|
|
386
399
|
handle(editorCommands.delete, ({ input, state }) => {
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as fitsField, a as FieldCondition, c as FieldOption, d as FieldRead, f as FieldSettings, g as FIELD_TESTS, h as FieldValue, i as BaseFieldPlugin, l as FieldPatch, m as FieldTest, n as FieldRefusal, o as FieldElement, p as FieldSubmission, r as applyFieldValues, s as FieldKind, t as FieldApplyResult, u as FieldProblem } from "../../index-C9Fu-P4E.js";
|
|
2
|
+
export { BaseFieldPlugin, FIELD_TESTS, FieldApplyResult, FieldCondition, FieldElement, FieldKind, FieldOption, FieldPatch, FieldProblem, FieldRead, FieldRefusal, FieldSettings, FieldSubmission, FieldTest, FieldValue, applyFieldValues, fitsField };
|