platejs 54.0.0-beta.13 → 54.0.0-beta.15

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 (226) hide show
  1. package/dist/{EditorStatic-CKG5xM3y.d.ts → EditorStatic-ldAMJg-F.d.ts} +4 -4
  2. package/dist/ai/index.d.ts +2 -2
  3. package/dist/ai/lib/aiDraftSession.js +9 -7
  4. package/dist/ai/lib/aiPolicy.internal.js +43 -6
  5. package/dist/ai/lib/editorAgent.js +30 -21
  6. package/dist/ai/lib/editorAgentSync.internal.js +2 -2
  7. package/dist/ai/lib/lockedContext.js +5 -4
  8. package/dist/ai/react/copilotInline.internal.js +6 -5
  9. package/dist/ai/react/index.d.ts +7 -7
  10. package/dist/ai/react/useEditorAgent.js +14 -3
  11. package/dist/authored/index.d.ts +4 -4
  12. package/dist/{authored-CJL7S8qI-BxC9ip4d.d.ts → authored-Cux94E76-fEDdP_BS.d.ts} +3 -3
  13. package/dist/clipboard-format-key-B_rCped5-BJzbgrSZ.d.ts +1 -0
  14. package/dist/code-block/codemirror/index.d.ts +2 -2
  15. package/dist/{comment-anchor.internal-DTBP1huU.d.ts → comment-anchor.internal-Ck30WbG4.d.ts} +2 -2
  16. package/dist/compiler/index.d.ts +3 -3
  17. package/dist/{core-CTB0OBoh.d.ts → core-DoxvjG5W.d.ts} +69 -23
  18. package/dist/diff/index.d.ts +2 -2
  19. package/dist/docs/agents/skills.md +6 -2
  20. package/dist/docs/agents.md +1 -1
  21. package/dist/docs/ai-agents.md +8 -4
  22. package/dist/docs/ai.md +5 -0
  23. package/dist/docs/api/plate.md +15 -7
  24. package/dist/docs/api/react-hooks.md +32 -2
  25. package/dist/docs/authored-changes.md +4 -0
  26. package/dist/docs/block-menu.md +4 -0
  27. package/dist/docs/board.md +4 -0
  28. package/dist/docs/callout.md +63 -9
  29. package/dist/docs/collaboration.md +6 -1
  30. package/dist/docs/combobox.md +9 -2
  31. package/dist/docs/comment.md +8 -4
  32. package/dist/docs/components/toolbar-buttons.md +1 -1
  33. package/dist/docs/copilot.md +4 -0
  34. package/dist/docs/deck.md +173 -0
  35. package/dist/docs/details.md +4 -0
  36. package/dist/docs/diff.md +4 -0
  37. package/dist/docs/discussion.md +4 -0
  38. package/dist/docs/dnd.md +4 -0
  39. package/dist/docs/docx.md +6 -0
  40. package/dist/docs/emoji.md +2 -2
  41. package/dist/docs/equation.md +4 -0
  42. package/dist/docs/examples/collaboration-example.md +4 -0
  43. package/dist/docs/examples/export.md +41 -31
  44. package/dist/docs/examples/merge.md +4 -0
  45. package/dist/docs/examples/version-history.md +4 -0
  46. package/dist/docs/field.md +4 -0
  47. package/dist/docs/footnote.md +4 -0
  48. package/dist/docs/format-painter.md +1 -1
  49. package/dist/docs/html.md +4 -0
  50. package/dist/docs/index.md +4 -0
  51. package/dist/docs/ink.md +6 -0
  52. package/dist/docs/installation/manual.md +2 -4
  53. package/dist/docs/installation/next.md +1 -3
  54. package/dist/docs/installation/plate-ui.md +6 -2
  55. package/dist/docs/installation/rsc.md +1 -1
  56. package/dist/docs/installation.md +4 -0
  57. package/dist/docs/link.md +6 -0
  58. package/dist/docs/lint.md +18 -0
  59. package/dist/docs/llms.txt +4 -1
  60. package/dist/docs/lock.md +34 -2
  61. package/dist/docs/markdown.md +8 -0
  62. package/dist/docs/media.md +4 -0
  63. package/dist/docs/mention.md +5 -0
  64. package/dist/docs/mobile.md +415 -0
  65. package/dist/docs/pagination.md +4 -0
  66. package/dist/docs/prompt-editor.md +17 -1
  67. package/dist/docs/reference.md +192 -0
  68. package/dist/docs/roots.md +34 -0
  69. package/dist/docs/serializing.md +23 -0
  70. package/dist/docs/slash-command.md +58 -4
  71. package/dist/docs/static.md +29 -20
  72. package/dist/docs/suggestion.md +4 -0
  73. package/dist/docs/sync.md +4 -0
  74. package/dist/docs/table.md +31 -0
  75. package/dist/docs/toc.md +14 -0
  76. package/dist/docs/toolbar.md +4 -0
  77. package/dist/docs/unit-testing.md +4 -0
  78. package/dist/docs/upload.md +4 -0
  79. package/dist/docx/export/index.d.ts +5 -5
  80. package/dist/docx/import/index.d.ts +5 -5
  81. package/dist/docx/paste/index.d.ts +4 -4
  82. package/dist/dom/index.d.ts +1 -1
  83. package/dist/features/basic-nodes/lib/BaseMarkPlugins.js +1 -1
  84. package/dist/features/basic-styles/lib/BaseFormattingPlugin.js +61 -28
  85. package/dist/features/basic-styles/lib/BaseStylePlugins.js +28 -7
  86. package/dist/features/board/index.d.ts +1 -1
  87. package/dist/features/callout/index.d.ts +2 -160
  88. package/dist/features/callout/lib/BaseCalloutPlugin.js +109 -9
  89. package/dist/features/column/index.d.ts +1 -1
  90. package/dist/features/comments/index.d.ts +2 -2
  91. package/dist/features/date/index.d.ts +3 -3
  92. package/dist/features/details/index.d.ts +3 -3
  93. package/dist/features/field/index.d.ts +1 -1
  94. package/dist/features/field/lib/BaseFieldPlugin.js +111 -53
  95. package/dist/features/field/lib/fieldCache.internal.js +9 -21
  96. package/dist/features/find/index.d.ts +3 -3
  97. package/dist/features/footnote/index.d.ts +3 -3
  98. package/dist/features/ink/index.d.ts +1 -1
  99. package/dist/features/link/lib/BaseLinkPlugin.js +5 -2
  100. package/dist/features/lint/index.d.ts +3 -3
  101. package/dist/features/list/lib/listKeyboard.internal.js +7 -2
  102. package/dist/features/lock/index.d.ts +1 -1
  103. package/dist/features/media/index.d.ts +1 -1
  104. package/dist/features/mention/index.d.ts +1 -1
  105. package/dist/features/reference/index.d.ts +240 -0
  106. package/dist/features/reference/index.js +2 -0
  107. package/dist/features/reference/lib/BaseReferencePlugin.js +598 -0
  108. package/dist/features/table/index.d.ts +2 -2
  109. package/dist/features/toc/index.d.ts +1 -1
  110. package/dist/features/upload/index.d.ts +1 -1
  111. package/dist/history/index.d.ts +1 -1
  112. package/dist/html/index.d.ts +4 -4
  113. package/dist/html/server/index.d.ts +2 -2
  114. package/dist/html/server/serverCssParser.internal.js +14 -25
  115. package/dist/html/server/serverCssStyle.internal.js +4 -7
  116. package/dist/{htmlConversion-Y-M6PLRi.d.ts → htmlConversion-CHcWrkh5.d.ts} +2 -2
  117. package/dist/{htmlTypes-CNhoCFjK.d.ts → htmlTypes-9HQ8p7c5.d.ts} +3 -3
  118. package/dist/hyperscript/index.d.ts +1 -1
  119. package/dist/index-1JPYTyFo.d.ts +305 -0
  120. package/dist/index-B-SGl9uM.d.ts +1 -0
  121. package/dist/{index-qqrnWAk_.d.ts → index-B048Z6JD.d.ts} +7 -7
  122. package/dist/index-BFkl1TNK.d.ts +1 -0
  123. package/dist/{index-DYuqsDrP.d.ts → index-BRwhNV78.d.ts} +3 -3
  124. package/dist/{index-B0R9sXv2-T1dxG9oM.d.ts → index-BYv6zIL_-DWmaXzbX.d.ts} +4 -4
  125. package/dist/{index-B-8L9f6a2.d.ts → index-Bm8V8SS4.d.ts} +5 -5
  126. package/dist/{index-B8JeECEk.d.ts → index-BujEk356.d.ts} +2 -2
  127. package/dist/{index-CHud6Aa-.d.ts → index-C4KIDKwP.d.ts} +3 -3
  128. package/dist/{index-B4aToRMv.d.ts → index-CAFKQNqu.d.ts} +3 -3
  129. package/dist/{index-Bqva6PJc.d.ts → index-CXJwwbAJ.d.ts} +3 -3
  130. package/dist/index-CfqQvdcO.d.ts +3 -0
  131. package/dist/{index-D54VPeky.d.ts → index-Cj09P2Qp.d.ts} +2 -2
  132. package/dist/{index-mcBtG6pK-CitQV9Bq.d.ts → index-CnumypT3-DGx8_6Ye.d.ts} +2 -2
  133. package/dist/{index-CWutqVQ_-BO-UgVeK.d.ts → index-DTTSk3WQ-D0TA0B5z.d.ts} +1 -1
  134. package/dist/{index-CLPMcGC5.d.ts → index-DsKfZoY4.d.ts} +4 -4
  135. package/dist/{index-UYpvOBXG.d.ts → index-UrJ6V3_e.d.ts} +2 -2
  136. package/dist/{index-DXCdafUk.d.ts → index-UuSQ_p3c.d.ts} +43 -20
  137. package/dist/{index-BEXBAmJf.d.ts → index-YNMmixU5.d.ts} +3 -3
  138. package/dist/{index-CXd5hwaH.d.ts → index-Zj4bj9bZ.d.ts} +1 -1
  139. package/dist/{index-BfJKfAwk.d.ts → index-eWzk-bcU.d.ts} +3 -3
  140. package/dist/{index-DhsryaAC.d.ts → index-h2HH9Rw8.d.ts} +1 -1
  141. package/dist/{index-DJhwDkfd.d.ts → index-l9R_LyGx.d.ts} +3 -3
  142. package/dist/{index-BFWK852j.d.ts → index-lD9iIU3j.d.ts} +3 -3
  143. package/dist/{index-D3bhjdRz.d.ts → index-lgeYbG68.d.ts} +3 -3
  144. package/dist/index.d.ts +3 -3
  145. package/dist/internal/plugin/compilePlateModel.js +24 -5
  146. package/dist/internal/plugin/pluginInjectNodeProps.js +33 -5
  147. package/dist/internal/utils/urlPolicy.js +11 -1
  148. package/dist/lib/editor/withPlite.js +8 -6
  149. package/dist/lib/plugins/html/cssLexer.internal.js +144 -37
  150. package/dist/lib/plugins/html/cssSafety.internal.js +100 -0
  151. package/dist/lib/plugins/html/htmlDecode.internal.js +2 -2
  152. package/dist/lib/plugins/html/htmlMatcher.internal.js +1 -1
  153. package/dist/lib/plugins/html/htmlRules.internal.js +2 -13
  154. package/dist/lib/plugins/html/htmlSafety.js +28 -27
  155. package/dist/lib/plugins/html/htmlSerialize.internal.js +16 -2
  156. package/dist/lib/plugins/html/htmlStyleInline.internal.js +38 -31
  157. package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +27 -1
  158. package/dist/markdown/index.d.ts +1 -1
  159. package/dist/markdown/lib/internal/markdownAttributes.js +16 -7
  160. package/dist/markdown/lib/internal/markdownMappings.js +123 -16
  161. package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +16 -1
  162. package/dist/math/index.d.ts +3 -3
  163. package/dist/math/react/index.d.ts +4 -4
  164. package/dist/migrations/index.d.ts +4 -4
  165. package/dist/migrations/migratePlateV54Urls.internal.js +63 -1
  166. package/dist/pagination/index.d.ts +1 -1
  167. package/dist/pagination/react/PaginationPlugin.js +46 -43
  168. package/dist/pagination/react/index.d.ts +13 -7
  169. package/dist/{protocol-CSuP7AWG-DAorqpaF.d.ts → protocol-CYflJUT3-CRJPCqOO.d.ts} +1 -1
  170. package/dist/react/authored/index.d.ts +4 -4
  171. package/dist/react/components/PlateView.js +7 -1
  172. package/dist/react/features/board/index.d.ts +5 -5
  173. package/dist/react/features/callout/index.d.ts +93 -4
  174. package/dist/react/features/column/index.d.ts +5 -5
  175. package/dist/react/features/combobox/combobox.internal.js +35 -22
  176. package/dist/react/features/combobox/comboboxOwner.internal.js +29 -2
  177. package/dist/react/features/combobox/index.d.ts +8 -6
  178. package/dist/react/features/comments/index.d.ts +6 -6
  179. package/dist/react/features/date/index.d.ts +4 -4
  180. package/dist/react/features/details/index.d.ts +4 -4
  181. package/dist/react/features/field/FieldPlugin.js +2 -2
  182. package/dist/react/features/field/index.d.ts +5 -5
  183. package/dist/react/features/footnote/index.d.ts +4 -4
  184. package/dist/react/features/format-painter/FormatPainterPlugin.js +27 -34
  185. package/dist/react/features/format-painter/index.d.ts +4 -4
  186. package/dist/react/features/ink/index.d.ts +5 -5
  187. package/dist/react/features/lock/index.d.ts +5 -5
  188. package/dist/react/features/media/index.d.ts +5 -5
  189. package/dist/react/features/mention/index.d.ts +4 -4
  190. package/dist/react/features/table/index.d.ts +6 -6
  191. package/dist/react/features/toc/index.d.ts +2 -2
  192. package/dist/react/features/upload/index.d.ts +5 -5
  193. package/dist/react/index.d.ts +6 -6
  194. package/dist/react/virtualized.d.ts +3 -3
  195. package/dist/refusal-VX2Y6Wmd-BJzbgrSZ.d.ts +1 -0
  196. package/dist/{registerEditorTools-Cl-o_Wnq.d.ts → registerEditorTools-DoRs57-M.d.ts} +16 -8
  197. package/dist/shared-room-BZxUmqjV-BJzbgrSZ.d.ts +1 -0
  198. package/dist/skills/plate/SKILL.md +4 -3
  199. package/dist/skills/plate/references/ai-and-agents.md +2 -2
  200. package/dist/skills/plate/references/pricing.md +3 -3
  201. package/dist/skills/plate/references/setup.md +6 -0
  202. package/dist/skills/plate/references/ui-and-sync.md +4 -3
  203. package/dist/{source-DUP5aKcT.d.ts → source-PTxjcq4_.d.ts} +3 -3
  204. package/dist/static/index.d.ts +23 -9
  205. package/dist/static/internal/staticPendingMedia.internal.js +2 -1
  206. package/dist/static/internal/staticPresentation.js +1 -0
  207. package/dist/static/renderStaticHtml.js +85 -39
  208. package/dist/{storage-EzfLDqRy-Cu4DQ-Rf.d.ts → storage-CkRL-SHq-CBP6PGqr.d.ts} +2 -2
  209. package/dist/sync/cloudflare/index.d.ts +3 -3
  210. package/dist/sync/index.d.ts +4 -4
  211. package/dist/sync/postgres/index.d.ts +1 -1
  212. package/dist/sync/react/index.d.ts +6 -6
  213. package/dist/sync/server/index.d.ts +5 -5
  214. package/dist/tabbable/react/index.d.ts +4 -4
  215. package/dist/testing/index.d.ts +3 -3
  216. package/dist/{transport-DAforzBt-BFwAhC-N.d.ts → transport-2koNcrqA-Dp_RYE3n.d.ts} +1 -1
  217. package/dist/utils/plate-keys.js +1 -0
  218. package/dist/{widths-BjIZxtaJ.d.ts → widths-DN1W6m66.d.ts} +5 -5
  219. package/package.json +9 -2
  220. package/dist/clipboard-format-key-D9rnh20X-CR00YA0H.d.ts +0 -1
  221. package/dist/index-CKAkaSJK.d.ts +0 -3
  222. package/dist/index-CxyK4HrT.d.ts +0 -1
  223. package/dist/index-zcb_RtZC.d.ts +0 -1
  224. package/dist/refusal-DCzeB9nD-CR00YA0H.d.ts +0 -1
  225. package/dist/shared-room-Bg8qMvm1-CR00YA0H.d.ts +0 -1
  226. /package/dist/{tx-only-CWT-IURY-BqIFhy44.d.ts → tx-only-x32UA-pQ-OQbgWQrN.d.ts} +0 -0
