platejs 54.0.0-beta.2 → 54.0.0-beta.3

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 (237) hide show
  1. package/README.md +1 -1
  2. package/THIRD_PARTY_NOTICES.md +56 -0
  3. package/dist/{AIChatRequestContext-BMVWhfPV.d.ts → AIChatRequestContext-DY104TqL.d.ts} +2 -2
  4. package/dist/{BaseSuggestionPlugin-DBl3fqnm.d.ts → BaseSuggestionPlugin-Deo6n6Fs.d.ts} +7 -3
  5. package/dist/{PlateStatic-DhNv2ejp.d.ts → PlateStatic-CJX5bKuv.d.ts} +7 -7
  6. package/dist/ai/index.d.ts +1 -1
  7. package/dist/ai/react/AIChatPlugin.js +113 -78
  8. package/dist/ai/react/CopilotPlugin.js +1 -1
  9. package/dist/ai/react/index.d.ts +23 -16
  10. package/dist/authored/index.d.ts +4 -4
  11. package/dist/code-block/codemirror/createCodeMirrorAdapter.js +12 -9
  12. package/dist/code-block/codemirror/index.d.ts +1 -1
  13. package/dist/{combobox-DkBGgyd3.d.ts → combobox-DAOYWuvC.d.ts} +2 -2
  14. package/dist/{comparison-types-CYnJ35qU.d.ts → comparison-types-Dt-unJZY-DCddmbSD.d.ts} +10 -2
  15. package/dist/compiler/index.d.ts +2 -2
  16. package/dist/{core-BJG8l_mk.d.ts → core-ClHasORr.d.ts} +433 -95
  17. package/dist/diff/index.d.ts +2 -2
  18. package/dist/docs/ai.md +4 -3
  19. package/dist/docs/api/core/plate-components.md +0 -19
  20. package/dist/docs/api/core/plate-controller.md +4 -2
  21. package/dist/docs/api/core/plate-plugin.md +3 -0
  22. package/dist/docs/api/core/plate-store.md +3 -3
  23. package/dist/docs/api/dom.md +14 -4
  24. package/dist/docs/api/editor-transforms.md +2 -1
  25. package/dist/docs/api/react-hooks.md +25 -11
  26. package/dist/docs/authored-changes.md +5 -2
  27. package/dist/docs/basic-blocks.md +42 -29
  28. package/dist/docs/blockquote.md +5 -3
  29. package/dist/docs/board.md +63 -8
  30. package/dist/docs/code-block.md +47 -0
  31. package/dist/docs/discussion.md +1 -1
  32. package/dist/docs/docx.md +1 -1
  33. package/dist/docs/dom-coverage.md +5 -0
  34. package/dist/docs/examples/editable-voids.md +2 -3
  35. package/dist/docs/external-text.md +2 -0
  36. package/dist/docs/field.md +370 -0
  37. package/dist/docs/find.md +9 -6
  38. package/dist/docs/form.md +2 -0
  39. package/dist/docs/heading.md +6 -0
  40. package/dist/docs/installation/manual.md +0 -4
  41. package/dist/docs/link.md +3 -3
  42. package/dist/docs/llms.txt +4 -2
  43. package/dist/docs/markdown.md +176 -8
  44. package/dist/docs/plugin-components.md +13 -10
  45. package/dist/docs/plugin-input-rules.md +4 -12
  46. package/dist/docs/prompt-editor.md +205 -0
  47. package/dist/docs/roots.md +8 -6
  48. package/dist/docs/rtl.md +6 -4
  49. package/dist/docs/selection.md +7 -4
  50. package/dist/docs/suggestion.md +1 -1
  51. package/dist/docs/toolbar.md +26 -30
  52. package/dist/docs/upload.md +106 -17
  53. package/dist/docx/export/index.d.ts +3 -3
  54. package/dist/docx/export/lib/docxStaticComponents.js +12 -2
  55. package/dist/docx/export/lib/exportDocx.js +29 -5
  56. package/dist/docx/export/lib/reviewPart.js +1 -1
  57. package/dist/docx/export/lib/reviewProjection.js +10 -8
  58. package/dist/docx/import/index.d.ts +4 -4
  59. package/dist/docx/paste/index.d.ts +4 -4
  60. package/dist/dom/index.d.ts +1 -6
  61. package/dist/dom/plite-dom.internal.js +2 -2
  62. package/dist/excalidraw/index.d.ts +3 -2
  63. package/dist/excalidraw/react/index.d.ts +3 -2
  64. package/dist/facade.js +2 -2
  65. package/dist/features/basic-nodes/lib/BaseBlockPlugins.js +13 -5
  66. package/dist/features/basic-nodes/lib/BaseHeadingPlugins.js +32 -10
  67. package/dist/features/board/index.d.ts +2 -2
  68. package/dist/features/board/lib/BaseBoardPlugin.js +14 -1
  69. package/dist/features/board/lib/boardStroke.internal.js +13 -1
  70. package/dist/features/board/lib/boardTypes.internal.js +16 -0
  71. package/dist/features/callout/index.d.ts +3 -2
  72. package/dist/features/code-block/lib/BaseCodeBlockPlugin.js +14 -5
  73. package/dist/features/combobox/index.d.ts +2 -2
  74. package/dist/features/comments/index.d.ts +1 -1
  75. package/dist/features/date/index.d.ts +3 -2
  76. package/dist/features/details/index.d.ts +3 -2
  77. package/dist/features/details/lib/BaseDetailsPlugin.js +10 -10
  78. package/dist/features/field/index.d.ts +2 -0
  79. package/dist/features/field/index.js +2 -0
  80. package/dist/features/field/lib/BaseFieldPlugin.js +414 -0
  81. package/dist/features/field/lib/fieldRules.internal.js +42 -0
  82. package/dist/features/find/index.d.ts +3 -2
  83. package/dist/features/footnote/index.d.ts +1 -1
  84. package/dist/features/ink/index.d.ts +1 -1
  85. package/dist/features/ink/lib/BaseInkPlugin.js +126 -103
  86. package/dist/features/ink/lib/inkCodec.internal.js +130 -0
  87. package/dist/features/ink/lib/inkGone.internal.js +229 -48
  88. package/dist/features/ink/lib/inkPlaces.internal.js +533 -62
  89. package/dist/features/layout/index.d.ts +1 -1
  90. package/dist/features/link/lib/BaseLinkPlugin.js +6 -4
  91. package/dist/features/lint/index.d.ts +3 -2
  92. package/dist/features/media/index.d.ts +1 -1
  93. package/dist/features/media/lib/media/parseMediaUrl.js +11 -1
  94. package/dist/features/media/lib/media-embed/BaseMediaEmbedPlugin.js +6 -2
  95. package/dist/features/mention/index.d.ts +5 -4
  96. package/dist/features/suggestion/index.d.ts +1 -1
  97. package/dist/features/table/index.d.ts +1 -1
  98. package/dist/features/table/lib/BaseTablePlugin.js +14 -8
  99. package/dist/features/table/lib/internal/selection.js +4 -2
  100. package/dist/features/toc/index.d.ts +1 -1
  101. package/dist/features/upload/index.d.ts +2 -2
  102. package/dist/features/upload/lib/BaseUploadPlugin.js +464 -250
  103. package/dist/history/index.d.ts +2 -2
  104. package/dist/html/index.d.ts +3 -3
  105. package/dist/html/server/index.d.ts +1 -1
  106. package/dist/{htmlTypes-DjeFG3P8.d.ts → htmlTypes-cg_cWsaN.d.ts} +2 -31
  107. package/dist/hyperscript/index.d.ts +1 -1
  108. package/dist/{index-D1CFXA-i.d.ts → index-8WO2vI0U.d.ts} +475 -143
  109. package/dist/{index-DaM37gF6.d.ts → index-B5mYEawV.d.ts} +37 -21
  110. package/dist/{index-Bq3sdm3S.d.ts → index-BZWFoUXt.d.ts} +5 -4
  111. package/dist/{index-DdIRduDG.d.ts → index-C0POz7rg.d.ts} +3 -2
  112. package/dist/{index-Bxfvicyy.d.ts → index-C1_JIhL4.d.ts} +4 -3
  113. package/dist/{index-DC_MNGyu.d.ts → index-C35V_hj0.d.ts} +3 -3
  114. package/dist/{index-kLKMc-pI.d.ts → index-C6ql9pKw.d.ts} +2 -2
  115. package/dist/{index-hsC_sOn2.d.ts → index-C9DiGDVj.d.ts} +35 -5
  116. package/dist/{index-DTgaSxKr.d.ts → index-CLsEe3LY.d.ts} +40 -4
  117. package/dist/{index-CT7miqQN.d.ts → index-CdOLsPaW.d.ts} +29 -9
  118. package/dist/{index-DLA2DUR2.d.ts → index-CktYvOgk.d.ts} +4 -3
  119. package/dist/{index-BBKGrsG3.d.ts → index-Cmuluh6f.d.ts} +1 -1
  120. package/dist/{index-BiQerPJS.d.ts → index-CzLwBZpY.d.ts} +2 -2
  121. package/dist/{index-DzD6BIFJ.d.ts → index-D3-2iM1b.d.ts} +7 -5
  122. package/dist/{index-Cl77E9yr.d.ts → index-DKOFvteF.d.ts} +2 -2
  123. package/dist/{index-iaZOhA76.d.ts → index-DPWyk3lG-DOYwohXO.d.ts} +1 -1
  124. package/dist/index-DQnjqtQa.d.ts +678 -0
  125. package/dist/{index-CcZbqPqk.d.ts → index-Do9pj1GK.d.ts} +73 -39
  126. package/dist/{index-BU6k1Aev.d.ts → index-DpltOCot-A2b3p3Eb.d.ts} +4735 -4586
  127. package/dist/{index-Bc2Yg_2j.d.ts → index-HPYawTae-BCUQLEWF.d.ts} +2 -2
  128. package/dist/{index-BkR7-GLI.d.ts → index-baQOK89E.d.ts} +2 -2
  129. package/dist/{index-D5W-p9bS.d.ts → index-oIJAZxc2.d.ts} +49 -4
  130. package/dist/{index-xdmCBvlT.d.ts → index-r7yb77Wy.d.ts} +3 -2
  131. package/dist/index.d.ts +4 -4
  132. package/dist/{react/internal → internal}/penStroke.internal.js +1 -1
  133. package/dist/internal/plugin/OverridePlugin.js +101 -119
  134. package/dist/internal/plugin/collectPlateNodeMappings.js +5 -1
  135. package/dist/internal/plugin/pastedUploadFiles.js +4 -0
  136. package/dist/internal/plugin/resolvePlugin.js +1 -1
  137. package/dist/internal/plugin/resolvePlugins.js +3 -0
  138. package/dist/internal/plugin/uploadDrafts.js +6 -0
  139. package/dist/internal/utils/mergePlugins.js +1 -0
  140. package/dist/lib/plugins/element-id/ElementIdPlugin.js +8 -2
  141. package/dist/lib/plugins/html/HtmlPlugin.js +9 -0
  142. package/dist/lib/plugins/html/htmlSafety.js +1 -1
  143. package/dist/lib/plugins/input-rules/InputRulesPlugin.js +5 -15
  144. package/dist/lib/plugins/input-rules/inputRuleVeto.internal.js +16 -0
  145. package/dist/markdown/index.d.ts +2 -2
  146. package/dist/markdown/index.js +2 -1
  147. package/dist/markdown/lib/MarkdownPlugin.js +16 -9
  148. package/dist/markdown/lib/RawHtmlPlugin.js +24 -0
  149. package/dist/markdown/lib/deserializer/mdastToSlate.js +12 -2
  150. package/dist/markdown/lib/internal/markdownConversion.js +773 -74
  151. package/dist/markdown/lib/internal/markdownDiagnostics.js +18 -7
  152. package/dist/markdown/lib/internal/markdownFrontmatter.js +102 -0
  153. package/dist/markdown/lib/internal/markdownIntrinsics.js +125 -43
  154. package/dist/markdown/lib/internal/markdownLine.js +5 -3
  155. package/dist/markdown/lib/internal/markdownMappings.js +19 -7
  156. package/dist/markdown/lib/internal/markdownOpenTail.js +381 -0
  157. package/dist/markdown/lib/internal/markdownRawHtml.js +314 -0
  158. package/dist/markdown/lib/internal/markdownSegments.js +57 -48
  159. package/dist/markdown/lib/internal/markdownTags.js +22 -8
  160. package/dist/markdown/lib/serializer/convertNodesSerialize.js +10 -8
  161. package/dist/markdown/lib/serializer/convertPhrasingSerialize.js +226 -0
  162. package/dist/markdown/lib/serializer/listToMdastTree.js +2 -0
  163. package/dist/math/index.d.ts +3 -2
  164. package/dist/math/react/index.d.ts +4 -3
  165. package/dist/migrations/index.d.ts +3 -3
  166. package/dist/pagination/index.d.ts +1 -1
  167. package/dist/pagination/react/index.d.ts +4 -4
  168. package/dist/react/components/EditorContentView.internal.js +17 -8
  169. package/dist/react/components/EditorProvider.js +5 -5
  170. package/dist/react/components/Plate.js +103 -122
  171. package/dist/react/components/PlateContainer.js +40 -32
  172. package/dist/react/components/PlateController.js +28 -16
  173. package/dist/react/components/PlateRoot.internal.js +3 -2
  174. package/dist/react/core.js +4 -4
  175. package/dist/react/features/board/BoardSurface.js +116 -87
  176. package/dist/react/features/board/boardClipboard.internal.js +15 -5
  177. package/dist/react/features/board/boardGesture.internal.js +6 -3
  178. package/dist/react/features/board/boardIndex.internal.js +7 -18
  179. package/dist/react/features/board/boardPictures.internal.js +19 -13
  180. package/dist/react/features/board/boardView.internal.js +184 -49
  181. package/dist/react/features/board/boardVoice.internal.js +10 -11
  182. package/dist/react/features/board/index.d.ts +64 -18
  183. package/dist/react/features/callout/index.d.ts +3 -2
  184. package/dist/react/features/combobox/index.d.ts +8 -8
  185. package/dist/react/features/comments/index.d.ts +6 -5
  186. package/dist/react/features/date/index.d.ts +4 -3
  187. package/dist/react/features/details/index.d.ts +4 -3
  188. package/dist/react/features/field/FieldPlugin.js +34 -0
  189. package/dist/react/features/field/index.d.ts +312 -0
  190. package/dist/react/features/field/index.js +2 -0
  191. package/dist/react/features/footnote/index.d.ts +7 -6
  192. package/dist/react/features/format-painter/index.d.ts +4 -3
  193. package/dist/react/features/ink/InkContent.js +313 -0
  194. package/dist/react/features/ink/index.d.ts +57 -29
  195. package/dist/react/features/ink/index.js +2 -2
  196. package/dist/react/features/ink/inkCapture.internal.js +39 -17
  197. package/dist/react/features/ink/inkInput.internal.js +1 -1
  198. package/dist/react/features/ink/inkLayout.internal.js +6 -3
  199. package/dist/react/features/ink/inkPaint.internal.js +78 -2
  200. package/dist/react/features/ink/inkPlacement.internal.js +331 -104
  201. package/dist/react/features/ink/inkWatch.internal.js +7 -5
  202. package/dist/react/features/layout/index.d.ts +5 -4
  203. package/dist/react/features/media/index.d.ts +5 -4
  204. package/dist/react/features/mention/index.d.ts +6 -5
  205. package/dist/react/features/resizable/Resizable.js +4 -6
  206. package/dist/react/features/resizable/index.d.ts +5 -5
  207. package/dist/react/features/suggestion/index.d.ts +6 -5
  208. package/dist/react/features/table/TablePlugin.js +4 -11
  209. package/dist/react/features/table/index.d.ts +8 -7
  210. package/dist/react/features/toc/index.d.ts +2 -2
  211. package/dist/react/features/upload/index.d.ts +11 -6
  212. package/dist/react/index.d.ts +6 -6
  213. package/dist/react/index.js +4 -4
  214. package/dist/react/internal/plate-context.js +425 -188
  215. package/dist/react/plite-react.js +2 -2
  216. package/dist/react/plugins/navigation-feedback/NavigationFeedbackPlugin.js +12 -10
  217. package/dist/react/stores/plate/useEditor.js +32 -14
  218. package/dist/react/stores/plate/useEditorHistory.js +55 -0
  219. package/dist/react/stores/plate/useEditorSelector.js +66 -21
  220. package/dist/react/utils/pipeRenderElement.internal.js +1 -1
  221. package/dist/react/utils/pluginRenderElement.internal.js +1 -1
  222. package/dist/react/virtualized.d.ts +4 -4
  223. package/dist/{source-CNKy99Th.d.ts → source-aUwpNnAw.d.ts} +4 -4
  224. package/dist/static/index.d.ts +18 -18
  225. package/dist/static/internal/renderStaticHtmlWithOverrides.js +2 -2
  226. package/dist/static/internal/staticPresentation.js +4 -4
  227. package/dist/static/internal/writeStaticSelectionClipboardData.js +7 -2
  228. package/dist/tabbable/index.d.ts +1 -1
  229. package/dist/tabbable/react/index.d.ts +3 -3
  230. package/dist/testing/index.d.ts +3 -3
  231. package/dist/yjs/index.d.ts +1 -1
  232. package/dist/yjs/react/index.d.ts +6 -6
  233. package/package.json +20 -2
  234. package/dist/markdown/lib/serializer/convertTextsSerialize.js +0 -163
  235. package/dist/react/components/EditorSelectionView.js +0 -40
  236. package/dist/react/features/ink/InkLayer.js +0 -218
  237. package/dist/react/internal/createPlateTargetScope.js +0 -62
