@aicayzer/inkkit 0.0.17 → 0.1.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 (81) hide show
  1. package/NOTICE +4 -2
  2. package/README.md +12 -6
  3. package/dist/THIRD-PARTY-NOTICES.txt +2742 -0
  4. package/dist/chunks/core-vtCr4MBS.js +56503 -0
  5. package/dist/chunks/highlight-Daj2fv_u.js +14122 -0
  6. package/dist/core.d.ts +4 -0
  7. package/dist/core.js +2 -0
  8. package/dist/editor.d.ts +261 -48
  9. package/dist/index.d.ts +1 -7
  10. package/dist/index.js +5 -2
  11. package/dist/style.css +242 -221
  12. package/dist/types.d.ts +143 -18
  13. package/package.json +26 -15
  14. package/dist/autolink.d.ts +0 -1
  15. package/dist/autolink.js +0 -18
  16. package/dist/callouts.d.ts +0 -26
  17. package/dist/callouts.js +0 -311
  18. package/dist/clipboard.d.ts +0 -11
  19. package/dist/clipboard.js +0 -261
  20. package/dist/code-fences.d.ts +0 -8
  21. package/dist/code-fences.js +0 -166
  22. package/dist/comments.d.ts +0 -55
  23. package/dist/comments.js +0 -494
  24. package/dist/decorations.d.ts +0 -2
  25. package/dist/decorations.js +0 -67
  26. package/dist/dialect.d.ts +0 -9
  27. package/dist/dialect.js +0 -358
  28. package/dist/editor.js +0 -2441
  29. package/dist/files.d.ts +0 -40
  30. package/dist/files.js +0 -133
  31. package/dist/highlight.d.ts +0 -1
  32. package/dist/highlight.js +0 -136
  33. package/dist/image-blocks.d.ts +0 -71
  34. package/dist/image-blocks.js +0 -286
  35. package/dist/images.d.ts +0 -51
  36. package/dist/images.js +0 -398
  37. package/dist/inline-highlight.d.ts +0 -6
  38. package/dist/inline-highlight.js +0 -112
  39. package/dist/labels.d.ts +0 -36
  40. package/dist/labels.js +0 -34
  41. package/dist/linked-syntax.d.ts +0 -48
  42. package/dist/linked-syntax.js +0 -320
  43. package/dist/literals.d.ts +0 -19
  44. package/dist/literals.js +0 -211
  45. package/dist/mermaid.d.ts +0 -8
  46. package/dist/mermaid.js +0 -321
  47. package/dist/outline.d.ts +0 -22
  48. package/dist/outline.js +0 -79
  49. package/dist/paste-html.d.ts +0 -23
  50. package/dist/paste-html.js +0 -441
  51. package/dist/paste.d.ts +0 -26
  52. package/dist/paste.js +0 -482
  53. package/dist/portable-files.d.ts +0 -10
  54. package/dist/portable-files.js +0 -36
  55. package/dist/preserve.d.ts +0 -21
  56. package/dist/preserve.js +0 -757
  57. package/dist/print.d.ts +0 -7
  58. package/dist/print.js +0 -409
  59. package/dist/reference-clipboard.d.ts +0 -8
  60. package/dist/reference-clipboard.js +0 -201
  61. package/dist/references.d.ts +0 -14
  62. package/dist/references.js +0 -368
  63. package/dist/search.d.ts +0 -15
  64. package/dist/search.js +0 -202
  65. package/dist/selection.d.ts +0 -1
  66. package/dist/selection.js +0 -59
  67. package/dist/source.d.ts +0 -16
  68. package/dist/source.js +0 -57
  69. package/dist/spreadsheet.d.ts +0 -3
  70. package/dist/spreadsheet.js +0 -275
  71. package/dist/table-alignment.d.ts +0 -2
  72. package/dist/table-alignment.js +0 -46
  73. package/dist/tables.d.ts +0 -27
  74. package/dist/tables.js +0 -322
  75. package/dist/tasks.d.ts +0 -3
  76. package/dist/tasks.js +0 -51
  77. package/dist/text-ranges.d.ts +0 -29
  78. package/dist/text-ranges.js +0 -256
  79. package/dist/types.js +0 -8
  80. package/dist/wiki-view.d.ts +0 -21
  81. package/dist/wiki-view.js +0 -78