@@ -1,2 +1,2 @@
1
- import { C as fillsField, S as FIELD_TESTS, _ as FieldRead, a as fieldSubmission, b as FieldTest, c as startFieldValues, d as FieldConditionTest, f as FieldElement, g as FieldProblem, h as FieldPatch, i as applyFieldValues, l as BaseFieldPlugin, m as FieldOption, n as FieldApplyResult, o as readFieldAnswers, p as FieldKind, r as FieldRefusal, s as readFields, t as FieldAnswer, u as FieldCondition, v as FieldSettings, w as fitsField, x as FieldValue, y as FieldSubmission } from "../../index-DJhwDkfd.js";
1
+ import { C as fillsField, S as FIELD_TESTS, _ as FieldRead, a as fieldSubmission, b as FieldTest, c as startFieldValues, d as FieldConditionTest, f as FieldElement, g as FieldProblem, h as FieldPatch, i as applyFieldValues, l as BaseFieldPlugin, m as FieldOption, n as FieldApplyResult, o as readFieldAnswers, p as FieldKind, r as FieldRefusal, s as readFields, t as FieldAnswer, u as FieldCondition, v as FieldSettings, w as fitsField, x as FieldValue, y as FieldSubmission } from "../../index-l9R_LyGx.js";
2
2
  export { BaseFieldPlugin, FIELD_TESTS, FieldAnswer, FieldApplyResult, FieldCondition, FieldConditionTest, FieldElement, FieldKind, FieldOption, FieldPatch, FieldProblem, FieldRead, FieldRefusal, FieldSettings, FieldSubmission, FieldTest, FieldValue, applyFieldValues, fieldSubmission, fillsField, fitsField, readFieldAnswers, readFields, startFieldValues };