@@ -0,0 +1,678 @@
1
+ import { Qo as PropertyJsonDescriptor, Ws as SchemaElementPropertyDefinition, Yo as PropertyBooleanDescriptor, Zo as PropertyEnumDescriptor, eu as TxDeclaredMethod, is as PropertyStringDescriptor, ki as ElementOf, ls as PropertyValueOptions } from "./index-DpltOCot-A2b3p3Eb.js";
2
+ import "./htmlTypes-cg_cWsaN.js";
3
+ import { _ as BasePlugin, _t as NodeInsertOptions } from "./core-ClHasORr.js";
4
+ import { nanoid } from "nanoid";
5
+ declare const FIELD_KINDS: readonly ['checkbox', 'choice', 'date', 'number', 'signature', 'text'];
6
+ /** What a field collects, which fixes the shape of its value. */
7
+ type FieldKind = (typeof FIELD_KINDS)[number];
8
+ /** A value a field stores: a string, a finite number or a boolean. */
9
+ type FieldValue = boolean | number | string;
10
+ /** One answer a `choice` field offers. A choice stores the `value`. */
11
+ type FieldOption = Readonly<{
12
+ label: string;
13
+ value: string;
14
+ }>;
15
+ /** How a condition judges the value of the field it names. */
16
+ type FieldTest = 'above' | 'below' | 'blank' | 'equals' | 'filled' | 'not-equals';
17
+ /**
18
+ * When a field applies: the field whose `fieldId` is `ref` passes `test`.
19
+ * Every test but `filled` and `blank` compares against `value`.
20
+ */
21
+ type FieldCondition = Readonly<{
22
+ ref: string;
23
+ test: FieldTest;
24
+ value?: FieldValue;
25
+ }>;
26
+ /**
27
+ * What a read finds wrong with a field. `missing-target`: no field holds the
28
+ * id its condition names. `unsupported-test`: the target's kind does not take
29
+ * the condition's test. `invalid-value`: its value, default or options do not
30
+ * fit its kind, or its condition's value does not fit its test or the
31
+ * target's kind. `condition-loop`: its condition names a field whose chain of
32
+ * conditions leads back to it.
33
+ */
34
+ type FieldProblem = 'condition-loop' | 'invalid-value' | 'missing-target' | 'unsupported-test';
35
+ /**
36
+ * The tests a condition may use on a field of each kind. `insert` and `update`
37
+ * refuse any other test, and a read reports it as `unsupported-test`.
38
+ */
39
+ declare const FIELD_TESTS: Readonly<Record<FieldKind, readonly FieldTest[]>>;
40
+ declare const isFieldValue: (value: unknown) => value is FieldValue;
41
+ declare const isFieldOptions: (value: unknown) => value is readonly FieldOption[];
42
+ declare const isFieldCondition: (value: unknown) => value is FieldCondition;
43
+ declare const fieldSchemaPlugin: BasePlugin<Readonly<{
44
+ formats: true;
45
+ }> & Readonly<{
46
+ name: "field";
47
+ }> & Readonly<Record<never, never>> & Readonly<{
48
+ initialState: {
49
+ readonly fillRole: string | null;
50
+ };
51
+ }> & Readonly<{
52
+ __pluginWritableProperties: Readonly<{
53
+ descriptor: PropertyJsonDescriptor<Readonly<{
54
+ ref: string;
55
+ test: FieldTest;
56
+ value?: FieldValue;
57
+ }>, {
58
+ readonly validate: typeof isFieldCondition;
59
+ readonly validationVersion: 1;
60
+ } & Readonly<{
61
+ default?: Readonly<{
62
+ ref: string;
63
+ test: FieldTest;
64
+ value?: FieldValue;
65
+ }> | undefined;
66
+ generate?: (() => Readonly<{
67
+ ref: string;
68
+ test: FieldTest;
69
+ value?: FieldValue;
70
+ }>) | undefined;
71
+ omitDefault?: boolean;
72
+ required?: boolean;
73
+ }> & Readonly<{
74
+ validate: (value: unknown) => value is Readonly<{
75
+ ref: string;
76
+ test: FieldTest;
77
+ value?: FieldValue;
78
+ }>;
79
+ validationVersion: number;
80
+ }>>;
81
+ key: "condition";
82
+ localId: "condition";
83
+ ownerName: "field";
84
+ placement: "element";
85
+ unaliased: true;
86
+ value: Readonly<{
87
+ ref: string;
88
+ test: FieldTest;
89
+ value?: FieldValue;
90
+ }>;
91
+ }> | Readonly<{
92
+ descriptor: PropertyJsonDescriptor<FieldValue, {
93
+ readonly validate: typeof isFieldValue;
94
+ readonly validationVersion: 1;
95
+ } & Readonly<{
96
+ default?: FieldValue | undefined;
97
+ generate?: (() => FieldValue) | undefined;
98
+ omitDefault?: boolean;
99
+ required?: boolean;
100
+ }> & Readonly<{
101
+ validate: (value: unknown) => value is FieldValue;
102
+ validationVersion: number;
103
+ }>>;
104
+ key: "defaultValue";
105
+ localId: "defaultValue";
106
+ ownerName: "field";
107
+ placement: "element";
108
+ unaliased: true;
109
+ value: string | number | boolean;
110
+ }> | Readonly<{
111
+ descriptor: PropertyStringDescriptor<{
112
+ readonly generate: typeof nanoid;
113
+ }>;
114
+ key: "fieldId";
115
+ localId: "fieldId";
116
+ ownerName: "field";
117
+ placement: "element";
118
+ unaliased: true;
119
+ value: string;
120
+ }> | Readonly<{
121
+ descriptor: PropertyEnumDescriptor<readonly ["checkbox", "choice", "date", "number", "signature", "text"], {
122
+ readonly required: true;
123
+ }>;
124
+ key: "kind";
125
+ localId: "kind";
126
+ ownerName: "field";
127
+ placement: "element";
128
+ unaliased: true;
129
+ value: "checkbox" | "choice" | "date" | "number" | "signature" | "text";
130
+ }> | Readonly<{
131
+ descriptor: PropertyStringDescriptor<{
132
+ readonly required: true;
133
+ }>;
134
+ key: "label";
135
+ localId: "label";
136
+ ownerName: "field";
137
+ placement: "element";
138
+ unaliased: true;
139
+ value: string;
140
+ }> | Readonly<{
141
+ descriptor: PropertyJsonDescriptor<readonly Readonly<{
142
+ label: string;
143
+ value: string;
144
+ }>[], {
145
+ readonly validate: typeof isFieldOptions;
146
+ readonly validationVersion: 1;
147
+ } & Readonly<{
148
+ default?: readonly Readonly<{
149
+ label: string;
150
+ value: string;
151
+ }>[] | undefined;
152
+ generate?: (() => readonly Readonly<{
153
+ label: string;
154
+ value: string;
155
+ }>[]) | undefined;
156
+ omitDefault?: boolean;
157
+ required?: boolean;
158
+ }> & Readonly<{
159
+ validate: (value: unknown) => value is readonly Readonly<{
160
+ label: string;
161
+ value: string;
162
+ }>[];
163
+ validationVersion: number;
164
+ }>>;
165
+ key: "options";
166
+ localId: "options";
167
+ ownerName: "field";
168
+ placement: "element";
169
+ unaliased: true;
170
+ value: readonly Readonly<{
171
+ label: string;
172
+ value: string;
173
+ }>[];
174
+ }> | Readonly<{
175
+ descriptor: PropertyBooleanDescriptor<PropertyValueOptions<boolean>>;
176
+ key: "required";
177
+ localId: "required";
178
+ ownerName: "field";
179
+ placement: "element";
180
+ unaliased: true;
181
+ value: boolean;
182
+ }> | Readonly<{
183
+ descriptor: PropertyStringDescriptor<{
184
+ readonly required: true;
185
+ }>;
186
+ key: "role";
187
+ localId: "role";
188
+ ownerName: "field";
189
+ placement: "element";
190
+ unaliased: true;
191
+ value: string;
192
+ }> | Readonly<{
193
+ descriptor: PropertyJsonDescriptor<FieldValue, {
194
+ readonly validate: typeof isFieldValue;
195
+ readonly validationVersion: 1;
196
+ } & Readonly<{
197
+ default?: FieldValue | undefined;
198
+ generate?: (() => FieldValue) | undefined;
199
+ omitDefault?: boolean;
200
+ required?: boolean;
201
+ }> & Readonly<{
202
+ validate: (value: unknown) => value is FieldValue;
203
+ validationVersion: number;
204
+ }>>;
205
+ key: "value";
206
+ localId: "value";
207
+ ownerName: "field";
208
+ placement: "element";
209
+ unaliased: true;
210
+ value: string | number | boolean;
211
+ }>;
212
+ schema: {
213
+ readonly element: {
214
+ readonly properties: {
215
+ defaultValue: PropertyJsonDescriptor<FieldValue, {
216
+ readonly validate: typeof isFieldValue;
217
+ readonly validationVersion: 1;
218
+ } & Readonly<{
219
+ default?: FieldValue | undefined;
220
+ generate?: (() => FieldValue) | undefined;
221
+ omitDefault?: boolean;
222
+ required?: boolean;
223
+ }> & Readonly<{
224
+ validate: (value: unknown) => value is FieldValue;
225
+ validationVersion: number;
226
+ }>>;
227
+ kind: PropertyEnumDescriptor<readonly ["checkbox", "choice", "date", "number", "signature", "text"], {
228
+ readonly required: true;
229
+ }>;
230
+ label: PropertyStringDescriptor<{
231
+ readonly required: true;
232
+ }>;
233
+ options: PropertyJsonDescriptor<readonly Readonly<{
234
+ label: string;
235
+ value: string;
236
+ }>[], {
237
+ readonly validate: typeof isFieldOptions;
238
+ readonly validationVersion: 1;
239
+ } & Readonly<{
240
+ default?: readonly Readonly<{
241
+ label: string;
242
+ value: string;
243
+ }>[] | undefined;
244
+ generate?: (() => readonly Readonly<{
245
+ label: string;
246
+ value: string;
247
+ }>[]) | undefined;
248
+ omitDefault?: boolean;
249
+ required?: boolean;
250
+ }> & Readonly<{
251
+ validate: (value: unknown) => value is readonly Readonly<{
252
+ label: string;
253
+ value: string;
254
+ }>[];
255
+ validationVersion: number;
256
+ }>>;
257
+ required: PropertyBooleanDescriptor<PropertyValueOptions<boolean>>;
258
+ role: PropertyStringDescriptor<{
259
+ readonly required: true;
260
+ }>;
261
+ value: PropertyJsonDescriptor<FieldValue, {
262
+ readonly validate: typeof isFieldValue;
263
+ readonly validationVersion: 1;
264
+ } & Readonly<{
265
+ default?: FieldValue | undefined;
266
+ generate?: (() => FieldValue) | undefined;
267
+ omitDefault?: boolean;
268
+ required?: boolean;
269
+ }> & Readonly<{
270
+ validate: (value: unknown) => value is FieldValue;
271
+ validationVersion: number;
272
+ }>>;
273
+ };
274
+ readonly void: "inline";
275
+ };
276
+ readonly properties: {
277
+ condition: SchemaElementPropertyDefinition<PropertyJsonDescriptor<Readonly<{
278
+ ref: string;
279
+ test: FieldTest;
280
+ value?: FieldValue;
281
+ }>, {
282
+ readonly validate: typeof isFieldCondition;
283
+ readonly validationVersion: 1;
284
+ } & Readonly<{
285
+ default?: Readonly<{
286
+ ref: string;
287
+ test: FieldTest;
288
+ value?: FieldValue;
289
+ }> | undefined;
290
+ generate?: (() => Readonly<{
291
+ ref: string;
292
+ test: FieldTest;
293
+ value?: FieldValue;
294
+ }>) | undefined;
295
+ omitDefault?: boolean;
296
+ required?: boolean;
297
+ }> & Readonly<{
298
+ validate: (value: unknown) => value is Readonly<{
299
+ ref: string;
300
+ test: FieldTest;
301
+ value?: FieldValue;
302
+ }>;
303
+ validationVersion: number;
304
+ }>>, Readonly<{
305
+ kind: 'types';
306
+ types: readonly ["field"];
307
+ }>, Readonly<{
308
+ key: string;
309
+ map: (value: Readonly<{
310
+ ref: string;
311
+ test: FieldTest;
312
+ value?: FieldValue;
313
+ }>, renamed: (name: string) => string | undefined) => Readonly<{
314
+ ref: string;
315
+ test: FieldTest;
316
+ value?: FieldValue;
317
+ }>;
318
+ }>>;
319
+ fieldId: SchemaElementPropertyDefinition<PropertyStringDescriptor<{
320
+ readonly generate: typeof nanoid;
321
+ }>, Readonly<{
322
+ kind: 'types';
323
+ types: readonly ["field"];
324
+ }>, Readonly<{
325
+ key: string;
326
+ map: (value: string, renamed: (name: string) => string | undefined) => string;
327
+ }>>;
328
+ };
329
+ };
330
+ }>>;
331
+ /** A field: an inline void that collects one value of its `kind`. */
332
+ type FieldElement = ElementOf<typeof fieldSchemaPlugin>;
333
+ /** What `insert` takes: a field's kind, role and label, with its settings. */
334
+ type FieldSettings = Omit<FieldElement, 'children' | 'fieldId' | 'type'>;
335
+ /**
336
+ * What `update` changes. An optional setting given as `undefined` is removed.
337
+ */
338
+ type FieldPatch = Partial<FieldSettings>;
339
+ /** A field as the plugin reads it, with what the read finds wrong with it. */
340
+ type FieldRead = Readonly<{
341
+ fieldId: string;
342
+ node: FieldElement;
343
+ problems: readonly FieldProblem[];
344
+ }>;
345
+ type FieldShape = Pick<FieldSettings, 'defaultValue' | 'kind' | 'options' | 'value'>;
346
+ /**
347
+ * Whether a value fits a field's kind: a boolean for a checkbox, one of its
348
+ * options' values for a choice, an ISO date string for a date, a finite number
349
+ * other than -0 for a number, a string with no line break for a text field,
350
+ * and a string for a signature field.
351
+ */
352
+ declare const fitsField: ({ kind, options }: FieldShape, value: unknown) => value is FieldValue;
353
+ /**
354
+ * Fields: inline voids that each collect one value of a kind and hold a
355
+ * document-wide unique `fieldId`. A field's `condition` names another field
356
+ * by that id, so a paste that copies both names the copy.
357
+ */
358
+ declare const BaseFieldPlugin: BasePlugin<Readonly<{
359
+ readonly __pluginWritableProperties: Readonly<{
360
+ descriptor: PropertyJsonDescriptor<Readonly<{
361
+ ref: string;
362
+ test: FieldTest;
363
+ value?: FieldValue;
364
+ }>, {
365
+ readonly validate: typeof isFieldCondition;
366
+ readonly validationVersion: 1;
367
+ } & Readonly<{
368
+ default?: Readonly<{
369
+ ref: string;
370
+ test: FieldTest;
371
+ value?: FieldValue;
372
+ }> | undefined;
373
+ generate?: (() => Readonly<{
374
+ ref: string;
375
+ test: FieldTest;
376
+ value?: FieldValue;
377
+ }>) | undefined;
378
+ omitDefault?: boolean;
379
+ required?: boolean;
380
+ }> & Readonly<{
381
+ validate: (value: unknown) => value is Readonly<{
382
+ ref: string;
383
+ test: FieldTest;
384
+ value?: FieldValue;
385
+ }>;
386
+ validationVersion: number;
387
+ }>>;
388
+ key: "condition";
389
+ localId: "condition";
390
+ ownerName: "field";
391
+ placement: "element";
392
+ unaliased: true;
393
+ value: Readonly<{
394
+ ref: string;
395
+ test: FieldTest;
396
+ value?: FieldValue;
397
+ }>;
398
+ }> | Readonly<{
399
+ descriptor: PropertyJsonDescriptor<FieldValue, {
400
+ readonly validate: typeof isFieldValue;
401
+ readonly validationVersion: 1;
402
+ } & Readonly<{
403
+ default?: FieldValue | undefined;
404
+ generate?: (() => FieldValue) | undefined;
405
+ omitDefault?: boolean;
406
+ required?: boolean;
407
+ }> & Readonly<{
408
+ validate: (value: unknown) => value is FieldValue;
409
+ validationVersion: number;
410
+ }>>;
411
+ key: "defaultValue";
412
+ localId: "defaultValue";
413
+ ownerName: "field";
414
+ placement: "element";
415
+ unaliased: true;
416
+ value: string | number | boolean;
417
+ }> | Readonly<{
418
+ descriptor: PropertyStringDescriptor<{
419
+ readonly generate: typeof nanoid;
420
+ }>;
421
+ key: "fieldId";
422
+ localId: "fieldId";
423
+ ownerName: "field";
424
+ placement: "element";
425
+ unaliased: true;
426
+ value: string;
427
+ }> | Readonly<{
428
+ descriptor: PropertyEnumDescriptor<readonly ["checkbox", "choice", "date", "number", "signature", "text"], {
429
+ readonly required: true;
430
+ }>;
431
+ key: "kind";
432
+ localId: "kind";
433
+ ownerName: "field";
434
+ placement: "element";
435
+ unaliased: true;
436
+ value: "checkbox" | "choice" | "date" | "number" | "signature" | "text";
437
+ }> | Readonly<{
438
+ descriptor: PropertyStringDescriptor<{
439
+ readonly required: true;
440
+ }>;
441
+ key: "label";
442
+ localId: "label";
443
+ ownerName: "field";
444
+ placement: "element";
445
+ unaliased: true;
446
+ value: string;
447
+ }> | Readonly<{
448
+ descriptor: PropertyJsonDescriptor<readonly Readonly<{
449
+ label: string;
450
+ value: string;
451
+ }>[], {
452
+ readonly validate: typeof isFieldOptions;
453
+ readonly validationVersion: 1;
454
+ } & Readonly<{
455
+ default?: readonly Readonly<{
456
+ label: string;
457
+ value: string;
458
+ }>[] | undefined;
459
+ generate?: (() => readonly Readonly<{
460
+ label: string;
461
+ value: string;
462
+ }>[]) | undefined;
463
+ omitDefault?: boolean;
464
+ required?: boolean;
465
+ }> & Readonly<{
466
+ validate: (value: unknown) => value is readonly Readonly<{
467
+ label: string;
468
+ value: string;
469
+ }>[];
470
+ validationVersion: number;
471
+ }>>;
472
+ key: "options";
473
+ localId: "options";
474
+ ownerName: "field";
475
+ placement: "element";
476
+ unaliased: true;
477
+ value: readonly Readonly<{
478
+ label: string;
479
+ value: string;
480
+ }>[];
481
+ }> | Readonly<{
482
+ descriptor: PropertyBooleanDescriptor<PropertyValueOptions<boolean>>;
483
+ key: "required";
484
+ localId: "required";
485
+ ownerName: "field";
486
+ placement: "element";
487
+ unaliased: true;
488
+ value: boolean;
489
+ }> | Readonly<{
490
+ descriptor: PropertyStringDescriptor<{
491
+ readonly required: true;
492
+ }>;
493
+ key: "role";
494
+ localId: "role";
495
+ ownerName: "field";
496
+ placement: "element";
497
+ unaliased: true;
498
+ value: string;
499
+ }> | Readonly<{
500
+ descriptor: PropertyJsonDescriptor<FieldValue, {
501
+ readonly validate: typeof isFieldValue;
502
+ readonly validationVersion: 1;
503
+ } & Readonly<{
504
+ default?: FieldValue | undefined;
505
+ generate?: (() => FieldValue) | undefined;
506
+ omitDefault?: boolean;
507
+ required?: boolean;
508
+ }> & Readonly<{
509
+ validate: (value: unknown) => value is FieldValue;
510
+ validationVersion: number;
511
+ }>>;
512
+ key: "value";
513
+ localId: "value";
514
+ ownerName: "field";
515
+ placement: "element";
516
+ unaliased: true;
517
+ value: string | number | boolean;
518
+ }>;
519
+ readonly schema: {
520
+ readonly element: {
521
+ readonly properties: {
522
+ defaultValue: PropertyJsonDescriptor<FieldValue, {
523
+ readonly validate: typeof isFieldValue;
524
+ readonly validationVersion: 1;
525
+ } & Readonly<{
526
+ default?: FieldValue | undefined;
527
+ generate?: (() => FieldValue) | undefined;
528
+ omitDefault?: boolean;
529
+ required?: boolean;
530
+ }> & Readonly<{
531
+ validate: (value: unknown) => value is FieldValue;
532
+ validationVersion: number;
533
+ }>>;
534
+ kind: PropertyEnumDescriptor<readonly ["checkbox", "choice", "date", "number", "signature", "text"], {
535
+ readonly required: true;
536
+ }>;
537
+ label: PropertyStringDescriptor<{
538
+ readonly required: true;
539
+ }>;
540
+ options: PropertyJsonDescriptor<readonly Readonly<{
541
+ label: string;
542
+ value: string;
543
+ }>[], {
544
+ readonly validate: typeof isFieldOptions;
545
+ readonly validationVersion: 1;
546
+ } & Readonly<{
547
+ default?: readonly Readonly<{
548
+ label: string;
549
+ value: string;
550
+ }>[] | undefined;
551
+ generate?: (() => readonly Readonly<{
552
+ label: string;
553
+ value: string;
554
+ }>[]) | undefined;
555
+ omitDefault?: boolean;
556
+ required?: boolean;
557
+ }> & Readonly<{
558
+ validate: (value: unknown) => value is readonly Readonly<{
559
+ label: string;
560
+ value: string;
561
+ }>[];
562
+ validationVersion: number;
563
+ }>>;
564
+ required: PropertyBooleanDescriptor<PropertyValueOptions<boolean>>;
565
+ role: PropertyStringDescriptor<{
566
+ readonly required: true;
567
+ }>;
568
+ value: PropertyJsonDescriptor<FieldValue, {
569
+ readonly validate: typeof isFieldValue;
570
+ readonly validationVersion: 1;
571
+ } & Readonly<{
572
+ default?: FieldValue | undefined;
573
+ generate?: (() => FieldValue) | undefined;
574
+ omitDefault?: boolean;
575
+ required?: boolean;
576
+ }> & Readonly<{
577
+ validate: (value: unknown) => value is FieldValue;
578
+ validationVersion: number;
579
+ }>>;
580
+ };
581
+ readonly void: "inline";
582
+ };
583
+ readonly properties: {
584
+ condition: SchemaElementPropertyDefinition<PropertyJsonDescriptor<Readonly<{
585
+ ref: string;
586
+ test: FieldTest;
587
+ value?: FieldValue;
588
+ }>, {
589
+ readonly validate: typeof isFieldCondition;
590
+ readonly validationVersion: 1;
591
+ } & Readonly<{
592
+ default?: Readonly<{
593
+ ref: string;
594
+ test: FieldTest;
595
+ value?: FieldValue;
596
+ }> | undefined;
597
+ generate?: (() => Readonly<{
598
+ ref: string;
599
+ test: FieldTest;
600
+ value?: FieldValue;
601
+ }>) | undefined;
602
+ omitDefault?: boolean;
603
+ required?: boolean;
604
+ }> & Readonly<{
605
+ validate: (value: unknown) => value is Readonly<{
606
+ ref: string;
607
+ test: FieldTest;
608
+ value?: FieldValue;
609
+ }>;
610
+ validationVersion: number;
611
+ }>>, Readonly<{
612
+ kind: 'types';
613
+ types: readonly ["field"];
614
+ }>, Readonly<{
615
+ key: string;
616
+ map: (value: Readonly<{
617
+ ref: string;
618
+ test: FieldTest;
619
+ value?: FieldValue;
620
+ }>, renamed: (name: string) => string | undefined) => Readonly<{
621
+ ref: string;
622
+ test: FieldTest;
623
+ value?: FieldValue;
624
+ }>;
625
+ }>>;
626
+ fieldId: SchemaElementPropertyDefinition<PropertyStringDescriptor<{
627
+ readonly generate: typeof nanoid;
628
+ }>, Readonly<{
629
+ kind: 'types';
630
+ types: readonly ["field"];
631
+ }>, Readonly<{
632
+ key: string;
633
+ map: (value: string, renamed: (name: string) => string | undefined) => string;
634
+ }>>;
635
+ };
636
+ };
637
+ readonly name: "field";
638
+ readonly activate: true;
639
+ readonly corrections: true;
640
+ readonly formats: true;
641
+ readonly initialState: {
642
+ readonly fillRole: string | null;
643
+ };
644
+ readonly read: {
645
+ /**
646
+ * The field whose `fieldId` is `fieldId`, in any root, or null when
647
+ * no field holds it. Looks up the field, then one field for each
648
+ * condition it follows along the chain.
649
+ */
650
+ readonly field: (fieldId: string) => FieldRead | null;
651
+ /** Every field of the document, in reading order. */
652
+ readonly fields: () => FieldRead[];
653
+ };
654
+ readonly update: {
655
+ /**
656
+ * Insert a field and return its new `fieldId`. Throws when a value,
657
+ * default or options do not fit `kind`, or the condition names no
658
+ * field, or a test or value the named field's kind does not take,
659
+ * or the settings name a `fieldId`.
660
+ */
661
+ readonly insert: TxDeclaredMethod<(settings: FieldSettings, options?: NodeInsertOptions) => string>;
662
+ /**
663
+ * Change the settings or value of the field whose `fieldId` is
664
+ * `fieldId`. A new kind or new options drop each value, default or
665
+ * options the patch leaves out and the field no longer fits. Throws,
666
+ * and changes nothing, when no field holds `fieldId`, a setting the
667
+ * patch names does not fit the field's kind, the patch removes `kind`,
668
+ * `role` or `label` or names `fieldId`, or its condition names no
669
+ * field, a test or value the named field's kind does not take, or a
670
+ * field it did not name before whose chain of conditions leads back
671
+ * to this one. While a fill role is set, a missing field or a
672
+ * setting that does not fit refuses the whole update instead, which
673
+ * then returns `undefined`.
674
+ */
675
+ readonly update: TxDeclaredMethod<(fieldId: string, patch: FieldPatch) => void>;
676
+ };
677
+ }>> & Readonly<Record<never, never>>;
678
+ export { FieldKind as a, FieldProblem as c, FieldTest as d, FieldValue as f, FieldElement as i, FieldRead as l, FIELD_TESTS as n, FieldOption as o, fitsField as p, FieldCondition as r, FieldPatch as s, BaseFieldPlugin as t, FieldSettings as u };