platejs 54.0.0-beta.4 → 54.0.0-beta.5

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 (117) hide show
  1. package/dist/{AIChatRequestContext-DrUahdTc.d.ts → AIChatRequestContext-CwCmEMVV.d.ts} +2 -2
  2. package/dist/{BaseSuggestionPlugin-_7Ka6nY3.d.ts → BaseSuggestionPlugin-CpVkv7k2.d.ts} +4 -4
  3. package/dist/{PlateStatic-D3Cb-QwH.d.ts → PlateStatic-C7FfXu-Z.d.ts} +3 -3
  4. package/dist/ai/index.d.ts +1 -1
  5. package/dist/ai/react/index.d.ts +9 -9
  6. package/dist/authored/index.d.ts +3 -3
  7. package/dist/code-block/codemirror/index.d.ts +1 -1
  8. package/dist/{combobox-Dr0OYZIE.d.ts → combobox-BhhymlUs.d.ts} +2 -2
  9. package/dist/{comparison-types-DdwE6mYq-BogsHoUO.d.ts → comparison-types-Bvvxzxq2-08gzpgF6.d.ts} +1 -1
  10. package/dist/compiler/index.d.ts +2 -2
  11. package/dist/{core-BqR-fEDp.d.ts → core-Bu--Bog3.d.ts} +4 -4
  12. package/dist/diff/index.d.ts +2 -2
  13. package/dist/docs/api/dom.md +5 -3
  14. package/dist/docs/field.md +138 -20
  15. package/dist/docs/link.md +1 -1
  16. package/dist/docs/llms.txt +1 -1
  17. package/dist/docs/media.md +88 -2
  18. package/dist/docs/plugin-input-rules.md +4 -3
  19. package/dist/docs/roots.md +16 -10
  20. package/dist/docx/export/index.d.ts +3 -3
  21. package/dist/docx/import/index.d.ts +4 -4
  22. package/dist/docx/paste/index.d.ts +4 -4
  23. package/dist/dom/index.d.ts +1 -1
  24. package/dist/excalidraw/index.d.ts +3 -3
  25. package/dist/excalidraw/react/index.d.ts +3 -3
  26. package/dist/facade.js +2 -2
  27. package/dist/features/board/index.d.ts +1 -1
  28. package/dist/features/callout/index.d.ts +3 -3
  29. package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -18
  30. package/dist/features/combobox/index.d.ts +2 -2
  31. package/dist/features/comments/BaseCommentsPlugin.js +6 -2
  32. package/dist/features/comments/index.d.ts +1 -1
  33. package/dist/features/date/index.d.ts +3 -3
  34. package/dist/features/details/index.d.ts +3 -3
  35. package/dist/features/field/index.d.ts +2 -2
  36. package/dist/features/field/index.js +2 -2
  37. package/dist/features/field/lib/BaseFieldPlugin.js +2 -2
  38. package/dist/features/field/lib/applyFieldValues.js +2 -2
  39. package/dist/features/field/lib/fieldRules.internal.js +9 -4
  40. package/dist/features/find/index.d.ts +3 -3
  41. package/dist/features/footnote/index.d.ts +1 -1
  42. package/dist/features/ink/index.d.ts +1 -1
  43. package/dist/features/layout/index.d.ts +1 -1
  44. package/dist/features/lint/index.d.ts +3 -3
  45. package/dist/features/media/index.d.ts +1 -1
  46. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +1 -1
  47. package/dist/features/mention/index.d.ts +5 -5
  48. package/dist/features/suggestion/index.d.ts +1 -1
  49. package/dist/features/table/index.d.ts +1 -1
  50. package/dist/features/toc/index.d.ts +1 -1
  51. package/dist/features/upload/index.d.ts +1 -1
  52. package/dist/history/index.d.ts +2 -2
  53. package/dist/html/index.d.ts +3 -3
  54. package/dist/html/server/index.d.ts +1 -1
  55. package/dist/{htmlTypes-eT2ZGDAj.d.ts → htmlTypes-aE9Qlenu.d.ts} +1 -1
  56. package/dist/hyperscript/index.d.ts +1 -1
  57. package/dist/{index-DYdObeFQ.d.ts → index-BR2S-6Js.d.ts} +3 -3
  58. package/dist/{index-BkwR-5hH.d.ts → index-BT1-fX5o.d.ts} +3 -3
  59. package/dist/{index-BsV2McRr.d.ts → index-BXs4598V.d.ts} +5 -5
  60. package/dist/{index-BXwU9QH6.d.ts → index-BYAqyTSY.d.ts} +2 -2
  61. package/dist/{index-DwWQVwQt.d.ts → index-Be_YFFLS.d.ts} +3 -3
  62. package/dist/{index-B8QJDAmG.d.ts → index-Bf6EwY5O.d.ts} +2 -2
  63. package/dist/{index-Dq3Jlj8O-BJ6NxZm0.d.ts → index-BwmXxqbi-COlJb0HZ.d.ts} +1 -1
  64. package/dist/{index-BTx5oK7k.d.ts → index-C9WSACSv.d.ts} +1 -1
  65. package/dist/{index-B33E1CRJ.d.ts → index-CGUt4h_4.d.ts} +3 -3
  66. package/dist/{index-BWPcE4ac-Cto_IsNs.d.ts → index-CRmyGzS8-BTrk6JzL.d.ts} +1 -1
  67. package/dist/{index-DNQXzU-X.d.ts → index-CTwrWir_.d.ts} +1 -1
  68. package/dist/{index-M781pyx9.d.ts → index-CYR4jNU7.d.ts} +4 -4
  69. package/dist/{index-C9Fu-P4E.d.ts → index-CbcYN_S_.d.ts} +10 -4
  70. package/dist/{index-Cob_iBdu.d.ts → index-CeVE8JR-.d.ts} +3 -3
  71. package/dist/{index-CpY7Xnxw.d.ts → index-DFvzP8N_.d.ts} +4 -4
  72. package/dist/{index-Ca48r1ng.d.ts → index-DgVsTFYL.d.ts} +3 -3
  73. package/dist/{index-DPowErHa.d.ts → index-DhVOU0pS.d.ts} +22 -15
  74. package/dist/{index-B7moSod7.d.ts → index-DhurStYU.d.ts} +1 -1
  75. package/dist/{index-DShbzec2.d.ts → index-DlBey0zf.d.ts} +6 -3
  76. package/dist/{index-B8-5Sr7I.d.ts → index-DqKFQcfb.d.ts} +2 -2
  77. package/dist/{index-d7io3MzC.d.ts → index-DqpzKYwP.d.ts} +3 -3
  78. package/dist/{index-JWgwL5l3.d.ts → index-dpi2ErEe.d.ts} +3 -3
  79. package/dist/index.d.ts +3 -3
  80. package/dist/internal/utils/vscodeClipboard.js +11 -0
  81. package/dist/markdown/index.d.ts +1 -1
  82. package/dist/markdown/lib/MarkdownPlugin.js +2 -1
  83. package/dist/math/index.d.ts +3 -3
  84. package/dist/math/react/index.d.ts +4 -4
  85. package/dist/migrations/index.d.ts +3 -3
  86. package/dist/pagination/index.d.ts +1 -1
  87. package/dist/pagination/react/index.d.ts +2 -2
  88. package/dist/react/features/board/index.d.ts +5 -5
  89. package/dist/react/features/callout/index.d.ts +3 -3
  90. package/dist/react/features/combobox/index.d.ts +5 -5
  91. package/dist/react/features/comments/index.d.ts +6 -6
  92. package/dist/react/features/date/index.d.ts +4 -4
  93. package/dist/react/features/details/index.d.ts +4 -4
  94. package/dist/react/features/field/index.d.ts +5 -5
  95. package/dist/react/features/footnote/index.d.ts +7 -7
  96. package/dist/react/features/format-painter/index.d.ts +4 -4
  97. package/dist/react/features/ink/InkContent.js +13 -0
  98. package/dist/react/features/ink/index.d.ts +5 -5
  99. package/dist/react/features/ink/inkPaint.internal.js +4 -1
  100. package/dist/react/features/layout/index.d.ts +5 -5
  101. package/dist/react/features/media/index.d.ts +5 -5
  102. package/dist/react/features/mention/index.d.ts +6 -6
  103. package/dist/react/features/suggestion/index.d.ts +6 -6
  104. package/dist/react/features/table/index.d.ts +5 -5
  105. package/dist/react/features/toc/index.d.ts +2 -2
  106. package/dist/react/features/upload/index.d.ts +5 -5
  107. package/dist/react/index.d.ts +5 -5
  108. package/dist/react/virtualized.d.ts +2 -2
  109. package/dist/{source-BGohy8vH.d.ts → source-GMnTi_Vr.d.ts} +3 -3
  110. package/dist/static/index.d.ts +5 -5
  111. package/dist/tabbable/index.d.ts +1 -1
  112. package/dist/tabbable/react/index.d.ts +3 -3
  113. package/dist/testing/index.d.ts +2 -2
  114. package/dist/yjs/index.d.ts +1 -1
  115. package/dist/yjs/react/index.d.ts +5 -5
  116. package/package.json +2 -2
  117. /package/dist/{index-BXjLmx1n-CXk17buG.d.ts → index-QuqD4Dyj-DlOIX0sH.d.ts} +0 -0
