@valkyrianlabs/payload-markdown 1.3.4 → 1.4.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 (99) hide show
  1. package/README.md +63 -14
  2. package/dist/components/MarkdownRenderer/index.css +150 -0
  3. package/dist/components/MarkdownRenderer/index.scss +158 -0
  4. package/dist/core/plugins/rehypeResolveIcons.d.ts +4 -0
  5. package/dist/core/plugins/rehypeResolveIcons.js +27 -0
  6. package/dist/core/plugins/rehypeResolveIcons.js.map +1 -0
  7. package/dist/core/plugins/remarkButtonDirectives.d.ts +4 -0
  8. package/dist/core/plugins/remarkButtonDirectives.js +237 -0
  9. package/dist/core/plugins/remarkButtonDirectives.js.map +1 -0
  10. package/dist/core/plugins/remarkCompileLayouts.js +6 -5
  11. package/dist/core/plugins/remarkCompileLayouts.js.map +1 -1
  12. package/dist/core/plugins/remarkLayoutDirectives.js +17 -7
  13. package/dist/core/plugins/remarkLayoutDirectives.js.map +1 -1
  14. package/dist/core/plugins/remarkLiftLayoutDirectives.js +42 -4
  15. package/dist/core/plugins/remarkLiftLayoutDirectives.js.map +1 -1
  16. package/dist/core/renderMarkdown.js +27 -2
  17. package/dist/core/renderMarkdown.js.map +1 -1
  18. package/dist/directives/attributeDiagnostics.d.ts +2 -0
  19. package/dist/directives/attributeDiagnostics.js +35 -0
  20. package/dist/directives/attributeDiagnostics.js.map +1 -0
  21. package/dist/directives/attributes.d.ts +8 -0
  22. package/dist/directives/attributes.js +56 -5
  23. package/dist/directives/attributes.js.map +1 -1
  24. package/dist/directives/buttonSyntax.d.ts +7 -0
  25. package/dist/directives/buttonSyntax.js +26 -0
  26. package/dist/directives/buttonSyntax.js.map +1 -0
  27. package/dist/directives/closeLabels.d.ts +8 -0
  28. package/dist/directives/closeLabels.js +76 -0
  29. package/dist/directives/closeLabels.js.map +1 -0
  30. package/dist/directives/definitions/button.d.ts +15 -0
  31. package/dist/directives/definitions/button.js +96 -0
  32. package/dist/directives/definitions/button.js.map +1 -0
  33. package/dist/directives/definitions/buttons.d.ts +8 -0
  34. package/dist/directives/definitions/buttons.js +82 -0
  35. package/dist/directives/definitions/buttons.js.map +1 -0
  36. package/dist/directives/definitions/callout.js +20 -9
  37. package/dist/directives/definitions/callout.js.map +1 -1
  38. package/dist/directives/definitions/card.d.ts +4 -0
  39. package/dist/directives/definitions/card.js +90 -9
  40. package/dist/directives/definitions/card.js.map +1 -1
  41. package/dist/directives/definitions/cards.d.ts +4 -0
  42. package/dist/directives/definitions/cards.js +119 -4
  43. package/dist/directives/definitions/cards.js.map +1 -1
  44. package/dist/directives/definitions/details.js +4 -3
  45. package/dist/directives/definitions/details.js.map +1 -1
  46. package/dist/directives/definitions/tab.d.ts +1 -0
  47. package/dist/directives/definitions/tab.js +10 -3
  48. package/dist/directives/definitions/tab.js.map +1 -1
  49. package/dist/directives/definitions/tabs.js +3 -3
  50. package/dist/directives/definitions/tabs.js.map +1 -1
  51. package/dist/directives/definitions/toc.js +4 -3
  52. package/dist/directives/definitions/toc.js.map +1 -1
  53. package/dist/directives/diagnostics.js +97 -7
  54. package/dist/directives/diagnostics.js.map +1 -1
  55. package/dist/directives/iconPlaceholder.d.ts +12 -0
  56. package/dist/directives/iconPlaceholder.js +19 -0
  57. package/dist/directives/iconPlaceholder.js.map +1 -0
  58. package/dist/directives/labels.d.ts +3 -0
  59. package/dist/directives/labels.js +12 -0
  60. package/dist/directives/labels.js.map +1 -0
  61. package/dist/directives/registry.d.ts +1 -1
  62. package/dist/directives/registry.js +46 -6
  63. package/dist/directives/registry.js.map +1 -1
  64. package/dist/directives/renderData.d.ts +2 -2
  65. package/dist/directives/renderData.js.map +1 -1
  66. package/dist/directives/types.d.ts +6 -4
  67. package/dist/directives/types.js.map +1 -1
  68. package/dist/editor/MarkdownCodeMirror/Component.client.js +2 -0
  69. package/dist/editor/MarkdownCodeMirror/Component.client.js.map +1 -1
  70. package/dist/editor/directives/closeLabels.d.ts +2 -0
  71. package/dist/editor/directives/closeLabels.js +75 -0
  72. package/dist/editor/directives/closeLabels.js.map +1 -0
  73. package/dist/editor/directives/completions.js +49 -7
  74. package/dist/editor/directives/completions.js.map +1 -1
  75. package/dist/editor/themes/payload.js +197 -9
  76. package/dist/editor/themes/payload.js.map +1 -1
  77. package/dist/exports/advanced.d.ts +1 -0
  78. package/dist/exports/advanced.js +1 -0
  79. package/dist/exports/advanced.js.map +1 -1
  80. package/dist/icons/generateRegistry.d.ts +8 -0
  81. package/dist/icons/generateRegistry.js +36 -0
  82. package/dist/icons/generateRegistry.js.map +1 -0
  83. package/dist/icons/refs.d.ts +10 -0
  84. package/dist/icons/refs.js +42 -0
  85. package/dist/icons/refs.js.map +1 -0
  86. package/dist/icons/resolve.d.ts +9 -0
  87. package/dist/icons/resolve.js +95 -0
  88. package/dist/icons/resolve.js.map +1 -0
  89. package/dist/index.d.ts +1 -1
  90. package/dist/index.js.map +1 -1
  91. package/dist/runtime/index.d.ts +1 -0
  92. package/dist/runtime/index.js +8 -1
  93. package/dist/runtime/index.js.map +1 -1
  94. package/dist/types/core.d.ts +9 -0
  95. package/dist/types/core.js.map +1 -1
  96. package/dist/types/mdast.d.js.map +1 -1
  97. package/dist/types.d.ts +5 -1
  98. package/dist/types.js.map +1 -1
  99. package/package.json +1 -1