@@ -1,10 +1,10 @@
1
- import { EditorRefusalError, claimsHistoryReplay, getActiveEditorUpdateId, getActiveEditorUpdateTags, getCompiledEditorSchema, getEditorAuthoredDocumentCapability, getInternalEditorRuntimeOwner, getMutationVersion, getSnapshotVersion, hasAuthoredRuntime, isAuthoredFormatOnlyPropertyWrite, isDocumentView, isPersistedEffect, notifyEditorAdmissionChange, readEditorCommitChangesHistoryTopStep, readElementPropertyWrites, readViewPage, registerEditorAdmissionCheck, registerEditorTransactionGuard } from "../../../facade.js";
1
+ import { EditorRefusalError, claimsHistoryReplay, getActiveEditorUpdateId, getActiveEditorUpdateTags, getCompiledEditorSchema, getEditorAuthoredDocumentCapability, getInternalEditorRuntimeOwner, getMutationVersion, getSnapshotVersion, hasAuthoredRuntime, isAuthoredFormatOnlyPropertyWrite, isDocumentView, isPersistedEffect, notifyEditorAdmissionChange, readEditorCommitChangesHistoryTopStep, readElementPropertyWrites, readShownDocument, readViewPage, registerEditorAdmissionCheck, registerEditorTransactionGuard } from "../../../facade.js";
2
2
  import { failInvariant } from "../../../internal/failInvariant.js";
3
3
  import { definePlugin } from "../../../lib/plugin/definePlugin.js";
4
4
  import { ElementApi, documentReplacement, locateAt, property, schema, target, txLocate } from "../../../core.js";
5
5
  import { BaseLockPlugin, lockWriteExemption } from "../../lock/lib/BaseLockPlugin.js";
6
- import { FIELD_KINDS, FIELD_TESTS, conditionGraph, conditionProblem, conditionRefs, conditionTargets, conditionTestKey, conditionTests, fieldProblems, fillsField, fitsField, indexFieldNames, isFieldCondition, isFieldKind, isFieldName, isFieldOptions, isFieldValue, isMaxCount, isMinCount, nameProblems, unfitSettings } from "./fieldRules.internal.js";
7
- import { carryFieldNames, dropFieldNames, holdsFieldNames, recordFieldAccess, sharedFieldLinks, sharedFieldNames, wantsFieldAccess } from "./fieldCache.internal.js";
6
+ import { FIELD_KINDS, FIELD_TESTS, conditionGraph, conditionProblem, conditionRefs, conditionTargets, conditionTestKey, conditionTests, fieldProblems, fillsField, fitsField, indexFieldNames, isFieldCondition, isFieldKind, isFieldName, isFieldOptions, isFieldValue, isMaxCount, isMinCount, nameProblems, sameFieldValue, unfitSettings } from "./fieldRules.internal.js";
7
+ import { carryFieldNames, dropFieldNames, holdsFieldNames, registerFieldAccessReader, sharedFieldLinks, sharedFieldNames } from "./fieldCache.internal.js";
8
8
  import { nanoid } from "nanoid";
9
9
  //#region src/features/field/lib/BaseFieldPlugin.ts
