payload-markdown 1.8.1 → 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.
- package/dist/core/plugins/remarkCompileLayouts.js.map +1 -1
- package/dist/core/plugins/remarkDirectiveLines.d.ts +7 -5
- package/dist/core/plugins/remarkDirectiveLines.js +29 -18
- package/dist/core/plugins/remarkDirectiveLines.js.map +1 -1
- package/dist/core/plugins/remarkLayoutDirectives.js +1 -1
- package/dist/core/plugins/remarkLayoutDirectives.js.map +1 -1
- package/dist/core/plugins/remarkValidateDirectiveThemes.js +7 -14
- package/dist/core/plugins/remarkValidateDirectiveThemes.js.map +1 -1
- package/dist/core/renderMarkdown.js +2 -231
- package/dist/core/renderMarkdown.js.map +1 -1
- package/dist/core/sanitizeSchema.d.ts +11 -0
- package/dist/core/sanitizeSchema.js +176 -0
- package/dist/core/sanitizeSchema.js.map +1 -0
- package/dist/directives/definitions/badge.d.ts +5 -2
- package/dist/directives/definitions/badge.js +138 -10
- package/dist/directives/definitions/badge.js.map +1 -1
- package/dist/directives/definitions/badges.d.ts +1 -2
- package/dist/directives/definitions/badges.js +12 -3
- package/dist/directives/definitions/badges.js.map +1 -1
- package/dist/directives/definitions/button.d.ts +6 -2
- package/dist/directives/definitions/button.js +202 -12
- package/dist/directives/definitions/button.js.map +1 -1
- package/dist/directives/definitions/buttons.d.ts +1 -2
- package/dist/directives/definitions/buttons.js +12 -3
- package/dist/directives/definitions/buttons.js.map +1 -1
- package/dist/directives/definitions/callout.d.ts +1 -2
- package/dist/directives/definitions/callout.js +37 -3
- package/dist/directives/definitions/callout.js.map +1 -1
- package/dist/directives/definitions/card.d.ts +6 -2
- package/dist/directives/definitions/card.js +51 -3
- package/dist/directives/definitions/card.js.map +1 -1
- package/dist/directives/definitions/cards.d.ts +1 -2
- package/dist/directives/definitions/cards.js +40 -4
- package/dist/directives/definitions/cards.js.map +1 -1
- package/dist/directives/definitions/cell.d.ts +2 -2
- package/dist/directives/definitions/cell.js +9 -3
- package/dist/directives/definitions/cell.js.map +1 -1
- package/dist/directives/definitions/columns.d.ts +3 -4
- package/dist/directives/definitions/columns.js +17 -3
- package/dist/directives/definitions/columns.js.map +1 -1
- package/dist/directives/definitions/details.d.ts +1 -2
- package/dist/directives/definitions/details.js +24 -3
- package/dist/directives/definitions/details.js.map +1 -1
- package/dist/directives/definitions/section.d.ts +1 -2
- package/dist/directives/definitions/section.js +22 -3
- package/dist/directives/definitions/section.js.map +1 -1
- package/dist/directives/definitions/steps.d.ts +1 -2
- package/dist/directives/definitions/steps.js +22 -3
- package/dist/directives/definitions/steps.js.map +1 -1
- package/dist/directives/definitions/tab.d.ts +8 -2
- package/dist/directives/definitions/tab.js +45 -3
- package/dist/directives/definitions/tab.js.map +1 -1
- package/dist/directives/definitions/tabs.d.ts +1 -1
- package/dist/directives/definitions/tabs.js +40 -3
- package/dist/directives/definitions/tabs.js.map +1 -1
- package/dist/directives/definitions/toc.d.ts +1 -2
- package/dist/directives/definitions/toc.js +32 -4
- package/dist/directives/definitions/toc.js.map +1 -1
- package/dist/directives/diagnostics.d.ts +2 -15
- package/dist/directives/diagnostics.js +27 -157
- package/dist/directives/diagnostics.js.map +1 -1
- package/dist/directives/lint.d.ts +11 -0
- package/dist/directives/lint.js +33 -0
- package/dist/directives/lint.js.map +1 -0
- package/dist/directives/registry.d.ts +23 -5
- package/dist/directives/registry.js +52 -40
- package/dist/directives/registry.js.map +1 -1
- package/dist/directives/spec.js +25 -51
- package/dist/directives/spec.js.map +1 -1
- package/dist/directives/themeDiagnostics.d.ts +8 -0
- package/dist/directives/themeDiagnostics.js +21 -0
- package/dist/directives/themeDiagnostics.js.map +1 -0
- package/dist/directives/types.d.ts +157 -14
- package/dist/directives/types.js +6 -1
- package/dist/directives/types.js.map +1 -1
- package/dist/editor/directives/completions.js +11 -4
- package/dist/editor/directives/completions.js.map +1 -1
- package/dist/editor/themes/payload.js +2 -1
- package/dist/editor/themes/payload.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/skills/payload-markdown/claude/skill.json +1 -1
- package/skills/payload-markdown/codex/skill.json +1 -1
- package/dist/core/plugins/directiveBadge.d.ts +0 -6
- package/dist/core/plugins/directiveBadge.js +0 -94
- package/dist/core/plugins/directiveBadge.js.map +0 -1
- package/dist/core/plugins/directiveButton.d.ts +0 -6
- package/dist/core/plugins/directiveButton.js +0 -132
- package/dist/core/plugins/directiveButton.js.map +0 -1
- package/dist/directives/buttonSyntax.d.ts +0 -7
- package/dist/directives/buttonSyntax.js +0 -6
- package/dist/directives/buttonSyntax.js.map +0 -1
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import type { Element, ElementContent } from 'hast';
|
|
2
2
|
import type { ContainerDirective, LeafDirective } from 'mdast-util-directive';
|
|
3
3
|
import type { Data } from 'unist';
|
|
4
|
-
import type { MarkdownRenderConfig } from '../types/core.js';
|
|
4
|
+
import type { MarkdownDirectiveThemes, MarkdownRenderConfig } from '../types/core.js';
|
|
5
|
+
import type { directiveDefinitions } from './registry.js';
|
|
5
6
|
import type { DirectiveThemeGroupName, ResolvedDirectiveTheme } from './themes.js';
|
|
6
|
-
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
9
|
-
export type GridDirectiveName =
|
|
7
|
+
type RegisteredDefinition = (typeof directiveDefinitions)[number];
|
|
8
|
+
export type MarkdownDirectiveName = RegisteredDefinition['name'];
|
|
9
|
+
export type LayoutDirectiveKind = RegisteredDefinition['kind'];
|
|
10
|
+
export type GridDirectiveName = Extract<RegisteredDefinition, {
|
|
11
|
+
kind: 'grid';
|
|
12
|
+
}>['name'];
|
|
13
|
+
/** Structural layout directives (sections, grids and their cells). */
|
|
14
|
+
export type LayoutDirectiveName = Extract<RegisteredDefinition, {
|
|
15
|
+
kind: 'cell' | 'grid' | 'section';
|
|
16
|
+
}>['name'];
|
|
17
|
+
export type StaticDirectiveName = Exclude<MarkdownDirectiveName, LayoutDirectiveName>;
|
|
10
18
|
export type LayoutName = MarkdownDirectiveName;
|
|
11
19
|
/** Layout token data: `vlPlace` is the marker's 1-based source position. */
|
|
12
20
|
export type LayoutTokenData = {
|
|
@@ -37,10 +45,8 @@ export type LayoutToken = {
|
|
|
37
45
|
};
|
|
38
46
|
export type DirectiveChild = ContainerDirective['children'][number];
|
|
39
47
|
export type MarkdownDirectiveNode = ContainerDirective | LeafDirective;
|
|
40
|
-
export type LayoutDirectiveKind = 'badge' | 'badges' | 'button' | 'buttons' | 'callout' | 'card' | 'cards' | 'cell' | 'details' | 'grid' | 'section' | 'steps' | 'tab' | 'tabs' | 'toc';
|
|
41
|
-
export type LayoutDirectiveRenderTagName = 'a' | 'article' | 'details' | 'div' | 'img' | 'nav' | 'section';
|
|
42
48
|
export type LayoutDirectiveTransformContext = {
|
|
43
|
-
isSupportedDirectiveName: (name: string) =>
|
|
49
|
+
isSupportedDirectiveName: (name: string) => boolean;
|
|
44
50
|
};
|
|
45
51
|
export type LayoutDirectiveClassHelpers = {
|
|
46
52
|
groupChildrenIntoCells: (children: ElementContent[], columnClassName?: string, cellTheme?: ResolvedDirectiveTheme) => ElementContent[];
|
|
@@ -65,24 +71,161 @@ export type LayoutDirectiveEditorMetadata = {
|
|
|
65
71
|
};
|
|
66
72
|
export type DirectiveValidationContext = {
|
|
67
73
|
attributes: Record<string, boolean | string>;
|
|
68
|
-
name:
|
|
74
|
+
name: string;
|
|
69
75
|
};
|
|
70
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Attribute types the directive spec cannot infer. An attribute listed in
|
|
78
|
+
* `attributeValues` is an enum (a boolean when its values are exactly `true`
|
|
79
|
+
* and `false`), one listed in `themeAttributes` names a theme; everything
|
|
80
|
+
* else is a plain string unless declared here.
|
|
81
|
+
*/
|
|
82
|
+
export type DirectiveAttributeTypeDeclaration = {
|
|
83
|
+
max?: number;
|
|
84
|
+
min?: number;
|
|
85
|
+
type: 'number';
|
|
86
|
+
} | {
|
|
87
|
+
type: 'boolean';
|
|
88
|
+
}
|
|
89
|
+
/** An enum the definition validates in code (its values are not offered as editor completions). */
|
|
90
|
+
| {
|
|
91
|
+
type: 'enum';
|
|
92
|
+
values: readonly string[];
|
|
93
|
+
}
|
|
94
|
+
/** One `@pack/name` icon ref, or a comma-separated list of entries that may add `palette=<name>`. */
|
|
95
|
+
| {
|
|
96
|
+
type: 'icon';
|
|
97
|
+
}
|
|
98
|
+
/** A palette name (built-in, configured, or managed in the admin). */
|
|
99
|
+
| {
|
|
100
|
+
type: 'palette';
|
|
101
|
+
}
|
|
102
|
+
/** A link target, protocol-checked like Markdown links. */
|
|
103
|
+
| {
|
|
104
|
+
type: 'url';
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Element properties (hast names, per tag name) that the directive's mdast
|
|
108
|
+
* stage emits and rehype-sanitize must keep. The registry adds the
|
|
109
|
+
* directive's own `tagName` with `dataVlLayout` for directives that carry the
|
|
110
|
+
* layout marker, and the sanitize schema is the base allowlist plus these.
|
|
111
|
+
* Elements built in `applyHast` run after sanitizing and need no entry.
|
|
112
|
+
*/
|
|
113
|
+
export type DirectiveSanitizeAllowlist = Readonly<Partial<Record<string, readonly string[]>>>;
|
|
114
|
+
/** Receives the diagnostics of a leaf builder. */
|
|
115
|
+
export type DirectiveMessageSink = {
|
|
116
|
+
message: (reason: string) => unknown;
|
|
117
|
+
};
|
|
118
|
+
/** Options of the editor linter (`lintMarkdownDirectives`). */
|
|
119
|
+
export type LintMarkdownDirectivesOptions = {
|
|
120
|
+
/**
|
|
121
|
+
* Configured icon pack aliases. When provided, icon refs to other packs are
|
|
122
|
+
* reported exactly like the renderer does ("Unknown icon pack").
|
|
123
|
+
*/
|
|
124
|
+
iconPacks?: readonly string[];
|
|
125
|
+
/**
|
|
126
|
+
* Known palette names. When provided, unknown `palette` / `iconPalette`
|
|
127
|
+
* values and icon-entry palettes are reported like the renderer does.
|
|
128
|
+
*/
|
|
129
|
+
palettes?: readonly string[];
|
|
130
|
+
/** Configured directive themes (names are what matters). */
|
|
131
|
+
themes?: MarkdownDirectiveThemes;
|
|
132
|
+
};
|
|
133
|
+
/** Close markers the directive grammar knows; see `layoutDirectiveRegistry.closeMarkers`. */
|
|
134
|
+
export type DirectiveCloseMarker = ':::' | ':::end' | ':::endcol' | ':::endsection';
|
|
135
|
+
/** The `:::name[label]{attributes}` … `:::` form. */
|
|
136
|
+
export type DirectiveContainerForm = {
|
|
137
|
+
/** Editor close-label text shown after a generic `:::` closer (default `end<name>`). */
|
|
138
|
+
closeLabel?: string;
|
|
139
|
+
/** Markers that close the directive (default `[':::']`). */
|
|
140
|
+
closeMarkers?: readonly DirectiveCloseMarker[];
|
|
141
|
+
/** Attribute that the `[label]` stands for; both given and different is reported. */
|
|
142
|
+
labelAttribute?: string;
|
|
143
|
+
};
|
|
144
|
+
/** The `::name[label]{attributes}` form: one line (attributes may span lines). */
|
|
145
|
+
export type DirectiveLeafForm = {
|
|
146
|
+
/**
|
|
147
|
+
* Builds the leaf directive node for a directive line the scanner found,
|
|
148
|
+
* reporting problems to `sink`. `undefined` leaves the line as text.
|
|
149
|
+
*/
|
|
150
|
+
build: (line: string, sink: DirectiveMessageSink, config: MarkdownRenderConfig) => LeafDirective | undefined;
|
|
151
|
+
/** Editor diagnostics for the same line; must cover what `build` reports. */
|
|
152
|
+
lint: (line: string, options: LintMarkdownDirectivesOptions) => string[];
|
|
153
|
+
/**
|
|
154
|
+
* Give the built element the layout marker (`data-vl-layout`), so the
|
|
155
|
+
* definition's `applyHast` runs on it after sanitizing. Leave it off when
|
|
156
|
+
* `build` emits the final element.
|
|
157
|
+
*/
|
|
158
|
+
marker?: boolean;
|
|
159
|
+
};
|
|
160
|
+
/** A container directive the editor linter is tracking. */
|
|
161
|
+
export type DirectiveLintFrame = {
|
|
162
|
+
from: number;
|
|
163
|
+
/** Something other than a directive marker was seen inside the frame. */
|
|
164
|
+
hasContent?: boolean;
|
|
165
|
+
line: number;
|
|
166
|
+
name: string;
|
|
167
|
+
/** Heading depth a grid was opened under (grids only). */
|
|
168
|
+
parentHeadingDepth?: number;
|
|
169
|
+
/** Directive-specific state owned by the definition's lint hooks. */
|
|
170
|
+
state?: unknown;
|
|
171
|
+
};
|
|
172
|
+
export type DirectiveLintOpenContext = {
|
|
173
|
+
attributes: Record<string, boolean | string>;
|
|
174
|
+
/** The frame being opened; hooks may set `frame.state`. */
|
|
175
|
+
frame: DirectiveLintFrame;
|
|
176
|
+
label?: string;
|
|
177
|
+
/** Frames open before this one, innermost last. */
|
|
178
|
+
stack: readonly DirectiveLintFrame[];
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* Nesting checks for the editor linter, which reads the document as a stream
|
|
182
|
+
* of markers. They mirror what `validateMdast` reports on the compiled tree.
|
|
183
|
+
*/
|
|
184
|
+
export type DirectiveLintHooks = {
|
|
185
|
+
/** Diagnostics when the frame closes (explicitly, by a parent closing, or at the end). */
|
|
186
|
+
close?: (frame: DirectiveLintFrame) => string[];
|
|
187
|
+
/** Diagnostics when the directive opens. */
|
|
188
|
+
open?: (context: DirectiveLintOpenContext) => string[];
|
|
189
|
+
};
|
|
190
|
+
export type LayoutDirectiveDefinition<Name extends string = string, Kind extends string = string> = {
|
|
191
|
+
/** Attribute names, in suggestion order ("Did you mean …?" prefers earlier names). */
|
|
71
192
|
allowedAttributes?: readonly string[];
|
|
72
193
|
applyHast?: (node: Element, config: MarkdownRenderConfig, helpers: LayoutDirectiveClassHelpers) => void;
|
|
194
|
+
/** Types not implied by `attributeValues` or `themeAttributes` (see the type). */
|
|
195
|
+
attributeTypes?: Partial<Record<string, DirectiveAttributeTypeDeclaration>>;
|
|
196
|
+
/** Values the editor offers; also makes the attribute an enum (or boolean) in the spec. */
|
|
73
197
|
attributeValues?: Partial<Record<string, readonly string[]>>;
|
|
198
|
+
/** The container form; a directive has a container form, a leaf form, or both. */
|
|
199
|
+
container?: DirectiveContainerForm;
|
|
74
200
|
defaultAttributes?: Record<string, string>;
|
|
75
201
|
description?: string;
|
|
76
202
|
editor: LayoutDirectiveEditorMetadata;
|
|
77
203
|
getMdastRenderProperties?: (node: ContainerDirective) => Record<string, unknown>;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
204
|
+
/** `grid`, `section` and `cell` drive layout compilation; other kinds are the name. */
|
|
205
|
+
kind: Kind;
|
|
206
|
+
/** The leaf form. */
|
|
207
|
+
leaf?: DirectiveLeafForm;
|
|
208
|
+
/** Editor-linter nesting checks (container form). */
|
|
209
|
+
lint?: DirectiveLintHooks;
|
|
210
|
+
name: Name;
|
|
81
211
|
public?: boolean;
|
|
212
|
+
sanitize?: DirectiveSanitizeAllowlist;
|
|
82
213
|
supportsAttributes?: boolean;
|
|
83
|
-
|
|
214
|
+
/** Element the directive renders as (the layout marker and `applyHast` target). */
|
|
215
|
+
tagName: string;
|
|
84
216
|
themeAttributes?: Partial<Record<string, DirectiveThemeGroupName>>;
|
|
85
217
|
transformMdast?: (node: ContainerDirective, context: LayoutDirectiveTransformContext) => void;
|
|
218
|
+
/**
|
|
219
|
+
* Extra sentence for an "Unknown theme" diagnostic, for a value that is
|
|
220
|
+
* likely a mix-up (a callout variant given as its theme, say).
|
|
221
|
+
*/
|
|
222
|
+
unknownThemeHint?: (attribute: string, value: string) => string | undefined;
|
|
86
223
|
validateAttributes?: (context: DirectiveValidationContext) => string[];
|
|
87
224
|
validateMdast?: (node: ContainerDirective) => string[];
|
|
88
225
|
};
|
|
226
|
+
/**
|
|
227
|
+
* Declares a directive definition. Only a typing helper: it keeps the
|
|
228
|
+
* literal `name` and `kind`, so the registry can derive its unions.
|
|
229
|
+
*/
|
|
230
|
+
export declare function defineDirective<const Name extends string, const Kind extends string>(definition: LayoutDirectiveDefinition<Name, Kind>): LayoutDirectiveDefinition<Name, Kind>;
|
|
231
|
+
export {};
|
package/dist/directives/types.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Declares a directive definition. Only a typing helper: it keeps the
|
|
3
|
+
* literal `name` and `kind`, so the registry can derive its unions.
|
|
4
|
+
*/ export function defineDirective(definition) {
|
|
5
|
+
return definition;
|
|
6
|
+
}
|
|
2
7
|
|
|
3
8
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/directives/types.ts"],"sourcesContent":["import type { Element, ElementContent } from 'hast'\nimport type { ContainerDirective, LeafDirective } from 'mdast-util-directive'\nimport type { Data } from 'unist'\n\nimport type { MarkdownRenderConfig } from '../types/core.js'\nimport type { DirectiveThemeGroupName, ResolvedDirectiveTheme } from './themes.js'\n\nexport type LayoutDirectiveName = '2col' | '3col' | 'cell' | 'section'\nexport type StaticDirectiveName =\n | 'badge'\n | 'badges'\n | 'button'\n | 'buttons'\n | 'callout'\n | 'card'\n | 'cards'\n | 'details'\n | 'steps'\n | 'tab'\n | 'tabs'\n | 'toc'\nexport type MarkdownDirectiveName = LayoutDirectiveName | StaticDirectiveName\nexport type GridDirectiveName = '2col' | '3col'\nexport type LayoutName = MarkdownDirectiveName\n\n/** Layout token data: `vlPlace` is the marker's 1-based source position. */\nexport type LayoutTokenData = { vlPlace?: { column: number; line: number } } & Data\n\nexport type LayoutToken =\n | {\n action: 'close'\n data?: LayoutTokenData\n type: 'vlLayoutToken'\n }\n | {\n action: 'closeGrid'\n data?: LayoutTokenData\n type: 'vlLayoutToken'\n }\n | {\n action: 'closeSection'\n data?: LayoutTokenData\n type: 'vlLayoutToken'\n }\n | {\n action: 'open'\n attributes?: Record<string, boolean | string>\n data?: LayoutTokenData\n label?: string\n name: LayoutName\n type: 'vlLayoutToken'\n }\n\nexport type DirectiveChild = ContainerDirective['children'][number]\nexport type MarkdownDirectiveNode = ContainerDirective | LeafDirective\n\nexport type LayoutDirectiveKind =\n | 'badge'\n | 'badges'\n | 'button'\n | 'buttons'\n | 'callout'\n | 'card'\n | 'cards'\n | 'cell'\n | 'details'\n | 'grid'\n | 'section'\n | 'steps'\n | 'tab'\n | 'tabs'\n | 'toc'\n\nexport type LayoutDirectiveRenderTagName =\n | 'a'\n | 'article'\n | 'details'\n | 'div'\n | 'img'\n | 'nav'\n | 'section'\n\nexport type LayoutDirectiveTransformContext = {\n isSupportedDirectiveName: (name: string) => name is MarkdownDirectiveName\n}\n\nexport type LayoutDirectiveClassHelpers = {\n groupChildrenIntoCells: (\n children: ElementContent[],\n columnClassName?: string,\n cellTheme?: ResolvedDirectiveTheme,\n ) => ElementContent[]\n mergeClassNames: (...values: Array<string | undefined>) => string[]\n /**\n * Reserves a group of element ids that must stay unique within one render\n * (CORE-20). Returns the bases unchanged when all are free; otherwise every\n * base gets the same smallest free `-n` suffix. Ids already present in the\n * tree (headings, footnotes) are pre-reserved.\n */\n reserveIds: (bases: string[]) => string[]\n}\n\nexport type LayoutDirectiveEditorMetadata = {\n detail?: string\n label: string\n snippet: string\n snippets?: Array<{\n detail?: string\n label: string\n snippet: string\n }>\n}\n\nexport type DirectiveValidationContext = {\n attributes: Record<string, boolean | string>\n name: MarkdownDirectiveName\n}\n\nexport type LayoutDirectiveDefinition = {\n allowedAttributes?: readonly string[]\n applyHast?: (\n node: Element,\n config: MarkdownRenderConfig,\n helpers: LayoutDirectiveClassHelpers,\n ) => void\n attributeValues?: Partial<Record<string, readonly string[]>>\n defaultAttributes?: Record<string, string>\n description?: string\n editor: LayoutDirectiveEditorMetadata\n getMdastRenderProperties?: (node: ContainerDirective) => Record<string, unknown>\n kind: LayoutDirectiveKind\n name: MarkdownDirectiveName\n openMarker?: `:::${string}`\n public?: boolean\n supportsAttributes?: boolean\n tagName: LayoutDirectiveRenderTagName\n themeAttributes?: Partial<Record<string, DirectiveThemeGroupName>>\n transformMdast?: (\n node: ContainerDirective,\n context: LayoutDirectiveTransformContext,\n ) => void\n validateAttributes?: (context: DirectiveValidationContext) => string[]\n validateMdast?: (node: ContainerDirective) => string[]\n}\n"],"names":[],"mappings":"AAsHA,WAyBC"}
|
|
1
|
+
{"version":3,"sources":["../../src/directives/types.ts"],"sourcesContent":["import type { Element, ElementContent } from 'hast'\nimport type { ContainerDirective, LeafDirective } from 'mdast-util-directive'\nimport type { Data } from 'unist'\n\nimport type { MarkdownDirectiveThemes, MarkdownRenderConfig } from '../types/core.js'\nimport type { directiveDefinitions } from './registry.js'\nimport type { DirectiveThemeGroupName, ResolvedDirectiveTheme } from './themes.js'\n\n/*\n * Directive names, kinds and tag names are derived from the registry's\n * definitions (src/directives/registry.ts): adding a definition there is what\n * makes a name valid.\n */\ntype RegisteredDefinition = (typeof directiveDefinitions)[number]\n\nexport type MarkdownDirectiveName = RegisteredDefinition['name']\nexport type LayoutDirectiveKind = RegisteredDefinition['kind']\nexport type GridDirectiveName = Extract<RegisteredDefinition, { kind: 'grid' }>['name']\n/** Structural layout directives (sections, grids and their cells). */\nexport type LayoutDirectiveName = Extract<RegisteredDefinition, { kind: 'cell' | 'grid' | 'section' }>['name']\nexport type StaticDirectiveName = Exclude<MarkdownDirectiveName, LayoutDirectiveName>\nexport type LayoutName = MarkdownDirectiveName\n\n/** Layout token data: `vlPlace` is the marker's 1-based source position. */\nexport type LayoutTokenData = { vlPlace?: { column: number; line: number } } & Data\n\nexport type LayoutToken =\n | {\n action: 'close'\n data?: LayoutTokenData\n type: 'vlLayoutToken'\n }\n | {\n action: 'closeGrid'\n data?: LayoutTokenData\n type: 'vlLayoutToken'\n }\n | {\n action: 'closeSection'\n data?: LayoutTokenData\n type: 'vlLayoutToken'\n }\n | {\n action: 'open'\n attributes?: Record<string, boolean | string>\n data?: LayoutTokenData\n label?: string\n name: LayoutName\n type: 'vlLayoutToken'\n }\n\nexport type DirectiveChild = ContainerDirective['children'][number]\nexport type MarkdownDirectiveNode = ContainerDirective | LeafDirective\n\nexport type LayoutDirectiveTransformContext = {\n isSupportedDirectiveName: (name: string) => boolean\n}\n\nexport type LayoutDirectiveClassHelpers = {\n groupChildrenIntoCells: (\n children: ElementContent[],\n columnClassName?: string,\n cellTheme?: ResolvedDirectiveTheme,\n ) => ElementContent[]\n mergeClassNames: (...values: Array<string | undefined>) => string[]\n /**\n * Reserves a group of element ids that must stay unique within one render\n * (CORE-20). Returns the bases unchanged when all are free; otherwise every\n * base gets the same smallest free `-n` suffix. Ids already present in the\n * tree (headings, footnotes) are pre-reserved.\n */\n reserveIds: (bases: string[]) => string[]\n}\n\nexport type LayoutDirectiveEditorMetadata = {\n detail?: string\n label: string\n snippet: string\n snippets?: Array<{\n detail?: string\n label: string\n snippet: string\n }>\n}\n\nexport type DirectiveValidationContext = {\n attributes: Record<string, boolean | string>\n name: string\n}\n\n/**\n * Attribute types the directive spec cannot infer. An attribute listed in\n * `attributeValues` is an enum (a boolean when its values are exactly `true`\n * and `false`), one listed in `themeAttributes` names a theme; everything\n * else is a plain string unless declared here.\n */\nexport type DirectiveAttributeTypeDeclaration =\n | { max?: number; min?: number; type: 'number' }\n | { type: 'boolean' }\n /** An enum the definition validates in code (its values are not offered as editor completions). */\n | { type: 'enum'; values: readonly string[] }\n /** One `@pack/name` icon ref, or a comma-separated list of entries that may add `palette=<name>`. */\n | { type: 'icon' }\n /** A palette name (built-in, configured, or managed in the admin). */\n | { type: 'palette' }\n /** A link target, protocol-checked like Markdown links. */\n | { type: 'url' }\n\n/**\n * Element properties (hast names, per tag name) that the directive's mdast\n * stage emits and rehype-sanitize must keep. The registry adds the\n * directive's own `tagName` with `dataVlLayout` for directives that carry the\n * layout marker, and the sanitize schema is the base allowlist plus these.\n * Elements built in `applyHast` run after sanitizing and need no entry.\n */\nexport type DirectiveSanitizeAllowlist = Readonly<Partial<Record<string, readonly string[]>>>\n\n/** Receives the diagnostics of a leaf builder. */\nexport type DirectiveMessageSink = {\n message: (reason: string) => unknown\n}\n\n/** Options of the editor linter (`lintMarkdownDirectives`). */\nexport type LintMarkdownDirectivesOptions = {\n /**\n * Configured icon pack aliases. When provided, icon refs to other packs are\n * reported exactly like the renderer does (\"Unknown icon pack\").\n */\n iconPacks?: readonly string[]\n /**\n * Known palette names. When provided, unknown `palette` / `iconPalette`\n * values and icon-entry palettes are reported like the renderer does.\n */\n palettes?: readonly string[]\n /** Configured directive themes (names are what matters). */\n themes?: MarkdownDirectiveThemes\n}\n\n/** Close markers the directive grammar knows; see `layoutDirectiveRegistry.closeMarkers`. */\nexport type DirectiveCloseMarker = ':::' | ':::end' | ':::endcol' | ':::endsection'\n\n/** The `:::name[label]{attributes}` … `:::` form. */\nexport type DirectiveContainerForm = {\n /** Editor close-label text shown after a generic `:::` closer (default `end<name>`). */\n closeLabel?: string\n /** Markers that close the directive (default `[':::']`). */\n closeMarkers?: readonly DirectiveCloseMarker[]\n /** Attribute that the `[label]` stands for; both given and different is reported. */\n labelAttribute?: string\n}\n\n/** The `::name[label]{attributes}` form: one line (attributes may span lines). */\nexport type DirectiveLeafForm = {\n /**\n * Builds the leaf directive node for a directive line the scanner found,\n * reporting problems to `sink`. `undefined` leaves the line as text.\n */\n build: (line: string, sink: DirectiveMessageSink, config: MarkdownRenderConfig) => LeafDirective | undefined\n /** Editor diagnostics for the same line; must cover what `build` reports. */\n lint: (line: string, options: LintMarkdownDirectivesOptions) => string[]\n /**\n * Give the built element the layout marker (`data-vl-layout`), so the\n * definition's `applyHast` runs on it after sanitizing. Leave it off when\n * `build` emits the final element.\n */\n marker?: boolean\n}\n\n/** A container directive the editor linter is tracking. */\nexport type DirectiveLintFrame = {\n from: number\n /** Something other than a directive marker was seen inside the frame. */\n hasContent?: boolean\n line: number\n name: string\n /** Heading depth a grid was opened under (grids only). */\n parentHeadingDepth?: number\n /** Directive-specific state owned by the definition's lint hooks. */\n state?: unknown\n}\n\nexport type DirectiveLintOpenContext = {\n attributes: Record<string, boolean | string>\n /** The frame being opened; hooks may set `frame.state`. */\n frame: DirectiveLintFrame\n label?: string\n /** Frames open before this one, innermost last. */\n stack: readonly DirectiveLintFrame[]\n}\n\n/**\n * Nesting checks for the editor linter, which reads the document as a stream\n * of markers. They mirror what `validateMdast` reports on the compiled tree.\n */\nexport type DirectiveLintHooks = {\n /** Diagnostics when the frame closes (explicitly, by a parent closing, or at the end). */\n close?: (frame: DirectiveLintFrame) => string[]\n /** Diagnostics when the directive opens. */\n open?: (context: DirectiveLintOpenContext) => string[]\n}\n\nexport type LayoutDirectiveDefinition<Name extends string = string, Kind extends string = string> = {\n /** Attribute names, in suggestion order (\"Did you mean …?\" prefers earlier names). */\n allowedAttributes?: readonly string[]\n applyHast?: (\n node: Element,\n config: MarkdownRenderConfig,\n helpers: LayoutDirectiveClassHelpers,\n ) => void\n /** Types not implied by `attributeValues` or `themeAttributes` (see the type). */\n attributeTypes?: Partial<Record<string, DirectiveAttributeTypeDeclaration>>\n /** Values the editor offers; also makes the attribute an enum (or boolean) in the spec. */\n attributeValues?: Partial<Record<string, readonly string[]>>\n /** The container form; a directive has a container form, a leaf form, or both. */\n container?: DirectiveContainerForm\n defaultAttributes?: Record<string, string>\n description?: string\n editor: LayoutDirectiveEditorMetadata\n getMdastRenderProperties?: (node: ContainerDirective) => Record<string, unknown>\n /** `grid`, `section` and `cell` drive layout compilation; other kinds are the name. */\n kind: Kind\n /** The leaf form. */\n leaf?: DirectiveLeafForm\n /** Editor-linter nesting checks (container form). */\n lint?: DirectiveLintHooks\n name: Name\n public?: boolean\n sanitize?: DirectiveSanitizeAllowlist\n supportsAttributes?: boolean\n /** Element the directive renders as (the layout marker and `applyHast` target). */\n tagName: string\n themeAttributes?: Partial<Record<string, DirectiveThemeGroupName>>\n transformMdast?: (\n node: ContainerDirective,\n context: LayoutDirectiveTransformContext,\n ) => void\n /**\n * Extra sentence for an \"Unknown theme\" diagnostic, for a value that is\n * likely a mix-up (a callout variant given as its theme, say).\n */\n unknownThemeHint?: (attribute: string, value: string) => string | undefined\n validateAttributes?: (context: DirectiveValidationContext) => string[]\n validateMdast?: (node: ContainerDirective) => string[]\n}\n\n/**\n * Declares a directive definition. Only a typing helper: it keeps the\n * literal `name` and `kind`, so the registry can derive its unions.\n */\nexport function defineDirective<const Name extends string, const Kind extends string>(\n definition: LayoutDirectiveDefinition<Name, Kind>,\n): LayoutDirectiveDefinition<Name, Kind> {\n return definition\n}\n"],"names":["defineDirective","definition"],"mappings":"AAqPA;;;CAGC,GACD,OAAO,SAASA,gBACdC,UAAiD;IAEjD,OAAOA;AACT"}
|
|
@@ -2,6 +2,13 @@ import { autocompletion, snippetCompletion } from '@codemirror/autocomplete';
|
|
|
2
2
|
import { layoutDirectiveRegistry } from '../../directives/registry.js';
|
|
3
3
|
import { getDirectiveThemeNames } from '../../directives/themes.js';
|
|
4
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*\\{`);
|
|
5
12
|
export function getDirectiveCompletionOptions() {
|
|
6
13
|
return layoutDirectiveRegistry.getPublicDefinitions().flatMap((definition)=>{
|
|
7
14
|
const label = definition.editor.label.startsWith(':') ? definition.editor.label : `:::${definition.name}`;
|
|
@@ -28,7 +35,7 @@ export function getDirectiveCompletionOptions() {
|
|
|
28
35
|
export function getDirectiveAttributeCompletionOptions(name) {
|
|
29
36
|
const definition = layoutDirectiveRegistry.get(name);
|
|
30
37
|
const attributes = definition?.allowedAttributes ?? [];
|
|
31
|
-
const detailPrefix = name
|
|
38
|
+
const detailPrefix = getMarkerPrefix(name);
|
|
32
39
|
return attributes.map((attribute)=>snippetCompletion(`${attribute}="\${${attribute}}"`, {
|
|
33
40
|
type: 'property',
|
|
34
41
|
detail: `${detailPrefix} attribute`,
|
|
@@ -38,7 +45,7 @@ export function getDirectiveAttributeCompletionOptions(name) {
|
|
|
38
45
|
export function getDirectiveThemeValueCompletionOptions(name, attribute, config = {}) {
|
|
39
46
|
const definition = layoutDirectiveRegistry.get(name);
|
|
40
47
|
const groupName = definition?.themeAttributes?.[attribute];
|
|
41
|
-
const detailPrefix = name
|
|
48
|
+
const detailPrefix = getMarkerPrefix(name);
|
|
42
49
|
if (attribute === 'palette' || attribute === 'iconPalette') return getPaletteCompletionOptions(config);
|
|
43
50
|
if (attribute === 'icon') return (config.iconPacks ?? []).map((alias)=>({
|
|
44
51
|
type: 'constant',
|
|
@@ -68,7 +75,7 @@ function attributeCompletionSource(context, config) {
|
|
|
68
75
|
const line = context.state.doc.lineAt(context.pos);
|
|
69
76
|
const beforeCursor = line.text.slice(0, context.pos - line.from);
|
|
70
77
|
const containerMatch = beforeCursor.match(/^\s*:::(\w+)(?:\[[^\]]*\])?\s*\{([^}]*)$/);
|
|
71
|
-
const leafMatch = beforeCursor.match(
|
|
78
|
+
const leafMatch = beforeCursor.match(LEAF_ATTRIBUTES_BEFORE_CURSOR);
|
|
72
79
|
const multilineMatch = containerMatch || leafMatch ? null : findOpenDirectiveAttributeBlock(context, beforeCursor);
|
|
73
80
|
const directiveMatch = containerMatch ? {
|
|
74
81
|
name: containerMatch[1],
|
|
@@ -120,7 +127,7 @@ function findOpenDirectiveAttributeBlock(context, attributesBeforeCursor) {
|
|
|
120
127
|
name: containerMatch[1],
|
|
121
128
|
attributesBeforeCursor
|
|
122
129
|
};
|
|
123
|
-
const leafMatch = previousLine.match(
|
|
130
|
+
const leafMatch = previousLine.match(LEAF_ATTRIBUTES_OPEN);
|
|
124
131
|
if (leafMatch) return {
|
|
125
132
|
name: leafMatch[1],
|
|
126
133
|
attributesBeforeCursor
|
|
@@ -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'\nimport { getEditorPaletteNames } from '../directiveConfig.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 === '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(/^\\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\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(/^\\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, 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","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","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,+BAA8B;AACtE,SAASC,sBAAsB,Q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,IAAI,CAACC,KAAK,CAACI,UAAUH,IAAI,GAAGR,KAAKQ,IAAI,EAAEG,UAAUwB,EAAE,GAAGnC,KAAKQ,IAAI;QAEtF,IAAI,CAAC0B,UAAUhE,UAAU,CAAC,UAAU,CAAC+D,WAAWL,IAAI,IAClD,OAAO;YACLpB,MAAMG,UAAUH,IAAI;YACpBS,SAASrD,gCAAgCwE,MAAM,CAAC,CAACC,SAC/C,OAAOA,OAAOrE,KAAK,KAAK,WACpBqE,OAAOrE,KAAK,CAACE,UAAU,CAAC,SAAS,CAACmE,OAAOrE,KAAK,CAACE,UAAU,CAAC,SAC1D;QAER;IACJ;IAEA,MAAMwC,QAAQX,QAAQiC,WAAW,CAAC;IAElC,IAAI,CAACtB,OAAO,OAAO;IACnB,IAAIA,MAAMF,IAAI,KAAKE,MAAMyB,EAAE,IAAI,CAACpC,QAAQwB,QAAQ,EAAE,OAAO;IAEzD,OAAO;QACLf,MAAME,MAAMF,IAAI;QAChBS,SAASrD,gCAAgCwE,MAAM,CAAC,CAACC,SAC/C,OAAOA,OAAOrE,KAAK,KAAK,WAAWqE,OAAOrE,KAAK,CAACE,UAAU,CAAC,SAAS;IAExE;AACF;AAEA;;;CAGC,GACD,OAAO,SAASoE,2BAA2BpD,SAAwC,CAAC,CAAC;IACnF,OAAO3B,eAAe;QACpBgF,kBAAkB;QAClBC,UAAU;YAAC,CAACzC,UAA+B+B,0BAA0B/B,SAASb;SAAQ;IACxF;AACF;AAEA,OAAO,MAAMuD,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,+BAA8B;AACtE,SAASC,sBAAsB,QAAQ,6BAA4B;AACnE,SAASC,qBAAqB,QAAQ,wBAAuB;AAE7D,4EAA4E,GAC5E,SAASC,gBAAgBC,IAAY;IACnC,OAAOJ,wBAAwBK,mBAAmB,CAACD,QAAQ,CAAC,EAAE,EAAEA,MAAM,GAAG,CAAC,GAAG,EAAEA,MAAM;AACvF;AAEA,oEAAoE;AACpE,MAAME,qBAAqBN,wBAAwBO,kBAAkB,CAACC,IAAI,CAAC;AAC3E,MAAMC,gCAAgC,IAAIC,OACxC,CAAC,QAAQ,EAAEJ,mBAAmB,kCAAkC,CAAC;AAEnE,MAAMK,uBAAuB,IAAID,OAAO,CAAC,QAAQ,EAAEJ,mBAAmB,0BAA0B,CAAC;AAEjG,OAAO,SAASM;IACd,OAAOZ,wBAAwBa,oBAAoB,GAAGC,OAAO,CAAC,CAACC;QAC7D,MAAMC,QAAQD,WAAWE,MAAM,CAACD,KAAK,CAACE,UAAU,CAAC,OAC7CH,WAAWE,MAAM,CAACD,KAAK,GACvB,CAAC,GAAG,EAAED,WAAWX,IAAI,EAAE;QAC3B,MAAMe,WAAW;YACf;gBACEC,QAAQL,WAAWE,MAAM,CAACG,MAAM;gBAChCJ;gBACAK,SAASN,WAAWE,MAAM,CAACI,OAAO;YACpC;eACG,AAACN,CAAAA,WAAWE,MAAM,CAACE,QAAQ,IAAI,EAAE,AAAD,EAAGG,GAAG,CAAC,CAACD,UAAa,CAAA;oBACtDD,QAAQC,QAAQD,MAAM,IAAIL,WAAWE,MAAM,CAACG,MAAM;oBAClDJ,OAAOK,QAAQL,KAAK;oBACpBK,SAASA,QAAQA,OAAO;gBAC1B,CAAA;SACD;QAED,OAAOF,SAASG,GAAG,CA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BAA2BpD,SAAwC,CAAC,CAAC;IACnF,OAAOnC,eAAe;QACpBwF,kBAAkB;QAClBC,UAAU;YAAC,CAACzC,UAA+B+B,0BAA0B/B,SAASb;SAAQ;IACxF;AACF;AAEA,OAAO,MAAMuD,uBAAuBH,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 ?
|
|
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,SAASC,SAAS,QAAQ,oBAAmB;AAE7C,MAAMC,aAAa,aACjBC,eAAe,aACfC,SAAS,WACTC,QAAQ,WACRC,SAAS,WACTC,OAAO,WACPC,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AAOzG;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,WACPC,sBAAsB,WACtBC,UAAU,WACVC,QAAQ,WACRC,SAAS,WACTC,OAAO,WACPC,cAAc,aACdC,qBAAqB,WACrBC,YAAY,WACZ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;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"}
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Version of this copy of payload-markdown (generated by scripts/sync-version.mjs). */
|
|
2
|
-
export declare const PAYLOAD_MARKDOWN_VERSION = "1.
|
|
2
|
+
export declare const PAYLOAD_MARKDOWN_VERSION = "1.9.0";
|
package/dist/version.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
/** Version of this copy of payload-markdown (generated by scripts/sync-version.mjs). */ export const PAYLOAD_MARKDOWN_VERSION = '1.
|
|
1
|
+
/** Version of this copy of payload-markdown (generated by scripts/sync-version.mjs). */ export const PAYLOAD_MARKDOWN_VERSION = '1.9.0';
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=version.js.map
|
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["/** Version of this copy of payload-markdown (generated by scripts/sync-version.mjs). */\nexport const PAYLOAD_MARKDOWN_VERSION = '1.
|
|
1
|
+
{"version":3,"sources":["../src/version.ts"],"sourcesContent":["/** Version of this copy of payload-markdown (generated by scripts/sync-version.mjs). */\nexport const PAYLOAD_MARKDOWN_VERSION = '1.9.0'\n"],"names":["PAYLOAD_MARKDOWN_VERSION"],"mappings":"AAAA,sFAAsF,GACtF,OAAO,MAAMA,2BAA2B,QAAO"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "payload-markdown",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"description": "Structured Markdown editing and rendering for Payload CMS with CodeMirror, Shiki, directives, themes, and server-first output.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "https://github.com/valkyrianlabs/payload-markdown"
|