@openeditor/core 0.0.34 → 0.0.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,7 +19,10 @@ escape hatch rather than a public-rendering default.
19
19
 
20
20
  - `OpenEditorDocument` and related types
21
21
  - document creation, normalization, validation, parsing, and platform support helpers
22
- - strict `parseOpenEditorDocument` for versioned documents and explicit `importProseMirrorDocument` for unversioned ProseMirror JSON
22
+ - strict, non-repairing `parseOpenEditorDocument` for versioned documents and explicit `importProseMirrorDocument` for unversioned ProseMirror JSON
23
+ - portable document contracts for configured node types, marks, content, attributes, custom validators, and schema versions
24
+ - structured validation diagnostics and configurable limits for untrusted document input
25
+ - deterministic canonical JSON fingerprints and revision precondition contracts
23
26
  - shared authoring capabilities and page metadata runtime contracts
24
27
  - platform-neutral command and transaction helpers
25
28
  - top-level block transforms and text extraction
@@ -28,3 +31,5 @@ escape hatch rather than a public-rendering default.
28
31
 
29
32
  - Renderer implementations should adapt at their package boundary, not by inventing their own document shape.
30
33
  - This package owns the stable cross-platform contract and should stay free of web/native runtime dependencies.
34
+ - Normalization and repair are explicit operations. Strict parsing never silently changes persisted input.
35
+ - `fingerprintOpenEditorDocument` is intended for optimistic concurrency and diff identity, not cryptographic authentication.
package/dist/index.d.ts CHANGED
@@ -38,11 +38,14 @@ type OpenEditorDocumentMeta = {
38
38
  createdAt?: string;
39
39
  updatedAt?: string;
40
40
  platform?: EditorPlatform;
41
+ /** Consumer-defined schema version. The OpenEditor JSON format remains independently versioned. */
42
+ schemaVersion?: string;
41
43
  custom?: Record<string, unknown>;
42
44
  };
45
+ declare const OPENEDITOR_DOCUMENT_FORMAT_VERSION: 1;
43
46
  type OpenEditorDocument = {
44
47
  type: "doc";
45
- version: 1;
48
+ version: typeof OPENEDITOR_DOCUMENT_FORMAT_VERSION;
46
49
  content: OpenEditorBlock[];
47
50
  meta?: OpenEditorDocumentMeta;
48
51
  };
@@ -66,8 +69,86 @@ type BlockSpec = {
66
69
  defaultNode: () => OpenEditorBlock;
67
70
  matchNode?: (node: ProseMirrorNode) => boolean;
68
71
  support?: PlatformSupport;
72
+ /** Optional portable contract used by server-side validation and schema-aware consumers. */
73
+ schema?: Omit<OpenEditorNodeSpec, "type">;
69
74
  };
70
75
  type BlockRegistry = ReadonlyMap<string, BlockSpec>;
76
+ type OpenEditorValueValidationContext = {
77
+ path: string;
78
+ };
79
+ type OpenEditorValueValidator = (value: unknown, context: OpenEditorValueValidationContext) => string | readonly string[] | null | undefined;
80
+ type OpenEditorValueSchemaBase = {
81
+ nullable?: boolean;
82
+ enum?: readonly JsonValue[];
83
+ validate?: OpenEditorValueValidator;
84
+ };
85
+ type OpenEditorValueSchema = OpenEditorValueSchemaBase & ({
86
+ type: "any";
87
+ } | {
88
+ type: "string";
89
+ minLength?: number;
90
+ maxLength?: number;
91
+ pattern?: string;
92
+ } | {
93
+ type: "number";
94
+ integer?: boolean;
95
+ minimum?: number;
96
+ maximum?: number;
97
+ } | {
98
+ type: "boolean";
99
+ } | {
100
+ type: "null";
101
+ } | {
102
+ type: "array";
103
+ items?: OpenEditorValueSchema;
104
+ minItems?: number;
105
+ maxItems?: number;
106
+ } | {
107
+ type: "object";
108
+ properties?: Readonly<Record<string, OpenEditorValueSchema>>;
109
+ required?: readonly string[];
110
+ additionalProperties?: boolean | OpenEditorValueSchema;
111
+ });
112
+ type OpenEditorAttributesSpec = {
113
+ properties?: Readonly<Record<string, OpenEditorValueSchema>>;
114
+ required?: readonly string[];
115
+ /** Defaults to false for contract-aware validation. */
116
+ additionalProperties?: boolean | OpenEditorValueSchema;
117
+ };
118
+ type OpenEditorContentSpec = {
119
+ allowedTypes?: readonly string[];
120
+ minItems?: number;
121
+ maxItems?: number;
122
+ };
123
+ type OpenEditorNodeValidator = (node: ProseMirrorNode, context: OpenEditorValueValidationContext) => string | readonly string[] | null | undefined;
124
+ /** Portable validation contract for one ProseMirror node type. */
125
+ type OpenEditorNodeSpec = {
126
+ type: string;
127
+ attributes?: OpenEditorAttributesSpec;
128
+ content?: OpenEditorContentSpec | false;
129
+ text?: "required" | "allowed" | "forbidden";
130
+ marks?: false | readonly string[];
131
+ validate?: OpenEditorNodeValidator;
132
+ };
133
+ type OpenEditorMarkSpec = {
134
+ type: string;
135
+ attributes?: OpenEditorAttributesSpec;
136
+ };
137
+ type OpenEditorDocumentContract = {
138
+ formatVersion: typeof OPENEDITOR_DOCUMENT_FORMAT_VERSION;
139
+ schemaVersion: string;
140
+ /** Optional portable constraint for the document root's direct children. */
141
+ rootContent?: OpenEditorContentSpec;
142
+ nodes: ReadonlyMap<string, OpenEditorNodeSpec>;
143
+ marks: ReadonlyMap<string, OpenEditorMarkSpec>;
144
+ };
145
+ type CreateOpenEditorDocumentContractOptions = {
146
+ schemaVersion: string;
147
+ blockSpecs?: readonly BlockSpec[];
148
+ nodeSpecs?: readonly OpenEditorNodeSpec[];
149
+ markSpecs?: readonly OpenEditorMarkSpec[];
150
+ rootContent?: OpenEditorContentSpec;
151
+ };
71
152
  type EditorSelection = {
72
153
  type: "none";
73
154
  } | {
@@ -182,7 +263,7 @@ type OpenEditorPageRuntime = {
182
263
  icon?: string | null;
183
264
  }) => Promise<OpenEditorPageSnapshot>;
184
265
  resolvePage?: (pageId: string) => Promise<OpenEditorPageSnapshot | null>;
185
- updatePage: (pageId: string, update: OpenEditorPageUpdate) => Promise<OpenEditorPageSnapshot | void> | OpenEditorPageSnapshot | void;
266
+ updatePage?: (pageId: string, update: OpenEditorPageUpdate) => Promise<OpenEditorPageSnapshot | void> | OpenEditorPageSnapshot | void;
186
267
  openPage?: (page: OpenEditorPageSnapshot) => Promise<void> | void;
187
268
  };
188
269
  /** Built-in URL-bearing surfaces rendered from portable document data. */
