@pixerate/editor 0.24.0 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/README.md +101 -1
  2. package/THIRD_PARTY_NOTICES.md +40 -0
  3. package/dist/agent/index.cjs +175 -11
  4. package/dist/agent/index.cjs.map +1 -1
  5. package/dist/agent/index.d.cts +18 -4
  6. package/dist/agent/index.d.ts +18 -4
  7. package/dist/agent/index.js +168 -4
  8. package/dist/agent/index.js.map +1 -1
  9. package/dist/{arrangeShortcuts-B8O3f8-P.d.cts → arrange-BICutYPk.d.cts} +243 -29
  10. package/dist/{arrangeShortcuts-sLlD2rSX.d.ts → arrange-BICutYPk.d.ts} +243 -29
  11. package/dist/builtins-CdPcLwwF.d.cts +176 -0
  12. package/dist/builtins-Chj6zv_O.d.ts +176 -0
  13. package/dist/canvas/index.cjs +8588 -1857
  14. package/dist/canvas/index.cjs.map +1 -1
  15. package/dist/canvas/index.d.cts +1847 -9
  16. package/dist/canvas/index.d.ts +1847 -9
  17. package/dist/canvas/index.js +8577 -1846
  18. package/dist/canvas/index.js.map +1 -1
  19. package/dist/chunk-3CC7OPUQ.cjs +831 -0
  20. package/dist/chunk-3CC7OPUQ.cjs.map +1 -0
  21. package/dist/chunk-4BVP64JJ.cjs +1406 -0
  22. package/dist/chunk-4BVP64JJ.cjs.map +1 -0
  23. package/dist/chunk-BVP3TSLH.cjs +69 -0
  24. package/dist/chunk-BVP3TSLH.cjs.map +1 -0
  25. package/dist/{chunk-OLZJXL4R.cjs → chunk-CS6NZWWA.cjs} +59 -25
  26. package/dist/chunk-CS6NZWWA.cjs.map +1 -0
  27. package/dist/{chunk-MCSJFWAO.cjs → chunk-EWCOFSCQ.cjs} +685 -100
  28. package/dist/chunk-EWCOFSCQ.cjs.map +1 -0
  29. package/dist/chunk-HDYMLS3X.cjs +409 -0
  30. package/dist/chunk-HDYMLS3X.cjs.map +1 -0
  31. package/dist/chunk-HRMEDT2L.js +1406 -0
  32. package/dist/chunk-HRMEDT2L.js.map +1 -0
  33. package/dist/{chunk-D27YFC46.cjs → chunk-IFHKKVXH.cjs} +382 -63
  34. package/dist/chunk-IFHKKVXH.cjs.map +1 -0
  35. package/dist/{chunk-PGNZKFQS.js → chunk-JOIREKL7.js} +137 -58
  36. package/dist/chunk-JOIREKL7.js.map +1 -0
  37. package/dist/chunk-KRGXUQ2Y.js +1696 -0
  38. package/dist/chunk-KRGXUQ2Y.js.map +1 -0
  39. package/dist/{chunk-3LV6RRPH.js → chunk-MHEPLBFB.js} +2 -2
  40. package/dist/chunk-MR2764X2.js +831 -0
  41. package/dist/chunk-MR2764X2.js.map +1 -0
  42. package/dist/{chunk-XNORY7M6.cjs → chunk-NFVBT3UZ.cjs} +166 -87
  43. package/dist/chunk-NFVBT3UZ.cjs.map +1 -0
  44. package/dist/chunk-NQF32I6Z.cjs +6478 -0
  45. package/dist/chunk-NQF32I6Z.cjs.map +1 -0
  46. package/dist/chunk-O5RYH2PG.js +69 -0
  47. package/dist/chunk-O5RYH2PG.js.map +1 -0
  48. package/dist/{chunk-ITBSKI26.js → chunk-Q2OHWD2A.js} +1064 -360
  49. package/dist/chunk-Q2OHWD2A.js.map +1 -0
  50. package/dist/{chunk-FODNLX5N.js → chunk-QJSOZFCZ.js} +38 -4
  51. package/dist/chunk-QJSOZFCZ.js.map +1 -0
  52. package/dist/{chunk-SML64VJG.cjs → chunk-RRREAOVM.cjs} +4 -4
  53. package/dist/{chunk-SML64VJG.cjs.map → chunk-RRREAOVM.cjs.map} +1 -1
  54. package/dist/{chunk-5S3Z4PPF.js → chunk-SWE3NPOU.js} +347 -28
  55. package/dist/chunk-SWE3NPOU.js.map +1 -0
  56. package/dist/chunk-TXXNBDQX.cjs +1696 -0
  57. package/dist/chunk-TXXNBDQX.cjs.map +1 -0
  58. package/dist/chunk-UBCFIABU.js +409 -0
  59. package/dist/chunk-UBCFIABU.js.map +1 -0
  60. package/dist/chunk-X7HXL2SB.js +6478 -0
  61. package/dist/chunk-X7HXL2SB.js.map +1 -0
  62. package/dist/{chunk-SBCZ6RN5.cjs → chunk-YOMYSFJU.cjs} +1163 -459
  63. package/dist/chunk-YOMYSFJU.cjs.map +1 -0
  64. package/dist/{chunk-3CN2WD3X.js → chunk-ZRNHGAQT.js} +661 -76
  65. package/dist/chunk-ZRNHGAQT.js.map +1 -0
  66. package/dist/commands/index.cjs +425 -4
  67. package/dist/commands/index.cjs.map +1 -1
  68. package/dist/commands/index.d.cts +39 -77
  69. package/dist/commands/index.d.ts +39 -77
  70. package/dist/commands/index.js +424 -3
  71. package/dist/commands/index.js.map +1 -1
  72. package/dist/compare/index.cjs +3 -3
  73. package/dist/compare/index.d.cts +1 -1
  74. package/dist/compare/index.d.ts +1 -1
  75. package/dist/compare/index.js +2 -2
  76. package/dist/controller-CxXGOEmy.d.cts +2038 -0
  77. package/dist/controller-CxXGOEmy.d.ts +2038 -0
  78. package/dist/{documents-BQjzJNe2.d.ts → documents-CHT1U5Vs.d.ts} +10 -0
  79. package/dist/{documents-KRTPhvst.d.cts → documents-Gp7wb0Me.d.cts} +10 -0
  80. package/dist/export/index.cjs +36 -0
  81. package/dist/export/index.cjs.map +1 -0
  82. package/dist/export/index.d.cts +243 -0
  83. package/dist/export/index.d.ts +243 -0
  84. package/dist/export/index.js +36 -0
  85. package/dist/export/index.js.map +1 -0
  86. package/dist/extensions/index.cjs +101 -6
  87. package/dist/extensions/index.cjs.map +1 -1
  88. package/dist/extensions/index.d.cts +18 -5
  89. package/dist/extensions/index.d.ts +18 -5
  90. package/dist/extensions/index.js +101 -6
  91. package/dist/generation/index.cjs +1013 -69
  92. package/dist/generation/index.cjs.map +1 -1
  93. package/dist/generation/index.d.cts +474 -13
  94. package/dist/generation/index.d.ts +474 -13
  95. package/dist/generation/index.js +976 -32
  96. package/dist/generation/index.js.map +1 -1
  97. package/dist/image-editor/index.cjs +3385 -1275
  98. package/dist/image-editor/index.cjs.map +1 -1
  99. package/dist/image-editor/index.d.cts +693 -128
  100. package/dist/image-editor/index.d.ts +693 -128
  101. package/dist/image-editor/index.js +3325 -1215
  102. package/dist/image-editor/index.js.map +1 -1
  103. package/dist/{index-fJrlkJCd.d.ts → index-B273Zllk.d.ts} +500 -7
  104. package/dist/{index-BhJBSm2d.d.cts → index-jcJwmBYt.d.cts} +500 -7
  105. package/dist/index.cjs +1603 -45
  106. package/dist/index.cjs.map +1 -1
  107. package/dist/index.d.cts +154 -27
  108. package/dist/index.d.ts +154 -27
  109. package/dist/index.js +1584 -26
  110. package/dist/index.js.map +1 -1
  111. package/dist/mention-text-CDnCFd3c.d.cts +53 -0
  112. package/dist/mention-text-CDnCFd3c.d.ts +53 -0
  113. package/dist/model-C1zApQM8.d.cts +219 -0
  114. package/dist/model-C1zApQM8.d.ts +219 -0
  115. package/dist/persistence/index.d.cts +3 -120
  116. package/dist/persistence/index.d.ts +3 -120
  117. package/dist/registry-CED5C0lA.d.cts +204 -0
  118. package/dist/registry-CED5C0lA.d.ts +204 -0
  119. package/dist/{registry-GJI4gToU.d.cts → registry-CEgwXED1.d.cts} +12 -1
  120. package/dist/{registry-GJI4gToU.d.ts → registry-CEgwXED1.d.ts} +12 -1
  121. package/dist/{registry-D32LpIc4.d.cts → registry-D0GADKc7.d.cts} +1 -1
  122. package/dist/{registry-evKTP4ls.d.ts → registry-DhVUZioj.d.ts} +1 -1
  123. package/dist/serializers/index.cjs +12 -4
  124. package/dist/serializers/index.cjs.map +1 -1
  125. package/dist/serializers/index.d.cts +41 -13
  126. package/dist/serializers/index.d.ts +41 -13
  127. package/dist/serializers/index.js +12 -4
  128. package/dist/spreadsheet/index.cjs +157 -3
  129. package/dist/spreadsheet/index.cjs.map +1 -1
  130. package/dist/spreadsheet/index.d.cts +534 -11
  131. package/dist/spreadsheet/index.d.ts +534 -11
  132. package/dist/spreadsheet/index.js +157 -3
  133. package/dist/storage-BpFfspHm.d.cts +120 -0
  134. package/dist/storage-BpFfspHm.d.ts +120 -0
  135. package/dist/tokens/index.cjs +115 -0
  136. package/dist/tokens/index.cjs.map +1 -0
  137. package/dist/tokens/index.d.cts +212 -0
  138. package/dist/tokens/index.d.ts +212 -0
  139. package/dist/tokens/index.js +115 -0
  140. package/dist/tokens/index.js.map +1 -0
  141. package/dist/{track-changes-BK5sVf4_.d.cts → track-changes-D_VAPELi.d.cts} +95 -11
  142. package/dist/{track-changes-CDjCrwKe.d.ts → track-changes-Db_fGEvx.d.ts} +95 -11
  143. package/package.json +15 -1
  144. package/dist/chunk-3CN2WD3X.js.map +0 -1
  145. package/dist/chunk-5S3Z4PPF.js.map +0 -1
  146. package/dist/chunk-D27YFC46.cjs.map +0 -1
  147. package/dist/chunk-FODNLX5N.js.map +0 -1
  148. package/dist/chunk-ITBSKI26.js.map +0 -1
  149. package/dist/chunk-MA2F5KHF.cjs +0 -3223
  150. package/dist/chunk-MA2F5KHF.cjs.map +0 -1
  151. package/dist/chunk-MCSJFWAO.cjs.map +0 -1
  152. package/dist/chunk-OLZJXL4R.cjs.map +0 -1
  153. package/dist/chunk-PGNZKFQS.js.map +0 -1
  154. package/dist/chunk-SBCZ6RN5.cjs.map +0 -1
  155. package/dist/chunk-U5KWZU4X.js +0 -3223
  156. package/dist/chunk-U5KWZU4X.js.map +0 -1
  157. package/dist/chunk-XNORY7M6.cjs.map +0 -1
  158. package/dist/controller-BhLLAoi8.d.cts +0 -1000
  159. package/dist/controller-BhLLAoi8.d.ts +0 -1000
  160. package/dist/types-DX4Mh4SL.d.cts +0 -217
  161. package/dist/types-DX4Mh4SL.d.ts +0 -217
  162. /package/dist/{chunk-3LV6RRPH.js.map → chunk-MHEPLBFB.js.map} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/extensions/paragraph-styles/registry.ts","../src/import/zip.ts"],"sourcesContent":["// Portions ported from wordcraft/crates/doc/src/styles.rs and wordcraft/crates/doc/src/resolve.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\n\n/** Paragraph styles format whole blocks; character styles format runs of text. */\nexport type StyleKind = \"paragraph\" | \"character\";\n\n/** Character formatting of a style (CSS values). */\nexport interface CharacterFormat {\n fontFamily?: string;\n /** CSS length, e.g. `\"1.5em\"` or `\"18px\"`. */\n fontSize?: string;\n bold?: boolean;\n italic?: boolean;\n underline?: boolean;\n strike?: boolean;\n color?: string;\n backgroundColor?: string;\n letterSpacing?: string;\n textTransform?: \"none\" | \"uppercase\" | \"lowercase\" | \"capitalize\";\n smallCaps?: boolean;\n}\n\n/** Paragraph formatting of a style (CSS values). */\nexport interface ParagraphFormat {\n textAlign?: \"left\" | \"center\" | \"right\" | \"justify\";\n lineHeight?: string;\n spaceBefore?: string;\n spaceAfter?: string;\n indentLeft?: string;\n indentRight?: string;\n indentFirstLine?: string;\n /** CSS border shorthand, e.g. `\"3px solid currentColor\"`. */\n borderLeft?: string;\n paddingLeft?: string;\n backgroundColor?: string;\n}\n\n/** The block node a paragraph style uses (`heading` with `level` for Heading N). */\nexport interface StyleBlock {\n type: string;\n attrs?: Record<string, any>;\n}\n\nexport interface StyleDefinition {\n /** Stable id (`Heading1`): letters, digits, `_` and `-`, starting with a letter. */\n id: string;\n /** Display name (`Heading 1`). */\n name: string;\n kind: StyleKind;\n /** Style this one inherits from; what it sets wins over its base. */\n basedOn?: string | null;\n /** Style of the paragraph after this one when Enter is pressed at its end (paragraph styles). */\n next?: string | null;\n /** Linked style: a paragraph style's character style, or a character style's paragraph style. */\n linked?: string | null;\n paragraph?: ParagraphFormat;\n character?: CharacterFormat;\n /** Block node of a paragraph style. Inherited along `basedOn`; `paragraph` by default. */\n block?: StyleBlock | null;\n /** Gallery order (lower first). */\n priority?: number;\n /** Shown in the styles gallery. */\n quick?: boolean;\n hidden?: boolean;\n /** Built in (cannot be removed). */\n builtin?: boolean;\n}\n\n/** A style with its `basedOn` chain and the defaults merged. */\nexport interface ResolvedStyle {\n id: string;\n paragraph: ParagraphFormat;\n character: CharacterFormat;\n block: StyleBlock;\n /** Id of the style after Enter at the end of a paragraph. */\n next: string;\n}\n\nexport interface StyleDefaults {\n paragraph?: ParagraphFormat;\n character?: CharacterFormat;\n}\n\nexport interface StyleRegistryOptions {\n /** Styles added to (or replacing) the built-in ones. */\n styles?: readonly StyleDefinition[];\n /** Include the built-in styles. Default `true`. */\n builtins?: boolean;\n /** Document defaults, applied below every style. */\n defaults?: StyleDefaults;\n}\n\nexport interface StyleRegistrySnapshot {\n styles: readonly StyleDefinition[];\n defaults: StyleDefaults;\n /** Increases on every change. */\n version: number;\n}\n\n/** Serializable registry content (`registry.toJSON()`). */\nexport interface StyleRegistryJSON {\n styles: StyleDefinition[];\n defaults: StyleDefaults;\n}\n\nexport interface StyleCSSOptions {\n /** Selector the rules are scoped to. Default `.ProseMirror`. */\n scope?: string;\n /**\n * Element selector of blocks that use a style without naming it\n * (`data-style` absent), e.g. `h2` for Heading 2. Return `null` for none.\n */\n tagFor?: (block: StyleBlock) => string | null;\n}\n\n/** Longest `basedOn` chain followed (cycle and depth guard). */\nconst MAX_CHAIN = 32;\nconst STYLE_ID = /^[A-Za-z][A-Za-z0-9_-]{0,63}$/;\n/** CSS values that could escape a declaration or load resources are dropped. */\nconst UNSAFE_CSS = /[;{}<>\\\\]|\\/\\*|url\\s*\\(|expression\\s*\\(|@import|javascript:/i;\n\nexport const NORMAL_STYLE_ID = \"Normal\";\n\nconst PREVIEW_PROPERTIES = new Set([\n \"font-family\",\n \"font-weight\",\n \"font-style\",\n \"color\",\n \"text-decoration-line\",\n \"text-transform\",\n \"letter-spacing\",\n \"font-variant-caps\",\n]);\n\n/** Whether `id` is a valid style id. */\nexport function isValidStyleId(id: unknown): id is string {\n return typeof id === \"string\" && STYLE_ID.test(id);\n}\n\nconst MUTED = \"var(--pixerate-style-muted, #6b7280)\";\nconst HEADING_SIZES = [\"2em\", \"1.5em\", \"1.25em\", \"1.1em\", \"1em\", \"0.9em\"];\n\nfunction builtinStyles(): StyleDefinition[] {\n const styles: StyleDefinition[] = [\n {\n id: NORMAL_STYLE_ID,\n name: \"Normal\",\n kind: \"paragraph\",\n block: { type: \"paragraph\" },\n priority: 0,\n quick: true,\n builtin: true,\n },\n {\n id: \"Title\",\n name: \"Title\",\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n next: NORMAL_STYLE_ID,\n linked: \"TitleChar\",\n paragraph: { spaceAfter: \"0.25em\", lineHeight: \"1.15\" },\n character: { fontSize: \"2.5em\", bold: true, letterSpacing: \"-0.01em\" },\n priority: 10,\n quick: true,\n builtin: true,\n },\n {\n id: \"Subtitle\",\n name: \"Subtitle\",\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n next: NORMAL_STYLE_ID,\n linked: \"SubtitleChar\",\n paragraph: { spaceAfter: \"0.75em\" },\n character: { fontSize: \"1.25em\", color: MUTED },\n priority: 11,\n quick: true,\n builtin: true,\n },\n ];\n HEADING_SIZES.forEach((fontSize, i) => {\n const level = i + 1;\n styles.push({\n id: `Heading${level}`,\n name: `Heading ${level}`,\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n next: NORMAL_STYLE_ID,\n linked: `Heading${level}Char`,\n block: { type: \"heading\", attrs: { level } },\n paragraph: { spaceBefore: level <= 2 ? \"1em\" : \"0.75em\", spaceAfter: \"0.25em\" },\n character: { fontSize, bold: true },\n priority: 11 + level,\n quick: level <= 3,\n builtin: true,\n });\n });\n styles.push(\n {\n id: \"Quote\",\n name: \"Quote\",\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n next: NORMAL_STYLE_ID,\n linked: \"QuoteChar\",\n paragraph: { indentLeft: \"1em\", paddingLeft: \"0.75em\", borderLeft: \"3px solid currentColor\" },\n character: { italic: true, color: MUTED },\n priority: 29,\n quick: true,\n builtin: true,\n },\n {\n id: \"Code\",\n name: \"Code\",\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n next: NORMAL_STYLE_ID,\n block: { type: \"codeBlock\" },\n character: {\n fontFamily: \"ui-monospace, SFMono-Regular, Menlo, Consolas, monospace\",\n fontSize: \"0.9em\",\n },\n priority: 30,\n quick: true,\n builtin: true,\n },\n {\n id: \"ListParagraph\",\n name: \"List Paragraph\",\n kind: \"paragraph\",\n basedOn: NORMAL_STYLE_ID,\n paragraph: { indentLeft: \"2em\" },\n priority: 34,\n quick: true,\n builtin: true,\n },\n );\n // Linked character styles: their formatting is the paragraph style's.\n const linked = [\"Title\", \"Subtitle\", \"Quote\", ...HEADING_SIZES.map((_, i) => `Heading${i + 1}`)];\n linked.forEach((paragraphId) => {\n const name = styles.find((s) => s.id === paragraphId)!.name;\n styles.push({\n id: `${paragraphId}Char`,\n name: `${name} Char`,\n kind: \"character\",\n linked: paragraphId,\n priority: 99,\n hidden: true,\n builtin: true,\n });\n });\n styles.push(\n {\n id: \"Emphasis\",\n name: \"Emphasis\",\n kind: \"character\",\n character: { italic: true },\n priority: 20,\n quick: true,\n builtin: true,\n },\n {\n id: \"Strong\",\n name: \"Strong\",\n kind: \"character\",\n character: { bold: true },\n priority: 22,\n quick: true,\n builtin: true,\n },\n );\n return styles;\n}\n\n/** The built-in styles: Normal, Title, Subtitle, Heading 1–6, Quote, Code, List Paragraph and character styles. */\nexport const DEFAULT_STYLES: readonly StyleDefinition[] = Object.freeze(builtinStyles());\n\nconst clone = <T>(value: T): T => (value === undefined ? value : JSON.parse(JSON.stringify(value)));\n\n/** Copies only defined values of `patch` over `base`. */\nfunction overlay<T extends object>(base: T, patch: T | undefined | null): T {\n if (!patch) return base;\n const out: Record<string, unknown> = { ...(base as Record<string, unknown>) };\n Object.entries(patch).forEach(([key, value]) => {\n if (value !== undefined && value !== null) out[key] = value;\n });\n return out as T;\n}\n\nfunction sameBlock(a: StyleBlock, type: string, attrs: Record<string, any>): boolean {\n if (a.type !== type) return false;\n return Object.entries(a.attrs ?? {}).every(([key, value]) => attrs[key] === value);\n}\n\n/**\n * Style definitions with `basedOn` inheritance, next-style and linked\n * character/paragraph styles, resolved in cascade order: document defaults →\n * style chain (base first) → direct formatting. Chains are cycle-safe.\n *\n * `subscribe` calls the listener immediately and on every change (Svelte\n * store contract); `getSnapshot` is stable between changes.\n */\nexport class StyleRegistry {\n private styles = new Map<string, StyleDefinition>();\n private defaults: StyleDefaults;\n private version = 0;\n private snapshot: StyleRegistrySnapshot | null = null;\n private listeners = new Set<(snapshot: StyleRegistrySnapshot) => void>();\n\n constructor(options: StyleRegistryOptions = {}) {\n this.defaults = clone(options.defaults ?? {});\n if (options.builtins !== false) DEFAULT_STYLES.forEach((style) => this.styles.set(style.id, clone(style)));\n (options.styles ?? []).forEach((style) => this.put(style));\n }\n\n // -- Reading --------------------------------------------------------------\n\n get(id: string | null | undefined): StyleDefinition | undefined {\n return id ? this.styles.get(id) : undefined;\n }\n\n /** Finds a style by id or display name (case-insensitive). */\n find(nameOrId: string): StyleDefinition | undefined {\n const direct = this.styles.get(nameOrId);\n if (direct) return direct;\n const lower = nameOrId.toLowerCase();\n return this.list().find((style) => style.name.toLowerCase() === lower);\n }\n\n /** All styles (optionally of one kind) in gallery order. */\n list(kind?: StyleKind): StyleDefinition[] {\n return Array.from(this.styles.values())\n .filter((style) => !kind || style.kind === kind)\n .sort((a, b) => (a.priority ?? 99) - (b.priority ?? 99) || a.name.localeCompare(b.name));\n }\n\n /** Styles shown in the gallery (`quick`, not hidden), paragraph styles by default. */\n gallery(kind: StyleKind = \"paragraph\"): StyleDefinition[] {\n return this.list(kind).filter((style) => style.quick && !style.hidden);\n }\n\n /** The `basedOn` chain from the root style down to `id` (cycle-safe, bounded). */\n chain(id: string): StyleDefinition[] {\n const out: StyleDefinition[] = [];\n let current = this.styles.get(id);\n while (current && out.length < MAX_CHAIN && !out.includes(current)) {\n out.push(current);\n current = current.basedOn ? this.styles.get(current.basedOn) : undefined;\n }\n return out.reverse();\n }\n\n /**\n * Resolves a paragraph style: defaults, then each style of the chain (base\n * first). Unknown ids resolve to the defaults in a `paragraph` block.\n */\n resolve(id: string): ResolvedStyle {\n let paragraph = overlay<ParagraphFormat>({}, this.defaults.paragraph);\n let character = overlay<CharacterFormat>({}, this.defaults.character);\n let block: StyleBlock = { type: \"paragraph\" };\n this.chain(id).forEach((style) => {\n if (style.kind !== \"paragraph\") return;\n paragraph = overlay(paragraph, style.paragraph);\n character = overlay(character, style.character);\n if (style.block) block = clone(style.block);\n });\n return { id, paragraph, character, block, next: this.nextStyleId(id) };\n }\n\n /** Character formatting a paragraph style's chain sets (without defaults). */\n private paragraphCharacter(id: string): CharacterFormat {\n let character: CharacterFormat = {};\n this.chain(id).forEach((style) => {\n if (style.kind === \"paragraph\") character = overlay(character, style.character);\n });\n return character;\n }\n\n /**\n * Character formatting of a character style's chain. A style linked to a\n * paragraph style takes that style's character formatting first.\n */\n resolveCharacterStyle(id: string): CharacterFormat {\n let character: CharacterFormat = {};\n this.chain(id).forEach((style) => {\n if (style.kind === \"character\" && style.linked && this.get(style.linked)?.kind === \"paragraph\") {\n character = overlay(character, this.paragraphCharacter(style.linked));\n }\n character = overlay(character, style.character);\n });\n return character;\n }\n\n /**\n * Character formatting of text: defaults → paragraph style chain →\n * character style chain → direct formatting.\n */\n resolveText(input: {\n paragraphStyle?: string | null;\n characterStyle?: string | null;\n direct?: CharacterFormat;\n }): CharacterFormat {\n let character = this.resolve(input.paragraphStyle || NORMAL_STYLE_ID).character;\n if (input.characterStyle) character = overlay(character, this.resolveCharacterStyle(input.characterStyle));\n return overlay(character, input.direct);\n }\n\n /** The style after Enter at the end of a paragraph of `id` (itself when unset or unknown). */\n nextStyleId(id: string): string {\n const next = this.styles.get(id)?.next;\n return next && this.styles.get(next)?.kind === \"paragraph\" ? next : id;\n }\n\n /** The linked character style of a paragraph style, if any. */\n linkedCharacterStyle(id: string): StyleDefinition | undefined {\n const style = this.styles.get(id);\n const linked = style?.linked ? this.styles.get(style.linked) : undefined;\n return style?.kind === \"paragraph\" && linked?.kind === \"character\" ? linked : undefined;\n }\n\n /**\n * The style a block uses when it names none: Normal for paragraphs,\n * Heading N for headings of level N, Code for code blocks (the built-in\n * style whose own `block` matches).\n */\n defaultStyleFor(type: string, attrs: Record<string, any> = {}): string | null {\n if (type === \"paragraph\" && this.styles.get(NORMAL_STYLE_ID)) return NORMAL_STYLE_ID;\n const candidates = this.list(\"paragraph\").filter(\n (style) => style.block && sameBlock(style.block, type, attrs),\n );\n return (candidates.find((s) => s.builtin) ?? candidates[0])?.id ?? null;\n }\n\n /** The style of a block: its `styleId` when known, otherwise the block's default style. */\n styleOfBlock(type: string, attrs: Record<string, any> = {}): string | null {\n const id = attrs.styleId;\n if (id && this.styles.get(id)?.kind === \"paragraph\") return id;\n return this.defaultStyleFor(type, attrs);\n }\n\n getSnapshot = (): StyleRegistrySnapshot => {\n if (!this.snapshot) {\n this.snapshot = Object.freeze({\n styles: Object.freeze(this.list()),\n defaults: this.defaults,\n version: this.version,\n });\n }\n return this.snapshot;\n };\n\n subscribe = (listener: (snapshot: StyleRegistrySnapshot) => void): (() => void) => {\n this.listeners.add(listener);\n listener(this.getSnapshot());\n return () => {\n this.listeners.delete(listener);\n };\n };\n\n toJSON(): StyleRegistryJSON {\n return { styles: clone(Array.from(this.styles.values())), defaults: clone(this.defaults) };\n }\n\n // -- Writing --------------------------------------------------------------\n\n /** Adds or replaces a style. Throws on an invalid id. */\n upsert(style: StyleDefinition): StyleDefinition {\n const stored = this.put(style);\n this.changed();\n return stored;\n }\n\n /** Merges `patch` into a style (formats are merged key by key). Returns `undefined` for unknown ids. */\n update(id: string, patch: Partial<Omit<StyleDefinition, \"id\">>): StyleDefinition | undefined {\n const current = this.styles.get(id);\n if (!current) return undefined;\n const next: StyleDefinition = {\n ...current,\n ...patch,\n id,\n paragraph: patch.paragraph ? { ...current.paragraph, ...patch.paragraph } : current.paragraph,\n character: patch.character ? { ...current.character, ...patch.character } : current.character,\n };\n return this.upsert(next);\n }\n\n /**\n * Removes a style and returns it. Built-in styles cannot be removed. Styles\n * based on it are rebased onto its own base, and `next`/`linked`\n * references to it are dropped.\n */\n remove(id: string): StyleDefinition | undefined {\n const gone = this.styles.get(id);\n if (!gone || gone.builtin) return undefined;\n this.styles.delete(id);\n this.styles.forEach((style, key) => {\n let changed = style;\n if (style.basedOn === id) {\n changed = { ...changed, basedOn: gone.basedOn && gone.basedOn !== key ? gone.basedOn : null };\n }\n if (style.next === id) changed = { ...changed, next: null };\n if (style.linked === id) changed = { ...changed, linked: null };\n if (changed !== style) this.styles.set(key, changed);\n });\n this.changed();\n return gone;\n }\n\n /** Replaces the document defaults. */\n setDefaults(defaults: StyleDefaults): void {\n this.defaults = clone(defaults);\n this.changed();\n }\n\n /** An unused id derived from a display name (`My Style` → `MyStyle`, then `MyStyle1`, …). */\n newId(name: string): string {\n let base = name.replace(/[^A-Za-z0-9_-]+/g, \"\").replace(/^[^A-Za-z]+/, \"\").slice(0, 56);\n if (!base) base = \"Style\";\n if (!this.styles.has(base)) return base;\n for (let i = 1; i < 100000; i++) {\n const id = `${base}${i}`;\n if (!this.styles.has(id)) return id;\n }\n return `${base}${Date.now()}`;\n }\n\n // -- CSS --------------------------------------------------------------------\n\n /** CSS declarations (`property: value`) of a resolved paragraph or character style. */\n cssDeclarations(id: string): Record<string, string> {\n const style = this.styles.get(id);\n if (style?.kind === \"character\") return characterCSS(this.resolveCharacterStyle(id));\n const resolved = this.resolve(id);\n return { ...paragraphCSS(resolved.paragraph), ...characterCSS(resolved.character) };\n }\n\n /**\n * Declarations for previewing a style in a menu or gallery: font family,\n * weight, style, color, decoration, case and letter spacing (no sizes,\n * margins or borders).\n */\n previewDeclarations(id: string): Record<string, string> {\n return Object.fromEntries(\n Object.entries(this.cssDeclarations(id)).filter(([property]) => PREVIEW_PROPERTIES.has(property)),\n );\n }\n\n /**\n * A stylesheet for the styles: `[data-style=\"Id\"]` rules for paragraph\n * styles (plus the plain element of blocks that use their default style,\n * e.g. `h2:not([data-style])`), `[data-char-style=\"Id\"]` for character\n * styles and the defaults on the scope element.\n */\n toCSS(options: StyleCSSOptions = {}): string {\n const scope = options.scope ?? \".ProseMirror\";\n const tagFor = options.tagFor ?? defaultTagFor;\n const rules: string[] = [];\n const rule = (selectors: string[], declarations: Record<string, string>) => {\n const body = Object.entries(declarations)\n .map(([property, value]) => `${property}: ${value};`)\n .join(\" \");\n if (body) rules.push(`${selectors.join(\", \")} { ${body} }`);\n };\n rule([scope], {\n ...paragraphCSS(this.defaults.paragraph ?? {}),\n ...characterCSS(this.defaults.character ?? {}),\n });\n this.list().forEach((style) => {\n if (style.kind === \"character\") {\n rule([`${scope} [data-char-style=\"${style.id}\"]`], this.cssDeclarations(style.id));\n return;\n }\n const selectors = [`${scope} [data-style=\"${style.id}\"]`];\n const block = this.resolve(style.id).block;\n if (this.defaultStyleFor(block.type, block.attrs ?? {}) === style.id) {\n const tag = tagFor(block);\n if (tag) selectors.push(`${scope} ${tag}:not([data-style])`);\n }\n // Defaults already apply to the scope; repeat only what the chain sets.\n const resolved = this.resolve(style.id);\n const own = {\n ...paragraphCSS(withoutDefaults(resolved.paragraph, this.defaults.paragraph)),\n ...characterCSS(withoutDefaults(resolved.character, this.defaults.character)),\n };\n rule(selectors, own);\n });\n return rules.join(\"\\n\");\n }\n\n // -- Internals --------------------------------------------------------------\n\n private put(style: StyleDefinition): StyleDefinition {\n if (!isValidStyleId(style.id)) throw new Error(`Invalid style id: ${String(style.id)}`);\n if (style.kind !== \"paragraph\" && style.kind !== \"character\") {\n throw new Error(`Invalid style kind: ${String(style.kind)}`);\n }\n const stored = clone({ ...style, name: style.name || style.id });\n this.styles.set(style.id, stored);\n return stored;\n }\n\n private changed(): void {\n this.version++;\n this.snapshot = null;\n const snapshot = this.getSnapshot();\n this.listeners.forEach((listener) => {\n try {\n listener(snapshot);\n } catch (err) {\n console.error(\"[StyleRegistry] Error in listener:\", err);\n }\n });\n }\n}\n\nfunction withoutDefaults<T extends object>(format: T, defaults: T | undefined): T {\n if (!defaults) return format;\n const out: Record<string, unknown> = {};\n Object.entries(format).forEach(([key, value]) => {\n if ((defaults as Record<string, unknown>)[key] !== value) out[key] = value;\n });\n return out as T;\n}\n\nfunction defaultTagFor(block: StyleBlock): string | null {\n if (block.type === \"paragraph\") return \"p\";\n if (block.type === \"heading\") {\n const level = Number(block.attrs?.level);\n return level >= 1 && level <= 6 ? `h${level}` : null;\n }\n if (block.type === \"codeBlock\") return \"pre\";\n return null;\n}\n\n/** A CSS value, or `undefined` when it is unsafe or empty. */\nexport function safeCSSValue(value: unknown): string | undefined {\n if (typeof value !== \"string\") return undefined;\n const trimmed = value.trim();\n if (!trimmed || trimmed.length > 200 || UNSAFE_CSS.test(trimmed)) return undefined;\n return trimmed;\n}\n\nfunction paragraphCSS(format: ParagraphFormat): Record<string, string> {\n const out: Record<string, string> = {};\n const set = (property: string, value: unknown) => {\n const safe = safeCSSValue(value);\n if (safe) out[property] = safe;\n };\n set(\"text-align\", format.textAlign);\n set(\"line-height\", format.lineHeight);\n set(\"margin-top\", format.spaceBefore);\n set(\"margin-bottom\", format.spaceAfter);\n set(\"margin-left\", format.indentLeft);\n set(\"margin-right\", format.indentRight);\n set(\"text-indent\", format.indentFirstLine);\n set(\"border-left\", format.borderLeft);\n set(\"padding-left\", format.paddingLeft);\n set(\"background-color\", format.backgroundColor);\n return out;\n}\n\nfunction characterCSS(format: CharacterFormat): Record<string, string> {\n const out: Record<string, string> = {};\n const set = (property: string, value: unknown) => {\n const safe = safeCSSValue(value);\n if (safe) out[property] = safe;\n };\n set(\"font-family\", format.fontFamily);\n set(\"font-size\", format.fontSize);\n if (format.bold !== undefined) out[\"font-weight\"] = format.bold ? \"700\" : \"400\";\n if (format.italic !== undefined) out[\"font-style\"] = format.italic ? \"italic\" : \"normal\";\n const lines = [format.underline && \"underline\", format.strike && \"line-through\"].filter(Boolean);\n if (format.underline !== undefined || format.strike !== undefined) {\n out[\"text-decoration-line\"] = lines.length ? lines.join(\" \") : \"none\";\n }\n set(\"color\", format.color);\n set(\"background-color\", format.backgroundColor);\n set(\"letter-spacing\", format.letterSpacing);\n set(\"text-transform\", format.textTransform);\n if (format.smallCaps !== undefined) out[\"font-variant-caps\"] = format.smallCaps ? \"small-caps\" : \"normal\";\n return out;\n}\n\n/** Creates a style registry with the built-in styles (unless `builtins: false`) and `styles`. */\nexport function createStyleRegistry(options: StyleRegistryOptions | StyleRegistryJSON = {}): StyleRegistry {\n return new StyleRegistry(options as StyleRegistryOptions);\n}\n","/**\n * Minimal, dependency-free ZIP reader used by the DOCX and zipped-export\n * import adapters.\n *\n * - Reads the central directory (including ZIP64 end records and extra\n * fields), so sizes come from the authoritative directory rather than local\n * headers or data descriptors.\n * - Supports stored (method 0) and deflate (method 8) entries; deflate is\n * inflated with the platform `DecompressionStream(\"deflate-raw\")` (modern\n * browsers, Node ≥ 18).\n * - Guards against zip bombs (entry-count and total-uncompressed-size caps,\n * enforced on the bytes actually inflated, not only the declared sizes),\n * path traversal in entry names and encrypted entries.\n * - Verifies CRC-32 checksums of extracted entries.\n */\n\nexport type ZipErrorCode =\n /** Not a ZIP archive, or its directory is truncated / inconsistent. */\n | \"invalid_archive\"\n /** Compression method other than stored/deflate, multi-disk archives, … */\n | \"unsupported_feature\"\n /** The entry is encrypted (general-purpose flag bit 0). */\n | \"encrypted\"\n /** An entry name is absolute or contains `..` segments. */\n | \"unsafe_path\"\n /** More entries than `maxEntries`. */\n | \"too_many_entries\"\n /** Extracting would exceed `maxTotalSize` uncompressed bytes. */\n | \"too_large\"\n /** The entry data is corrupt (bad header, size or CRC mismatch, bad deflate stream). */\n | \"corrupt_entry\"\n /** No entry with the requested name. */\n | \"entry_not_found\"\n /** `DecompressionStream` is unavailable in this environment. */\n | \"unsupported_environment\";\n\nexport class ZipError extends Error {\n readonly code: ZipErrorCode;\n readonly entryName?: string;\n\n constructor(code: ZipErrorCode, message: string, details: { entryName?: string; cause?: unknown } = {}) {\n super(message, details.cause !== undefined ? { cause: details.cause } : undefined);\n this.name = \"ZipError\";\n this.code = code;\n this.entryName = details.entryName;\n }\n}\n\nexport interface ZipEntry {\n /** Entry path with `/` separators (backslashes are normalized). */\n name: string;\n /** Whether the entry is a directory (name ends with `/`). */\n isDirectory: boolean;\n /** Whether the entry is encrypted; reading it throws `ZipError(\"encrypted\")`. */\n encrypted: boolean;\n /** Compression method (0 = stored, 8 = deflate). */\n method: number;\n /** Declared compressed size in bytes. */\n compressedSize: number;\n /** Declared uncompressed size in bytes. */\n size: number;\n /** CRC-32 of the uncompressed data. */\n crc32: number;\n /** Offset of the entry's local file header. */\n localHeaderOffset: number;\n}\n\nexport interface ZipReadOptions {\n /** Maximum number of entries in the central directory (default 10 000). */\n maxEntries?: number;\n /**\n * Maximum number of uncompressed bytes extracted from the archive, summed\n * over every `read` call (default 256 MiB). Enforced while inflating.\n */\n maxTotalSize?: number;\n /**\n * What to do with entries whose names are absolute or contain `..`\n * segments: `\"error\"` (default) rejects the archive, `\"skip\"` leaves them\n * out of `entries`.\n */\n unsafePaths?: \"error\" | \"skip\";\n}\n\nexport const DEFAULT_ZIP_MAX_ENTRIES = 10_000;\nexport const DEFAULT_ZIP_MAX_TOTAL_SIZE = 256 * 1024 * 1024;\n\nconst SIG_EOCD = 0x06054b50;\nconst SIG_ZIP64_EOCD = 0x06064b50;\nconst SIG_ZIP64_LOCATOR = 0x07064b50;\nconst SIG_CENTRAL = 0x02014b50;\nconst SIG_LOCAL = 0x04034b50;\nconst EOCD_SIZE = 22;\nconst MAX_COMMENT = 0xffff;\n\nlet crcTable: Uint32Array | null = null;\n\n/** CRC-32 (IEEE 802.3), as used by ZIP. */\nexport function zipCrc32(data: Uint8Array): number {\n if (!crcTable) {\n crcTable = new Uint32Array(256);\n for (let n = 0; n < 256; n++) {\n let c = n;\n for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;\n crcTable[n] = c >>> 0;\n }\n }\n let crc = 0xffffffff;\n for (let i = 0; i < data.length; i++) crc = crcTable[(crc ^ data[i]) & 0xff] ^ (crc >>> 8);\n return (crc ^ 0xffffffff) >>> 0;\n}\n\nfunction toBytes(data: ArrayBuffer | ArrayBufferView): Uint8Array {\n // Duck-typed so ArrayBuffers from other realms (iframes, jsdom) work too.\n if (ArrayBuffer.isView(data)) return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);\n return new Uint8Array(data as ArrayBuffer);\n}\n\n/** Whether `name` is absolute, has a drive letter, or contains `..` / NUL. */\nexport function isUnsafeZipPath(name: string): boolean {\n if (!name || name.includes(\"\\0\")) return true;\n const normalized = name.replace(/\\\\/g, \"/\");\n if (normalized.startsWith(\"/\") || /^[a-zA-Z]:/.test(normalized)) return true;\n return normalized.split(\"/\").some((segment) => segment === \"..\");\n}\n\nconst utf8 = new TextDecoder(\"utf-8\");\n\n/** CP437 high half, used for names without the UTF-8 flag. */\nconst CP437_HIGH =\n \"ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜ¢£¥₧ƒáíóúñѪº¿⌐¬½¼¡«»░▒▓│┤╡╢╖╕╣║╗╝╜╛┐└┴┬├─┼╞╟╚╔╩╦╠═╬╧╨╤╥╙╘╒╓╫╪┘┌█▄▌▐▀αßΓπΣσµτΦΘΩδ∞φε∩≡±≥≤⌠⌡÷≈°∙·√ⁿ²■ \";\n\nfunction decodeName(bytes: Uint8Array, isUtf8: boolean): string {\n if (isUtf8 || bytes.every((b) => b < 0x80)) return utf8.decode(bytes);\n let out = \"\";\n for (const b of bytes) out += b < 0x80 ? String.fromCharCode(b) : CP437_HIGH[b - 0x80];\n return out;\n}\n\n/**\n * A parsed ZIP archive. Entry data is extracted lazily with {@link read}.\n * Create it with {@link readZip}.\n */\nexport class ZipArchive {\n /** Entries in central-directory order. */\n readonly entries: readonly ZipEntry[];\n private readonly byName = new Map<string, ZipEntry>();\n private extracted = 0;\n\n constructor(\n private readonly bytes: Uint8Array,\n entries: ZipEntry[],\n private readonly maxTotalSize: number,\n ) {\n this.entries = entries;\n entries.forEach((entry) => {\n if (!this.byName.has(entry.name)) this.byName.set(entry.name, entry);\n });\n }\n\n /** Looks up an entry by exact name (a leading `/` is ignored). */\n get(name: string): ZipEntry | undefined {\n return this.byName.get(name.replace(/^\\/+/, \"\"));\n }\n\n has(name: string): boolean {\n return !!this.get(name);\n }\n\n /** Uncompressed bytes extracted so far (counted against `maxTotalSize`). */\n get extractedSize(): number {\n return this.extracted;\n }\n\n /** Extracts an entry's data, verifying its size and CRC-32. */\n async read(entryOrName: ZipEntry | string): Promise<Uint8Array> {\n const entry = typeof entryOrName === \"string\" ? this.get(entryOrName) : entryOrName;\n if (!entry) {\n throw new ZipError(\"entry_not_found\", `ZIP entry \"${String(entryOrName)}\" not found.`, {\n entryName: String(entryOrName),\n });\n }\n const name = entry.name;\n if (entry.encrypted) {\n throw new ZipError(\"encrypted\", `ZIP entry \"${name}\" is encrypted; encrypted archives are not supported.`, {\n entryName: name,\n });\n }\n if (entry.isDirectory) return new Uint8Array(0);\n const remaining = this.maxTotalSize - this.extracted;\n if (entry.size > remaining) {\n throw new ZipError(\n \"too_large\",\n `Extracting \"${name}\" (${entry.size} bytes) would exceed the ${this.maxTotalSize}-byte limit.`,\n { entryName: name },\n );\n }\n\n const { bytes } = this;\n const offset = entry.localHeaderOffset;\n if (offset + 30 > bytes.length || readU32(bytes, offset) !== SIG_LOCAL) {\n throw new ZipError(\"corrupt_entry\", `ZIP entry \"${name}\" has no valid local header.`, { entryName: name });\n }\n const dataStart = offset + 30 + readU16(bytes, offset + 26) + readU16(bytes, offset + 28);\n const dataEnd = dataStart + entry.compressedSize;\n if (dataEnd > bytes.length) {\n throw new ZipError(\"corrupt_entry\", `ZIP entry \"${name}\" is truncated.`, { entryName: name });\n }\n const raw = bytes.subarray(dataStart, dataEnd);\n\n let data: Uint8Array;\n if (entry.method === 0) {\n if (entry.compressedSize !== entry.size) {\n throw new ZipError(\"corrupt_entry\", `Stored ZIP entry \"${name}\" has inconsistent sizes.`, { entryName: name });\n }\n data = raw.slice();\n } else if (entry.method === 8) {\n // Cap at the declared size: more output means a lying header (or a bomb).\n data = await inflateRaw(raw, entry.size, name);\n } else {\n throw new ZipError(\n \"unsupported_feature\",\n `ZIP entry \"${name}\" uses unsupported compression method ${entry.method}; only stored and deflate are supported.`,\n { entryName: name },\n );\n }\n if (data.length !== entry.size) {\n throw new ZipError(\"corrupt_entry\", `ZIP entry \"${name}\" size does not match the directory.`, { entryName: name });\n }\n this.extracted += data.length;\n if (zipCrc32(data) !== entry.crc32) {\n throw new ZipError(\"corrupt_entry\", `ZIP entry \"${name}\" failed its CRC-32 check.`, { entryName: name });\n }\n return data;\n }\n\n /** Extracts an entry and decodes it as UTF-8 (a leading BOM is removed). */\n async readText(entryOrName: ZipEntry | string): Promise<string> {\n const text = utf8.decode(await this.read(entryOrName));\n return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;\n }\n}\n\nfunction readU16(bytes: Uint8Array, offset: number): number {\n return bytes[offset] | (bytes[offset + 1] << 8);\n}\n\nfunction readU32(bytes: Uint8Array, offset: number): number {\n return (bytes[offset] | (bytes[offset + 1] << 8) | (bytes[offset + 2] << 16) | (bytes[offset + 3] << 24)) >>> 0;\n}\n\nfunction readU64(bytes: Uint8Array, offset: number): number {\n const value = readU32(bytes, offset) + readU32(bytes, offset + 4) * 0x100000000;\n if (!Number.isSafeInteger(value)) {\n throw new ZipError(\"unsupported_feature\", \"ZIP64 value exceeds the supported range.\");\n }\n return value;\n}\n\n/** Inflates a raw deflate stream, failing as soon as output exceeds `limit` bytes. */\nasync function inflateRaw(raw: Uint8Array, limit: number, entryName: string): Promise<Uint8Array> {\n const Stream: typeof DecompressionStream | undefined = (globalThis as any).DecompressionStream;\n if (typeof Stream !== \"function\") {\n throw new ZipError(\n \"unsupported_environment\",\n \"Inflating ZIP entries needs DecompressionStream (modern browsers, Node 18+).\",\n { entryName },\n );\n }\n const stream = new Stream(\"deflate-raw\");\n const writer = stream.writable.getWriter();\n const reader = stream.readable.getReader();\n // Feed the input in slices so output is pulled (and checked) incrementally.\n const CHUNK = 64 * 1024;\n const feeding = (async () => {\n for (let i = 0; i < raw.length; i += CHUNK) await writer.write(raw.subarray(i, i + CHUNK) as unknown as BufferSource);\n await writer.close();\n })();\n feeding.catch(() => {});\n\n const chunks: Uint8Array[] = [];\n let total = 0;\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n total += value.length;\n if (total > limit) {\n throw new ZipError(\n \"corrupt_entry\",\n `ZIP entry \"${entryName}\" inflates beyond its declared size of ${limit} bytes.`,\n { entryName },\n );\n }\n chunks.push(value);\n }\n } catch (error) {\n reader.cancel().catch(() => {});\n writer.abort().catch(() => {});\n if (error instanceof ZipError) throw error;\n throw new ZipError(\"corrupt_entry\", `ZIP entry \"${entryName}\" has an invalid deflate stream.`, {\n entryName,\n cause: error,\n });\n }\n await feeding.catch(() => {});\n const out = new Uint8Array(total);\n let pos = 0;\n for (const chunk of chunks) {\n out.set(chunk, pos);\n pos += chunk.length;\n }\n return out;\n}\n\nfunction findEndOfCentralDirectory(bytes: Uint8Array): number {\n const min = Math.max(0, bytes.length - EOCD_SIZE - MAX_COMMENT);\n for (let i = bytes.length - EOCD_SIZE; i >= min; i--) {\n if (readU32(bytes, i) === SIG_EOCD && i + EOCD_SIZE + readU16(bytes, i + 20) <= bytes.length) return i;\n }\n return -1;\n}\n\n/**\n * Parses a ZIP archive's central directory. Entry data is not extracted until\n * {@link ZipArchive.read} is called. Throws {@link ZipError}.\n */\nexport async function readZip(data: ArrayBuffer | ArrayBufferView, options: ZipReadOptions = {}): Promise<ZipArchive> {\n const bytes = toBytes(data);\n const maxEntries = options.maxEntries ?? DEFAULT_ZIP_MAX_ENTRIES;\n const maxTotalSize = options.maxTotalSize ?? DEFAULT_ZIP_MAX_TOTAL_SIZE;\n\n const eocd = findEndOfCentralDirectory(bytes);\n if (eocd < 0) throw new ZipError(\"invalid_archive\", \"Not a ZIP archive (no end of central directory record).\");\n\n let diskNumber = readU16(bytes, eocd + 4);\n let cdDisk = readU16(bytes, eocd + 6);\n let count = readU16(bytes, eocd + 10);\n let cdSize = readU32(bytes, eocd + 12);\n let cdOffset = readU32(bytes, eocd + 16);\n\n if (count === 0xffff || cdSize === 0xffffffff || cdOffset === 0xffffffff) {\n const locator = eocd - 20;\n if (locator < 0 || readU32(bytes, locator) !== SIG_ZIP64_LOCATOR) {\n throw new ZipError(\"invalid_archive\", \"ZIP64 archive is missing its end of central directory locator.\");\n }\n const record = readU64(bytes, locator + 8);\n if (record + 56 > bytes.length || readU32(bytes, record) !== SIG_ZIP64_EOCD) {\n throw new ZipError(\"invalid_archive\", \"ZIP64 end of central directory record not found.\");\n }\n diskNumber = readU32(bytes, record + 16);\n cdDisk = readU32(bytes, record + 20);\n count = readU64(bytes, record + 32);\n cdSize = readU64(bytes, record + 40);\n cdOffset = readU64(bytes, record + 48);\n }\n if (diskNumber !== 0 || cdDisk !== 0) {\n throw new ZipError(\"unsupported_feature\", \"Multi-disk (spanned) ZIP archives are not supported.\");\n }\n if (count > maxEntries) {\n throw new ZipError(\"too_many_entries\", `ZIP archive has ${count} entries; the limit is ${maxEntries}.`);\n }\n if (cdOffset + cdSize > bytes.length) {\n throw new ZipError(\"invalid_archive\", \"ZIP central directory lies outside the file.\");\n }\n\n const entries: ZipEntry[] = [];\n let p = cdOffset;\n for (let i = 0; i < count; i++) {\n if (p + 46 > bytes.length || readU32(bytes, p) !== SIG_CENTRAL) {\n throw new ZipError(\"invalid_archive\", \"ZIP central directory is corrupt.\");\n }\n const flags = readU16(bytes, p + 8);\n const method = readU16(bytes, p + 10);\n const crc32 = readU32(bytes, p + 16);\n let compressedSize = readU32(bytes, p + 20);\n let size = readU32(bytes, p + 24);\n const nameLength = readU16(bytes, p + 28);\n const extraLength = readU16(bytes, p + 30);\n const commentLength = readU16(bytes, p + 32);\n let localHeaderOffset = readU32(bytes, p + 42);\n const nameStart = p + 46;\n const extraStart = nameStart + nameLength;\n const next = extraStart + extraLength + commentLength;\n if (next > bytes.length) throw new ZipError(\"invalid_archive\", \"ZIP central directory is truncated.\");\n\n // ZIP64 extended information: only the fields that overflowed are present, in order.\n for (let e = extraStart; e + 4 <= extraStart + extraLength; ) {\n const id = readU16(bytes, e);\n const len = readU16(bytes, e + 2);\n if (id === 0x0001) {\n let f = e + 4;\n const end = f + len;\n if (size === 0xffffffff && f + 8 <= end) {\n size = readU64(bytes, f);\n f += 8;\n }\n if (compressedSize === 0xffffffff && f + 8 <= end) {\n compressedSize = readU64(bytes, f);\n f += 8;\n }\n if (localHeaderOffset === 0xffffffff && f + 8 <= end) localHeaderOffset = readU64(bytes, f);\n }\n e += 4 + len;\n }\n\n const rawName = decodeName(bytes.subarray(nameStart, extraStart), (flags & 0x0800) !== 0);\n const name = rawName.replace(/\\\\/g, \"/\");\n p = next;\n if (isUnsafeZipPath(rawName)) {\n if (options.unsafePaths === \"skip\") continue;\n throw new ZipError(\"unsafe_path\", `ZIP entry name \"${rawName}\" is absolute or escapes the archive root.`, {\n entryName: rawName,\n });\n }\n entries.push({\n name,\n isDirectory: name.endsWith(\"/\"),\n encrypted: (flags & 0x0001) !== 0,\n method,\n compressedSize,\n size,\n crc32,\n localHeaderOffset,\n });\n }\n return new ZipArchive(bytes, entries, maxTotalSize);\n}\n"],"mappings":";AAmHA,IAAM,YAAY;AAClB,IAAM,WAAW;AAEjB,IAAM,aAAa;AAEZ,IAAM,kBAAkB;AAE/B,IAAM,qBAAqB,oBAAI,IAAI;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAGM,SAAS,eAAe,IAA2B;AACxD,SAAO,OAAO,OAAO,YAAY,SAAS,KAAK,EAAE;AACnD;AAEA,IAAM,QAAQ;AACd,IAAM,gBAAgB,CAAC,OAAO,SAAS,UAAU,SAAS,OAAO,OAAO;AAExE,SAAS,gBAAmC;AAC1C,QAAM,SAA4B;AAAA,IAChC;AAAA,MACE,IAAI;AAAA,MACJ,MAAM;AAAA,MACN,MAAM;AAAA,MACN,OAAO,EAAE,MAAM,YAAY;AAAA,MAC3B,UAA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O,GAAQ;AACjB,YAAI,IAAI,IAAI;AACZ,cAAM,MAAM,IAAI;AAChB,YAAI,SAAS,cAAc,IAAI,KAAK,KAAK;AACvC,iBAAO,QAAQ,OAAO,CAAC;AACvB,eAAK;AAAA,QACP;AACA,YAAI,mBAAmB,cAAc,IAAI,KAAK,KAAK;AACjD,2BAAiB,QAAQ,OAAO,CAAC;AACjC,eAAK;AAAA,QACP;AACA,YAAI,sBAAsB,cAAc,IAAI,KAAK,IAAK,qBAAoB,QAAQ,OAAO,CAAC;AAAA,MAC5F;AACA,WAAK,IAAI;AAAA,IACX;AAEA,UAAM,UAAU,WAAW,MAAM,SAAS,WAAW,UAAU,IAAI,QAAQ,UAAY,CAAC;AACxF,UAAM,OAAO,QAAQ,QAAQ,OAAO,GAAG;AACvC,QAAI;AACJ,QAAI,gBAAgB,OAAO,GAAG;AAC5B,UAAI,QAAQ,gBAAgB,OAAQ;AACpC,YAAM,IAAI,SAAS,eAAe,mBAAmB,OAAO,8CAA8C;AAAA,QACxG,WAAW;AAAA,MACb,CAAC;AAAA,IACH;AACA,YAAQ,KAAK;AAAA,MACX;AAAA,MACA,aAAa,KAAK,SAAS,GAAG;AAAA,MAC9B,YAAY,QAAQ,OAAY;AAAA,MAChC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO,IAAI,WAAW,OAAO,SAAS,YAAY;AACpD;","names":[]}
