payload-markdown 1.8.0 → 1.9.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 (196) hide show
  1. package/README.md +16 -0
  2. package/dist/agent/access.d.ts +1 -1
  3. package/dist/agent/access.js.map +1 -1
  4. package/dist/agent/guide.d.ts +3 -0
  5. package/dist/agent/guide.js +28 -2
  6. package/dist/agent/guide.js.map +1 -1
  7. package/dist/agent/palettes.d.ts +55 -0
  8. package/dist/agent/palettes.js +194 -0
  9. package/dist/agent/palettes.js.map +1 -0
  10. package/dist/agent/skill.d.ts +2 -2
  11. package/dist/agent/skill.js +2 -2
  12. package/dist/agent/skill.js.map +1 -1
  13. package/dist/agent/validate.d.ts +1 -1
  14. package/dist/agent/validate.js +3 -0
  15. package/dist/agent/validate.js.map +1 -1
  16. package/dist/appearance/PaletteRowLabel.client.d.ts +2 -0
  17. package/dist/appearance/PaletteRowLabel.client.js +70 -0
  18. package/dist/appearance/PaletteRowLabel.client.js.map +1 -0
  19. package/dist/appearance/config.d.ts +8 -0
  20. package/dist/appearance/config.js +172 -0
  21. package/dist/appearance/config.js.map +1 -0
  22. package/dist/appearance/options.d.ts +11 -0
  23. package/dist/appearance/options.js +15 -0
  24. package/dist/appearance/options.js.map +1 -0
  25. package/dist/appearance/runtime.d.ts +25 -0
  26. package/dist/appearance/runtime.js +126 -0
  27. package/dist/appearance/runtime.js.map +1 -0
  28. package/dist/components/MarkdownRenderer/Component.js +4 -0
  29. package/dist/components/MarkdownRenderer/Component.js.map +1 -1
  30. package/dist/core/plugins/rehypeResolveIcons.js +10 -1
  31. package/dist/core/plugins/rehypeResolveIcons.js.map +1 -1
  32. package/dist/core/plugins/remarkCompileLayouts.js.map +1 -1
  33. package/dist/core/plugins/remarkDirectiveLines.d.ts +7 -5
  34. package/dist/core/plugins/remarkDirectiveLines.js +29 -18
  35. package/dist/core/plugins/remarkDirectiveLines.js.map +1 -1
  36. package/dist/core/plugins/remarkLayoutDirectives.js +1 -1
  37. package/dist/core/plugins/remarkLayoutDirectives.js.map +1 -1
  38. package/dist/core/plugins/remarkValidateDirectiveThemes.js +7 -14
  39. package/dist/core/plugins/remarkValidateDirectiveThemes.js.map +1 -1
  40. package/dist/core/plugins/remarkValidatePalettes.d.ts +9 -0
  41. package/dist/core/plugins/remarkValidatePalettes.js +51 -0
  42. package/dist/core/plugins/remarkValidatePalettes.js.map +1 -0
  43. package/dist/core/renderMarkdown.js +4 -221
  44. package/dist/core/renderMarkdown.js.map +1 -1
  45. package/dist/core/sanitizeSchema.d.ts +11 -0
  46. package/dist/core/sanitizeSchema.js +176 -0
  47. package/dist/core/sanitizeSchema.js.map +1 -0
  48. package/dist/directive-spec.json +60 -0
  49. package/dist/directives/definitions/badge.d.ts +5 -2
  50. package/dist/directives/definitions/badge.js +138 -10
  51. package/dist/directives/definitions/badge.js.map +1 -1
  52. package/dist/directives/definitions/badges.d.ts +1 -2
  53. package/dist/directives/definitions/badges.js +12 -3
  54. package/dist/directives/definitions/badges.js.map +1 -1
  55. package/dist/directives/definitions/button.d.ts +7 -3
  56. package/dist/directives/definitions/button.js +211 -14
  57. package/dist/directives/definitions/button.js.map +1 -1
  58. package/dist/directives/definitions/buttons.d.ts +1 -2
  59. package/dist/directives/definitions/buttons.js +12 -3
  60. package/dist/directives/definitions/buttons.js.map +1 -1
  61. package/dist/directives/definitions/callout.d.ts +1 -2
  62. package/dist/directives/definitions/callout.js +46 -5
  63. package/dist/directives/definitions/callout.js.map +1 -1
  64. package/dist/directives/definitions/card.d.ts +6 -4
  65. package/dist/directives/definitions/card.js +64 -11
  66. package/dist/directives/definitions/card.js.map +1 -1
  67. package/dist/directives/definitions/cards.d.ts +1 -2
  68. package/dist/directives/definitions/cards.js +49 -4
  69. package/dist/directives/definitions/cards.js.map +1 -1
  70. package/dist/directives/definitions/cell.d.ts +2 -2
  71. package/dist/directives/definitions/cell.js +9 -3
  72. package/dist/directives/definitions/cell.js.map +1 -1
  73. package/dist/directives/definitions/columns.d.ts +3 -4
  74. package/dist/directives/definitions/columns.js +17 -3
  75. package/dist/directives/definitions/columns.js.map +1 -1
  76. package/dist/directives/definitions/details.d.ts +1 -2
  77. package/dist/directives/definitions/details.js +28 -3
  78. package/dist/directives/definitions/details.js.map +1 -1
  79. package/dist/directives/definitions/section.d.ts +1 -2
  80. package/dist/directives/definitions/section.js +26 -3
  81. package/dist/directives/definitions/section.js.map +1 -1
  82. package/dist/directives/definitions/steps.d.ts +1 -2
  83. package/dist/directives/definitions/steps.js +26 -3
  84. package/dist/directives/definitions/steps.js.map +1 -1
  85. package/dist/directives/definitions/tab.d.ts +8 -2
  86. package/dist/directives/definitions/tab.js +45 -3
  87. package/dist/directives/definitions/tab.js.map +1 -1
  88. package/dist/directives/definitions/tabs.d.ts +1 -1
  89. package/dist/directives/definitions/tabs.js +44 -3
  90. package/dist/directives/definitions/tabs.js.map +1 -1
  91. package/dist/directives/definitions/toc.d.ts +1 -2
  92. package/dist/directives/definitions/toc.js +33 -5
  93. package/dist/directives/definitions/toc.js.map +1 -1
  94. package/dist/directives/diagnostics.d.ts +2 -10
  95. package/dist/directives/diagnostics.js +27 -141
  96. package/dist/directives/diagnostics.js.map +1 -1
  97. package/dist/directives/iconPlaceholder.d.ts +9 -3
  98. package/dist/directives/iconPlaceholder.js +8 -1
  99. package/dist/directives/iconPlaceholder.js.map +1 -1
  100. package/dist/directives/lint.d.ts +11 -0
  101. package/dist/directives/lint.js +33 -0
  102. package/dist/directives/lint.js.map +1 -0
  103. package/dist/directives/palette.d.ts +23 -0
  104. package/dist/directives/palette.js +40 -0
  105. package/dist/directives/palette.js.map +1 -0
  106. package/dist/directives/registry.d.ts +23 -5
  107. package/dist/directives/registry.js +52 -40
  108. package/dist/directives/registry.js.map +1 -1
  109. package/dist/directives/spec.d.ts +6 -2
  110. package/dist/directives/spec.js +29 -50
  111. package/dist/directives/spec.js.map +1 -1
  112. package/dist/directives/themeDiagnostics.d.ts +8 -0
  113. package/dist/directives/themeDiagnostics.js +21 -0
  114. package/dist/directives/themeDiagnostics.js.map +1 -0
  115. package/dist/directives/types.d.ts +157 -14
  116. package/dist/directives/types.js +6 -1
  117. package/dist/directives/types.js.map +1 -1
  118. package/dist/editor/directiveConfig.d.ts +15 -1
  119. package/dist/editor/directiveConfig.js +21 -1
  120. package/dist/editor/directiveConfig.js.map +1 -1
  121. package/dist/editor/directives/completions.d.ts +4 -2
  122. package/dist/editor/directives/completions.js +33 -7
  123. package/dist/editor/directives/completions.js.map +1 -1
  124. package/dist/editor/directives/diagnostics.d.ts +2 -2
  125. package/dist/editor/directives/diagnostics.js +10 -3
  126. package/dist/editor/directives/diagnostics.js.map +1 -1
  127. package/dist/editor/themes/payload.js +2 -1
  128. package/dist/editor/themes/payload.js.map +1 -1
  129. package/dist/exports/client.d.ts +4 -1
  130. package/dist/exports/client.js +5 -2
  131. package/dist/exports/client.js.map +1 -1
  132. package/dist/field/MarkdownField/Component.js +54 -3
  133. package/dist/field/MarkdownField/Component.js.map +1 -1
  134. package/dist/icons/entries.d.ts +22 -0
  135. package/dist/icons/entries.js +50 -0
  136. package/dist/icons/entries.js.map +1 -0
  137. package/dist/icons/resolve.d.ts +2 -1
  138. package/dist/icons/resolve.js +2 -2
  139. package/dist/icons/resolve.js.map +1 -1
  140. package/dist/icons/sanitizeSvg.d.ts +12 -2
  141. package/dist/icons/sanitizeSvg.js +104 -3
  142. package/dist/icons/sanitizeSvg.js.map +1 -1
  143. package/dist/index.d.ts +11 -4
  144. package/dist/index.js +34 -3
  145. package/dist/index.js.map +1 -1
  146. package/dist/mcp/index.d.ts +2 -2
  147. package/dist/mcp/index.js +65 -4
  148. package/dist/mcp/index.js.map +1 -1
  149. package/dist/palettes/colors.d.ts +21 -0
  150. package/dist/palettes/colors.js +43 -0
  151. package/dist/palettes/colors.js.map +1 -0
  152. package/dist/palettes/contrast.d.ts +7 -0
  153. package/dist/palettes/contrast.js +63 -0
  154. package/dist/palettes/contrast.js.map +1 -0
  155. package/dist/palettes/defaults.d.ts +8 -0
  156. package/dist/palettes/defaults.js +275 -0
  157. package/dist/palettes/defaults.js.map +1 -0
  158. package/dist/palettes/diagnostics.d.ts +10 -0
  159. package/dist/palettes/diagnostics.js +38 -0
  160. package/dist/palettes/diagnostics.js.map +1 -0
  161. package/dist/palettes/index.d.ts +61 -0
  162. package/dist/palettes/index.js +246 -0
  163. package/dist/palettes/index.js.map +1 -0
  164. package/dist/render/renderMarkdown.d.ts +3 -1
  165. package/dist/render/renderMarkdown.js +9 -1
  166. package/dist/render/renderMarkdown.js.map +1 -1
  167. package/dist/runtime/index.d.ts +12 -1
  168. package/dist/runtime/index.js +21 -2
  169. package/dist/runtime/index.js.map +1 -1
  170. package/dist/types/core.d.ts +43 -0
  171. package/dist/types/core.js.map +1 -1
  172. package/dist/types.d.ts +46 -2
  173. package/dist/types.js.map +1 -1
  174. package/dist/version.d.ts +1 -1
  175. package/dist/version.js +1 -1
  176. package/dist/version.js.map +1 -1
  177. package/package.json +1 -1
  178. package/skills/payload-markdown/claude/SKILL.md +1 -0
  179. package/skills/payload-markdown/claude/reference/directive-spec.json +60 -0
  180. package/skills/payload-markdown/claude/reference/mcp-content-workflow.md +7 -0
  181. package/skills/payload-markdown/claude/reference/payload-markdown-directives.md +22 -2
  182. package/skills/payload-markdown/claude/skill.json +2 -2
  183. package/skills/payload-markdown/codex/SKILL.md +1 -0
  184. package/skills/payload-markdown/codex/reference/directive-spec.json +60 -0
  185. package/skills/payload-markdown/codex/reference/mcp-content-workflow.md +7 -0
  186. package/skills/payload-markdown/codex/reference/payload-markdown-directives.md +22 -2
  187. package/skills/payload-markdown/codex/skill.json +2 -2
  188. package/dist/core/plugins/directiveBadge.d.ts +0 -6
  189. package/dist/core/plugins/directiveBadge.js +0 -94
  190. package/dist/core/plugins/directiveBadge.js.map +0 -1
  191. package/dist/core/plugins/directiveButton.d.ts +0 -6
  192. package/dist/core/plugins/directiveButton.js +0 -115
  193. package/dist/core/plugins/directiveButton.js.map +0 -1
  194. package/dist/directives/buttonSyntax.d.ts +0 -7
  195. package/dist/directives/buttonSyntax.js +0 -6
  196. package/dist/directives/buttonSyntax.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/editor/directiveConfig.ts"],"sourcesContent":["import type {\n MarkdownDirectiveTheme,\n MarkdownDirectiveThemeGroup,\n MarkdownDirectiveThemes,\n MarkdownRenderConfig,\n} from '../types/core.js'\n\n/** Key under `field.admin.custom` that carries the editor's directive config. */\nexport const PAYLOAD_MARKDOWN_ADMIN_CUSTOM_KEY = 'payloadMarkdown'\n\n/**\n * Serializable subset of the render configuration that the admin editor needs\n * to lint and complete directives the same way the renderer resolves them:\n * the directive theme registry (names only) and the icon pack aliases.\n */\nexport type MarkdownEditorDirectiveConfig = {\n /** Configured icon pack aliases; `undefined` when unknown to the editor. */\n iconPacks?: string[]\n themes?: MarkdownDirectiveThemes\n}\n\nfunction stripThemeGroup(group: MarkdownDirectiveThemeGroup): MarkdownDirectiveThemeGroup {\n const toNameOnly = (theme: MarkdownDirectiveTheme): MarkdownDirectiveTheme => ({\n name: theme.name,\n classes: '',\n })\n\n if (Array.isArray(group)) return group.map(toNameOnly)\n\n return {\n ...(typeof group.extendDefaults === 'boolean' ? { extendDefaults: group.extendDefaults } : {}),\n items: (group.items ?? []).map(toNameOnly),\n }\n}\n\n/**\n * Builds the editor config from a resolved render config. Theme classes are\n * dropped (the editor only needs names), so the result is small and safe to\n * serialize into the admin client config.\n */\nexport function createEditorDirectiveConfig(\n config: MarkdownRenderConfig | undefined,\n): MarkdownEditorDirectiveConfig {\n const themes: MarkdownDirectiveThemes = {}\n\n for (const [groupName, group] of Object.entries(config?.themes ?? {}) as Array<\n [keyof MarkdownDirectiveThemes, MarkdownDirectiveThemeGroup | undefined]\n >)\n if (group) themes[groupName] = stripThemeGroup(group)\n\n return {\n iconPacks: (config?.icons?.packs ?? [])\n .map((pack) => pack.alias.trim())\n .filter((alias) => alias.length > 0),\n ...(Object.keys(themes).length > 0 ? { themes } : {}),\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n\n/** Reads the editor config from `field.admin.custom`, tolerating bad input. */\nexport function readEditorDirectiveConfig(custom: unknown): MarkdownEditorDirectiveConfig | undefined {\n if (!isRecord(custom)) return undefined\n\n const value = custom[PAYLOAD_MARKDOWN_ADMIN_CUSTOM_KEY]\n if (!isRecord(value)) return undefined\n\n return {\n ...(Array.isArray(value.iconPacks)\n ? { iconPacks: value.iconPacks.filter((alias): alias is string => typeof alias === 'string') }\n : {}),\n ...(isRecord(value.themes) ? { themes: value.themes as MarkdownDirectiveThemes } : {}),\n }\n}\n"],"names":["PAYLOAD_MARKDOWN_ADMIN_CUSTOM_KEY","stripThemeGroup","group","toNameOnly","theme","name","classes","Array","isArray","map","extendDefaults","items","createEditorDirectiveConfig","config","themes","groupName","Object","entries","iconPacks","icons","packs","pack","alias","trim","filter","length","keys","isRecord","value","Boolean","readEditorDirectiveConfig","custom","undefined"],"mappings":"AAOA,+EAA+E,GAC/E,OAAO,MAAMA,oCAAoC,kBAAiB;AAalE,SAASC,gBAAgBC,KAAkC;IACzD,MAAMC,aAAa,CAACC,QAA2D,CAAA;YAC7EC,MAAMD,MAAMC,IAAI;YAChBC,SAAS;QACX,CAAA;IAEA,IAAIC,MAAMC,OAAO,CAACN,QAAQ,OAAOA,MAAMO,GAAG,CAACN;IAE3C,OAAO;QACL,GAAI,OAAOD,MAAMQ,cAAc,KAAK,YAAY;YAAEA,gBAAgBR,MAAMQ,cAAc;QAAC,IAAI,CAAC,CAAC;QAC7FC,OAAO,AAACT,CAAAA,MAAMS,KAAK,IAAI,EAAE,AAAD,EAAGF,GAAG,CAACN;IACjC;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASS,4BACdC,MAAwC;IAExC,MAAMC,SAAkC,CAAC;IAEzC,KAAK,MAAM,CAACC,WAAWb,MAAM,IAAIc,OAAOC,OAAO,CAACJ,QAAQC,UAAU,CAAC,GAGjE,IAAIZ,OAAOY,MAAM,CAACC,UAAU,GAAGd,gBAAgBC;IAEjD,OAAO;QACLgB,WAAW,AAACL,CAAAA,QAAQM,OAAOC,SAAS,EAAE,AAAD,EAClCX,GAAG,CAAC,CAACY,OAASA,KAAKC,KAAK,CAACC,IAAI,IAC7BC,MAAM,CAAC,CAACF,QAAUA,MAAMG,MAAM,GAAG;QACpC,GAAIT,OAAOU,IAAI,CAACZ,QAAQW,MAAM,GAAG,IAAI;YAAEX;QAAO,IAAI,CAAC,CAAC;IACtD;AACF;AAEA,SAASa,SAASC,KAAc;IAC9B,OAAOC,QAAQD,UAAU,OAAOA,UAAU,YAAY,CAACrB,MAAMC,OAAO,CAACoB;AACvE;AAEA,6EAA6E,GAC7E,OAAO,SAASE,0BAA0BC,MAAe;IACvD,IAAI,CAACJ,SAASI,SAAS,OAAOC;IAE9B,MAAMJ,QAAQG,MAAM,CAAC/B,kCAAkC;IACvD,IAAI,CAAC2B,SAASC,QAAQ,OAAOI;IAE7B,OAAO;QACL,GAAIzB,MAAMC,OAAO,CAACoB,MAAMV,SAAS,IAC7B;YAAEA,WAAWU,MAAMV,SAAS,CAACM,MAAM,CAAC,CAACF,QAA2B,OAAOA,UAAU;QAAU,IAC3F,CAAC,CAAC;QACN,GAAIK,SAASC,MAAMd,MAAM,IAAI;YAAEA,QAAQc,MAAMd,MAAM;QAA4B,IAAI,CAAC,CAAC;IACvF;AACF"}
1
+ {"version":3,"sources":["../../src/editor/directiveConfig.ts"],"sourcesContent":["import type {\n MarkdownDirectiveTheme,\n MarkdownDirectiveThemeGroup,\n MarkdownDirectiveThemes,\n MarkdownRenderConfig,\n} from '../types/core.js'\n\nimport { getPaletteRegistry } from '../palettes/index.js'\n\n/** Key under `field.admin.custom` that carries the editor's directive config. */\nexport const PAYLOAD_MARKDOWN_ADMIN_CUSTOM_KEY = 'payloadMarkdown'\n\n/**\n * Serializable subset of the render configuration that the admin editor needs\n * to lint and complete directives the same way the renderer resolves them:\n * the directive theme registry (names only) and the icon pack aliases.\n */\nexport type MarkdownEditorDirectiveConfig = {\n /** Slug of the \"Markdown Appearance\" global, whose palettes the editor loads at runtime. */\n appearanceSlug?: string\n /**\n * Runtime palette names (configured plus admin-managed), set by the field\n * component once loaded; `undefined` while they are still loading.\n */\n getPaletteNames?: () => readonly string[] | undefined\n /** Configured icon pack aliases; `undefined` when unknown to the editor. */\n iconPacks?: string[]\n /** Palette names known when the config was built (built-in and configured). */\n palettes?: string[]\n themes?: MarkdownDirectiveThemes\n}\n\n/**\n * Palette names the editor can check against, or `undefined` while palettes\n * managed in the admin are still loading (nothing is reported as unknown then).\n */\nexport function getEditorPaletteNames(config: MarkdownEditorDirectiveConfig): readonly string[] | undefined {\n const loaded = config.getPaletteNames?.()\n if (loaded) return loaded\n\n return config.appearanceSlug ? undefined : config.palettes\n}\n\nfunction stripThemeGroup(group: MarkdownDirectiveThemeGroup): MarkdownDirectiveThemeGroup {\n const toNameOnly = (theme: MarkdownDirectiveTheme): MarkdownDirectiveTheme => ({\n name: theme.name,\n classes: '',\n })\n\n if (Array.isArray(group)) return group.map(toNameOnly)\n\n return {\n ...(typeof group.extendDefaults === 'boolean' ? { extendDefaults: group.extendDefaults } : {}),\n items: (group.items ?? []).map(toNameOnly),\n }\n}\n\n/**\n * Builds the editor config from a resolved render config. Theme classes are\n * dropped (the editor only needs names), so the result is small and safe to\n * serialize into the admin client config.\n */\nexport function createEditorDirectiveConfig(\n config: MarkdownRenderConfig | undefined,\n appearanceSlug?: string,\n): MarkdownEditorDirectiveConfig {\n const themes: MarkdownDirectiveThemes = {}\n\n for (const [groupName, group] of Object.entries(config?.themes ?? {}) as Array<\n [keyof MarkdownDirectiveThemes, MarkdownDirectiveThemeGroup | undefined]\n >)\n if (group) themes[groupName] = stripThemeGroup(group)\n\n return {\n ...(appearanceSlug ? { appearanceSlug } : {}),\n iconPacks: (config?.icons?.packs ?? [])\n .map((pack) => pack.alias.trim())\n .filter((alias) => alias.length > 0),\n palettes: getPaletteRegistry(config?.palettes).names(),\n ...(Object.keys(themes).length > 0 ? { themes } : {}),\n }\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return Boolean(value) && typeof value === 'object' && !Array.isArray(value)\n}\n\n/** Reads the editor config from `field.admin.custom`, tolerating bad input. */\nexport function readEditorDirectiveConfig(custom: unknown): MarkdownEditorDirectiveConfig | undefined {\n if (!isRecord(custom)) return undefined\n\n const value = custom[PAYLOAD_MARKDOWN_ADMIN_CUSTOM_KEY]\n if (!isRecord(value)) return undefined\n\n const strings = (list: unknown) =>\n Array.isArray(list) ? list.filter((item): item is string => typeof item === 'string') : undefined\n\n return {\n ...(typeof value.appearanceSlug === 'string' && value.appearanceSlug ? { appearanceSlug: value.appearanceSlug } : {}),\n ...(strings(value.palettes) ? { palettes: strings(value.palettes) } : {}),\n ...(Array.isArray(value.iconPacks)\n ? { iconPacks: value.iconPacks.filter((alias): alias is string => typeof alias === 'string') }\n : {}),\n ...(isRecord(value.themes) ? { themes: value.themes as MarkdownDirectiveThemes } : {}),\n }\n}\n"],"names":["getPaletteRegistry","PAYLOAD_MARKDOWN_ADMIN_CUSTOM_KEY","getEditorPaletteNames","config","loaded","getPaletteNames","appearanceSlug","undefined","palettes","stripThemeGroup","group","toNameOnly","theme","name","classes","Array","isArray","map","extendDefaults","items","createEditorDirectiveConfig","themes","groupName","Object","entries","iconPacks","icons","packs","pack","alias","trim","filter","length","names","keys","isRecord","value","Boolean","readEditorDirectiveConfig","custom","strings","list","item"],"mappings":"AAOA,SAASA,kBAAkB,QAAQ,uBAAsB;AAEzD,+EAA+E,GAC/E,OAAO,MAAMC,oCAAoC,kBAAiB;AAsBlE;;;CAGC,GACD,OAAO,SAASC,sBAAsBC,MAAqC;IACzE,MAAMC,SAASD,OAAOE,eAAe;IACrC,IAAID,QAAQ,OAAOA;IAEnB,OAAOD,OAAOG,cAAc,GAAGC,YAAYJ,OAAOK,QAAQ;AAC5D;AAEA,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,kCAAkC;IACvD,IAAI,CAACkC,SAASC,QAAQ,OAAO7B;IAE7B,MAAMiC,UAAU,CAACC,OACf1B,MAAMC,OAAO,CAACyB,QAAQA,KAAKV,MAAM,CAAC,CAACW,OAAyB,OAAOA,SAAS,YAAYnC;IAE1F,OAAO;QACL,GAAI,OAAO6B,MAAM9B,cAAc,KAAK,YAAY8B,MAAM9B,cAAc,GAAG;YAAEA,gBAAgB8B,MAAM9B,cAAc;QAAC,IAAI,CAAC,CAAC;QACpH,GAAIkC,QAAQJ,MAAM5B,QAAQ,IAAI;YAAEA,UAAUgC,QAAQJ,MAAM5B,QAAQ;QAAE,IAAI,CAAC,CAAC;QACxE,GAAIO,MAAMC,OAAO,CAACoB,MAAMX,SAAS,IAC7B;YAAEA,WAAWW,MAAMX,SAAS,CAACM,MAAM,CAAC,CAACF,QAA2B,OAAOA,UAAU;QAAU,IAC3F,CAAC,CAAC;QACN,GAAIM,SAASC,MAAMf,MAAM,IAAI;YAAEA,QAAQe,MAAMf,MAAM;QAA4B,IAAI,CAAC,CAAC;IACvF;AACF"}
@@ -3,9 +3,11 @@ import type { MarkdownEditorDirectiveConfig } from '../directiveConfig.js';
3
3
  export declare function getDirectiveCompletionOptions(): Completion[];
4
4
  export declare function getDirectiveAttributeCompletionOptions(name: string): Completion[];
5
5
  export declare function getDirectiveThemeValueCompletionOptions(name: string, attribute: string, config?: MarkdownEditorDirectiveConfig): Completion[];
6
+ /** Palette names: configured ones plus, once loaded, those managed in the admin. */
7
+ export declare function getPaletteCompletionOptions(config?: MarkdownEditorDirectiveConfig): Completion[];
6
8
  /**
7
- * Directive completions that know the field's configured themes and icon
8
- * packs (CORE-8). `config` comes from `field.admin.custom.payloadMarkdown`.
9
+ * Directive completions that know the field's configured themes, icon packs
10
+ * and palettes (CORE-8). `config` comes from `field.admin.custom.payloadMarkdown`.
9
11
  */
10
12
  export declare function createDirectiveCompletions(config?: MarkdownEditorDirectiveConfig): import("@codemirror/state").Extension;
11
13
  export declare const directiveCompletions: import("@codemirror/state").Extension;
@@ -1,6 +1,14 @@
1
1
  import { autocompletion, snippetCompletion } from '@codemirror/autocomplete';
2
2
  import { layoutDirectiveRegistry } from '../../directives/registry.js';
3
3
  import { getDirectiveThemeNames } from '../../directives/themes.js';
4
+ import { getEditorPaletteNames } from '../directiveConfig.js';
5
+ /** `::name` for leaf directives, `:::name` otherwise (completion details). */ function getMarkerPrefix(name) {
6
+ return layoutDirectiveRegistry.isLeafDirectiveName(name) ? `::${name}` : `:::${name}`;
7
+ }
8
+ // `::name` lines of the registry's leaf directives (button, badge).
9
+ const LEAF_NAMES_PATTERN = layoutDirectiveRegistry.leafDirectiveNames.join('|');
10
+ const LEAF_ATTRIBUTES_BEFORE_CURSOR = new RegExp(`^\\s*::(${LEAF_NAMES_PATTERN})(?:\\[[^\\]]*\\])?\\s*\\{([^}]*)$`);
11
+ const LEAF_ATTRIBUTES_OPEN = new RegExp(`^\\s*::(${LEAF_NAMES_PATTERN})(?:\\[[^\\]]*\\])?\\s*\\{`);
4
12
  export function getDirectiveCompletionOptions() {
5
13
  return layoutDirectiveRegistry.getPublicDefinitions().flatMap((definition)=>{
6
14
  const label = definition.editor.label.startsWith(':') ? definition.editor.label : `:::${definition.name}`;
@@ -27,7 +35,7 @@ export function getDirectiveCompletionOptions() {
27
35
  export function getDirectiveAttributeCompletionOptions(name) {
28
36
  const definition = layoutDirectiveRegistry.get(name);
29
37
  const attributes = definition?.allowedAttributes ?? [];
30
- const detailPrefix = name === 'button' || name === 'badge' ? `::${name}` : `:::${name}`;
38
+ const detailPrefix = getMarkerPrefix(name);
31
39
  return attributes.map((attribute)=>snippetCompletion(`${attribute}="\${${attribute}}"`, {
32
40
  type: 'property',
33
41
  detail: `${detailPrefix} attribute`,
@@ -37,7 +45,8 @@ export function getDirectiveAttributeCompletionOptions(name) {
37
45
  export function getDirectiveThemeValueCompletionOptions(name, attribute, config = {}) {
38
46
  const definition = layoutDirectiveRegistry.get(name);
39
47
  const groupName = definition?.themeAttributes?.[attribute];
40
- const detailPrefix = name === 'button' || name === 'badge' ? `::${name}` : `:::${name}`;
48
+ const detailPrefix = getMarkerPrefix(name);
49
+ if (attribute === 'palette' || attribute === 'iconPalette') return getPaletteCompletionOptions(config);
41
50
  if (attribute === 'icon') return (config.iconPacks ?? []).map((alias)=>({
42
51
  type: 'constant',
43
52
  detail: 'icon pack',
@@ -54,11 +63,19 @@ export function getDirectiveThemeValueCompletionOptions(name, attribute, config
54
63
  label: themeName
55
64
  }));
56
65
  }
66
+ /** Palette names: configured ones plus, once loaded, those managed in the admin. */ export function getPaletteCompletionOptions(config = {}) {
67
+ const names = getEditorPaletteNames(config) ?? config.palettes ?? [];
68
+ return names.map((name)=>({
69
+ type: 'constant',
70
+ detail: 'palette',
71
+ label: name
72
+ }));
73
+ }
57
74
  function attributeCompletionSource(context, config) {
58
75
  const line = context.state.doc.lineAt(context.pos);
59
76
  const beforeCursor = line.text.slice(0, context.pos - line.from);
60
77
  const containerMatch = beforeCursor.match(/^\s*:::(\w+)(?:\[[^\]]*\])?\s*\{([^}]*)$/);
61
- const leafMatch = beforeCursor.match(/^\s*::(button|badge)(?:\[[^\]]*\])?\s*\{([^}]*)$/);
78
+ const leafMatch = beforeCursor.match(LEAF_ATTRIBUTES_BEFORE_CURSOR);
62
79
  const multilineMatch = containerMatch || leafMatch ? null : findOpenDirectiveAttributeBlock(context, beforeCursor);
63
80
  const directiveMatch = containerMatch ? {
64
81
  name: containerMatch[1],
@@ -69,7 +86,16 @@ function attributeCompletionSource(context, config) {
69
86
  } : multilineMatch;
70
87
  if (!directiveMatch) return null;
71
88
  const { name, attributesBeforeCursor } = directiveMatch;
72
- const valueMatch = attributesBeforeCursor.match(/(?:^|\s)(align|gap|theme|cardTheme|cellTheme|icon|iconPosition|interval|linkScope|newTab|size|stack|stepTheme|style|tabTheme|target|type|variant|wrap)=["']?([^"'\s}]*)$/);
89
+ // `palette=` inside an icon entry: icon="@pack/a palette=|"
90
+ const iconPaletteMatch = attributesBeforeCursor.match(/(?:^|\s)icon=["'][^"']*\spalette=([\w-]*)$/);
91
+ if (iconPaletteMatch) {
92
+ const options = getPaletteCompletionOptions(config);
93
+ return options.length > 0 ? {
94
+ from: context.pos - iconPaletteMatch[1].length,
95
+ options
96
+ } : null;
97
+ }
98
+ const valueMatch = attributesBeforeCursor.match(/(?:^|\s)(align|gap|theme|cardTheme|cellTheme|icon|iconPalette|iconPosition|interval|linkScope|newTab|palette|size|stack|stepTheme|style|tabTheme|target|type|variant|wrap)=["']?([^"'\s}]*)$/);
73
99
  if (valueMatch) {
74
100
  const [, attribute, typedValue] = valueMatch;
75
101
  const options = getDirectiveThemeValueCompletionOptions(name, attribute, config);
@@ -101,7 +127,7 @@ function findOpenDirectiveAttributeBlock(context, attributesBeforeCursor) {
101
127
  name: containerMatch[1],
102
128
  attributesBeforeCursor
103
129
  };
104
- const leafMatch = previousLine.match(/^\s*::(button|badge)(?:\[[^\]]*\])?\s*\{/);
130
+ const leafMatch = previousLine.match(LEAF_ATTRIBUTES_OPEN);
105
131
  if (leafMatch) return {
106
132
  name: leafMatch[1],
107
133
  attributesBeforeCursor
@@ -131,8 +157,8 @@ function directiveCompletionSource(context, config = {}) {
131
157
  };
132
158
  }
133
159
  /**
134
- * Directive completions that know the field's configured themes and icon
135
- * packs (CORE-8). `config` comes from `field.admin.custom.payloadMarkdown`.
160
+ * Directive completions that know the field's configured themes, icon packs
161
+ * and palettes (CORE-8). `config` comes from `field.admin.custom.payloadMarkdown`.
136
162
  */ export function createDirectiveCompletions(config = {}) {
137
163
  return autocompletion({
138
164
  activateOnTyping: true,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/directives/completions.ts"],"sourcesContent":["import type { Completion, CompletionContext } from '@codemirror/autocomplete'\n\nimport { autocompletion, snippetCompletion } from '@codemirror/autocomplete'\n\nimport type { MarkdownEditorDirectiveConfig } from '../directiveConfig.js'\n\nimport { layoutDirectiveRegistry } from '../../directives/registry.js'\nimport { getDirectiveThemeNames } from '../../directives/themes.js'\n\nexport function getDirectiveCompletionOptions() {\n return layoutDirectiveRegistry.getPublicDefinitions().flatMap((definition) => {\n const label = definition.editor.label.startsWith(':')\n ? definition.editor.label\n : `:::${definition.name}`\n const snippets = [\n {\n detail: definition.editor.detail,\n label,\n snippet: definition.editor.snippet,\n },\n ...(definition.editor.snippets ?? []).map((snippet) => ({\n detail: snippet.detail ?? definition.editor.detail,\n label: snippet.label,\n snippet: snippet.snippet,\n })),\n ]\n\n return snippets.map((snippet) =>\n snippetCompletion(snippet.snippet, {\n type: 'keyword',\n detail: snippet.detail,\n info: definition.description,\n label: snippet.label,\n }),\n )\n })\n}\n\nexport function getDirectiveAttributeCompletionOptions(name: string): Completion[] {\n const definition = layoutDirectiveRegistry.get(name)\n const attributes = definition?.allowedAttributes ?? []\n const detailPrefix = name === 'button' || name === 'badge' ? `::${name}` : `:::${name}`\n\n return attributes.map((attribute) =>\n snippetCompletion(`${attribute}=\"\\${${attribute}}\"`, {\n type: 'property',\n detail: `${detailPrefix} attribute`,\n label: attribute,\n }),\n )\n}\n\nexport function getDirectiveThemeValueCompletionOptions(\n name: string,\n attribute: string,\n config: MarkdownEditorDirectiveConfig = {},\n): Completion[] {\n const definition = layoutDirectiveRegistry.get(name)\n const groupName = definition?.themeAttributes?.[attribute]\n const detailPrefix = name === 'button' || name === 'badge' ? `::${name}` : `:::${name}`\n\n if (attribute === 'icon')\n return (config.iconPacks ?? []).map((alias) => ({\n type: 'constant',\n detail: 'icon pack',\n label: `@${alias}/`,\n }))\n\n if (!groupName)\n return (definition?.attributeValues?.[attribute] ?? []).map((value) => ({\n type: 'constant',\n detail: `${detailPrefix} ${attribute}`,\n label: value,\n }))\n\n return getDirectiveThemeNames(groupName, config.themes).map((themeName) => ({\n type: 'constant',\n detail: `${groupName} theme`,\n label: themeName,\n }))\n}\n\nfunction attributeCompletionSource(\n context: CompletionContext,\n config: MarkdownEditorDirectiveConfig,\n) {\n const line = context.state.doc.lineAt(context.pos)\n const beforeCursor = line.text.slice(0, context.pos - line.from)\n const containerMatch = beforeCursor.match(/^\\s*:::(\\w+)(?:\\[[^\\]]*\\])?\\s*\\{([^}]*)$/)\n const leafMatch = beforeCursor.match(/^\\s*::(button|badge)(?:\\[[^\\]]*\\])?\\s*\\{([^}]*)$/)\n const multilineMatch =\n containerMatch || leafMatch\n ? null\n : findOpenDirectiveAttributeBlock(context, beforeCursor)\n const directiveMatch = containerMatch\n ? {\n name: containerMatch[1],\n attributesBeforeCursor: containerMatch[2],\n }\n : leafMatch\n ? {\n name: leafMatch[1],\n attributesBeforeCursor: leafMatch[2],\n }\n : multilineMatch\n\n if (!directiveMatch) return null\n\n const { name, attributesBeforeCursor } = directiveMatch\n const valueMatch = attributesBeforeCursor.match(\n /(?:^|\\s)(align|gap|theme|cardTheme|cellTheme|icon|iconPosition|interval|linkScope|newTab|size|stack|stepTheme|style|tabTheme|target|type|variant|wrap)=[\"']?([^\"'\\s}]*)$/,\n )\n\n if (valueMatch) {\n const [, attribute, typedValue] = valueMatch\n const options = getDirectiveThemeValueCompletionOptions(name, attribute, config)\n\n if (options.length === 0) return null\n\n return {\n from: context.pos - typedValue.length,\n options,\n }\n }\n\n const attributeMatch = attributesBeforeCursor.match(/(?:^|\\s)([\\w-]*)$/)\n const typedAttribute = attributeMatch?.[1] ?? ''\n const options = getDirectiveAttributeCompletionOptions(name)\n\n if (options.length === 0) return null\n if (!context.explicit && typedAttribute.length === 0) return null\n\n return {\n from: context.pos - typedAttribute.length,\n options,\n }\n}\n\nfunction findOpenDirectiveAttributeBlock(\n context: CompletionContext,\n attributesBeforeCursor: string,\n): { attributesBeforeCursor: string; name: string } | null {\n const line = context.state.doc.lineAt(context.pos)\n\n for (let lineNumber = line.number - 1; lineNumber >= 1; --lineNumber) {\n const previousLine = context.state.doc.line(lineNumber).text\n const trimmed = previousLine.trim()\n\n if (!trimmed) break\n if (trimmed.includes('}')) break\n\n const containerMatch = previousLine.match(/^\\s*:::(\\w+)(?:\\[[^\\]]*\\])?\\s*\\{/)\n if (containerMatch)\n return {\n name: containerMatch[1],\n attributesBeforeCursor,\n }\n\n const leafMatch = previousLine.match(/^\\s*::(button|badge)(?:\\[[^\\]]*\\])?\\s*\\{/)\n if (leafMatch)\n return {\n name: leafMatch[1],\n attributesBeforeCursor,\n }\n }\n\n return null\n}\n\nfunction directiveCompletionSource(\n context: CompletionContext,\n config: MarkdownEditorDirectiveConfig = {},\n) {\n const attributeResult = attributeCompletionSource(context, config)\n if (attributeResult) return attributeResult\n\n const leafMatch = context.matchBefore(/::[\\w-]*/)\n if (leafMatch) {\n const line = context.state.doc.lineAt(context.pos)\n const beforeLeaf = line.text.slice(0, leafMatch.from - line.from)\n const typedLeaf = line.text.slice(leafMatch.from - line.from, leafMatch.to - line.from)\n\n if (!typedLeaf.startsWith(':::') && !beforeLeaf.trim())\n return {\n from: leafMatch.from,\n options: getDirectiveCompletionOptions().filter((option) =>\n typeof option.label === 'string'\n ? option.label.startsWith('::') && !option.label.startsWith(':::')\n : false,\n ),\n }\n }\n\n const match = context.matchBefore(/:::[\\w-]*/)\n\n if (!match) return null\n if (match.from === match.to && !context.explicit) return null\n\n return {\n from: match.from,\n options: getDirectiveCompletionOptions().filter((option) =>\n typeof option.label === 'string' ? option.label.startsWith(':::') : true,\n ),\n }\n}\n\n/**\n * Directive completions that know the field's configured themes and icon\n * packs (CORE-8). `config` comes from `field.admin.custom.payloadMarkdown`.\n */\nexport function createDirectiveCompletions(config: MarkdownEditorDirectiveConfig = {}) {\n return autocompletion({\n activateOnTyping: true,\n override: [(context: CompletionContext) => directiveCompletionSource(context, config)],\n })\n}\n\nexport const directiveCompletions = createDirectiveCompletions()\n"],"names":["autocompletion","snippetCompletion","layoutDirectiveRegistry","getDirectiveThemeNames","getDirectiveCompletionOptions","getPublicDefinitions","flatMap","definition","label","editor","startsWith","name","snippets","detail","snippet","map","type","info","description","getDirectiveAttributeCompletionOptions","get","attributes","allowedAttributes","detailPrefix","attribute","getDirectiveThemeValueCompletionOptions","config","groupName","themeAttributes","iconPacks","alias","attributeValues","value","themes","themeName","attributeCompletionSource","context","line","state","doc","lineAt","pos","beforeCursor","text","slice","from","containerMatch","match","leafMatch","multilineMatch","findOpenDirectiveAttributeBlock","directiveMatch","attributesBeforeCursor","valueMatch","typedValue","options","length","attributeMatch","typedAttribute","explicit","lineNumber","number","previousLine","trimmed","trim","includes","directiveCompletionSource","attributeResult","matchBefore","beforeLeaf","typedLeaf","to","filter","option","createDirectiveCompletions","activateOnTyping","override","directiveCompletions"],"mappings":"AAEA,SAASA,cAAc,EAAEC,iBAAiB,QAAQ,2BAA0B;AAI5E,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,sBAAsB,QAAQ,6BAA4B;AAEnE,OAAO,SAASC;IACd,OAAOF,wBAAwBG,oBAAoB,GAAGC,OAAO,CAAC,CAACC;QAC7D,MAAMC,QAAQD,WAAWE,MAAM,CAACD,KAAK,CAACE,UAAU,CAAC,OAC7CH,WAAWE,MAAM,CAACD,KAAK,GACvB,CAAC,GAAG,EAAED,WAAWI,IAAI,EAAE;QAC3B,MAAMC,WAAW;YACf;gBACEC,QAAQN,WAAWE,MAAM,CAACI,MAAM;gBAChCL;gBACAM,SAASP,WAAWE,MAAM,CAACK,OAAO;YACpC;eACG,AAACP,CAAAA,WAAWE,MAAM,CAACG,QAAQ,IAAI,EAAE,AAAD,EAAGG,GAAG,CAAC,CAACD,UAAa,CAAA;oBACtDD,QAAQC,QAAQD,MAAM,IAAIN,WAAWE,MAAM,CAACI,MAAM;oBAClDL,OAAOM,QAAQN,KAAK;oBACpBM,SAASA,QAAQA,OAAO;gBAC1B,CAAA;SACD;QAED,OAAOF,SAASG,GAAG,CAAC,CAACD,UACnBb,kBAAkBa,QAAQA,OAAO,EAAE;gBACjCE,MAAM;gBACNH,QAAQC,QAAQD,MAAM;gBACtBI,MAAMV,WAAWW,WAAW;gBAC5BV,OAAOM,QAAQN,KAAK;YACtB;IAEJ;AACF;AAEA,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2D,WAAWL,IAAI,IAClD,OAAO;YACLnB,MAAMG,UAAUH,IAAI;YACpBU,SAASnD,gCAAgCoE,MAAM,CAAC,CAACC,SAC/C,OAAOA,OAAOjE,KAAK,KAAK,WACpBiE,OAAOjE,KAAK,CAACE,UAAU,CAAC,SAAS,CAAC+D,OAAOjE,KAAK,CAACE,UAAU,CAAC,SAC1D;QAER;IACJ;IAEA,MAAMqC,QAAQX,QAAQgC,WAAW,CAAC;IAElC,IAAI,CAACrB,OAAO,OAAO;IACnB,IAAIA,MAAMF,IAAI,KAAKE,MAAMwB,EAAE,IAAI,CAACnC,QAAQuB,QAAQ,EAAE,OAAO;IAEzD,OAAO;QACLd,MAAME,MAAMF,IAAI;QAChBU,SAASnD,gCAAgCoE,MAAM,CAAC,CAACC,SAC/C,OAAOA,OAAOjE,KAAK,KAAK,WAAWiE,OAAOjE,KAAK,CAACE,UAAU,CAAC,SAAS;IAExE;AACF;AAEA;;;CAGC,GACD,OAAO,SAASgE,2BAA2BhD,SAAwC,CAAC,CAAC;IACnF,OAAO1B,eAAe;QACpB2E,kBAAkB;QAClBC,UAAU;YAAC,CAACxC,UAA+B8B,0BAA0B9B,SAASV;SAAQ;IACxF;AACF;AAEA,OAAO,MAAMmD,uBAAuBH,6BAA4B"}
1
+ {"version":3,"sources":["../../../src/editor/directives/completions.ts"],"sourcesContent":["import type { Completion, CompletionContext } from '@codemirror/autocomplete'\n\nimport { autocompletion, snippetCompletion } from '@codemirror/autocomplete'\n\nimport type { MarkdownEditorDirectiveConfig } from '../directiveConfig.js'\n\nimport { layoutDirectiveRegistry } from '../../directives/registry.js'\nimport { getDirectiveThemeNames } from '../../directives/themes.js'\nimport { getEditorPaletteNames } from '../directiveConfig.js'\n\n/** `::name` for leaf directives, `:::name` otherwise (completion details). */\nfunction getMarkerPrefix(name: string): string {\n return layoutDirectiveRegistry.isLeafDirectiveName(name) ? `::${name}` : `:::${name}`\n}\n\n// `::name` lines of the registry's leaf directives (button, badge).\nconst LEAF_NAMES_PATTERN = layoutDirectiveRegistry.leafDirectiveNames.join('|')\nconst LEAF_ATTRIBUTES_BEFORE_CURSOR = new RegExp(\n `^\\\\s*::(${LEAF_NAMES_PATTERN})(?:\\\\[[^\\\\]]*\\\\])?\\\\s*\\\\{([^}]*)$`,\n)\nconst LEAF_ATTRIBUTES_OPEN = new RegExp(`^\\\\s*::(${LEAF_NAMES_PATTERN})(?:\\\\[[^\\\\]]*\\\\])?\\\\s*\\\\{`)\n\nexport function getDirectiveCompletionOptions() {\n return layoutDirectiveRegistry.getPublicDefinitions().flatMap((definition) => {\n const label = definition.editor.label.startsWith(':')\n ? definition.editor.label\n : `:::${definition.name}`\n const snippets = [\n {\n detail: definition.editor.detail,\n label,\n snippet: definition.editor.snippet,\n },\n ...(definition.editor.snippets ?? []).map((snippet) => ({\n detail: snippet.detail ?? definition.editor.detail,\n label: snippet.label,\n snippet: snippet.snippet,\n })),\n ]\n\n return snippets.map((snippet) =>\n snippetCompletion(snippet.snippet, {\n type: 'keyword',\n detail: snippet.detail,\n info: definition.description,\n label: snippet.label,\n }),\n )\n })\n}\n\nexport function getDirectiveAttributeCompletionOptions(name: string): Completion[] {\n const definition = layoutDirectiveRegistry.get(name)\n const attributes = definition?.allowedAttributes ?? []\n const detailPrefix = getMarkerPrefix(name)\n\n return attributes.map((attribute) =>\n snippetCompletion(`${attribute}=\"\\${${attribute}}\"`, {\n type: 'property',\n detail: `${detailPrefix} attribute`,\n label: attribute,\n }),\n )\n}\n\nexport function getDirectiveThemeValueCompletionOptions(\n name: string,\n attribute: string,\n config: MarkdownEditorDirectiveConfig = {},\n): Completion[] {\n const definition = layoutDirectiveRegistry.get(name)\n const groupName = definition?.themeAttributes?.[attribute]\n const detailPrefix = getMarkerPrefix(name)\n\n if (attribute === 'palette' || attribute === 'iconPalette') return getPaletteCompletionOptions(config)\n\n if (attribute === 'icon')\n return (config.iconPacks ?? []).map((alias) => ({\n type: 'constant',\n detail: 'icon pack',\n label: `@${alias}/`,\n }))\n\n if (!groupName)\n return (definition?.attributeValues?.[attribute] ?? []).map((value) => ({\n type: 'constant',\n detail: `${detailPrefix} ${attribute}`,\n label: value,\n }))\n\n return getDirectiveThemeNames(groupName, config.themes).map((themeName) => ({\n type: 'constant',\n detail: `${groupName} theme`,\n label: themeName,\n }))\n}\n\n/** Palette names: configured ones plus, once loaded, those managed in the admin. */\nexport function getPaletteCompletionOptions(config: MarkdownEditorDirectiveConfig = {}): Completion[] {\n const names = getEditorPaletteNames(config) ?? config.palettes ?? []\n\n return names.map((name) => ({ type: 'constant', detail: 'palette', label: name }))\n}\n\nfunction attributeCompletionSource(\n context: CompletionContext,\n config: MarkdownEditorDirectiveConfig,\n) {\n const line = context.state.doc.lineAt(context.pos)\n const beforeCursor = line.text.slice(0, context.pos - line.from)\n const containerMatch = beforeCursor.match(/^\\s*:::(\\w+)(?:\\[[^\\]]*\\])?\\s*\\{([^}]*)$/)\n const leafMatch = beforeCursor.match(LEAF_ATTRIBUTES_BEFORE_CURSOR)\n const multilineMatch =\n containerMatch || leafMatch\n ? null\n : findOpenDirectiveAttributeBlock(context, beforeCursor)\n const directiveMatch = containerMatch\n ? {\n name: containerMatch[1],\n attributesBeforeCursor: containerMatch[2],\n }\n : leafMatch\n ? {\n name: leafMatch[1],\n attributesBeforeCursor: leafMatch[2],\n }\n : multilineMatch\n\n if (!directiveMatch) return null\n\n const { name, attributesBeforeCursor } = directiveMatch\n\n // `palette=` inside an icon entry: icon=\"@pack/a palette=|\"\n const iconPaletteMatch = attributesBeforeCursor.match(/(?:^|\\s)icon=[\"'][^\"']*\\spalette=([\\w-]*)$/)\n\n if (iconPaletteMatch) {\n const options = getPaletteCompletionOptions(config)\n\n return options.length > 0 ? { from: context.pos - iconPaletteMatch[1].length, options } : null\n }\n\n const valueMatch = attributesBeforeCursor.match(\n /(?:^|\\s)(align|gap|theme|cardTheme|cellTheme|icon|iconPalette|iconPosition|interval|linkScope|newTab|palette|size|stack|stepTheme|style|tabTheme|target|type|variant|wrap)=[\"']?([^\"'\\s}]*)$/,\n )\n\n if (valueMatch) {\n const [, attribute, typedValue] = valueMatch\n const options = getDirectiveThemeValueCompletionOptions(name, attribute, config)\n\n if (options.length === 0) return null\n\n return {\n from: context.pos - typedValue.length,\n options,\n }\n }\n\n const attributeMatch = attributesBeforeCursor.match(/(?:^|\\s)([\\w-]*)$/)\n const typedAttribute = attributeMatch?.[1] ?? ''\n const options = getDirectiveAttributeCompletionOptions(name)\n\n if (options.length === 0) return null\n if (!context.explicit && typedAttribute.length === 0) return null\n\n return {\n from: context.pos - typedAttribute.length,\n options,\n }\n}\n\nfunction findOpenDirectiveAttributeBlock(\n context: CompletionContext,\n attributesBeforeCursor: string,\n): { attributesBeforeCursor: string; name: string } | null {\n const line = context.state.doc.lineAt(context.pos)\n\n for (let lineNumber = line.number - 1; lineNumber >= 1; --lineNumber) {\n const previousLine = context.state.doc.line(lineNumber).text\n const trimmed = previousLine.trim()\n\n if (!trimmed) break\n if (trimmed.includes('}')) break\n\n const containerMatch = previousLine.match(/^\\s*:::(\\w+)(?:\\[[^\\]]*\\])?\\s*\\{/)\n if (containerMatch)\n return {\n name: containerMatch[1],\n attributesBeforeCursor,\n }\n\n const leafMatch = previousLine.match(LEAF_ATTRIBUTES_OPEN)\n if (leafMatch)\n return {\n name: leafMatch[1],\n attributesBeforeCursor,\n }\n }\n\n return null\n}\n\nfunction directiveCompletionSource(\n context: CompletionContext,\n config: MarkdownEditorDirectiveConfig = {},\n) {\n const attributeResult = attributeCompletionSource(context, config)\n if (attributeResult) return attributeResult\n\n const leafMatch = context.matchBefore(/::[\\w-]*/)\n if (leafMatch) {\n const line = context.state.doc.lineAt(context.pos)\n const beforeLeaf = line.text.slice(0, leafMatch.from - line.from)\n const typedLeaf = line.text.slice(leafMatch.from - line.from, leafMatch.to - line.from)\n\n if (!typedLeaf.startsWith(':::') && !beforeLeaf.trim())\n return {\n from: leafMatch.from,\n options: getDirectiveCompletionOptions().filter((option) =>\n typeof option.label === 'string'\n ? option.label.startsWith('::') && !option.label.startsWith(':::')\n : false,\n ),\n }\n }\n\n const match = context.matchBefore(/:::[\\w-]*/)\n\n if (!match) return null\n if (match.from === match.to && !context.explicit) return null\n\n return {\n from: match.from,\n options: getDirectiveCompletionOptions().filter((option) =>\n typeof option.label === 'string' ? option.label.startsWith(':::') : true,\n ),\n }\n}\n\n/**\n * Directive completions that know the field's configured themes, icon packs\n * and palettes (CORE-8). `config` comes from `field.admin.custom.payloadMarkdown`.\n */\nexport function createDirectiveCompletions(config: MarkdownEditorDirectiveConfig = {}) {\n return autocompletion({\n activateOnTyping: true,\n override: [(context: CompletionContext) => directiveCompletionSource(context, config)],\n })\n}\n\nexport const directiveCompletions = createDirectiveCompletions()\n"],"names":["autocompletion","snippetCompletion","layoutDirectiveRegistry","getDirectiveThemeNames","getEditorPaletteNames","getMarkerPrefix","name","isLeafDirectiveName","LEAF_NAMES_PATTERN","leafDirectiveNames","join","LEAF_ATTRIBUTES_BEFORE_CURSOR","RegExp","LEAF_ATTRIBUTES_OPEN","getDirectiveCompletionOptions","getPublicDefinitions","flatMap","definition","label","editor","startsWith","snippets","detail","snippet","map","type","info","description","getDirectiveAttributeCompletionOptions","get","attributes","allowedAttributes","detailPrefix","attribute","getDirectiveThemeValueCompletionOptions","config","groupName","themeAttributes","getPaletteCompletionOptions","iconPacks","alias","attributeValues","value","themes","themeName","names","palettes","attributeCompletionSource","context","line","state","doc","lineAt","pos","beforeCursor","text","slice","from","containerMatch","match","leafMatch","multilineMatch","findOpenDirectiveAttributeBlock","directiveMatch","attributesBeforeCursor","iconPaletteMatch","options","length","valueMatch","typedValue","attributeMatch","typedAttribute","explicit","lineNumber","number","previousLine","trimmed","trim","includes","directiveCompletionSource","attributeResult","matchBefore","beforeLeaf","typedLeaf","to","filter","option","createDirectiveCompletions","activateOnTyping","override","directiveCompletions"],"mappings":"AAEA,SAASA,cAAc,EAAEC,iBAAiB,QAAQ,2BAA0B;AAI5E,SAASC,uBAAuB,QAAQ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BH,6BAA4B"}
@@ -1,7 +1,7 @@
1
1
  import type { MarkdownEditorDirectiveConfig } from '../directiveConfig.js';
2
2
  /**
3
- * Directive lint source that knows the field's configured themes and icon
4
- * packs (CORE-8), so custom themes are not reported as unknown.
3
+ * Directive lint source that knows the field's configured themes, icon packs
4
+ * and palettes (CORE-8), so custom ones are not reported as unknown.
5
5
  */
6
6
  export declare const createDirectiveDiagnostics: (config?: MarkdownEditorDirectiveConfig) => import("@codemirror/state").Extension;
7
7
  export declare const directiveDiagnostics: import("@codemirror/state").Extension;
@@ -1,11 +1,18 @@
1
1
  import { linter } from '@codemirror/lint';
2
2
  import { lintMarkdownDirectives } from '../../directives/diagnostics.js';
3
+ import { getEditorPaletteNames } from '../directiveConfig.js';
3
4
  /**
4
- * Directive lint source that knows the field's configured themes and icon
5
- * packs (CORE-8), so custom themes are not reported as unknown.
5
+ * Directive lint source that knows the field's configured themes, icon packs
6
+ * and palettes (CORE-8), so custom ones are not reported as unknown.
6
7
  */ export const createDirectiveDiagnostics = (config = {})=>linter((view)=>{
7
8
  try {
8
- return lintMarkdownDirectives(view.state.doc.toString(), config).map((diagnostic)=>({
9
+ // Palettes managed in the admin load after the editor mounts; until then
10
+ // no palette is reported as unknown.
11
+ const options = {
12
+ ...config,
13
+ palettes: getEditorPaletteNames(config)
14
+ };
15
+ return lintMarkdownDirectives(view.state.doc.toString(), options).map((diagnostic)=>({
9
16
  from: diagnostic.from,
10
17
  message: diagnostic.message,
11
18
  severity: diagnostic.severity,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/directives/diagnostics.ts"],"sourcesContent":["import type { Diagnostic } from '@codemirror/lint'\n\nimport { linter } from '@codemirror/lint'\n\nimport type { MarkdownEditorDirectiveConfig } from '../directiveConfig.js'\n\nimport { lintMarkdownDirectives } from '../../directives/diagnostics.js'\n\n/**\n * Directive lint source that knows the field's configured themes and icon\n * packs (CORE-8), so custom themes are not reported as unknown.\n */\nexport const createDirectiveDiagnostics = (config: MarkdownEditorDirectiveConfig = {}) =>\n linter((view): Diagnostic[] => {\n try {\n return lintMarkdownDirectives(view.state.doc.toString(), config).map((diagnostic) => ({\n from: diagnostic.from,\n message: diagnostic.message,\n severity: diagnostic.severity,\n to: diagnostic.to,\n }))\n } catch (error) {\n // A linter bug must never take the editor down or hide unrelated\n // diagnostics permanently; report it once at the top of the document.\n return [\n {\n from: 0,\n message: `Directive diagnostics failed: ${error instanceof Error ? error.message : String(error)}`,\n severity: 'info',\n to: 0,\n },\n ]\n }\n})\n\nexport const directiveDiagnostics = createDirectiveDiagnostics()\n"],"names":["linter","lintMarkdownDirectives","createDirectiveDiagnostics","config","view","state","doc","toString","map","diagnostic","from","message","severity","to","error","Error","String","directiveDiagnostics"],"mappings":"AAEA,SAASA,MAAM,QAAQ,mBAAkB;AAIzC,SAASC,sBAAsB,QAAQ,kCAAiC;AAExE;;;CAGC,GACD,OAAO,MAAMC,6BAA6B,CAACC,SAAwC,CAAC,CAAC,GACnFH,OAAO,CAACI;QACR,IAAI;YACF,OAAOH,uBAAuBG,KAAKC,KAAK,CAACC,GAAG,CAACC,QAAQ,IAAIJ,QAAQK,GAAG,CAAC,CAACC,aAAgB,CAAA;oBACpFC,MAAMD,WAAWC,IAAI;oBACrBC,SAASF,WAAWE,OAAO;oBAC3BC,UAAUH,WAAWG,QAAQ;oBAC7BC,IAAIJ,WAAWI,EAAE;gBACnB,CAAA;QACF,EAAE,OAAOC,OAAO;YACd,iEAAiE;YACjE,sEAAsE;YACtE,OAAO;gBACL;oBACEJ,MAAM;oBACNC,SAAS,CAAC,8BAA8B,EAAEG,iBAAiBC,QAAQD,MAAMH,OAAO,GAAGK,OAAOF,QAAQ;oBAClGF,UAAU;oBACVC,IAAI;gBACN;aACD;QACH;IACF,GAAE;AAEF,OAAO,MAAMI,uBAAuBf,6BAA4B"}
1
+ {"version":3,"sources":["../../../src/editor/directives/diagnostics.ts"],"sourcesContent":["import type { Diagnostic } from '@codemirror/lint'\n\nimport { linter } from '@codemirror/lint'\n\nimport type { MarkdownEditorDirectiveConfig } from '../directiveConfig.js'\n\nimport { lintMarkdownDirectives } from '../../directives/diagnostics.js'\nimport { getEditorPaletteNames } from '../directiveConfig.js'\n\n/**\n * Directive lint source that knows the field's configured themes, icon packs\n * and palettes (CORE-8), so custom ones are not reported as unknown.\n */\nexport const createDirectiveDiagnostics = (config: MarkdownEditorDirectiveConfig = {}) =>\n linter((view): Diagnostic[] => {\n try {\n // Palettes managed in the admin load after the editor mounts; until then\n // no palette is reported as unknown.\n const options = { ...config, palettes: getEditorPaletteNames(config) }\n\n return lintMarkdownDirectives(view.state.doc.toString(), options).map((diagnostic) => ({\n from: diagnostic.from,\n message: diagnostic.message,\n severity: diagnostic.severity,\n to: diagnostic.to,\n }))\n } catch (error) {\n // A linter bug must never take the editor down or hide unrelated\n // diagnostics permanently; report it once at the top of the document.\n return [\n {\n from: 0,\n message: `Directive diagnostics failed: ${error instanceof Error ? error.message : String(error)}`,\n severity: 'info',\n to: 0,\n },\n ]\n }\n})\n\nexport const directiveDiagnostics = createDirectiveDiagnostics()\n"],"names":["linter","lintMarkdownDirectives","getEditorPaletteNames","createDirectiveDiagnostics","config","view","options","palettes","state","doc","toString","map","diagnostic","from","message","severity","to","error","Error","String","directiveDiagnostics"],"mappings":"AAEA,SAASA,MAAM,QAAQ,mBAAkB;AAIzC,SAASC,sBAAsB,QAAQ,kCAAiC;AACxE,SAASC,qBAAqB,QAAQ,wBAAuB;AAE7D;;;CAGC,GACD,OAAO,MAAMC,6BAA6B,CAACC,SAAwC,CAAC,CAAC,GACnFJ,OAAO,CAACK;QACR,IAAI;YACF,yEAAyE;YACzE,qCAAqC;YACrC,MAAMC,UAAU;gBAAE,GAAGF,MAAM;gBAAEG,UAAUL,sBAAsBE;YAAQ;YAErE,OAAOH,uBAAuBI,KAAKG,KAAK,CAACC,GAAG,CAACC,QAAQ,IAAIJ,SAASK,GAAG,CAAC,CAACC,aAAgB,CAAA;oBACrFC,MAAMD,WAAWC,IAAI;oBACrBC,SAASF,WAAWE,OAAO;oBAC3BC,UAAUH,WAAWG,QAAQ;oBAC7BC,IAAIJ,WAAWI,EAAE;gBACnB,CAAA;QACF,EAAE,OAAOC,OAAO;YACd,iEAAiE;YACjE,sEAAsE;YACtE,OAAO;gBACL;oBACEJ,MAAM;oBACNC,SAAS,CAAC,8BAA8B,EAAEG,iBAAiBC,QAAQD,MAAMH,OAAO,GAAGK,OAAOF,QAAQ;oBAClGF,UAAU;oBACVC,IAAI;gBACN;aACD;QACH;IACF,GAAE;AAEF,OAAO,MAAMI,uBAAuBjB,6BAA4B"}
@@ -260,6 +260,7 @@ function isDirectiveLine(line) {
260
260
  }
261
261
  // Leaf directive names come from the directive registry (button, badge).
262
262
  const LEAF_DIRECTIVE_LINE_PATTERN = new RegExp(`^::(?:${layoutDirectiveRegistry.leafDirectiveNames.join('|')})(?:$|[\\s[{])`);
263
+ const LEAF_DIRECTIVE_NAME_PATTERN = new RegExp(`^::(?:${layoutDirectiveRegistry.leafDirectiveNames.join('|')})(?=$|[\\s[{])`);
263
264
  function isLeafDirectiveLine(line) {
264
265
  return LEAF_DIRECTIVE_LINE_PATTERN.test(line.text.slice(line.pos));
265
266
  }
@@ -343,7 +344,7 @@ function parseDirectiveLineElements(cx, line, leaf) {
343
344
  const text = line.text;
344
345
  const start = line.pos;
345
346
  const lineStart = cxLineStart(cx);
346
- const directiveMatch = text.slice(start).match(leaf ? /^::(?:button|badge)(?=$|[\s[{])/ : /^:::[\w-]*/);
347
+ const directiveMatch = text.slice(start).match(leaf ? LEAF_DIRECTIVE_NAME_PATTERN : /^:::[\w-]*/);
347
348
  const directiveText = directiveMatch?.[0]?.trimEnd();
348
349
  if (!directiveText) return [];
349
350
  const nameTo = start + directiveText.length;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/editor/themes/payload.ts"],"sourcesContent":["import type { Extension } from '@codemirror/state'\n\nimport { markdown } from '@codemirror/lang-markdown'\nimport { HighlightStyle, syntaxHighlighting } from '@codemirror/language'\nimport { EditorView } from '@codemirror/view'\nimport { tags as t, Tag } from '@lezer/highlight'\n\nimport { hasUnclosedDirectiveAttributeBlock } from '../../directives/attributes.js'\nimport { layoutDirectiveRegistry } from '../../directives/registry.js'\nimport { supportedLangHighlight } from './support/highlighters.js'\nimport { languages } from './support/lang.js'\n\nconst activeLine = '#6699ff0b',\n bracketMatch = '#bad0f847',\n chalky = '#e5c07b',\n coral = '#e06c75',\n cursor = '#a5edff',\n cyan = '#56b6c2',\n highlightBackground = '#2c313a',\n invalid = '#ff6b81',\n ivory = '#c4c9d5',\n malibu = '#61afef',\n sage = '#98c379',\n searchMatch = '#72a1ff59',\n searchMatchOutline = '#457dff',\n selection = '#ffffff',\n selectionBackground = '#3E4451',\n selectionMatch = '#aafe661a',\n stone = '#7d8799',\n tooltipBackground = '#353a42',\n violet = '#e47cd2',\n whiskey = '#d19a66'\n\nexport const color = {\n activeLine,\n bracketMatch,\n chalky,\n coral,\n cursor,\n cyan,\n highlightBackground,\n invalid,\n ivory,\n malibu,\n sage,\n searchMatch,\n searchMatchOutline,\n selection,\n selectionBackground,\n selectionMatch,\n stone,\n tooltipBackground,\n violet,\n whiskey,\n}\n\nexport const payloadTheme = EditorView.theme(\n {\n '&': {\n backgroundColor: 'transparent',\n color: ivory,\n fontSize: '1.05rem',\n },\n\n '.cm-content': {\n caretColor: cursor,\n padding: '0.75rem',\n },\n\n '.cm-scroller': {\n fontFamily: 'monospace',\n },\n\n '.cm-cursor, .cm-dropCursor': {\n borderLeftColor: cursor,\n },\n\n '.cm-selectionBackground': {\n backgroundColor: selectionBackground,\n },\n\n '.cm-content ::selection': {\n backgroundColor: selectionBackground,\n color: selection,\n },\n\n '.cm-selectionBackground, .cm-content ::selection': {\n color: selection,\n },\n\n '.cm-activeLine': {\n backgroundColor: activeLine,\n },\n\n '.cm-selectionMatch': {\n backgroundColor: selectionMatch,\n },\n\n '&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket': {\n backgroundColor: bracketMatch,\n },\n\n '.cm-gutters': {\n backgroundColor: 'transparent',\n border: 'none',\n color: stone,\n },\n\n '.cm-activeLineGutter': {\n backgroundColor: highlightBackground,\n },\n\n '.cm-searchMatch': {\n backgroundColor: searchMatch,\n outline: `1px solid ${searchMatchOutline}`,\n },\n\n '.cm-searchMatch.cm-searchMatch-selected': {\n backgroundColor: '#6199ff2f',\n },\n\n '.cm-foldPlaceholder': {\n backgroundColor: 'transparent',\n border: 'none',\n color: ivory,\n },\n\n '.cm-tooltip': {\n backgroundColor: tooltipBackground,\n border: 'none',\n color: ivory,\n },\n\n '.cm-tooltip .cm-tooltip-arrow:before': {\n borderBottomColor: 'transparent',\n borderTopColor: 'transparent',\n },\n\n '.cm-tooltip .cm-tooltip-arrow:after': {\n borderBottomColor: tooltipBackground,\n borderTopColor: tooltipBackground,\n },\n\n '.cm-tooltip-autocomplete': {\n '& > ul > li[aria-selected]': {\n backgroundColor: highlightBackground,\n color: ivory,\n },\n },\n },\n { dark: true },\n)\n\n// Keep custom directive highlighting compatible with keyword semantics\nconst mdQualifierTag = Tag.define(t.keyword)\nconst mdLeafDirectiveTag = Tag.define(t.keyword)\nconst mdDirectiveArgNameTag = Tag.define(t.propertyName)\nconst mdDirectiveArgValueTag = Tag.define(t.string)\nconst mdDirectiveBraceTag = Tag.define(t.separator)\nconst mdDirectiveLabelTag = Tag.define(t.labelName)\n\nexport const payloadHighlightStyle = HighlightStyle.define([\n // Directives + language keywords\n { color: violet, tag: [mdQualifierTag, t.keyword] },\n { color: '#d7a7df', tag: mdLeafDirectiveTag },\n { color: coral, tag: mdDirectiveArgNameTag },\n { color: sage, tag: mdDirectiveArgValueTag },\n { color: stone, tag: mdDirectiveBraceTag },\n { color: malibu, tag: mdDirectiveLabelTag },\n\n // Names / identifiers that should read warm\n { color: coral, tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName] },\n\n // Functions and labels should pop cooler like JetBrains method names\n { color: malibu, tag: [t.function(t.variableName), t.function(t.propertyName), t.labelName] },\n\n // Constants / enum-like / builtins\n {\n color: whiskey,\n tag: [\n t.color,\n t.constant(t.name),\n t.standard(t.name),\n t.atom,\n t.bool,\n t.special(t.variableName),\n ],\n },\n\n // Definitions and separators\n { color: ivory, tag: [t.definition(t.name), t.separator] },\n\n // Types / classes / annotations / namespaces / numerics\n {\n color: chalky,\n tag: [\n t.typeName,\n t.className,\n t.number,\n t.changed,\n t.annotation,\n t.modifier,\n t.self,\n t.namespace,\n ],\n },\n\n // Operators / escapes / urls / regex / special strings\n {\n color: cyan,\n tag: [t.operator, t.operatorKeyword, t.url, t.escape, t.regexp, t.link, t.special(t.string)],\n },\n\n // Comments + meta\n { color: stone, tag: [t.meta, t.comment] },\n\n // Markdown emphasis\n { fontWeight: 'bold', tag: t.strong },\n { fontStyle: 'italic', tag: t.emphasis },\n { tag: t.strikethrough, textDecoration: 'line-through' },\n { color: stone, tag: t.link, textDecoration: 'underline' },\n { color: coral, fontWeight: 'bold', tag: t.heading },\n\n // Strings / inserted text / processing-ish constructs\n { color: sage, tag: [t.processingInstruction, t.string, t.inserted] },\n\n // Actually-invalid syntax should look wrong\n { color: invalid, tag: t.invalid },\n])\n\ntype MarkdownConfig = Extract<\n NonNullable<NonNullable<Parameters<typeof markdown>[0]>['extensions']>,\n { parseBlock?: unknown }\n>\n\ntype MarkdownLine = {\n pos: number\n text: string\n}\n\n// @lezer/markdown's Element type is not a direct package dependency here.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype MarkdownElement = any\n\ntype DirectiveParseContext = {\n elt: (type: string, from: number, to: number, children?: readonly MarkdownElement[]) => MarkdownElement\n lineStart: number\n}\n\nfunction isDirectiveLine(line: MarkdownLine): boolean {\n return line.text.slice(line.pos).startsWith(':::')\n}\n\n// Leaf directive names come from the directive registry (button, badge).\nconst LEAF_DIRECTIVE_LINE_PATTERN = new RegExp(\n `^::(?:${layoutDirectiveRegistry.leafDirectiveNames.join('|')})(?:$|[\\\\s[{])`,\n)\n\nfunction isLeafDirectiveLine(line: MarkdownLine): boolean {\n return LEAF_DIRECTIVE_LINE_PATTERN.test(line.text.slice(line.pos))\n}\n\nfunction skipInlineSpace(text: string, index: number): number {\n let next = index\n\n while (next < text.length && /\\s/.test(text[next])) ++next\n\n return next\n}\n\nfunction parseQuotedValue(\n cx: DirectiveParseContext,\n text: string,\n lineStart: number,\n index: number,\n): { elements: MarkdownElement[]; index: number } {\n const quote = text[index]\n let end = index + 1\n\n while (end < text.length) {\n if (text[end] === '\\\\') {\n end += 2\n continue\n }\n\n if (text[end] === quote) {\n end += 1\n break\n }\n\n ++end\n }\n\n return {\n elements: [cx.elt('DirectiveAttributeValue', lineStart + index, lineStart + end)],\n index: end,\n }\n}\n\nfunction parseBareValue(\n cx: DirectiveParseContext,\n text: string,\n lineStart: number,\n index: number,\n): { elements: MarkdownElement[]; index: number } {\n let end = index\n\n while (end < text.length && !/[\\s}]/.test(text[end])) ++end\n\n return end > index\n ? {\n elements: [cx.elt('DirectiveAttributeValue', lineStart + index, lineStart + end)],\n index: end,\n }\n : {\n elements: [],\n index,\n }\n}\n\nfunction parseAttributeElements(\n cx: DirectiveParseContext,\n text: string,\n lineStart: number,\n startIndex: number,\n): MarkdownElement[] {\n const elements: MarkdownElement[] = []\n let index = startIndex\n\n while (index < text.length) {\n const char = text[index]\n\n if (char === '{' || char === '}') {\n elements.push(cx.elt('DirectiveBrace', lineStart + index, lineStart + index + 1))\n ++index\n continue\n }\n\n if (/\\s/.test(char)) {\n ++index\n continue\n }\n\n if (/[\\w-]/.test(char)) {\n const nameStart = index\n\n while (index < text.length && /[\\w-]/.test(text[index])) ++index\n\n const nameEnd = index\n const equalsIndex = skipInlineSpace(text, index)\n\n if (text[equalsIndex] !== '=') continue\n\n elements.push(cx.elt('DirectiveAttributeName', lineStart + nameStart, lineStart + nameEnd))\n index = skipInlineSpace(text, equalsIndex + 1)\n\n if (text[index] === '\"' || text[index] === \"'\") {\n const parsed = parseQuotedValue(cx, text, lineStart, index)\n elements.push(...parsed.elements)\n index = parsed.index\n continue\n }\n\n const parsed = parseBareValue(cx, text, lineStart, index)\n elements.push(...parsed.elements)\n index = parsed.index\n continue\n }\n\n ++index\n }\n\n return elements\n}\n\nfunction parseDirectiveLineElements(\n cx: DirectiveParseContext,\n line: MarkdownLine,\n leaf: boolean,\n): MarkdownElement[] {\n const text = line.text\n const start = line.pos\n const lineStart = cxLineStart(cx)\n const directiveMatch = text\n .slice(start)\n .match(leaf ? /^::(?:button|badge)(?=$|[\\s[{])/ : /^:::[\\w-]*/)\n const directiveText = directiveMatch?.[0]?.trimEnd()\n\n if (!directiveText) return []\n\n const nameTo = start + directiveText.length\n const elements = [\n cx.elt(\n leaf ? 'LeafDirectiveName' : 'DirectiveName',\n lineStart + start,\n lineStart + nameTo,\n ),\n ]\n let cursor = skipInlineSpace(text, nameTo)\n\n if (text[cursor] === '[') {\n const labelEnd = text.indexOf(']', cursor + 1)\n\n if (labelEnd >= 0) {\n elements.push(cx.elt('DirectiveLabel', lineStart + cursor, lineStart + labelEnd + 1))\n cursor = skipInlineSpace(text, labelEnd + 1)\n }\n }\n\n const braceIndex = text.indexOf('{', cursor)\n if (braceIndex >= 0) elements.push(...parseAttributeElements(cx, text, lineStart, braceIndex))\n\n return elements\n}\n\nfunction parseDirectiveAttributeContinuationElements(\n cx: DirectiveParseContext,\n line: MarkdownLine,\n): MarkdownElement[] {\n return parseAttributeElements(cx, line.text, cxLineStart(cx), line.pos)\n}\n\nfunction cxLineStart(cx: { lineStart: number }): number {\n return cx.lineStart\n}\n\nfunction addDirectiveBlock(\n cx: {\n addElement: (element: MarkdownElement) => void\n elt: (type: string, from: number, to: number, children?: readonly MarkdownElement[]) => MarkdownElement\n lineStart: number\n nextLine: () => boolean\n peekLine: () => string\n },\n line: MarkdownLine,\n blockName: 'DirectiveLine' | 'LeafDirectiveLine',\n leaf: boolean,\n) {\n const from = cx.lineStart + line.pos\n const children = parseDirectiveLineElements(cx, line, leaf)\n let collectedText = line.text.slice(line.pos)\n let to = cx.lineStart + line.text.length\n\n while (hasUnclosedDirectiveAttributeBlock(collectedText)) {\n if (cx.peekLine().trim().startsWith('::')) break\n if (!cx.nextLine()) break\n\n collectedText += `\\n${line.text}`\n to = cx.lineStart + line.text.length\n children.push(...parseDirectiveAttributeContinuationElements(cx, line))\n }\n\n cx.addElement(cx.elt(blockName, from, to, children))\n cx.nextLine()\n}\n\nconst directiveBlock = {\n defineNodes: [\n {\n name: 'DirectiveLine',\n block: true,\n },\n {\n name: 'LeafDirectiveLine',\n block: true,\n },\n {\n name: 'DirectiveName',\n style: mdQualifierTag,\n },\n {\n name: 'LeafDirectiveName',\n style: mdLeafDirectiveTag,\n },\n {\n name: 'DirectiveLabel',\n style: mdDirectiveLabelTag,\n },\n {\n name: 'DirectiveAttributeName',\n style: mdDirectiveArgNameTag,\n },\n {\n name: 'DirectiveAttributeValue',\n style: mdDirectiveArgValueTag,\n },\n {\n name: 'DirectiveBrace',\n style: mdDirectiveBraceTag,\n },\n ],\n\n parseBlock: [\n {\n name: 'LeafDirectiveLine',\n before: 'HTMLBlock',\n endLeaf(_cx, line) {\n return isLeafDirectiveLine(line)\n },\n parse(cx, line) {\n if (!isLeafDirectiveLine(line)) return false\n\n addDirectiveBlock(cx, line, 'LeafDirectiveLine', true)\n\n return true\n },\n },\n {\n name: 'DirectiveLine',\n before: 'HTMLBlock',\n endLeaf(_cx, line) {\n return isDirectiveLine(line)\n },\n parse(cx, line) {\n if (!isDirectiveLine(line)) return false\n\n addDirectiveBlock(cx, line, 'DirectiveLine', false)\n\n return true\n },\n },\n ],\n} satisfies MarkdownConfig\n\nexport const payloadMarkdownTheme: Extension = [\n payloadTheme,\n syntaxHighlighting(payloadHighlightStyle),\n ...supportedLangHighlight,\n markdown({\n codeLanguages: languages,\n extensions: [directiveBlock],\n }),\n]\n"],"names":["markdown","HighlightStyle","syntaxHighlighting","EditorView","tags","t","Tag","hasUnclosedDirectiveAttributeBlock","layoutDirectiveRegistry","supportedLangHighlight","languages","activeLine","bracketMatch","chalky","coral","cursor","cyan","highlightBackground","invalid","ivory","malibu","sage","searchMatch","searchMatchOutline","selection","selectionBackground","selectionMatch","stone","tooltipBackground","violet","whiskey","color","payloadTheme","theme","backgroundColor","fontSize","caretColor","padding","fontFamily","borderLeftColor","border","outline","borderBottomColor","borderTopColor","dark","mdQualifierTag","define","keyword","mdLeafDirectiveTag","mdDirectiveArgNameTag","propertyName","mdDirectiveArgValueTag","string","mdDirectiveBraceTag","separator","mdDirectiveLabelTag","labelName","payloadHighlightStyle","tag","name","deleted","character","macroName","function","variableName","constant","standard","atom","bool","special","definition","typeName","className","number","changed","annotation","modifier","self","namespace","operator","operatorKeyword","url","escape","regexp","link","meta","comment","fontWeight","strong","fontStyle","emphasis","strikethrough","textDecoration","heading","processingInstruction","inserted","isDirectiveLine","line","text","slice","pos","startsWith","LEAF_DIRECTIVE_LINE_PATTERN","RegExp","leafDirectiveNames","join","isLeafDirectiveLine","test","skipInlineSpace","index","next","length","parseQuotedValue","cx","lineStart","quote","end","elements","elt","parseBareValue","parseAttributeElements","startIndex","char","push","nameStart","nameEnd","equalsIndex","parsed","parseDirectiveLineElements","leaf","start","cxLineStart","directiveMatch","match","directiveText","trimEnd","nameTo","labelEnd","indexOf","braceIndex","parseDirectiveAttributeContinuationElements","addDirectiveBlock","blockName","from","children","collectedText","to","peekLine","trim","nextLine","addElement","directiveBlock","defineNodes","block","style","parseBlock","before","endLeaf","_cx","parse","payloadMarkdownTheme","codeLanguages","extensions"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,4BAA2B;AACpD,SAASC,cAAc,EAAEC,kBAAkB,QAAQ,uBAAsB;AACzE,SAASC,UAAU,QAAQ,mBAAkB;AAC7C,SAASC,QAAQC,CAAC,EAAEC,GAAG,QAAQ,mBAAkB;AAEjD,SAASC,kCAAkC,QAAQ,iCAAgC;AACnF,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,sBAAsB,QAAQ,4BAA2B;AAClE,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+F,OAAO7G;QACT;QACA;YACEc,MAAM;YACN+F,OAAO1G;QACT;QACA;YACEW,MAAM;YACN+F,OAAOnG;QACT;QACA;YACEI,MAAM;YACN+F,OAAOzG;QACT;QACA;YACEU,MAAM;YACN+F,OAAOvG;QACT;QACA;YACEQ,MAAM;YACN+F,OAAOrG;QACT;KACD;IAEDsG,YAAY;QACV;YACEhG,MAAM;YACNiG,QAAQ;YACRC,SAAQC,GAAG,EAAE7D,IAAI;gBACf,OAAOS,oBAAoBT;YAC7B;YACA8D,OAAM9C,EAAE,EAAEhB,IAAI;gBACZ,IAAI,CAACS,oBAAoBT,OAAO,OAAO;gBAEvC4C,kBAAkB5B,IAAIhB,MAAM,qBAAqB;gBAEjD,OAAO;YACT;QACF;QACA;YACEtC,MAAM;YACNiG,QAAQ;YACRC,SAAQC,GAAG,EAAE7D,IAAI;gBACf,OAAOD,gBAAgBC;YACzB;YACA8D,OAAM9C,EAAE,EAAEhB,IAAI;gBACZ,IAAI,CAACD,gBAAgBC,OAAO,OAAO;gBAEnC4C,kBAAkB5B,IAAIhB,MAAM,iBAAiB;gBAE7C,OAAO;YACT;QACF;KACD;AACH;AAEA,OAAO,MAAM+D,uBAAkC;IAC7ChI;IACA9B,mBAAmBuD;OAChBhD;IACHT,SAAS;QACPiK,eAAevJ;QACfwJ,YAAY;YAACX;SAAe;IAC9B;CACD,CAAA"}
1
+ {"version":3,"sources":["../../../src/editor/themes/payload.ts"],"sourcesContent":["import type { Extension } from '@codemirror/state'\n\nimport { markdown } from '@codemirror/lang-markdown'\nimport { HighlightStyle, syntaxHighlighting } from '@codemirror/language'\nimport { EditorView } from '@codemirror/view'\nimport { tags as t, Tag } from '@lezer/highlight'\n\nimport { hasUnclosedDirectiveAttributeBlock } from '../../directives/attributes.js'\nimport { layoutDirectiveRegistry } from '../../directives/registry.js'\nimport { supportedLangHighlight } from './support/highlighters.js'\nimport { languages } from './support/lang.js'\n\nconst activeLine = '#6699ff0b',\n bracketMatch = '#bad0f847',\n chalky = '#e5c07b',\n coral = '#e06c75',\n cursor = '#a5edff',\n cyan = '#56b6c2',\n highlightBackground = '#2c313a',\n invalid = '#ff6b81',\n ivory = '#c4c9d5',\n malibu = '#61afef',\n sage = '#98c379',\n searchMatch = '#72a1ff59',\n searchMatchOutline = '#457dff',\n selection = '#ffffff',\n selectionBackground = '#3E4451',\n selectionMatch = '#aafe661a',\n stone = '#7d8799',\n tooltipBackground = '#353a42',\n violet = '#e47cd2',\n whiskey = '#d19a66'\n\nexport const color = {\n activeLine,\n bracketMatch,\n chalky,\n coral,\n cursor,\n cyan,\n highlightBackground,\n invalid,\n ivory,\n malibu,\n sage,\n searchMatch,\n searchMatchOutline,\n selection,\n selectionBackground,\n selectionMatch,\n stone,\n tooltipBackground,\n violet,\n whiskey,\n}\n\nexport const payloadTheme = EditorView.theme(\n {\n '&': {\n backgroundColor: 'transparent',\n color: ivory,\n fontSize: '1.05rem',\n },\n\n '.cm-content': {\n caretColor: cursor,\n padding: '0.75rem',\n },\n\n '.cm-scroller': {\n fontFamily: 'monospace',\n },\n\n '.cm-cursor, .cm-dropCursor': {\n borderLeftColor: cursor,\n },\n\n '.cm-selectionBackground': {\n backgroundColor: selectionBackground,\n },\n\n '.cm-content ::selection': {\n backgroundColor: selectionBackground,\n color: selection,\n },\n\n '.cm-selectionBackground, .cm-content ::selection': {\n color: selection,\n },\n\n '.cm-activeLine': {\n backgroundColor: activeLine,\n },\n\n '.cm-selectionMatch': {\n backgroundColor: selectionMatch,\n },\n\n '&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket': {\n backgroundColor: bracketMatch,\n },\n\n '.cm-gutters': {\n backgroundColor: 'transparent',\n border: 'none',\n color: stone,\n },\n\n '.cm-activeLineGutter': {\n backgroundColor: highlightBackground,\n },\n\n '.cm-searchMatch': {\n backgroundColor: searchMatch,\n outline: `1px solid ${searchMatchOutline}`,\n },\n\n '.cm-searchMatch.cm-searchMatch-selected': {\n backgroundColor: '#6199ff2f',\n },\n\n '.cm-foldPlaceholder': {\n backgroundColor: 'transparent',\n border: 'none',\n color: ivory,\n },\n\n '.cm-tooltip': {\n backgroundColor: tooltipBackground,\n border: 'none',\n color: ivory,\n },\n\n '.cm-tooltip .cm-tooltip-arrow:before': {\n borderBottomColor: 'transparent',\n borderTopColor: 'transparent',\n },\n\n '.cm-tooltip .cm-tooltip-arrow:after': {\n borderBottomColor: tooltipBackground,\n borderTopColor: tooltipBackground,\n },\n\n '.cm-tooltip-autocomplete': {\n '& > ul > li[aria-selected]': {\n backgroundColor: highlightBackground,\n color: ivory,\n },\n },\n },\n { dark: true },\n)\n\n// Keep custom directive highlighting compatible with keyword semantics\nconst mdQualifierTag = Tag.define(t.keyword)\nconst mdLeafDirectiveTag = Tag.define(t.keyword)\nconst mdDirectiveArgNameTag = Tag.define(t.propertyName)\nconst mdDirectiveArgValueTag = Tag.define(t.string)\nconst mdDirectiveBraceTag = Tag.define(t.separator)\nconst mdDirectiveLabelTag = Tag.define(t.labelName)\n\nexport const payloadHighlightStyle = HighlightStyle.define([\n // Directives + language keywords\n { color: violet, tag: [mdQualifierTag, t.keyword] },\n { color: '#d7a7df', tag: mdLeafDirectiveTag },\n { color: coral, tag: mdDirectiveArgNameTag },\n { color: sage, tag: mdDirectiveArgValueTag },\n { color: stone, tag: mdDirectiveBraceTag },\n { color: malibu, tag: mdDirectiveLabelTag },\n\n // Names / identifiers that should read warm\n { color: coral, tag: [t.name, t.deleted, t.character, t.propertyName, t.macroName] },\n\n // Functions and labels should pop cooler like JetBrains method names\n { color: malibu, tag: [t.function(t.variableName), t.function(t.propertyName), t.labelName] },\n\n // Constants / enum-like / builtins\n {\n color: whiskey,\n tag: [\n t.color,\n t.constant(t.name),\n t.standard(t.name),\n t.atom,\n t.bool,\n t.special(t.variableName),\n ],\n },\n\n // Definitions and separators\n { color: ivory, tag: [t.definition(t.name), t.separator] },\n\n // Types / classes / annotations / namespaces / numerics\n {\n color: chalky,\n tag: [\n t.typeName,\n t.className,\n t.number,\n t.changed,\n t.annotation,\n t.modifier,\n t.self,\n t.namespace,\n ],\n },\n\n // Operators / escapes / urls / regex / special strings\n {\n color: cyan,\n tag: [t.operator, t.operatorKeyword, t.url, t.escape, t.regexp, t.link, t.special(t.string)],\n },\n\n // Comments + meta\n { color: stone, tag: [t.meta, t.comment] },\n\n // Markdown emphasis\n { fontWeight: 'bold', tag: t.strong },\n { fontStyle: 'italic', tag: t.emphasis },\n { tag: t.strikethrough, textDecoration: 'line-through' },\n { color: stone, tag: t.link, textDecoration: 'underline' },\n { color: coral, fontWeight: 'bold', tag: t.heading },\n\n // Strings / inserted text / processing-ish constructs\n { color: sage, tag: [t.processingInstruction, t.string, t.inserted] },\n\n // Actually-invalid syntax should look wrong\n { color: invalid, tag: t.invalid },\n])\n\ntype MarkdownConfig = Extract<\n NonNullable<NonNullable<Parameters<typeof markdown>[0]>['extensions']>,\n { parseBlock?: unknown }\n>\n\ntype MarkdownLine = {\n pos: number\n text: string\n}\n\n// @lezer/markdown's Element type is not a direct package dependency here.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype MarkdownElement = any\n\ntype DirectiveParseContext = {\n elt: (type: string, from: number, to: number, children?: readonly MarkdownElement[]) => MarkdownElement\n lineStart: number\n}\n\nfunction isDirectiveLine(line: MarkdownLine): boolean {\n return line.text.slice(line.pos).startsWith(':::')\n}\n\n// Leaf directive names come from the directive registry (button, badge).\nconst LEAF_DIRECTIVE_LINE_PATTERN = new RegExp(\n `^::(?:${layoutDirectiveRegistry.leafDirectiveNames.join('|')})(?:$|[\\\\s[{])`,\n)\n\nconst LEAF_DIRECTIVE_NAME_PATTERN = new RegExp(\n `^::(?:${layoutDirectiveRegistry.leafDirectiveNames.join('|')})(?=$|[\\\\s[{])`,\n)\n\nfunction isLeafDirectiveLine(line: MarkdownLine): boolean {\n return LEAF_DIRECTIVE_LINE_PATTERN.test(line.text.slice(line.pos))\n}\n\nfunction skipInlineSpace(text: string, index: number): number {\n let next = index\n\n while (next < text.length && /\\s/.test(text[next])) ++next\n\n return next\n}\n\nfunction parseQuotedValue(\n cx: DirectiveParseContext,\n text: string,\n lineStart: number,\n index: number,\n): { elements: MarkdownElement[]; index: number } {\n const quote = text[index]\n let end = index + 1\n\n while (end < text.length) {\n if (text[end] === '\\\\') {\n end += 2\n continue\n }\n\n if (text[end] === quote) {\n end += 1\n break\n }\n\n ++end\n }\n\n return {\n elements: [cx.elt('DirectiveAttributeValue', lineStart + index, lineStart + end)],\n index: end,\n }\n}\n\nfunction parseBareValue(\n cx: DirectiveParseContext,\n text: string,\n lineStart: number,\n index: number,\n): { elements: MarkdownElement[]; index: number } {\n let end = index\n\n while (end < text.length && !/[\\s}]/.test(text[end])) ++end\n\n return end > index\n ? {\n elements: [cx.elt('DirectiveAttributeValue', lineStart + index, lineStart + end)],\n index: end,\n }\n : {\n elements: [],\n index,\n }\n}\n\nfunction parseAttributeElements(\n cx: DirectiveParseContext,\n text: string,\n lineStart: number,\n startIndex: number,\n): MarkdownElement[] {\n const elements: MarkdownElement[] = []\n let index = startIndex\n\n while (index < text.length) {\n const char = text[index]\n\n if (char === '{' || char === '}') {\n elements.push(cx.elt('DirectiveBrace', lineStart + index, lineStart + index + 1))\n ++index\n continue\n }\n\n if (/\\s/.test(char)) {\n ++index\n continue\n }\n\n if (/[\\w-]/.test(char)) {\n const nameStart = index\n\n while (index < text.length && /[\\w-]/.test(text[index])) ++index\n\n const nameEnd = index\n const equalsIndex = skipInlineSpace(text, index)\n\n if (text[equalsIndex] !== '=') continue\n\n elements.push(cx.elt('DirectiveAttributeName', lineStart + nameStart, lineStart + nameEnd))\n index = skipInlineSpace(text, equalsIndex + 1)\n\n if (text[index] === '\"' || text[index] === \"'\") {\n const parsed = parseQuotedValue(cx, text, lineStart, index)\n elements.push(...parsed.elements)\n index = parsed.index\n continue\n }\n\n const parsed = parseBareValue(cx, text, lineStart, index)\n elements.push(...parsed.elements)\n index = parsed.index\n continue\n }\n\n ++index\n }\n\n return elements\n}\n\nfunction parseDirectiveLineElements(\n cx: DirectiveParseContext,\n line: MarkdownLine,\n leaf: boolean,\n): MarkdownElement[] {\n const text = line.text\n const start = line.pos\n const lineStart = cxLineStart(cx)\n const directiveMatch = text\n .slice(start)\n .match(leaf ? LEAF_DIRECTIVE_NAME_PATTERN : /^:::[\\w-]*/)\n const directiveText = directiveMatch?.[0]?.trimEnd()\n\n if (!directiveText) return []\n\n const nameTo = start + directiveText.length\n const elements = [\n cx.elt(\n leaf ? 'LeafDirectiveName' : 'DirectiveName',\n lineStart + start,\n lineStart + nameTo,\n ),\n ]\n let cursor = skipInlineSpace(text, nameTo)\n\n if (text[cursor] === '[') {\n const labelEnd = text.indexOf(']', cursor + 1)\n\n if (labelEnd >= 0) {\n elements.push(cx.elt('DirectiveLabel', lineStart + cursor, lineStart + labelEnd + 1))\n cursor = skipInlineSpace(text, labelEnd + 1)\n }\n }\n\n const braceIndex = text.indexOf('{', cursor)\n if (braceIndex >= 0) elements.push(...parseAttributeElements(cx, text, lineStart, braceIndex))\n\n return elements\n}\n\nfunction parseDirectiveAttributeContinuationElements(\n cx: DirectiveParseContext,\n line: MarkdownLine,\n): MarkdownElement[] {\n return parseAttributeElements(cx, line.text, cxLineStart(cx), line.pos)\n}\n\nfunction cxLineStart(cx: { lineStart: number }): number {\n return cx.lineStart\n}\n\nfunction addDirectiveBlock(\n cx: {\n addElement: (element: MarkdownElement) => void\n elt: (type: string, from: number, to: number, children?: readonly MarkdownElement[]) => MarkdownElement\n lineStart: number\n nextLine: () => boolean\n peekLine: () => string\n },\n line: MarkdownLine,\n blockName: 'DirectiveLine' | 'LeafDirectiveLine',\n leaf: boolean,\n) {\n const from = cx.lineStart + line.pos\n const children = parseDirectiveLineElements(cx, line, leaf)\n let collectedText = line.text.slice(line.pos)\n let to = cx.lineStart + line.text.length\n\n while (hasUnclosedDirectiveAttributeBlock(collectedText)) {\n if (cx.peekLine().trim().startsWith('::')) break\n if (!cx.nextLine()) break\n\n collectedText += `\\n${line.text}`\n to = cx.lineStart + line.text.length\n children.push(...parseDirectiveAttributeContinuationElements(cx, line))\n }\n\n cx.addElement(cx.elt(blockName, from, to, children))\n cx.nextLine()\n}\n\nconst directiveBlock = {\n defineNodes: [\n {\n name: 'DirectiveLine',\n block: true,\n },\n {\n name: 'LeafDirectiveLine',\n block: true,\n },\n {\n name: 'DirectiveName',\n style: mdQualifierTag,\n },\n {\n name: 'LeafDirectiveName',\n style: mdLeafDirectiveTag,\n },\n {\n name: 'DirectiveLabel',\n style: mdDirectiveLabelTag,\n },\n {\n name: 'DirectiveAttributeName',\n style: mdDirectiveArgNameTag,\n },\n {\n name: 'DirectiveAttributeValue',\n style: mdDirectiveArgValueTag,\n },\n {\n name: 'DirectiveBrace',\n style: mdDirectiveBraceTag,\n },\n ],\n\n parseBlock: [\n {\n name: 'LeafDirectiveLine',\n before: 'HTMLBlock',\n endLeaf(_cx, line) {\n return isLeafDirectiveLine(line)\n },\n parse(cx, line) {\n if (!isLeafDirectiveLine(line)) return false\n\n addDirectiveBlock(cx, line, 'LeafDirectiveLine', true)\n\n return true\n },\n },\n {\n name: 'DirectiveLine',\n before: 'HTMLBlock',\n endLeaf(_cx, line) {\n return isDirectiveLine(line)\n },\n parse(cx, line) {\n if (!isDirectiveLine(line)) return false\n\n addDirectiveBlock(cx, line, 'DirectiveLine', false)\n\n return true\n },\n },\n ],\n} satisfies MarkdownConfig\n\nexport const payloadMarkdownTheme: Extension = [\n payloadTheme,\n syntaxHighlighting(payloadHighlightStyle),\n ...supportedLangHighlight,\n markdown({\n codeLanguages: languages,\n extensions: [directiveBlock],\n }),\n]\n"],"names":["markdown","HighlightStyle","syntaxHighlighting","EditorView","tags","t","Tag","hasUnclosedDirectiveAttributeBlock","layoutDirectiveRegistry","supportedLangHighlight","languages","activeLine","bracketMatch","chalky","coral","cursor","cyan","highlightBackground","invalid","ivory","malibu","sage","searchMatch","searchMatchOutline","selection","selectionBackground","selectionMatch","stone","tooltipBackground","violet","whiskey","color","payloadTheme","theme","backgroundColor","fontSize","caretColor","padding","fontFamily","borderLeftColor","border","outline","borderBottomColor","borderTopColor","dark","mdQualifierTag","define","keyword","mdLeafDirectiveTag","mdDirectiveArgNameTag","propertyName","mdDirectiveArgValueTag","string","mdDirectiveBraceTag","separator","mdDirectiveLabelTag","labelName","payloadHighlightStyle","tag","name","deleted","character","macroName","function","variableName","constant","standard","atom","bool","special","definition","typeName","className","number","changed","annotation","modifier","self","namespace","operator","operatorKeyword","url","escape","regexp","link","meta","comment","fontWeight","strong","fontStyle","emphasis","strikethrough","textDecoration","heading","processingInstruction","inserted","isDirectiveLine","line","text","slice","pos","startsWith","LEAF_DIRECTIVE_LINE_PATTERN","RegExp","leafDirectiveNames","join","LEAF_DIRECTIVE_NAME_PATTERN","isLeafDirectiveLine","test","skipInlineSpace","index","next","length","parseQuotedValue","cx","lineStart","quote","end","elements","elt","parseBareValue","parseAttributeElements","startIndex","char","push","nameStart","nameEnd","equalsIndex","parsed","parseDirectiveLineElements","leaf","start","cxLineStart","directiveMatch","match","directiveText","trimEnd","nameTo","labelEnd","indexOf","braceIndex","parseDirectiveAttributeContinuationElements","addDirectiveBlock","blockName","from","children","collectedText","to","peekLine","trim","nextLine","addElement","directiveBlock","defineNodes","block","style","parseBlock","before","endLeaf","_cx","parse","payloadMarkdownTheme","codeLanguages","extensions"],"mappings":"AAEA,SAASA,QAAQ,QAAQ,4BAA2B;AACpD,SAASC,cAAc,EAAEC,kBAAkB,QAAQ,uBAAsB;AACzE,SAASC,UAAU,QAAQ,mBAAkB;AAC7C,SAASC,QAAQC,CAAC,EAAEC,GAAG,QAAQ,mBAAkB;AAEjD,SAASC,kCAAkC,QAAQ,iCAAgC;AACnF,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,sBAAsB,QAAQ,4BAA2B;AAClE,SAASC,SAAS,QAAQ,oBAAmB;AAE7C,MAAMC,aAAa,aACjBC,eAAe,aACfC,SAAS,WACTC,QAAQ,WACRC,SAAS,WACTC,OAAO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E/F,MAAM;YACNgG,OAAO9G;QACT;QACA;YACEc,MAAM;YACNgG,OAAO3G;QACT;QACA;YACEW,MAAM;YACNgG,OAAOpG;QACT;QACA;YACEI,MAAM;YACNgG,OAAO1G;QACT;QACA;YACEU,MAAM;YACNgG,OAAOxG;QACT;QACA;YACEQ,MAAM;YACNgG,OAAOtG;QACT;KACD;IAEDuG,YAAY;QACV;YACEjG,MAAM;YACNkG,QAAQ;YACRC,SAAQC,GAAG,EAAE9D,IAAI;gBACf,OAAOU,oBAAoBV;YAC7B;YACA+D,OAAM9C,EAAE,EAAEjB,IAAI;gBACZ,IAAI,CAACU,oBAAoBV,OAAO,OAAO;gBAEvC6C,kBAAkB5B,IAAIjB,MAAM,qBAAqB;gBAEjD,OAAO;YACT;QACF;QACA;YACEtC,MAAM;YACNkG,QAAQ;YACRC,SAAQC,GAAG,EAAE9D,IAAI;gBACf,OAAOD,gBAAgBC;YACzB;YACA+D,OAAM9C,EAAE,EAAEjB,IAAI;gBACZ,IAAI,CAACD,gBAAgBC,OAAO,OAAO;gBAEnC6C,kBAAkB5B,IAAIjB,MAAM,iBAAiB;gBAE7C,OAAO;YACT;QACF;KACD;AACH;AAEA,OAAO,MAAMgE,uBAAkC;IAC7CjI;IACA9B,mBAAmBuD;OAChBhD;IACHT,SAAS;QACPkK,eAAexJ;QACfyJ,YAAY;YAACX;SAAe;IAC9B;CACD,CAAA"}
@@ -1,4 +1,3 @@
1
- export { MarkdownBlockParamsEnableField } from '../blocks/MarkdownBlock/ParamsEnableField.client.js';
2
1
  /**
3
2
  * `payload-markdown/client` (or the scoped `@valkyrianlabs/...` name): the package's `'use client'`
4
3
  * components, for bundled (Next.js / Payload admin) apps.
@@ -10,10 +9,14 @@ export { MarkdownBlockParamsEnableField } from '../blocks/MarkdownBlock/ParamsEn
10
9
  * - `MarkdownBlockParamsEnableField` is the markdown block's "Enable Blocks
11
10
  * Params" checkbox: it pre-fills the block's params with their effective
12
11
  * values when checked.
12
+ * - `MarkdownPaletteRowLabel` labels palette rows in the "Markdown Appearance"
13
+ * global (`appearance` plugin option) with their name and colour swatches.
13
14
  * - `MarkdownRendererClient` is the interactive island `MarkdownRenderer`
14
15
  * mounts next to its HTML (tabs, code copy). Render it with the id of the
15
16
  * element that contains HTML from `renderMarkdown()` to get the same
16
17
  * behavior without `MarkdownRenderer`.
17
18
  */
19
+ export { MarkdownPaletteRowLabel } from '../appearance/PaletteRowLabel.client.js';
20
+ export { MarkdownBlockParamsEnableField } from '../blocks/MarkdownBlock/ParamsEnableField.client.js';
18
21
  export { MarkdownRendererClient, type MarkdownRendererClientProps, } from '../components/MarkdownRenderer/Component.client.js';
19
22
  export { PayloadMarkdownField } from '../field/MarkdownField/Component.js';
@@ -1,4 +1,3 @@
1
- export { MarkdownBlockParamsEnableField } from '../blocks/MarkdownBlock/ParamsEnableField.client.js';
2
1
  /**
3
2
  * `payload-markdown/client` (or the scoped `@valkyrianlabs/...` name): the package's `'use client'`
4
3
  * components, for bundled (Next.js / Payload admin) apps.
@@ -10,11 +9,15 @@ export { MarkdownBlockParamsEnableField } from '../blocks/MarkdownBlock/ParamsEn
10
9
  * - `MarkdownBlockParamsEnableField` is the markdown block's "Enable Blocks
11
10
  * Params" checkbox: it pre-fills the block's params with their effective
12
11
  * values when checked.
12
+ * - `MarkdownPaletteRowLabel` labels palette rows in the "Markdown Appearance"
13
+ * global (`appearance` plugin option) with their name and colour swatches.
13
14
  * - `MarkdownRendererClient` is the interactive island `MarkdownRenderer`
14
15
  * mounts next to its HTML (tabs, code copy). Render it with the id of the
15
16
  * element that contains HTML from `renderMarkdown()` to get the same
16
17
  * behavior without `MarkdownRenderer`.
17
- */ export { MarkdownRendererClient } from '../components/MarkdownRenderer/Component.client.js';
18
+ */ export { MarkdownPaletteRowLabel } from '../appearance/PaletteRowLabel.client.js';
19
+ export { MarkdownBlockParamsEnableField } from '../blocks/MarkdownBlock/ParamsEnableField.client.js';
20
+ export { MarkdownRendererClient } from '../components/MarkdownRenderer/Component.client.js';
18
21
  export { PayloadMarkdownField } from '../field/MarkdownField/Component.js';
19
22
 
20
23
  //# sourceMappingURL=client.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { MarkdownBlockParamsEnableField } from '../blocks/MarkdownBlock/ParamsEnableField.client.js'\n/**\n * `payload-markdown/client` (or the scoped `@valkyrianlabs/...` name): the package's `'use client'`\n * components, for bundled (Next.js / Payload admin) apps.\n *\n * - `PayloadMarkdownField` is the admin field component. The specifier\n * `<package>/server#PayloadMarkdownField` (used by\n * `markdownField()` and existing import maps) re-exports the same component\n * and keeps working.\n * - `MarkdownBlockParamsEnableField` is the markdown block's \"Enable Blocks\n * Params\" checkbox: it pre-fills the block's params with their effective\n * values when checked.\n * - `MarkdownRendererClient` is the interactive island `MarkdownRenderer`\n * mounts next to its HTML (tabs, code copy). Render it with the id of the\n * element that contains HTML from `renderMarkdown()` to get the same\n * behavior without `MarkdownRenderer`.\n */\nexport {\n MarkdownRendererClient,\n type MarkdownRendererClientProps,\n} from '../components/MarkdownRenderer/Component.client.js'\nexport { PayloadMarkdownField } from '../field/MarkdownField/Component.js'\n"],"names":["MarkdownBlockParamsEnableField","MarkdownRendererClient","PayloadMarkdownField"],"mappings":"AAAA,SAASA,8BAA8B,QAAQ,sDAAqD;AACpG;;;;;;;;;;;;;;;CAeC,GACD,SACEC,sBAAsB,QAEjB,qDAAoD;AAC3D,SAASC,oBAAoB,QAAQ,sCAAqC"}
1
+ {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["/**\n * `payload-markdown/client` (or the scoped `@valkyrianlabs/...` name): the package's `'use client'`\n * components, for bundled (Next.js / Payload admin) apps.\n *\n * - `PayloadMarkdownField` is the admin field component. The specifier\n * `<package>/server#PayloadMarkdownField` (used by\n * `markdownField()` and existing import maps) re-exports the same component\n * and keeps working.\n * - `MarkdownBlockParamsEnableField` is the markdown block's \"Enable Blocks\n * Params\" checkbox: it pre-fills the block's params with their effective\n * values when checked.\n * - `MarkdownPaletteRowLabel` labels palette rows in the \"Markdown Appearance\"\n * global (`appearance` plugin option) with their name and colour swatches.\n * - `MarkdownRendererClient` is the interactive island `MarkdownRenderer`\n * mounts next to its HTML (tabs, code copy). Render it with the id of the\n * element that contains HTML from `renderMarkdown()` to get the same\n * behavior without `MarkdownRenderer`.\n */\nexport { MarkdownPaletteRowLabel } from '../appearance/PaletteRowLabel.client.js'\nexport { MarkdownBlockParamsEnableField } from '../blocks/MarkdownBlock/ParamsEnableField.client.js'\nexport {\n MarkdownRendererClient,\n type MarkdownRendererClientProps,\n} from '../components/MarkdownRenderer/Component.client.js'\nexport { PayloadMarkdownField } from '../field/MarkdownField/Component.js'\n"],"names":["MarkdownPaletteRowLabel","MarkdownBlockParamsEnableField","MarkdownRendererClient","PayloadMarkdownField"],"mappings":"AAAA;;;;;;;;;;;;;;;;;CAiBC,GACD,SAASA,uBAAuB,QAAQ,0CAAyC;AACjF,SAASC,8BAA8B,QAAQ,sDAAqD;AACpG,SACEC,sBAAsB,QAEjB,qDAAoD;AAC3D,SAASC,oBAAoB,QAAQ,sCAAqC"}
@@ -1,10 +1,26 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { FieldDescription, FieldError, FieldLabel, RenderCustomComponent, useField } from '@payloadcms/ui';
4
- import React, { useCallback, useEffect, useMemo, useState } from 'react';
3
+ import { FieldDescription, FieldError, FieldLabel, RenderCustomComponent, useConfig, useField } from '@payloadcms/ui';
4
+ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
5
5
  import { readEditorDirectiveConfig } from '../../editor/directiveConfig.js';
6
6
  import { MarkdownCodeMirror } from '../../editor/MarkdownCodeMirror/Component.js';
7
7
  const SAVE_DEBOUNCE_MS = 800;
8
+ /** How long the admin reuses palette names it loaded (every markdown field on a page shares one request). */ const PALETTE_NAMES_TTL_MS = 30_000;
9
+ const paletteNameRequests = new Map();
10
+ /** Names of the palettes in the appearance global, or `undefined` when they cannot be read. */ function loadAdminPaletteNames(url) {
11
+ const cached = paletteNameRequests.get(url);
12
+ if (cached && cached.expires > Date.now()) return cached.names;
13
+ const names = fetch(url, {
14
+ credentials: 'include'
15
+ }).then((response)=>response.ok ? response.json() : undefined).then((doc)=>doc ? (doc.palettes ?? []).flatMap((row)=>typeof row?.name === 'string' ? [
16
+ row.name
17
+ ] : []) : undefined).catch(()=>undefined);
18
+ paletteNameRequests.set(url, {
19
+ expires: Date.now() + PALETTE_NAMES_TTL_MS,
20
+ names
21
+ });
22
+ return names;
23
+ }
8
24
  const fieldBaseClass = 'field-type';
9
25
  export const PayloadMarkdownField = (props)=>{
10
26
  const { field, path: pathFromProps, readOnly: readOnlyFromProps, validate } = props;
@@ -34,9 +50,44 @@ export const PayloadMarkdownField = (props)=>{
34
50
  // Configured themes and icon packs, injected by the plugin (CORE-8). Keyed
35
51
  // by content so a new-but-equal config object does not rebuild the editor.
36
52
  const directiveConfigKey = JSON.stringify(admin?.custom ?? null);
37
- const directiveConfig = useMemo(()=>readEditorDirectiveConfig(JSON.parse(directiveConfigKey)), [
53
+ const staticDirectiveConfig = useMemo(()=>readEditorDirectiveConfig(JSON.parse(directiveConfigKey)), [
38
54
  directiveConfigKey
39
55
  ]);
56
+ // Palettes managed in the admin are data, not config: load their names so
57
+ // completions and lint know palettes created after the app was built. The
58
+ // editor reads them through a getter, so their arrival does not rebuild it.
59
+ const { config: { routes, serverURL } } = useConfig();
60
+ const paletteNamesRef = useRef(undefined);
61
+ const appearanceSlug = staticDirectiveConfig?.appearanceSlug;
62
+ const staticPalettes = staticDirectiveConfig?.palettes;
63
+ useEffect(()=>{
64
+ if (!appearanceSlug) return;
65
+ let active = true;
66
+ const url = `${serverURL ?? ''}${routes.api}/globals/${encodeURIComponent(appearanceSlug)}?depth=0`;
67
+ void loadAdminPaletteNames(url).then((names)=>{
68
+ // Without read access the names stay unknown and no palette is linted.
69
+ if (active && names) paletteNamesRef.current = [
70
+ ...new Set([
71
+ ...staticPalettes ?? [],
72
+ ...names
73
+ ])
74
+ ];
75
+ });
76
+ return ()=>{
77
+ active = false;
78
+ };
79
+ }, [
80
+ appearanceSlug,
81
+ routes.api,
82
+ serverURL,
83
+ staticPalettes
84
+ ]);
85
+ const directiveConfig = useMemo(()=>staticDirectiveConfig && {
86
+ ...staticDirectiveConfig,
87
+ getPaletteNames: ()=>paletteNamesRef.current
88
+ }, [
89
+ staticDirectiveConfig
90
+ ]);
40
91
  // Sync in external value changes only when they actually differ.
41
92
  useEffect(()=>{
42
93
  const nextValue = value ?? '';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/field/MarkdownField/Component.tsx"],"sourcesContent":["'use client'\n\nimport type { TextFieldClientComponent, Validate } from 'payload'\n\nimport {\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useField,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { readEditorDirectiveConfig } from '../../editor/directiveConfig.js'\nimport { MarkdownCodeMirror } from '../../editor/MarkdownCodeMirror/Component.js'\n\nconst SAVE_DEBOUNCE_MS = 800\nconst fieldBaseClass = 'field-type'\n\nexport const PayloadMarkdownField: TextFieldClientComponent = (props) => {\n const { field, path: pathFromProps, readOnly: readOnlyFromProps, validate } = props\n const { admin, label, localized, maxLength, minLength, required } = field\n\n // Same client-side validation contract as Payload's own text field, so\n // length and required errors show before the server rejects a save.\n const memoizedValidate = useCallback<Validate>(\n (value, options) => {\n if (typeof validate !== 'function') return true\n\n return validate(value as string, {\n ...options,\n maxLength,\n minLength,\n required,\n } as Parameters<typeof validate>[1])\n },\n [validate, maxLength, minLength, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n path,\n setValue,\n showError,\n value,\n } = useField<string>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const readOnly = Boolean(readOnlyFromProps || disabled || admin?.readOnly)\n const [draftValue, setDraftValue] = useState<string>(value ?? '')\n\n // Configured themes and icon packs, injected by the plugin (CORE-8). Keyed\n // by content so a new-but-equal config object does not rebuild the editor.\n const directiveConfigKey = JSON.stringify(admin?.custom ?? null)\n const directiveConfig = useMemo(\n () => readEditorDirectiveConfig(JSON.parse(directiveConfigKey)),\n [directiveConfigKey],\n )\n\n // Sync in external value changes only when they actually differ.\n useEffect(() => {\n const nextValue = value ?? ''\n if (nextValue === draftValue) return\n setDraftValue(nextValue)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value])\n\n // Debounce writes back into Payload form state / autosave machinery.\n useEffect(() => {\n if (readOnly) return\n if (draftValue === (value ?? '')) return\n\n const timer = window.setTimeout(() => {\n setValue(draftValue)\n }, SAVE_DEBOUNCE_MS)\n\n return () => window.clearTimeout(timer)\n }, [draftValue, readOnly, value, setValue])\n\n const placeholder =\n 'placeholder' in field && typeof field.placeholder === 'string'\n ? field.placeholder\n : typeof admin?.placeholder === 'string'\n ? admin.placeholder\n : 'Write markdown...'\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'text',\n 'payload-markdown-field',\n admin?.className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={<FieldLabel label={label} localized={localized} path={path} required={required} />}\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <MarkdownCodeMirror\n directiveConfig={directiveConfig}\n onChangeAction={setDraftValue}\n placeholder={placeholder}\n readOnly={readOnly}\n value={draftValue}\n />\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={admin?.description} path={path} />}\n />\n </div>\n </div>\n )\n}\n"],"names":["FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useField","React","useCallback","useEffect","useMemo","useState","readEditorDirectiveConfig","MarkdownCodeMirror","SAVE_DEBOUNCE_MS","fieldBaseClass","PayloadMarkdownField","props","field","path","pathFromProps","readOnly","readOnlyFromProps","validate","admin","label","localized","maxLength","minLength","required","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","setValue","showError","potentiallyStalePath","Boolean","draftValue","setDraftValue","directiveConfigKey","JSON","stringify","custom","directiveConfig","parse","nextValue","timer","window","setTimeout","clearTimeout","placeholder","div","className","filter","join","CustomComponent","Fallback","onChangeAction","description"],"mappings":"AAAA;;AAIA,SACEA,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,QAAQ,QACH,iBAAgB;AACvB,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAExE,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,kBAAkB,QAAQ,+CAA8C;AAEjF,MAAMC,mBAAmB;AACzB,MAAMC,iBAAiB;AAEvB,OAAO,MAAMC,uBAAiD,CAACC;IAC7D,MAAM,EAAEC,KAAK,EAAEC,MAAMC,aAAa,EAAEC,UAAUC,iBAAiB,EAAEC,QAAQ,EAAE,GAAGN;IAC9E,MAAM,EAAEO,KAAK,EAAEC,KAAK,EAAEC,SAAS,EAAEC,SAAS,EAAEC,SAAS,EAAEC,QAAQ,EAAE,GAAGX;IAEpE,uEAAuE;IACvE,oEAAoE;IACpE,MAAMY,mBAAmBtB,YACvB,CAACuB,OAAOC;QACN,IAAI,OAAOT,aAAa,YAAY,OAAO;QAE3C,OAAOA,SAASQ,OAAiB;YAC/B,GAAGC,OAAO;YACVL;YACAC;YACAC;QACF;IACF,GACA;QAACN;QAAUI;QAAWC;QAAWC;KAAS;IAG5C,MAAM,EACJI,kBAAkB,EAAEC,UAAU,EAAEC,WAAW,EAAEC,WAAW,EAAEC,KAAK,EAAEC,KAAK,EAAE,GAAG,CAAC,CAAC,EAC7EC,QAAQ,EACRpB,IAAI,EACJqB,QAAQ,EACRC,SAAS,EAC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yD,iBAAiBzB;wBACjB0B,wBAAU,KAAC5D;4BAAWgB,MAAMA;4BAAMsB,WAAWA;;;oBAE9CN;kCACD,KAACtB;wBACCqC,iBAAiBA;wBACjBc,gBAAgBnB;wBAChBY,aAAaA;wBACbpC,UAAUA;wBACVU,OAAOa;;oBAERV;kCACD,KAAC7B;wBACCyD,iBAAiB1B;wBACjB2B,wBAAU,KAAC7D;4BAAiB+D,aAAazC,OAAOyC;4BAAa9C,MAAMA;;;;;;;AAK7E,EAAC"}
1
+ {"version":3,"sources":["../../../src/field/MarkdownField/Component.tsx"],"sourcesContent":["'use client'\n\nimport type { TextFieldClientComponent, Validate } from 'payload'\n\nimport {\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useConfig,\n useField,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'\n\nimport { readEditorDirectiveConfig } from '../../editor/directiveConfig.js'\nimport { MarkdownCodeMirror } from '../../editor/MarkdownCodeMirror/Component.js'\n\nconst SAVE_DEBOUNCE_MS = 800\n\n/** How long the admin reuses palette names it loaded (every markdown field on a page shares one request). */\nconst PALETTE_NAMES_TTL_MS = 30_000\nconst paletteNameRequests = new Map<string, { expires: number; names: Promise<string[] | undefined> }>()\n\n/** Names of the palettes in the appearance global, or `undefined` when they cannot be read. */\nfunction loadAdminPaletteNames(url: string): Promise<string[] | undefined> {\n const cached = paletteNameRequests.get(url)\n if (cached && cached.expires > Date.now()) return cached.names\n\n const names = fetch(url, { credentials: 'include' })\n .then((response) => (response.ok ? response.json() : undefined))\n .then((doc: { palettes?: Array<{ name?: unknown }> } | undefined) =>\n doc ? (doc.palettes ?? []).flatMap((row) => (typeof row?.name === 'string' ? [row.name] : [])) : undefined,\n )\n .catch(() => undefined)\n\n paletteNameRequests.set(url, { expires: Date.now() + PALETTE_NAMES_TTL_MS, names })\n\n return names\n}\nconst fieldBaseClass = 'field-type'\n\nexport const PayloadMarkdownField: TextFieldClientComponent = (props) => {\n const { field, path: pathFromProps, readOnly: readOnlyFromProps, validate } = props\n const { admin, label, localized, maxLength, minLength, required } = field\n\n // Same client-side validation contract as Payload's own text field, so\n // length and required errors show before the server rejects a save.\n const memoizedValidate = useCallback<Validate>(\n (value, options) => {\n if (typeof validate !== 'function') return true\n\n return validate(value as string, {\n ...options,\n maxLength,\n minLength,\n required,\n } as Parameters<typeof validate>[1])\n },\n [validate, maxLength, minLength, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled,\n path,\n setValue,\n showError,\n value,\n } = useField<string>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const readOnly = Boolean(readOnlyFromProps || disabled || admin?.readOnly)\n const [draftValue, setDraftValue] = useState<string>(value ?? '')\n\n // Configured themes and icon packs, injected by the plugin (CORE-8). Keyed\n // by content so a new-but-equal config object does not rebuild the editor.\n const directiveConfigKey = JSON.stringify(admin?.custom ?? null)\n const staticDirectiveConfig = useMemo(\n () => readEditorDirectiveConfig(JSON.parse(directiveConfigKey)),\n [directiveConfigKey],\n )\n\n // Palettes managed in the admin are data, not config: load their names so\n // completions and lint know palettes created after the app was built. The\n // editor reads them through a getter, so their arrival does not rebuild it.\n const {\n config: { routes, serverURL },\n } = useConfig()\n const paletteNamesRef = useRef<readonly string[] | undefined>(undefined)\n const appearanceSlug = staticDirectiveConfig?.appearanceSlug\n const staticPalettes = staticDirectiveConfig?.palettes\n\n useEffect(() => {\n if (!appearanceSlug) return\n\n let active = true\n const url = `${serverURL ?? ''}${routes.api}/globals/${encodeURIComponent(appearanceSlug)}?depth=0`\n\n void loadAdminPaletteNames(url).then((names) => {\n // Without read access the names stay unknown and no palette is linted.\n if (active && names) paletteNamesRef.current = [...new Set([...(staticPalettes ?? []), ...names])]\n })\n\n return () => {\n active = false\n }\n }, [appearanceSlug, routes.api, serverURL, staticPalettes])\n\n const directiveConfig = useMemo(\n () =>\n staticDirectiveConfig && {\n ...staticDirectiveConfig,\n getPaletteNames: () => paletteNamesRef.current,\n },\n [staticDirectiveConfig],\n )\n\n // Sync in external value changes only when they actually differ.\n useEffect(() => {\n const nextValue = value ?? ''\n if (nextValue === draftValue) return\n setDraftValue(nextValue)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [value])\n\n // Debounce writes back into Payload form state / autosave machinery.\n useEffect(() => {\n if (readOnly) return\n if (draftValue === (value ?? '')) return\n\n const timer = window.setTimeout(() => {\n setValue(draftValue)\n }, SAVE_DEBOUNCE_MS)\n\n return () => window.clearTimeout(timer)\n }, [draftValue, readOnly, value, setValue])\n\n const placeholder =\n 'placeholder' in field && typeof field.placeholder === 'string'\n ? field.placeholder\n : typeof admin?.placeholder === 'string'\n ? admin.placeholder\n : 'Write markdown...'\n\n return (\n <div\n className={[\n fieldBaseClass,\n 'text',\n 'payload-markdown-field',\n admin?.className,\n showError && 'error',\n readOnly && 'read-only',\n ]\n .filter(Boolean)\n .join(' ')}\n >\n <RenderCustomComponent\n CustomComponent={Label}\n Fallback={<FieldLabel label={label} localized={localized} path={path} required={required} />}\n />\n <div className={`${fieldBaseClass}__wrap`}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {BeforeInput}\n <MarkdownCodeMirror\n directiveConfig={directiveConfig}\n onChangeAction={setDraftValue}\n placeholder={placeholder}\n readOnly={readOnly}\n value={draftValue}\n />\n {AfterInput}\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={admin?.description} path={path} />}\n />\n </div>\n </div>\n )\n}\n"],"names":["FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useConfig","useField","React","useCallback","useEffect","useMemo","useRef","useState","readEditorDirectiveConfig","MarkdownCodeMirror","SAVE_DEBOUNCE_MS","PALETTE_NAMES_TTL_MS","paletteNameRequests","Map","loadAdminPaletteNames","url","cached","get","expires","Date","now","names","fetch","credentials","then","response","ok","json","undefined","doc","palettes","flatMap","row","name","catch","set","fieldBaseClass","PayloadMarkdownField","props","field","path","pathFromProps","readOnly","readOnlyFromProps","validate","admin","label","localized","maxLength","minLength","required","memoizedValidate","value","options","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","setValue","showError","potentiallyStalePath","Boolean","draftValue","setDraftValue","directiveConfigKey","JSON","stringify","custom","staticDirectiveConfig","parse","config","routes","serverURL","paletteNamesRef","appearanceSlug","staticPalettes","active","api","encodeURIComponent","current","Set","directiveConfig","getPaletteNames","nextValue","timer","window","setTimeout","clearTimeout","placeholder","div","className","filter","join","CustomComponent","Fallback","onChangeAction","description"],"mappings":"AAAA;;AAIA,SACEA,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,SAAS,EACTC,QAAQ,QACH,iBAAgB;AACvB,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAEhF,SAASC,yBAAyB,QAAQ,kCAAiC;AAC3E,SAASC,kBAAkB,QAAQ,+CAA8C;AAEjF,MAAMC,mBAAmB;AAEzB,2GAA2G,GAC3G,MAAMC,uBAAuB;AAC7B,MAAMC,sBAAsB,IAAIC;AAEhC,6FAA6F,GAC7F,SAASC,sBAAsBC,GAAW;IACxC,MAAMC,SAASJ,oBAAoBK,GAAG,CAACF;IACvC,IAAIC,UAAUA,OAAOE,OAAO,GAAGC,KAAKC,GAAG,IAAI,OAAOJ,OAAOK,KAAK;IAE9D,MAAMA,QAAQC,MAAMP,KAAK;QAAEQ,aAAa;IAAU,GAC/CC,IAAI,CAAC,CAACC,WAAcA,SAASC,EAAE,GAAGD,SAASE,IAAI,KAAKC,WACpDJ,IAAI,CAAC,CAACK,MACLA,MAAM,AAACA,CAAAA,IAAIC,QAAQ,IAAI,EAAE,AAAD,EAAGC,OAAO,CAAC,CAACC,MAAS,OAAOA,KAAKC,SAAS,WAAW;gBAACD,IAAIC,IAAI;aAAC,GAAG,EAAE,IAAKL,WAElGM,KAAK,CAAC,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