@@ -278,11 +359,33 @@ type OpenEditorController = {
278
359
  type DocumentValidationIssue = {
279
360
  path: string;
280
361
  message: string;
362
+ code?: DocumentValidationCode;
281
363
  };
364
+ type DocumentValidationCode = "invalid_document" | "invalid_document_type" | "unsupported_format_version" | "schema_version_mismatch" | "invalid_meta" | "invalid_node" | "invalid_node_type" | "unknown_node_type" | "invalid_text" | "unexpected_text" | "invalid_attrs" | "missing_attribute" | "unknown_attribute" | "unknown_property" | "invalid_attribute" | "invalid_marks" | "invalid_mark" | "unknown_mark_type" | "disallowed_mark" | "invalid_content" | "disallowed_child" | "duplicate_node_id" | "missing_node_id" | "non_json_value" | "cyclic_value" | "limit_depth" | "limit_nodes" | "limit_marks" | "limit_text" | "limit_attributes" | "custom_validation";
282
365
  type DocumentValidationResult = {
283
366
  valid: boolean;
284
367
  issues: DocumentValidationIssue[];
285
368
  };
369
+ type DocumentValidationLimits = {
370
+ maxDepth: number;
371
+ maxNodes: number;
372
+ maxMarksPerNode: number;
373
+ maxTextLength: number;
374
+ maxTotalTextLength: number;
375
+ maxAttributeDepth: number;
376
+ maxArrayItems: number;
377
+ maxObjectKeys: number;
378
+ /** Global JSON value budget, including metadata and attributes. */
379
+ maxJsonValues: number;
380
+ requireNodeIds: boolean;
381
+ };
382
+ type ValidateDocumentOptions = {
383
+ contract?: OpenEditorDocumentContract;
384
+ limits?: Partial<DocumentValidationLimits>;
385
+ /** Reject a document whose meta.schemaVersion differs from the configured contract. */
386
+ requireSchemaVersion?: boolean;
387
+ };
388
+ declare const DEFAULT_DOCUMENT_VALIDATION_LIMITS: Readonly<DocumentValidationLimits>;
286
389
  type PlatformSupportIssue = {
287
390
  path: string;
288
391
  block: string;
@@ -310,13 +413,21 @@ declare const withBlockId: <T extends ProseMirrorNode>(node: T, id: string) => T
310
413
  declare const ensureBlockIds: (document: OpenEditorDocument, createId?: () => string) => OpenEditorDocument;
311
414
  declare const findBlockLocation: (document: OpenEditorDocument, id: string) => OpenEditorBlockLocation | null;
312
415
  declare const normalizeDocument: (document: OpenEditorDocument) => OpenEditorDocument;
313
- declare const validateDocument: (document: unknown) => DocumentValidationResult;
416
+ declare const createOpenEditorDocumentContract: ({ schemaVersion, blockSpecs, nodeSpecs, markSpecs, rootContent, }: CreateOpenEditorDocumentContractOptions) => OpenEditorDocumentContract;
417
+ /** Deterministic JSON serialization with lexicographically sorted object keys. */
418
+ declare const canonicalSerializeJson: (value: unknown) => string;
419
+ /**
420
+ * Stable non-cryptographic content fingerprint for optimistic concurrency and diffs.
421
+ * Security-sensitive integrity checks should use a cryptographic digest at the host boundary.
422
+ */
423
+ declare const fingerprintOpenEditorDocument: (document: OpenEditorDocument) => string;
424
+ declare const validateDocument: (document: unknown, options?: ValidateDocumentOptions) => DocumentValidationResult;
314
425
  declare const isOpenEditorDocument: (value: unknown) => value is OpenEditorDocument;
315
426
  declare class OpenEditorDocumentParseError extends Error {
316
427
  readonly validation: DocumentValidationResult;
317
428
  constructor(validation: DocumentValidationResult);
318
429
  }
319
- declare const parseOpenEditorDocument: (value: unknown) => OpenEditorDocument;
430
+ declare const parseOpenEditorDocument: (value: unknown, options?: ValidateDocumentOptions) => OpenEditorDocument;
320
431
  /** Imports unversioned ProseMirror JSON. Versioned values require strict OpenEditor parsing. */
321
432
  declare const importProseMirrorDocument: (value: unknown, meta?: OpenEditorDocumentMeta) => OpenEditorDocument;
322
433
  declare const serializeEditorState: (state: SerializedEditorState) => string;
@@ -332,4 +443,4 @@ declare const duplicateTopLevelBlock: (document: OpenEditorDocument, index: numb
332
443
  declare const deleteTopLevelBlock: (document: OpenEditorDocument, index: number, emptyBlock?: OpenEditorBlock) => OpenEditorDocument;
333
444
  declare const createTransaction: (before: OpenEditorDocument, after: OpenEditorDocument, command?: EditorCommand) => EditorTransaction;
334
445
 
335
- export { type BlockGroup, type BlockRegistry, type BlockSpec, DEFAULT_CALLOUT_EMOJI, DEFAULT_PAGE_EMOJI, type DocumentValidationIssue, type DocumentValidationResult, type EditorCommand, type EditorPlatform, type EditorSelection, type EditorTransaction, type JsonObject, type JsonPrimitive, type JsonValue, OPENEDITOR_BLOCK_ID_ATTR, type OpenEditorAttachmentRuntime, type OpenEditorAttachmentSnapshot, type OpenEditorAttachmentUploadCallbacks, type OpenEditorAttachmentUploadInput, type OpenEditorAttachmentValidationResult, type OpenEditorAuthoringCapabilities, type OpenEditorBlock, type OpenEditorBlockLocation, type OpenEditorBlockRef, type OpenEditorCommand, type OpenEditorConfig, type OpenEditorController, type OpenEditorDocument, type OpenEditorDocumentMeta, OpenEditorDocumentParseError, type OpenEditorEventHandlers, type OpenEditorFeatureName, type OpenEditorFeatureSet, type OpenEditorImageRuntime, type OpenEditorImageSnapshot, type OpenEditorImageUploadCallbacks, type OpenEditorImageUploadInput, type OpenEditorImageValidationResult, type OpenEditorMarkName, type OpenEditorPageRuntime, type OpenEditorPageSnapshot, type OpenEditorPageUpdate, type OpenEditorUrlContext, type OpenEditorUrlPolicy, type PlatformSupport, type PlatformSupportIssue, type PlatformSupportLevel, type PlatformSupportResult, type ProseMirrorAttrs, type ProseMirrorDocument, type ProseMirrorMark, type ProseMirrorNode, type SerializedEditorState, applyCommand, cloneNode, createAttachmentSnapshot, createBlockId, createBlockRegistry, createDocument, createEditorState, createTextNode, createTransaction, deleteTopLevelBlock, duplicateTopLevelBlock, ensureBlockIds, findBlockLocation, findBlockSpecForNode, fromProseMirrorDocument, getBlockId, getDocumentText, getPlatformDocument, getPlatformSupport, importProseMirrorDocument, isOpenEditorBlockEnabled, isOpenEditorDocument, moveTopLevelBlock, normalizeDocument, normalizeEmoji, openEditorPublicUrlPolicy, openEditorUnsafeUrlPolicy, parseEditorState, parseOpenEditorDocument, replaceTopLevelNode, replaceTopLevelRange, serializeEditorState, textBlock, toProseMirrorDocument, validateDocument, withBlockId };
446
+ export { type BlockGroup, type BlockRegistry, type BlockSpec, type CreateOpenEditorDocumentContractOptions, DEFAULT_CALLOUT_EMOJI, DEFAULT_DOCUMENT_VALIDATION_LIMITS, DEFAULT_PAGE_EMOJI, type DocumentValidationCode, type DocumentValidationIssue, type DocumentValidationLimits, type DocumentValidationResult, type EditorCommand, type EditorPlatform, type EditorSelection, type EditorTransaction, type JsonObject, type JsonPrimitive, type JsonValue, OPENEDITOR_BLOCK_ID_ATTR, OPENEDITOR_DOCUMENT_FORMAT_VERSION, type OpenEditorAttachmentRuntime, type OpenEditorAttachmentSnapshot, type OpenEditorAttachmentUploadCallbacks, type OpenEditorAttachmentUploadInput, type OpenEditorAttachmentValidationResult, type OpenEditorAttributesSpec, type OpenEditorAuthoringCapabilities, type OpenEditorBlock, type OpenEditorBlockLocation, type OpenEditorBlockRef, type OpenEditorCommand, type OpenEditorConfig, type OpenEditorContentSpec, type OpenEditorController, type OpenEditorDocument, type OpenEditorDocumentContract, type OpenEditorDocumentMeta, OpenEditorDocumentParseError, type OpenEditorEventHandlers, type OpenEditorFeatureName, type OpenEditorFeatureSet, type OpenEditorImageRuntime, type OpenEditorImageSnapshot, type OpenEditorImageUploadCallbacks, type OpenEditorImageUploadInput, type OpenEditorImageValidationResult, type OpenEditorMarkName, type OpenEditorMarkSpec, type OpenEditorNodeSpec, type OpenEditorNodeValidator, type OpenEditorPageRuntime, type OpenEditorPageSnapshot, type OpenEditorPageUpdate, type OpenEditorUrlContext, type OpenEditorUrlPolicy, type OpenEditorValueSchema, type OpenEditorValueValidationContext, type OpenEditorValueValidator, type PlatformSupport, type PlatformSupportIssue, type PlatformSupportLevel, type PlatformSupportResult, type ProseMirrorAttrs, type ProseMirrorDocument, type ProseMirrorMark, type ProseMirrorNode, type SerializedEditorState, type ValidateDocumentOptions, applyCommand, canonicalSerializeJson, cloneNode, createAttachmentSnapshot, createBlockId, createBlockRegistry, createDocument, createEditorState, createOpenEditorDocumentContract, createTextNode, createTransaction, deleteTopLevelBlock, duplicateTopLevelBlock, ensureBlockIds, findBlockLocation, findBlockSpecForNode, fingerprintOpenEditorDocument, fromProseMirrorDocument, getBlockId, getDocumentText, getPlatformDocument, getPlatformSupport, importProseMirrorDocument, isOpenEditorBlockEnabled, isOpenEditorDocument, moveTopLevelBlock, normalizeDocument, normalizeEmoji, openEditorPublicUrlPolicy, openEditorUnsafeUrlPolicy, parseEditorState, parseOpenEditorDocument, replaceTopLevelNode, replaceTopLevelRange, serializeEditorState, textBlock, toProseMirrorDocument, validateDocument, withBlockId };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/index.ts
2
+ var OPENEDITOR_DOCUMENT_FORMAT_VERSION = 1;
2
3
  var OPENEDITOR_URL_SCHEME = /^([a-z][a-z\d+.-]*):/i;
3
4
  var OPENEDITOR_URL_CONTROL_CHARACTER = /[\u0000-\u001f\u007f]/;
4
5
  var OPENEDITOR_PUBLIC_SCHEMES = {
@@ -29,6 +30,18 @@ var isOpenEditorBlockEnabled = (blockName, capabilities) => capabilities?.enable
29
30
  var DEFAULT_CALLOUT_EMOJI = "\u{1F4A1}";
30
31
  var DEFAULT_PAGE_EMOJI = "\u{1F4C4}";
31
32
  var normalizeEmoji = (value, fallback) => typeof value === "string" && value.trim() ? value.trim() : fallback;
33
+ var DEFAULT_DOCUMENT_VALIDATION_LIMITS = {
34
+ maxDepth: 128,
35
+ maxNodes: 1e5,
36
+ maxMarksPerNode: 64,
37
+ maxTextLength: 1e6,
38
+ maxTotalTextLength: 1e7,
39
+ maxAttributeDepth: 32,
40
+ maxArrayItems: 1e5,
41
+ maxObjectKeys: 1e4,
42
+ maxJsonValues: 5e5,
43
+ requireNodeIds: false
44
+ };
32
45
  var OPENEDITOR_BLOCK_ID_ATTR = "openeditor-id";
33
46
  var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
34
47
  var normalizeMeta = (meta) => meta && Object.keys(meta).length ? { ...meta } : void 0;
@@ -185,61 +198,382 @@ var normalizeNode = (node) => {
185
198
  };
186
199
  };
187
200
  var normalizeDocument = (document) => createDocument(document.content.map(normalizeNode), document.meta);
188
- var validateDocument = (document) => {
201
+ var cloneAndFreezeContractValue = (value) => {
202
+ if (!value || typeof value !== "object") return value;
203
+ if (Array.isArray(value)) {
204
+ return Object.freeze(value.map((child) => cloneAndFreezeContractValue(child)));
205
+ }
206
+ const clone = Object.fromEntries(Object.entries(value).map(
207
+ ([key, child]) => [key, cloneAndFreezeContractValue(child)]
208
+ ));
209
+ return Object.freeze(clone);
210
+ };
211
+ var createReadonlyMap = (source) => {
212
+ let view;
213
+ view = Object.freeze({
214
+ get size() {
215
+ return source.size;
216
+ },
217
+ get: (key) => source.get(key),
218
+ has: (key) => source.has(key),
219
+ entries: () => source.entries(),
220
+ keys: () => source.keys(),
221
+ values: () => source.values(),
222
+ forEach: (callback, thisArg) => {
223
+ source.forEach((value, key) => callback.call(thisArg, value, key, view));
224
+ },
225
+ [Symbol.iterator]: () => source[Symbol.iterator]()
226
+ });
227
+ return view;
228
+ };
229
+ var createOpenEditorDocumentContract = ({
230
+ schemaVersion,
231
+ blockSpecs = [],
232
+ nodeSpecs = [],
233
+ markSpecs = [],
234
+ rootContent
235
+ }) => {
236
+ if (!schemaVersion.trim()) throw new Error("OpenEditor schema versions must not be empty.");
237
+ const nodes = /* @__PURE__ */ new Map();
238
+ const marks = /* @__PURE__ */ new Map();
239
+ for (const block of blockSpecs) {
240
+ const type = block.nodeType ?? block.name;
241
+ if (nodes.has(type)) throw new Error(`Duplicate OpenEditor node contract "${type}".`);
242
+ nodes.set(type, cloneAndFreezeContractValue({ ...block.schema, type }));
243
+ }
244
+ for (const node of nodeSpecs) {
245
+ if (!node.type.trim()) throw new Error("OpenEditor node contract types must not be empty.");
246
+ if (nodes.has(node.type)) throw new Error(`Duplicate OpenEditor node contract "${node.type}".`);
247
+ nodes.set(node.type, cloneAndFreezeContractValue(node));
248
+ }
249
+ for (const mark of markSpecs) {
250
+ if (!mark.type.trim()) throw new Error("OpenEditor mark contract types must not be empty.");
251
+ if (marks.has(mark.type)) throw new Error(`Duplicate OpenEditor mark contract "${mark.type}".`);
252
+ marks.set(mark.type, cloneAndFreezeContractValue(mark));
253
+ }
254
+ return Object.freeze({
255
+ formatVersion: OPENEDITOR_DOCUMENT_FORMAT_VERSION,
256
+ schemaVersion,
257
+ ...rootContent ? { rootContent: cloneAndFreezeContractValue(rootContent) } : {},
258
+ nodes: createReadonlyMap(nodes),
259
+ marks: createReadonlyMap(marks)
260
+ });
261
+ };
262
+ var isPlainRecord = (value) => {
263
+ if (!isRecord(value)) return false;
264
+ const prototype = Object.getPrototypeOf(value);
265
+ return prototype === Object.prototype || prototype === null;
266
+ };
267
+ var formatJsonPathKey = (path, key) => /^[A-Za-z_$][\w$-]*$/.test(key) ? `${path}.${key}` : `${path}[${JSON.stringify(key)}]`;
268
+ var canonicalSerializeJson = (value) => {
269
+ const ancestors = /* @__PURE__ */ new Set();
270
+ const serialize = (input) => {
271
+ if (input === null || typeof input === "boolean" || typeof input === "string") {
272
+ return JSON.stringify(input);
273
+ }
274
+ if (typeof input === "number") {
275
+ if (!Number.isFinite(input)) throw new TypeError("Canonical JSON cannot serialize non-finite numbers.");
276
+ return JSON.stringify(input);
277
+ }
278
+ if (typeof input !== "object") throw new TypeError("Canonical JSON can only serialize JSON-safe values.");
279
+ if (!Array.isArray(input) && !isPlainRecord(input)) throw new TypeError("Canonical JSON objects must be plain objects.");
280
+ if (ancestors.has(input)) throw new TypeError("Canonical JSON cannot serialize cyclic values.");
281
+ ancestors.add(input);
282
+ let serialized;
283
+ if (Array.isArray(input)) {
284
+ serialized = `[${input.map(serialize).join(",")}]`;
285
+ } else {
286
+ serialized = `{${Object.keys(input).sort().map((key) => `${JSON.stringify(key)}:${serialize(input[key])}`).join(",")}}`;
287
+ }
288
+ ancestors.delete(input);
289
+ return serialized;
290
+ };
291
+ return serialize(value);
292
+ };
293
+ var fingerprintOpenEditorDocument = (document) => {
294
+ const serialized = canonicalSerializeJson(document);
295
+ let hash = 0xcbf29ce484222325n;
296
+ for (const byte of new TextEncoder().encode(serialized)) {
297
+ hash ^= BigInt(byte);
298
+ hash = BigInt.asUintN(64, hash * 0x100000001b3n);
299
+ }
300
+ return `oe1-fnv1a64-${hash.toString(16).padStart(16, "0")}`;
301
+ };
302
+ var validatorMessages = (validator, value, path) => {
303
+ if (!validator) return [];
304
+ try {
305
+ const result = validator(value, { path });
306
+ if (typeof result === "string") return [result];
307
+ return result ?? [];
308
+ } catch (error) {
309
+ return [error instanceof Error ? error.message : "Custom validator failed."];
310
+ }
311
+ };
312
+ var jsonValuesEqual = (left, right) => {
313
+ try {
314
+ return canonicalSerializeJson(left) === canonicalSerializeJson(right);
315
+ } catch {
316
+ return false;
317
+ }
318
+ };
319
+ var validateDocument = (document, options = {}) => {
189
320
  const issues = [];
190
- const push = (path, message) => issues.push({ path, message });
191
- const validateNode = (node, path) => {
321
+ const limits = { ...DEFAULT_DOCUMENT_VALIDATION_LIMITS, ...options.limits };
322
+ const push = (path, message, code) => issues.push({ path, message, code });
323
+ let nodeCount = 0;
324
+ let totalTextLength = 0;
325
+ let jsonValueCount = 0;
326
+ let jsonValueLimitReported = false;
327
+ const seenIds = /* @__PURE__ */ new Map();
328
+ const validateJsonValue = (value, path, depth, ancestors, maximumDepth = limits.maxAttributeDepth, countTowardsGlobalBudget = true) => {
329
+ if (countTowardsGlobalBudget) {
330
+ jsonValueCount += 1;
331
+ if (jsonValueCount > limits.maxJsonValues) {
332
+ if (!jsonValueLimitReported) {
333
+ push(path, `Document exceeds maximum JSON value count ${limits.maxJsonValues}.`, "limit_attributes");
334
+ jsonValueLimitReported = true;
335
+ }
336
+ return;
337
+ }
338
+ }
339
+ if (value === null || typeof value === "string" || typeof value === "boolean") return;
340
+ if (typeof value === "number") {
341
+ if (!Number.isFinite(value)) push(path, "Numbers must be finite JSON values.", "non_json_value");
342
+ return;
343
+ }
344
+ if (typeof value !== "object") {
345
+ push(path, "Value must be JSON-safe.", "non_json_value");
346
+ return;
347
+ }
348
+ if (ancestors.has(value)) {
349
+ push(path, "Cyclic values are not valid JSON.", "cyclic_value");
350
+ return;
351
+ }
352
+ if (depth > maximumDepth) {
353
+ push(path, `Value exceeds maximum depth ${maximumDepth}.`, "limit_attributes");
354
+ return;
355
+ }
356
+ if (!Array.isArray(value) && !isPlainRecord(value)) {
357
+ push(path, "Value must be a plain JSON object.", "non_json_value");
358
+ return;
359
+ }
360
+ ancestors.add(value);
361
+ if (Array.isArray(value)) {
362
+ if (value.length > limits.maxArrayItems) {
363
+ push(path, `Array exceeds maximum item count ${limits.maxArrayItems}.`, "limit_attributes");
364
+ }
365
+ for (let index = 0; index < value.length; index += 1) {
366
+ if (countTowardsGlobalBudget && jsonValueCount > limits.maxJsonValues) break;
367
+ validateJsonValue(value[index], `${path}.${index}`, depth + 1, ancestors, maximumDepth, countTowardsGlobalBudget);
368
+ }
369
+ } else {
370
+ const entries = Object.entries(value);
371
+ if (entries.length > limits.maxObjectKeys) {
372
+ push(path, `Object exceeds maximum key count ${limits.maxObjectKeys}.`, "limit_attributes");
373
+ }
374
+ for (const [key, item] of entries) {
375
+ if (countTowardsGlobalBudget && jsonValueCount > limits.maxJsonValues) break;
376
+ validateJsonValue(item, formatJsonPathKey(path, key), depth + 1, ancestors, maximumDepth, countTowardsGlobalBudget);
377
+ }
378
+ }
379
+ ancestors.delete(value);
380
+ };
381
+ const validateValueSchema = (value, schema, path) => {
382
+ if (value === null && schema.nullable) return;
383
+ let typeValid = true;
384
+ if (schema.type === "string") typeValid = typeof value === "string";
385
+ else if (schema.type === "number") typeValid = typeof value === "number" && Number.isFinite(value);
386
+ else if (schema.type === "boolean") typeValid = typeof value === "boolean";
387
+ else if (schema.type === "null") typeValid = value === null;
388
+ else if (schema.type === "array") typeValid = Array.isArray(value);
389
+ else if (schema.type === "object") typeValid = isPlainRecord(value);
390
+ if (!typeValid) {
391
+ push(path, `Attribute must match schema type "${schema.type}".`, "invalid_attribute");
392
+ return;
393
+ }
394
+ if (schema.enum && !schema.enum.some((candidate) => jsonValuesEqual(candidate, value))) {
395
+ push(path, "Attribute must be one of the configured enum values.", "invalid_attribute");
396
+ }
397
+ if (schema.type === "string" && typeof value === "string") {
398
+ if (schema.minLength !== void 0 && value.length < schema.minLength) push(path, `String must contain at least ${schema.minLength} characters.`, "invalid_attribute");
399
+ if (schema.maxLength !== void 0 && value.length > schema.maxLength) push(path, `String must contain at most ${schema.maxLength} characters.`, "invalid_attribute");
400
+ if (schema.pattern !== void 0) {
401
+ try {
402
+ if (!new RegExp(schema.pattern).test(value)) push(path, `String must match /${schema.pattern}/.`, "invalid_attribute");
403
+ } catch {
404
+ push(path, "Attribute contract contains an invalid regular expression.", "custom_validation");
405
+ }
406
+ }
407
+ } else if (schema.type === "number" && typeof value === "number") {
408
+ if (schema.integer && !Number.isInteger(value)) push(path, "Number must be an integer.", "invalid_attribute");
409
+ if (schema.minimum !== void 0 && value < schema.minimum) push(path, `Number must be at least ${schema.minimum}.`, "invalid_attribute");
410
+ if (schema.maximum !== void 0 && value > schema.maximum) push(path, `Number must be at most ${schema.maximum}.`, "invalid_attribute");
411
+ } else if (schema.type === "array" && Array.isArray(value)) {
412
+ if (schema.minItems !== void 0 && value.length < schema.minItems) push(path, `Array must contain at least ${schema.minItems} items.`, "invalid_attribute");
413
+ if (schema.maxItems !== void 0 && value.length > schema.maxItems) push(path, `Array must contain at most ${schema.maxItems} items.`, "invalid_attribute");
414
+ if (schema.items) value.forEach((item, index) => validateValueSchema(item, schema.items, `${path}.${index}`));
415
+ } else if (schema.type === "object" && isPlainRecord(value)) {
416
+ validateAttributes(value, schema, path);
417
+ }
418
+ for (const message of validatorMessages(schema.validate, value, path)) push(path, message, "custom_validation");
419
+ };
420
+ const validateAttributes = (attrs, spec, path) => {
421
+ for (const required of spec.required ?? []) {
422
+ if (!(required in attrs)) push(formatJsonPathKey(path, required), "Required attribute is missing.", "missing_attribute");
423
+ }
424
+ for (const [name, value] of Object.entries(attrs)) {
425
+ if (name === OPENEDITOR_BLOCK_ID_ATTR) continue;
426
+ const schema = spec.properties?.[name];
427
+ if (schema) {
428
+ validateValueSchema(value, schema, formatJsonPathKey(path, name));
429
+ } else if (spec.additionalProperties === true) {
430
+ continue;
431
+ } else if (typeof spec.additionalProperties === "object") {
432
+ validateValueSchema(value, spec.additionalProperties, formatJsonPathKey(path, name));
433
+ } else {
434
+ push(formatJsonPathKey(path, name), `Unknown attribute "${name}".`, "unknown_attribute");
435
+ }
436
+ }
437
+ };
438
+ const validateNode = (node, path, depth) => {
439
+ nodeCount += 1;
440
+ if (nodeCount > limits.maxNodes) {
441
+ if (nodeCount === limits.maxNodes + 1) push(path, `Document exceeds maximum node count ${limits.maxNodes}.`, "limit_nodes");
442
+ return;
443
+ }
444
+ if (depth > limits.maxDepth) {
445
+ push(path, `Document exceeds maximum node depth ${limits.maxDepth}.`, "limit_depth");
446
+ return;
447
+ }
192
448
  if (!isRecord(node)) {
193
- push(path, "Node must be an object.");
449
+ push(path, "Node must be an object.", "invalid_node");
194
450
  return;
195
451
  }
452
+ for (const key of Object.keys(node)) {
453
+ if (!["type", "attrs", "content", "marks", "text"].includes(key)) {
454
+ push(formatJsonPathKey(path, key), `Unknown node property "${key}".`, "unknown_property");
455
+ }
456
+ }
196
457
  if (typeof node.type !== "string" || !node.type) {
197
- push(`${path}.type`, "Node type must be a non-empty string.");
458
+ push(`${path}.type`, "Node type must be a non-empty string.", "invalid_node_type");
198
459
  }
460
+ const nodeSpec = typeof node.type === "string" ? options.contract?.nodes.get(node.type) : void 0;
461
+ if (options.contract && typeof node.type === "string" && !nodeSpec) push(`${path}.type`, `Unknown node type "${node.type}".`, "unknown_node_type");
199
462
  if ("text" in node && typeof node.text !== "string") {
200
- push(`${path}.text`, "Text node content must be a string.");
463
+ push(`${path}.text`, "Text node content must be a string.", "invalid_text");
464
+ } else if (typeof node.text === "string" && node.text.length > limits.maxTextLength) {
465
+ push(`${path}.text`, `Text exceeds maximum length ${limits.maxTextLength}.`, "limit_text");
466
+ }
467
+ if (typeof node.text === "string") {
468
+ totalTextLength += node.text.length;
469
+ if (totalTextLength > limits.maxTotalTextLength && totalTextLength - node.text.length <= limits.maxTotalTextLength) {
470
+ push(`${path}.text`, `Document exceeds maximum total text length ${limits.maxTotalTextLength}.`, "limit_text");
471
+ }
472
+ }
473
+ if (nodeSpec?.text === "required" && typeof node.text !== "string") push(`${path}.text`, "Node requires text content.", "invalid_text");
474
+ if (nodeSpec?.text === "forbidden" && "text" in node) push(`${path}.text`, "Node does not allow text content.", "unexpected_text");
475
+ const nodeId = typeof node.attrs === "object" && node.attrs !== null ? getBlockId(node) : void 0;
476
+ if (node.type !== "text" && limits.requireNodeIds && !nodeId) push(`${path}.attrs.${OPENEDITOR_BLOCK_ID_ATTR}`, "Node requires a stable OpenEditor ID.", "missing_node_id");
477
+ if (nodeId) {
478
+ const previousPath = seenIds.get(nodeId);
479
+ if (previousPath) push(`${path}.attrs.${OPENEDITOR_BLOCK_ID_ATTR}`, `Node ID "${nodeId}" duplicates ${previousPath}.`, "duplicate_node_id");
480
+ else seenIds.set(nodeId, path);
201
481
  }
202
482
  if ("attrs" in node && node.attrs !== void 0 && !isRecord(node.attrs)) {
203
- push(`${path}.attrs`, "Node attrs must be an object.");
483
+ push(`${path}.attrs`, "Node attrs must be an object.", "invalid_attrs");
484
+ } else if (isRecord(node.attrs)) {
485
+ validateJsonValue(node.attrs, `${path}.attrs`, 0, /* @__PURE__ */ new Set(), limits.maxAttributeDepth, false);
486
+ if (nodeSpec?.attributes) validateAttributes(node.attrs, nodeSpec.attributes, `${path}.attrs`);
204
487
  }
205
488
  if ("marks" in node && node.marks !== void 0) {
206
489
  if (!Array.isArray(node.marks)) {
207
- push(`${path}.marks`, "Marks must be an array.");
490
+ push(`${path}.marks`, "Marks must be an array.", "invalid_marks");
208
491
  } else {
492
+ if (node.marks.length > limits.maxMarksPerNode) push(`${path}.marks`, `Node exceeds maximum mark count ${limits.maxMarksPerNode}.`, "limit_marks");
209
493
  node.marks.forEach((mark, index) => {
210
494
  if (!isRecord(mark) || typeof mark.type !== "string" || !mark.type) {
211
- push(`${path}.marks.${index}`, "Mark must have a non-empty type.");
495
+ push(`${path}.marks.${index}`, "Mark must have a non-empty type.", "invalid_mark");
496
+ return;
497
+ }
498
+ const markPath = `${path}.marks.${index}`;
499
+ for (const key of Object.keys(mark)) {
500
+ if (!["type", "attrs"].includes(key)) push(formatJsonPathKey(markPath, key), `Unknown mark property "${key}".`, "unknown_property");
501
+ }
502
+ const markSpec = options.contract?.marks.get(mark.type);
503
+ if (options.contract && !markSpec) push(`${markPath}.type`, `Unknown mark type "${mark.type}".`, "unknown_mark_type");
504
+ if (nodeSpec?.marks === false || Array.isArray(nodeSpec?.marks) && !nodeSpec.marks.includes(mark.type)) push(markPath, `Mark "${mark.type}" is not allowed on node "${String(node.type)}".`, "disallowed_mark");
505
+ if ("attrs" in mark && mark.attrs !== void 0 && !isRecord(mark.attrs)) push(`${markPath}.attrs`, "Mark attrs must be an object.", "invalid_attrs");
506
+ else if (isRecord(mark.attrs)) {
507
+ validateJsonValue(mark.attrs, `${markPath}.attrs`, 0, /* @__PURE__ */ new Set(), limits.maxAttributeDepth, false);
508
+ if (markSpec?.attributes) validateAttributes(mark.attrs, markSpec.attributes, `${markPath}.attrs`);
212
509
  }
213
510
  });
214
511
  }
215
512
  }
216
513
  if ("content" in node && node.content !== void 0) {
217
514
  if (!Array.isArray(node.content)) {
218
- push(`${path}.content`, "Node content must be an array.");
515
+ push(`${path}.content`, "Node content must be an array.", "invalid_content");
219
516
  } else {
220
- node.content.forEach((child, index) => validateNode(child, `${path}.content.${index}`));
517
+ if (nodeSpec?.content === false) push(`${path}.content`, `Node "${String(node.type)}" does not allow content.`, "invalid_content");
518
+ const contentSpec = nodeSpec?.content;
519
+ if (contentSpec) {
520
+ if (contentSpec.minItems !== void 0 && node.content.length < contentSpec.minItems) push(`${path}.content`, `Node requires at least ${contentSpec.minItems} children.`, "invalid_content");
521
+ if (contentSpec.maxItems !== void 0 && node.content.length > contentSpec.maxItems) push(`${path}.content`, `Node allows at most ${contentSpec.maxItems} children.`, "invalid_content");
522
+ if (contentSpec.allowedTypes) node.content.forEach((child, index) => {
523
+ if (isRecord(child) && typeof child.type === "string" && !contentSpec.allowedTypes.includes(child.type)) push(`${path}.content.${index}.type`, `Child type "${child.type}" is not allowed in "${String(node.type)}".`, "disallowed_child");
524
+ });
525
+ }
526
+ node.content.forEach((child, index) => validateNode(child, `${path}.content.${index}`, depth + 1));
221
527
  }
528
+ } else if (nodeSpec?.content && (nodeSpec.content.minItems ?? 0) > 0) {
529
+ push(`${path}.content`, `Node requires at least ${nodeSpec.content.minItems} children.`, "invalid_content");
222
530
  }
531
+ for (const message of validatorMessages(nodeSpec?.validate, node, path)) push(path, message, "custom_validation");
223
532
  };
224
533
  if (!isRecord(document)) {
225
534
  return {
226
535
  valid: false,
227
- issues: [{ path: "$", message: "Document must be an object." }]
536
+ issues: [{ path: "$", message: "Document must be an object.", code: "invalid_document" }]
228
537
  };
229
538
  }
539
+ validateJsonValue(document, "$", 0, /* @__PURE__ */ new Set(), Math.max(limits.maxDepth * 3, limits.maxAttributeDepth));
540
+ for (const key of Object.keys(document)) {
541
+ if (!["type", "version", "content", "meta"].includes(key)) push(formatJsonPathKey("$", key), `Unknown document property "${key}".`, "unknown_property");
542
+ }
230
543
  if (document.type !== "doc") {
231
- push("$.type", 'Document type must be "doc".');
544
+ push("$.type", 'Document type must be "doc".', "invalid_document_type");
232
545
  }
233
- if (document.version !== 1) {
234
- push("$.version", "Document version must be 1.");
546
+ if (document.version !== OPENEDITOR_DOCUMENT_FORMAT_VERSION) {
547
+ push("$.version", `Document version must be ${OPENEDITOR_DOCUMENT_FORMAT_VERSION}.`, "unsupported_format_version");
235
548
  }
236
549
  if (!Array.isArray(document.content)) {
237
- push("$.content", "Document content must be an array.");
550
+ push("$.content", "Document content must be an array.", "invalid_content");
238
551
  } else {
239
- document.content.forEach((node, index) => validateNode(node, `$.content.${index}`));
552
+ const rootContent = options.contract?.rootContent;
553
+ if (rootContent) {
554
+ if (rootContent.minItems !== void 0 && document.content.length < rootContent.minItems) push("$.content", `Document requires at least ${rootContent.minItems} children.`, "invalid_content");
555
+ if (rootContent.maxItems !== void 0 && document.content.length > rootContent.maxItems) push("$.content", `Document allows at most ${rootContent.maxItems} children.`, "invalid_content");
556
+ if (rootContent.allowedTypes) document.content.forEach((child, index) => {
557
+ if (isRecord(child) && typeof child.type === "string" && !rootContent.allowedTypes.includes(child.type)) push(`$.content.${index}.type`, `Node type "${child.type}" is not allowed at the document root.`, "disallowed_child");
558
+ });
559
+ }
560
+ document.content.forEach((node, index) => validateNode(node, `$.content.${index}`, 1));
240
561
  }
241
562
  if ("meta" in document && document.meta !== void 0 && !isRecord(document.meta)) {
242
- push("$.meta", "Document meta must be an object.");
563
+ push("$.meta", "Document meta must be an object.", "invalid_meta");
564
+ } else if (isRecord(document.meta) && options.contract) {
565
+ const actualSchemaVersion = document.meta.schemaVersion;
566
+ if ((actualSchemaVersion !== void 0 || options.requireSchemaVersion) && actualSchemaVersion !== options.contract.schemaVersion) push("$.meta.schemaVersion", `Document schema version must be "${options.contract.schemaVersion}".`, "schema_version_mismatch");
567
+ }
568
+ if (isRecord(document.meta)) {
569
+ for (const key of Object.keys(document.meta)) {
570
+ if (!["id", "title", "source", "createdAt", "updatedAt", "platform", "schemaVersion", "custom"].includes(key)) push(formatJsonPathKey("$.meta", key), `Unknown document metadata property "${key}".`, "unknown_property");
571
+ }
572
+ for (const key of ["id", "title", "source", "createdAt", "updatedAt", "schemaVersion"]) {
573
+ if (document.meta[key] !== void 0 && typeof document.meta[key] !== "string") push(`$.meta.${key}`, `Document metadata "${key}" must be a string.`, "invalid_meta");
574
+ }
575
+ if (document.meta.platform !== void 0 && document.meta.platform !== "web" && document.meta.platform !== "native") push("$.meta.platform", 'Document platform must be "web" or "native".', "invalid_meta");
576
+ if (document.meta.custom !== void 0 && !isPlainRecord(document.meta.custom)) push("$.meta.custom", "Custom document metadata must be a plain object.", "invalid_meta");
243
577
  }
244
578
  return {
245
579
  valid: issues.length === 0,
@@ -255,10 +589,10 @@ var OpenEditorDocumentParseError = class extends Error {
255
589
  this.validation = validation;
256
590
  }
257
591
  };
258
- var parseOpenEditorDocument = (value) => {
259
- const validation = validateDocument(value);
592
+ var parseOpenEditorDocument = (value, options = {}) => {
593
+ const validation = validateDocument(value, options);
260
594
  if (!validation.valid) throw new OpenEditorDocumentParseError(validation);
261
- return normalizeDocument(value);
595
+ return JSON.parse(JSON.stringify(value));
262
596
  };
263
597
  var importProseMirrorDocument = (value, meta) => {
264
598
  if (isRecord(value) && "version" in value) {
@@ -417,6 +751,6 @@ var createTransaction = (before, after, command) => ({
417
751
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
418
752
  });
419
753
 
420
- export { DEFAULT_CALLOUT_EMOJI, DEFAULT_PAGE_EMOJI, OPENEDITOR_BLOCK_ID_ATTR, OpenEditorDocumentParseError, applyCommand, cloneNode, createAttachmentSnapshot, createBlockId, createBlockRegistry, createDocument, createEditorState, createTextNode, createTransaction, deleteTopLevelBlock, duplicateTopLevelBlock, ensureBlockIds, findBlockLocation, findBlockSpecForNode, fromProseMirrorDocument, getBlockId, getDocumentText, getPlatformDocument, getPlatformSupport, importProseMirrorDocument, isOpenEditorBlockEnabled, isOpenEditorDocument, moveTopLevelBlock, normalizeDocument, normalizeEmoji, openEditorPublicUrlPolicy, openEditorUnsafeUrlPolicy, parseEditorState, parseOpenEditorDocument, replaceTopLevelNode, replaceTopLevelRange, serializeEditorState, textBlock, toProseMirrorDocument, validateDocument, withBlockId };
754
+ export { DEFAULT_CALLOUT_EMOJI, DEFAULT_DOCUMENT_VALIDATION_LIMITS, DEFAULT_PAGE_EMOJI, OPENEDITOR_BLOCK_ID_ATTR, OPENEDITOR_DOCUMENT_FORMAT_VERSION, OpenEditorDocumentParseError, applyCommand, canonicalSerializeJson, cloneNode, createAttachmentSnapshot, createBlockId, createBlockRegistry, createDocument, createEditorState, createOpenEditorDocumentContract, createTextNode, createTransaction, deleteTopLevelBlock, duplicateTopLevelBlock, ensureBlockIds, findBlockLocation, findBlockSpecForNode, fingerprintOpenEditorDocument, fromProseMirrorDocument, getBlockId, getDocumentText, getPlatformDocument, getPlatformSupport, importProseMirrorDocument, isOpenEditorBlockEnabled, isOpenEditorDocument, moveTopLevelBlock, normalizeDocument, normalizeEmoji, openEditorPublicUrlPolicy, openEditorUnsafeUrlPolicy, parseEditorState, parseOpenEditorDocument, replaceTopLevelNode, replaceTopLevelRange, serializeEditorState, textBlock, toProseMirrorDocument, validateDocument, withBlockId };
421
755
  //# sourceMappingURL=index.js.map
422
756
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["content"],"mappings":";AA6PA,IAAM,qBAAA,GAAwB,uBAAA;AAC9B,IAAM,gCAAA,GAAmC,uBAAA;AACzC,IAAM,yBAAA,GAAyF;AAAA,EAC7F,IAAA,sBAAU,GAAA,CAAI,CAAC,QAAQ,OAAA,EAAS,QAAA,EAAU,KAAK,CAAC,CAAA;AAAA,EAChD,uBAAO,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAO,CAAC,CAAA;AAAA,EAChC,sBAAM,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAO,CAAC,CAAA;AAAA,EAC/B,4BAAY,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAO,CAAC;AACvC,CAAA;AAOO,IAAM,yBAAA,GAAiD,CAAC,KAAA,EAAO,OAAA,KAAY;AAChF,EAAA,MAAM,UAAA,GAAa,MAAM,IAAA,EAAK;AAC9B,EAAA,IAAI,CAAC,UAAA,IAAc,gCAAA,CAAiC,IAAA,CAAK,UAAU,GAAG,OAAO,IAAA;AAE7E,EAAA,MAAM,SAAS,qBAAA,CAAsB,IAAA,CAAK,UAAU,CAAA,GAAI,CAAC,GAAG,WAAA,EAAY;AACxE,EAAA,IAAI,CAAC,QAAQ,OAAO,UAAA;AACpB,EAAA,OAAO,0BAA0B,OAAO,CAAA,CAAE,GAAA,CAAI,MAAM,IAAI,UAAA,GAAa,IAAA;AACvE;AAGO,IAAM,yBAAA,GAAiD,CAAC,KAAA,KAAU;AACvE,EAAA,MAAM,UAAA,GAAa,MAAM,IAAA,EAAK;AAC9B,EAAA,OAAO,UAAA,IAAc,IAAA;AACvB;AAE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S,OAAA,CAAQ,MAAA,IAAU,CAAA,EAAG;AAChC,IAAA,OAAO,iBAAA,CAAkB,EAAE,GAAG,QAAA,EAAU,OAAA,EAAS,CAAC,SAAA,CAAU,UAAU,CAAC,CAAA,EAAG,CAAA;AAAA,EAC5E;AAEA,EAAA,IAAI,KAAA,GAAQ,CAAA,IAAK,KAAA,IAAS,QAAA,CAAS,QAAQ,MAAA,EAAQ;AACjD,IAAA,OAAO,kBAAkB,QAAQ,CAAA;AAAA,EACnC;AAEA,EAAA,OAAO,iBAAA,CAAkB;AAAA,IACvB,GAAG,QAAA;AAAA,IACH,OAAA,EAAS,QAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,CAAC,CAAA,EAAG,YAAA,KAAiB,YAAA,KAAiB,KAAK,CAAA,CAAE,GAAA,CAAI,SAAS;AAAA,GAC5F,CAAA;AACH;AAEO,IAAM,iBAAA,GAAoB,CAC/B,MAAA,EACA,KAAA,EACA,OAAA,MACuB;AAAA,EACvB,MAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAI,OAAA,GAAU,EAAE,OAAA,KAAY,EAAC;AAAA,EAC7B,SAAA,EAAA,iBAAW,IAAI,IAAA,EAAK,EAAE,WAAA;AACxB,CAAA","file":"index.js","sourcesContent":["export type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonObject | JsonValue[];\nexport type JsonObject = { [key: string]: JsonValue | undefined };\n\nexport type ProseMirrorAttrs = Record<string, unknown>;\n\nexport type ProseMirrorMark = {\n type: string;\n attrs?: ProseMirrorAttrs;\n};\n\nexport type ProseMirrorNode = {\n type: string;\n attrs?: ProseMirrorAttrs;\n content?: ProseMirrorNode[];\n marks?: ProseMirrorMark[];\n text?: string;\n};\n\nexport type OpenEditorBlock = ProseMirrorNode & {\n attrs?: ProseMirrorAttrs & {\n \"openeditor-id\"?: string;\n };\n};\n\n/** Stable identity used by commands and interaction adapters. */\nexport type OpenEditorBlockRef = {\n id: string;\n nodeType: string;\n blockName?: string;\n};\n\nexport type OpenEditorBlockLocation = OpenEditorBlockRef & {\n parentId: string | null;\n index: number;\n path: readonly number[];\n};\n\nexport type OpenEditorDocumentMeta = {\n id?: string;\n title?: string;\n source?: string;\n createdAt?: string;\n updatedAt?: string;\n platform?: EditorPlatform;\n custom?: Record<string, unknown>;\n};\n\nexport type OpenEditorDocument = {\n type: \"doc\";\n version: 1;\n content: OpenEditorBlock[];\n meta?: OpenEditorDocumentMeta;\n};\n\nexport type ProseMirrorDocument = {\n type: \"doc\";\n content: ProseMirrorNode[];\n};\n\nexport type EditorPlatform = \"web\" | \"native\";\n\nexport type PlatformSupportLevel = \"supported\" | \"unsupported\";\n\nexport type PlatformSupport = {\n web: PlatformSupportLevel;\n native: PlatformSupportLevel;\n};\n\nexport type BlockGroup = \"text\" | \"media\" | \"layout\" | \"structure\" | \"embed\";\n\nexport type BlockSpec = {\n name: string;\n /** ProseMirror node type. Defaults to `name`. */\n nodeType?: string;\n label: string;\n group: BlockGroup;\n defaultNode: () => OpenEditorBlock;\n matchNode?: (node: ProseMirrorNode) => boolean;\n support?: PlatformSupport;\n};\n\nexport type BlockRegistry = ReadonlyMap<string, BlockSpec>;\n\nexport type EditorSelection =\n | { type: \"none\" }\n | { type: \"text\"; anchor: number; head: number }\n | { type: \"node\"; from: number; to: number; nodeType?: string }\n | { type: \"block\"; blockId: string };\n\nexport type OpenEditorMarkName =\n | \"bold\"\n | \"italic\"\n | \"underline\"\n | \"strike\"\n | \"code\"\n | \"link\";\n\nexport type OpenEditorFeatureName =\n | \"headings\"\n | \"lists\"\n | \"taskLists\"\n | \"quotes\"\n | \"codeBlocks\"\n | \"dividers\"\n | \"links\"\n | \"images\"\n | \"columns\"\n | \"tables\"\n | \"toggleLists\"\n | \"callouts\"\n | \"diagrams\"\n | \"pages\"\n | \"attachments\";\n\n/** Durable image data stored by the editor. Resolved preview URLs stay runtime-owned. */\nexport type OpenEditorImageSnapshot = {\n imageId: string | null;\n src: string | null;\n alt: string;\n width: number | null;\n height: number | null;\n};\n\n/** A host-selected image. `source` is platform-specific and is never serialized. */\nexport type OpenEditorImageUploadInput<TSource = unknown> = {\n name: string;\n mimeType: string | null;\n size: number | null;\n source: TSource;\n};\n\nexport type OpenEditorImageUploadCallbacks = {\n onProgress?: (progress: number) => void;\n signal?: AbortSignal;\n};\n\nexport type OpenEditorImageValidationResult =\n | { accepted: true }\n | { accepted: false; message: string };\n\n/** Host-owned image selection, storage, validation, and URL resolution. */\nexport type OpenEditorImageRuntime<TSource = unknown> = {\n selectImage?: (options?: { signal?: AbortSignal }) =>\n | Promise<OpenEditorImageUploadInput<TSource> | null>\n | OpenEditorImageUploadInput<TSource>\n | null;\n validateImage?: (\n input: OpenEditorImageUploadInput<TSource>,\n ) => OpenEditorImageValidationResult | Promise<OpenEditorImageValidationResult>;\n uploadImage?: (\n input: OpenEditorImageUploadInput<TSource>,\n callbacks?: OpenEditorImageUploadCallbacks,\n ) => Promise<OpenEditorImageSnapshot>;\n resolveImage?: (imageId: string, options?: { signal?: AbortSignal }) =>\n Promise<OpenEditorImageSnapshot | null>;\n replaceImage?: (\n imageId: string,\n input: OpenEditorImageUploadInput<TSource>,\n callbacks?: OpenEditorImageUploadCallbacks,\n ) => Promise<OpenEditorImageSnapshot>;\n};\n\n/** Durable, portable attributes stored on an attachment node. */\nexport type OpenEditorAttachmentSnapshot = {\n attachmentId: string | null;\n name: string;\n mimeType: string | null;\n size: number | null;\n url: string | null;\n};\n\n/**\n * A host-selected local file. `source` is deliberately opaque: on web it may\n * be a File, while native hosts typically use a picker result or local URI.\n * OpenEditor never serializes it.\n */\nexport type OpenEditorAttachmentUploadInput<TSource = unknown> = {\n name: string;\n mimeType: string | null;\n size: number | null;\n source: TSource;\n};\n\nexport type OpenEditorAttachmentUploadCallbacks = {\n onProgress?: (progress: number) => void;\n signal?: AbortSignal;\n};\n\nexport type OpenEditorAttachmentValidationResult =\n | { accepted: true }\n | { accepted: false; message: string };\n\n/** Host-owned storage, picker, policy, resolution, and platform actions. */\nexport type OpenEditorAttachmentRuntime<TSource = unknown> = {\n selectAttachment?: (options?: { signal?: AbortSignal }) =>\n | Promise<OpenEditorAttachmentUploadInput<TSource> | null>\n | OpenEditorAttachmentUploadInput<TSource>\n | null;\n validateAttachment?: (\n input: OpenEditorAttachmentUploadInput<TSource>,\n ) => OpenEditorAttachmentValidationResult | Promise<OpenEditorAttachmentValidationResult>;\n uploadAttachment?: (\n input: OpenEditorAttachmentUploadInput<TSource>,\n callbacks?: OpenEditorAttachmentUploadCallbacks,\n ) => Promise<OpenEditorAttachmentSnapshot>;\n resolveAttachment?: (attachmentId: string, options?: { signal?: AbortSignal }) =>\n Promise<OpenEditorAttachmentSnapshot | null>;\n openAttachment?: (attachment: OpenEditorAttachmentSnapshot) => void | Promise<void>;\n renameAttachment?: (attachmentId: string, name: string) => void | Promise<void>;\n replaceAttachment?: (\n attachmentId: string,\n input: OpenEditorAttachmentUploadInput<TSource>,\n callbacks?: OpenEditorAttachmentUploadCallbacks,\n ) => Promise<OpenEditorAttachmentSnapshot>;\n};\n\nexport type OpenEditorPageSnapshot = {\n pageId: string;\n title: string;\n icon?: string | null;\n href?: string | null;\n};\n\nexport type OpenEditorPageUpdate = {\n title?: string;\n icon?: string | null;\n};\n\n/** Host-owned page identity, persistence, navigation, and metadata lifecycle. */\nexport type OpenEditorPageRuntime = {\n createPage?: (input: { title: string; icon?: string | null }) => Promise<OpenEditorPageSnapshot>;\n resolvePage?: (pageId: string) => Promise<OpenEditorPageSnapshot | null>;\n updatePage: (\n pageId: string,\n update: OpenEditorPageUpdate,\n ) => Promise<OpenEditorPageSnapshot | void> | OpenEditorPageSnapshot | void;\n openPage?: (page: OpenEditorPageSnapshot) => Promise<void> | void;\n};\n\n/** Built-in URL-bearing surfaces rendered from portable document data. */\nexport type OpenEditorUrlContext = \"link\" | \"image\" | \"page\" | \"attachment\";\n\n/**\n * Returns the URL that may be rendered for a context, or `null` to omit the\n * navigation/resource. Policies are pure so the same contract can be shared by\n * React viewers, HTML exporters, and other public renderers.\n */\nexport type OpenEditorUrlPolicy = (\n value: string,\n context: OpenEditorUrlContext,\n) => string | null;\n\nconst OPENEDITOR_URL_SCHEME = /^([a-z][a-z\\d+.-]*):/i;\nconst OPENEDITOR_URL_CONTROL_CHARACTER = /[\\u0000-\\u001f\\u007f]/;\nconst OPENEDITOR_PUBLIC_SCHEMES: Readonly<Record<OpenEditorUrlContext, ReadonlySet<string>>> = {\n link: new Set([\"http\", \"https\", \"mailto\", \"tel\"]),\n image: new Set([\"http\", \"https\"]),\n page: new Set([\"http\", \"https\"]),\n attachment: new Set([\"http\", \"https\"]),\n};\n\n/**\n * Safe default for public rendering. Ordinary relative references (including\n * query strings and fragments) are preserved; explicit schemes are allowlisted\n * per context. Local preview schemes such as `blob:` require a host policy.\n */\nexport const openEditorPublicUrlPolicy: OpenEditorUrlPolicy = (value, context) => {\n const normalized = value.trim();\n if (!normalized || OPENEDITOR_URL_CONTROL_CHARACTER.test(normalized)) return null;\n\n const scheme = OPENEDITOR_URL_SCHEME.exec(normalized)?.[1]?.toLowerCase();\n if (!scheme) return normalized;\n return OPENEDITOR_PUBLIC_SCHEMES[context].has(scheme) ? normalized : null;\n};\n\n/** Explicit trusted-host escape hatch. Never use this for untrusted documents. */\nexport const openEditorUnsafeUrlPolicy: OpenEditorUrlPolicy = (value) => {\n const normalized = value.trim();\n return normalized || null;\n};\n\nexport const createAttachmentSnapshot = (\n attrs: Partial<OpenEditorAttachmentSnapshot> = {},\n): OpenEditorAttachmentSnapshot => ({\n attachmentId: typeof attrs.attachmentId === \"string\" ? attrs.attachmentId : null,\n name: typeof attrs.name === \"string\" ? attrs.name : \"\",\n mimeType: typeof attrs.mimeType === \"string\" ? attrs.mimeType : null,\n size: typeof attrs.size === \"number\" && Number.isFinite(attrs.size) && attrs.size >= 0 ? attrs.size : null,\n url: typeof attrs.url === \"string\" ? attrs.url : null,\n});\n\nexport type OpenEditorFeatureSet = Readonly<Record<OpenEditorFeatureName, boolean>>;\n\n/** Controls which schema-supported blocks may be created by an editor surface. */\nexport type OpenEditorAuthoringCapabilities = {\n enabledBlocks?: readonly string[];\n};\n\nexport const isOpenEditorBlockEnabled = (\n blockName: string,\n capabilities?: OpenEditorAuthoringCapabilities,\n): boolean => capabilities?.enabledBlocks === undefined\n || capabilities.enabledBlocks.includes(blockName);\n\nexport const DEFAULT_CALLOUT_EMOJI = \"💡\";\nexport const DEFAULT_PAGE_EMOJI = \"📄\";\n\nexport const normalizeEmoji = (value: unknown, fallback: string) =>\n typeof value === \"string\" && value.trim() ? value.trim() : fallback;\n\nexport type SerializedEditorState = {\n document: OpenEditorDocument;\n selection?: EditorSelection;\n};\n\nexport type EditorTransaction = {\n before: OpenEditorDocument;\n after: OpenEditorDocument;\n command?: OpenEditorCommand;\n timestamp: string;\n};\n\nexport type OpenEditorCommand =\n | { type: \"setContent\"; document: OpenEditorDocument }\n | { type: \"insertBlock\"; block: string; at?: number; attrs?: ProseMirrorAttrs }\n | { type: \"moveBlock\"; from: number; to: number }\n | { type: \"duplicateBlock\"; index: number }\n | { type: \"deleteBlock\"; index: number }\n | { type: \"setLink\"; href?: string }\n | { type: \"toggleMark\"; mark: OpenEditorMarkName }\n | { type: \"undo\" }\n | { type: \"redo\" }\n | { type: \"setSelection\"; selection: EditorSelection };\n\nexport type EditorCommand = OpenEditorCommand;\n\nexport type OpenEditorEventHandlers = {\n onChange?: (document: OpenEditorDocument) => void;\n onSelectionChange?: (selection: EditorSelection) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n onReady?: (controller: OpenEditorController) => void;\n onCommand?: (command: OpenEditorCommand, transaction: EditorTransaction) => void;\n};\n\nexport type OpenEditorConfig = OpenEditorEventHandlers & {\n initialDocument?: OpenEditorDocument;\n editable?: boolean;\n placeholder?: string;\n enabledBlocks?: readonly string[];\n theme?: Record<string, string | number>;\n};\n\nexport type OpenEditorController = {\n getContent: () => OpenEditorDocument;\n setContent: (document: OpenEditorDocument) => void;\n getSelection: () => EditorSelection;\n execute: (command: OpenEditorCommand) => void;\n};\n\nexport type DocumentValidationIssue = {\n path: string;\n message: string;\n};\n\nexport type DocumentValidationResult = {\n valid: boolean;\n issues: DocumentValidationIssue[];\n};\n\nexport type PlatformSupportIssue = {\n path: string;\n block: string;\n platform: EditorPlatform;\n support: PlatformSupportLevel;\n};\n\nexport type PlatformSupportResult = {\n platform: EditorPlatform;\n document: OpenEditorDocument;\n issues: PlatformSupportIssue[];\n};\n\nexport const OPENEDITOR_BLOCK_ID_ATTR = \"openeditor-id\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst normalizeMeta = (meta?: OpenEditorDocumentMeta): OpenEditorDocumentMeta | undefined =>\n meta && Object.keys(meta).length ? { ...meta } : undefined;\n\nconst cloneAttrs = (attrs?: ProseMirrorAttrs): ProseMirrorAttrs | undefined =>\n attrs ? { ...attrs } : undefined;\n\nconst cloneMark = (mark: ProseMirrorMark): ProseMirrorMark => ({\n type: mark.type,\n ...(mark.attrs ? { attrs: cloneAttrs(mark.attrs) } : {}),\n});\n\nconst cloneNodeShallow = <T extends ProseMirrorNode>(node: T): T => ({\n ...node,\n ...(node.attrs ? { attrs: cloneAttrs(node.attrs) } : {}),\n ...(node.marks ? { marks: node.marks.map(cloneMark) } : {}),\n});\n\nexport const cloneNode = <T extends ProseMirrorNode>(node: T): T => ({\n ...cloneNodeShallow(node),\n ...(node.content ? { content: node.content.map(cloneNode) } : {}),\n});\n\nexport const createBlockId = (prefix = \"oe\"): string => {\n const random =\n typeof globalThis.crypto?.randomUUID === \"function\"\n ? globalThis.crypto.randomUUID()\n : Math.random().toString(36).slice(2);\n\n return `${prefix}_${random.replaceAll(\"-\", \"\").slice(0, 24)}`;\n};\n\nconst cloneNodeWithIds = (\n node: ProseMirrorNode,\n createId: () => string,\n seenIds: Set<string>,\n): ProseMirrorNode => {\n if (node.type === \"text\") return cloneNode(node);\n const cloned = cloneNodeShallow(node);\n const existingId = getBlockId(cloned);\n let id = existingId && !seenIds.has(existingId) ? existingId : createId();\n while (!id.trim() || seenIds.has(id)) id = createId();\n seenIds.add(id);\n const withId = withBlockId(cloned, id);\n return {\n ...withId,\n ...(node.content\n ? { content: node.content.map((child) => cloneNodeWithIds(child, createId, seenIds)) }\n : {}),\n };\n};\n\nconst createDocumentWithIds = (\n content: ProseMirrorNode[] = [],\n meta?: OpenEditorDocumentMeta,\n createId: () => string = createBlockId,\n): OpenEditorDocument => {\n const normalizedMeta = normalizeMeta(meta);\n const seenIds = new Set<string>();\n return {\n type: \"doc\",\n version: 1,\n content: content.map((node) => cloneNodeWithIds(node, createId, seenIds)) as OpenEditorBlock[],\n ...(normalizedMeta ? { meta: normalizedMeta } : {}),\n };\n};\n\nexport const createDocument = (\n content: ProseMirrorNode[] = [],\n meta?: OpenEditorDocumentMeta,\n): OpenEditorDocument => createDocumentWithIds(content, meta);\n\nexport const createEditorState = (\n document: OpenEditorDocument,\n selection: EditorSelection = { type: \"none\" },\n): SerializedEditorState => ({\n document: normalizeDocument(document),\n selection,\n});\n\nexport const toProseMirrorDocument = (document: OpenEditorDocument): ProseMirrorDocument => ({\n type: \"doc\",\n content: document.content.map(cloneNode),\n});\n\nexport const fromProseMirrorDocument = (\n document: ProseMirrorDocument,\n meta?: OpenEditorDocumentMeta,\n): OpenEditorDocument => createDocument(document.content, meta);\n\nexport const createTextNode = (text: string, marks?: ProseMirrorMark[]): ProseMirrorNode => ({\n type: \"text\",\n text,\n ...(marks?.length ? { marks: marks.map(cloneMark) } : {}),\n});\n\nexport const textBlock = (type: string, text: string, attrs?: ProseMirrorAttrs): OpenEditorBlock => ({\n type,\n ...(attrs ? { attrs: cloneAttrs(attrs) } : {}),\n content: text ? [createTextNode(text)] : [],\n});\n\nexport const createBlockRegistry = (specs: readonly BlockSpec[]): BlockRegistry => {\n const registry = new Map<string, BlockSpec>();\n const nodeTypes = new Map<string, string>();\n\n for (const spec of specs) {\n if (!spec.name.trim()) {\n throw new Error(\"OpenEditor block names must not be empty.\");\n }\n if (registry.has(spec.name)) {\n throw new Error(`Duplicate OpenEditor block name \"${spec.name}\".`);\n }\n\n const nodeType = spec.nodeType ?? spec.name;\n const existing = nodeTypes.get(nodeType);\n if (existing) {\n throw new Error(\n `OpenEditor blocks \"${existing}\" and \"${spec.name}\" both claim node type \"${nodeType}\".`,\n );\n }\n\n registry.set(spec.name, spec);\n nodeTypes.set(nodeType, spec.name);\n }\n\n return registry;\n};\n\nexport const findBlockSpecForNode = (\n registry: BlockRegistry,\n node: ProseMirrorNode,\n): BlockSpec | undefined => {\n for (const spec of registry.values()) {\n if (spec.matchNode?.(node) || (spec.nodeType ?? spec.name) === node.type) {\n return spec;\n }\n }\n\n return undefined;\n};\n\nexport const getBlockId = (node: ProseMirrorNode): string | undefined => {\n const value = node.attrs?.[OPENEDITOR_BLOCK_ID_ATTR];\n return typeof value === \"string\" && value.trim() ? value : undefined;\n};\n\nexport const withBlockId = <T extends ProseMirrorNode>(node: T, id: string): T => ({\n ...node,\n attrs: {\n ...cloneAttrs(node.attrs),\n [OPENEDITOR_BLOCK_ID_ATTR]: id,\n },\n});\n\nexport const ensureBlockIds = (\n document: OpenEditorDocument,\n createId: () => string = createBlockId,\n): OpenEditorDocument => createDocumentWithIds(document.content, document.meta, createId);\n\nexport const findBlockLocation = (\n document: OpenEditorDocument,\n id: string,\n): OpenEditorBlockLocation | null => {\n const visit = (\n nodes: readonly ProseMirrorNode[],\n parentId: string | null,\n path: readonly number[],\n ): OpenEditorBlockLocation | null => {\n for (let index = 0; index < nodes.length; index += 1) {\n const node = nodes[index];\n if (!node) continue;\n const nodeId = getBlockId(node);\n const nodePath = [...path, index];\n if (nodeId === id) {\n return { id, nodeType: node.type, parentId, index, path: nodePath };\n }\n const nested = node.content?.length\n ? visit(node.content, nodeId ?? parentId, nodePath)\n : null;\n if (nested) return nested;\n }\n return null;\n };\n\n return visit(document.content, null, []);\n};\n\nconst normalizeNode = (node: ProseMirrorNode): OpenEditorBlock => {\n if (node.type === \"heading\") {\n const level = typeof node.attrs?.level === \"number\" ? node.attrs.level : 2;\n const content = node.content?.map(normalizeNode);\n\n return {\n ...cloneNode(node),\n attrs: { ...node.attrs, level: Math.min(Math.max(level, 1), 6) },\n ...(content ? { content } : {}),\n };\n }\n\n if (node.type === \"columns\") {\n const content = node.content?.length\n ? node.content.map(normalizeNode)\n : [\n { type: \"column\", content: [textBlock(\"paragraph\", \"\")] },\n { type: \"column\", content: [textBlock(\"paragraph\", \"\")] },\n ];\n\n return {\n ...cloneNode(node),\n attrs: Object.fromEntries(\n Object.entries(node.attrs ?? {}).filter(([name]) => name !== \"count\"),\n ),\n content,\n };\n }\n\n if (node.type === \"column\" && !node.content?.length) {\n return { ...cloneNode(node), content: [textBlock(\"paragraph\", \"\")] };\n }\n\n const content = node.content?.map(normalizeNode);\n return {\n ...cloneNode(node),\n ...(content ? { content } : {}),\n };\n};\n\nexport const normalizeDocument = (document: OpenEditorDocument): OpenEditorDocument =>\n createDocument(document.content.map(normalizeNode), document.meta);\n\nexport const validateDocument = (document: unknown): DocumentValidationResult => {\n const issues: DocumentValidationIssue[] = [];\n const push = (path: string, message: string) => issues.push({ path, message });\n\n const validateNode = (node: unknown, path: string) => {\n if (!isRecord(node)) {\n push(path, \"Node must be an object.\");\n return;\n }\n\n if (typeof node.type !== \"string\" || !node.type) {\n push(`${path}.type`, \"Node type must be a non-empty string.\");\n }\n\n if (\"text\" in node && typeof node.text !== \"string\") {\n push(`${path}.text`, \"Text node content must be a string.\");\n }\n\n if (\"attrs\" in node && node.attrs !== undefined && !isRecord(node.attrs)) {\n push(`${path}.attrs`, \"Node attrs must be an object.\");\n }\n\n if (\"marks\" in node && node.marks !== undefined) {\n if (!Array.isArray(node.marks)) {\n push(`${path}.marks`, \"Marks must be an array.\");\n } else {\n node.marks.forEach((mark, index) => {\n if (!isRecord(mark) || typeof mark.type !== \"string\" || !mark.type) {\n push(`${path}.marks.${index}`, \"Mark must have a non-empty type.\");\n }\n });\n }\n }\n\n if (\"content\" in node && node.content !== undefined) {\n if (!Array.isArray(node.content)) {\n push(`${path}.content`, \"Node content must be an array.\");\n } else {\n node.content.forEach((child, index) => validateNode(child, `${path}.content.${index}`));\n }\n }\n };\n\n if (!isRecord(document)) {\n return {\n valid: false,\n issues: [{ path: \"$\", message: \"Document must be an object.\" }],\n };\n }\n\n if (document.type !== \"doc\") {\n push(\"$.type\", 'Document type must be \"doc\".');\n }\n\n if (document.version !== 1) {\n push(\"$.version\", \"Document version must be 1.\");\n }\n\n if (!Array.isArray(document.content)) {\n push(\"$.content\", \"Document content must be an array.\");\n } else {\n document.content.forEach((node, index) => validateNode(node, `$.content.${index}`));\n }\n\n if (\"meta\" in document && document.meta !== undefined && !isRecord(document.meta)) {\n push(\"$.meta\", \"Document meta must be an object.\");\n }\n\n return {\n valid: issues.length === 0,\n issues,\n };\n};\n\nexport const isOpenEditorDocument = (value: unknown): value is OpenEditorDocument =>\n validateDocument(value).valid;\n\nexport class OpenEditorDocumentParseError extends Error {\n readonly validation: DocumentValidationResult;\n\n constructor(validation: DocumentValidationResult) {\n super(validation.issues.map((issue) => `${issue.path}: ${issue.message}`).join(\"\\n\"));\n this.name = \"OpenEditorDocumentParseError\";\n this.validation = validation;\n }\n}\n\nexport const parseOpenEditorDocument = (\n value: unknown,\n): OpenEditorDocument => {\n const validation = validateDocument(value);\n if (!validation.valid) throw new OpenEditorDocumentParseError(validation);\n return normalizeDocument(value as OpenEditorDocument);\n};\n\n/** Imports unversioned ProseMirror JSON. Versioned values require strict OpenEditor parsing. */\nexport const importProseMirrorDocument = (\n value: unknown,\n meta?: OpenEditorDocumentMeta,\n): OpenEditorDocument => {\n if (isRecord(value) && \"version\" in value) {\n throw new Error(\"Versioned documents must be parsed with parseOpenEditorDocument().\");\n }\n\n const validation = validateDocument(\n isRecord(value) ? { ...value, version: 1 } : value,\n );\n if (!validation.valid) throw new OpenEditorDocumentParseError(validation);\n return fromProseMirrorDocument(value as ProseMirrorDocument, meta);\n};\n\nexport const serializeEditorState = (state: SerializedEditorState): string =>\n JSON.stringify({\n document: normalizeDocument(state.document),\n ...(state.selection ? { selection: state.selection } : {}),\n });\n\nexport const parseEditorState = (\n value: unknown,\n defaultState: SerializedEditorState = createEditorState(createDocument()),\n): SerializedEditorState => {\n let parsed: unknown;\n\n try {\n parsed = typeof value === \"string\" ? JSON.parse(value) : value;\n } catch {\n return defaultState;\n }\n\n if (!isRecord(parsed)) {\n return defaultState;\n }\n\n try {\n return {\n document: parseOpenEditorDocument(parsed.document),\n selection: isRecord(parsed.selection) ? (parsed.selection as EditorSelection) : defaultState.selection,\n };\n } catch {\n return defaultState;\n }\n};\n\nexport const getPlatformDocument = (\n document: OpenEditorDocument,\n registry: BlockRegistry,\n platform: EditorPlatform,\n): OpenEditorDocument => getPlatformSupport(document, registry, platform).document;\n\nexport const getPlatformSupport = (\n document: OpenEditorDocument,\n registry: BlockRegistry,\n platform: EditorPlatform,\n): PlatformSupportResult => {\n const issues: PlatformSupportIssue[] = [];\n\n const mapNode = (node: OpenEditorBlock, path: string): OpenEditorBlock => {\n const spec = findBlockSpecForNode(registry, node);\n const support = spec?.support?.[platform] ?? \"supported\";\n\n if (support !== \"supported\") {\n issues.push({\n path,\n block: spec?.name ?? node.type,\n platform,\n support,\n });\n }\n\n return normalizeNode({\n ...cloneNode(node),\n content: node.content?.map((child, index) => mapNode(child, `${path}.content.${index}`)),\n });\n };\n\n return {\n platform,\n document: createDocument(\n document.content.map((node, index) => mapNode(node, `$.content.${index}`)),\n { ...document.meta, platform },\n ),\n issues,\n };\n};\n\nconst INLINE_NODE_TYPES = new Set([\"text\", \"hardBreak\"]);\n\nexport const getDocumentText = (node: OpenEditorDocument | ProseMirrorNode): string => {\n if (\"text\" in node && typeof node.text === \"string\") {\n return node.text;\n }\n\n const content = \"content\" in node ? node.content : undefined;\n\n if (!content?.length) {\n return \"\";\n }\n\n const isInlineContainer = content.every(\n (child) => INLINE_NODE_TYPES.has(child.type) || child.type === \"link\",\n );\n const joiner = isInlineContainer ? \"\" : \"\\n\";\n return content.map(getDocumentText).filter(Boolean).join(joiner);\n};\n\nexport const applyCommand = (\n document: OpenEditorDocument,\n registry: BlockRegistry,\n command: OpenEditorCommand,\n): OpenEditorDocument => {\n if (command.type === \"setContent\") {\n return normalizeDocument(command.document);\n }\n\n if (command.type === \"setSelection\") {\n return document;\n }\n\n if (command.type === \"moveBlock\") {\n return moveTopLevelBlock(document, command.from, command.to);\n }\n\n if (command.type === \"duplicateBlock\") {\n return duplicateTopLevelBlock(document, command.index);\n }\n\n if (command.type === \"deleteBlock\") {\n return deleteTopLevelBlock(document, command.index);\n }\n\n if (\n command.type === \"setLink\"\n || command.type === \"toggleMark\"\n || command.type === \"undo\"\n || command.type === \"redo\"\n ) {\n return normalizeDocument(document);\n }\n\n const spec = registry.get(command.block);\n if (!spec) {\n throw new Error(`Unknown block \"${command.block}\"`);\n }\n\n const nextContent = [...document.content];\n const index = command.at ?? nextContent.length;\n const defaultNode = spec.defaultNode();\n const node = command.attrs\n ? { ...defaultNode, attrs: { ...defaultNode.attrs, ...command.attrs } }\n : defaultNode;\n\n nextContent.splice(index, 0, node);\n return normalizeDocument(createDocument(nextContent, document.meta));\n};\n\nexport const replaceTopLevelRange = (\n document: OpenEditorDocument,\n start: number,\n length: number,\n replacement: ProseMirrorNode[],\n): OpenEditorDocument =>\n normalizeDocument({\n ...document,\n content: [\n ...document.content.slice(0, start),\n ...replacement.map(cloneNode),\n ...document.content.slice(start + length),\n ],\n });\n\nexport const replaceTopLevelNode = (\n document: OpenEditorDocument,\n index: number,\n replacement: ProseMirrorNode,\n): OpenEditorDocument =>\n normalizeDocument({\n ...document,\n content: document.content.map((node, nodeIndex) => nodeIndex === index ? cloneNode(replacement) : cloneNode(node)),\n });\n\nexport const moveTopLevelBlock = (\n document: OpenEditorDocument,\n from: number,\n to: number,\n): OpenEditorDocument => {\n if (from < 0 || from >= document.content.length || to < 0 || to >= document.content.length || from === to) {\n return normalizeDocument(document);\n }\n\n const nextContent = document.content.map(cloneNode);\n const [item] = nextContent.splice(from, 1);\n if (!item) {\n return normalizeDocument(document);\n }\n\n nextContent.splice(to, 0, item);\n return normalizeDocument({ ...document, content: nextContent });\n};\n\nexport const duplicateTopLevelBlock = (\n document: OpenEditorDocument,\n index: number,\n): OpenEditorDocument => {\n if (index < 0 || index >= document.content.length) {\n return normalizeDocument(document);\n }\n\n const nextContent = document.content.map(cloneNode);\n nextContent.splice(index + 1, 0, cloneNode(document.content[index]));\n return normalizeDocument({ ...document, content: nextContent });\n};\n\nexport const deleteTopLevelBlock = (\n document: OpenEditorDocument,\n index: number,\n emptyBlock: OpenEditorBlock = textBlock(\"paragraph\", \"\"),\n): OpenEditorDocument => {\n if (document.content.length <= 1) {\n return normalizeDocument({ ...document, content: [cloneNode(emptyBlock)] });\n }\n\n if (index < 0 || index >= document.content.length) {\n return normalizeDocument(document);\n }\n\n return normalizeDocument({\n ...document,\n content: document.content.filter((_, currentIndex) => currentIndex !== index).map(cloneNode),\n });\n};\n\nexport const createTransaction = (\n before: OpenEditorDocument,\n after: OpenEditorDocument,\n command?: EditorCommand,\n): EditorTransaction => ({\n before,\n after,\n ...(command ? { command } : {}),\n timestamp: new Date().toISOString(),\n});\n"]}
1
+ {"version":3,"sources":["../src/index.ts"],"names":["content"],"mappings":";AAkDO,IAAM,kCAAA,GAAqC;AAsSlD,IAAM,qBAAA,GAAwB,uBAAA;AAC9B,IAAM,gCAAA,GAAmC,uBAAA;AACzC,IAAM,yBAAA,GAAyF;AAAA,EAC7F,IAAA,sBAAU,GAAA,CAAI,CAAC,QAAQ,OAAA,EAAS,QAAA,EAAU,KAAK,CAAC,CAAA;AAAA,EAChD,uBAAO,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAO,CAAC,CAAA;AAAA,EAChC,sBAAM,IAAI,GAAA,CAAI,CAAC,MAAA,EAAQ,OAAO,CAAC,CAAA;AAAA,EAC/B,4BAAY,IAAI,GAAA,CAAI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G,QAAA;AAAA,IACH,OAAA,EAAS,QAAA,CAAS,OAAA,CAAQ,MAAA,CAAO,CAAC,CAAA,EAAG,YAAA,KAAiB,YAAA,KAAiB,KAAK,CAAA,CAAE,GAAA,CAAI,SAAS;AAAA,GAC5F,CAAA;AACH;AAEO,IAAM,iBAAA,GAAoB,CAC/B,MAAA,EACA,KAAA,EACA,OAAA,MACuB;AAAA,EACvB,MAAA;AAAA,EACA,KAAA;AAAA,EACA,GAAI,OAAA,GAAU,EAAE,OAAA,KAAY,EAAC;AAAA,EAC7B,SAAA,EAAA,iBAAW,IAAI,IAAA,EAAK,EAAE,WAAA;AACxB,CAAA","file":"index.js","sourcesContent":["export type JsonPrimitive = string | number | boolean | null;\nexport type JsonValue = JsonPrimitive | JsonObject | JsonValue[];\nexport type JsonObject = { [key: string]: JsonValue | undefined };\n\nexport type ProseMirrorAttrs = Record<string, unknown>;\n\nexport type ProseMirrorMark = {\n type: string;\n attrs?: ProseMirrorAttrs;\n};\n\nexport type ProseMirrorNode = {\n type: string;\n attrs?: ProseMirrorAttrs;\n content?: ProseMirrorNode[];\n marks?: ProseMirrorMark[];\n text?: string;\n};\n\nexport type OpenEditorBlock = ProseMirrorNode & {\n attrs?: ProseMirrorAttrs & {\n \"openeditor-id\"?: string;\n };\n};\n\n/** Stable identity used by commands and interaction adapters. */\nexport type OpenEditorBlockRef = {\n id: string;\n nodeType: string;\n blockName?: string;\n};\n\nexport type OpenEditorBlockLocation = OpenEditorBlockRef & {\n parentId: string | null;\n index: number;\n path: readonly number[];\n};\n\nexport type OpenEditorDocumentMeta = {\n id?: string;\n title?: string;\n source?: string;\n createdAt?: string;\n updatedAt?: string;\n platform?: EditorPlatform;\n /** Consumer-defined schema version. The OpenEditor JSON format remains independently versioned. */\n schemaVersion?: string;\n custom?: Record<string, unknown>;\n};\n\nexport const OPENEDITOR_DOCUMENT_FORMAT_VERSION = 1 as const;\n\nexport type OpenEditorDocument = {\n type: \"doc\";\n version: typeof OPENEDITOR_DOCUMENT_FORMAT_VERSION;\n content: OpenEditorBlock[];\n meta?: OpenEditorDocumentMeta;\n};\n\nexport type ProseMirrorDocument = {\n type: \"doc\";\n content: ProseMirrorNode[];\n};\n\nexport type EditorPlatform = \"web\" | \"native\";\n\nexport type PlatformSupportLevel = \"supported\" | \"unsupported\";\n\nexport type PlatformSupport = {\n web: PlatformSupportLevel;\n native: PlatformSupportLevel;\n};\n\nexport type BlockGroup = \"text\" | \"media\" | \"layout\" | \"structure\" | \"embed\";\n\nexport type BlockSpec = {\n name: string;\n /** ProseMirror node type. Defaults to `name`. */\n nodeType?: string;\n label: string;\n group: BlockGroup;\n defaultNode: () => OpenEditorBlock;\n matchNode?: (node: ProseMirrorNode) => boolean;\n support?: PlatformSupport;\n /** Optional portable contract used by server-side validation and schema-aware consumers. */\n schema?: Omit<OpenEditorNodeSpec, \"type\">;\n};\n\nexport type BlockRegistry = ReadonlyMap<string, BlockSpec>;\n\nexport type OpenEditorValueValidationContext = {\n path: string;\n};\n\nexport type OpenEditorValueValidator = (\n value: unknown,\n context: OpenEditorValueValidationContext,\n) => string | readonly string[] | null | undefined;\n\ntype OpenEditorValueSchemaBase = {\n nullable?: boolean;\n enum?: readonly JsonValue[];\n validate?: OpenEditorValueValidator;\n};\n\nexport type OpenEditorValueSchema = OpenEditorValueSchemaBase & (\n | { type: \"any\" }\n | { type: \"string\"; minLength?: number; maxLength?: number; pattern?: string }\n | { type: \"number\"; integer?: boolean; minimum?: number; maximum?: number }\n | { type: \"boolean\" }\n | { type: \"null\" }\n | {\n type: \"array\";\n items?: OpenEditorValueSchema;\n minItems?: number;\n maxItems?: number;\n }\n | {\n type: \"object\";\n properties?: Readonly<Record<string, OpenEditorValueSchema>>;\n required?: readonly string[];\n additionalProperties?: boolean | OpenEditorValueSchema;\n }\n);\n\nexport type OpenEditorAttributesSpec = {\n properties?: Readonly<Record<string, OpenEditorValueSchema>>;\n required?: readonly string[];\n /** Defaults to false for contract-aware validation. */\n additionalProperties?: boolean | OpenEditorValueSchema;\n};\n\nexport type OpenEditorContentSpec = {\n allowedTypes?: readonly string[];\n minItems?: number;\n maxItems?: number;\n};\n\nexport type OpenEditorNodeValidator = (\n node: ProseMirrorNode,\n context: OpenEditorValueValidationContext,\n) => string | readonly string[] | null | undefined;\n\n/** Portable validation contract for one ProseMirror node type. */\nexport type OpenEditorNodeSpec = {\n type: string;\n attributes?: OpenEditorAttributesSpec;\n content?: OpenEditorContentSpec | false;\n text?: \"required\" | \"allowed\" | \"forbidden\";\n marks?: false | readonly string[];\n validate?: OpenEditorNodeValidator;\n};\n\nexport type OpenEditorMarkSpec = {\n type: string;\n attributes?: OpenEditorAttributesSpec;\n};\n\nexport type OpenEditorDocumentContract = {\n formatVersion: typeof OPENEDITOR_DOCUMENT_FORMAT_VERSION;\n schemaVersion: string;\n /** Optional portable constraint for the document root's direct children. */\n rootContent?: OpenEditorContentSpec;\n nodes: ReadonlyMap<string, OpenEditorNodeSpec>;\n marks: ReadonlyMap<string, OpenEditorMarkSpec>;\n};\n\nexport type CreateOpenEditorDocumentContractOptions = {\n schemaVersion: string;\n blockSpecs?: readonly BlockSpec[];\n nodeSpecs?: readonly OpenEditorNodeSpec[];\n markSpecs?: readonly OpenEditorMarkSpec[];\n rootContent?: OpenEditorContentSpec;\n};\n\nexport type EditorSelection =\n | { type: \"none\" }\n | { type: \"text\"; anchor: number; head: number }\n | { type: \"node\"; from: number; to: number; nodeType?: string }\n | { type: \"block\"; blockId: string };\n\nexport type OpenEditorMarkName =\n | \"bold\"\n | \"italic\"\n | \"underline\"\n | \"strike\"\n | \"code\"\n | \"link\";\n\nexport type OpenEditorFeatureName =\n | \"headings\"\n | \"lists\"\n | \"taskLists\"\n | \"quotes\"\n | \"codeBlocks\"\n | \"dividers\"\n | \"links\"\n | \"images\"\n | \"columns\"\n | \"tables\"\n | \"toggleLists\"\n | \"callouts\"\n | \"diagrams\"\n | \"pages\"\n | \"attachments\";\n\n/** Durable image data stored by the editor. Resolved preview URLs stay runtime-owned. */\nexport type OpenEditorImageSnapshot = {\n imageId: string | null;\n src: string | null;\n alt: string;\n width: number | null;\n height: number | null;\n};\n\n/** A host-selected image. `source` is platform-specific and is never serialized. */\nexport type OpenEditorImageUploadInput<TSource = unknown> = {\n name: string;\n mimeType: string | null;\n size: number | null;\n source: TSource;\n};\n\nexport type OpenEditorImageUploadCallbacks = {\n onProgress?: (progress: number) => void;\n signal?: AbortSignal;\n};\n\nexport type OpenEditorImageValidationResult =\n | { accepted: true }\n | { accepted: false; message: string };\n\n/** Host-owned image selection, storage, validation, and URL resolution. */\nexport type OpenEditorImageRuntime<TSource = unknown> = {\n selectImage?: (options?: { signal?: AbortSignal }) =>\n | Promise<OpenEditorImageUploadInput<TSource> | null>\n | OpenEditorImageUploadInput<TSource>\n | null;\n validateImage?: (\n input: OpenEditorImageUploadInput<TSource>,\n ) => OpenEditorImageValidationResult | Promise<OpenEditorImageValidationResult>;\n uploadImage?: (\n input: OpenEditorImageUploadInput<TSource>,\n callbacks?: OpenEditorImageUploadCallbacks,\n ) => Promise<OpenEditorImageSnapshot>;\n resolveImage?: (imageId: string, options?: { signal?: AbortSignal }) =>\n Promise<OpenEditorImageSnapshot | null>;\n replaceImage?: (\n imageId: string,\n input: OpenEditorImageUploadInput<TSource>,\n callbacks?: OpenEditorImageUploadCallbacks,\n ) => Promise<OpenEditorImageSnapshot>;\n};\n\n/** Durable, portable attributes stored on an attachment node. */\nexport type OpenEditorAttachmentSnapshot = {\n attachmentId: string | null;\n name: string;\n mimeType: string | null;\n size: number | null;\n url: string | null;\n};\n\n/**\n * A host-selected local file. `source` is deliberately opaque: on web it may\n * be a File, while native hosts typically use a picker result or local URI.\n * OpenEditor never serializes it.\n */\nexport type OpenEditorAttachmentUploadInput<TSource = unknown> = {\n name: string;\n mimeType: string | null;\n size: number | null;\n source: TSource;\n};\n\nexport type OpenEditorAttachmentUploadCallbacks = {\n onProgress?: (progress: number) => void;\n signal?: AbortSignal;\n};\n\nexport type OpenEditorAttachmentValidationResult =\n | { accepted: true }\n | { accepted: false; message: string };\n\n/** Host-owned storage, picker, policy, resolution, and platform actions. */\nexport type OpenEditorAttachmentRuntime<TSource = unknown> = {\n selectAttachment?: (options?: { signal?: AbortSignal }) =>\n | Promise<OpenEditorAttachmentUploadInput<TSource> | null>\n | OpenEditorAttachmentUploadInput<TSource>\n | null;\n validateAttachment?: (\n input: OpenEditorAttachmentUploadInput<TSource>,\n ) => OpenEditorAttachmentValidationResult | Promise<OpenEditorAttachmentValidationResult>;\n uploadAttachment?: (\n input: OpenEditorAttachmentUploadInput<TSource>,\n callbacks?: OpenEditorAttachmentUploadCallbacks,\n ) => Promise<OpenEditorAttachmentSnapshot>;\n resolveAttachment?: (attachmentId: string, options?: { signal?: AbortSignal }) =>\n Promise<OpenEditorAttachmentSnapshot | null>;\n openAttachment?: (attachment: OpenEditorAttachmentSnapshot) => void | Promise<void>;\n renameAttachment?: (attachmentId: string, name: string) => void | Promise<void>;\n replaceAttachment?: (\n attachmentId: string,\n input: OpenEditorAttachmentUploadInput<TSource>,\n callbacks?: OpenEditorAttachmentUploadCallbacks,\n ) => Promise<OpenEditorAttachmentSnapshot>;\n};\n\nexport type OpenEditorPageSnapshot = {\n pageId: string;\n title: string;\n icon?: string | null;\n href?: string | null;\n};\n\nexport type OpenEditorPageUpdate = {\n title?: string;\n icon?: string | null;\n};\n\n/** Host-owned page identity, persistence, navigation, and metadata lifecycle. */\nexport type OpenEditorPageRuntime = {\n createPage?: (input: { title: string; icon?: string | null }) => Promise<OpenEditorPageSnapshot>;\n resolvePage?: (pageId: string) => Promise<OpenEditorPageSnapshot | null>;\n updatePage?: (\n pageId: string,\n update: OpenEditorPageUpdate,\n ) => Promise<OpenEditorPageSnapshot | void> | OpenEditorPageSnapshot | void;\n openPage?: (page: OpenEditorPageSnapshot) => Promise<void> | void;\n};\n\n/** Built-in URL-bearing surfaces rendered from portable document data. */\nexport type OpenEditorUrlContext = \"link\" | \"image\" | \"page\" | \"attachment\";\n\n/**\n * Returns the URL that may be rendered for a context, or `null` to omit the\n * navigation/resource. Policies are pure so the same contract can be shared by\n * React viewers, HTML exporters, and other public renderers.\n */\nexport type OpenEditorUrlPolicy = (\n value: string,\n context: OpenEditorUrlContext,\n) => string | null;\n\nconst OPENEDITOR_URL_SCHEME = /^([a-z][a-z\\d+.-]*):/i;\nconst OPENEDITOR_URL_CONTROL_CHARACTER = /[\\u0000-\\u001f\\u007f]/;\nconst OPENEDITOR_PUBLIC_SCHEMES: Readonly<Record<OpenEditorUrlContext, ReadonlySet<string>>> = {\n link: new Set([\"http\", \"https\", \"mailto\", \"tel\"]),\n image: new Set([\"http\", \"https\"]),\n page: new Set([\"http\", \"https\"]),\n attachment: new Set([\"http\", \"https\"]),\n};\n\n/**\n * Safe default for public rendering. Ordinary relative references (including\n * query strings and fragments) are preserved; explicit schemes are allowlisted\n * per context. Local preview schemes such as `blob:` require a host policy.\n */\nexport const openEditorPublicUrlPolicy: OpenEditorUrlPolicy = (value, context) => {\n const normalized = value.trim();\n if (!normalized || OPENEDITOR_URL_CONTROL_CHARACTER.test(normalized)) return null;\n\n const scheme = OPENEDITOR_URL_SCHEME.exec(normalized)?.[1]?.toLowerCase();\n if (!scheme) return normalized;\n return OPENEDITOR_PUBLIC_SCHEMES[context].has(scheme) ? normalized : null;\n};\n\n/** Explicit trusted-host escape hatch. Never use this for untrusted documents. */\nexport const openEditorUnsafeUrlPolicy: OpenEditorUrlPolicy = (value) => {\n const normalized = value.trim();\n return normalized || null;\n};\n\nexport const createAttachmentSnapshot = (\n attrs: Partial<OpenEditorAttachmentSnapshot> = {},\n): OpenEditorAttachmentSnapshot => ({\n attachmentId: typeof attrs.attachmentId === \"string\" ? attrs.attachmentId : null,\n name: typeof attrs.name === \"string\" ? attrs.name : \"\",\n mimeType: typeof attrs.mimeType === \"string\" ? attrs.mimeType : null,\n size: typeof attrs.size === \"number\" && Number.isFinite(attrs.size) && attrs.size >= 0 ? attrs.size : null,\n url: typeof attrs.url === \"string\" ? attrs.url : null,\n});\n\nexport type OpenEditorFeatureSet = Readonly<Record<OpenEditorFeatureName, boolean>>;\n\n/** Controls which schema-supported blocks may be created by an editor surface. */\nexport type OpenEditorAuthoringCapabilities = {\n enabledBlocks?: readonly string[];\n};\n\nexport const isOpenEditorBlockEnabled = (\n blockName: string,\n capabilities?: OpenEditorAuthoringCapabilities,\n): boolean => capabilities?.enabledBlocks === undefined\n || capabilities.enabledBlocks.includes(blockName);\n\nexport const DEFAULT_CALLOUT_EMOJI = \"💡\";\nexport const DEFAULT_PAGE_EMOJI = \"📄\";\n\nexport const normalizeEmoji = (value: unknown, fallback: string) =>\n typeof value === \"string\" && value.trim() ? value.trim() : fallback;\n\nexport type SerializedEditorState = {\n document: OpenEditorDocument;\n selection?: EditorSelection;\n};\n\nexport type EditorTransaction = {\n before: OpenEditorDocument;\n after: OpenEditorDocument;\n command?: OpenEditorCommand;\n timestamp: string;\n};\n\nexport type OpenEditorCommand =\n | { type: \"setContent\"; document: OpenEditorDocument }\n | { type: \"insertBlock\"; block: string; at?: number; attrs?: ProseMirrorAttrs }\n | { type: \"moveBlock\"; from: number; to: number }\n | { type: \"duplicateBlock\"; index: number }\n | { type: \"deleteBlock\"; index: number }\n | { type: \"setLink\"; href?: string }\n | { type: \"toggleMark\"; mark: OpenEditorMarkName }\n | { type: \"undo\" }\n | { type: \"redo\" }\n | { type: \"setSelection\"; selection: EditorSelection };\n\nexport type EditorCommand = OpenEditorCommand;\n\nexport type OpenEditorEventHandlers = {\n onChange?: (document: OpenEditorDocument) => void;\n onSelectionChange?: (selection: EditorSelection) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n onReady?: (controller: OpenEditorController) => void;\n onCommand?: (command: OpenEditorCommand, transaction: EditorTransaction) => void;\n};\n\nexport type OpenEditorConfig = OpenEditorEventHandlers & {\n initialDocument?: OpenEditorDocument;\n editable?: boolean;\n placeholder?: string;\n enabledBlocks?: readonly string[];\n theme?: Record<string, string | number>;\n};\n\nexport type OpenEditorController = {\n getContent: () => OpenEditorDocument;\n setContent: (document: OpenEditorDocument) => void;\n getSelection: () => EditorSelection;\n execute: (command: OpenEditorCommand) => void;\n};\n\nexport type DocumentValidationIssue = {\n path: string;\n message: string;\n code?: DocumentValidationCode;\n};\n\nexport type DocumentValidationCode =\n | \"invalid_document\"\n | \"invalid_document_type\"\n | \"unsupported_format_version\"\n | \"schema_version_mismatch\"\n | \"invalid_meta\"\n | \"invalid_node\"\n | \"invalid_node_type\"\n | \"unknown_node_type\"\n | \"invalid_text\"\n | \"unexpected_text\"\n | \"invalid_attrs\"\n | \"missing_attribute\"\n | \"unknown_attribute\"\n | \"unknown_property\"\n | \"invalid_attribute\"\n | \"invalid_marks\"\n | \"invalid_mark\"\n | \"unknown_mark_type\"\n | \"disallowed_mark\"\n | \"invalid_content\"\n | \"disallowed_child\"\n | \"duplicate_node_id\"\n | \"missing_node_id\"\n | \"non_json_value\"\n | \"cyclic_value\"\n | \"limit_depth\"\n | \"limit_nodes\"\n | \"limit_marks\"\n | \"limit_text\"\n | \"limit_attributes\"\n | \"custom_validation\";\n\nexport type DocumentValidationResult = {\n valid: boolean;\n issues: DocumentValidationIssue[];\n};\n\nexport type DocumentValidationLimits = {\n maxDepth: number;\n maxNodes: number;\n maxMarksPerNode: number;\n maxTextLength: number;\n maxTotalTextLength: number;\n maxAttributeDepth: number;\n maxArrayItems: number;\n maxObjectKeys: number;\n /** Global JSON value budget, including metadata and attributes. */\n maxJsonValues: number;\n requireNodeIds: boolean;\n};\n\nexport type ValidateDocumentOptions = {\n contract?: OpenEditorDocumentContract;\n limits?: Partial<DocumentValidationLimits>;\n /** Reject a document whose meta.schemaVersion differs from the configured contract. */\n requireSchemaVersion?: boolean;\n};\n\nexport const DEFAULT_DOCUMENT_VALIDATION_LIMITS: Readonly<DocumentValidationLimits> = {\n maxDepth: 128,\n maxNodes: 100_000,\n maxMarksPerNode: 64,\n maxTextLength: 1_000_000,\n maxTotalTextLength: 10_000_000,\n maxAttributeDepth: 32,\n maxArrayItems: 100_000,\n maxObjectKeys: 10_000,\n maxJsonValues: 500_000,\n requireNodeIds: false,\n};\n\nexport type PlatformSupportIssue = {\n path: string;\n block: string;\n platform: EditorPlatform;\n support: PlatformSupportLevel;\n};\n\nexport type PlatformSupportResult = {\n platform: EditorPlatform;\n document: OpenEditorDocument;\n issues: PlatformSupportIssue[];\n};\n\nexport const OPENEDITOR_BLOCK_ID_ATTR = \"openeditor-id\";\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null && !Array.isArray(value);\n\nconst normalizeMeta = (meta?: OpenEditorDocumentMeta): OpenEditorDocumentMeta | undefined =>\n meta && Object.keys(meta).length ? { ...meta } : undefined;\n\nconst cloneAttrs = (attrs?: ProseMirrorAttrs): ProseMirrorAttrs | undefined =>\n attrs ? { ...attrs } : undefined;\n\nconst cloneMark = (mark: ProseMirrorMark): ProseMirrorMark => ({\n type: mark.type,\n ...(mark.attrs ? { attrs: cloneAttrs(mark.attrs) } : {}),\n});\n\nconst cloneNodeShallow = <T extends ProseMirrorNode>(node: T): T => ({\n ...node,\n ...(node.attrs ? { attrs: cloneAttrs(node.attrs) } : {}),\n ...(node.marks ? { marks: node.marks.map(cloneMark) } : {}),\n});\n\nexport const cloneNode = <T extends ProseMirrorNode>(node: T): T => ({\n ...cloneNodeShallow(node),\n ...(node.content ? { content: node.content.map(cloneNode) } : {}),\n});\n\nexport const createBlockId = (prefix = \"oe\"): string => {\n const random =\n typeof globalThis.crypto?.randomUUID === \"function\"\n ? globalThis.crypto.randomUUID()\n : Math.random().toString(36).slice(2);\n\n return `${prefix}_${random.replaceAll(\"-\", \"\").slice(0, 24)}`;\n};\n\nconst cloneNodeWithIds = (\n node: ProseMirrorNode,\n createId: () => string,\n seenIds: Set<string>,\n): ProseMirrorNode => {\n if (node.type === \"text\") return cloneNode(node);\n const cloned = cloneNodeShallow(node);\n const existingId = getBlockId(cloned);\n let id = existingId && !seenIds.has(existingId) ? existingId : createId();\n while (!id.trim() || seenIds.has(id)) id = createId();\n seenIds.add(id);\n const withId = withBlockId(cloned, id);\n return {\n ...withId,\n ...(node.content\n ? { content: node.content.map((child) => cloneNodeWithIds(child, createId, seenIds)) }\n : {}),\n };\n};\n\nconst createDocumentWithIds = (\n content: ProseMirrorNode[] = [],\n meta?: OpenEditorDocumentMeta,\n createId: () => string = createBlockId,\n): OpenEditorDocument => {\n const normalizedMeta = normalizeMeta(meta);\n const seenIds = new Set<string>();\n return {\n type: \"doc\",\n version: 1,\n content: content.map((node) => cloneNodeWithIds(node, createId, seenIds)) as OpenEditorBlock[],\n ...(normalizedMeta ? { meta: normalizedMeta } : {}),\n };\n};\n\nexport const createDocument = (\n content: ProseMirrorNode[] = [],\n meta?: OpenEditorDocumentMeta,\n): OpenEditorDocument => createDocumentWithIds(content, meta);\n\nexport const createEditorState = (\n document: OpenEditorDocument,\n selection: EditorSelection = { type: \"none\" },\n): SerializedEditorState => ({\n document: normalizeDocument(document),\n selection,\n});\n\nexport const toProseMirrorDocument = (document: OpenEditorDocument): ProseMirrorDocument => ({\n type: \"doc\",\n content: document.content.map(cloneNode),\n});\n\nexport const fromProseMirrorDocument = (\n document: ProseMirrorDocument,\n meta?: OpenEditorDocumentMeta,\n): OpenEditorDocument => createDocument(document.content, meta);\n\nexport const createTextNode = (text: string, marks?: ProseMirrorMark[]): ProseMirrorNode => ({\n type: \"text\",\n text,\n ...(marks?.length ? { marks: marks.map(cloneMark) } : {}),\n});\n\nexport const textBlock = (type: string, text: string, attrs?: ProseMirrorAttrs): OpenEditorBlock => ({\n type,\n ...(attrs ? { attrs: cloneAttrs(attrs) } : {}),\n content: text ? [createTextNode(text)] : [],\n});\n\nexport const createBlockRegistry = (specs: readonly BlockSpec[]): BlockRegistry => {\n const registry = new Map<string, BlockSpec>();\n const nodeTypes = new Map<string, string>();\n\n for (const spec of specs) {\n if (!spec.name.trim()) {\n throw new Error(\"OpenEditor block names must not be empty.\");\n }\n if (registry.has(spec.name)) {\n throw new Error(`Duplicate OpenEditor block name \"${spec.name}\".`);\n }\n\n const nodeType = spec.nodeType ?? spec.name;\n const existing = nodeTypes.get(nodeType);\n if (existing) {\n throw new Error(\n `OpenEditor blocks \"${existing}\" and \"${spec.name}\" both claim node type \"${nodeType}\".`,\n );\n }\n\n registry.set(spec.name, spec);\n nodeTypes.set(nodeType, spec.name);\n }\n\n return registry;\n};\n\nexport const findBlockSpecForNode = (\n registry: BlockRegistry,\n node: ProseMirrorNode,\n): BlockSpec | undefined => {\n for (const spec of registry.values()) {\n if (spec.matchNode?.(node) || (spec.nodeType ?? spec.name) === node.type) {\n return spec;\n }\n }\n\n return undefined;\n};\n\nexport const getBlockId = (node: ProseMirrorNode): string | undefined => {\n const value = node.attrs?.[OPENEDITOR_BLOCK_ID_ATTR];\n return typeof value === \"string\" && value.trim() ? value : undefined;\n};\n\nexport const withBlockId = <T extends ProseMirrorNode>(node: T, id: string): T => ({\n ...node,\n attrs: {\n ...cloneAttrs(node.attrs),\n [OPENEDITOR_BLOCK_ID_ATTR]: id,\n },\n});\n\nexport const ensureBlockIds = (\n document: OpenEditorDocument,\n createId: () => string = createBlockId,\n): OpenEditorDocument => createDocumentWithIds(document.content, document.meta, createId);\n\nexport const findBlockLocation = (\n document: OpenEditorDocument,\n id: string,\n): OpenEditorBlockLocation | null => {\n const visit = (\n nodes: readonly ProseMirrorNode[],\n parentId: string | null,\n path: readonly number[],\n ): OpenEditorBlockLocation | null => {\n for (let index = 0; index < nodes.length; index += 1) {\n const node = nodes[index];\n if (!node) continue;\n const nodeId = getBlockId(node);\n const nodePath = [...path, index];\n if (nodeId === id) {\n return { id, nodeType: node.type, parentId, index, path: nodePath };\n }\n const nested = node.content?.length\n ? visit(node.content, nodeId ?? parentId, nodePath)\n : null;\n if (nested) return nested;\n }\n return null;\n };\n\n return visit(document.content, null, []);\n};\n\nconst normalizeNode = (node: ProseMirrorNode): OpenEditorBlock => {\n if (node.type === \"heading\") {\n const level = typeof node.attrs?.level === \"number\" ? node.attrs.level : 2;\n const content = node.content?.map(normalizeNode);\n\n return {\n ...cloneNode(node),\n attrs: { ...node.attrs, level: Math.min(Math.max(level, 1), 6) },\n ...(content ? { content } : {}),\n };\n }\n\n if (node.type === \"columns\") {\n const content = node.content?.length\n ? node.content.map(normalizeNode)\n : [\n { type: \"column\", content: [textBlock(\"paragraph\", \"\")] },\n { type: \"column\", content: [textBlock(\"paragraph\", \"\")] },\n ];\n\n return {\n ...cloneNode(node),\n attrs: Object.fromEntries(\n Object.entries(node.attrs ?? {}).filter(([name]) => name !== \"count\"),\n ),\n content,\n };\n }\n\n if (node.type === \"column\" && !node.content?.length) {\n return { ...cloneNode(node), content: [textBlock(\"paragraph\", \"\")] };\n }\n\n const content = node.content?.map(normalizeNode);\n return {\n ...cloneNode(node),\n ...(content ? { content } : {}),\n };\n};\n\nexport const normalizeDocument = (document: OpenEditorDocument): OpenEditorDocument =>\n createDocument(document.content.map(normalizeNode), document.meta);\n\nconst cloneAndFreezeContractValue = <T>(value: T): T => {\n if (!value || typeof value !== \"object\") return value;\n if (Array.isArray(value)) {\n return Object.freeze(value.map((child) => cloneAndFreezeContractValue(child))) as T;\n }\n const clone = Object.fromEntries(Object.entries(value as Record<string, unknown>).map(\n ([key, child]) => [key, cloneAndFreezeContractValue(child)],\n ));\n return Object.freeze(clone) as T;\n};\n\nconst createReadonlyMap = <K, V>(source: ReadonlyMap<K, V>): ReadonlyMap<K, V> => {\n let view: ReadonlyMap<K, V>;\n view = Object.freeze({\n get size() { return source.size; },\n get: (key: K) => source.get(key),\n has: (key: K) => source.has(key),\n entries: () => source.entries(),\n keys: () => source.keys(),\n values: () => source.values(),\n forEach: (callback: (value: V, key: K, map: ReadonlyMap<K, V>) => void, thisArg?: unknown) => {\n source.forEach((value, key) => callback.call(thisArg, value, key, view));\n },\n [Symbol.iterator]: () => source[Symbol.iterator](),\n });\n return view;\n};\n\nexport const createOpenEditorDocumentContract = ({\n schemaVersion,\n blockSpecs = [],\n nodeSpecs = [],\n markSpecs = [],\n rootContent,\n}: CreateOpenEditorDocumentContractOptions): OpenEditorDocumentContract => {\n if (!schemaVersion.trim()) throw new Error(\"OpenEditor schema versions must not be empty.\");\n const nodes = new Map<string, OpenEditorNodeSpec>();\n const marks = new Map<string, OpenEditorMarkSpec>();\n\n for (const block of blockSpecs) {\n const type = block.nodeType ?? block.name;\n if (nodes.has(type)) throw new Error(`Duplicate OpenEditor node contract \"${type}\".`);\n nodes.set(type, cloneAndFreezeContractValue({ ...block.schema, type }));\n }\n for (const node of nodeSpecs) {\n if (!node.type.trim()) throw new Error(\"OpenEditor node contract types must not be empty.\");\n if (nodes.has(node.type)) throw new Error(`Duplicate OpenEditor node contract \"${node.type}\".`);\n nodes.set(node.type, cloneAndFreezeContractValue(node));\n }\n for (const mark of markSpecs) {\n if (!mark.type.trim()) throw new Error(\"OpenEditor mark contract types must not be empty.\");\n if (marks.has(mark.type)) throw new Error(`Duplicate OpenEditor mark contract \"${mark.type}\".`);\n marks.set(mark.type, cloneAndFreezeContractValue(mark));\n }\n\n return Object.freeze({\n formatVersion: OPENEDITOR_DOCUMENT_FORMAT_VERSION,\n schemaVersion,\n ...(rootContent ? { rootContent: cloneAndFreezeContractValue(rootContent) } : {}),\n nodes: createReadonlyMap(nodes),\n marks: createReadonlyMap(marks),\n });\n};\n\nconst isPlainRecord = (value: unknown): value is Record<string, unknown> => {\n if (!isRecord(value)) return false;\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n};\n\nconst formatJsonPathKey = (path: string, key: string) =>\n /^[A-Za-z_$][\\w$-]*$/.test(key) ? `${path}.${key}` : `${path}[${JSON.stringify(key)}]`;\n\n/** Deterministic JSON serialization with lexicographically sorted object keys. */\nexport const canonicalSerializeJson = (value: unknown): string => {\n const ancestors = new Set<object>();\n const serialize = (input: unknown): string => {\n if (input === null || typeof input === \"boolean\" || typeof input === \"string\") {\n return JSON.stringify(input);\n }\n if (typeof input === \"number\") {\n if (!Number.isFinite(input)) throw new TypeError(\"Canonical JSON cannot serialize non-finite numbers.\");\n return JSON.stringify(input);\n }\n if (typeof input !== \"object\") throw new TypeError(\"Canonical JSON can only serialize JSON-safe values.\");\n if (!Array.isArray(input) && !isPlainRecord(input)) throw new TypeError(\"Canonical JSON objects must be plain objects.\");\n if (ancestors.has(input)) throw new TypeError(\"Canonical JSON cannot serialize cyclic values.\");\n ancestors.add(input);\n let serialized: string;\n if (Array.isArray(input)) {\n serialized = `[${input.map(serialize).join(\",\")}]`;\n } else {\n serialized = `{${Object.keys(input).sort().map((key) => `${JSON.stringify(key)}:${serialize(input[key])}`).join(\",\")}}`;\n }\n ancestors.delete(input);\n return serialized;\n };\n return serialize(value);\n};\n\n/**\n * Stable non-cryptographic content fingerprint for optimistic concurrency and diffs.\n * Security-sensitive integrity checks should use a cryptographic digest at the host boundary.\n */\nexport const fingerprintOpenEditorDocument = (document: OpenEditorDocument): string => {\n const serialized = canonicalSerializeJson(document);\n let hash = 0xcbf29ce484222325n;\n for (const byte of new TextEncoder().encode(serialized)) {\n hash ^= BigInt(byte);\n hash = BigInt.asUintN(64, hash * 0x100000001b3n);\n }\n return `oe1-fnv1a64-${hash.toString(16).padStart(16, \"0\")}`;\n};\n\nconst validatorMessages = (\n validator: OpenEditorValueValidator | OpenEditorNodeValidator | undefined,\n value: unknown,\n path: string,\n): readonly string[] => {\n if (!validator) return [];\n try {\n const result = validator(value as never, { path });\n if (typeof result === \"string\") return [result];\n return result ?? [];\n } catch (error) {\n return [error instanceof Error ? error.message : \"Custom validator failed.\"];\n }\n};\n\nconst jsonValuesEqual = (left: JsonValue, right: unknown): boolean => {\n try {\n return canonicalSerializeJson(left) === canonicalSerializeJson(right);\n } catch {\n return false;\n }\n};\n\nexport const validateDocument = (\n document: unknown,\n options: ValidateDocumentOptions = {},\n): DocumentValidationResult => {\n const issues: DocumentValidationIssue[] = [];\n const limits = { ...DEFAULT_DOCUMENT_VALIDATION_LIMITS, ...options.limits };\n const push = (path: string, message: string, code: DocumentValidationCode) =>\n issues.push({ path, message, code });\n let nodeCount = 0;\n let totalTextLength = 0;\n let jsonValueCount = 0;\n let jsonValueLimitReported = false;\n const seenIds = new Map<string, string>();\n\n const validateJsonValue = (\n value: unknown,\n path: string,\n depth: number,\n ancestors: Set<object>,\n maximumDepth = limits.maxAttributeDepth,\n countTowardsGlobalBudget = true,\n ): void => {\n if (countTowardsGlobalBudget) {\n jsonValueCount += 1;\n if (jsonValueCount > limits.maxJsonValues) {\n if (!jsonValueLimitReported) {\n push(path, `Document exceeds maximum JSON value count ${limits.maxJsonValues}.`, \"limit_attributes\");\n jsonValueLimitReported = true;\n }\n return;\n }\n }\n if (\n value === null\n || typeof value === \"string\"\n || typeof value === \"boolean\"\n ) return;\n if (typeof value === \"number\") {\n if (!Number.isFinite(value)) push(path, \"Numbers must be finite JSON values.\", \"non_json_value\");\n return;\n }\n if (typeof value !== \"object\") {\n push(path, \"Value must be JSON-safe.\", \"non_json_value\");\n return;\n }\n if (ancestors.has(value)) {\n push(path, \"Cyclic values are not valid JSON.\", \"cyclic_value\");\n return;\n }\n if (depth > maximumDepth) {\n push(path, `Value exceeds maximum depth ${maximumDepth}.`, \"limit_attributes\");\n return;\n }\n if (!Array.isArray(value) && !isPlainRecord(value)) {\n push(path, \"Value must be a plain JSON object.\", \"non_json_value\");\n return;\n }\n ancestors.add(value);\n if (Array.isArray(value)) {\n if (value.length > limits.maxArrayItems) {\n push(path, `Array exceeds maximum item count ${limits.maxArrayItems}.`, \"limit_attributes\");\n }\n for (let index = 0; index < value.length; index += 1) {\n if (countTowardsGlobalBudget && jsonValueCount > limits.maxJsonValues) break;\n validateJsonValue(value[index], `${path}.${index}`, depth + 1, ancestors, maximumDepth, countTowardsGlobalBudget);\n }\n } else {\n const entries = Object.entries(value);\n if (entries.length > limits.maxObjectKeys) {\n push(path, `Object exceeds maximum key count ${limits.maxObjectKeys}.`, \"limit_attributes\");\n }\n for (const [key, item] of entries) {\n if (countTowardsGlobalBudget && jsonValueCount > limits.maxJsonValues) break;\n validateJsonValue(item, formatJsonPathKey(path, key), depth + 1, ancestors, maximumDepth, countTowardsGlobalBudget);\n }\n }\n ancestors.delete(value);\n };\n\n const validateValueSchema = (value: unknown, schema: OpenEditorValueSchema, path: string): void => {\n if (value === null && schema.nullable) return;\n let typeValid = true;\n if (schema.type === \"string\") typeValid = typeof value === \"string\";\n else if (schema.type === \"number\") typeValid = typeof value === \"number\" && Number.isFinite(value);\n else if (schema.type === \"boolean\") typeValid = typeof value === \"boolean\";\n else if (schema.type === \"null\") typeValid = value === null;\n else if (schema.type === \"array\") typeValid = Array.isArray(value);\n else if (schema.type === \"object\") typeValid = isPlainRecord(value);\n\n if (!typeValid) {\n push(path, `Attribute must match schema type \"${schema.type}\".`, \"invalid_attribute\");\n return;\n }\n if (schema.enum && !schema.enum.some((candidate) => jsonValuesEqual(candidate, value))) {\n push(path, \"Attribute must be one of the configured enum values.\", \"invalid_attribute\");\n }\n if (schema.type === \"string\" && typeof value === \"string\") {\n if (schema.minLength !== undefined && value.length < schema.minLength) push(path, `String must contain at least ${schema.minLength} characters.`, \"invalid_attribute\");\n if (schema.maxLength !== undefined && value.length > schema.maxLength) push(path, `String must contain at most ${schema.maxLength} characters.`, \"invalid_attribute\");\n if (schema.pattern !== undefined) {\n try {\n if (!new RegExp(schema.pattern).test(value)) push(path, `String must match /${schema.pattern}/.`, \"invalid_attribute\");\n } catch {\n push(path, \"Attribute contract contains an invalid regular expression.\", \"custom_validation\");\n }\n }\n } else if (schema.type === \"number\" && typeof value === \"number\") {\n if (schema.integer && !Number.isInteger(value)) push(path, \"Number must be an integer.\", \"invalid_attribute\");\n if (schema.minimum !== undefined && value < schema.minimum) push(path, `Number must be at least ${schema.minimum}.`, \"invalid_attribute\");\n if (schema.maximum !== undefined && value > schema.maximum) push(path, `Number must be at most ${schema.maximum}.`, \"invalid_attribute\");\n } else if (schema.type === \"array\" && Array.isArray(value)) {\n if (schema.minItems !== undefined && value.length < schema.minItems) push(path, `Array must contain at least ${schema.minItems} items.`, \"invalid_attribute\");\n if (schema.maxItems !== undefined && value.length > schema.maxItems) push(path, `Array must contain at most ${schema.maxItems} items.`, \"invalid_attribute\");\n if (schema.items) value.forEach((item, index) => validateValueSchema(item, schema.items!, `${path}.${index}`));\n } else if (schema.type === \"object\" && isPlainRecord(value)) {\n validateAttributes(value, schema, path);\n }\n for (const message of validatorMessages(schema.validate, value, path)) push(path, message, \"custom_validation\");\n };\n\n const validateAttributes = (\n attrs: Record<string, unknown>,\n spec: OpenEditorAttributesSpec,\n path: string,\n ): void => {\n for (const required of spec.required ?? []) {\n if (!(required in attrs)) push(formatJsonPathKey(path, required), \"Required attribute is missing.\", \"missing_attribute\");\n }\n for (const [name, value] of Object.entries(attrs)) {\n if (name === OPENEDITOR_BLOCK_ID_ATTR) continue;\n const schema = spec.properties?.[name];\n if (schema) {\n validateValueSchema(value, schema, formatJsonPathKey(path, name));\n } else if (spec.additionalProperties === true) {\n continue;\n } else if (typeof spec.additionalProperties === \"object\") {\n validateValueSchema(value, spec.additionalProperties, formatJsonPathKey(path, name));\n } else {\n push(formatJsonPathKey(path, name), `Unknown attribute \"${name}\".`, \"unknown_attribute\");\n }\n }\n };\n\n const validateNode = (node: unknown, path: string, depth: number) => {\n nodeCount += 1;\n if (nodeCount > limits.maxNodes) {\n if (nodeCount === limits.maxNodes + 1) push(path, `Document exceeds maximum node count ${limits.maxNodes}.`, \"limit_nodes\");\n return;\n }\n if (depth > limits.maxDepth) {\n push(path, `Document exceeds maximum node depth ${limits.maxDepth}.`, \"limit_depth\");\n return;\n }\n if (!isRecord(node)) {\n push(path, \"Node must be an object.\", \"invalid_node\");\n return;\n }\n for (const key of Object.keys(node)) {\n if (![\"type\", \"attrs\", \"content\", \"marks\", \"text\"].includes(key)) {\n push(formatJsonPathKey(path, key), `Unknown node property \"${key}\".`, \"unknown_property\");\n }\n }\n\n if (typeof node.type !== \"string\" || !node.type) {\n push(`${path}.type`, \"Node type must be a non-empty string.\", \"invalid_node_type\");\n }\n const nodeSpec = typeof node.type === \"string\" ? options.contract?.nodes.get(node.type) : undefined;\n if (options.contract && typeof node.type === \"string\" && !nodeSpec) push(`${path}.type`, `Unknown node type \"${node.type}\".`, \"unknown_node_type\");\n\n if (\"text\" in node && typeof node.text !== \"string\") {\n push(`${path}.text`, \"Text node content must be a string.\", \"invalid_text\");\n } else if (typeof node.text === \"string\" && node.text.length > limits.maxTextLength) {\n push(`${path}.text`, `Text exceeds maximum length ${limits.maxTextLength}.`, \"limit_text\");\n }\n if (typeof node.text === \"string\") {\n totalTextLength += node.text.length;\n if (totalTextLength > limits.maxTotalTextLength && totalTextLength - node.text.length <= limits.maxTotalTextLength) {\n push(`${path}.text`, `Document exceeds maximum total text length ${limits.maxTotalTextLength}.`, \"limit_text\");\n }\n }\n if (nodeSpec?.text === \"required\" && typeof node.text !== \"string\") push(`${path}.text`, \"Node requires text content.\", \"invalid_text\");\n if (nodeSpec?.text === \"forbidden\" && \"text\" in node) push(`${path}.text`, \"Node does not allow text content.\", \"unexpected_text\");\n\n const nodeId = typeof node.attrs === \"object\" && node.attrs !== null\n ? getBlockId(node as ProseMirrorNode)\n : undefined;\n if (node.type !== \"text\" && limits.requireNodeIds && !nodeId) push(`${path}.attrs.${OPENEDITOR_BLOCK_ID_ATTR}`, \"Node requires a stable OpenEditor ID.\", \"missing_node_id\");\n if (nodeId) {\n const previousPath = seenIds.get(nodeId);\n if (previousPath) push(`${path}.attrs.${OPENEDITOR_BLOCK_ID_ATTR}`, `Node ID \"${nodeId}\" duplicates ${previousPath}.`, \"duplicate_node_id\");\n else seenIds.set(nodeId, path);\n }\n\n if (\"attrs\" in node && node.attrs !== undefined && !isRecord(node.attrs)) {\n push(`${path}.attrs`, \"Node attrs must be an object.\", \"invalid_attrs\");\n } else if (isRecord(node.attrs)) {\n validateJsonValue(node.attrs, `${path}.attrs`, 0, new Set(), limits.maxAttributeDepth, false);\n if (nodeSpec?.attributes) validateAttributes(node.attrs, nodeSpec.attributes, `${path}.attrs`);\n }\n\n if (\"marks\" in node && node.marks !== undefined) {\n if (!Array.isArray(node.marks)) {\n push(`${path}.marks`, \"Marks must be an array.\", \"invalid_marks\");\n } else {\n if (node.marks.length > limits.maxMarksPerNode) push(`${path}.marks`, `Node exceeds maximum mark count ${limits.maxMarksPerNode}.`, \"limit_marks\");\n node.marks.forEach((mark, index) => {\n if (!isRecord(mark) || typeof mark.type !== \"string\" || !mark.type) {\n push(`${path}.marks.${index}`, \"Mark must have a non-empty type.\", \"invalid_mark\");\n return;\n }\n const markPath = `${path}.marks.${index}`;\n for (const key of Object.keys(mark)) {\n if (![\"type\", \"attrs\"].includes(key)) push(formatJsonPathKey(markPath, key), `Unknown mark property \"${key}\".`, \"unknown_property\");\n }\n const markSpec = options.contract?.marks.get(mark.type);\n if (options.contract && !markSpec) push(`${markPath}.type`, `Unknown mark type \"${mark.type}\".`, \"unknown_mark_type\");\n if (nodeSpec?.marks === false || (Array.isArray(nodeSpec?.marks) && !nodeSpec.marks.includes(mark.type))) push(markPath, `Mark \"${mark.type}\" is not allowed on node \"${String(node.type)}\".`, \"disallowed_mark\");\n if (\"attrs\" in mark && mark.attrs !== undefined && !isRecord(mark.attrs)) push(`${markPath}.attrs`, \"Mark attrs must be an object.\", \"invalid_attrs\");\n else if (isRecord(mark.attrs)) {\n validateJsonValue(mark.attrs, `${markPath}.attrs`, 0, new Set(), limits.maxAttributeDepth, false);\n if (markSpec?.attributes) validateAttributes(mark.attrs, markSpec.attributes, `${markPath}.attrs`);\n }\n });\n }\n }\n\n if (\"content\" in node && node.content !== undefined) {\n if (!Array.isArray(node.content)) {\n push(`${path}.content`, \"Node content must be an array.\", \"invalid_content\");\n } else {\n if (nodeSpec?.content === false) push(`${path}.content`, `Node \"${String(node.type)}\" does not allow content.`, \"invalid_content\");\n const contentSpec = nodeSpec?.content;\n if (contentSpec) {\n if (contentSpec.minItems !== undefined && node.content.length < contentSpec.minItems) push(`${path}.content`, `Node requires at least ${contentSpec.minItems} children.`, \"invalid_content\");\n if (contentSpec.maxItems !== undefined && node.content.length > contentSpec.maxItems) push(`${path}.content`, `Node allows at most ${contentSpec.maxItems} children.`, \"invalid_content\");\n if (contentSpec.allowedTypes) node.content.forEach((child, index) => {\n if (isRecord(child) && typeof child.type === \"string\" && !contentSpec.allowedTypes!.includes(child.type)) push(`${path}.content.${index}.type`, `Child type \"${child.type}\" is not allowed in \"${String(node.type)}\".`, \"disallowed_child\");\n });\n }\n node.content.forEach((child, index) => validateNode(child, `${path}.content.${index}`, depth + 1));\n }\n } else if (nodeSpec?.content && (nodeSpec.content.minItems ?? 0) > 0) {\n push(`${path}.content`, `Node requires at least ${nodeSpec.content.minItems} children.`, \"invalid_content\");\n }\n for (const message of validatorMessages(nodeSpec?.validate, node, path)) push(path, message, \"custom_validation\");\n };\n\n if (!isRecord(document)) {\n return {\n valid: false,\n issues: [{ path: \"$\", message: \"Document must be an object.\", code: \"invalid_document\" }],\n };\n }\n\n validateJsonValue(document, \"$\", 0, new Set(), Math.max(limits.maxDepth * 3, limits.maxAttributeDepth));\n for (const key of Object.keys(document)) {\n if (![\"type\", \"version\", \"content\", \"meta\"].includes(key)) push(formatJsonPathKey(\"$\", key), `Unknown document property \"${key}\".`, \"unknown_property\");\n }\n\n if (document.type !== \"doc\") {\n push(\"$.type\", 'Document type must be \"doc\".', \"invalid_document_type\");\n }\n\n if (document.version !== OPENEDITOR_DOCUMENT_FORMAT_VERSION) {\n push(\"$.version\", `Document version must be ${OPENEDITOR_DOCUMENT_FORMAT_VERSION}.`, \"unsupported_format_version\");\n }\n\n if (!Array.isArray(document.content)) {\n push(\"$.content\", \"Document content must be an array.\", \"invalid_content\");\n } else {\n const rootContent = options.contract?.rootContent;\n if (rootContent) {\n if (rootContent.minItems !== undefined && document.content.length < rootContent.minItems) push(\"$.content\", `Document requires at least ${rootContent.minItems} children.`, \"invalid_content\");\n if (rootContent.maxItems !== undefined && document.content.length > rootContent.maxItems) push(\"$.content\", `Document allows at most ${rootContent.maxItems} children.`, \"invalid_content\");\n if (rootContent.allowedTypes) document.content.forEach((child, index) => {\n if (isRecord(child) && typeof child.type === \"string\" && !rootContent.allowedTypes!.includes(child.type)) push(`$.content.${index}.type`, `Node type \"${child.type}\" is not allowed at the document root.`, \"disallowed_child\");\n });\n }\n document.content.forEach((node, index) => validateNode(node, `$.content.${index}`, 1));\n }\n\n if (\"meta\" in document && document.meta !== undefined && !isRecord(document.meta)) {\n push(\"$.meta\", \"Document meta must be an object.\", \"invalid_meta\");\n } else if (isRecord(document.meta) && options.contract) {\n const actualSchemaVersion = document.meta.schemaVersion;\n if (\n (actualSchemaVersion !== undefined || options.requireSchemaVersion)\n && actualSchemaVersion !== options.contract.schemaVersion\n ) push(\"$.meta.schemaVersion\", `Document schema version must be \"${options.contract.schemaVersion}\".`, \"schema_version_mismatch\");\n }\n if (isRecord(document.meta)) {\n for (const key of Object.keys(document.meta)) {\n if (![\"id\", \"title\", \"source\", \"createdAt\", \"updatedAt\", \"platform\", \"schemaVersion\", \"custom\"].includes(key)) push(formatJsonPathKey(\"$.meta\", key), `Unknown document metadata property \"${key}\".`, \"unknown_property\");\n }\n for (const key of [\"id\", \"title\", \"source\", \"createdAt\", \"updatedAt\", \"schemaVersion\"] as const) {\n if (document.meta[key] !== undefined && typeof document.meta[key] !== \"string\") push(`$.meta.${key}`, `Document metadata \"${key}\" must be a string.`, \"invalid_meta\");\n }\n if (document.meta.platform !== undefined && document.meta.platform !== \"web\" && document.meta.platform !== \"native\") push(\"$.meta.platform\", 'Document platform must be \"web\" or \"native\".', \"invalid_meta\");\n if (document.meta.custom !== undefined && !isPlainRecord(document.meta.custom)) push(\"$.meta.custom\", \"Custom document metadata must be a plain object.\", \"invalid_meta\");\n }\n\n return {\n valid: issues.length === 0,\n issues,\n };\n};\n\nexport const isOpenEditorDocument = (value: unknown): value is OpenEditorDocument =>\n validateDocument(value).valid;\n\nexport class OpenEditorDocumentParseError extends Error {\n readonly validation: DocumentValidationResult;\n\n constructor(validation: DocumentValidationResult) {\n super(validation.issues.map((issue) => `${issue.path}: ${issue.message}`).join(\"\\n\"));\n this.name = \"OpenEditorDocumentParseError\";\n this.validation = validation;\n }\n}\n\nexport const parseOpenEditorDocument = (\n value: unknown,\n options: ValidateDocumentOptions = {},\n): OpenEditorDocument => {\n const validation = validateDocument(value, options);\n if (!validation.valid) throw new OpenEditorDocumentParseError(validation);\n return JSON.parse(JSON.stringify(value)) as OpenEditorDocument;\n};\n\n/** Imports unversioned ProseMirror JSON. Versioned values require strict OpenEditor parsing. */\nexport const importProseMirrorDocument = (\n value: unknown,\n meta?: OpenEditorDocumentMeta,\n): OpenEditorDocument => {\n if (isRecord(value) && \"version\" in value) {\n throw new Error(\"Versioned documents must be parsed with parseOpenEditorDocument().\");\n }\n\n const validation = validateDocument(\n isRecord(value) ? { ...value, version: 1 } : value,\n );\n if (!validation.valid) throw new OpenEditorDocumentParseError(validation);\n return fromProseMirrorDocument(value as ProseMirrorDocument, meta);\n};\n\nexport const serializeEditorState = (state: SerializedEditorState): string =>\n JSON.stringify({\n document: normalizeDocument(state.document),\n ...(state.selection ? { selection: state.selection } : {}),\n });\n\nexport const parseEditorState = (\n value: unknown,\n defaultState: SerializedEditorState = createEditorState(createDocument()),\n): SerializedEditorState => {\n let parsed: unknown;\n\n try {\n parsed = typeof value === \"string\" ? JSON.parse(value) : value;\n } catch {\n return defaultState;\n }\n\n if (!isRecord(parsed)) {\n return defaultState;\n }\n\n try {\n return {\n document: parseOpenEditorDocument(parsed.document),\n selection: isRecord(parsed.selection) ? (parsed.selection as EditorSelection) : defaultState.selection,\n };\n } catch {\n return defaultState;\n }\n};\n\nexport const getPlatformDocument = (\n document: OpenEditorDocument,\n registry: BlockRegistry,\n platform: EditorPlatform,\n): OpenEditorDocument => getPlatformSupport(document, registry, platform).document;\n\nexport const getPlatformSupport = (\n document: OpenEditorDocument,\n registry: BlockRegistry,\n platform: EditorPlatform,\n): PlatformSupportResult => {\n const issues: PlatformSupportIssue[] = [];\n\n const mapNode = (node: OpenEditorBlock, path: string): OpenEditorBlock => {\n const spec = findBlockSpecForNode(registry, node);\n const support = spec?.support?.[platform] ?? \"supported\";\n\n if (support !== \"supported\") {\n issues.push({\n path,\n block: spec?.name ?? node.type,\n platform,\n support,\n });\n }\n\n return normalizeNode({\n ...cloneNode(node),\n content: node.content?.map((child, index) => mapNode(child, `${path}.content.${index}`)),\n });\n };\n\n return {\n platform,\n document: createDocument(\n document.content.map((node, index) => mapNode(node, `$.content.${index}`)),\n { ...document.meta, platform },\n ),\n issues,\n };\n};\n\nconst INLINE_NODE_TYPES = new Set([\"text\", \"hardBreak\"]);\n\nexport const getDocumentText = (node: OpenEditorDocument | ProseMirrorNode): string => {\n if (\"text\" in node && typeof node.text === \"string\") {\n return node.text;\n }\n\n const content = \"content\" in node ? node.content : undefined;\n\n if (!content?.length) {\n return \"\";\n }\n\n const isInlineContainer = content.every(\n (child) => INLINE_NODE_TYPES.has(child.type) || child.type === \"link\",\n );\n const joiner = isInlineContainer ? \"\" : \"\\n\";\n return content.map(getDocumentText).filter(Boolean).join(joiner);\n};\n\nexport const applyCommand = (\n document: OpenEditorDocument,\n registry: BlockRegistry,\n command: OpenEditorCommand,\n): OpenEditorDocument => {\n if (command.type === \"setContent\") {\n return normalizeDocument(command.document);\n }\n\n if (command.type === \"setSelection\") {\n return document;\n }\n\n if (command.type === \"moveBlock\") {\n return moveTopLevelBlock(document, command.from, command.to);\n }\n\n if (command.type === \"duplicateBlock\") {\n return duplicateTopLevelBlock(document, command.index);\n }\n\n if (command.type === \"deleteBlock\") {\n return deleteTopLevelBlock(document, command.index);\n }\n\n if (\n command.type === \"setLink\"\n || command.type === \"toggleMark\"\n || command.type === \"undo\"\n || command.type === \"redo\"\n ) {\n return normalizeDocument(document);\n }\n\n const spec = registry.get(command.block);\n if (!spec) {\n throw new Error(`Unknown block \"${command.block}\"`);\n }\n\n const nextContent = [...document.content];\n const index = command.at ?? nextContent.length;\n const defaultNode = spec.defaultNode();\n const node = command.attrs\n ? { ...defaultNode, attrs: { ...defaultNode.attrs, ...command.attrs } }\n : defaultNode;\n\n nextContent.splice(index, 0, node);\n return normalizeDocument(createDocument(nextContent, document.meta));\n};\n\nexport const replaceTopLevelRange = (\n document: OpenEditorDocument,\n start: number,\n length: number,\n replacement: ProseMirrorNode[],\n): OpenEditorDocument =>\n normalizeDocument({\n ...document,\n content: [\n ...document.content.slice(0, start),\n ...replacement.map(cloneNode),\n ...document.content.slice(start + length),\n ],\n });\n\nexport const replaceTopLevelNode = (\n document: OpenEditorDocument,\n index: number,\n replacement: ProseMirrorNode,\n): OpenEditorDocument =>\n normalizeDocument({\n ...document,\n content: document.content.map((node, nodeIndex) => nodeIndex === index ? cloneNode(replacement) : cloneNode(node)),\n });\n\nexport const moveTopLevelBlock = (\n document: OpenEditorDocument,\n from: number,\n to: number,\n): OpenEditorDocument => {\n if (from < 0 || from >= document.content.length || to < 0 || to >= document.content.length || from === to) {\n return normalizeDocument(document);\n }\n\n const nextContent = document.content.map(cloneNode);\n const [item] = nextContent.splice(from, 1);\n if (!item) {\n return normalizeDocument(document);\n }\n\n nextContent.splice(to, 0, item);\n return normalizeDocument({ ...document, content: nextContent });\n};\n\nexport const duplicateTopLevelBlock = (\n document: OpenEditorDocument,\n index: number,\n): OpenEditorDocument => {\n if (index < 0 || index >= document.content.length) {\n return normalizeDocument(document);\n }\n\n const nextContent = document.content.map(cloneNode);\n nextContent.splice(index + 1, 0, cloneNode(document.content[index]));\n return normalizeDocument({ ...document, content: nextContent });\n};\n\nexport const deleteTopLevelBlock = (\n document: OpenEditorDocument,\n index: number,\n emptyBlock: OpenEditorBlock = textBlock(\"paragraph\", \"\"),\n): OpenEditorDocument => {\n if (document.content.length <= 1) {\n return normalizeDocument({ ...document, content: [cloneNode(emptyBlock)] });\n }\n\n if (index < 0 || index >= document.content.length) {\n return normalizeDocument(document);\n }\n\n return normalizeDocument({\n ...document,\n content: document.content.filter((_, currentIndex) => currentIndex !== index).map(cloneNode),\n });\n};\n\nexport const createTransaction = (\n before: OpenEditorDocument,\n after: OpenEditorDocument,\n command?: EditorCommand,\n): EditorTransaction => ({\n before,\n after,\n ...(command ? { command } : {}),\n timestamp: new Date().toISOString(),\n});\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openeditor/core",
3
- "version": "0.0.34",
3
+ "version": "0.0.36",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "repository": {