@@ -1,5 +1,5 @@
1
- import { $a as Path, Fc as Selection, La as NodeSelectionMode, ps as Range, su as Value } from "./index-BXjLmx1n-CXk17buG.js";
2
- import "./core-BqR-fEDp.js";
1
+ import { $a as Path, Fc as Selection, La as NodeSelectionMode, ps as Range, su as Value } from "./index-QuqD4Dyj-DlOIX0sH.js";
2
+ import "./core-Bu--Bog3.js";
3
3
  type AIToolName = 'comment' | 'edit' | 'generate' | null;
4
4
  /** Request-local reference into `AIChatRequestContext.children`. */
5
5
  type AIChatRequestNodeRef = Readonly<{
@@ -1,7 +1,7 @@
1
- import { Ca as NodeKey, Ji as Location, iu as TxDeclaredMethod, oo as Plugin, ou as TxOnlyMethod } from "./index-BXjLmx1n-CXk17buG.js";
2
- import "./htmlTypes-eT2ZGDAj.js";
3
- import { Co as PluginReference, V as InternalBasePluginRuntimeExtension, _ as BasePlugin, aa as BasePluginDependencyReferenceFor, xo as PluginDependency } from "./core-BqR-fEDp.js";
4
- import { S as AuthoredView, _ as AuthoredPlugin, b as AuthoredResult, c as AuthoredDecision, h as AuthoredPage, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, r as AuthoredChangeGroup, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, x as AuthoredReview, y as AuthoredRefusal } from "./index-B8-5Sr7I.js";
1
+ import { Ca as NodeKey, Ji as Location, iu as TxDeclaredMethod, oo as Plugin, ou as TxOnlyMethod } from "./index-QuqD4Dyj-DlOIX0sH.js";
2
+ import "./htmlTypes-aE9Qlenu.js";
3
+ import { Co as PluginReference, V as InternalBasePluginRuntimeExtension, _ as BasePlugin, aa as BasePluginDependencyReferenceFor, xo as PluginDependency } from "./core-Bu--Bog3.js";
4
+ import { S as AuthoredView, _ as AuthoredPlugin, b as AuthoredResult, c as AuthoredDecision, h as AuthoredPage, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, r as AuthoredChangeGroup, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, x as AuthoredReview, y as AuthoredRefusal } from "./index-DqKFQcfb.js";
5
5
  /** Paints each node's pending authored changes as `data-editor-authored-*` attributes. */
6
6
  declare const BaseSuggestionPlugin: BasePlugin<Readonly<{
7
7
  inject: true;
@@ -1,6 +1,6 @@
1
- import { Tt as EditorDocumentValue } from "./index-BXjLmx1n-CXk17buG.js";
2
- import "./htmlTypes-eT2ZGDAj.js";
3
- import { u as Editor } from "./core-BqR-fEDp.js";
1
+ import { Tt as EditorDocumentValue } from "./index-QuqD4Dyj-DlOIX0sH.js";
2
+ import "./htmlTypes-aE9Qlenu.js";
3
+ import { u as Editor } from "./core-Bu--Bog3.js";
4
4
  import React$1 from "react";
5
5
  type EditorStaticProps<E = Editor> = {
6
6
  /**
@@ -1,2 +1,2 @@
1
- import { a as AIToolName, i as AIChatRequestRefs, n as AIChatRequestNodeRef, o as resolveAIChatRequestContext, r as AIChatRequestNodeSelection, t as AIChatRequestContext } from "../AIChatRequestContext-DrUahdTc.js";
1
+ import { a as AIToolName, i as AIChatRequestRefs, n as AIChatRequestNodeRef, o as resolveAIChatRequestContext, r as AIChatRequestNodeSelection, t as AIChatRequestContext } from "../AIChatRequestContext-CwCmEMVV.js";
2
2
  export { AIChatRequestContext, AIChatRequestNodeRef, AIChatRequestNodeSelection, AIChatRequestRefs, AIToolName, resolveAIChatRequestContext };
@@ -1,12 +1,12 @@
1
- import { $a as Path, Ca as NodeKey, Ci as Element, Fo as PluginReference, Ji as Location, La as NodeSelectionMode, Pi as HistoryApi, aa as Node, b as BasePoint, dn as EditorReadMethodTree, iu as TxDeclaredMethod, oo as Plugin, ou as TxOnlyMethod, pa as NodeEntry, ps as Range, su as Value, tn as EditorNodesOptions, v as BaseElement, zo as PluginTypeProvider } from "../../index-BXjLmx1n-CXk17buG.js";
2
- import "../../htmlTypes-eT2ZGDAj.js";
3
- import { Co as PluginReference$1, Eo as PluginSchemaDeclaration, V as InternalBasePluginRuntimeExtension, _ as BasePlugin, aa as BasePluginDependencyReferenceFor, ea as HistoryPluginState, qa as DefinitionOf, xo as PluginDependency } from "../../core-BqR-fEDp.js";
4
- import { c as HistoryPluginTypeProvider, d as HistoryTxApi, n as History, u as HistoryStateApi } from "../../index-DNQXzU-X.js";
5
- import { a as AIToolName } from "../../AIChatRequestContext-DrUahdTc.js";
6
- import { At as Plugin$1, n as InternalReactEditorWithInstalledPlugins, t as Editor, xt as InternalPluginAuthorExtension } from "../../index-DPowErHa.js";
7
- import { O as MarkdownSyncPlugin, d as Unsafe, i as MarkdownEditor, l as Handle, n as MarkdownApi, u as Join } from "../../index-Cob_iBdu.js";
8
- import { S as AuthoredView, _ as AuthoredPlugin, b as AuthoredResult, c as AuthoredDecision, h as AuthoredPage, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, r as AuthoredChangeGroup, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, x as AuthoredReview, y as AuthoredRefusal } from "../../index-B8-5Sr7I.js";
9
- import "../../index-M781pyx9.js";
1
+ import { $a as Path, Ca as NodeKey, Ci as Element, Fo as PluginReference, Ji as Location, La as NodeSelectionMode, Pi as HistoryApi, aa as Node, b as BasePoint, dn as EditorReadMethodTree, iu as TxDeclaredMethod, oo as Plugin, ou as TxOnlyMethod, pa as NodeEntry, ps as Range, su as Value, tn as EditorNodesOptions, v as BaseElement, zo as PluginTypeProvider } from "../../index-QuqD4Dyj-DlOIX0sH.js";
2
+ import "../../htmlTypes-aE9Qlenu.js";
3
+ import { Co as PluginReference$1, Eo as PluginSchemaDeclaration, V as InternalBasePluginRuntimeExtension, _ as BasePlugin, aa as BasePluginDependencyReferenceFor, ea as HistoryPluginState, qa as DefinitionOf, xo as PluginDependency } from "../../core-Bu--Bog3.js";
4
+ import { c as HistoryPluginTypeProvider, d as HistoryTxApi, n as History, u as HistoryStateApi } from "../../index-CTwrWir_.js";
5
+ import { a as AIToolName } from "../../AIChatRequestContext-CwCmEMVV.js";
6
+ import { At as Plugin$1, n as InternalReactEditorWithInstalledPlugins, t as Editor, xt as InternalPluginAuthorExtension } from "../../index-DhVOU0pS.js";
7
+ import { O as MarkdownSyncPlugin, d as Unsafe, i as MarkdownEditor, l as Handle, n as MarkdownApi, u as Join } from "../../index-CeVE8JR-.js";
8
+ import { S as AuthoredView, _ as AuthoredPlugin, b as AuthoredResult, c as AuthoredDecision, h as AuthoredPage, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, r as AuthoredChangeGroup, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, x as AuthoredReview, y as AuthoredRefusal } from "../../index-DqKFQcfb.js";
9
+ import "../../index-CYR4jNU7.js";
10
10
  import * as React from "react";
11
11
  import React$1 from "react";
12
12
  import { ChatRequestOptions, ChatStatus, ChatTransport, DataUIPart, UIMessage } from "ai";
@@ -1,4 +1,4 @@
1
- import { h as AuthoredProjectionRefusal, m as AuthoredProjectionDiagnostic, p as AuthoredDocumentProjection } from "../index-BXjLmx1n-CXk17buG.js";
2
- import { C as projectAuthoredDocument, S as AuthoredView, T as proposeAuthoredComparison, a as AuthoredChangePart, b as AuthoredResult, c as AuthoredDecision, d as AuthoredGroupPart, f as AuthoredMark, g as AuthoredPlaceError, h as AuthoredPage, i as AuthoredChangeKind, l as AuthoredFormatProjection, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, p as AuthoredOptions, r as AuthoredChangeGroup, s as AuthoredComparisonImportResult, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, w as projectAuthoredRange, x as AuthoredReview, y as AuthoredRefusal } from "../index-B8-5Sr7I.js";
3
- import { t as AuthoredPlugin } from "../index-M781pyx9.js";
1
+ import { h as AuthoredProjectionRefusal, m as AuthoredProjectionDiagnostic, p as AuthoredDocumentProjection } from "../index-QuqD4Dyj-DlOIX0sH.js";
2
+ import { C as projectAuthoredDocument, S as AuthoredView, T as proposeAuthoredComparison, a as AuthoredChangePart, b as AuthoredResult, c as AuthoredDecision, d as AuthoredGroupPart, f as AuthoredMark, g as AuthoredPlaceError, h as AuthoredPage, i as AuthoredChangeKind, l as AuthoredFormatProjection, m as AuthoredOutcome, n as AuthoredChangeDetails, o as AuthoredChangesDelta, p as AuthoredOptions, r as AuthoredChangeGroup, s as AuthoredComparisonImportResult, t as AuthoredChange, u as AuthoredGroupDetails, v as AuthoredQuery, w as projectAuthoredRange, x as AuthoredReview, y as AuthoredRefusal } from "../index-DqKFQcfb.js";
3
+ import { t as AuthoredPlugin } from "../index-CYR4jNU7.js";
4
4
  export { type AuthoredChange, type AuthoredChangeDetails, type AuthoredChangeGroup, type AuthoredChangeKind, type AuthoredChangePart, type AuthoredChangesDelta, type AuthoredComparisonImportResult, type AuthoredDecision, type AuthoredDocumentProjection, type AuthoredFormatProjection, type AuthoredGroupDetails, type AuthoredGroupPart, type AuthoredMark, type AuthoredOptions, type AuthoredOutcome, type AuthoredPage, AuthoredPlaceError, AuthoredPlugin, type AuthoredProjectionDiagnostic, type AuthoredProjectionRefusal, type AuthoredQuery, type AuthoredRefusal, type AuthoredResult, type AuthoredReview, type AuthoredView, projectAuthoredDocument, projectAuthoredRange, proposeAuthoredComparison };
@@ -1,4 +1,4 @@
1
- import { Xn as ExternalTextAdapter } from "../../index-DPowErHa.js";
1
+ import { Xn as ExternalTextAdapter } from "../../index-DhVOU0pS.js";
2
2
  import { Extension } from "@codemirror/state";
3
3
  type CodeBlockCodeMirrorConfig = Readonly<{
4
4
  language?: string;
@@ -1,5 +1,5 @@
1
- import { vt as EditorCoreStateView } from "./index-BXjLmx1n-CXk17buG.js";
2
- import { u as Editor } from "./core-BqR-fEDp.js";
1
+ import { vt as EditorCoreStateView } from "./index-QuqD4Dyj-DlOIX0sH.js";
2
+ import { u as Editor } from "./core-Bu--Bog3.js";
3
3
  type ComboboxEditor = Pick<Editor, 'plugin'> & {
4
4
  read: Pick<EditorCoreStateView, 'nodes'>;
5
5
  };
@@ -1,4 +1,4 @@
1
- import { J as DocumentChange, Tt as EditorDocumentValue, su as Value, zn as EditorSchemaIdentity } from "./index-BXjLmx1n-CXk17buG.js";
1
+ import { J as DocumentChange, Tt as EditorDocumentValue, su as Value, zn as EditorSchemaIdentity } from "./index-QuqD4Dyj-DlOIX0sH.js";
2
2
  /** A comparison-local interval in the canonical document token coordinate. */
3
3
  type ComparisonSpan = Readonly<{
4
4
  from: number;
@@ -1,5 +1,5 @@
1
- import { h as EditorApplicationSchema } from "../htmlTypes-eT2ZGDAj.js";
2
- import { Xo as GeneratedEditorTypeProvider, st as BasePluginInput, tt as EditorCompilation, ut as EditorPropertyTypes } from "../core-BqR-fEDp.js";
1
+ import { h as EditorApplicationSchema } from "../htmlTypes-aE9Qlenu.js";
2
+ import { Xo as GeneratedEditorTypeProvider, st as BasePluginInput, tt as EditorCompilation, ut as EditorPropertyTypes } from "../core-Bu--Bog3.js";
3
3
  /**
4
4
  * Compile nominal plugins and optional application schema into immutable JSON data.
5
5
  * Evaluates configuration, API factories and validators without activating plugins
@@ -1,7 +1,7 @@
1
- import { $ as EditorBreakExitOptions, $a as Path, $n as EditorSchemaSourceProvider, $r as EditorTransactionSpecBuilder, $t as EditorNodeTypeProvider, Ac as SchemaTextPropertyOptions, Ba as NodeTarget, Bo as PluginTypeProviderOf, Bs as SchemaElementConstructionPropertiesFor, Bt as EditorInstalledUpdateGroups, Ca as NodeKey, Cc as SchemaTarget, Ci as Element, Da as NodeMatchPredicate, Dc as SchemaTextProperty, Di as ElementIdTarget, Dl as TextTarget, Dr as EditorStateViewProvider, Ds as SchemaContentDefault, Ea as NodeMatch, Ec as SchemaTextProperties, Es as SchemaContent, F as DecorationAttributes, Fl as TransferApi, Fo as PluginReference$1, Gs as SchemaElementPropertiesFor, Gt as EditorLifecycleErrorSink, H as Descendant, Ht as EditorJsonValue, I as DecorationRefresh, Ia as NodeSelection, Ji as Location, Jl as TransferRead, Jt as EditorNextOptions, K as DescendantIn, Ks as SchemaElementProperty, Ls as SchemaContentRule, Lt as EditorGenericMethod, Ma as NodeOf, Ms as SchemaContentRootContribution, Nl as TransactionSpec, Nn as EditorSchemaDerivedDefinition, Oc as SchemaTextPropertyDefinition, Oo as PluginPortal, P as Decoration, Pa as NodeRemoveNodesOptions, Pi as HistoryApi, Pn as EditorSchemaElement, Qo as PropertyBooleanDescriptor, Qt as EditorNodeGetOptions, R as DefinitionOf$1, Ra as NodeSetNodesOptions, Rr as EditorTransactionChangeContext, S as BaseText, St as EditorDirectUpdate, To as PluginInstalledCapabilitiesOf, Tr as EditorStateView, Tt as EditorDocumentValue, Un as EditorSchemaPlugin, Ut as EditorLevelsOptions, Wn as EditorSchemaPluginProvider, Wo as PluginWitnessFor, X as EditorAboveOptions, Y as Editor$1, Yt as EditorNodeChangeContext, Z as EditorBlockOptions, Zr as EditorTransactionSelectionApi, Zs as SchemaElementShapeFor, _o as PluginDefinitionInput, aa as Node$1, ac as SchemaKeyPrefix, au as TxMethodDeclarations, b as BasePoint, bi as EditorValueTypeProvider, bl as TextInsertFragmentOptions, bo as PluginDependencyReferenceFor, br as EditorStateSelectionApi, cc as SchemaProperty, ci as EditorUpdateMethods, cr as EditorSelectionBlockOptions, dl as Text$1, dn as EditorReadMethodTree, ds as PropertyValueOf, ea as MaximizeMode, en as EditorNodeUnsetOptions, es as PropertyEnumDescriptor, fc as SchemaPropertyHandle, fn as EditorReadMethods, fo as PluginCapabilities, fs as PropertyValueOptions, gi as EditorUpdateValueFromPlugin, go as PluginDefinition, hc as SchemaPropertyKey, hi as EditorUpdateTransactionProvider, in as EditorPreviousOptions, io as PersistedDocumentInput, is as PropertyOptionsOf, iu as TxDeclaredMethod, j as ContentSlice, jc as SchemaTypesTarget, ji as ElementOf, jr as EditorToggleBlockOptions, kn as EditorSchemaContribution, kr as EditorTextChangeContext, ks as SchemaContentOptions, li as EditorUpdatePolicy, ll as StructuralPlainTextDiagnostic, ls as PropertyValueDescriptor, lu as WithNodeTarget, m as AuthoredProjectionDiagnostic, mi as EditorUpdateTransactionOf, mo as PluginContribution, mt as EditorCommitContext, nn as EditorNodesReadOptions, oc as SchemaNodeTypeProvider, oo as Plugin, pa as NodeEntry, pi as EditorUpdateTransaction, ps as Range, qa as NodeTypeSelector, qi as LeafPosition, ql as TransferPlugin$1, qo as Point$1, qs as SchemaElementPropertyDefinition, rn as EditorParentOptions, rs as PropertyNumberDescriptor, sc as SchemaPluginsOf, si as EditorUpdateContext, sr as EditorSelection, ss as PropertyStringDescriptor, su as Value, tc as SchemaElementTypes, tn as EditorNodesOptions, ts as PropertyJsonDescriptor, uc as SchemaPropertyDefinition, un as EditorReadMethodRecord, v as BaseElement, va as NodeIn, vo as PluginDependencyContractReference, vt as EditorCoreStateView, w as BlockInsertOptions$1, wc as SchemaText, ws as RootKey, xl as TextInsertTextOptions, xn as EditorSchemaContract, ya as NodeInsertNodesOptions, yo as PluginDependencyReference, yr as EditorStateSchemaApi, zo as PluginTypeProvider, zs as SchemaElement } from "./index-BXjLmx1n-CXk17buG.js";
2
- import { a as HtmlEditorSerializeOptions, d as HtmlSerializeResult, f as HtmlSliceParseResult, h as EditorApplicationSchema, i as HtmlEditorParseOptions, r as HtmlDocumentParseResult, t as HtmlApi } from "./htmlTypes-eT2ZGDAj.js";
3
- import { E as DataTransferEncodeContext, I as ScrollIntoViewOptions, P as HotkeySpec, _ as DOMRange, i as DOMClipboardApi, m as DOMPlugin$1, r as DOMApi, w as DataTransferDecodeContext } from "./index-DShbzec2.js";
4
- import { d as HistoryTxApi, s as HistoryPlugin$1, u as HistoryStateApi } from "./index-DNQXzU-X.js";
1
+ import { $ as EditorBreakExitOptions, $a as Path, $n as EditorSchemaSourceProvider, $r as EditorTransactionSpecBuilder, $t as EditorNodeTypeProvider, Ac as SchemaTextPropertyOptions, Ba as NodeTarget, Bo as PluginTypeProviderOf, Bs as SchemaElementConstructionPropertiesFor, Bt as EditorInstalledUpdateGroups, Ca as NodeKey, Cc as SchemaTarget, Ci as Element, Da as NodeMatchPredicate, Dc as SchemaTextProperty, Di as ElementIdTarget, Dl as TextTarget, Dr as EditorStateViewProvider, Ds as SchemaContentDefault, Ea as NodeMatch, Ec as SchemaTextProperties, Es as SchemaContent, F as DecorationAttributes, Fl as TransferApi, Fo as PluginReference$1, Gs as SchemaElementPropertiesFor, Gt as EditorLifecycleErrorSink, H as Descendant, Ht as EditorJsonValue, I as DecorationRefresh, Ia as NodeSelection, Ji as Location, Jl as TransferRead, Jt as EditorNextOptions, K as DescendantIn, Ks as SchemaElementProperty, Ls as SchemaContentRule, Lt as EditorGenericMethod, Ma as NodeOf, Ms as SchemaContentRootContribution, Nl as TransactionSpec, Nn as EditorSchemaDerivedDefinition, Oc as SchemaTextPropertyDefinition, Oo as PluginPortal, P as Decoration, Pa as NodeRemoveNodesOptions, Pi as HistoryApi, Pn as EditorSchemaElement, Qo as PropertyBooleanDescriptor, Qt as EditorNodeGetOptions, R as DefinitionOf$1, Ra as NodeSetNodesOptions, Rr as EditorTransactionChangeContext, S as BaseText, St as EditorDirectUpdate, To as PluginInstalledCapabilitiesOf, Tr as EditorStateView, Tt as EditorDocumentValue, Un as EditorSchemaPlugin, Ut as EditorLevelsOptions, Wn as EditorSchemaPluginProvider, Wo as PluginWitnessFor, X as EditorAboveOptions, Y as Editor$1, Yt as EditorNodeChangeContext, Z as EditorBlockOptions, Zr as EditorTransactionSelectionApi, Zs as SchemaElementShapeFor, _o as PluginDefinitionInput, aa as Node$1, ac as SchemaKeyPrefix, au as TxMethodDeclarations, b as BasePoint, bi as EditorValueTypeProvider, bl as TextInsertFragmentOptions, bo as PluginDependencyReferenceFor, br as EditorStateSelectionApi, cc as SchemaProperty, ci as EditorUpdateMethods, cr as EditorSelectionBlockOptions, dl as Text$1, dn as EditorReadMethodTree, ds as PropertyValueOf, ea as MaximizeMode, en as EditorNodeUnsetOptions, es as PropertyEnumDescriptor, fc as SchemaPropertyHandle, fn as EditorReadMethods, fo as PluginCapabilities, fs as PropertyValueOptions, gi as EditorUpdateValueFromPlugin, go as PluginDefinition, hc as SchemaPropertyKey, hi as EditorUpdateTransactionProvider, in as EditorPreviousOptions, io as PersistedDocumentInput, is as PropertyOptionsOf, iu as TxDeclaredMethod, j as ContentSlice, jc as SchemaTypesTarget, ji as ElementOf, jr as EditorToggleBlockOptions, kn as EditorSchemaContribution, kr as EditorTextChangeContext, ks as SchemaContentOptions, li as EditorUpdatePolicy, ll as StructuralPlainTextDiagnostic, ls as PropertyValueDescriptor, lu as WithNodeTarget, m as AuthoredProjectionDiagnostic, mi as EditorUpdateTransactionOf, mo as PluginContribution, mt as EditorCommitContext, nn as EditorNodesReadOptions, oc as SchemaNodeTypeProvider, oo as Plugin, pa as NodeEntry, pi as EditorUpdateTransaction, ps as Range, qa as NodeTypeSelector, qi as LeafPosition, ql as TransferPlugin$1, qo as Point$1, qs as SchemaElementPropertyDefinition, rn as EditorParentOptions, rs as PropertyNumberDescriptor, sc as SchemaPluginsOf, si as EditorUpdateContext, sr as EditorSelection, ss as PropertyStringDescriptor, su as Value, tc as SchemaElementTypes, tn as EditorNodesOptions, ts as PropertyJsonDescriptor, uc as SchemaPropertyDefinition, un as EditorReadMethodRecord, v as BaseElement, va as NodeIn, vo as PluginDependencyContractReference, vt as EditorCoreStateView, w as BlockInsertOptions$1, wc as SchemaText, ws as RootKey, xl as TextInsertTextOptions, xn as EditorSchemaContract, ya as NodeInsertNodesOptions, yo as PluginDependencyReference, yr as EditorStateSchemaApi, zo as PluginTypeProvider, zs as SchemaElement } from "./index-QuqD4Dyj-DlOIX0sH.js";
2
+ import { a as HtmlEditorSerializeOptions, d as HtmlSerializeResult, f as HtmlSliceParseResult, h as EditorApplicationSchema, i as HtmlEditorParseOptions, r as HtmlDocumentParseResult, t as HtmlApi } from "./htmlTypes-aE9Qlenu.js";
3
+ import { E as DataTransferEncodeContext, I as ScrollIntoViewOptions, P as HotkeySpec, _ as DOMRange, i as DOMClipboardApi, m as DOMPlugin$1, r as DOMApi, w as DataTransferDecodeContext } from "./index-DlBey0zf.js";
4
+ import { d as HistoryTxApi, s as HistoryPlugin$1, u as HistoryStateApi } from "./index-CTwrWir_.js";
5
5
  import { Draft } from "mutative";
6
6
  import { nanoid as nanoid$1 } from "nanoid";
7
7
  import "zustand/vanilla";
@@ -1,5 +1,5 @@
1
- import { su as Value, yr as EditorStateSchemaApi } from "../index-BXjLmx1n-CXk17buG.js";
2
- import { a as ComparisonConflictAlternative, c as ComparisonEffect, d as ComparisonResolutionResult, f as ComparisonSnapshot, h as TwoWayComparison, i as ComparisonConflict, l as ComparisonEvidence, m as ThreeWayComparison, n as Comparison, o as ComparisonCorrespondence, p as ComparisonSpan, r as ComparisonBranch, s as ComparisonDiagnostic, t as ComparedChange, u as ComparisonResolution } from "../comparison-types-DdwE6mYq-BogsHoUO.js";
1
+ import { su as Value, yr as EditorStateSchemaApi } from "../index-QuqD4Dyj-DlOIX0sH.js";
2
+ import { a as ComparisonConflictAlternative, c as ComparisonEffect, d as ComparisonResolutionResult, f as ComparisonSnapshot, h as TwoWayComparison, i as ComparisonConflict, l as ComparisonEvidence, m as ThreeWayComparison, n as Comparison, o as ComparisonCorrespondence, p as ComparisonSpan, r as ComparisonBranch, s as ComparisonDiagnostic, t as ComparedChange, u as ComparisonResolution } from "../comparison-types-Bvvxzxq2-08gzpgF6.js";
3
3
  type TwoWayInput<V extends Value> = Readonly<{
4
4
  after: unknown;
5
5
  before: unknown;
@@ -125,9 +125,11 @@ while it holds it. An unmounted editor only clears its focused state.
125
125
  #### `editor.api.dom.focus(options?: { retries?: number }): void`
126
126
 
127
127
  Focus the editor's [view](#views). Does nothing when no view is picked. The
128
- root's `nodeSelectionFocus` element takes focus while there is no selection or
129
- a node selection holds only the root's top-level blocks, and a range shown
130
- across roots stays shown.
128
+ root's `nodeSelectionFocus` element takes focus while no range is shown into
129
+ the root and the root's own selection is none or a node selection of its
130
+ top-level blocks, including one the root kept while the caret was in another
131
+ root. A range shown into the root stays shown. Inside an open update or read,
132
+ such a root's editable takes focus instead.
131
133
 
132
134
  #### `editor.api.dom.deselect(): void`
133
135
 
@@ -6,7 +6,7 @@ A field is a typed blank in a document that one role fills, such as a tenant's n
6
6
 
7
7
  _Example `field-demo` in the Plate repository: `apps/www/src/registry/examples/field-demo.tsx`, `apps/www/src/registry/examples/values/field-value.tsx`, `apps/www/src/registry/examples/values/cn/field-value.tsx`._
8
8
 
9
- The demo is a lease template for a landlord and a tenant. Insert a field from the toolbar's menu, click a field to change its settings, and read the HTML, Markdown and Word panels under the editor. Pick Fill as landlord or Fill as tenant above the editor to fill the lease as that role.
9
+ The demo is a lease template for a landlord and a tenant. Insert a field from the toolbar's menu, click a field to change its settings, and read the HTML, Markdown and Word panels under the editor. Pick Fill as landlord or Fill as tenant above the editor to fill the lease as that role. Submit checks that role's answers after the answers of the roles that submitted before it. The Submission panel then shows each refusal, or the filled document as static output with the roles it still waits on.
10
10
 
11
11
  <PackageInfo>
12
12
 
@@ -14,12 +14,13 @@ The demo is a lease template for a landlord and a tenant. Insert a field from th
14
14
 
15
15
  - Inline void `field` element of six kinds: text, number, date, checkbox, choice and signature.
16
16
  - A role per field, a label, and an optional required flag, default, choice options and value, each checked against the field's kind.
17
- - A condition that names another field by its `fieldId` and tests that field's value.
18
- - `insert` and `update` commands that refuse a setting or condition that does not fit, and reads that report what is wrong with each field.
17
+ - A condition that names another field by its `fieldId` and tests that field's value. A field whose condition fails is skipped, so it needs no answer.
18
+ - `insert` and `update` commands that refuse a setting or condition that does not fit, and reads that report what is wrong with each field and whether it applies.
19
19
  - A fill-only view of one role, which takes that role's answers, refuses every other local change and undoes only that role's answers.
20
+ - `applyFieldValues`, which checks each role's answers against the template on a server and builds the filled document.
20
21
  - New ids for the fields a paste, a drag copy, a duplicate or a table fill copies, with copied conditions that name the copies.
21
22
  - HTML and Markdown that keep every property, and Word export that keeps each answer and reports the settings it drops.
22
- - A field chip with a settings popover, an insert menu and a static renderer in the registry UI.
23
+ - A field chip with a settings popover that mutes a skipped field, an insert menu, and a static renderer that shows each answer in place or a blank line, in the registry UI.
23
24
 
24
25
  </PackageInfo>
25
26
 
@@ -71,7 +72,7 @@ export function FieldToolbar() {
71
72
 
72
73
  ### Add static rendering
73
74
 
74
- `BaseFieldKit` renders each field's answer, a choice as its option's label, or the field's label when it has no answer, for read-only output with `platejs/static`.
75
+ `BaseFieldKit` renders each field for read-only output with `platejs/static`. A field shows its answer in place: a choice as its option's label, a checkbox as a ticked or empty box, and a number as written, `0` included. A field other than a checkbox shows a blank line when it has no filled answer. An app makes the PDF of a filled document from this output, as [Print the filled document](#print-the-filled-document) shows.
75
76
 
76
77
  _Registry item `field-static`: `npx shadcn@latest add @plate/field-static`._
77
78
 
@@ -143,11 +144,11 @@ A field sits inside a paragraph, like a date or a mention.
143
144
  | `fieldId` | `string` | Unique in the document. A new field gets a random `nanoid`. |
144
145
  | `kind` | `FieldKind` | `'text'`, `'number'`, `'date'`, `'checkbox'`, `'choice'` or `'signature'`. Required. |
145
146
  | `role` | `string` | The role that fills the field, such as `'tenant'`. Required. |
146
- | `label` | `string` | Required. The chip shows it, and output shows it when the field has no answer. |
147
- | `required` | `boolean` | Marks a field that must be filled. Plate stores it, and your app checks it when it collects answers. |
147
+ | `label` | `string` | Required. The chip shows it, and HTML, Word and plain text show it in brackets when the field has no answer. |
148
+ | `required` | `boolean` | Marks a field that needs a filled answer while it applies. `applyFieldValues` refuses a submission that leaves it unfilled. |
148
149
  | `defaultValue` | `FieldValue` | A value of the field's kind. |
149
150
  | `options` | `FieldOption[]` | Choice fields only. Each option is `{ value, label }`, and no two share a `value`. |
150
- | `value` | `FieldValue` | The answer. A field without one is unfilled. |
151
+ | `value` | `FieldValue` | The answer. A field is unfilled without one, or when `fillsField` says its answer does not fill it. |
151
152
  | `condition` | `FieldCondition` | `{ ref, test, value? }`, see [Conditions](#conditions). |
152
153
  | `children` | `[{ text: '' }]` | Required child of an inline void element. |
153
154
 
@@ -166,11 +167,21 @@ Each kind fixes the shape of its value and the tests a condition on it may use.
166
167
 
167
168
  A choice stores the option's `value`, so renaming an option's `label` keeps every answer and condition that names it.
168
169
 
170
+ `fillsField(field, value)` from `platejs/field` says whether a value is a filled answer for a field. `required` and the `filled` and `blank` tests read the same rule. A filled answer is a ticked checkbox, or a value that fits the field's kind. A text or signature answer also needs a character that JavaScript's `\s` does not match. So `false`, an empty text and a text of spaces fit a field but do not fill it, and `0` fills a number field.
171
+
172
+ ```ts
173
+ import { fillsField } from 'platejs/field';
174
+
175
+ fillsField({ kind: 'text' }, ' '); // false
176
+ fillsField({ kind: 'number' }, 0); // true
177
+ fillsField({ kind: 'checkbox' }, false); // false
178
+ ```
179
+
169
180
  ## Roles
170
181
 
171
182
  Each field names the role that fills it, such as `landlord` or `tenant`. A role is any string. Plate stores it and never checks who a user is. Your app maps each person to a role, as it maps each comment to its author.
172
183
 
173
- A [fill-only view](#fill-as-one-role) stops one role from changing another role's field, or the text around it, in that editor. An app that collects answers from several people still checks each submitted value on its server.
184
+ A [fill-only view](#fill-as-one-role) stops one role from changing another role's field, or the text around it, in that editor. An app that collects answers from several people still checks each role's answers on its server, with [`applyFieldValues`](#apply-answers-on-the-server).
174
185
 
175
186
  The settings popover offers the roles the document's fields already use, and takes a new one.
176
187
 
@@ -210,7 +221,7 @@ A patch that changes `kind` or `options` also drops each value, default and opti
210
221
 
211
222
  ## Conditions
212
223
 
213
- A condition says when a field applies. It applies when the field whose `fieldId` is `ref` passes `test`. Every test but `filled` and `blank` compares against `value`, which takes the shape of the named field's value. The demo's Pet name field applies when the Pets choice is `yes`:
224
+ A condition says when a field applies. It applies when the field whose `fieldId` is `ref` passes `test`. Every test but `filled` and `blank` compares against `value`, which takes the shape of the named field's value. The demo's Pet name field, which the tenant fills, applies when the landlord's Pets allowed choice is `yes`:
214
225
 
215
226
  ```tsx
216
227
  editor.update((tx) => {
@@ -220,13 +231,20 @@ editor.update((tx) => {
220
231
  });
221
232
  ```
222
233
 
223
- The popover's Show when list offers the field the condition names and every other field whose conditions do not lead back to this one. Its test list offers only the tests that field's kind takes. Plate stores the condition and checks that it fits the field it names. It does not hide a field or skip it, so your app decides what a condition that fails means.
234
+ The popover's Show when list offers the field the condition names and every other field whose conditions do not lead back to this one. Its test list offers only the tests that field's kind takes.
235
+
236
+ The editor never hides a field. A field whose condition fails is skipped. It needs no answer even when it is `required`, and `applyFieldValues` refuses a filled answer for it. A condition tests the answer of the field it names:
237
+
238
+ - `equals` holds when the answer is `value`, and `not-equals` when it is not, no answer included.
239
+ - `above` and `below` compare numbers, and ISO dates as dates. Neither holds without an answer.
240
+ - An answer that does not fit its field's kind counts as no answer, and so does the answer of a field that is skipped itself.
241
+ - A checkbox with no answer reads as `false` once its role is done answering. In the editor, that holds for a checkbox of the role that fills the field being read. In `applyFieldValues`, it holds once the checkbox's role has submitted.
224
242
 
225
243
  `update` refuses a condition that would close a loop, such as A naming B while B names A, or a field naming itself. A new test or value on a field of a loop passes. A loop can still come from a loaded document, a plain node write or two peers' updates made at the same time, and each of its fields then reports `condition-loop`.
226
244
 
227
245
  ## Read fields and their problems
228
246
 
229
- `read.field(fieldId)` returns the field that holds an id, in any root, or `null`. It looks up that field, then one field for each condition it follows along the chain. `read.fields()` returns every field of the document in reading order. Each read is a `FieldRead`: `{ fieldId, node, problems }`.
247
+ `read.field(fieldId)` returns the field that holds an id, in any root, or `null`. It looks up that field, then one field for each condition it follows along the chain. `read.fields()` returns every field of the document in reading order. Each read is a `FieldRead`: `{ applies, fieldId, node, problems }`.
230
248
 
231
249
  ```tsx
232
250
  import { BaseFieldPlugin } from 'platejs/field';
@@ -235,6 +253,7 @@ const fields = editor.plugin(BaseFieldPlugin).read;
235
253
 
236
254
  const tenant = fields.field(tenantId);
237
255
  const broken = fields.fields().filter((field) => field.problems.length > 0);
256
+ const skipped = fields.fields().filter((field) => field.applies === false);
238
257
  ```
239
258
 
240
259
  | Problem | When |
@@ -246,13 +265,22 @@ const broken = fields.fields().filter((field) => field.problems.length > 0);
246
265
 
247
266
  `insert` and `update` refuse a write that would cause a problem. A problem comes from a later edit, such as deleting or changing the field a condition names, or from a write that skipped the commands, such as a plain `tx.nodes.set` or a loaded document.
248
267
 
249
- In React, `useFieldRead(fieldId)` from `platejs/field/react` reads one field and its problems. A commit that changes an element reads it again, and the component renders again only when the field or its problems changed. The registry chip uses it to show a warning when the field its condition names is deleted, and an undo clears the warning.
268
+ `applies` says whether the field applies under its condition. It reads the answers the document holds now, along the whole chain of conditions, as the field's own role reads them:
269
+
270
+ - `true` for a field with no condition, a condition that has a problem or one in a loop, and a condition that holds.
271
+ - `false` for a skipped field, whose condition fails.
272
+ - `null` while it depends on an answer another role has not given, such as the tenant's Pet name before the landlord picks Pets allowed. Only `applyFieldValues` knows which roles have submitted, so the editor reads such a field as waiting.
273
+
274
+ A field whose condition names a skipped field is decided, even when another role owns that field.
275
+
276
+ In React, `useFieldRead(fieldId)` from `platejs/field/react` reads one field, its problems and whether it applies. A commit that changes an element reads it again, and the component renders again only when the field, its problems or `applies` changed. The registry chip uses it to show a warning when the field its condition names is deleted, and an undo clears the warning. The chip also mutes a field whose `applies` is `false` and marks it skipped. The chip of a field that waits is not muted.
250
277
 
251
278
  ```tsx
252
279
  import { useFieldRead } from 'platejs/field/react';
253
280
 
254
281
  const field = useFieldRead(element.fieldId);
255
282
  const problems = field?.problems ?? [];
283
+ const skipped = field?.applies === false;
256
284
  ```
257
285
 
258
286
  ## Fill as one role
@@ -299,7 +327,94 @@ A peer's change passes whole. Every commit tagged `collaboration` passes, so col
299
327
 
300
328
  The fill check runs in the field plugin's `activate`, and the undo step boundary in its `corrections`. A plugin that extends the field plugin with its own `activate` or `corrections` replaces them, so put that work in a companion plugin.
301
329
 
302
- The fill check runs in the person's browser, where anyone can run their own code. Your server assigns each person's role and checks each submitted answer.
330
+ The fill check runs in the person's browser, where anyone can run their own code. Your server assigns each person's role and checks each submission with `applyFieldValues`.
331
+
332
+ ## Submit answers
333
+
334
+ A client reads one role's answers from the editor and posts them. The server checks every role's answers against the template it saved, and keeps the filled document.
335
+
336
+ ### Read a role's answers
337
+
338
+ `read.submission(role)` returns a `FieldSubmission`, `{ role, values }`. `values` holds the `value` of each field of the role that has one, keyed by `fieldId`.
339
+
340
+ ```tsx
341
+ import { FieldPlugin } from 'platejs/field/react';
342
+
343
+ const submission = editor.plugin(FieldPlugin).read.submission('tenant');
344
+ // { role: 'tenant', values: { tenant: 'Grace Hopper', 'pet-name': 'Milo', rules: true } }
345
+ ```
346
+
347
+ The submission keeps `false`, `0`, an empty text, a text of spaces and a value that no longer fits its field's kind, so the server judges each of them. It leaves out a field with no `value`, so a checkbox never touched and one ticked and then unticked stay apart.
348
+
349
+ ### Apply answers on the server
350
+
351
+ `applyFieldValues(template, submissions, options?)` from `platejs/field` checks each role's answers and builds the filled document. It imports no React and checks each submission's shape itself, so a server passes parsed JSON straight in. In this route, `frozenTemplate` is the template your app saved, `accepted` holds the submissions it accepted before, and `saveFilled` stores the result.
352
+
353
+ ```ts
354
+ import { applyFieldValues } from 'platejs/field';
355
+
356
+ const result = applyFieldValues(frozenTemplate, [...accepted, submission]);
357
+
358
+ if (!result.ok) {
359
+ return Response.json({ refusals: result.refusals }, { status: 400 });
360
+ }
361
+
362
+ await saveFilled(result.document);
363
+ ```
364
+
365
+ - `template` is the authored document as your app saved it, with its `fieldId`s and no answers, so the fill view and `applyFieldValues` start from the same ids. It takes a `Value` or a document with named roots, and `result.document` has the same shape. `applyFieldValues` reads fields in the main root and each named root, never in `meta` or records.
366
+ - `submissions` lists each role's submission in the order the roles submitted. Each one is checked against the roles before it plus its own answers.
367
+ - `options.type` names the field element's type when your app renamed it with `schema.override`. It defaults to `field`.
368
+
369
+ The filled document is the template with each accepted answer set as its field's `value`. A default stays a setting and never becomes an answer.
370
+
371
+ On success, `pending` lists each role that has not submitted and holds a required field that applies or waits. It also lists the role whose answer each such waiting field needs next. An optional field never puts a role in `pending`. The demo shows `pending` as Waiting on.
372
+
373
+ ### Refusals
374
+
375
+ On a refusal, `result` is `{ ok: false, refusals }` with at least one refusal. When the template has refusals, the result lists all of them and checks no submission. Otherwise it lists the refusals of the first submission that has any.
376
+
377
+ | Code | When |
378
+ |------|------|
379
+ | `invalid-template` | A template field holds an answer (`answered`), lacks a `fieldId`, holds anything but one text or has a kind, role, label, setting or condition of the wrong shape (`malformed`), repeats a `fieldId` (`duplicate-id`), or has a problem a read reports, `condition-loop` included. The refusal names the `problem`, the field's `path`, its `root` in a named root and its `fieldId` when it has one. |
380
+ | `invalid-submission` | A submission is not an object with a `role` string and a `values` object. The refusal names its `index`. |
381
+ | `duplicate-role` | A role already in the list submits again. |
382
+ | `unknown-role` | The role owns no field. |
383
+ | `unknown-field` | An answer names no field of the template. |
384
+ | `wrong-role` | An answer is for another role's field. |
385
+ | `invalid-value` | An answer does not fit its field. |
386
+ | `waiting` | A field of the role waits on a role that has not submitted, which `waitsOn` names. It is reported even when the field's answer is refused too. |
387
+ | `skipped` | A field of the role is skipped and holds a filled answer. An unfilled answer stays as written, so clearing the answer or unticking the box ends the refusal. |
388
+ | `missing-required` | A required field of the role applies and has no filled answer. |
389
+
390
+ `invalid-submission`, `duplicate-role` and `unknown-role` come alone. The other submission refusals name the `role` and the `fieldId`, and the result lists every one of them for that submission.
391
+
392
+ In the demo, the tenant's Submit before the landlord's gets a `waiting` refusal, because Pet name waits on the landlord's Pets allowed. When the landlord submits No, a pet name the tenant types anyway is refused as `skipped` until it is cleared.
393
+
394
+ A template where two roles each wait on the other passes, because a third role's answer can end the wait by making a field along the chain skip. While both fields still wait, the role that submits first is refused as `waiting` on the other.
395
+
396
+ ### Print the filled document
397
+
398
+ Render the filled document with `BaseFieldKit` through `platejs/static`, and make its PDF from that output. Static output shows a field other than a checkbox as a blank line when it has no filled answer, while `editor.api.html.serialize()` writes the label in brackets for a field with no answer.
399
+
400
+ ```tsx
401
+ import { createEditor } from 'platejs';
402
+ import { renderStaticHtml } from 'platejs/static';
403
+
404
+ import { BaseFieldKit } from '@/components/editor/field-static';
405
+
406
+ const filled = createEditor({
407
+ initialValue: result.document,
408
+ plugins: [
409
+ // ...otherPlugins,
410
+ ...BaseFieldKit,
411
+ ],
412
+ });
413
+
414
+ const { data } = await renderStaticHtml(filled);
415
+ ```
416
+
417
+ [Static Rendering](/docs/static) covers `EditorStatic` and `renderStaticHtml`.
303
418
 
304
419
  ## Copy and paste
305
420
 
@@ -319,7 +434,7 @@ In Suggesting mode, a change from a field to a mention shows the field as delete
319
434
  `editor.api.html.serialize()` writes each field as a `span` with one `data-field-*` attribute per property. The span's text is the answer, a choice as its option's label, or the label in brackets when the field has no answer. The id, kind, label and role attributes hold plain text, and the others hold JSON:
320
435
 
321
436
  ```html
322
- <p>Pets? <span data-field-id="pets" data-field-kind="choice" data-field-label="Pets" data-field-options="[{&quot;label&quot;:&quot;Yes&quot;,&quot;value&quot;:&quot;yes&quot;},{&quot;label&quot;:&quot;No&quot;,&quot;value&quot;:&quot;no&quot;}]" data-field-role="tenant" data-field-value="&quot;yes&quot;">Yes</span> Pet name: <span data-field-condition="{&quot;ref&quot;:&quot;pets&quot;,&quot;test&quot;:&quot;equals&quot;,&quot;value&quot;:&quot;yes&quot;}" data-field-id="pet-name" data-field-kind="text" data-field-label="Pet name" data-field-role="tenant">[Pet name]</span></p>
437
+ <p>Pets allowed? <span data-field-id="pets" data-field-kind="choice" data-field-label="Pets allowed" data-field-options="[{&quot;label&quot;:&quot;Yes&quot;,&quot;value&quot;:&quot;yes&quot;},{&quot;label&quot;:&quot;No&quot;,&quot;value&quot;:&quot;no&quot;}]" data-field-required="true" data-field-role="landlord" data-field-value="&quot;yes&quot;">Yes</span> Pet name: <span data-field-condition="{&quot;ref&quot;:&quot;pets&quot;,&quot;test&quot;:&quot;equals&quot;,&quot;value&quot;:&quot;yes&quot;}" data-field-id="pet-name" data-field-kind="text" data-field-label="Pet name" data-field-required="true" data-field-role="tenant">[Pet name]</span></p>
323
438
  ```
324
439
 
325
440
  Parsing that HTML reads every property back. A span needs `data-field-kind`, `data-field-label` and `data-field-role` to read as a field. A pasted HTML template gets new ids, and its conditions name the copies.
@@ -331,7 +446,7 @@ The demo's HTML panel serializes with `lossPolicy: 'allow'`, because the date el
331
446
  Markdown writes each field as a `<field>` tag with every property, the `fieldId` and the condition included:
332
447
 
333
448
  ```md
334
- Pets? <field kind="choice" label="Pets" options="[{&quot;label&quot;:&quot;Yes&quot;,&quot;value&quot;:&quot;yes&quot;},{&quot;label&quot;:&quot;No&quot;,&quot;value&quot;:&quot;no&quot;}]" role="tenant" value="yes" fieldId="pets" /> Pet name: <field kind="text" label="Pet name" role="tenant" condition="{&quot;ref&quot;:&quot;pets&quot;,&quot;test&quot;:&quot;equals&quot;,&quot;value&quot;:&quot;yes&quot;}" fieldId="pet-name" />
449
+ Pets allowed? <field kind="choice" label="Pets allowed" options="[{&quot;label&quot;:&quot;Yes&quot;,&quot;value&quot;:&quot;yes&quot;},{&quot;label&quot;:&quot;No&quot;,&quot;value&quot;:&quot;no&quot;}]" required role="landlord" value="yes" fieldId="pets" /> Pet name: <field kind="text" label="Pet name" required role="tenant" condition="{&quot;ref&quot;:&quot;pets&quot;,&quot;test&quot;:&quot;equals&quot;,&quot;value&quot;:&quot;yes&quot;}" fieldId="pet-name" />
335
450
  ```
336
451
 
337
452
  The reader needs `kind`, `label` and `role`. A tag without them stays as text, with a `markdown-unsupported-node` diagnostic. A pasted Markdown template gets new ids, and its conditions name the copies.
@@ -361,10 +476,13 @@ Plain text, through `serializePlainText` from `platejs`, writes the same text as
361
476
  | `FieldPlugin` | `platejs/field/react` | React field plugin. |
362
477
  | `tx.plugin(BaseFieldPlugin).insert(settings, options?)` | `BaseFieldPlugin` update | Inserts a field and returns its `fieldId`. |
363
478
  | `tx.plugin(BaseFieldPlugin).update(fieldId, patch)` | `BaseFieldPlugin` update | Changes a field's settings or value. |
364
- | `editor.plugin(BaseFieldPlugin).read.field(fieldId)` | `BaseFieldPlugin` read | The field that holds an id, with its problems, or `null`. |
365
- | `editor.plugin(BaseFieldPlugin).read.fields()` | `BaseFieldPlugin` read | Every field in reading order, with its problems. |
479
+ | `editor.plugin(BaseFieldPlugin).read.field(fieldId)` | `BaseFieldPlugin` read | The field that holds an id, with its problems and whether it applies, or `null`. |
480
+ | `editor.plugin(BaseFieldPlugin).read.fields()` | `BaseFieldPlugin` read | Every field in reading order, with its problems and whether it applies. |
481
+ | `editor.plugin(BaseFieldPlugin).read.submission(role)` | `BaseFieldPlugin` read | The values of one role's fields, keyed by `fieldId`, to pass to `applyFieldValues`. |
366
482
  | `fillRole` | `BaseFieldPlugin` state | The role this editor fills as, or `null` while authoring. Set it through `initialState` or `editor.plugin(FieldPlugin).store.set`. |
367
- | `useFieldRead(fieldId)` | `platejs/field/react` | Reads one field and its problems, and renders again when either changes. |
483
+ | `useFieldRead(fieldId)` | `platejs/field/react` | Reads one field, its problems and whether it applies, and renders again when any of them changes. |
484
+ | `applyFieldValues(template, submissions, options?)` | `platejs/field` | Checks each role's answers against the template, and returns the filled document with `pending` or the refusals. |
368
485
  | `fitsField(field, value)` | `platejs/field` | Whether a value fits a field's kind and options. |
486
+ | `fillsField(field, value)` | `platejs/field` | Whether a value is a filled answer for a field. |
369
487
  | `FIELD_TESTS` | `platejs/field` | The tests a condition may use on each kind. |
370
- | `FieldElement`, `FieldSettings`, `FieldPatch`, `FieldRead`, `FieldCondition`, `FieldProblem`, `FieldKind`, `FieldTest`, `FieldValue`, `FieldOption` | `platejs/field` | Field types. |
488
+ | `FieldElement`, `FieldSettings`, `FieldPatch`, `FieldRead`, `FieldCondition`, `FieldProblem`, `FieldKind`, `FieldTest`, `FieldValue`, `FieldOption`, `FieldSubmission`, `FieldRefusal`, `FieldApplyResult` | `platejs/field` | Field types. |
package/dist/docs/link.md CHANGED
@@ -8,7 +8,7 @@ _Example `link-demo` in the Plate repository: `apps/www/src/registry/examples/de
8
8
 
9
9
  - Insert, edit, and remove hyperlinks.
10
10
  - Markdown shortcut: type `[text](url)` and close with `)` to turn it into a link.
11
- - Plain URL autolink: paste a URL, or type a URL then press space or `Enter`.
11
+ - Plain URL autolink: paste a URL, or type a URL then press space or `Enter`. With `MediaKit`, a video or post link pasted alone on an empty line lands as a link. Then an embed of that link goes in above the line, and the line empties, as [Media](/docs/media#input-rules) describes.
12
12
 
13
13
  </PackageInfo>
14
14
 
@@ -1,4 +1,4 @@
1
- # Plate docs for platejs@54.0.0-beta.4
1
+ # Plate docs for platejs@54.0.0-beta.5
2
2
 
3
3
  These pages match the installed `platejs` version. A `/docs/<path>` link in a page is the file `<path>.md` in this folder when the list below names it, and `/docs` is `index.md`. Read the pages your task needs before you write editor code.
4
4
 
@@ -22,6 +22,7 @@ _Example `media-demo` in the Plate repository: `apps/www/src/registry/examples/d
22
22
  - Editable captions
23
23
  - Resizable elements
24
24
  - Embed URLs are normalized into `url` and `provider`, with an optional `sourceUrl` preserved for reversible editing.
25
+ - Paste a video or post link alone on an empty line to embed it above that line.
25
26
 
26
27
  ### Upload
27
28
  - **Multiple upload methods**:
@@ -150,9 +151,49 @@ For local file uploads, add `UploadPlugin` separately as shown in
150
151
  [Upload files](/docs/upload).
151
152
 
152
153
  <Callout type="info">
153
- **Note:** In Markdown, an image with only `url`, `alt`, and `title` is written as `![alt](url "title")`. An image with other properties, such as `width`, uses `<img src="…" />`, and a captioned image uses `<figure>` with `<img />` and `<figcaption>`. Video, audio, file, and embed use their own tags, such as `<video src="…">Caption</video>`; embeds keep the canonical `src` and `provider`, plus an optional `sourceUrl` so edits remain reversible. A caption must be one Markdown paragraph. Allowlisted provider snippets (e.g. YouTube, Tweet) are reduced to canonical URLs on paste. Raw `<script>` or custom embed chrome is out of scope — add your own rules if you need to preserve it.
154
+ **Note:** In Markdown, an image with only `url`, `alt`, and `title` is written as `![alt](url "title")`. An image with other properties, such as `width`, uses `<img src="…" />`, and a captioned image uses `<figure>` with `<img />` and `<figcaption>`. Video, audio, file, and embed use their own tags, such as `<video src="…">Caption</video>`; embeds keep the canonical `src` and `provider`, plus an optional `sourceUrl` so edits remain reversible. A caption must be one Markdown paragraph. `update.insert` takes the `src` out of an `<iframe>` snippet, and a provider link pasted alone on an empty line embeds through [`MediaEmbedRules`](#input-rules). Raw `<script>` and custom embed chrome are out of scope. Add your own rules to keep them.
154
155
  </Callout>
155
156
 
157
+ ### Input rules
158
+
159
+ `MediaKit` enables the paste embed rule. To enable it on your own `MediaEmbedPlugin`:
160
+
161
+ ```tsx
162
+ import { MediaEmbedRules } from 'platejs/media';
163
+ import { MediaEmbedPlugin } from 'platejs/media/react';
164
+ import { createEditor } from 'platejs/react';
165
+ import { MediaEmbedElement } from '@/components/editor/media-embed';
166
+
167
+ const editor = createEditor({
168
+ plugins: [
169
+ // ...otherPlugins,
170
+ MediaEmbedPlugin.configure({
171
+ component: MediaEmbedElement,
172
+ inputRules: [MediaEmbedRules.autoEmbed({ variant: 'paste' })],
173
+ }),
174
+ ],
175
+ });
176
+ ```
177
+
178
+ - `MediaEmbedRules.autoEmbed({ variant: 'paste' })`: Embeds a YouTube, Vimeo, Dailymotion, Youku, Coub or X (Twitter) link pasted alone into an empty paragraph. The paste lands first, as a link under the link plugin's paste rule or as plain text without it. Then, as its own undo step, the embed goes in above that paragraph, which stays empty and keeps the caret. One undo gives back what the paste landed, and a second gives the empty line.
179
+
180
+ The paste stays as it landed, a link or plain text, when:
181
+
182
+ - other text shares the line, or a line break follows the link;
183
+ - the paragraph is not bare, such as a list item, heading, indented or aligned paragraph, toggle title or caption, or the caret is in a code block;
184
+ - the paste replaces a selected range, or the clipboard holds an exact Plate slice or no plain text;
185
+ - the link is a Vimeo link with an `h` parameter, such as the player URL in Vimeo's embed code, because the embed would drop it;
186
+ - the view proposes changes, as in Suggesting mode;
187
+ - in `EditorKit`, a space or tab sits before or after the link, because the kit's Markdown or HTML paste then replaces the line. A leading tab or four leading spaces land a code block.
188
+
189
+ When the clipboard's HTML holds only the link, as an anchor with no attribute but
190
+ `href` and no text but the URL, the HTML paste drops the space or tab around it,
191
+ and the link embeds.
192
+ An empty paragraph inside a quote, table cell, column or details body embeds.
193
+ In another root, the paste embeds when it goes through a view of that root,
194
+ made with `createEditorView(editor, { root })`. A paste through the main
195
+ editor into another root stays a link.
196
+
156
197
  ### Captions
157
198
 
158
199
  Every image, audio, video, file, and embed is a non-void object element.
@@ -313,7 +354,7 @@ inline children store captions.
313
354
  </APIOptions>
314
355
  </API>
315
356
 
316
- `UploadPlugin` handles pasted image files. `ImagePlugin` inserts a pasted image URL as an image when no earlier paste rule takes it. In `EditorKit`, the link kit's `LinkRules.autolink({ variant: 'paste' })` rule runs first and takes any valid URL, image URLs included, as a link.
357
+ `UploadPlugin` handles pasted image files. `ImagePlugin` inserts a pasted image URL as an image when no earlier paste rule takes it. In `EditorKit`, the link kit's `LinkRules.autolink({ variant: 'paste' })` rule runs first and takes any valid URL, image URLs included, as a link. When that link is a provider link pasted alone on an empty line, `MediaEmbedRules.autoEmbed({ variant: 'paste' })` then embeds it above the line.
317
358
 
318
359
  ### `VideoPlugin`
319
360
 
@@ -340,6 +381,8 @@ inline children store captions. Extends `MediaPluginState`.
340
381
 
341
382
  Plugin for non-void object media embed elements whose
342
383
  direct inline children store captions. Extends `MediaPluginState`.
384
+ Its paste rule, [`MediaEmbedRules.autoEmbed`](#mediaembedrulesautoembed), ships
385
+ from `platejs/media`.
343
386
 
344
387
  ### `UploadPlugin`
345
388
 
@@ -378,6 +421,49 @@ like a pasted one, without landing rules or vetoes.
378
421
 
379
422
  ## API
380
423
 
424
+ ### `MediaEmbedRules.autoEmbed`
425
+
426
+ Returns a [follow-up paste rule](/docs/plugin-input-rules#follow-up-paste-rules)
427
+ for `MediaEmbedPlugin`'s `inputRules`.
428
+
429
+ <API name="MediaEmbedRules.autoEmbed">
430
+ <APIParameters>
431
+ <APIItem name="options.variant" type="'paste'">
432
+ Embeds a provider link pasted alone into an empty paragraph, as
433
+ [Input rules](#input-rules) describes.
434
+ </APIItem>
435
+ <APIItem name="options.enabled" type="(context) => boolean" optional>
436
+ Policy gate, evaluated before the rule matches.
437
+ </APIItem>
438
+ <APIItem name="options.priority" type="number" optional>
439
+ Sort order among the editor's paste rules.
440
+ </APIItem>
441
+ </APIParameters>
442
+ </API>
443
+
444
+ The rule reads one `http` or `https` link with only spaces or tabs around it.
445
+ The embed stores the provider's name in `provider`, its player URL in `url` and
446
+ its canonical link in `sourceUrl`. X stores `twitter` as its `provider` and its
447
+ canonical link as its `url`:
448
+
449
+ | Provider | Accepted links | `url` | `sourceUrl` |
450
+ | --- | --- | --- | --- |
451
+ | YouTube | `youtube.com/watch?v=<id>`, `/shorts/<id>`, `/embed/<id>` and `/live/<id>`, and `youtu.be/<id>` | `https://www.youtube.com/embed/<id>` | `https://www.youtube.com/watch?v=<id>` |
452
+ | Vimeo | `vimeo.com/<id>` and `player.vimeo.com/video/<id>`, without an `h` parameter | `https://player.vimeo.com/video/<id>` | `https://vimeo.com/<id>` |
453
+ | Dailymotion | `dailymotion.com/video/<id>` and `dai.ly/<id>` | `https://www.dailymotion.com/embed/video/<id>` | `https://www.dailymotion.com/video/<id>` |
454
+ | Youku | `v.youku.com/v_show/id_<id>.html` | `https://player.youku.com/embed/<id>` | `https://v.youku.com/v_show/id_<id>.html` |
455
+ | Coub | `coub.com/view/<id>` and `coub.com/embed/<id>` | `https://coub.com/embed/<id>` | `https://coub.com/view/<id>` |
456
+ | X (Twitter) | `/<user>/status/<id>` and `/i/web/status/<id>` on `x.com` and `twitter.com`, with an optional `/photo/<n>` or `/video/<n>` | `https://x.com/i/status/<id>` | none |
457
+
458
+ Links on `youtube.com`, `vimeo.com`, `dailymotion.com`, `coub.com`, `x.com` and
459
+ `twitter.com` also match with `www.`, `m.` or `mobile.`. A YouTube `t` or
460
+ `start` time in the query, or a `t` time in the fragment, goes on `sourceUrl` as
461
+ `&t=` with its value as given. When that value reads as a positive number of
462
+ seconds, such as `90` or `1m30s`, `url` also gets `?start=` with those seconds.
463
+
464
+ A YouTube playlist, a Vimeo `showcase`, `channels`, `album` or `groups` link, and a link with
465
+ more path after its id stay links.
466
+
381
467
  ### Upload tasks
382
468
 
383
469
  | Operation | Contract |