@@ -1,7 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
- var _chunkD27YFC46cjs = require('./chunk-D27YFC46.cjs');
4
+
5
+
6
+ var _chunkBVP3TSLHcjs = require('./chunk-BVP3TSLH.cjs');
7
+
8
+
9
+
10
+
11
+ var _chunkIFHKKVXHcjs = require('./chunk-IFHKKVXH.cjs');
5
12
 
6
13
  // src/serializers/plain-text.ts
7
14
  var _model = require('@tiptap/pm/model');
@@ -169,6 +176,61 @@ function parseHtmlFragment(html) {
169
176
  function decodeHtmlEntities(text) {
170
177
  return text.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#0*39;/g, "'").replace(/&nbsp;/g, "\xA0").replace(/&amp;/g, "&");
171
178
  }
179
+ var CELL_TAGS = /* @__PURE__ */ new Set(["TD", "TH"]);
180
+ function blockLines(nodes) {
181
+ const lines = [];
182
+ let current = null;
183
+ const flush = () => {
184
+ if (current !== null) {
185
+ lines.push(current);
186
+ current = null;
187
+ }
188
+ };
189
+ const visit = (node) => {
190
+ if (node.nodeType === 3) {
191
+ const value = _nullishCoalesce(node.nodeValue, () => ( ""));
192
+ if (current === null && value.trim() === "") return;
193
+ current = (_nullishCoalesce(current, () => ( ""))) + value;
194
+ return;
195
+ }
196
+ if (node.nodeType !== 1) return;
197
+ const element = node;
198
+ const tag = element.tagName.toUpperCase();
199
+ if (tag === "BR") {
200
+ current = (_nullishCoalesce(current, () => ( ""))) + "\n";
201
+ return;
202
+ }
203
+ if (tag === "TR") {
204
+ flush();
205
+ const cells = [];
206
+ element.childNodes.forEach((child) => {
207
+ if (child.nodeType !== 1 || !CELL_TAGS.has(child.tagName.toUpperCase())) return;
208
+ const cell = child;
209
+ cells.push(
210
+ blockLines(Array.from(cell.childNodes)).filter((line) => line !== "").join(" ").replace(/[\t\n]+/g, " ")
211
+ );
212
+ const span = parseInt(_nullishCoalesce(cell.getAttribute("colspan"), () => ( "1")), 10);
213
+ for (let i = 1; i < Math.min(Number.isFinite(span) ? span : 1, 1e3); i++) cells.push("");
214
+ });
215
+ lines.push(cells.join(" "));
216
+ return;
217
+ }
218
+ if (!BLOCK_TAGS.has(tag)) {
219
+ node.childNodes.forEach(visit);
220
+ return;
221
+ }
222
+ flush();
223
+ const linesBefore = lines.length;
224
+ node.childNodes.forEach(visit);
225
+ flush();
226
+ if (lines.length === linesBefore && tag !== "HR" && tag !== "TABLE") {
227
+ lines.push("");
228
+ }
229
+ };
230
+ nodes.forEach(visit);
231
+ flush();
232
+ return lines;
233
+ }
172
234
  function htmlToPlainText(html, options = {}) {
173
235
  if (!html) return "";
174
236
  const trackedResolved = stripTrackedChanges(
@@ -177,49 +239,16 @@ function htmlToPlainText(html, options = {}) {
177
239
  );
178
240
  const mentionNormalized = replaceTagSpans(trackedResolved, "span", MENTION_TYPE_ATTRIBUTE, (match, attrs) => {
179
241
  const label = getHtmlAttribute(attrs, "data-label") || getHtmlAttribute(attrs, "data-id");
180
- return label ? `@${label}` : match;
242
+ const role = getHtmlAttribute(attrs, "data-role");
243
+ const validRole = role && /^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9])?$/.test(role) ? role : "";
244
+ return label ? `@${label}${validRole ? `:${validRole}` : ""}` : match;
181
245
  });
182
246
  if (typeof document !== "undefined") {
183
247
  const fragment = parseHtmlFragment(mentionNormalized);
184
248
  fragment.querySelectorAll("br.ProseMirror-trailingBreak").forEach((br) => br.remove());
185
- const lines = [];
186
- let current = null;
187
- const flush = () => {
188
- if (current !== null) {
189
- lines.push(current);
190
- current = null;
191
- }
192
- };
193
- const visit = (node) => {
194
- if (node.nodeType === 3) {
195
- const value = _nullishCoalesce(node.nodeValue, () => ( ""));
196
- if (current === null && value.trim() === "") return;
197
- current = (_nullishCoalesce(current, () => ( ""))) + value;
198
- return;
199
- }
200
- if (node.nodeType !== 1) return;
201
- const tag = node.tagName.toUpperCase();
202
- if (tag === "BR") {
203
- current = (_nullishCoalesce(current, () => ( ""))) + "\n";
204
- return;
205
- }
206
- if (!BLOCK_TAGS.has(tag)) {
207
- node.childNodes.forEach(visit);
208
- return;
209
- }
210
- flush();
211
- const linesBefore = lines.length;
212
- node.childNodes.forEach(visit);
213
- flush();
214
- if (lines.length === linesBefore && tag !== "HR") {
215
- lines.push("");
216
- }
217
- };
218
- fragment.childNodes.forEach(visit);
219
- flush();
220
- return lines.join("\n");
249
+ return blockLines(Array.from(fragment.childNodes)).join("\n");
221
250
  }
222
- const text = mentionNormalized.replace(/<br\s*\/?>/gi, "\n").replace(
251
+ const text = mentionNormalized.replace(/<\/p>\s*<\/t([dh])>/gi, "</t$1>").replace(/<\/t[dh]>\s*(?=<t[dh][\s>])/gi, " ").replace(/<\/tr>/gi, "\n").replace(/<br\s*\/?>/gi, "\n").replace(
223
252
  /<\/(?:p|div|li|pre|blockquote|h[1-6])>(?:\s*<\/(?:li|ul|ol|blockquote|div)>)*/gi,
224
253
  "\n"
225
254
  );
@@ -232,13 +261,16 @@ function resolvedBlockOperationsHtml(editor, view) {
232
261
  doc.descendants((node) => {
233
262
  if (found) return false;
234
263
  if (node.isTextblock) {
235
- if (_optionalChain([node, 'access', _3 => _3.attrs, 'optionalAccess', _4 => _4[_chunkD27YFC46cjs.BLOCK_CHANGE_ATTRIBUTE], 'optionalAccess', _5 => _5.operation])) found = true;
264
+ if (_optionalChain([node, 'access', _3 => _3.attrs, 'optionalAccess', _4 => _4[_chunkIFHKKVXHcjs.BLOCK_CHANGE_ATTRIBUTE], 'optionalAccess', _5 => _5.operation])) found = true;
265
+ else node.forEach((child) => {
266
+ if (child.marks.some((mark) => _optionalChain([mark, 'access', _6 => _6.attrs, 'optionalAccess', _7 => _7[_chunkIFHKKVXHcjs.MOVE_ID_ATTRIBUTE]]))) found = true;
267
+ });
236
268
  return false;
237
269
  }
238
270
  return true;
239
271
  });
240
272
  if (!found) return null;
241
- const resolved = _chunkD27YFC46cjs.resolveTrackedChanges.call(void 0, doc, view);
273
+ const resolved = _chunkIFHKKVXHcjs.resolveTrackedChanges.call(void 0, doc, view);
242
274
  const container = document.createElement("div");
243
275
  container.appendChild(_model.DOMSerializer.fromSchema(doc.type.schema).serializeFragment(resolved.content));
244
276
  return container.innerHTML;
@@ -261,17 +293,18 @@ function getEditorText(editor, options = {}) {
261
293
  function extractMentionsFromDoc(docOrEditor) {
262
294
  if (!docOrEditor) return [];
263
295
  const mentions = [];
264
- const doc = _optionalChain([docOrEditor, 'optionalAccess', _6 => _6.state, 'optionalAccess', _7 => _7.doc]) || (typeof _optionalChain([docOrEditor, 'optionalAccess', _8 => _8.descendants]) === "function" ? docOrEditor : null);
296
+ const doc = _optionalChain([docOrEditor, 'optionalAccess', _8 => _8.state, 'optionalAccess', _9 => _9.doc]) || (typeof _optionalChain([docOrEditor, 'optionalAccess', _10 => _10.descendants]) === "function" ? docOrEditor : null);
265
297
  if (doc && typeof doc.descendants === "function") {
266
298
  doc.descendants((node) => {
267
- if (_optionalChain([node, 'access', _9 => _9.type, 'optionalAccess', _10 => _10.name]) === "mention" && node.attrs) {
299
+ if (_optionalChain([node, 'access', _11 => _11.type, 'optionalAccess', _12 => _12.name]) === "mention" && node.attrs) {
268
300
  mentions.push({
269
301
  id: node.attrs.id || "",
270
302
  label: node.attrs.label || "",
271
303
  type: node.attrs.type,
272
304
  avatarUrl: node.attrs.avatarUrl,
273
305
  color: node.attrs.color,
274
- ...node.attrs
306
+ ...node.attrs,
307
+ ...node.attrs.assetRole ? { role: node.attrs.assetRole } : {}
275
308
  });
276
309
  }
277
310
  });
@@ -287,7 +320,8 @@ function extractMentionsFromDoc(docOrEditor) {
287
320
  type: node.attrs.type,
288
321
  avatarUrl: node.attrs.avatarUrl,
289
322
  color: node.attrs.color,
290
- ...node.attrs
323
+ ...node.attrs,
324
+ ...node.attrs.assetRole ? { role: node.attrs.assetRole } : {}
291
325
  });
292
326
  }
293
327
  if (Array.isArray(node.content)) {
@@ -306,7 +340,8 @@ function extractMentionsFromDoc(docOrEditor) {
306
340
  label: el.getAttribute("data-label") || "",
307
341
  type: el.getAttribute("data-type-name") || void 0,
308
342
  avatarUrl: el.getAttribute("data-avatar-url") || void 0,
309
- color: el.getAttribute("data-color") || void 0
343
+ color: el.getAttribute("data-color") || void 0,
344
+ ...el.getAttribute("data-role") ? { role: el.getAttribute("data-role") } : {}
310
345
  });
311
346
  });
312
347
  } else {
@@ -321,7 +356,8 @@ function extractMentionsFromDoc(docOrEditor) {
321
356
  label: getAttr("data-label") || "",
322
357
  type: getAttr("data-type-name") || getAttr("data-entity-type"),
323
358
  avatarUrl: getAttr("data-avatar-url"),
324
- color: getAttr("data-color")
359
+ color: getAttr("data-color"),
360
+ ...getAttr("data-role") ? { role: getAttr("data-role") } : {}
325
361
  });
326
362
  }
327
363
  }