@@ -1,320 +0,0 @@
1
- import { $node, $remark } from '@milkdown/kit/utils';
2
- import { defaultHandlers } from 'mdast-util-to-markdown';
3
- const fromTable = (raw) => raw.replace(/(\\*)\|/g, (_match, escapes) => `${'\\'.repeat(Math.floor(escapes.length / 2))}|`);
4
- const toTable = (raw) => raw.replace(/(\\*)\|/g, (_match, escapes) => `${'\\'.repeat(escapes.length * 2 + 1)}|`);
5
- export function parseLinkedSyntax(raw, inTable = false) {
6
- const source = inTable ? fromTable(raw) : raw;
7
- const embed = source.startsWith('!');
8
- const prefix = embed ? '![[' : '[[';
9
- if (!source.startsWith(prefix) || !source.endsWith(']]'))
10
- return undefined;
11
- const content = source.slice(prefix.length, -2);
12
- const parts = { target: '', fragment: '', alias: '' };
13
- let section = 'target', hasFragment = false, hasAlias = false;
14
- for (let index = 0; index < content.length; index++) {
15
- const character = content[index];
16
- if (character === '\\') {
17
- const escaped = content[++index];
18
- if (!escaped || !'[]|#\\'.includes(escaped))
19
- return undefined;
20
- parts[section] += escaped;
21
- }
22
- else if (character === '|') {
23
- if (hasAlias)
24
- return undefined;
25
- hasAlias = true;
26
- section = 'alias';
27
- }
28
- else if (character === '#' && section !== 'alias') {
29
- if (hasFragment)
30
- return undefined;
31
- hasFragment = true;
32
- section = 'fragment';
33
- }
34
- else {
35
- if ('[]'.includes(character) ||
36
- (character.charCodeAt(0) < 32 && character !== '\t') ||
37
- character === '\u007f')
38
- return undefined;
39
- parts[section] += character;
40
- }
41
- }
42
- if ((!parts.target.trim() && !(hasFragment && parts.fragment.trim())) ||
43
- (hasFragment && !parts.fragment.trim()) ||
44
- (hasAlias && !parts.alias.trim()) ||
45
- parts.target.trimStart().startsWith('^') ||
46
- parts.fragment.trimStart().startsWith('^'))
47
- return undefined;
48
- const size = /^[ \t]*(\d{1,5})(?:x(\d{1,5}))?[ \t]*$/.exec(parts.alias);
49
- if (embed &&
50
- (!parts.target.trim() ||
51
- (hasAlias &&
52
- (!size ||
53
- Number(size[1]) < 1 ||
54
- (size[2] != null && Number(size[2]) < 1)))))
55
- return undefined;
56
- const target = embed ? parts.target.trim() : parts.target;
57
- const fragment = hasFragment
58
- ? embed
59
- ? parts.fragment.trim()
60
- : parts.fragment
61
- : null;
62
- return {
63
- raw,
64
- target,
65
- fragment,
66
- label: !embed && hasAlias
67
- ? parts.alias
68
- : target + (fragment != null ? `#${fragment}` : ''),
69
- width: embed && hasAlias ? Number(size[1]) : null,
70
- embed,
71
- inTable,
72
- };
73
- }
74
- function linkedTokenizer(embed) {
75
- return function (effects, ok, nok) {
76
- const prefix = embed ? '![[' : '[[';
77
- let index = 0, raw = '';
78
- return opening;
79
- function consume(code) {
80
- raw += code === -2 ? '\t' : code === -1 ? ' ' : String.fromCodePoint(code);
81
- effects.consume(code);
82
- }
83
- function opening(code) {
84
- if (code !== prefix.charCodeAt(index))
85
- return nok(code);
86
- if (!index)
87
- effects.enter('inkkitLinkedSyntax');
88
- consume(code);
89
- index++;
90
- return index === prefix.length ? body : opening;
91
- }
92
- function body(code) {
93
- if (code === null ||
94
- (code < 32 && code !== -2 && code !== -1 && code !== 9) ||
95
- code === 91)
96
- return nok(code);
97
- consume(code);
98
- if (code === 92)
99
- return escaped;
100
- return code === 93 ? closing : body;
101
- }
102
- function escaped(code) {
103
- if (code === null || code < 32)
104
- return nok(code);
105
- consume(code);
106
- return body;
107
- }
108
- function closing(code) {
109
- if (code !== 93)
110
- return nok(code);
111
- consume(code);
112
- if (!parseLinkedSyntax(raw) && !parseLinkedSyntax(raw, true))
113
- return nok(code);
114
- effects.exit('inkkitLinkedSyntax');
115
- return ok;
116
- }
117
- };
118
- }
119
- function tableForm(raw, authoredInTable, outputInTable) {
120
- if (authoredInTable === outputInTable)
121
- return raw;
122
- return outputInTable ? toTable(raw) : fromTable(raw);
123
- }
124
- export function wikiMarkdown(node, inTable = false) {
125
- return tableForm(String(node.attrs.raw), Boolean(node.attrs.inTable), inTable);
126
- }
127
- export function wikiReference(node) {
128
- return {
129
- target: String(node.attrs.target),
130
- ...(node.attrs.fragment != null
131
- ? { fragment: String(node.attrs.fragment) }
132
- : {}),
133
- label: String(node.attrs.label),
134
- };
135
- }
136
- export function fileReference(node) {
137
- const reference = String(node.attrs.src ?? '');
138
- const named = node.attrs.inkkitFileRaw != null;
139
- const alt = String(node.attrs.alt ?? '');
140
- const match = /\|(\d{1,5})$/.exec(alt);
141
- const fragment = named
142
- ? node.attrs.inkkitFileFragment
143
- : reference.includes('#')
144
- ? reference.slice(reference.indexOf('#') + 1)
145
- : null;
146
- const label = named
147
- ? String(node.attrs.inkkitFileTarget ?? '') +
148
- (fragment != null ? `#${fragment}` : '')
149
- : match
150
- ? alt.slice(0, match.index)
151
- : alt;
152
- const width = named && alt === label && node.attrs.inkkitFileWidth == null
153
- ? null
154
- : match
155
- ? Number(match[1])
156
- : null;
157
- return {
158
- reference,
159
- kind: named ? 'wiki' : 'path',
160
- ...(fragment != null ? { fragment: String(fragment) } : {}),
161
- ...(label ? { label } : {}),
162
- ...(width != null ? { width } : {}),
163
- };
164
- }
165
- export function namedFileMarkdown(node, inTable = false) {
166
- if (node.attrs.inkkitFileRaw == null)
167
- return undefined;
168
- let raw = String(node.attrs.inkkitFileRaw);
169
- const authoredInTable = Boolean(node.attrs.inkkitFileInTable);
170
- const width = fileReference(node).width ?? null;
171
- const original = node.attrs.inkkitFileWidth ?? null;
172
- if (width !== original) {
173
- if (authoredInTable)
174
- raw = fromTable(raw);
175
- if (original != null)
176
- raw = raw.replace(/\|[ \t]*\d{1,5}(?:x\d{1,5})?[ \t]*\]\]$/, ']]');
177
- if (width != null)
178
- raw = `${raw.slice(0, -2)}|${width}]]`;
179
- return inTable ? toTable(raw) : raw;
180
- }
181
- return tableForm(raw, authoredInTable, inTable);
182
- }
183
- export const wikiLinkSchema = $node('inkkit_wiki_link', () => ({
184
- inline: true,
185
- group: 'inline',
186
- atom: true,
187
- marks: '',
188
- attrs: {
189
- raw: { default: '' },
190
- target: { default: '' },
191
- fragment: { default: null },
192
- label: { default: '' },
193
- inTable: { default: false },
194
- },
195
- parseDOM: [
196
- {
197
- tag: 'span[data-inkkit-wiki]',
198
- getAttrs(dom) {
199
- const parsed = parseLinkedSyntax(dom.getAttribute('data-inkkit-wiki-raw') ?? '', dom.getAttribute('data-inkkit-wiki-table') === 'true');
200
- return parsed && !parsed.embed
201
- ? {
202
- raw: parsed.raw,
203
- target: parsed.target,
204
- fragment: parsed.fragment,
205
- label: parsed.label,
206
- inTable: parsed.inTable,
207
- }
208
- : false;
209
- },
210
- },
211
- ],
212
- toDOM: (node) => [
213
- 'span',
214
- {
215
- 'data-inkkit-wiki': node.attrs.target,
216
- 'data-inkkit-fragment': node.attrs.fragment ?? '',
217
- 'data-inkkit-wiki-raw': node.attrs.raw,
218
- 'data-inkkit-wiki-table': String(node.attrs.inTable),
219
- role: 'link',
220
- tabindex: '0',
221
- },
222
- node.attrs.label,
223
- ],
224
- parseMarkdown: {
225
- match: (node) => node.type === 'inkkitWikiLink',
226
- runner(state, node, type) {
227
- state.addNode(type, {
228
- raw: node.raw,
229
- target: node.target,
230
- fragment: node.fragment,
231
- label: node.label,
232
- inTable: node.inTable,
233
- });
234
- },
235
- },
236
- toMarkdown: {
237
- match: (node) => node.type.name === 'inkkit_wiki_link',
238
- runner(state, node) {
239
- state.addNode('inkkitWikiLink', undefined, node.attrs.label, {
240
- raw: node.attrs.raw,
241
- target: node.attrs.target,
242
- fragment: node.attrs.fragment,
243
- label: node.attrs.label,
244
- inTable: node.attrs.inTable,
245
- });
246
- },
247
- },
248
- }));
249
- export function linkedSyntax(wikiLinks, files) {
250
- const syntax = { text: {} };
251
- if (wikiLinks)
252
- syntax.text[91] = {
253
- name: 'inkkitWikiLink',
254
- tokenize: linkedTokenizer(false),
255
- previous: (code) => code !== 33 && code !== 91,
256
- };
257
- if (files)
258
- syntax.text[33] = {
259
- name: 'inkkitNamedFile',
260
- tokenize: linkedTokenizer(true),
261
- };
262
- const from = {
263
- enter: {
264
- inkkitLinkedSyntax(token) {
265
- const inTable = this.stack.some((node) => node.type === 'tableCell');
266
- const parsed = parseLinkedSyntax(this.sliceSerialize(token), inTable);
267
- if (!parsed) {
268
- this.enter({ type: 'text', value: this.sliceSerialize(token) }, token);
269
- return;
270
- }
271
- if (parsed.embed)
272
- this.enter({
273
- type: 'image',
274
- url: parsed.target +
275
- (parsed.fragment != null ? `#${parsed.fragment}` : ''),
276
- alt: parsed.label + (parsed.width != null ? `|${parsed.width}` : ''),
277
- title: null,
278
- inkkitFileRaw: parsed.raw,
279
- inkkitFileTarget: parsed.target,
280
- inkkitFileFragment: parsed.fragment,
281
- inkkitFileWidth: parsed.width,
282
- inkkitFileInTable: inTable,
283
- }, token);
284
- else
285
- this.enter({
286
- type: 'inkkitWikiLink',
287
- value: parsed.label,
288
- raw: parsed.raw,
289
- target: parsed.target,
290
- fragment: parsed.fragment,
291
- label: parsed.label,
292
- inTable,
293
- }, token);
294
- },
295
- },
296
- exit: {
297
- inkkitLinkedSyntax(token) {
298
- this.exit(token);
299
- },
300
- },
301
- };
302
- const wiki = (node, _parent, state) => tableForm(String(node.raw), Boolean(node.inTable), state.stack.includes('tableCell'));
303
- const named = (node, parent, state, info) => {
304
- if (node.inkkitFileRaw != null)
305
- return tableForm(String(node.inkkitFileRaw), Boolean(node.inkkitFileInTable), state.stack.includes('tableCell'));
306
- return defaultHandlers.image(node, parent, state, info);
307
- };
308
- // Standard image handling is installed by CommonMark; wrap it only for authored named tokens.
309
- return $remark('inkkitLinkedSyntax', () => function () {
310
- const data = this.data();
311
- (data.micromarkExtensions ??= []).push(syntax);
312
- (data.fromMarkdownExtensions ??= []).push(from);
313
- (data.toMarkdownExtensions ??= []).push({
314
- handlers: {
315
- inkkitWikiLink: wiki,
316
- ...(files ? { image: named } : {}),
317
- },
318
- });
319
- });
320
- }
@@ -1,19 +0,0 @@
1
- import type { Literal } from 'mdast';
2
- import { type CommentSpan } from './comments.js';
3
- interface InkKitLiteral extends Literal {
4
- type: 'inkkitLiteral';
5
- comments?: CommentSpan[];
6
- }
7
- declare module 'mdast' {
8
- interface BlockContentMap {
9
- inkkitLiteral: InkKitLiteral;
10
- }
11
- interface RootContentMap {
12
- inkkitLiteral: InkKitLiteral;
13
- }
14
- }
15
- export declare function sourceFrontmatter(source: string): string | undefined;
16
- export declare function createLiteralPreservation(images: boolean): import("@milkdown/kit/utils").$Remark<"preserveLiterals", unknown>;
17
- export declare const preserveLiterals: import("@milkdown/kit/utils").$Remark<"preserveLiterals", unknown>;
18
- export declare const literalBlock: import("@milkdown/kit/utils").$Node;
19
- export {};
package/dist/literals.js DELETED
@@ -1,211 +0,0 @@
1
- import { $node, $remark } from '@milkdown/kit/utils';
2
- import { commentSource, literalCommentSpans, } from './comments.js';
3
- const unsupported = new Set(['html', 'image', 'imageReference']);
4
- export function sourceFrontmatter(source) {
5
- return /^(---|\+\+\+)\r?\n[\s\S]*?\r?\n\1(?:\r?\n|$)/.exec(source)?.[0];
6
- }
7
- function restoreInlineBreaks(node) {
8
- if ((node.type === 'paragraph' || node.type === 'heading') &&
9
- node.children.length > 1) {
10
- node.children = node.children.map((child) => child.type === 'html' &&
11
- ['<br />', '<br>', '<br >', '<br/>'].includes(child.value.trim())
12
- ? {
13
- type: 'break',
14
- data: { inkkitHTMLBreak: true },
15
- position: child.position,
16
- }
17
- : child);
18
- }
19
- if ('children' in node)
20
- node.children.forEach(restoreInlineBreaks);
21
- }
22
- function containsUnsupported(node, images, inline = false) {
23
- // Only a standalone break represents a spacer; inline HTML must remain literal.
24
- if (!inline &&
25
- node.type === 'html' &&
26
- ['<br />', '<br>', '<br >', '<br/>'].includes(node.value.trim()))
27
- return false;
28
- if (node.type === 'paragraph' && node.children.length === 1) {
29
- const child = node.children[0];
30
- if (child?.type === 'html' &&
31
- ['<br />', '<br>', '<br >', '<br/>'].includes(child.value.trim()))
32
- return false;
33
- }
34
- return ((unsupported.has(node.type) && !(images && node.type === 'image')) ||
35
- ('children' in node &&
36
- node.children.some((child) => containsUnsupported(child, images, inline || node.type === 'paragraph' || node.type === 'heading'))));
37
- }
38
- function containsUnresolved(node, source) {
39
- if (node.type === 'text') {
40
- const start = node.position?.start.offset;
41
- const end = node.position?.end.offset;
42
- if (start == null || end == null)
43
- return false;
44
- const raw = source.slice(start, end);
45
- return /(?<!\\)\[\^[^\]\n]+\]|(?<!\\)\[[^\]\n]+\](?:\[[^\]\n]*\])?/.test(raw);
46
- }
47
- return ('children' in node &&
48
- node.children.some((child) => containsUnresolved(child, source)));
49
- }
50
- function containsUnsupportedLinked(node, source) {
51
- const start = node.position?.start.offset, end = node.position?.end.offset;
52
- if (start == null || end == null || node.type === 'definition')
53
- return false;
54
- const supported = [];
55
- const visit = (child) => {
56
- if ([
57
- 'inkkitWikiLink',
58
- 'image',
59
- 'code',
60
- 'inlineCode',
61
- 'link',
62
- 'inkkitCommentInline',
63
- 'inkkitCommentBlock',
64
- ].includes(child.type)) {
65
- const from = child.position?.start.offset, to = child.position?.end.offset;
66
- if (from != null && to != null)
67
- supported.push({ from, to });
68
- return;
69
- }
70
- if ('children' in child)
71
- child.children.forEach(visit);
72
- };
73
- visit(node);
74
- for (const match of source
75
- .slice(start, end)
76
- .matchAll(/!?\[\[[^\r\n]*?\]\]/g)) {
77
- const from = start + match.index, to = from + match[0].length;
78
- let escapes = 0;
79
- while (from - escapes > 0 && source[from - escapes - 1] === '\\')
80
- escapes++;
81
- if (escapes % 2)
82
- continue;
83
- if (!supported.some((span) => span.from <= from && span.to >= to))
84
- return true;
85
- }
86
- return false;
87
- }
88
- // Keep syntax we cannot faithfully edit as literal text, without making the rest
89
- // of the document a source editor or allowing HTML and image network requests.
90
- export function createLiteralPreservation(images) {
91
- return $remark('preserveLiterals', () => () => (tree, file) => {
92
- restoreInlineBreaks(tree);
93
- // Micromark's positions exclude an initial byte-order mark.
94
- const source = String(file.value).replace(/^\uFEFF/, '');
95
- const frontmatter = sourceFrontmatter(source);
96
- const frontmatterEnd = frontmatter?.length ?? 0;
97
- const preserveBlock = (node, depth = 0) => {
98
- if (node.type === 'footnoteDefinition') {
99
- node.children = node.children.map((child) => preserveBlock(child, depth + 1));
100
- return node;
101
- }
102
- const start = node.position?.start.offset;
103
- const end = node.position?.end.offset;
104
- if (start == null ||
105
- end == null ||
106
- (!containsUnsupported(node, images) &&
107
- !containsUnresolved(node, source) &&
108
- !containsUnsupportedLinked(node, source)))
109
- return node;
110
- let raw = source.slice(start, end);
111
- // Definition indentation is restored by the footnote serializer.
112
- for (let index = 0; index < depth; index++)
113
- raw = raw.replace(/\r?\n(?: {4}|\t)/g, '\n');
114
- return {
115
- type: 'inkkitLiteral',
116
- value: raw,
117
- comments: literalCommentSpans(raw),
118
- position: node.position,
119
- };
120
- };
121
- const blocks = [];
122
- if (frontmatter)
123
- blocks.push({
124
- type: 'inkkitLiteral',
125
- value: frontmatter.trimEnd(),
126
- position: {
127
- start: { line: 1, column: 1, offset: 0 },
128
- end: {
129
- line: 1,
130
- column: 1,
131
- offset: frontmatter.trimEnd().length,
132
- },
133
- },
134
- });
135
- for (const node of tree.children) {
136
- const start = node.position?.start.offset;
137
- const end = node.position?.end.offset;
138
- if (start == null || end == null) {
139
- blocks.push(node);
140
- continue;
141
- }
142
- if (start < frontmatterEnd) {
143
- // TOML delimiters are ordinary paragraph text to CommonMark, so a
144
- // paragraph may also contain body text immediately after the header.
145
- if (end > frontmatterEnd)
146
- blocks.push({
147
- type: 'inkkitLiteral',
148
- value: source.slice(frontmatterEnd, end),
149
- position: {
150
- start: { line: 1, column: 1, offset: frontmatterEnd },
151
- end: node.position.end,
152
- },
153
- });
154
- continue;
155
- }
156
- if (node.type === 'inkkitLiteral')
157
- node.comments = literalCommentSpans(node.value);
158
- blocks.push(preserveBlock(node));
159
- }
160
- tree.children = blocks;
161
- });
162
- }
163
- export const preserveLiterals = createLiteralPreservation(false);
164
- export const literalBlock = $node('literal_markdown', () => ({
165
- group: 'block',
166
- content: '(text | comment_inline)*',
167
- marks: '',
168
- code: true,
169
- defining: true,
170
- parseDOM: [
171
- { tag: 'pre.literal-markdown', preserveWhitespace: 'full', priority: 100 },
172
- ],
173
- toDOM: () => [
174
- 'pre',
175
- { class: 'literal-markdown', 'aria-label': 'Preserved Markdown' },
176
- 0,
177
- ],
178
- parseMarkdown: {
179
- match: (node) => node.type === 'inkkitLiteral',
180
- runner: (state, node, type) => {
181
- state.openNode(type);
182
- const value = String(node.value ?? '');
183
- let cursor = 0;
184
- for (const span of node.comments ?? []) {
185
- if (span.start > cursor)
186
- state.addText(value.slice(cursor, span.start));
187
- state.openNode(state.schema.nodes.comment_inline, {
188
- syntax: span.syntax,
189
- block: Boolean(span.block),
190
- });
191
- if (span.value)
192
- state.addText(span.value);
193
- state.closeNode();
194
- cursor = span.end;
195
- }
196
- if (cursor < value.length)
197
- state.addText(value.slice(cursor));
198
- state.closeNode();
199
- },
200
- },
201
- toMarkdown: {
202
- match: (node) => node.type.name === 'literal_markdown',
203
- runner: (state, node) => {
204
- let source = '';
205
- node.forEach((child) => {
206
- source += child.isText ? child.text : commentSource(child);
207
- });
208
- state.addNode('html', undefined, source);
209
- },
210
- },
211
- }));
package/dist/mermaid.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import type { Node as ProseNode } from '@milkdown/kit/prose/model';
2
- import { type PortableImage } from './types.js';
3
- export declare function isMermaid(node: ProseNode): boolean;
4
- export declare function validateDiagram(source: string): void;
5
- export declare function safeDiagramSVG(svg: string): string;
6
- export declare function renderDiagram(source: string): Promise<string>;
7
- export declare function diagramImage(source: string): Promise<PortableImage>;
8
- export declare function mermaidPreview(onError: (error: Error) => void): import("@milkdown/kit/utils").$Prose;