@@ -0,0 +1,75 @@
1
+ import { RangeSetBuilder } from '@codemirror/state';
2
+ import { Decoration, EditorView, ViewPlugin, WidgetType } from '@codemirror/view';
3
+ import { getDirectiveCloseLabels } from '../../directives/closeLabels.js';
4
+ const closeLabelMark = Decoration.mark({
5
+ class: 'vl-md-directive-close-label vl-md-directive-close-label--suffix'
6
+ });
7
+ class CloseLabelWidget extends WidgetType {
8
+ label;
9
+ constructor(label){
10
+ super(), this.label = label;
11
+ }
12
+ eq(widget) {
13
+ return widget.label === this.label;
14
+ }
15
+ ignoreEvent() {
16
+ return true;
17
+ }
18
+ toDOM() {
19
+ const label = document.createElement('span');
20
+ label.setAttribute('aria-hidden', 'true');
21
+ label.className = 'vl-md-directive-close-label vl-md-directive-close-label--widget';
22
+ label.textContent = this.label;
23
+ return label;
24
+ }
25
+ }
26
+ function buildCloseLabelDecorations(view) {
27
+ const builder = new RangeSetBuilder();
28
+ for (const closeLabel of getDirectiveCloseLabels(view.state.doc.toString())){
29
+ if (closeLabel.kind === 'suffix') {
30
+ builder.add(closeLabel.from, closeLabel.to, closeLabelMark);
31
+ continue;
32
+ }
33
+ builder.add(closeLabel.to, closeLabel.to, Decoration.widget({
34
+ side: 1,
35
+ widget: new CloseLabelWidget(closeLabel.label)
36
+ }));
37
+ }
38
+ return builder.finish();
39
+ }
40
+ const closeLabelPlugin = ViewPlugin.fromClass(class {
41
+ decorations;
42
+ constructor(view){
43
+ this.decorations = buildCloseLabelDecorations(view);
44
+ }
45
+ update(update) {
46
+ if (!update.docChanged) return;
47
+ this.decorations = buildCloseLabelDecorations(update.view);
48
+ }
49
+ }, {
50
+ decorations: (plugin)=>plugin.decorations
51
+ });
52
+ const closeLabelTheme = EditorView.baseTheme({
53
+ '.vl-md-directive-close-label': {
54
+ backgroundColor: 'rgba(125, 135, 153, 0.14)',
55
+ border: '1px solid rgba(125, 135, 153, 0.35)',
56
+ borderRadius: '3px',
57
+ color: '#9aa4b5',
58
+ display: 'inline-block',
59
+ fontSize: '0.78em',
60
+ lineHeight: '1.45',
61
+ marginLeft: '0.35rem',
62
+ padding: '0 0.35rem',
63
+ verticalAlign: 'baseline'
64
+ },
65
+ '.vl-md-directive-close-label--widget': {
66
+ pointerEvents: 'none',
67
+ userSelect: 'none'
68
+ }
69
+ });
70
+ export const directiveCloseLabels = [
71
+ closeLabelPlugin,
72
+ closeLabelTheme
73
+ ];
74
+
75
+ //# sourceMappingURL=closeLabels.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/editor/directives/closeLabels.ts"],"sourcesContent":["import type { Extension } from '@codemirror/state'\nimport type { DecorationSet, ViewUpdate } from '@codemirror/view'\n\nimport { RangeSetBuilder } from '@codemirror/state'\nimport { Decoration, EditorView, ViewPlugin, WidgetType } from '@codemirror/view'\n\nimport { getDirectiveCloseLabels } from '../../directives/closeLabels.js'\n\nconst closeLabelMark = Decoration.mark({\n class: 'vl-md-directive-close-label vl-md-directive-close-label--suffix',\n})\n\nclass CloseLabelWidget extends WidgetType {\n constructor(private readonly label: string) {\n super()\n }\n\n eq(widget: CloseLabelWidget): boolean {\n return widget.label === this.label\n }\n\n ignoreEvent(): boolean {\n return true\n }\n\n toDOM(): HTMLElement {\n const label = document.createElement('span')\n\n label.setAttribute('aria-hidden', 'true')\n label.className = 'vl-md-directive-close-label vl-md-directive-close-label--widget'\n label.textContent = this.label\n\n return label\n }\n}\n\nfunction buildCloseLabelDecorations(view: EditorView): DecorationSet {\n const builder = new RangeSetBuilder<Decoration>()\n\n for (const closeLabel of getDirectiveCloseLabels(view.state.doc.toString())) {\n if (closeLabel.kind === 'suffix') {\n builder.add(closeLabel.from, closeLabel.to, closeLabelMark)\n continue\n }\n\n builder.add(\n closeLabel.to,\n closeLabel.to,\n Decoration.widget({\n side: 1,\n widget: new CloseLabelWidget(closeLabel.label),\n }),\n )\n }\n\n return builder.finish()\n}\n\nconst closeLabelPlugin = ViewPlugin.fromClass(\n class {\n decorations: DecorationSet\n\n constructor(view: EditorView) {\n this.decorations = buildCloseLabelDecorations(view)\n }\n\n update(update: ViewUpdate): void {\n if (!update.docChanged) return\n\n this.decorations = buildCloseLabelDecorations(update.view)\n }\n },\n {\n decorations: (plugin): DecorationSet => plugin.decorations,\n },\n)\n\nconst closeLabelTheme = EditorView.baseTheme({\n '.vl-md-directive-close-label': {\n backgroundColor: 'rgba(125, 135, 153, 0.14)',\n border: '1px solid rgba(125, 135, 153, 0.35)',\n borderRadius: '3px',\n color: '#9aa4b5',\n display: 'inline-block',\n fontSize: '0.78em',\n lineHeight: '1.45',\n marginLeft: '0.35rem',\n padding: '0 0.35rem',\n verticalAlign: 'baseline',\n },\n\n '.vl-md-directive-close-label--widget': {\n pointerEvents: 'none',\n userSelect: 'none',\n },\n})\n\nexport const directiveCloseLabels: Extension = [closeLabelPlugin, closeLabelTheme]\n"],"names":["RangeSetBuilder","Decoration","EditorView","ViewPlugin","WidgetType","getDirectiveCloseLabels","closeLabelMark","mark","class","CloseLabelWidget","label","eq","widget","ignoreEvent","toDOM","document","createElement","setAttribute","className","textContent","buildCloseLabelDecorations","view","builder","closeLabel","state","doc","toString","kind","add","from","to","side","finish","closeLabelPlugin","fromClass","decorations","update","docChanged","plugin","closeLabelTheme","baseTheme","backgroundColor","border","borderRadius","color","display","fontSize","lineHeight","marginLeft","padding","verticalAlign","pointerEvents","userSelect","directiveCloseLabels"],"mappings":"AAGA,SAASA,eAAe,QAAQ,oBAAmB;AACnD,SAASC,UAAU,EAAEC,UAAU,EAAEC,UAAU,EAAEC,UAAU,QAAQ,mBAAkB;AAEjF,SAASC,uBAAuB,QAAQ,kCAAiC;AAEzE,MAAMC,iBAAiBL,WAAWM,IAAI,CAAC;IACrCC,OAAO;AACT;AAEA,MAAMC,yBAAyBL;;IAC7B,YAAY,AAAiBM,KAAa,CAAE;QAC1C,KAAK,SADsBA,QAAAA;IAE7B;IAEAC,GAAGC,MAAwB,EAAW;QACpC,OAAOA,OAAOF,KAAK,KAAK,IAAI,CAACA,KAAK;IACpC;IAEAG,cAAuB;QACrB,OAAO;IACT;IAEAC,QAAqB;QACnB,MAAMJ,QAAQK,SAASC,aAAa,CAAC;QAErCN,MAAMO,YAAY,CAAC,eAAe;QAClCP,MAAMQ,SAAS,GAAG;QAClBR,MAAMS,WAAW,GAAG,IAAI,CAACT,KAAK;QAE9B,OAAOA;IACT;AACF;AAEA,SAASU,2BAA2BC,IAAgB;IAClD,MAAMC,UAAU,IAAItB;IAEpB,KAAK,MAAMuB,cAAclB,wBAAwBgB,KAAKG,KAAK,CAACC,GAAG,CAACC,QAAQ,IAAK;QAC3E,IAAIH,WAAWI,IAAI,KAAK,UAAU;YAChCL,QAAQM,GAAG,CAACL,WAAWM,IAAI,EAAEN,WAAWO,EAAE,EAAExB;YAC5C;QACF;QAEAgB,QAAQM,GAAG,CACTL,WAAWO,EAAE,EACbP,WAAWO,EAAE,EACb7B,WAAWW,MAAM,CAAC;YAChBmB,MAAM;YACNnB,QAAQ,IAAIH,iBAAiBc,WAAWb,KAAK;QAC/C;IAEJ;IAEA,OAAOY,QAAQU,MAAM;AACvB;AAEA,MAAMC,mBAAmB9B,WAAW+B,SAAS,CAC3C;IACEC,YAA0B;IAE1B,YAAYd,IAAgB,CAAE;QAC5B,IAAI,CAACc,WAAW,GAAGf,2BAA2BC;IAChD;IAEAe,OAAOA,MAAkB,EAAQ;QAC/B,IAAI,CAACA,OAAOC,UAAU,EAAE;QAExB,IAAI,CAACF,WAAW,GAAGf,2BAA2BgB,OAAOf,IAAI;IAC3D;AACF,GACA;IACEc,aAAa,CAACG,SAA0BA,OAAOH,WAAW;AAC5D;AAGF,MAAMI,kBAAkBrC,WAAWsC,SAAS,CAAC;IAC3C,gCAAgC;QAC9BC,iBAAiB;QACjBC,QAAQ;QACRC,cAAc;QACdC,OAAO;QACPC,SAAS;QACTC,UAAU;QACVC,YAAY;QACZC,YAAY;QACZC,SAAS;QACTC,eAAe;IACjB;IAEA,wCAAwC;QACtCC,eAAe;QACfC,YAAY;IACd;AACF;AAEA,OAAO,MAAMC,uBAAkC;IAACpB;IAAkBM;CAAgB,CAAA"}
@@ -3,10 +3,11 @@ import { layoutDirectiveRegistry } from '../../directives/registry.js';
3
3
  import { getDirectiveThemeNames } from '../../directives/themes.js';