@@ -340,7 +376,6 @@ function extractMentionsFromDoc(docOrEditor) {
340
376
  }
341
377
 
342
378
  // src/serializers/mentions.ts
343
- var MENTION_REGEX = /(?:^|[\s>(*_"';\\/[\]{}~`:]|&quot;|&gt;|&lt;|&amp;)@(?:"([^"]+)"|&quot;([^&]+)&quot;|([a-zA-Z0-9_-]+(?:\.[a-zA-Z0-9_-]+)*))/g;
344
379
  var MARKDOWN_MENTION_SPLIT_REGEX = /(```[\s\S]*?```|~~~[\s\S]*?~~~|<pre[\s\S]*?<\/pre>|<code[\s\S]*?<\/code>|`[^`\n]+`|<span\b[^>]*\b(?:data-type=["']mention["']|class=["'][^"']*pixerate-mention-node[^"']*["']|data-mention=["'][^"']*["'])[^>]*>[\s\S]*?<\/span>|<[^>]+>|\]\([^)]+\)|(?:https?|file|vscode|cursor|mailto):\/\/[^\s<)]+)/gi;
345
380
  function stripMarkdownCode(content) {
346
381
  if (!content || typeof content !== "string") return "";
@@ -358,15 +393,22 @@ function isMentionNodeAttributes(attrs) {
358
393
  const valueEnd = attrs.indexOf(classAttr[1], valueStart);
359
394
  return valueEnd !== -1 && attrs.slice(valueStart, valueEnd).includes("pixerate-mention-node");
360
395
  }
361
- function extractMentions(content) {
396
+ function extractMentions(content, options = {}) {
362
397
  if (!content || typeof content !== "string") return [];
398
+ const details = options.details === true;
363
399
  let normalizedMentionNodes = "";
364
400
  let last = 0;
365
401
  for (const span of findTagSpans(content, "span", isMentionNodeAttributes, true)) {
366
402
  const labelMatch = /\bdata-label=["']([^"']+)["']/i.exec(span.attrs);
367
403
  const idMatch = labelMatch ? null : /\bdata-id=["']([^"']+)["']/i.exec(span.attrs);
368
404
  const inner = content.slice(span.openEnd, span.end - "</span>".length);
369
- const replacement = labelMatch ? ` @${labelMatch[1]} ` : idMatch ? ` @${idMatch[1]} ` : ` ${inner} `;
405
+ let replacement = labelMatch ? ` @${labelMatch[1]} ` : idMatch ? ` @${idMatch[1]} ` : ` ${inner} `;
406
+ if (details && (labelMatch || idMatch)) {
407
+ const roleMatch = /\bdata-role=["']([^"']+)["']/i.exec(span.attrs);
408
+ const role = roleMatch && /^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9])?$/.test(roleMatch[1]) ? roleMatch[1] : null;
409
+ const label = (_nullishCoalesce(labelMatch, () => ( idMatch)))[1];
410
+ replacement = ` ${_chunkBVP3TSLHcjs.formatMentionHandle.call(void 0, label)}${role ? _chunkBVP3TSLHcjs.NODE_ROLE_MARK + role : ""} `;
411
+ }
370
412
  normalizedMentionNodes += content.slice(last, span.start) + replacement;
371
413
  last = span.end;
372
414
  }
@@ -376,31 +418,47 @@ function extractMentions(content) {
376
418
  const withoutLinks = replaceDelimited(withoutUrls, /\]\(/g, ")", () => "]");
377
419
  const textOnly = stripTags(withoutLinks, " ");
378
420
  const mentions = [];
421
+ const detailed = [];
379
422
  const seen = /* @__PURE__ */ new Set();
380
- const regex = new RegExp(MENTION_REGEX.source, "g");
423
+ const regex = new RegExp(_chunkBVP3TSLHcjs.MENTION_REGEX.source, "g");
381
424
  let match;
382
425
  while ((match = regex.exec(textOnly)) !== null) {
383
426
  const handle = (_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(match[1], () => ( match[2])), () => ( match[3])), () => ( ""))).trim();
427
+ if (details) {
428
+ const suffix = _chunkBVP3TSLHcjs.readRoleSuffix.call(void 0, textOnly, regex.lastIndex, options.roles);
429
+ if (suffix) regex.lastIndex = suffix.end;
430
+ const key = `${handle}\0${_nullishCoalesce(_optionalChain([suffix, 'optionalAccess', _13 => _13.role]), () => ( ""))}`;
431
+ if (handle && !seen.has(key)) {
432
+ seen.add(key);
433
+ detailed.push(suffix ? { handle, role: suffix.role } : { handle });
434
+ }
435
+ continue;
436
+ }
384
437
  if (handle && !seen.has(handle)) {
385
438
  seen.add(handle);
386
439
  mentions.push(handle);
387
440
  }
388
441
  }
389
- return mentions;
442
+ return details ? detailed : mentions;
390
443
  }
391
- function parseMentionSegments(content) {
444
+ function parseMentionSegments(content, options = {}) {
392
445
  if (!content) return [];
393
446
  const segments = [];
394
- const regex = new RegExp(MENTION_REGEX.source, "g");
447
+ const regex = new RegExp(_chunkBVP3TSLHcjs.MENTION_REGEX.source, "g");
395
448
  let lastIndex = 0;
396
449
  let match;
397
450
  while ((match = regex.exec(content)) !== null) {
398
451
  const fullMatch = match[0];
399
452
  const atIndex = fullMatch.indexOf("@");
400
453
  const prefix = atIndex > 0 ? fullMatch.slice(0, atIndex) : "";
401
- const mentionToken = fullMatch.slice(atIndex);
454
+ let mentionToken = fullMatch.slice(atIndex);
402
455
  const handle = _nullishCoalesce(_nullishCoalesce(match[1], () => ( match[2])), () => ( match[3]));
403
456
  const matchStart = match.index + prefix.length;
457
+ const suffix = options.roles && content.charAt(regex.lastIndex) === ":" ? _chunkBVP3TSLHcjs.readRoleSuffix.call(void 0, content, regex.lastIndex, options.roles) : null;
458
+ if (suffix) {
459
+ mentionToken = content.slice(matchStart, suffix.end);
460
+ regex.lastIndex = suffix.end;
461
+ }
404
462
  if (matchStart > lastIndex) {
405
463
  segments.push({
406
464
  type: "text",
@@ -410,7 +468,8 @@ function parseMentionSegments(content) {
410
468
  segments.push({
411
469
  type: "mention",
412
470
  value: mentionToken,
413
- handle
471
+ handle,
472
+ ...suffix ? { role: suffix.role } : {}
414
473
  });
415
474
  lastIndex = matchStart + mentionToken.length;
416
475
  }
@@ -436,33 +495,33 @@ function preprocessMarkdownMentions(content, optionsOrMentionables = []) {
436
495
  )) {
437
496
  return part;
438
497
  }
439
- const regex = new RegExp(MENTION_REGEX.source, "g");
440
- return part.replace(regex, (match, quotedHandle, escapedQuotedHandle, standardHandle) => {
441
- const atIndex = match.indexOf("@");
442
- const prefix = atIndex > 0 ? match.slice(0, atIndex) : "";
498
+ const regex = new RegExp(_chunkBVP3TSLHcjs.MENTION_REGEX.source, "g");
499
+ const render = (match2, quotedHandle, escapedQuotedHandle, standardHandle, role) => {
500
+ const atIndex = match2.indexOf("@");
501
+ const prefix = atIndex > 0 ? match2.slice(0, atIndex) : "";
443
502
  const rawHandle = (quotedHandle || escapedQuotedHandle || standardHandle || "").trim();
444
- if (!rawHandle) return match;
503
+ if (!rawHandle) return match2;
445
504
  const lowerHandle = rawHandle.toLowerCase();
446
505
  const entity = allMentionables.find((e) => {
447
- if (_optionalChain([e, 'access', _11 => _11.label, 'optionalAccess', _12 => _12.toLowerCase, 'call', _13 => _13()]) === lowerHandle) return true;
448
- if (_optionalChain([e, 'access', _14 => _14.handle, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16()]) === lowerHandle) return true;
449
- if (_optionalChain([e, 'access', _17 => _17.name, 'optionalAccess', _18 => _18.toLowerCase, 'call', _19 => _19()]) === lowerHandle) return true;
450
- if (_optionalChain([e, 'access', _20 => _20.id, 'optionalAccess', _21 => _21.toLowerCase, 'call', _22 => _22()]) === lowerHandle) return true;
506
+ if (_optionalChain([e, 'access', _14 => _14.label, 'optionalAccess', _15 => _15.toLowerCase, 'call', _16 => _16()]) === lowerHandle) return true;
507
+ if (_optionalChain([e, 'access', _17 => _17.handle, 'optionalAccess', _18 => _18.toLowerCase, 'call', _19 => _19()]) === lowerHandle) return true;
508
+ if (_optionalChain([e, 'access', _20 => _20.name, 'optionalAccess', _21 => _21.toLowerCase, 'call', _22 => _22()]) === lowerHandle) return true;
509
+ if (_optionalChain([e, 'access', _23 => _23.id, 'optionalAccess', _24 => _24.toLowerCase, 'call', _25 => _25()]) === lowerHandle) return true;
451
510
  if (e.type === "agent" && `agent${(e.handle || e.label || "").toLowerCase()}` === lowerHandle) return true;
452
- if (_optionalChain([e, 'access', _23 => _23.aliases, 'optionalAccess', _24 => _24.some, 'call', _25 => _25(
511
+ if (_optionalChain([e, 'access', _26 => _26.aliases, 'optionalAccess', _27 => _27.some, 'call', _28 => _28(
453
512
  (a) => a.toLowerCase() === lowerHandle || e.type === "agent" && `agent${a.toLowerCase()}` === lowerHandle
454
513
  )])) {
455
514
  return true;
456
515
  }
457
516
  return false;
458
517
  });
459
- let id = _optionalChain([entity, 'optionalAccess', _26 => _26.id]);
460
- let label = _optionalChain([entity, 'optionalAccess', _27 => _27.label]) || _optionalChain([entity, 'optionalAccess', _28 => _28.handle]) || rawHandle;
461
- let type = _optionalChain([entity, 'optionalAccess', _29 => _29.type]);
462
- let avatarUrl = _optionalChain([entity, 'optionalAccess', _30 => _30.avatarUrl]);
463
- let color = _optionalChain([entity, 'optionalAccess', _31 => _31.color]) || _optionalChain([entity, 'optionalAccess', _32 => _32.hexColor]);
518
+ let id = _optionalChain([entity, 'optionalAccess', _29 => _29.id]);
519
+ let label = _optionalChain([entity, 'optionalAccess', _30 => _30.label]) || _optionalChain([entity, 'optionalAccess', _31 => _31.handle]) || rawHandle;
520
+ let type = _optionalChain([entity, 'optionalAccess', _32 => _32.type]);
521
+ let avatarUrl = _optionalChain([entity, 'optionalAccess', _33 => _33.avatarUrl]);
522
+ let color = _optionalChain([entity, 'optionalAccess', _34 => _34.color]) || _optionalChain([entity, 'optionalAccess', _35 => _35.hexColor]);
464
523
  if (!entity) {
465
- const customResolved = _optionalChain([resolveMention, 'optionalCall', _33 => _33(rawHandle)]);
524
+ const customResolved = _optionalChain([resolveMention, 'optionalCall', _36 => _36(rawHandle)]);
466
525
  if (customResolved) {
467
526
  id = _nullishCoalesce(customResolved.id, () => ( id));
468
527
  label = _nullishCoalesce(_nullishCoalesce(customResolved.label, () => ( customResolved.handle)), () => ( label));
@@ -492,8 +551,25 @@ function preprocessMarkdownMentions(content, optionsOrMentionables = []) {
492
551
  id || label
493
552
  )}" data-label="${escapeHtml(label)}" data-mention-suggestion-char="@" data-type-name="${escapeHtml(
494
553
  type || defaultType
495
- )}"${avatarAttr}${colorAttr}>@${escapeHtml(label)}</span>`;
496
- });
554
+ )}"${avatarAttr}${colorAttr}${role ? ` data-role="${escapeHtml(role)}"` : ""}>@${escapeHtml(label)}</span>`;
555
+ };
556
+ if (!options.roles) {
557
+ return part.replace(
558
+ regex,
559
+ (match2, quotedHandle, escapedQuotedHandle, standardHandle) => render(match2, quotedHandle, escapedQuotedHandle, standardHandle)
560
+ );
561
+ }
562
+ let out = "";
563
+ let last = 0;
564
+ let match;
565
+ while ((match = regex.exec(part)) !== null) {
566
+ const suffix = _chunkBVP3TSLHcjs.readRoleSuffix.call(void 0, part, regex.lastIndex, options.roles);
567
+ const rendered = render(match[0], match[1], match[2], match[3], _optionalChain([suffix, 'optionalAccess', _37 => _37.role]));
568
+ if (suffix && rendered !== match[0]) regex.lastIndex = suffix.end;
569
+ out += part.slice(last, match.index) + rendered;
570
+ last = regex.lastIndex;
571
+ }
572
+ return out + part.slice(last);
497
573
  }).join("");