10
10
  const optionText = (options, entry) => {
@@ -302,6 +302,100 @@ const BaseFieldPlugin = fieldSchemaPlugin.extend(({ editor, schema: { properties
302
302
  if (afterValueWrite?.updateId === updateId) return afterValueWrite.count === count ? afterValueWrite.index : void 0;
303
303
  return countAtCommit === count ? sharedFieldNames(reader, nodes) : void 0;
304
304
  };
305
+ const readFieldRecord = (reader, state, fieldId) => {
306
+ readCountAtCommit();
307
+ const { held, heldWithKey, listed } = documentOf(state);
308
+ const entry = heldWithKey(fieldId);
309
+ if (!entry) return null;
310
+ const [node, key] = entry;
311
+ const names = (nodes) => namesOfUntouchedDraft(reader, nodes) ?? indexFieldNames(nodes());
312
+ const link = sharedFieldLinks(reader).link(node, held);
313
+ return {
314
+ key,
315
+ node,
316
+ read: {
317
+ applies: link.applies,
318
+ fieldId,
319
+ node,
320
+ problems: [...fieldProblems(node, link), ...node.name === void 0 ? [] : nameProblems(node, names(() => listed().nodes), held)]
321
+ }
322
+ };
323
+ };
324
+ const pendingDeleteCache = /* @__PURE__ */ new WeakMap();
325
+ const fieldsOfDocument = (doc) => {
326
+ const byId = /* @__PURE__ */ new Map();
327
+ const add = (nodes) => {
328
+ for (const node of fieldsIn(nodes)) if (!byId.has(node.fieldId)) byId.set(node.fieldId, node);
329
+ };
330
+ add(doc.children);
331
+ for (const rootNodes of Object.values(doc.roots ?? {})) add(rootNodes);
332
+ return byId;
333
+ };
334
+ const pendingDeletedFieldIds = (doc, authored, compiled) => {
335
+ const bySchema = pendingDeleteCache.get(doc);
336
+ const cached = bySchema?.get(compiled);
337
+ if (cached) return cached;
338
+ const stored = fieldsOfDocument(doc);
339
+ const deletedFieldIds = /* @__PURE__ */ new Set();
340
+ const projected = authored.project(doc, "proposed", compiled);
341
+ const surviving = projected.ok ? fieldsOfDocument(projected.document) : null;
342
+ for (const [fieldId, node] of stored) if (surviving ? !surviving.has(fieldId) : authored.reviewOf(doc, node, compiled).marks.some((mark) => mark.kind === "delete")) deletedFieldIds.add(fieldId);
343
+ const nextBySchema = bySchema ?? /* @__PURE__ */ new WeakMap();
344
+ nextBySchema.set(compiled, deletedFieldIds);
345
+ if (!bySchema) pendingDeleteCache.set(doc, nextBySchema);
346
+ return deletedFieldIds;
347
+ };
348
+ const assertNoPendingDeleteWrites = (before, after, refuse) => {
349
+ const authored = getEditorAuthoredDocumentCapability(editor);
350
+ if (!authored || authored.pending(after) === 0) return;
351
+ const intervals = [];
352
+ let cursor = before;
353
+ for (const span of authored.activeDecisionSpans?.(editor) ?? []) {
354
+ if (cursor !== span.before) intervals.push([cursor, span.before]);
355
+ cursor = span.after;
356
+ }
357
+ if (cursor !== after) intervals.push([cursor, after]);
358
+ if (intervals.length === 0) return;
359
+ const compiled = getCompiledEditorSchema(editor);
360
+ const deletedAfter = pendingDeletedFieldIds(after, authored, compiled);
361
+ if (deletedAfter.size === 0) return;
362
+ const afterFields = fieldsOfDocument(after);
363
+ const pendingDeleteMessage = "Cannot write a field answer while a pending deletion awaits review.";
364
+ let afterIndex;
365
+ for (const [segBefore, segAfter] of intervals) {
366
+ const prevFields = fieldsOfDocument(segBefore);
367
+ const nextFields = segAfter === after ? afterFields : fieldsOfDocument(segAfter);
368
+ for (const [fieldId, nextNode] of nextFields) {
369
+ const prevNode = prevFields.get(fieldId);
370
+ if (sameFieldValue(prevNode?.value, nextNode.value)) continue;
371
+ if (deletedAfter.has(fieldId)) throw refuse(pendingDeleteMessage);
372
+ const finalNode = afterFields.get(fieldId) ?? nextNode;
373
+ if (finalNode.name === void 0) continue;
374
+ afterIndex ??= indexFieldNames([...afterFields.values()]);
375
+ if (nameProblems(finalNode, afterIndex, (id) => afterFields.get(id)).includes("name-conflict")) continue;
376
+ for (const id of afterIndex.byRole.get(finalNode.role)?.get(finalNode.name) ?? []) if (deletedAfter.has(id) && (prevNode !== void 0 || !sameFieldValue(nextNode.value, afterFields.get(id)?.value))) throw refuse(pendingDeleteMessage);
377
+ }
378
+ }
379
+ };
380
+ const readAccess = (reader, state, node, key) => {
381
+ const fixed = isDocumentView(reader);
382
+ const locked = !fixed && reader.plugin(BaseLockPlugin).installed && reader.plugin(BaseLockPlugin).read.isLocked(key);
383
+ let waitsForReview = false;
384
+ if (!fixed && readShownDocument(reader) === null && hasAuthoredRuntime(reader)) {
385
+ const authored = getEditorAuthoredDocumentCapability(reader);
386
+ if (authored) {
387
+ const doc = state.value();
388
+ if (authored.pending(doc) > 0) {
389
+ const compiled = getCompiledEditorSchema(reader);
390
+ waitsForReview = pendingDeletedFieldIds(doc, authored, compiled).has(node.fieldId) || authored.reviewOf(doc, node, compiled).marks.some((mark) => mark.kind === "delete" || mark.kind === "format" && mark.key === "value");
391
+ }
392
+ }
393
+ }
394
+ return {
395
+ locked,
396
+ waitsForReview
397
+ };
398
+ };
305
399
  return {
306
400
  contributions: [lockWriteExemption.of(({ element, modifications }) => {
307
401
  if (!isField(element)) return false;
@@ -312,6 +406,14 @@ const BaseFieldPlugin = fieldSchemaPlugin.extend(({ editor, schema: { properties
312
406
  activate({ afterPublish, onCleanup }) {
313
407
  afterPublish(readCountAtCommit);
314
408
  onCleanup(owner.subscribeCommit(readCountAtCommit));
409
+ onCleanup(registerFieldAccessReader(editor, (reader, fieldId) => reader.read((state) => {
410
+ const found = readFieldRecord(reader, state, fieldId);
411
+ if (!found) return null;
412
+ return {
413
+ ...found.read,
414
+ ...readAccess(reader, state, found.node, found.key)
415
+ };
416
+ })));
315
417
  let lastFillRole = store.get("fillRole") ?? null;
316
418
  onCleanup(store.subscribe(() => {
317
419
  const nextFillRole = store.get("fillRole") ?? null;
@@ -324,7 +426,7 @@ const BaseFieldPlugin = fieldSchemaPlugin.extend(({ editor, schema: { properties
324
426
  mode: store.get("fillRole") ?? null,
325
427
  version: getSnapshotVersion(editor)
326
428
  };
327
- onCleanup(registerEditorAdmissionCheck(editor, ({ before, commit, effects }) => {
429
+ onCleanup(registerEditorAdmissionCheck(editor, ({ after, before, commit, effects }) => {
328
430
  const role = store.get("fillRole") ?? null;
329
431
  const write = openWriteOfThisUpdate();
330
432
  const refuse = (message) => new EditorRefusalError({
@@ -334,8 +436,10 @@ const BaseFieldPlugin = fieldSchemaPlugin.extend(({ editor, schema: { properties
334
436
  const { tags } = commit;
335
437
  const collaboration = tags.includes("collaboration");
336
438
  if (write !== null && (write.switched || write.mode !== role) && !collaboration) throw refuse(`The fill role changed from ${JSON.stringify(write.mode)} to ${JSON.stringify(role)} inside one update.`);
439
+ const replaces = commit.annotations[documentReplacement.key] === true;
440
+ if (!collaboration && !replaces && !tags.includes("historic") && hasAuthoredRuntime(editor)) assertNoPendingDeleteWrites(before, after, refuse);
337
441
  if (role === null || collaboration) return;
338
- if (commit.annotations[documentReplacement.key] === true) throw refuse(`A fill as ${JSON.stringify(role)} cannot replace the document.`);
442
+ if (replaces) throw refuse(`A fill as ${JSON.stringify(role)} cannot replace the document.`);
339
443
  if ((claimsHistoryReplay(commit) || effects.some(({ type: effect }) => isPersistedEffect(effect)) ? null : readElementPropertyWrites(editor, {
340
444
  before,
341
445
  commit
@@ -390,7 +494,7 @@ const BaseFieldPlugin = fieldSchemaPlugin.extend(({ editor, schema: { properties
390
494
  }],
391
495
  read: ({ editor: reader, state }) => {
392
496
  readCountAtCommit();
393
- const { held, heldWithKey, listed } = documentOf(state);
497
+ const { listed } = documentOf(state);
394
498
  const names = (nodes) => namesOfUntouchedDraft(reader, nodes) ?? indexFieldNames(nodes());
395
499
  return {
396
500
  /**
@@ -408,31 +512,7 @@ const BaseFieldPlugin = fieldSchemaPlugin.extend(({ editor, schema: { properties
408
512
  * no field holds it. Looks up the field, then one field for each
409
513
  * condition it follows along the chain.
410
514
  */
411
- field: (fieldId) => {
412
- const entry = heldWithKey(fieldId);
413
- if (!entry) return null;
414
- const [node, key] = entry;
415
- if (wantsFieldAccess()) {
416
- const fixed = isDocumentView(reader);
417
- const locked = !fixed && reader.plugin(BaseLockPlugin).installed && reader.plugin(BaseLockPlugin).read.isLocked(key);
418
- let waitsForReview = false;
419
- if (!fixed && hasAuthoredRuntime(reader)) {
420
- const authored = getEditorAuthoredDocumentCapability(reader);
421
- if (authored) waitsForReview = authored.reviewOf(state.value(), node, getCompiledEditorSchema(reader)).marks.some((mark) => mark.kind === "delete" || mark.kind === "format" && mark.key === "value");
422
- }
423
- recordFieldAccess({
424
- locked,
425
- waitsForReview
426
- });
427
- }
428
- const link = sharedFieldLinks(reader).link(node, held);
429
- return {
430
- applies: link.applies,
431
- fieldId,
432
- node,
433
- problems: [...fieldProblems(node, link), ...node.name === void 0 ? [] : nameProblems(node, names(() => listed().nodes), held)]
434
- };
435
- },
515
+ field: (fieldId) => readFieldRecord(reader, state, fieldId)?.read ?? null,
436
516
  /** Every field of the document, in reading order. */
437
517
  fields: () => {
438
518
  const { lookup, nodes } = listed();
@@ -543,28 +623,6 @@ const BaseFieldPlugin = fieldSchemaPlugin.extend(({ editor, schema: { properties
543
623
  } else if (!("condition" in patch) && reshaped && field.condition && isFieldCondition(field.condition)) checkCondition(field.condition, field, next);
544
624
  const valuesOnly = Object.keys(patch).every((setting) => setting === "value");
545
625
  const kept = field.name === void 0 || !valuesOnly ? void 0 : namesOfUntouchedDraft(writer, () => document.listed().nodes);
546
- if ("value" in patch && hasAuthoredRuntime(writer)) {
547
- const authored = getEditorAuthoredDocumentCapability(writer);
548
- if (authored) {
549
- const compiled = getCompiledEditorSchema(writer);
550
- const snapshot = tx.value();
551
- const hasPendingDelete = (targetNode) => authored.reviewOf(snapshot, targetNode, compiled).marks.some((mark) => mark.kind === "delete");
552
- const rejectPendingDelete = () => new EditorRefusalError({
553
- reason: "field-fill",
554
- role: role ?? null
555
- }, "Cannot write a field answer while a pending deletion awaits review.");
556
- if (hasPendingDelete(field)) throw rejectPendingDelete();
557
- if (next.name !== void 0) {
558
- const previewIndex = kept ?? indexFieldNames(document.listed().nodes.map((entry) => entry.fieldId === fieldId ? next : entry));
559
- const previewHeld = (id) => id === fieldId ? next : document.held(id);
560
- if (!nameProblems(next, previewIndex, previewHeld).includes("name-conflict")) for (const id of previewIndex.byRole.get(next.role)?.get(next.name) ?? []) {
561
- if (id === fieldId) continue;
562
- const [sibling] = held(id);
563
- if (sibling && hasPendingDelete(sibling)) throw rejectPendingDelete();
564
- }
565
- }
566
- }
567
- }
568
626
  const dropped = unfit.filter((setting) => next.kind !== field.kind ? true : setting === "value" && ("max" in patch || "options" in patch));
569
627
  tx.nodes.set({
570
628
  ...patch,
@@ -53,27 +53,15 @@ const dropFieldNames = (editor, from) => {
53
53
  const owner = getInternalEditorRuntimeOwner(editor);
54
54
  if (nameIndexes.get(owner)?.version === from) nameIndexes.delete(owner);
55
55
  };
56
- let activeAccessCollector = null;
57
- const wantsFieldAccess = () => activeAccessCollector !== null;
58
- const recordFieldAccess = (access) => {
59
- if (activeAccessCollector) activeAccessCollector.access = access;
56
+ const accessReaders = /* @__PURE__ */ new WeakMap();
57
+ const registerFieldAccessReader = (editor, read) => {
58
+ const owner = getInternalEditorRuntimeOwner(editor);
59
+ accessReaders.set(owner, read);
60
+ return () => {
61
+ if (accessReaders.get(owner) === read) accessReaders.delete(owner);
62
+ };
60
63
  };
61
64
  const isFieldLockInstalled = (editor) => editor.plugin(BaseLockPlugin).installed;
62
- const readWithFieldAccess = (readField) => {
63
- const previous = activeAccessCollector;
64
- const collector = { access: null };
65
- activeAccessCollector = collector;
66
- try {
67
- const field = readField();
68
- if (!field) return null;
69
- return {
70
- ...field,
71
- locked: collector.access?.locked ?? false,
72
- waitsForReview: collector.access?.waitsForReview ?? false
73
- };
74
- } finally {
75
- activeAccessCollector = previous;
76
- }
77
- };
65
+ const readFieldWithAccess = (editor, fieldId) => accessReaders.get(getInternalEditorRuntimeOwner(editor))?.(editor, fieldId) ?? null;
78
66
  //#endregion
79
- export { carryFieldNames, dropFieldNames, holdsFieldNames, isFieldLockInstalled, readWithFieldAccess, recordFieldAccess, sharedFieldLinks, sharedFieldNames, wantsFieldAccess };
67
+ export { carryFieldNames, dropFieldNames, holdsFieldNames, isFieldLockInstalled, readFieldWithAccess, registerFieldAccessReader, sharedFieldLinks, sharedFieldNames };
@@ -1,6 +1,6 @@
1
- import { $o as Range, Po as Point, Vl as TxDeclaredMethod, fs as RootKey } from "../../tx-only-CWT-IURY-BqIFhy44.js";
2
- import "../../htmlTypes-CNhoCFjK.js";
3
- import { ao as NormalizePluginSelectors, p as BasePlugin, xo as PluginSelectorMethods } from "../../core-CTB0OBoh.js";
1
+ import { $o as Range, Po as Point, Vl as TxDeclaredMethod, fs as RootKey } from "../../tx-only-x32UA-pQ-OQbgWQrN.js";
2
+ import "../../htmlTypes-9HQ8p7c5.js";
3
+ import { ao as NormalizePluginSelectors, p as BasePlugin, xo as PluginSelectorMethods } from "../../core-DoxvjG5W.js";
4
4
  /** Query matching options for literal, whole-word, or regular-expression search. */
5
5
  type FindOptions = Readonly<{
6
6
  /** Match exact letter casing. Defaults to false. */
@@ -1,6 +1,6 @@
1
- import { Es as SchemaContentRule, Mt as EditorJsonValue, N as Descendant, Vl as TxDeclaredMethod, Wa as Path, gi as Element$1, gs as SchemaContentDefault, ia as NodeEntry, qo as PropertyStringDescriptor, wi as ElementOf } from "../../tx-only-CWT-IURY-BqIFhy44.js";
2
- import "../../htmlTypes-CNhoCFjK.js";
3
- import { fo as PluginReference, p as BasePlugin, uo as PluginDependency, vt as NodeInsertOptions } from "../../core-CTB0OBoh.js";
1
+ import { Es as SchemaContentRule, Mt as EditorJsonValue, N as Descendant, Vl as TxDeclaredMethod, Wa as Path, gi as Element$1, gs as SchemaContentDefault, ia as NodeEntry, qo as PropertyStringDescriptor, wi as ElementOf } from "../../tx-only-x32UA-pQ-OQbgWQrN.js";
2
+ import "../../htmlTypes-9HQ8p7c5.js";
3
+ import { fo as PluginReference, p as BasePlugin, uo as PluginDependency, vt as NodeInsertOptions } from "../../core-DoxvjG5W.js";
4
4
  declare const isNonBlankRef: (value: unknown) => value is string;
5
5
  type FootnoteAnchor = {
6
6
  id: string;
@@ -1,2 +1,2 @@
1
- import { C as InkViewState, D as InkPassageSvgSuggestion, E as InkPassageSvgOptions, S as InkTool, T as InkPassageSvg, _ as InkRoundRecord, a as InkDigitizedMeta, b as InkSample, c as InkLine, d as InkMarkBlock, f as InkMarkInput, g as InkPassageWord, h as InkPassageMark, i as InkCopyPlace, l as InkMargin, m as InkPassageCluster, n as InkBrush, o as InkDigitizedMode, p as InkPassage, r as InkCopy, s as InkDirection, t as BaseInkPlugin, u as InkMark, v as InkRoundStatus, w as renderInkPassageSvg, x as InkSubmitRoundOptions, y as InkRun } from "../../index-D3bhjdRz.js";
1
+ import { C as InkViewState, D as InkPassageSvgSuggestion, E as InkPassageSvgOptions, S as InkTool, T as InkPassageSvg, _ as InkRoundRecord, a as InkDigitizedMeta, b as InkSample, c as InkLine, d as InkMarkBlock, f as InkMarkInput, g as InkPassageWord, h as InkPassageMark, i as InkCopyPlace, l as InkMargin, m as InkPassageCluster, n as InkBrush, o as InkDigitizedMode, p as InkPassage, r as InkCopy, s as InkDirection, t as BaseInkPlugin, u as InkMark, v as InkRoundStatus, w as renderInkPassageSvg, x as InkSubmitRoundOptions, y as InkRun } from "../../index-lgeYbG68.js";
2
2
  export { BaseInkPlugin, InkBrush, InkCopy, InkCopyPlace, InkDigitizedMeta, InkDigitizedMode, InkDirection, InkLine, InkMargin, InkMark, InkMarkBlock, InkMarkInput, InkPassage, InkPassageCluster, InkPassageMark, type InkPassageSvg, type InkPassageSvgOptions, type InkPassageSvgSuggestion, InkPassageWord, InkRoundRecord, InkRoundStatus, InkRun, InkSample, InkSubmitRoundOptions, InkTool, InkViewState, renderInkPassageSvg };
@@ -1,5 +1,5 @@
1
1
  import { definePlugin } from "../../../lib/plugin/definePlugin.js";
2
- import { decideUrl, encodeUrlInput, isStoredUrl } from "../../../internal/utils/urlPolicy.js";
2
+ import { decideUrl, encodeSafeUrlInput, isStoredUrl } from "../../../internal/utils/urlPolicy.js";
3
3
  import { rangeHasVetoedMark } from "../../../lib/plugins/input-rules/inputRuleVeto.internal.js";
4
4
  import { defineInputRule } from "../../../lib/plugins/input-rules/defineInputRule.js";
5
5
  import { isDefined } from "../../../lib/utils/isDefined.js";
@@ -130,7 +130,10 @@ const getLinkHref = (url, { allowedSchemes = DEFAULT_ALLOWED_SCHEMES } = {}) =>
130
130
  const decision = decideUrl("navigation", url, { allowedSchemes });
131
131
  return decision.ok ? decision.url : void 0;
132
132
  };
133
- const admitLinkInput = (allowedSchemes, input) => getLinkHref(encodeUrlInput(input), { allowedSchemes });
133
+ const admitLinkInput = (allowedSchemes, input) => {
134
+ const encoded = encodeSafeUrlInput(input);
135
+ return encoded === void 0 ? void 0 : getLinkHref(encoded, { allowedSchemes });
136
+ };
134
137
  const defaultParseUrl = (text) => {
135
138
  if (WWW_TOKEN.test(text)) {
136
139
  const candidate = `https://${text}`;
@@ -1,6 +1,6 @@
1
- import { $o as Range, Vl as TxDeclaredMethod, gi as Element$1 } from "../../tx-only-CWT-IURY-BqIFhy44.js";
2
- import "../../htmlTypes-CNhoCFjK.js";
3
- import { o as Editor, p as BasePlugin } from "../../core-CTB0OBoh.js";
1
+ import { $o as Range, Vl as TxDeclaredMethod, gi as Element$1 } from "../../tx-only-x32UA-pQ-OQbgWQrN.js";
2
+ import "../../htmlTypes-9HQ8p7c5.js";
3
+ import { o as Editor, p as BasePlugin } from "../../core-DoxvjG5W.js";
4
4
  /** A replacement option on a finding, with an optional UI button label. */
5
5
  type LintFix = Readonly<{
6
6
  label?: string;
@@ -95,10 +95,15 @@ const handleListDeleteBackward = (editor, { direction, next, state }) => {
95
95
  const blockKey = state.key(nodeEntry[0]);
96
96
  if (!blockKey) return next();
97
97
  const blockStart = state.points.start(blockKey);
98
- if (!(state.points.isStart(selection.anchor, blockKey) || !!blockStart && state.text.string({
98
+ const beforeCaret = blockStart ? {
99
99
  anchor: blockStart,
100
100
  focus: selection.anchor
101
- }) === "")) return next();
101
+ } : void 0;
102
+ if (!(state.points.isStart(selection.anchor, blockKey) || !!beforeCaret && state.text.string(beforeCaret) === "" && state.nodes.entries({
103
+ at: beforeCaret,
104
+ match: (node) => ElementApi.isElement(node) && state.schema.isInline(node) && (state.schema.isVoid(node) || state.schema.isAtom(node) || state.schema.isObject(node)),
105
+ voids: true
106
+ }).next().done === true)) return next();
102
107
  if (hasNonWritableBlock(editor, nodeEntry[1], root)) return next();
103
108
  const [family] = getListFamilies(state, [nodeEntry], root);
104
109
  if (family?.some(({ path }) => hasNonWritableBlock(editor, path, root))) return false;
@@ -1,2 +1,2 @@
1
- import { a as LockWriteExemptionInput, i as LockWriteExemption, n as LockRefusal, o as isLockRefusal, r as LockTargetOptions, s as lockWriteExemption, t as BaseLockPlugin } from "../../index-Bqva6PJc.js";
1
+ import { a as LockWriteExemptionInput, i as LockWriteExemption, n as LockRefusal, o as isLockRefusal, r as LockTargetOptions, s as lockWriteExemption, t as BaseLockPlugin } from "../../index-CXJwwbAJ.js";
2
2
  export { BaseLockPlugin, LockRefusal, LockTargetOptions, LockWriteExemption, LockWriteExemptionInput, isLockRefusal, lockWriteExemption };
@@ -1,2 +1,2 @@
1
- import { S as VideoElement, _ as FileInsertInput, a as parseMediaEmbedUrl, b as MediaPluginState, c as BaseImagePlugin, d as AlignedMediaInsertInput, f as AudioElement, g as FileElement, h as BaseVideoPlugin, i as MediaEmbedRules, l as ImageElement, m as BaseFilePlugin, n as MediaEmbedElement, o as MediaEmbedProvider, p as BaseAudioPlugin, r as MediaEmbedPluginState, s as ParsedMediaEmbed, t as BaseMediaEmbedPlugin, u as ImageRules, v as ImageInsertInput, x as ProviderMediaInsertInput, y as MediaInsertInput } from "../../index-B4aToRMv.js";
1
+ import { S as VideoElement, _ as FileInsertInput, a as parseMediaEmbedUrl, b as MediaPluginState, c as BaseImagePlugin, d as AlignedMediaInsertInput, f as AudioElement, g as FileElement, h as BaseVideoPlugin, i as MediaEmbedRules, l as ImageElement, m as BaseFilePlugin, n as MediaEmbedElement, o as MediaEmbedProvider, p as BaseAudioPlugin, r as MediaEmbedPluginState, s as ParsedMediaEmbed, t as BaseMediaEmbedPlugin, u as ImageRules, v as ImageInsertInput, x as ProviderMediaInsertInput, y as MediaInsertInput } from "../../index-CAFKQNqu.js";
2
2
  export { AlignedMediaInsertInput, AudioElement, BaseAudioPlugin, BaseFilePlugin, BaseImagePlugin, BaseMediaEmbedPlugin, BaseVideoPlugin, FileElement, FileInsertInput, ImageElement, ImageInsertInput, ImageRules, MediaEmbedElement, MediaEmbedPluginState, type MediaEmbedProvider, MediaEmbedRules, MediaInsertInput, MediaPluginState, type ParsedMediaEmbed, ProviderMediaInsertInput, VideoElement, parseMediaEmbedUrl };
@@ -1,2 +1,2 @@
1
- import { i as MentionInsertOptions, n as MentionDefinition, r as MentionElement, t as BaseMentionPlugin } from "../../index-BfJKfAwk.js";
1
+ import { i as MentionInsertOptions, n as MentionDefinition, r as MentionElement, t as BaseMentionPlugin } from "../../index-eWzk-bcU.js";
2
2
  export { BaseMentionPlugin, MentionDefinition, MentionElement, MentionInsertOptions };
@@ -0,0 +1,240 @@
1
+ import { Vl as TxDeclaredMethod, Wa as Path, _t as EditorDocumentValue, qo as PropertyStringDescriptor, wi as ElementOf } from "../../tx-only-x32UA-pQ-OQbgWQrN.js";
2
+ import "../../htmlTypes-9HQ8p7c5.js";
3
+ import { Ra as DefinitionOf, p as BasePlugin, vt as NodeInsertOptions } from "../../core-DoxvjG5W.js";
4
+ declare const isValidReferenceString: (value: unknown) => value is string;
5
+ /** Input payload for inserting an inline cross-document reference or citation. */
6
+ type ReferenceInsertInput = Readonly<{
7
+ /** Explicit display override that remains stable when the target document is renamed. */
8
+ alias?: string;
9
+ /** Optional target block or clause element ID inside the target document. */
10
+ blockId?: string;
11
+ /** Offline and export fallback title snapshot; yields to live target title on rename. */
12
+ label?: string;
13
+ /** Optional pinned verbatim quote used for citation drift detection. */
14
+ quote?: string;
15
+ /** Stable target document or source identifier. */
16
+ ref: string;
17
+ /** Optional opaque app or content revision token pinned alongside the citation. */
18
+ revision?: string;
19
+ /** Optional target named root for whole-tab references. */
20
+ root?: string;
21
+ }>;
22
+ /** Options for inserting a reference node through `BaseReferencePlugin`. */
23
+ type ReferenceInsertOptions = NodeInsertOptions & {
24
+ /**
25
+ * Insert a trailing space when inserting at the current selection at the end
26
+ * of a block.
27
+ */
28
+ trailingSpace?: boolean;
29
+ };
30
+ /** Extracted outgoing reference occurrence from a detached `EditorDocumentValue`. */
31
+ type ExtractedDocumentReference = Readonly<{
32
+ /** Explicit display override when authored on the node. */
33
+ alias?: string;
34
+ /** Target block element ID when pinned to a specific block or clause. */
35
+ blockId?: string;
36
+ /** Fallback display title snapshot stored on the node. */
37
+ label?: string;
38
+ /** Path of the reference node within `sourceRoot`. */
39
+ path: Path;
40
+ /** Pinned verbatim quote when present on the node. */
41
+ quote?: string;
42
+ /** Stable target document or source identifier. */
43
+ ref: string;
44
+ /** Opaque pinned revision token when present on the node. */
45
+ revision?: string;
46
+ /** Target named root when addressing a whole tab. */
47
+ root?: string;
48
+ /** Persisted ID of the enclosing block containing this reference, if present. */
49
+ sourceBlockId?: string;
50
+ /** Root name (`'main'` or named root) where this reference occurs. */
51
+ sourceRoot: string;
52
+ }>;
53
+ /** Options for `extractDocumentReferences`. */
54
+ type ExtractDocumentReferencesOptions = Readonly<{
55
+ /** Include references inside authored-deleted nodes when `true`. Defaults to `false`. */
56
+ includeDeleted?: boolean;
57
+ /** Additional custom inline element types to treat as inline when resolving enclosing blocks. */
58
+ inlineTypes?: Iterable<string>;
59
+ /** Custom persisted element type name when `BaseReferencePlugin` was configured with a different type. */
60
+ type?: string;
61
+ }>;
62
+ /** Resolved target document or text input passed to `evaluateReferenceDrift`. */
63
+ type ReferenceDriftTarget = Readonly<{
64
+ /** Target document value (accepted or viewer-redacted). */
65
+ document?: EditorDocumentValue;
66
+ /** Additional custom inline element types to treat as inline when extracting target block text. */
67
+ inlineTypes?: Iterable<string>;
68
+ /** Pre-extracted visible target text; overrides text extraction from `document` when provided. */
69
+ liveText?: string;
70
+ /** Set `true` when redaction hid part of the target so drift cannot be truthfully asserted. */
71
+ partialVisibility?: boolean;
72
+ /** Current opaque app or content revision token of the target. */
73
+ revision?: string;
74
+ }>;
75
+ /** Discriminated drift evaluation result returned by `evaluateReferenceDrift`. */
76
+ type ReferenceDriftResult = Readonly<{
77
+ status: 'unpinned';
78
+ }> | Readonly<{
79
+ status: 'unavailable';
80
+ }> | Readonly<{
81
+ status: 'unverifiable';
82
+ }> | Readonly<{
83
+ currentRevision?: string;
84
+ liveText?: string;
85
+ status: 'current';
86
+ }> | Readonly<{
87
+ currentRevision?: string;
88
+ liveText?: string;
89
+ pinnedQuote?: string;
90
+ pinnedRevision?: string;
91
+ reanchoredBlockId?: string;
92
+ reason: 'quote-changed' | 'revision-changed' | 'target-not-found';
93
+ status: 'drifted';
94
+ }>;
95
+ /**
96
+ * Stateless inline markable-void primitive unifying rename-safe wikilinks,
97
+ * block references, hover-transclusion anchors, and version-pinned citations.
98
+ */
99
+ declare const BaseReferencePlugin: BasePlugin<Readonly<{
100
+ formats: true;
101
+ }> & Readonly<{
102
+ name: "reference";
103
+ }> & Readonly<Record<never, never>> & Readonly<{
104
+ update: {
105
+ readonly insert: TxDeclaredMethod<(input: ReferenceInsertInput, options?: ReferenceInsertOptions) => void>;
106
+ };
107
+ }> & Readonly<{
108
+ __pluginWritableProperties: Readonly<{
109
+ descriptor: PropertyStringDescriptor<{
110
+ readonly validate: typeof isValidReferenceString;
111
+ readonly validationVersion: 1;
112
+ }>;
113
+ key: "alias";
114
+ localId: "alias";
115
+ ownerName: "reference";
116
+ placement: "element";
117
+ unaliased: true;
118
+ value: string;
119
+ }> | Readonly<{
120
+ descriptor: PropertyStringDescriptor<{
121
+ readonly validate: typeof isValidReferenceString;
122
+ readonly validationVersion: 1;
123
+ }>;
124
+ key: "blockId";
125
+ localId: "blockId";
126
+ ownerName: "reference";
127
+ placement: "element";
128
+ unaliased: true;
129
+ value: string;
130
+ }> | Readonly<{
131
+ descriptor: PropertyStringDescriptor<{
132
+ readonly validate: typeof isValidReferenceString;
133
+ readonly validationVersion: 1;
134
+ }>;
135
+ key: "label";
136
+ localId: "label";
137
+ ownerName: "reference";
138
+ placement: "element";
139
+ unaliased: true;
140
+ value: string;
141
+ }> | Readonly<{
142
+ descriptor: PropertyStringDescriptor<{
143
+ readonly validate: typeof isValidReferenceString;
144
+ readonly validationVersion: 1;
145
+ }>;
146
+ key: "quote";
147
+ localId: "quote";
148
+ ownerName: "reference";
149
+ placement: "element";
150
+ unaliased: true;
151
+ value: string;
152
+ }> | Readonly<{
153
+ descriptor: PropertyStringDescriptor<{
154
+ readonly required: true;
155
+ readonly validate: typeof isValidReferenceString;
156
+ readonly validationVersion: 1;
157
+ }>;
158
+ key: "ref";
159
+ localId: "ref";
160
+ ownerName: "reference";
161
+ placement: "element";
162
+ unaliased: true;
163
+ value: string;
164
+ }> | Readonly<{
165
+ descriptor: PropertyStringDescriptor<{
166
+ readonly validate: typeof isValidReferenceString;
167
+ readonly validationVersion: 1;
168
+ }>;
169
+ key: "revision";
170
+ localId: "revision";
171
+ ownerName: "reference";
172
+ placement: "element";
173
+ unaliased: true;
174
+ value: string;
175
+ }> | Readonly<{
176
+ descriptor: PropertyStringDescriptor<{
177
+ readonly validate: typeof isValidReferenceString;
178
+ readonly validationVersion: 1;
179
+ }>;
180
+ key: "root";
181
+ localId: "root";
182
+ ownerName: "reference";
183
+ placement: "element";
184
+ unaliased: true;
185
+ value: string;
186
+ }>;
187
+ schema: {
188
+ readonly element: {
189
+ readonly properties: {
190
+ alias: PropertyStringDescriptor<{
191
+ readonly validate: typeof isValidReferenceString;
192
+ readonly validationVersion: 1;
193
+ }>;
194
+ blockId: PropertyStringDescriptor<{
195
+ readonly validate: typeof isValidReferenceString;
196
+ readonly validationVersion: 1;
197
+ }>;
198
+ label: PropertyStringDescriptor<{
199
+ readonly validate: typeof isValidReferenceString;
200
+ readonly validationVersion: 1;
201
+ }>;
202
+ quote: PropertyStringDescriptor<{
203
+ readonly validate: typeof isValidReferenceString;
204
+ readonly validationVersion: 1;
205
+ }>;
206
+ ref: PropertyStringDescriptor<{
207
+ readonly required: true;
208
+ readonly validate: typeof isValidReferenceString;
209
+ readonly validationVersion: 1;
210
+ }>;
211
+ revision: PropertyStringDescriptor<{
212
+ readonly validate: typeof isValidReferenceString;
213
+ readonly validationVersion: 1;
214
+ }>;
215
+ root: PropertyStringDescriptor<{
216
+ readonly validate: typeof isValidReferenceString;
217
+ readonly validationVersion: 1;
218
+ }>;
219
+ };
220
+ readonly void: "markable-inline";
221
+ };
222
+ };
223
+ }>>;
224
+ /** Inferred definition type of `BaseReferencePlugin`. */
225
+ type ReferenceDefinition = DefinitionOf<typeof BaseReferencePlugin>;
226
+ /** Inferred element node type produced by `BaseReferencePlugin`. */
227
+ type ReferenceElement = ElementOf<typeof BaseReferencePlugin>;
228
+ /**
229
+ * Extract all outgoing reference occurrences across `main` and all named `roots`
230
+ * of a detached `EditorDocumentValue` without constructing an editor.
231
+ */
232
+ declare function extractDocumentReferences(document: EditorDocumentValue, options?: ExtractDocumentReferencesOptions): readonly ExtractedDocumentReference[];
233
+ /**
234
+ * Evaluate whether a pinned reference or citation has drifted from its target.
235
+ *
236
+ * When `quote` is present, quote matching always runs even if `revision` equals
237
+ * `target.revision`, preventing silent drift or spoofed revision tokens.
238
+ */
239
+ declare function evaluateReferenceDrift(reference: Pick<ReferenceInsertInput, 'blockId' | 'quote' | 'ref' | 'revision' | 'root'>, target: ReferenceDriftTarget | null): ReferenceDriftResult;
240
+ export { BaseReferencePlugin, ExtractDocumentReferencesOptions, ExtractedDocumentReference, ReferenceDefinition, ReferenceDriftResult, ReferenceDriftTarget, ReferenceElement, ReferenceInsertInput, ReferenceInsertOptions, evaluateReferenceDrift, extractDocumentReferences };
@@ -0,0 +1,2 @@
1
+ import { BaseReferencePlugin, evaluateReferenceDrift, extractDocumentReferences } from "./lib/BaseReferencePlugin.js";
2
+ export { BaseReferencePlugin, evaluateReferenceDrift, extractDocumentReferences };