4
4
  export function getDirectiveCompletionOptions() {
5
5
  return layoutDirectiveRegistry.getPublicDefinitions().flatMap((definition)=>{
6
+ const label = definition.editor.label.startsWith(':') ? definition.editor.label : `:::${definition.name}`;
6
7
  const snippets = [
7
8
  {
8
9
  detail: definition.editor.detail,
9
- label: `:::${definition.name}`,
10
+ label,
10
11
  snippet: definition.editor.snippet
11
12
  },
12
13
  ...(definition.editor.snippets ?? []).map((snippet)=>({
@@ -26,18 +27,20 @@ export function getDirectiveCompletionOptions() {
26
27
  export function getDirectiveAttributeCompletionOptions(name) {
27
28
  const definition = layoutDirectiveRegistry.get(name);
28
29
  const attributes = definition?.allowedAttributes ?? [];
30
+ const detailPrefix = name === 'button' ? '::button' : `:::${name}`;
29
31
  return attributes.map((attribute)=>snippetCompletion(`${attribute}="\${${attribute}}"`, {
30
32
  type: 'property',
31
- detail: `:::${name} attribute`,
33
+ detail: `${detailPrefix} attribute`,
32
34
  label: attribute
33
35
  }));
34
36
  }
35
37
  export function getDirectiveThemeValueCompletionOptions(name, attribute) {
36
38
  const definition = layoutDirectiveRegistry.get(name);
37
39
  const groupName = definition?.themeAttributes?.[attribute];
40
+ const detailPrefix = name === 'button' ? '::button' : `:::${name}`;
38
41
  if (!groupName) return (definition?.attributeValues?.[attribute] ?? []).map((value)=>({
39
42
  type: 'constant',
40
- detail: `:::${name} ${attribute}`,
43
+ detail: `${detailPrefix} ${attribute}`,
41
44
  label: value
42
45
  }));
43
46
  return getDirectiveThemeNames(groupName).map((themeName)=>({
@@ -49,10 +52,19 @@ export function getDirectiveThemeValueCompletionOptions(name, attribute) {
49
52
  function attributeCompletionSource(context) {
50
53
  const line = context.state.doc.lineAt(context.pos);
51
54
  const beforeCursor = line.text.slice(0, context.pos - line.from);
52
- const directiveMatch = beforeCursor.match(/^\s*:::(\w+)\s+\{([^}]*)$/);
55
+ const containerMatch = beforeCursor.match(/^\s*:::(\w+)(?:\[[^\]]*\])?\s*\{([^}]*)$/);
56
+ const buttonMatch = beforeCursor.match(/^\s*::button(?:\[[^\]]*\])?\s*\{([^}]*)$/);
57
+ const multilineMatch = containerMatch || buttonMatch ? null : findOpenDirectiveAttributeBlock(context, beforeCursor);
58
+ const directiveMatch = containerMatch ? {
59
+ name: containerMatch[1],
60
+ attributesBeforeCursor: containerMatch[2]
61
+ } : buttonMatch ? {
62
+ name: 'button',
63
+ attributesBeforeCursor: buttonMatch[1]
64
+ } : multilineMatch;
53
65
  if (!directiveMatch) return null;
54
- const [, name, attributesBeforeCursor] = directiveMatch;
55
- const valueMatch = attributesBeforeCursor.match(/(?:^|\s)(theme|cardTheme|cellTheme|stepTheme|tabTheme)="([^"]*)$/);
66
+ const { name, attributesBeforeCursor } = directiveMatch;
67
+ const valueMatch = attributesBeforeCursor.match(/(?:^|\s)(align|gap|theme|cardTheme|cellTheme|iconPosition|linkScope|newTab|size|stack|stepTheme|tabTheme|variant)=["']?([^"'\s}]*)$/);
56
68
  if (valueMatch) {
57
69
  const [, attribute, typedValue] = valueMatch;
58
70
  const options = getDirectiveThemeValueCompletionOptions(name, attribute);
@@ -72,15 +84,45 @@ function attributeCompletionSource(context) {
72
84
  options
73
85
  };
74
86
  }
87
+ function findOpenDirectiveAttributeBlock(context, attributesBeforeCursor) {
88
+ const line = context.state.doc.lineAt(context.pos);
89
+ for(let lineNumber = line.number - 1; lineNumber >= 1; --lineNumber){
90
+ const previousLine = context.state.doc.line(lineNumber).text;
91
+ const trimmed = previousLine.trim();
92
+ if (!trimmed) break;
93
+ if (trimmed.includes('}')) break;
94
+ const containerMatch = previousLine.match(/^\s*:::(\w+)(?:\[[^\]]*\])?\s*\{/);
95
+ if (containerMatch) return {
96
+ name: containerMatch[1],
97
+ attributesBeforeCursor
98
+ };
99
+ const buttonMatch = previousLine.match(/^\s*::button(?:\[[^\]]*\])?\s*\{/);
100
+ if (buttonMatch) return {
101
+ name: 'button',
102
+ attributesBeforeCursor
103
+ };
104
+ }
105
+ return null;
106
+ }
75
107
  function directiveCompletionSource(context) {
76
108
  const attributeResult = attributeCompletionSource(context);
77
109
  if (attributeResult) return attributeResult;
110
+ const leafMatch = context.matchBefore(/::[\w-]*/);
111
+ if (leafMatch) {
112
+ const line = context.state.doc.lineAt(context.pos);
113
+ const beforeLeaf = line.text.slice(0, leafMatch.from - line.from);
114
+ const typedLeaf = line.text.slice(leafMatch.from - line.from, leafMatch.to - line.from);
115
+ if (!typedLeaf.startsWith(':::') && !beforeLeaf.trim()) return {
116
+ from: leafMatch.from,
117
+ options: getDirectiveCompletionOptions().filter((option)=>typeof option.label === 'string' ? option.label.startsWith('::') && !option.label.startsWith(':::') : false)
118
+ };
119
+ }
78
120
  const match = context.matchBefore(/:::[\w-]*/);
79
121
  if (!match) return null;
80
122
  if (match.from === match.to && !context.explicit) return null;
81
123
  return {
82
124
  from: match.from,
83
- options: getDirectiveCompletionOptions()
125
+ options: getDirectiveCompletionOptions().filter((option)=>typeof option.label === 'string' ? option.label.startsWith(':::') : true)
84
126
  };
85
127
  }
86
128
  export const directiveCompletions = autocompletion({
@@ -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 { layoutDirectiveRegistry } from '../../directives/registry.js'\nimport { getDirectiveThemeNames } from '../../directives/themes.js'\n\nexport function getDirectiveCompletionOptions() {\n return layoutDirectiveRegistry.getPublicDefinitions().flatMap((definition) => {\n const snippets = [\n {\n detail: definition.editor.detail,\n label: `:::${definition.name}`,\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\n return attributes.map((attribute) =>\n snippetCompletion(`${attribute}=\"\\${${attribute}}\"`, {\n type: 'property',\n detail: `:::${name} attribute`,\n label: attribute,\n }),\n )\n}\n\nexport function getDirectiveThemeValueCompletionOptions(\n name: string,\n attribute: string,\n): Completion[] {\n const definition = layoutDirectiveRegistry.get(name)\n const groupName = definition?.themeAttributes?.[attribute]\n\n if (!groupName)\n return (definition?.attributeValues?.[attribute] ?? []).map((value) => ({\n type: 'constant',\n detail: `:::${name} ${attribute}`,\n label: value,\n }))\n\n return getDirectiveThemeNames(groupName).map((themeName) => ({\n type: 'constant',\n detail: `${groupName} theme`,\n label: themeName,\n }))\n}\n\nfunction attributeCompletionSource(context: CompletionContext) {\n const line = context.state.doc.lineAt(context.pos)\n const beforeCursor = line.text.slice(0, context.pos - line.from)\n const directiveMatch = beforeCursor.match(/^\\s*:::(\\w+)\\s+\\{([^}]*)$/)\n\n if (!directiveMatch) return null\n\n const [, name, attributesBeforeCursor] = directiveMatch\n const valueMatch = attributesBeforeCursor.match(\n /(?:^|\\s)(theme|cardTheme|cellTheme|stepTheme|tabTheme)=\"([^\"]*)$/,\n )\n\n if (valueMatch) {\n const [, attribute, typedValue] = valueMatch\n const options = getDirectiveThemeValueCompletionOptions(name, attribute)\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 directiveCompletionSource(context: CompletionContext) {\n const attributeResult = attributeCompletionSource(context)\n if (attributeResult) return attributeResult\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(),\n }\n}\n\nexport const directiveCompletions = autocompletion({\n activateOnTyping: true,\n override: [directiveCompletionSource],\n})\n"],"names":["autocompletion","snippetCompletion","layoutDirectiveRegistry","getDirectiveThemeNames","getDirectiveCompletionOptions","getPublicDefinitions","flatMap","definition","snippets","detail","editor","label","name","snippet","map","type","info","description","getDirectiveAttributeCompletionOptions","get","attributes","allowedAttributes","attribute","getDirectiveThemeValueCompletionOptions","groupName","themeAttributes","attributeValues","value","themeName","attributeCompletionSource","context","line","state","doc","lineAt","pos","beforeCursor","text","slice","from","directiveMatch","match","attributesBeforeCursor","valueMatch","typedValue","options","length","attributeMatch","typedAttribute","explicit","directiveCompletionSource","attributeResult","matchBefore","to","directiveCompletions","activateOnTyping","override"],"mappings":"AAEA,SAASA,cAAc,EAAEC,iBAAiB,QAAQ,2BAA0B;AAE5E,SAASC,uBAAuB,QAAQ,+BAA8B;AACtE,SAASC,sBAAsB,QAAQ,6BAA4B;AAEnE,OAAO,SAASC;IACd,OAAOF,wBAAwBG,oBAAoB,GAAGC,OAAO,CAAC,CAACC;QAC7D,MAAMC,WAAW;YACf;gBACEC,QAAQF,WAAWG,MAAM,CAACD,MAAM;gBAChCE,OAAO,CAAC,GAAG,EAAEJ,WAAWK,IAAI,EAAE;gBAC9BC,SAASN,WAAWG,MAAM,CAACG,OAAO;YACpC;eACG,AAACN,CAAAA,WAAWG,MAAM,CAACF,QAAQ,IAAI,EAAE,AAAD,EAAGM,GAAG,CAAC,CAACD,UAAa,CAAA;oBACtDJ,QAAQI,QAAQJ,MAAM,IAAIF,WAAWG,MAAM,CAACD,MAAM;oBAClDE,OAAOE,QAAQF,KAAK;oBACpBE,SAASA,QAAQA,OAAO;gBAC1B,CAAA;SACD;QAED,OAAOL,SAASM,GAAG,CAAC,CAACD,UACnBZ,kBAAkBY,QAAQA,OAAO,EAAE;gBACjCE,MAAM;gBACNN,QAAQI,QAAQJ,MAAM;gBACtBO,MAAMT,WAAWU,WAAW;gBAC5BN,OAAOE,QAAQF,KAAK;YACtB;IAEJ;AACF;AAEA,OAAO,SAASO,uCAAuCN,IAAY;IACjE,MAAML,aAAaL,wBAAwBiB,GAAG,CAACP;IAC/C,MAAMQ,aAAab,YAAYc,qBAAqB,EAAE;IAEtD,OAAOD,WAAWN,GAAG,CAAC,CAACQ,YACrBrB,kBAAkB,GAAGqB,UAAU,KAAK,EAAEA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,MAAME,iBAAiBL,uBAAuBD,KAAK,CAAC;IACpD,MAAMO,iBAAiBD,gBAAgB,CAAC,EAAE,IAAI;IAC9C,MAAMF,UAAU3B,uCAAuCN;IAEvD,IAAIiC,QAAQC,MAAM,KAAK,GAAG,OAAO;IACjC,IAAI,CAAChB,QAAQmB,QAAQ,IAAID,eAAeF,MAAM,KAAK,GAAG,OAAO;IAE7D,OAAO;QACLP,MAAMT,QAAQK,GAAG,GAAGa,eAAeF,MAAM;QACzCD;IACF;AACF;AAEA,SAASK,0BAA0BpB,OAA0B;IAC3D,MAAMqB,kBAAkBtB,0BAA0BC;IAClD,IAAIqB,iBAAiB,OAAOA;IAE5B,MAAMV,QAAQX,QAAQsB,WAAW,CAAC;IAElC,IAAI,CAACX,OAAO,OAAO;IACnB,IAAIA,MAAMF,IAAI,KAAKE,MAAMY,EAAE,IAAI,CAACvB,QAAQmB,QAAQ,EAAE,OAAO;IAEzD,OAAO;QACLV,MAAME,MAAMF,IAAI;QAChBM,SAASzC;IACX;AACF;AAEA,OAAO,MAAMkD,uBAAuBtD,eAAe;IACjDuD,kBAAkB;IAClBC,UAAU;QAACN;KAA0B;AACvC,GAAE"}
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 { 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' ? '::button' : `:::${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): Completion[] {\n const definition = layoutDirectiveRegistry.get(name)\n const groupName = definition?.themeAttributes?.[attribute]\n const detailPrefix = name === 'button' ? '::button' : `:::${name}`\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).map((themeName) => ({\n type: 'constant',\n detail: `${groupName} theme`,\n label: themeName,\n }))\n}\n\nfunction attributeCompletionSource(context: CompletionContext) {\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 buttonMatch = beforeCursor.match(/^\\s*::button(?:\\[[^\\]]*\\])?\\s*\\{([^}]*)$/)\n const multilineMatch =\n containerMatch || buttonMatch\n ? null\n : findOpenDirectiveAttributeBlock(context, beforeCursor)\n const directiveMatch = containerMatch\n ? {\n name: containerMatch[1],\n attributesBeforeCursor: containerMatch[2],\n }\n : buttonMatch\n ? {\n name: 'button',\n attributesBeforeCursor: buttonMatch[1],\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|iconPosition|linkScope|newTab|size|stack|stepTheme|tabTheme|variant)=[\"']?([^\"'\\s}]*)$/,\n )\n\n if (valueMatch) {\n const [, attribute, typedValue] = valueMatch\n const options = getDirectiveThemeValueCompletionOptions(name, attribute)\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 buttonMatch = previousLine.match(/^\\s*::button(?:\\[[^\\]]*\\])?\\s*\\{/)\n if (buttonMatch)\n return {\n name: 'button',\n attributesBeforeCursor,\n }\n }\n\n return null\n}\n\nfunction directiveCompletionSource(context: CompletionContext) {\n const attributeResult = attributeCompletionSource(context)\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\nexport const directiveCompletions = autocompletion({\n activateOnTyping: true,\n override: [directiveCompletionSource],\n})\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","groupName","themeAttributes","attributeValues","value","themeName","attributeCompletionSource","context","line","state","doc","lineAt","pos","beforeCursor","text","slice","from","containerMatch","match","buttonMatch","multilineMatch","findOpenDirectiveAttributeBlock","directiveMatch","attributesBeforeCursor","valueMatch","typedValue","options","length","attributeMatch","typedAttribute","explicit","lineNumber","number","previousLine","trimmed","trim","includes","directiveCompletionSource","attributeResult","leafMatch","matchBefore","beforeLeaf","typedLeaf","to","filter","option","directiveCompletions","activateOnTyping","override"],"mappings":"AAEA,SAASA,cAAc,EAAEC,iBAAiB,QAAQ,2BAA0B;AAE5E,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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AAI,CAAC0B,UAAUzD,UAAU,CAAC,UAAU,CAACwD,WAAWN,IAAI,IAClD,OAAO;YACLnB,MAAMuB,UAAUvB,IAAI;YACpBU,SAAS/C,gCAAgCiE,MAAM,CAAC,CAACC,SAC/C,OAAOA,OAAO9D,KAAK,KAAK,WACpB8D,OAAO9D,KAAK,CAACE,UAAU,CAAC,SAAS,CAAC4D,OAAO9D,KAAK,CAACE,UAAU,CAAC,SAC1D;QAER;IACJ;IAEA,MAAMiC,QAAQX,QAAQiC,WAAW,CAAC;IAElC,IAAI,CAACtB,OAAO,OAAO;IACnB,IAAIA,MAAMF,IAAI,KAAKE,MAAMyB,EAAE,IAAI,CAACpC,QAAQuB,QAAQ,EAAE,OAAO;IAEzD,OAAO;QACLd,MAAME,MAAMF,IAAI;QAChBU,SAAS/C,gCAAgCiE,MAAM,CAAC,CAACC,SAC/C,OAAOA,OAAO9D,KAAK,KAAK,WAAW8D,OAAO9D,KAAK,CAACE,UAAU,CAAC,SAAS;IAExE;AACF;AAEA,OAAO,MAAM6D,uBAAuBvE,eAAe;IACjDwE,kBAAkB;IAClBC,UAAU;QAACX;KAA0B;AACvC,GAAE"}
@@ -2,6 +2,7 @@ import { markdown } from '@codemirror/lang-markdown';
2
2
  import { HighlightStyle, syntaxHighlighting } from '@codemirror/language';
3
3
  import { EditorView } from '@codemirror/view';
4
4
  import { tags as t, Tag } from '@lezer/highlight';
5
+ import { hasUnclosedDirectiveAttributeBlock } from '../../directives/attributes.js';
5
6
  import { supportedLangHighlight } from './support/highlighters.js';
6
7
  import { languages } from './support/lang.js';
7
8
  const activeLine = '#6699ff0b', bracketMatch = '#bad0f847', chalky = '#e5c07b', coral = '#e06c75', cursor = '#a5edff', cyan = '#56b6c2', highlightBackground = '#2c313a', invalid = '#ff6b81', ivory = '#c4c9d5', malibu = '#61afef', sage = '#98c379', searchMatch = '#72a1ff59', searchMatchOutline = '#457dff', selection = '#ffffff', selectionBackground = '#3E4451', selectionMatch = '#aafe661a', stone = '#7d8799', tooltipBackground = '#353a42', violet = '#e47cd2', whiskey = '#d19a66';
@@ -106,6 +107,11 @@ export const payloadTheme = EditorView.theme({
106
107
  });
107
108
  // Keep custom directive highlighting compatible with keyword semantics
108
109
  const mdQualifierTag = Tag.define(t.keyword);
110
+ const mdLeafDirectiveTag = Tag.define(t.keyword);
111
+ const mdDirectiveArgNameTag = Tag.define(t.propertyName);
112
+ const mdDirectiveArgValueTag = Tag.define(t.string);
113
+ const mdDirectiveBraceTag = Tag.define(t.separator);
114
+ const mdDirectiveLabelTag = Tag.define(t.labelName);
109
115
  export const payloadHighlightStyle = HighlightStyle.define([
110
116
  // Directives + language keywords
111
117
  {
@@ -115,6 +121,26 @@ export const payloadHighlightStyle = HighlightStyle.define([
115
121
  t.keyword
116
122
  ]
117
123
  },
124
+ {
125
+ color: '#d7a7df',
126
+ tag: mdLeafDirectiveTag
127
+ },
128
+ {
129
+ color: coral,
130
+ tag: mdDirectiveArgNameTag
131
+ },
132
+ {
133
+ color: sage,
134
+ tag: mdDirectiveArgValueTag
135
+ },
136
+ {
137
+ color: stone,
138
+ tag: mdDirectiveBraceTag
139
+ },
140
+ {
141
+ color: malibu,
142
+ tag: mdDirectiveLabelTag
143
+ },
118
144
  // Names / identifiers that should read warm
119
145
  {
120
146
  color: coral,
@@ -228,27 +254,189 @@ export const payloadHighlightStyle = HighlightStyle.define([
228
254
  tag: t.invalid
229
255
  }
230
256
  ]);
257
+ function isDirectiveLine(line) {
258
+ return line.text.slice(line.pos).startsWith(':::');
259
+ }
260
+ function isLeafDirectiveLine(line) {
261
+ return /^::button(?:$|[\s[{])/.test(line.text.slice(line.pos));
262
+ }
263
+ function skipInlineSpace(text, index) {
264
+ let next = index;
265
+ while(next < text.length && /\s/.test(text[next]))++next;
266
+ return next;
267
+ }
268
+ function parseQuotedValue(cx, text, lineStart, index) {
269
+ const quote = text[index];
270
+ let end = index + 1;
271
+ while(end < text.length){
272
+ if (text[end] === '\\') {
273
+ end += 2;
274
+ continue;
275
+ }
276
+ if (text[end] === quote) {
277
+ end += 1;
278
+ break;
279
+ }
280
+ ++end;
281
+ }
282
+ return {
283
+ elements: [
284
+ cx.elt('DirectiveAttributeValue', lineStart + index, lineStart + end)
285
+ ],
286
+ index: end
287
+ };
288
+ }
289
+ function parseBareValue(cx, text, lineStart, index) {
290
+ let end = index;
291
+ while(end < text.length && !/[\s}]/.test(text[end]))++end;
292
+ return end > index ? {
293
+ elements: [
294
+ cx.elt('DirectiveAttributeValue', lineStart + index, lineStart + end)
295
+ ],
296
+ index: end
297
+ } : {
298
+ elements: [],
299
+ index
300
+ };
301
+ }
302
+ function parseAttributeElements(cx, text, lineStart, startIndex) {
303
+ const elements = [];
304
+ let index = startIndex;
305
+ while(index < text.length){
306
+ const char = text[index];
307
+ if (char === '{' || char === '}') {
308
+ elements.push(cx.elt('DirectiveBrace', lineStart + index, lineStart + index + 1));
309
+ ++index;
310
+ continue;
311
+ }
312
+ if (/\s/.test(char)) {
313
+ ++index;
314
+ continue;
315
+ }
316
+ if (/[\w-]/.test(char)) {
317
+ const nameStart = index;
318
+ while(index < text.length && /[\w-]/.test(text[index]))++index;
319
+ const nameEnd = index;
320
+ const equalsIndex = skipInlineSpace(text, index);
321
+ if (text[equalsIndex] !== '=') continue;
322
+ elements.push(cx.elt('DirectiveAttributeName', lineStart + nameStart, lineStart + nameEnd));
323
+ index = skipInlineSpace(text, equalsIndex + 1);
324
+ if (text[index] === '"' || text[index] === "'") {
325
+ const parsed = parseQuotedValue(cx, text, lineStart, index);
326
+ elements.push(...parsed.elements);
327
+ index = parsed.index;
328
+ continue;
329
+ }
330
+ const parsed = parseBareValue(cx, text, lineStart, index);
331
+ elements.push(...parsed.elements);
332
+ index = parsed.index;
333
+ continue;
334
+ }
335
+ ++index;
336
+ }
337
+ return elements;
338
+ }
339
+ function parseDirectiveLineElements(cx, line, leaf) {
340
+ const text = line.text;
341
+ const start = line.pos;
342
+ const lineStart = cxLineStart(cx);
343
+ const directiveMatch = text.slice(start).match(leaf ? /^::button(?=$|[\s[{])/ : /^:::[\w-]*/);
344
+ const directiveText = directiveMatch?.[0]?.trimEnd();
345
+ if (!directiveText) return [];
346
+ const nameTo = start + directiveText.length;
347
+ const elements = [
348
+ cx.elt(leaf ? 'LeafDirectiveName' : 'DirectiveName', lineStart + start, lineStart + nameTo)
349
+ ];
350
+ let cursor = skipInlineSpace(text, nameTo);
351
+ if (text[cursor] === '[') {
352
+ const labelEnd = text.indexOf(']', cursor + 1);
353
+ if (labelEnd >= 0) {
354
+ elements.push(cx.elt('DirectiveLabel', lineStart + cursor, lineStart + labelEnd + 1));
355
+ cursor = skipInlineSpace(text, labelEnd + 1);
356
+ }
357
+ }
358
+ const braceIndex = text.indexOf('{', cursor);
359
+ if (braceIndex >= 0) elements.push(...parseAttributeElements(cx, text, lineStart, braceIndex));
360
+ return elements;
361
+ }
362
+ function parseDirectiveAttributeContinuationElements(cx, line) {
363
+ return parseAttributeElements(cx, line.text, cxLineStart(cx), line.pos);
364
+ }
365
+ function cxLineStart(cx) {
366
+ return cx.lineStart;
367
+ }
368
+ function addDirectiveBlock(cx, line, blockName, leaf) {
369
+ const from = cx.lineStart + line.pos;
370
+ const children = parseDirectiveLineElements(cx, line, leaf);
371
+ let collectedText = line.text.slice(line.pos);
372
+ let to = cx.lineStart + line.text.length;
373
+ while(hasUnclosedDirectiveAttributeBlock(collectedText)){
374
+ if (cx.peekLine().trim().startsWith('::')) break;
375
+ if (!cx.nextLine()) break;
376
+ collectedText += `\n${line.text}`;
377
+ to = cx.lineStart + line.text.length;
378
+ children.push(...parseDirectiveAttributeContinuationElements(cx, line));
379
+ }
380
+ cx.addElement(cx.elt(blockName, from, to, children));
381
+ cx.nextLine();
382
+ }
231
383
  const directiveBlock = {
232
384
  defineNodes: [
233
385
  {
234
386
  name: 'DirectiveLine',
235
- block: true,
387
+ block: true
388
+ },
389
+ {
390
+ name: 'LeafDirectiveLine',
391
+ block: true
392
+ },
393
+ {
394
+ name: 'DirectiveName',
236
395
  style: mdQualifierTag
396
+ },
397
+ {
398
+ name: 'LeafDirectiveName',
399
+ style: mdLeafDirectiveTag
400
+ },
401
+ {
402
+ name: 'DirectiveLabel',
403
+ style: mdDirectiveLabelTag
404
+ },
405
+ {
406
+ name: 'DirectiveAttributeName',
407
+ style: mdDirectiveArgNameTag
408
+ },
409
+ {
410
+ name: 'DirectiveAttributeValue',
411
+ style: mdDirectiveArgValueTag
412
+ },
413
+ {
414
+ name: 'DirectiveBrace',
415
+ style: mdDirectiveBraceTag
237
416
  }
238
417
  ],
239
418
  parseBlock: [
419
+ {
420
+ name: 'LeafDirectiveLine',
421
+ before: 'HTMLBlock',
422
+ endLeaf (_cx, line) {
423
+ return isLeafDirectiveLine(line);
424
+ },
425
+ parse (cx, line) {
426
+ if (!isLeafDirectiveLine(line)) return false;
427
+ addDirectiveBlock(cx, line, 'LeafDirectiveLine', true);
428
+ return true;
429
+ }
430
+ },
240
431
  {
241
432
  name: 'DirectiveLine',
242
433
  before: 'HTMLBlock',
243
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
434
+ endLeaf (_cx, line) {
435
+ return isDirectiveLine(line);
436
+ },
244
437
  parse (cx, line) {
245
- const startInLine = line.pos;
246
- const text = line.text.slice(startInLine);
247
- if (!text.startsWith(':::')) return false;
248
- const from = cx.lineStart + startInLine;
249
- const to = cx.lineStart + line.text.length;
250
- cx.addElement(cx.elt('DirectiveLine', from, to));
251
- cx.nextLine();
438
+ if (!isDirectiveLine(line)) return false;
439
+ addDirectiveBlock(cx, line, 'DirectiveLine', false);
252
440
  return true;
253
441
  }
254
442
  }
@@ -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 { 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)\n\nexport const payloadHighlightStyle = HighlightStyle.define([\n // Directives + language keywords\n { color: violet, tag: [mdQualifierTag, t.keyword] },\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\nconst directiveBlock = {\n defineNodes: [\n {\n name: 'DirectiveLine',\n block: true,\n style: mdQualifierTag,\n },\n ],\n\n parseBlock: [\n {\n name: 'DirectiveLine',\n before: 'HTMLBlock',\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n parse(cx: any, line: any) {\n const startInLine = line.pos\n const text = line.text.slice(startInLine)\n\n if (!text.startsWith(':::')) return false\n\n const from = cx.lineStart + startInLine\n const to = cx.lineStart + line.text.length\n\n cx.addElement(cx.elt('DirectiveLine', from, to))\n cx.nextLine()\n\n return true\n },\n },\n ],\n}\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","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","payloadHighlightStyle","tag","name","deleted","character","propertyName","macroName","function","variableName","labelName","constant","standard","atom","bool","special","definition","separator","typeName","className","number","changed","annotation","modifier","self","namespace","operator","operatorKeyword","url","escape","regexp","link","string","meta","comment","fontWeight","strong","fontStyle","emphasis","strikethrough","textDecoration","heading","processingInstruction","inserted","directiveBlock","defineNodes","block","style","parseBlock","before","parse","cx","line","startInLine","pos","text","slice","startsWith","from","lineStart","to","length","addElement","elt","nextLine","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,sBAAsB,QAAQ,4BAA2B;AAClE,SAASC,SAAS,QAAQ,oBAAmB;AAE7C,MAAMC,aAAa,aACjBC,eAAe,aACfC,SAAS,WACTC,QAAQ,WACRC,SAAS,WACTC,OAAO,WACPC,sBAAsB,WACtBC,UAAU,WACVC,QAAQ,WACRC,SAAS,WACTC,OAAO,WACPC,cAAc,aACdC,qBAAqB,WACrBC,YAAY,WACZC,sBAAsB,WACtBC,iBAAiB,aACjBC,QAAQ,WACRC,oBAAoB,WACpBC,SAAS,WACTC,UAAU;AAEZ,OAAO,MAAMC,QAAQ;IACnBpB;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;AACF,EAAC;AAED,OAAO,MAAME,eAAe3B,WAAW4B,KAAK,CAC1C;IACE,KAAK;QACHC,iBAAiB;QACjBH,OAAOZ;QACPgB,UAAU;IACZ;IAEA,eAAe;QACbC,YAAYrB;QACZsB,SAAS;IACX;IAEA,gBAAgB;QACdC,YAAY;IACd;IAEA,8BAA8B;QAC5BC,iBAAiBxB;IACnB;IAEA,2BAA2B;QACzBmB,iBAAiBT;IACnB;IAEA,2BAA2B;QACzBS,iBAAiBT;QACjBM,OAAOP;IACT;IAEA,oDAAoD;QAClDO,OAAOP;IACT;IAEA,kBAAkB;QAChBU,iBAAiBvB;IACnB;IAEA,sBAAsB;QACpBuB,iBAAiBR;IACnB;IAEA,yEAAyE;QACvEQ,iBAAiBtB;IACnB;IA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sD;IACtD;QAAEzD,OAAOV;QAAM4B,KAAK;YAAC1C,EAAEkF,qBAAqB;YAAElF,EAAEwE,MAAM;YAAExE,EAAEmF,QAAQ;SAAC;IAAC;IAEpE,4CAA4C;IAC5C;QAAE3D,OAAOb;QAAS+B,KAAK1C,EAAEW,OAAO;IAAC;CAClC,EAAC;AAEF,MAAMyE,iBAAiB;IACrBC,aAAa;QACX;YACE1C,MAAM;YACN2C,OAAO;YACPC,OAAOjD;QACT;KACD;IAEDkD,YAAY;QACV;YACE7C,MAAM;YACN8C,QAAQ;YACR,8DAA8D;YAC9DC,OAAMC,EAAO,EAAEC,IAAS;gBACtB,MAAMC,cAAcD,KAAKE,GAAG;gBAC5B,MAAMC,OAAOH,KAAKG,IAAI,CAACC,KAAK,CAACH;gBAE7B,IAAI,CAACE,KAAKE,UAAU,CAAC,QAAQ,OAAO;gBAEpC,MAAMC,OAAOP,GAAGQ,SAAS,GAAGN;gBAC5B,MAAMO,KAAKT,GAAGQ,SAAS,GAAGP,KAAKG,IAAI,CAACM,MAAM;gBAE1CV,GAAGW,UAAU,CAACX,GAAGY,GAAG,CAAC,iBAAiBL,MAAME;gBAC5CT,GAAGa,QAAQ;gBAEX,OAAO;YACT;QACF;KACD;AACH;AAEA,OAAO,MAAMC,uBAAkC;IAC7ChF;IACA5B,mBAAmB4C;OAChBvC;IACHP,SAAS;QACP+G,eAAevG;QACfwG,YAAY;YAACvB;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 { 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\nfunction isLeafDirectiveLine(line: MarkdownLine): boolean {\n return /^::button(?:$|[\\s[{])/.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.slice(start).match(leaf ? /^::button(?=$|[\\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","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","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,sBAAsB,QAAQ,4BAA2B;AAClE,SAASC,SAAS,QAAQ,oBAAmB;AAE7C,MAAMC,aAAa,aACjBC,eAAe,aACfC,SAAS,WACTC,QAAQ,WACRC,SAAS,WACTC,OAAO,WACPC,sBAAsB,WACtBC,UAAU,WACVC,QAAQ,WACRC,SAAS,WACTC,OAAO,WACPC,cAAc,aACdC,qBAAqB,WACrBC,YAAY,WACZC,sBAAsB,WACtBC,iBAAiB,aACjBC,QAAQ,WACRC,oBAAoB,WACpBC,SAAS,WACTC,UAAU;AAEZ,OAAO,MAAMC,QAAQ;IACnBpB;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;AACF,EAAC;AAED,OAAO,MAAME,eAAe5B,WAAW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AEnCwC,kBAAkB5B,IAAIZ,MAAM,iBAAiB;gBAE7C,OAAO;YACT;QACF;KACD;AACH;AAEA,OAAO,MAAM2D,uBAAkC;IAC7C5H;IACA7B,mBAAmBsD;OAChBhD;IACHR,SAAS;QACP4J,eAAenJ;QACfoJ,YAAY;YAACX;SAAe;IAC9B;CACD,CAAA"}
@@ -1,3 +1,4 @@
1
1
  export { vlMdCodeBlockConfig } from '../field/CodeBlockConfig/config.js';
2
2
  export { vlMdConfig } from '../field/Config/config.js';
3
3
  export { vlMdTailwindField } from '../field/Tailwind/config.js';
4
+ export { createPayloadMarkdownIconRegistryEntry, createPayloadMarkdownIconRegistrySource, } from '../icons/generateRegistry.js';
@@ -1,5 +1,6 @@
1
1
  export { vlMdCodeBlockConfig } from '../field/CodeBlockConfig/config.js';
2
2
  export { vlMdConfig } from '../field/Config/config.js';
3
3
  export { vlMdTailwindField } from '../field/Tailwind/config.js';
4
+ export { createPayloadMarkdownIconRegistryEntry, createPayloadMarkdownIconRegistrySource } from '../icons/generateRegistry.js';
4
5
 
5
6
  //# sourceMappingURL=advanced.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/exports/advanced.ts"],"sourcesContent":["export { vlMdCodeBlockConfig } from '../field/CodeBlockConfig/config.js'\nexport { vlMdConfig } from '../field/Config/config.js'\nexport { vlMdTailwindField } from '../field/Tailwind/config.js'\n"],"names":["vlMdCodeBlockConfig","vlMdConfig","vlMdTailwindField"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,qCAAoC;AACxE,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,iBAAiB,QAAQ,8BAA6B"}
1
+ {"version":3,"sources":["../../src/exports/advanced.ts"],"sourcesContent":["export { vlMdCodeBlockConfig } from '../field/CodeBlockConfig/config.js'\nexport { vlMdConfig } from '../field/Config/config.js'\nexport { vlMdTailwindField } from '../field/Tailwind/config.js'\nexport {\n createPayloadMarkdownIconRegistryEntry,\n createPayloadMarkdownIconRegistrySource,\n} from '../icons/generateRegistry.js'\n"],"names":["vlMdCodeBlockConfig","vlMdConfig","vlMdTailwindField","createPayloadMarkdownIconRegistryEntry","createPayloadMarkdownIconRegistrySource"],"mappings":"AAAA,SAASA,mBAAmB,QAAQ,qCAAoC;AACxE,SAASC,UAAU,QAAQ,4BAA2B;AACtD,SAASC,iBAAiB,QAAQ,8BAA6B;AAC/D,SACEC,sCAAsC,EACtCC,uCAAuC,QAClC,+BAA8B"}
@@ -0,0 +1,8 @@
1
+ import type { PayloadMarkdownIconsConfig } from '../types/core.js';
2
+ type IconRegistryEntry = {
3
+ importPath: string;
4
+ key: string;
5
+ };
6
+ export declare function createPayloadMarkdownIconRegistrySource(entries: IconRegistryEntry[]): string;
7
+ export declare function createPayloadMarkdownIconRegistryEntry(config: PayloadMarkdownIconsConfig, packAlias: string, iconPath: string): IconRegistryEntry | undefined;
8
+ export {};