498
574
  }
499
575
 
@@ -519,6 +595,8 @@ var ALLOWED_HTML_TAGS = /* @__PURE__ */ new Set([
519
595
  "blockquote",
520
596
  "br",
521
597
  "code",
598
+ "col",
599
+ "colgroup",
522
600
  "del",
523
601
  "details",
524
602
  "div",
@@ -533,6 +611,7 @@ var ALLOWED_HTML_TAGS = /* @__PURE__ */ new Set([
533
611
  "i",
534
612
  "img",
535
613
  "input",
614
+ "ins",
536
615
  "kbd",
537
616
  "li",
538
617
  "mark",
@@ -561,6 +640,7 @@ var ALLOWED_HTML_ATTRS = /* @__PURE__ */ new Set([
561
640
  "checked",
562
641
  "class",
563
642
  "colspan",
643
+ "colwidth",
564
644
  "disabled",
565
645
  "height",
566
646
  "href",
@@ -622,8 +702,8 @@ function sanitizeEmbeddedHtml(html, stripDisallowed = false) {
622
702
  }
623
703
  var defaultHtmlInline = md.renderer.rules.html_inline;
624
704
  var defaultHtmlBlock = md.renderer.rules.html_block;
625
- md.renderer.rules.html_inline = (tokens, idx, options, env, self) => _optionalChain([env, 'optionalAccess', _34 => _34.allowUnsafeHtml]) ? defaultHtmlInline(tokens, idx, options, env, self) : sanitizeEmbeddedHtml(tokens[idx].content);
626
- md.renderer.rules.html_block = (tokens, idx, options, env, self) => _optionalChain([env, 'optionalAccess', _35 => _35.allowUnsafeHtml]) ? defaultHtmlBlock(tokens, idx, options, env, self) : sanitizeEmbeddedHtml(tokens[idx].content);
705
+ md.renderer.rules.html_inline = (tokens, idx, options, env, self) => _optionalChain([env, 'optionalAccess', _38 => _38.allowUnsafeHtml]) ? defaultHtmlInline(tokens, idx, options, env, self) : sanitizeEmbeddedHtml(tokens[idx].content);
706
+ md.renderer.rules.html_block = (tokens, idx, options, env, self) => _optionalChain([env, 'optionalAccess', _39 => _39.allowUnsafeHtml]) ? defaultHtmlBlock(tokens, idx, options, env, self) : sanitizeEmbeddedHtml(tokens[idx].content);
627
707
  function preprocessMarkdownFileLinks(content) {
628
708
  if (!content) return "";
629
709
  return content.replace(
@@ -639,24 +719,24 @@ function preprocessMarkdownFileLinks(content) {
639
719
  function markdownToTipTapHtml(markdown, options) {
640
720
  if (!markdown) return "<p></p>";
641
721
  let content = markdown;
642
- if (_optionalChain([options, 'optionalAccess', _36 => _36.preprocessFileLinks])) {
722
+ if (_optionalChain([options, 'optionalAccess', _40 => _40.preprocessFileLinks])) {
643
723
  content = preprocessMarkdownFileLinks(content);
644
724
  }
645
- if (_optionalChain([options, 'optionalAccess', _37 => _37.preprocessMentions]) || _optionalChain([options, 'optionalAccess', _38 => _38.mentionables]) || _optionalChain([options, 'optionalAccess', _39 => _39.preprocessOptions])) {
725
+ if (_optionalChain([options, 'optionalAccess', _41 => _41.preprocessMentions]) || _optionalChain([options, 'optionalAccess', _42 => _42.mentionables]) || _optionalChain([options, 'optionalAccess', _43 => _43.preprocessOptions])) {
646
726
  const mentionOpts = options.preprocessOptions || {
647
727
  mentionables: options.mentionables
648
728
  };
649
729
  content = preprocessMarkdownMentions(content, mentionOpts);
650
730
  }
651
- return md.render(content, { allowUnsafeHtml: _optionalChain([options, 'optionalAccess', _40 => _40.allowUnsafeHtml]) });
731
+ return md.render(content, { allowUnsafeHtml: _optionalChain([options, 'optionalAccess', _44 => _44.allowUnsafeHtml]) });
652
732
  }
653
733
  function getEditorMarkdown(editor, options = {}) {
654
734
  if (!editor) return "";
655
- const markdown = _optionalChain([editor, 'access', _41 => _41.storage, 'optionalAccess', _42 => _42.markdown]);
656
- if (typeof _optionalChain([markdown, 'optionalAccess', _43 => _43.getMarkdown]) === "function") {
657
- const doc = _optionalChain([editor, 'access', _44 => _44.state, 'optionalAccess', _45 => _45.doc]);
658
- if (doc && typeof _optionalChain([markdown, 'access', _46 => _46.serializer, 'optionalAccess', _47 => _47.serialize]) === "function") {
659
- const resolved = _chunkD27YFC46cjs.resolveTrackedChanges.call(void 0, doc, _nullishCoalesce(options.trackedChanges, () => ( "accepted")));
735
+ const markdown = _optionalChain([editor, 'access', _45 => _45.storage, 'optionalAccess', _46 => _46.markdown]);
736
+ if (typeof _optionalChain([markdown, 'optionalAccess', _47 => _47.getMarkdown]) === "function") {
737
+ const doc = _optionalChain([editor, 'access', _48 => _48.state, 'optionalAccess', _49 => _49.doc]);
738
+ if (doc && typeof _optionalChain([markdown, 'access', _50 => _50.serializer, 'optionalAccess', _51 => _51.serialize]) === "function") {
739
+ const resolved = _chunkIFHKKVXHcjs.resolveTrackedChanges.call(void 0, doc, _nullishCoalesce(options.trackedChanges, () => ( "accepted")));
660
740
  if (resolved !== doc) return markdown.serializer.serialize(resolved);
661
741
  }
662
742
  return markdown.getMarkdown();
@@ -680,6 +760,5 @@ function getEditorMarkdown(editor, options = {}) {
680
760
 
681
761
 
682
762
 
683
-
684
- exports.MENTION_REGEX = MENTION_REGEX; exports.MARKDOWN_MENTION_SPLIT_REGEX = MARKDOWN_MENTION_SPLIT_REGEX; exports.stripMarkdownCode = stripMarkdownCode; exports.extractMentions = extractMentions; exports.parseMentionSegments = parseMentionSegments; exports.preprocessMarkdownMentions = preprocessMarkdownMentions; exports.escapeHtml = escapeHtml; exports.plainTextToTipTapHtml = plainTextToTipTapHtml; exports.plainTextToSlice = plainTextToSlice; exports.htmlToPlainText = htmlToPlainText; exports.getEditorText = getEditorText; exports.extractMentionsFromDoc = extractMentionsFromDoc; exports.sanitizeHtml = sanitizeHtml; exports.preprocessMarkdownFileLinks = preprocessMarkdownFileLinks; exports.markdownToTipTapHtml = markdownToTipTapHtml; exports.getEditorMarkdown = getEditorMarkdown;
685
- //# sourceMappingURL=chunk-XNORY7M6.cjs.map
763
+ exports.MARKDOWN_MENTION_SPLIT_REGEX = MARKDOWN_MENTION_SPLIT_REGEX; exports.stripMarkdownCode = stripMarkdownCode; exports.extractMentions = extractMentions; exports.parseMentionSegments = parseMentionSegments; exports.preprocessMarkdownMentions = preprocessMarkdownMentions; exports.escapeHtml = escapeHtml; exports.plainTextToTipTapHtml = plainTextToTipTapHtml; exports.plainTextToSlice = plainTextToSlice; exports.htmlToPlainText = htmlToPlainText; exports.getEditorText = getEditorText; exports.extractMentionsFromDoc = extractMentionsFromDoc; exports.sanitizeHtml = sanitizeHtml; exports.preprocessMarkdownFileLinks = preprocessMarkdownFileLinks; exports.markdownToTipTapHtml = markdownToTipTapHtml; exports.getEditorMarkdown = getEditorMarkdown;
764
+ //# sourceMappingURL=chunk-NFVBT3UZ.cjs.map