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.
Files changed (255) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +56 -0
  3. package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DrUahdTc.d.ts} +2 -2
  4. package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-_7Ka6nY3.d.ts} +7 -3
  5. package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-D3Cb-QwH.d.ts} +7 -7
  6. package/dist/ai/index.d.ts +1 -1
  7. package/dist/ai/react/AIChatPlugin.js +113 -78
  8. package/dist/ai/react/CopilotPlugin.js +1 -1
  9. package/dist/ai/react/index.d.ts +23 -16
  10. package/dist/authored/index.d.ts +4 -4
  11. package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
  12. package/dist/code-block/codemirror/index.d.ts +1 -1
  13. package/dist/{combobox-DkBGgyd3.d.ts → combobox-Dr0OYZIE.d.ts} +2 -2
  14. package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-DdwE6mYq-BogsHoUO.d.ts} +10 -2
  15. package/dist/compiler/index.d.ts +2 -2
  16. package/dist/{core-BJG8l_mk.d.ts → core-BqR-fEDp.d.ts} +493 -116
  17. package/dist/diff/index.d.ts +2 -2
  18. package/dist/docs/ai.md +4 -3
  19. package/dist/docs/api/core/plate-components.md +0 -19
  20. package/dist/docs/api/core/plate-controller.md +5 -3
  21. package/dist/docs/api/core/plate-plugin.md +3 -0
  22. package/dist/docs/api/core/plate-store.md +3 -3
  23. package/dist/docs/api/core.md +45 -5
  24. package/dist/docs/api/dom.md +11 -4
  25. package/dist/docs/api/editor-transforms.md +2 -1
  26. package/dist/docs/api/react-hooks.md +45 -13
  27. package/dist/docs/authored-changes.md +9 -4
  28. package/dist/docs/basic-blocks.md +42 -29
  29. package/dist/docs/block-placeholder.md +4 -2
  30. package/dist/docs/blockquote.md +5 -3
  31. package/dist/docs/board.md +118 -10
  32. package/dist/docs/code-block.md +47 -0
  33. package/dist/docs/comment.md +2 -2
  34. package/dist/docs/discussion.md +1 -1
  35. package/dist/docs/document-model.md +15 -3
  36. package/dist/docs/docx.md +1 -1
  37. package/dist/docs/dom-coverage.md +5 -0
  38. package/dist/docs/editor.md +50 -4
  39. package/dist/docs/examples/editable-voids.md +2 -3
  40. package/dist/docs/external-text.md +2 -0
  41. package/dist/docs/field.md +370 -0
  42. package/dist/docs/find.md +9 -6
  43. package/dist/docs/form.md +2 -0
  44. package/dist/docs/heading.md +6 -0
  45. package/dist/docs/installation/manual.md +0 -4
  46. package/dist/docs/link.md +3 -3
  47. package/dist/docs/llms.txt +4 -2
  48. package/dist/docs/markdown.md +270 -14
  49. package/dist/docs/plugin-components.md +13 -10
  50. package/dist/docs/plugin-input-rules.md +66 -15
  51. package/dist/docs/prompt-editor.md +205 -0
  52. package/dist/docs/roots.md +8 -6
  53. package/dist/docs/rtl.md +6 -4
  54. package/dist/docs/selection.md +7 -4
  55. package/dist/docs/suggestion.md +1 -1
  56. package/dist/docs/toolbar.md +26 -30
  57. package/dist/docs/upload.md +106 -17
  58. package/dist/docx/export/index.d.ts +3 -3
  59. package/dist/docx/export/lib/docxStaticComponents.js +12 -2
  60. package/dist/docx/export/lib/exportDocx.js +46 -17
  61. package/dist/docx/export/lib/internal/xml-builder.js +11 -16
  62. package/dist/docx/export/lib/reviewPart.js +1 -1
  63. package/dist/docx/export/lib/reviewProjection.js +52 -10
  64. package/dist/docx/import/index.d.ts +4 -4
  65. package/dist/docx/paste/index.d.ts +4 -4
  66. package/dist/dom/index.d.ts +1 -6
  67. package/dist/dom/plite-dom.internal.js +2 -2
  68. package/dist/excalidraw/index.d.ts +3 -2
  69. package/dist/excalidraw/react/index.d.ts +3 -2
  70. package/dist/facade.js +2 -2
  71. package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
  72. package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
  73. package/dist/features/board/index.d.ts +2 -2
  74. package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
  75. package/dist/features/board/lib/boardStroke.internal.js +13 -1
  76. package/dist/features/board/lib/boardTypes.internal.js +16 -0
  77. package/dist/features/callout/index.d.ts +3 -2
  78. package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
  79. package/dist/features/combobox/index.d.ts +2 -2
  80. package/dist/features/comments/BaseCommentsPlugin.js +33 -17
  81. package/dist/features/comments/index.d.ts +1 -1
  82. package/dist/features/date/index.d.ts +3 -2
  83. package/dist/features/details/index.d.ts +3 -2
  84. package/dist/features/details/lib/BaseDetailsPlugin.js +25 -12
  85. package/dist/features/field/index.d.ts +2 -0
  86. package/dist/features/field/index.js +4 -0
  87. package/dist/features/field/lib/BaseFieldPlugin.js +360 -0
  88. package/dist/features/field/lib/applyFieldValues.js +188 -0
  89. package/dist/features/field/lib/fieldRules.internal.js +204 -0
  90. package/dist/features/find/index.d.ts +3 -2
  91. package/dist/features/footnote/index.d.ts +1 -1
  92. package/dist/features/ink/index.d.ts +1 -1
  93. package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
  94. package/dist/features/ink/lib/inkCodec.internal.js +130 -0
  95. package/dist/features/ink/lib/inkGone.internal.js +229 -48
  96. package/dist/features/ink/lib/inkPlaces.internal.js +534 -64
  97. package/dist/features/layout/index.d.ts +1 -1
  98. package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
  99. package/dist/features/lint/index.d.ts +3 -2
  100. package/dist/features/media/index.d.ts +2 -2
  101. package/dist/features/media/index.js +2 -2
  102. package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
  103. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +206 -4
  104. package/dist/features/mention/index.d.ts +5 -4
  105. package/dist/features/suggestion/index.d.ts +1 -1
  106. package/dist/features/table/index.d.ts +1 -1
  107. package/dist/features/table/lib/BaseTablePlugin.js +64 -15
  108. package/dist/features/table/lib/internal/selection.js +4 -2
  109. package/dist/features/toc/index.d.ts +1 -1
  110. package/dist/features/upload/index.d.ts +2 -2
  111. package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
  112. package/dist/history/index.d.ts +2 -2
  113. package/dist/html/index.d.ts +3 -3
  114. package/dist/html/server/index.d.ts +1 -1
  115. package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-eT2ZGDAj.d.ts} +2 -31
  116. package/dist/hyperscript/index.d.ts +1 -1
  117. package/dist/{index-DzD6BIFJ.d.ts → index-B33E1CRJ.d.ts} +295 -6
  118. package/dist/{index-Cl77E9yr.d.ts → index-B7moSod7.d.ts} +2 -2
  119. package/dist/{index-hsC_sOn2.d.ts → index-B8-5Sr7I.d.ts} +35 -5
  120. package/dist/{index-BiQerPJS.d.ts → index-B8QJDAmG.d.ts} +2 -2
  121. package/dist/{index-BBKGrsG3.d.ts → index-BTx5oK7k.d.ts} +1 -1
  122. package/dist/{index-iaZOhA76.d.ts → index-BWPcE4ac-Cto_IsNs.d.ts} +7 -1
  123. package/dist/{index-BU6k1Aev.d.ts → index-BXjLmx1n-CXk17buG.d.ts} +4781 -4584
  124. package/dist/{index-kLKMc-pI.d.ts → index-BXwU9QH6.d.ts} +2 -2
  125. package/dist/{index-DTgaSxKr.d.ts → index-BkwR-5hH.d.ts} +40 -4
  126. package/dist/{index-Bq3sdm3S.d.ts → index-BsV2McRr.d.ts} +5 -4
  127. package/dist/index-C9Fu-P4E.d.ts +773 -0
  128. package/dist/{index-D5W-p9bS.d.ts → index-Ca48r1ng.d.ts} +49 -4
  129. package/dist/{index-CcZbqPqk.d.ts → index-Cob_iBdu.d.ts} +116 -41
  130. package/dist/{index-Bxfvicyy.d.ts → index-CpY7Xnxw.d.ts} +4 -3
  131. package/dist/{index-BkR7-GLI.d.ts → index-DNQXzU-X.d.ts} +2 -2
  132. package/dist/{index-D1CFXA-i.d.ts → index-DPowErHa.d.ts} +471 -141
  133. package/dist/{index-DaM37gF6.d.ts → index-DShbzec2.d.ts} +38 -23
  134. package/dist/{index-DC_MNGyu.d.ts → index-DYdObeFQ.d.ts} +3 -3
  135. package/dist/{index-Bc2Yg_2j.d.ts → index-Dq3Jlj8O-BJ6NxZm0.d.ts} +2 -2
  136. package/dist/{index-CT7miqQN.d.ts → index-DwWQVwQt.d.ts} +29 -11
  137. package/dist/{index-xdmCBvlT.d.ts → index-JWgwL5l3.d.ts} +5 -2
  138. package/dist/{index-DLA2DUR2.d.ts → index-M781pyx9.d.ts} +4 -3
  139. package/dist/{index-DdIRduDG.d.ts → index-d7io3MzC.d.ts} +3 -2
  140. package/dist/index.d.ts +4 -4
  141. package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
  142. package/dist/internal/plugin/OverridePlugin.js +101 -119
  143. package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
  144. package/dist/internal/plugin/pastedUploadFiles.js +4 -0
  145. package/dist/internal/plugin/resolvePlugin.js +1 -1
  146. package/dist/internal/plugin/resolvePlugins.js +3 -0
  147. package/dist/internal/plugin/uploadDrafts.js +6 -0
  148. package/dist/internal/utils/mergePlugins.js +1 -0
  149. package/dist/lib/plugins/element-id/ElementIdPlugin.js +14 -18
  150. package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
  151. package/dist/lib/plugins/html/htmlSafety.js +1 -1
  152. package/dist/lib/plugins/input-rules/InputRulesPlugin.js +77 -28
  153. package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
  154. package/dist/markdown/index.d.ts +2 -2
  155. package/dist/markdown/index.js +3 -1
  156. package/dist/markdown/lib/MarkdownPlugin.js +14 -11
  157. package/dist/markdown/lib/RawHtmlPlugin.js +26 -0
  158. package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
  159. package/dist/markdown/lib/internal/markdownConversion.js +776 -74
  160. package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
  161. package/dist/markdown/lib/internal/markdownFootnoteWriter.js +35 -0
  162. package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
  163. package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
  164. package/dist/markdown/lib/internal/markdownLine.js +5 -3
  165. package/dist/markdown/lib/internal/markdownMappings.js +19 -7
  166. package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
  167. package/dist/markdown/lib/internal/markdownRawHtml.js +353 -0
  168. package/dist/markdown/lib/internal/markdownSegments.js +57 -48
  169. package/dist/markdown/lib/internal/markdownTags.js +29 -9
  170. package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
  171. package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
  172. package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
  173. package/dist/math/index.d.ts +3 -2
  174. package/dist/math/react/index.d.ts +4 -3
  175. package/dist/migrations/index.d.ts +3 -3
  176. package/dist/migrations/migratePlateV54.js +4 -6
  177. package/dist/migrations/migratePlateV54RetiredMarks.internal.js +23 -8
  178. package/dist/migrations/migratePlateV54Suggestions.internal.js +2 -2
  179. package/dist/migrations/v53-manifest.internal.js +4 -0
  180. package/dist/pagination/index.d.ts +1 -1
  181. package/dist/pagination/react/index.d.ts +4 -4
  182. package/dist/react/components/EditorContentView.internal.js +42 -23
  183. package/dist/react/components/EditorProvider.js +5 -5
  184. package/dist/react/components/Plate.js +102 -128
  185. package/dist/react/components/PlateContainer.js +40 -32
  186. package/dist/react/components/PlateController.js +28 -16
  187. package/dist/react/components/PlateRoot.internal.js +3 -2
  188. package/dist/react/core.js +4 -4
  189. package/dist/react/features/board/BoardSurface.js +116 -87
  190. package/dist/react/features/board/boardClipboard.internal.js +15 -5
  191. package/dist/react/features/board/boardExport.internal.js +470 -0
  192. package/dist/react/features/board/boardGesture.internal.js +6 -3
  193. package/dist/react/features/board/boardIndex.internal.js +7 -18
  194. package/dist/react/features/board/boardPictureStyles.internal.js +415 -0
  195. package/dist/react/features/board/boardPictures.internal.js +19 -13
  196. package/dist/react/features/board/boardView.internal.js +190 -50
  197. package/dist/react/features/board/boardVoice.internal.js +10 -11
  198. package/dist/react/features/board/index.d.ts +108 -18
  199. package/dist/react/features/callout/index.d.ts +3 -2
  200. package/dist/react/features/combobox/index.d.ts +8 -8
  201. package/dist/react/features/comments/index.d.ts +6 -5
  202. package/dist/react/features/date/index.d.ts +4 -3
  203. package/dist/react/features/details/index.d.ts +4 -3
  204. package/dist/react/features/field/FieldPlugin.js +35 -0
  205. package/dist/react/features/field/index.d.ts +315 -0
  206. package/dist/react/features/field/index.js +2 -0
  207. package/dist/react/features/footnote/index.d.ts +7 -6
  208. package/dist/react/features/format-painter/index.d.ts +4 -3
  209. package/dist/react/features/ink/InkContent.js +313 -0
  210. package/dist/react/features/ink/index.d.ts +57 -33
  211. package/dist/react/features/ink/index.js +2 -2
  212. package/dist/react/features/ink/inkCapture.internal.js +39 -17
  213. package/dist/react/features/ink/inkInput.internal.js +1 -1
  214. package/dist/react/features/ink/inkLayout.internal.js +6 -3
  215. package/dist/react/features/ink/inkPaint.internal.js +78 -2
  216. package/dist/react/features/ink/inkPlacement.internal.js +332 -104
  217. package/dist/react/features/ink/inkWatch.internal.js +7 -5
  218. package/dist/react/features/layout/index.d.ts +5 -4
  219. package/dist/react/features/media/index.d.ts +5 -4
  220. package/dist/react/features/mention/index.d.ts +6 -5
  221. package/dist/react/features/resizable/Resizable.js +4 -6
  222. package/dist/react/features/resizable/index.d.ts +5 -5
  223. package/dist/react/features/suggestion/index.d.ts +6 -5
  224. package/dist/react/features/table/TablePlugin.js +4 -11
  225. package/dist/react/features/table/index.d.ts +10 -8
  226. package/dist/react/features/table/useTableResize.js +10 -1
  227. package/dist/react/features/toc/index.d.ts +2 -2
  228. package/dist/react/features/upload/index.d.ts +11 -6
  229. package/dist/react/index.d.ts +6 -6
  230. package/dist/react/index.js +4 -4
  231. package/dist/react/internal/plate-context.js +434 -188
  232. package/dist/react/plite-react.js +2 -2
  233. package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
  234. package/dist/react/stores/plate/useEditor.js +32 -14
  235. package/dist/react/stores/plate/useEditorHistory.js +55 -0
  236. package/dist/react/stores/plate/useEditorSelector.js +79 -21
  237. package/dist/react/utils/BlockPlaceholderPlugin.js +5 -2
  238. package/dist/react/utils/pipeRenderElement.internal.js +1 -1
  239. package/dist/react/utils/pluginRenderElement.internal.js +1 -1
  240. package/dist/react/virtualized.d.ts +4 -4
  241. package/dist/{source-CNKy99Th.d.ts → source-BGohy8vH.d.ts} +4 -4
  242. package/dist/static/index.d.ts +18 -18
  243. package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
  244. package/dist/static/internal/staticPresentation.js +4 -4
  245. package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
  246. package/dist/tabbable/index.d.ts +1 -1
  247. package/dist/tabbable/react/index.d.ts +3 -3
  248. package/dist/testing/index.d.ts +3 -3
  249. package/dist/yjs/index.d.ts +1 -1
  250. package/dist/yjs/react/index.d.ts +6 -6
  251. package/package.json +20 -2
  252. package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
  253. package/dist/react/components/EditorSelectionView.js +0 -40
  254. package/dist/react/features/ink/InkLayer.js +0 -218
  255. 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: { language: property.string() },
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-DkBGgyd3.js";
2
- import { n as filterWords, t as FilterWordsOptions } from "../../index-BBKGrsG3.js";
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()) ?? [], { id: "comments" });
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
- if (commit && !commit.changed.hasAny("document")) return;
293
- announce(changedIds(commit && ((root) => commit.changed.has("document", root)), !commit || commit.changed.hasAny("structure") || commit.changed.hasAny("properties")), "editor");
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 resolveIn = (view, anchor) => anchor.root === view.read.view.root() || isPageView(view) ? anchor.resolve(view) : null;
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
- if (location.resolve()) {
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 = location.resolve();
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 (RangeApi.isCollapsed(range)) return null;
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 (RangeApi.isCollapsed(range)) {
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 || RangeApi.isCollapsed(range)) return false;
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 = resolveIn(commandEditor, anchor);
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 && !RangeApi.isCollapsed(range) ? freezeComment({
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-Bxfvicyy.js";
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 { Mc as ElementOf, Qo as TxDeclaredMethod, vl as PropertyStringDescriptor } from "../../index-BU6k1Aev.js";
2
- import { _ as BasePlugin, _t as NodeInsertOptions } from "../../core-BJG8l_mk.js";
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 { $i as NodeKey, $u as EditorJsonValue, El as SchemaContentDefault, Il as SchemaContentRule, Mc as ElementOf, Mu as Location, Qo as TxDeclaredMethod, fl as PropertyJsonDescriptor, kl as SchemaContentPrefixSlot, ms as NodeSelection } from "../../index-BU6k1Aev.js";
2
- import { Qn as HeadingLevel, _ as BasePlugin, bo as PluginReference, ct as BlockInsertOptions, lt as BlockUpsertOptions, vo as PluginDependency } from "../../core-BJG8l_mk.js";
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 phrasing = node.level ? [
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 exitAfterDetails = () => state.transaction((tx) => {
350
- const nextPath = PathApi.next(details[1]);
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: nextPath,
368
+ at: afterDetails,
361
369
  select: true
362
370
  });
363
371
  });
364
372
  if (summary) {
365
- if (!viewStoreOf(state).get("openKeys").has(detailsKey)) return exitAfterDetails();
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 exitAfterDetails();
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 };
@@ -0,0 +1,4 @@
1
+ import { FIELD_TESTS, fitsField } from "./lib/fieldRules.internal.js";
2
+ import { BaseFieldPlugin } from "./lib/BaseFieldPlugin.js";
3
+ import { applyFieldValues } from "./lib/applyFieldValues.js";
4
+ export { BaseFieldPlugin, FIELD_TESTS, applyFieldValues, fitsField };