@plexui/vue 0.17.0 → 0.18.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/es/components/MarkdownEditor/MarkdownEditor.js +84 -216
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/MarkdownEditor/index.js.map +1 -1
- package/dist/es/lib/markdownEditorSchema.js +318 -0
- package/dist/es/lib/markdownEditorSchema.js.map +1 -0
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts +74 -1
- package/dist/types/components/MarkdownEditor/index.d.ts +1 -1
- package/dist/types/lib/markdownEditorSchema.d.ts +47 -0
- package/package.json +2 -2
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
import { defineComponent, h, reactive, ref, watch, } from "vue";
|
|
2
2
|
import { EditorContent, useEditor } from "@tiptap/vue-3";
|
|
3
3
|
import { getMarkRange } from "@tiptap/core";
|
|
4
|
-
import Document from "@tiptap/extension-document";
|
|
5
|
-
import Paragraph from "@tiptap/extension-paragraph";
|
|
6
|
-
import Text from "@tiptap/extension-text";
|
|
7
|
-
import BoldExtension from "@tiptap/extension-bold";
|
|
8
|
-
import ItalicExtension from "@tiptap/extension-italic";
|
|
9
|
-
import LinkExtension from "@tiptap/extension-link";
|
|
10
|
-
import BulletList from "@tiptap/extension-bullet-list";
|
|
11
|
-
import OrderedList from "@tiptap/extension-ordered-list";
|
|
12
|
-
import ListItem from "@tiptap/extension-list-item";
|
|
13
|
-
import History from "@tiptap/extension-history";
|
|
14
|
-
import Placeholder from "@tiptap/extension-placeholder";
|
|
15
|
-
import HardBreak from "@tiptap/extension-hard-break";
|
|
16
|
-
import { Markdown as MarkdownExtension } from "tiptap-markdown";
|
|
17
4
|
import { keepMovedFocus } from "../../lib/helpers.js";
|
|
5
|
+
import { markdownEditorExtensions, markdownEditorSchema, rehypeEditorSchema, remarkLineBreaks, remarkWithoutHtml, } from "../../lib/markdownEditorSchema.js";
|
|
18
6
|
import { Bold as BoldIcon, Italic as ItalicIcon, Link as LinkIcon, List as ListIcon, ListNumbers as ListNumbersIcon, } from "../Icon/index.js";
|
|
19
7
|
import { Tooltip } from "../Tooltip/index.js";
|
|
20
8
|
import { Button } from "../Button/index.js";
|
|
@@ -142,6 +130,17 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
142
130
|
value: { type: String, default: undefined },
|
|
143
131
|
/** Default value as a markdown string for uncontrolled mode */
|
|
144
132
|
defaultValue: { type: String, default: undefined },
|
|
133
|
+
/**
|
|
134
|
+
* The formats the editor offers, read when the editor is created. A format left out has no toolbar button,
|
|
135
|
+
* shortcut or input rule; pasted and incoming content keeps its text without it, and the markdown does not write it.
|
|
136
|
+
* @default ["bold", "italic", "orderedList", "bulletList", "link"]
|
|
137
|
+
*/
|
|
138
|
+
formats: { type: Array, default: undefined },
|
|
139
|
+
/**
|
|
140
|
+
* A single newline is a line break, read and written as one "\n", read when the editor is created. Without it a
|
|
141
|
+
* line break is written as a backslash and a newline, and a single newline joins the lines. @default false
|
|
142
|
+
*/
|
|
143
|
+
breaks: { type: Boolean, default: false },
|
|
145
144
|
/** Minimum visible rows. @default 1 */
|
|
146
145
|
rows: { type: Number, default: 1 },
|
|
147
146
|
/** `id` of the editable element */
|
|
@@ -162,6 +161,8 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
162
161
|
"change": (markdown) => typeof markdown === "string",
|
|
163
162
|
},
|
|
164
163
|
setup(props, { slots, attrs, emit }) {
|
|
164
|
+
// The schema is the editor's, made once with it, as the toolbar offers what the schema has
|
|
165
|
+
const schema = markdownEditorSchema(props.formats, props.breaks);
|
|
165
166
|
const focused = ref(false);
|
|
166
167
|
const linkDialogOpen = ref(false);
|
|
167
168
|
const linkDialogInitial = ref({ url: "", title: "" });
|
|
@@ -198,28 +199,7 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
198
199
|
...(props.ariaInvalid && { "aria-invalid": "true" }),
|
|
199
200
|
});
|
|
200
201
|
const editor = useEditor({
|
|
201
|
-
extensions:
|
|
202
|
-
Document,
|
|
203
|
-
Paragraph,
|
|
204
|
-
Text,
|
|
205
|
-
HardBreak,
|
|
206
|
-
BoldExtension,
|
|
207
|
-
ItalicExtension,
|
|
208
|
-
LinkExtension.configure({
|
|
209
|
-
openOnClick: false,
|
|
210
|
-
HTMLAttributes: { rel: "noopener noreferrer nofollow" },
|
|
211
|
-
}),
|
|
212
|
-
BulletList,
|
|
213
|
-
OrderedList,
|
|
214
|
-
ListItem,
|
|
215
|
-
History,
|
|
216
|
-
MarkdownExtension.configure({
|
|
217
|
-
html: false,
|
|
218
|
-
transformPastedText: true,
|
|
219
|
-
transformCopiedText: true,
|
|
220
|
-
}),
|
|
221
|
-
...(props.placeholder ? [Placeholder.configure({ placeholder: props.placeholder })] : []),
|
|
222
|
-
],
|
|
202
|
+
extensions: markdownEditorExtensions(schema, props.placeholder),
|
|
223
203
|
content: props.value ?? props.defaultValue ?? "",
|
|
224
204
|
editable: !props.disabled,
|
|
225
205
|
editorProps: {
|
|
@@ -368,6 +348,51 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
368
348
|
// React renders the slot only for a truthy `toolbarEnd`
|
|
369
349
|
const toolbarEnd = slots.toolbarEnd?.();
|
|
370
350
|
const hasToolbarEnd = flattenSlot(toolbarEnd).length > 0;
|
|
351
|
+
const offered = schema.formats;
|
|
352
|
+
// Groups of the offered formats, a separator between two of them
|
|
353
|
+
const groups = [
|
|
354
|
+
[
|
|
355
|
+
offered.has("bold") && h(ToolbarButton, {
|
|
356
|
+
tooltip: "Bold",
|
|
357
|
+
active: activeMarks.bold,
|
|
358
|
+
disabled,
|
|
359
|
+
icon: BoldIcon,
|
|
360
|
+
onClick: () => editor.value?.chain().focus().toggleBold().run(),
|
|
361
|
+
}),
|
|
362
|
+
offered.has("italic") && h(ToolbarButton, {
|
|
363
|
+
tooltip: "Italic",
|
|
364
|
+
active: activeMarks.italic,
|
|
365
|
+
disabled,
|
|
366
|
+
icon: ItalicIcon,
|
|
367
|
+
onClick: () => editor.value?.chain().focus().toggleItalic().run(),
|
|
368
|
+
}),
|
|
369
|
+
],
|
|
370
|
+
[
|
|
371
|
+
offered.has("orderedList") && h(ToolbarButton, {
|
|
372
|
+
tooltip: "Numbered list",
|
|
373
|
+
active: activeMarks.orderedList,
|
|
374
|
+
disabled,
|
|
375
|
+
icon: ListNumbersIcon,
|
|
376
|
+
onClick: () => editor.value?.chain().focus().toggleOrderedList().run(),
|
|
377
|
+
}),
|
|
378
|
+
offered.has("bulletList") && h(ToolbarButton, {
|
|
379
|
+
tooltip: "Bullet list",
|
|
380
|
+
active: activeMarks.bulletList,
|
|
381
|
+
disabled,
|
|
382
|
+
icon: ListIcon,
|
|
383
|
+
onClick: () => editor.value?.chain().focus().toggleBulletList().run(),
|
|
384
|
+
}),
|
|
385
|
+
],
|
|
386
|
+
[
|
|
387
|
+
offered.has("link") && h(ToolbarButton, {
|
|
388
|
+
tooltip: "Link",
|
|
389
|
+
active: activeMarks.link,
|
|
390
|
+
disabled: disabled || !linkCanEnable.value,
|
|
391
|
+
icon: LinkIcon,
|
|
392
|
+
onClick: openLinkDialog,
|
|
393
|
+
}),
|
|
394
|
+
],
|
|
395
|
+
].map((group) => group.filter((button) => button !== false)).filter((group) => group.length > 0);
|
|
371
396
|
return h("div", {
|
|
372
397
|
"class": [s.Container, attrs.class],
|
|
373
398
|
"data-variant": variant,
|
|
@@ -376,57 +401,26 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
376
401
|
"data-invalid": isInvalid ? "" : undefined,
|
|
377
402
|
"onMousedown": handleContainerMouseDown,
|
|
378
403
|
}, [
|
|
379
|
-
|
|
380
|
-
h("div", { class: s.
|
|
381
|
-
h(
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
h("div", { "class": s.ToolbarSeparator, "aria-hidden": "true" }),
|
|
396
|
-
h(ToolbarButton, {
|
|
397
|
-
tooltip: "Numbered list",
|
|
398
|
-
active: activeMarks.orderedList,
|
|
399
|
-
disabled,
|
|
400
|
-
icon: ListNumbersIcon,
|
|
401
|
-
onClick: () => editor.value?.chain().focus().toggleOrderedList().run(),
|
|
402
|
-
}),
|
|
403
|
-
h(ToolbarButton, {
|
|
404
|
-
tooltip: "Bullet list",
|
|
405
|
-
active: activeMarks.bulletList,
|
|
406
|
-
disabled,
|
|
407
|
-
icon: ListIcon,
|
|
408
|
-
onClick: () => editor.value?.chain().focus().toggleBulletList().run(),
|
|
409
|
-
}),
|
|
410
|
-
h("div", { "class": s.ToolbarSeparator, "aria-hidden": "true" }),
|
|
411
|
-
h(ToolbarButton, {
|
|
412
|
-
tooltip: "Link",
|
|
413
|
-
active: activeMarks.link,
|
|
414
|
-
disabled: disabled || !linkCanEnable.value,
|
|
415
|
-
icon: LinkIcon,
|
|
416
|
-
onClick: openLinkDialog,
|
|
417
|
-
}),
|
|
418
|
-
...(hasToolbarEnd
|
|
419
|
-
? [
|
|
420
|
-
h("div", { "class": s.ToolbarSeparator, "aria-hidden": "true" }),
|
|
421
|
-
h("div", { class: s.ToolbarEnd }, toolbarEnd),
|
|
422
|
-
]
|
|
423
|
-
: []),
|
|
424
|
-
]),
|
|
425
|
-
]),
|
|
404
|
+
groups.length || hasToolbarEnd
|
|
405
|
+
? h("div", { class: s.Toolbar, onMousedown: (e) => e.preventDefault() }, [
|
|
406
|
+
h("div", { class: s.ToolbarGroup }, [
|
|
407
|
+
...groups.flatMap((group, index) => [
|
|
408
|
+
...(index ? [h("div", { "class": s.ToolbarSeparator, "aria-hidden": "true" })] : []),
|
|
409
|
+
...group,
|
|
410
|
+
]),
|
|
411
|
+
...(hasToolbarEnd
|
|
412
|
+
? [
|
|
413
|
+
...(groups.length ? [h("div", { "class": s.ToolbarSeparator, "aria-hidden": "true" })] : []),
|
|
414
|
+
h("div", { class: s.ToolbarEnd }, toolbarEnd),
|
|
415
|
+
]
|
|
416
|
+
: []),
|
|
417
|
+
]),
|
|
418
|
+
])
|
|
419
|
+
: null,
|
|
426
420
|
h("div", { class: s.Editor, style: { minHeight: `${minHeight}px` } }, [
|
|
427
421
|
editor.value
|
|
428
422
|
? h(EditorContent, { editor: editor.value })
|
|
429
|
-
: editorFirstFrame(props.value ?? props.defaultValue ?? "", props.placeholder, props.disabled),
|
|
423
|
+
: editorFirstFrame(props.value ?? props.defaultValue ?? "", props.placeholder, props.disabled, schema),
|
|
430
424
|
]),
|
|
431
425
|
h(LinkDialog, {
|
|
432
426
|
open: linkDialogOpen.value,
|
|
@@ -443,147 +437,21 @@ const MarkdownEditorComponent = defineComponent({
|
|
|
443
437
|
};
|
|
444
438
|
},
|
|
445
439
|
});
|
|
446
|
-
// The editor reads markdown with `html: false` (markdown-it): HTML is not parsed, its characters are text, and the
|
|
447
|
-
// markdown around and inside it still is
|
|
448
|
-
function remarkWithoutHtml() {
|
|
449
|
-
const data = this.data();
|
|
450
|
-
(data.micromarkExtensions ??= []).push({ disable: { null: ["htmlFlow", "htmlText"] } });
|
|
451
|
-
}
|
|
452
|
-
// The editor's schema keeps paragraphs, lists, bold, italic, links and line breaks. ProseMirror parses anything else
|
|
453
|
-
// into them: a heading is a paragraph of its text, a code block a paragraph of its lines, a quote its paragraphs,
|
|
454
|
-
// inline code its text, an image or a rule nothing, and the text of a list item sits in a paragraph. Outside a code
|
|
455
|
-
// block it collapses white space, as the page does; the editor's text keeps its spaces (white-space: break-spaces)
|
|
456
|
-
const SCHEMA_AS_PARAGRAPH = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
457
|
-
const SCHEMA_BLOCKS = new Set(["p", "ul", "ol"]);
|
|
458
|
-
const textOf = (node) => node.value ?? (node.children ?? []).map(textOf).join("");
|
|
459
|
-
const isBlank = (node) => node.type === "text" && !node.value?.trim();
|
|
460
|
-
const lineBreak = () => ({ type: "element", tagName: "br", properties: {}, children: [] });
|
|
461
|
-
// White space of a paragraph's text as ProseMirror parses it: runs collapse to one space, none at the start of the
|
|
462
|
-
// paragraph, after a line break or after another space, none at its end
|
|
463
|
-
function collapseWhiteSpace(children) {
|
|
464
|
-
let previous = null;
|
|
465
|
-
let lineStart = true;
|
|
466
|
-
const walk = (nodes) => {
|
|
467
|
-
for (const node of nodes) {
|
|
468
|
-
if (node.type === "text") {
|
|
469
|
-
let value = (node.value ?? "").replace(/[ \t\r\n\f]+/g, " ");
|
|
470
|
-
if (value.startsWith(" ") && (lineStart || previous?.value?.endsWith(" ")))
|
|
471
|
-
value = value.slice(1);
|
|
472
|
-
node.value = value;
|
|
473
|
-
if (value) {
|
|
474
|
-
previous = node;
|
|
475
|
-
lineStart = false;
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
else if (node.tagName === "br") {
|
|
479
|
-
lineStart = true;
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
walk(node.children ?? []);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
};
|
|
486
|
-
walk(children);
|
|
487
|
-
if (previous)
|
|
488
|
-
previous.value = previous.value.replace(/ $/, "");
|
|
489
|
-
}
|
|
490
|
-
const paragraph = (children, { preserveWhiteSpace = false } = {}) => {
|
|
491
|
-
if (!preserveWhiteSpace)
|
|
492
|
-
collapseWhiteSpace(children);
|
|
493
|
-
return {
|
|
494
|
-
type: "element",
|
|
495
|
-
tagName: "p",
|
|
496
|
-
properties: {},
|
|
497
|
-
// An empty paragraph keeps its line, as ProseMirror's trailing break does
|
|
498
|
-
children: children.every((child) => child.type === "text" && !child.value) ? [lineBreak()] : children,
|
|
499
|
-
};
|
|
500
|
-
};
|
|
501
|
-
// tiptap-markdown drops the newline markdown-it writes after an element, outside a code block: a line that follows
|
|
502
|
-
// bold, a link or code joins it without a space
|
|
503
|
-
const dropNewlineAfterElements = (nodes) => nodes.map((node, index) => index && node.type === "text" && nodes[index - 1].type === "element" && node.value?.startsWith("\n")
|
|
504
|
-
? { ...node, value: node.value.slice(1) }
|
|
505
|
-
: node);
|
|
506
|
-
function toEditorSchema(nodes) {
|
|
507
|
-
return dropNewlineAfterElements(nodes).flatMap((node) => {
|
|
508
|
-
if (node.type !== "element")
|
|
509
|
-
return [node];
|
|
510
|
-
const children = node.children ?? [];
|
|
511
|
-
switch (node.tagName) {
|
|
512
|
-
case "img":
|
|
513
|
-
case "hr":
|
|
514
|
-
return [];
|
|
515
|
-
case "code":
|
|
516
|
-
return [{ type: "text", value: textOf(node) }];
|
|
517
|
-
case "pre": {
|
|
518
|
-
// ProseMirror keeps a code block's spaces and its newlines as line breaks, the last one followed by the
|
|
519
|
-
// trailing break of a paragraph that ends in a break
|
|
520
|
-
const lines = textOf(node).split("\n");
|
|
521
|
-
if (lines.every((line) => !line))
|
|
522
|
-
return [];
|
|
523
|
-
const content = [];
|
|
524
|
-
lines.forEach((line, index) => {
|
|
525
|
-
if (index)
|
|
526
|
-
content.push(lineBreak());
|
|
527
|
-
if (line)
|
|
528
|
-
content.push({ type: "text", value: line });
|
|
529
|
-
});
|
|
530
|
-
if (content[content.length - 1].tagName === "br")
|
|
531
|
-
content.push(lineBreak());
|
|
532
|
-
return [paragraph(content, { preserveWhiteSpace: true })];
|
|
533
|
-
}
|
|
534
|
-
case "blockquote":
|
|
535
|
-
return toEditorSchema(children);
|
|
536
|
-
case "p":
|
|
537
|
-
return [paragraph(toEditorSchema(children))];
|
|
538
|
-
case "li": {
|
|
539
|
-
const content = [];
|
|
540
|
-
let run = [];
|
|
541
|
-
const flush = () => {
|
|
542
|
-
if (!run.every(isBlank))
|
|
543
|
-
content.push(paragraph(run));
|
|
544
|
-
run = [];
|
|
545
|
-
};
|
|
546
|
-
for (const child of toEditorSchema(children)) {
|
|
547
|
-
if (child.type === "element" && SCHEMA_BLOCKS.has(child.tagName)) {
|
|
548
|
-
flush();
|
|
549
|
-
content.push(child);
|
|
550
|
-
}
|
|
551
|
-
else {
|
|
552
|
-
run.push(child);
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
flush();
|
|
556
|
-
// A list item starts with a paragraph, an empty one if it has no text (an empty item, an image)
|
|
557
|
-
if (content[0]?.tagName !== "p")
|
|
558
|
-
content.unshift(paragraph([]));
|
|
559
|
-
return [{ ...node, children: content }];
|
|
560
|
-
}
|
|
561
|
-
case "ul":
|
|
562
|
-
case "ol":
|
|
563
|
-
return [{ ...node, children: toEditorSchema(children).filter((child) => !isBlank(child)) }];
|
|
564
|
-
default:
|
|
565
|
-
return SCHEMA_AS_PARAGRAPH.has(node.tagName)
|
|
566
|
-
? [paragraph(toEditorSchema(children))]
|
|
567
|
-
: [{ ...node, children: toEditorSchema(children) }];
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
function rehypeEditorSchema() {
|
|
572
|
-
return (tree) => {
|
|
573
|
-
tree.children = toEditorSchema(tree.children ?? []).filter((child) => !isBlank(child));
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
440
|
/**
|
|
577
441
|
* The content before the editor exists, on the server and until it mounts: the markdown as the editor will show it,
|
|
578
442
|
* in its schema and its own boxes (EditorContent's, then ProseMirror's), so the page does not move when ProseMirror
|
|
579
443
|
* takes over, as in React. An empty editor shows its placeholder while it can be edited (`showOnlyWhenEditable`).
|
|
580
444
|
*/
|
|
581
|
-
const editorFirstFrame = (markdown, placeholder, disabled) => {
|
|
582
|
-
const hint = placeholder && !disabled;
|
|
445
|
+
const editorFirstFrame = (markdown, placeholder, disabled, schema) => {
|
|
446
|
+
const hint = placeholder && !disabled ? placeholder : undefined;
|
|
583
447
|
return h("div", null, [
|
|
584
448
|
h("div", { class: ["tiptap", s.EditorContent] }, [
|
|
585
449
|
markdown.trim()
|
|
586
|
-
? renderMarkdown({
|
|
450
|
+
? renderMarkdown({
|
|
451
|
+
children: markdown,
|
|
452
|
+
remarkPlugins: schema.breaks ? [remarkWithoutHtml, remarkLineBreaks] : [remarkWithoutHtml],
|
|
453
|
+
rehypePlugins: [rehypeEditorSchema(schema, hint)],
|
|
454
|
+
})
|
|
587
455
|
: h("p", { class: hint ? "is-editor-empty" : undefined, "data-placeholder": hint ? placeholder : undefined }, [h("br")]),
|
|
588
456
|
]),
|
|
589
457
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownEditor.js","sourceRoot":"","sources":["../../../../src/components/MarkdownEditor/MarkdownEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,CAAC,EACD,QAAQ,EACR,GAAG,EACH,KAAK,GAGN,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,YAAY,EAA6B,MAAM,cAAc,CAAA;AACtE,OAAO,QAAQ,MAAM,4BAA4B,CAAA;AACjD,OAAO,SAAS,MAAM,6BAA6B,CAAA;AACnD,OAAO,IAAI,MAAM,wBAAwB,CAAA;AACzC,OAAO,aAAa,MAAM,wBAAwB,CAAA;AAClD,OAAO,eAAe,MAAM,0BAA0B,CAAA;AACtD,OAAO,aAAa,MAAM,wBAAwB,CAAA;AAClD,OAAO,UAAU,MAAM,+BAA+B,CAAA;AACtD,OAAO,WAAW,MAAM,gCAAgC,CAAA;AACxD,OAAO,QAAQ,MAAM,6BAA6B,CAAA;AAClD,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAC/C,OAAO,WAAW,MAAM,+BAA+B,CAAA;AACvD,OAAO,SAAS,MAAM,8BAA8B,CAAA;AACpD,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,iBAAiB,CAAA;AAE/D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EACL,IAAI,IAAI,QAAQ,EAChB,MAAM,IAAI,UAAU,EACpB,IAAI,IAAI,QAAQ,EAChB,IAAI,IAAI,QAAQ,EAChB,WAAW,IAAI,eAAe,GAC/B,MAAM,kBAA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QAAQ,CAAA;IACrC,OAAO,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE;QACpB,CAAC,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,aAAa,CAAC,EAAE,EAAE;YAC/C,QAAQ,CAAC,IAAI,EAAE;gBACb,CAAC,CAAC,cAAc,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,iBAAiB,CAAC,EAAE,aAAa,EAAE,CAAC,kBAAkB,CAAC,EAAE,CAAC;gBACjH,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,EAAE,kBAAkB,EAAE,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;SAC3H,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,uBAAuB,CAAA","sourcesContent":["import {\n defineComponent,\n h,\n reactive,\n ref,\n watch,\n type Component,\n type PropType,\n} from \"vue\"\nimport { EditorContent, useEditor } from \"@tiptap/vue-3\"\nimport { getMarkRange, type Editor as CoreEditor } from \"@tiptap/core\"\nimport Document from \"@tiptap/extension-document\"\nimport Paragraph from \"@tiptap/extension-paragraph\"\nimport Text from \"@tiptap/extension-text\"\nimport BoldExtension from \"@tiptap/extension-bold\"\nimport ItalicExtension from \"@tiptap/extension-italic\"\nimport LinkExtension from \"@tiptap/extension-link\"\nimport BulletList from \"@tiptap/extension-bullet-list\"\nimport OrderedList from \"@tiptap/extension-ordered-list\"\nimport ListItem from \"@tiptap/extension-list-item\"\nimport History from \"@tiptap/extension-history\"\nimport Placeholder from \"@tiptap/extension-placeholder\"\nimport HardBreak from \"@tiptap/extension-hard-break\"\nimport { Markdown as MarkdownExtension } from \"tiptap-markdown\"\nimport type { Variants } from \"@plexui/styles/types\"\nimport { keepMovedFocus } from \"../../lib/helpers.js\"\nimport {\n Bold as BoldIcon,\n Italic as ItalicIcon,\n Link as LinkIcon,\n List as ListIcon,\n ListNumbers as ListNumbersIcon,\n} from \"../Icon/index.js\"\nimport { Tooltip } from \"../Tooltip/index.js\"\nimport { Button } from \"../Button/index.js\"\nimport { Dialog, DialogContent, DialogHeader, DialogTitle, DialogBody, DialogFooter } from \"../Dialog/index.js\"\nimport { Field } from \"../Field/index.js\"\nimport { Input } from \"../Input/index.js\"\nimport { flattenSlot } from \"../Tooltip/slot.js\"\nimport { renderMarkdown } from \"../Markdown/pipeline.js\"\nimport s from \"@plexui/styles/components/MarkdownEditor/MarkdownEditor.module.css\"\n\n// Vue port of packages/ui/src/components/MarkdownEditor/MarkdownEditor.tsx on\n// @tiptap/vue-3 with the same extensions, configured the same way, so\n// ProseMirror renders the same DOM and tiptap-markdown emits the same markdown.\n//\n// - The editor is created on mount (@tiptap/vue-3's `useEditor`, like React's\n// `immediatelyRender: false`) and destroyed on unmount.\n// - Value: `value` + `update:value` (`v-model:value`) and `change` mirror\n// React's `value` + `onChange`; `default-value` is the uncontrolled start.\n// As in React, a controlled value is only pushed into the editor when it\n// changes and differs from the editor's markdown.\n// - As in React, `update:value` / `change` also fire once when the editor is\n// created and whenever `disabled` changes (`setEditable` emits an update).\n// - Options React reads only when it creates the editor (`placeholder`, the\n// initial content) are read once here too; `id`, `aria-label`,\n// `aria-labelledby`, `aria-describedby` and `aria-invalid` follow the\n// props, as React re-applies them on render.\n// - `toolbarEnd` is the `#toolbarEnd` slot. Like React, only `class` is\n// applied (to the container); other attributes are not forwarded.\n// - The shared Dialog owns focus trapping and closing. Its portal is not part\n// of the editor's click area, so editing a link preserves its selection.\n\ntype EditorLike = Pick<CoreEditor, \"isActive\" | \"state\">\n\nconst getMarkdown = (editor: CoreEditor) =>\n (editor.storage as unknown as Record<string, { getMarkdown?: () => string }>).markdown?.getMarkdown?.() ?? \"\"\n\n// A link inserted as a text node, not as `<a>` HTML: the markdown parser runs\n// with `html: false`, so HTML would land in the text as written\nconst linkText = (text: string, href: string) => ({\n type: \"text\",\n text,\n marks: [{ type: \"link\", attrs: { href } }],\n})\n\nexport const markdownEditorStyles = {\n toolbarButton: s.ToolbarButton,\n}\n\ntype LinkSelection = { from: number; to: number; doc: CoreEditor[\"state\"][\"doc\"] }\n\nconst LinkDialog = defineComponent({\n name: \"MarkdownEditorLinkDialog\",\n props: {\n open: { type: Boolean, required: true },\n initialUrl: { type: String, required: true },\n initialTitle: { type: String, required: true },\n isEditing: { type: Boolean, required: true },\n disabled: { type: Boolean, required: true },\n onSave: { type: Function as PropType<(url: string, title: string) => void>, required: true },\n onRemove: { type: Function as PropType<() => void>, required: true },\n onCancel: { type: Function as PropType<() => void>, required: true },\n onRestoreFocus: { type: Function as PropType<(event: Event) => void>, required: true },\n },\n setup(props) {\n const url = ref(props.initialUrl)\n const title = ref(props.initialTitle)\n watch(() => [props.open, props.initialUrl, props.initialTitle] as const, ([open, initialUrl, initialTitle]) => {\n if (open) { url.value = initialUrl; title.value = initialTitle }\n })\n return () => h(Dialog, {\n \"open\": props.open,\n \"onUpdate:open\": (next: boolean) => { if (!next) props.onCancel() },\n }, { default: () => h(DialogContent, {\n width: 450, mobileVariant: \"sheet\", showClose: false,\n onCloseAutoFocus: props.onRestoreFocus,\n }, { default: () => [\n h(DialogHeader, null, { default: () => h(DialogTitle, null, { default: () => \"Link\" }) }),\n h(DialogBody, null, { default: () => h(\"div\", {\n class: s.LinkDialogFields,\n onKeydown: (event: KeyboardEvent) => {\n if (event.key === \"Enter\" && !event.isComposing && event.target instanceof HTMLInputElement) {\n event.preventDefault()\n if (!props.disabled) props.onSave(url.value, title.value)\n }\n },\n }, [\n h(Field, { label: \"URL\" }, { default: () => h(Input, {\n type: \"url\", inputmode: \"url\", autocapitalize: \"none\", autocorrect: \"off\", spellcheck: false,\n placeholder: \"Enter URL\", value: url.value, disabled: props.disabled,\n \"onUpdate:value\": (value: string) => { url.value = value },\n }) }),\n h(Field, { label: \"Link title\" }, { default: () => h(Input, {\n placeholder: \"Enter link title\", value: title.value, disabled: props.disabled,\n \"onUpdate:value\": (value: string) => { title.value = value },\n }) }),\n ]) }),\n h(DialogFooter, null, { default: () => [\n props.isEditing ? h(Button, { color: \"danger\", variant: \"soft\", disabled: props.disabled, onClick: () => { if (!props.disabled) props.onRemove() } }, { default: () => \"Remove\" }) : null,\n h(Button, { color: \"secondary\", variant: \"soft\", onClick: () => props.onCancel() }, { default: () => \"Cancel\" }),\n h(Button, { color: \"primary\", disabled: props.disabled, onClick: () => { if (!props.disabled) props.onSave(url.value, title.value) } }, { default: () => \"Save\" }),\n ] }),\n ] }) })\n },\n})\n\nconst ToolbarButton = defineComponent({\n name: \"MarkdownEditorToolbarButton\",\n props: {\n tooltip: { type: String, required: true },\n active: { type: Boolean, default: false },\n disabled: { type: Boolean, default: false },\n icon: { type: [Object, Function] as PropType<Component>, required: true },\n onClick: { type: Function as PropType<() => void>, required: true },\n },\n setup(props) {\n return () =>\n h(\n Tooltip,\n { content: props.tooltip, compact: true },\n {\n default: () =>\n h(\n Button,\n {\n \"color\": \"secondary\", \"variant\": \"ghost\", \"size\": \"2xs\", \"iconSize\": \"sm\", \"uniform\": true, \"mobileMaterial\": \"flat\",\n \"class\": s.ToolbarButton,\n \"data-active\": props.active || undefined,\n \"selected\": props.active,\n // Formatting buttons are toggles: announce their on/off state\n \"aria-pressed\": props.active,\n // React DOM never calls onClick on a disabled button, even\n // for a dispatched event; Vue's listener would run\n \"onClick\": () => {\n if (!props.disabled) props.onClick()\n },\n \"disabled\": props.disabled,\n \"aria-label\": props.tooltip,\n },\n { default: () => h(props.icon) },\n ),\n },\n )\n },\n})\n\nconst MarkdownEditorComponent = defineComponent({\n name: \"MarkdownEditor\",\n inheritAttrs: false,\n props: {\n /** Visual style of the editor. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"outline\" | \"soft\">>, default: \"outline\" },\n /** Disables editing and the toolbar. @default false */\n disabled: { type: Boolean, default: false },\n /** Marks the editor as invalid. @default false */\n invalid: { type: Boolean, default: false },\n /** Placeholder text when empty (read when the editor is created) */\n placeholder: String,\n /** Controlled value as a markdown string (`v-model:value`) */\n value: { type: String, default: undefined },\n /** Default value as a markdown string for uncontrolled mode */\n defaultValue: { type: String, default: undefined },\n /** Minimum visible rows. @default 1 */\n rows: { type: Number, default: 1 },\n /** `id` of the editable element */\n id: String,\n /** Accessible name of the editable element; a `<label for>` cannot name a contenteditable region */\n ariaLabel: String,\n /** Id of the element that names the editor, such as a Field label */\n ariaLabelledby: String,\n /** `aria-describedby` of the editable element */\n ariaDescribedby: String,\n /** Sets `aria-invalid=\"true\"` on the editable element and the invalid style */\n ariaInvalid: { type: Boolean, default: undefined },\n },\n emits: {\n /** The editor's markdown after a change (`v-model:value`) */\n \"update:value\": (markdown: string) => typeof markdown === \"string\",\n /** Same as `update:value` (React's `onChange`) */\n \"change\": (markdown: string) => typeof markdown === \"string\",\n },\n setup(props, { slots, attrs, emit }) {\n const focused = ref(false)\n const linkDialogOpen = ref(false)\n const linkDialogInitial = ref({ url: \"\", title: \"\" })\n const activeMarks = reactive({\n bold: false,\n italic: false,\n link: false,\n orderedList: false,\n bulletList: false,\n })\n const linkCanEnable = ref(false)\n const isControlled = () => props.value !== undefined\n let suppressChange = false\n let linkSelection: LinkSelection | null = null\n let restoreEditorFocus = false\n\n const syncToolbar = (e: EditorLike) => {\n Object.assign(activeMarks, {\n bold: e.isActive(\"bold\"),\n italic: e.isActive(\"italic\"),\n link: e.isActive(\"link\"),\n orderedList: e.isActive(\"orderedList\"),\n bulletList: e.isActive(\"bulletList\"),\n })\n linkCanEnable.value = !e.state.selection.empty || e.isActive(\"link\")\n }\n\n const editorAttributes = () => ({\n \"class\": s.EditorContent,\n \"role\": \"textbox\",\n \"aria-multiline\": \"true\",\n ...(props.id && { id: props.id }),\n ...(props.ariaLabel && { \"aria-label\": props.ariaLabel }),\n ...(props.ariaLabelledby && { \"aria-labelledby\": props.ariaLabelledby }),\n ...(props.ariaDescribedby && { \"aria-describedby\": props.ariaDescribedby }),\n ...(props.ariaInvalid && { \"aria-invalid\": \"true\" }),\n })\n\n const editor = useEditor({\n extensions: [\n Document,\n Paragraph,\n Text,\n HardBreak,\n BoldExtension,\n ItalicExtension,\n LinkExtension.configure({\n openOnClick: false,\n HTMLAttributes: { rel: \"noopener noreferrer nofollow\" },\n }),\n BulletList,\n OrderedList,\n ListItem,\n History,\n MarkdownExtension.configure({\n html: false,\n transformPastedText: true,\n transformCopiedText: true,\n }),\n ...(props.placeholder ? [Placeholder.configure({ placeholder: props.placeholder })] : []),\n ],\n content: props.value ?? props.defaultValue ?? \"\",\n editable: !props.disabled,\n editorProps: {\n attributes: editorAttributes(),\n },\n onFocus: () => {\n focused.value = true\n },\n onBlur: () => {\n focused.value = false\n },\n onUpdate: ({ editor: e }) => {\n if (suppressChange) return\n const md = getMarkdown(e)\n emit(\"update:value\", md)\n emit(\"change\", md)\n },\n onSelectionUpdate: ({ editor: e }) => syncToolbar(e),\n onTransaction: ({ editor: e }) => {\n syncToolbar(e)\n if (linkSelection && linkSelection.doc !== e.state.doc) {\n linkSelection = null\n restoreEditorFocus = false\n linkDialogOpen.value = false\n }\n },\n })\n\n // React re-applies the editor props on every render\n watch(editorAttributes, (attributes) => {\n editor.value?.setOptions({ editorProps: { attributes } })\n })\n\n watch(\n () => [editor.value, props.value, isControlled()] as const,\n ([instance, value, controlled]) => {\n if (!instance || !controlled) return\n const currentMd = getMarkdown(instance)\n if (value !== currentMd) {\n suppressChange = true\n instance.commands.setContent(value || \"\", { emitUpdate: false })\n suppressChange = false\n }\n },\n )\n\n watch(\n () => [editor.value, props.disabled] as const,\n ([instance, disabled]) => {\n if (instance) instance.setEditable(!disabled)\n if (disabled) {\n linkSelection = null\n restoreEditorFocus = false\n linkDialogOpen.value = false\n }\n },\n )\n\n const handleContainerMouseDown = (evt: MouseEvent) => {\n const instance = editor.value\n if (props.disabled || !instance) return\n const target = evt.target\n if (!(target instanceof Element) || !(evt.currentTarget instanceof Element) || !evt.currentTarget.contains(target)) return\n if (target.closest(\"button, [type='button'], [role='button'], a, input, label\")) return\n // A press in the text places the caret there itself\n if (instance.view.dom.contains(target)) return\n if (instance.isFocused) return\n evt.preventDefault()\n instance.commands.focus(\"end\")\n }\n\n const openLinkDialog = () => {\n const instance = editor.value\n if (!instance || props.disabled) return\n const url = instance.getAttributes(\"link\").href ?? \"\"\n const selection = instance.state.selection\n const range = selection.empty && instance.isActive(\"link\")\n ? getMarkRange(selection.$from, instance.schema.marks.link, { href: url })\n : selection\n if (!range) return\n linkSelection = { from: range.from, to: range.to, doc: instance.state.doc }\n restoreEditorFocus = true\n linkDialogInitial.value = { url, title: instance.state.doc.textBetween(range.from, range.to, \"\") }\n linkDialogOpen.value = true\n }\n const handleLinkSave = (url: string, title: string) => {\n const instance = editor.value\n const range = linkSelection\n if (!instance || props.disabled || !range) return\n linkDialogOpen.value = false\n if (range.doc !== instance.state.doc) { restoreEditorFocus = false; return }\n linkSelection = null\n const selectedText = instance.state.doc.textBetween(range.from, range.to, \"\")\n const chain = instance.chain().setTextSelection({ from: range.from, to: range.to })\n if (!url) chain.unsetLink().run()\n else if (title && title !== selectedText) chain.insertContent(linkText(title, url)).run()\n else chain.setLink({ href: url }).run()\n }\n const handleLinkRemove = () => {\n const instance = editor.value\n const range = linkSelection\n if (!instance || props.disabled || !range) return\n linkDialogOpen.value = false\n if (range.doc !== instance.state.doc) { restoreEditorFocus = false; return }\n linkSelection = null\n instance.chain().setTextSelection({ from: range.from, to: range.to }).unsetLink().run()\n }\n const handleLinkCancel = () => { linkDialogOpen.value = false }\n const handleRestoreFocus = (event: Event) => {\n keepMovedFocus(event)\n const shouldRestore = restoreEditorFocus && !event.defaultPrevented\n event.preventDefault()\n restoreEditorFocus = false\n linkSelection = null\n const instance = editor.value\n if (shouldRestore && instance && !instance.isDestroyed && !props.disabled) {\n const closingScope = event.target\n requestAnimationFrame(() => {\n if (instance.isDestroyed || !instance.isEditable) return\n const doc = instance.view.dom.ownerDocument\n const active = doc.activeElement\n if (active && active !== doc.body && !instance.view.dom.contains(active)\n && !(closingScope instanceof Node && closingScope.contains(active))) return\n // Check at the actual restore, then focus synchronously: Tiptap's\n // focus command queues another frame that could steal moved focus.\n instance.view.focus()\n })\n }\n }\n\n return () => {\n const { variant, disabled, invalid, ariaInvalid, rows } = props\n const isInvalid = invalid || ariaInvalid\n const minHeight = 20 * rows + 16\n // React renders the slot only for a truthy `toolbarEnd`\n const toolbarEnd = slots.toolbarEnd?.()\n const hasToolbarEnd = flattenSlot(toolbarEnd).length > 0\n\n return h(\n \"div\",\n {\n \"class\": [s.Container, attrs.class],\n \"data-variant\": variant,\n \"data-focused\": String(focused.value),\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-invalid\": isInvalid ? \"\" : undefined,\n \"onMousedown\": handleContainerMouseDown,\n },\n [\n h(\"div\", { class: s.Toolbar, onMousedown: (e: MouseEvent) => e.preventDefault() }, [\n h(\"div\", { class: s.ToolbarGroup }, [\n h(ToolbarButton, {\n tooltip: \"Bold\",\n active: activeMarks.bold,\n disabled,\n icon: BoldIcon,\n onClick: () => editor.value?.chain().focus().toggleBold().run(),\n }),\n h(ToolbarButton, {\n tooltip: \"Italic\",\n active: activeMarks.italic,\n disabled,\n icon: ItalicIcon,\n onClick: () => editor.value?.chain().focus().toggleItalic().run(),\n }),\n\n h(\"div\", { \"class\": s.ToolbarSeparator, \"aria-hidden\": \"true\" }),\n\n h(ToolbarButton, {\n tooltip: \"Numbered list\",\n active: activeMarks.orderedList,\n disabled,\n icon: ListNumbersIcon,\n onClick: () => editor.value?.chain().focus().toggleOrderedList().run(),\n }),\n h(ToolbarButton, {\n tooltip: \"Bullet list\",\n active: activeMarks.bulletList,\n disabled,\n icon: ListIcon,\n onClick: () => editor.value?.chain().focus().toggleBulletList().run(),\n }),\n\n h(\"div\", { \"class\": s.ToolbarSeparator, \"aria-hidden\": \"true\" }),\n\n h(ToolbarButton, {\n tooltip: \"Link\",\n active: activeMarks.link,\n disabled: disabled || !linkCanEnable.value,\n icon: LinkIcon,\n onClick: openLinkDialog,\n }),\n\n ...(hasToolbarEnd\n ? [\n h(\"div\", { \"class\": s.ToolbarSeparator, \"aria-hidden\": \"true\" }),\n h(\"div\", { class: s.ToolbarEnd }, toolbarEnd),\n ]\n : []),\n ]),\n ]),\n\n h(\"div\", { class: s.Editor, style: { minHeight: `${minHeight}px` } }, [\n editor.value\n ? h(EditorContent, { editor: editor.value })\n : editorFirstFrame(props.value ?? props.defaultValue ?? \"\", props.placeholder, props.disabled),\n ]),\n\n h(LinkDialog, {\n open: linkDialogOpen.value,\n initialUrl: linkDialogInitial.value.url,\n initialTitle: linkDialogInitial.value.title,\n isEditing: !!linkDialogInitial.value.url,\n disabled,\n onRestoreFocus: handleRestoreFocus,\n onSave: handleLinkSave,\n onRemove: handleLinkRemove,\n onCancel: handleLinkCancel,\n }),\n ],\n )\n }\n },\n})\n\n// Nodes of the HTML (hast) tree the first frame rewrites\ntype HtmlNode = {\n type: string\n tagName?: string\n value?: string\n properties?: Record<string, unknown>\n children?: HtmlNode[]\n}\n\n// The editor reads markdown with `html: false` (markdown-it): HTML is not parsed, its characters are text, and the\n// markdown around and inside it still is\nfunction remarkWithoutHtml(this: { data(): object }) {\n const data = this.data() as { micromarkExtensions?: unknown[] }\n ;(data.micromarkExtensions ??= []).push({ disable: { null: [\"htmlFlow\", \"htmlText\"] } })\n}\n\n// The editor's schema keeps paragraphs, lists, bold, italic, links and line breaks. ProseMirror parses anything else\n// into them: a heading is a paragraph of its text, a code block a paragraph of its lines, a quote its paragraphs,\n// inline code its text, an image or a rule nothing, and the text of a list item sits in a paragraph. Outside a code\n// block it collapses white space, as the page does; the editor's text keeps its spaces (white-space: break-spaces)\nconst SCHEMA_AS_PARAGRAPH = new Set([\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"])\nconst SCHEMA_BLOCKS = new Set([\"p\", \"ul\", \"ol\"])\nconst textOf = (node: HtmlNode): string => node.value ?? (node.children ?? []).map(textOf).join(\"\")\nconst isBlank = (node: HtmlNode) => node.type === \"text\" && !node.value?.trim()\nconst lineBreak = (): HtmlNode => ({ type: \"element\", tagName: \"br\", properties: {}, children: [] })\n\n// White space of a paragraph's text as ProseMirror parses it: runs collapse to one space, none at the start of the\n// paragraph, after a line break or after another space, none at its end\nfunction collapseWhiteSpace(children: HtmlNode[]) {\n let previous: HtmlNode | null = null\n let lineStart = true\n const walk = (nodes: HtmlNode[]) => {\n for (const node of nodes) {\n if (node.type === \"text\") {\n let value = (node.value ?? \"\").replace(/[ \\t\\r\\n\\f]+/g, \" \")\n if (value.startsWith(\" \") && (lineStart || previous?.value?.endsWith(\" \"))) value = value.slice(1)\n node.value = value\n if (value) {\n previous = node\n lineStart = false\n }\n } else if (node.tagName === \"br\") {\n lineStart = true\n } else {\n walk(node.children ?? [])\n }\n }\n }\n walk(children)\n if (previous) (previous as HtmlNode).value = (previous as HtmlNode).value!.replace(/ $/, \"\")\n}\n\nconst paragraph = (children: HtmlNode[], { preserveWhiteSpace = false } = {}): HtmlNode => {\n if (!preserveWhiteSpace) collapseWhiteSpace(children)\n return {\n type: \"element\",\n tagName: \"p\",\n properties: {},\n // An empty paragraph keeps its line, as ProseMirror's trailing break does\n children: children.every((child) => child.type === \"text\" && !child.value) ? [lineBreak()] : children,\n }\n}\n\n// tiptap-markdown drops the newline markdown-it writes after an element, outside a code block: a line that follows\n// bold, a link or code joins it without a space\nconst dropNewlineAfterElements = (nodes: HtmlNode[]) =>\n nodes.map((node, index) =>\n index && node.type === \"text\" && nodes[index - 1]!.type === \"element\" && node.value?.startsWith(\"\\n\")\n ? { ...node, value: node.value.slice(1) }\n : node,\n )\n\nfunction toEditorSchema(nodes: HtmlNode[]): HtmlNode[] {\n return dropNewlineAfterElements(nodes).flatMap((node): HtmlNode[] => {\n if (node.type !== \"element\") return [node]\n const children = node.children ?? []\n switch (node.tagName) {\n case \"img\":\n case \"hr\":\n return []\n case \"code\":\n return [{ type: \"text\", value: textOf(node) }]\n case \"pre\": {\n // ProseMirror keeps a code block's spaces and its newlines as line breaks, the last one followed by the\n // trailing break of a paragraph that ends in a break\n const lines = textOf(node).split(\"\\n\")\n if (lines.every((line) => !line)) return []\n const content: HtmlNode[] = []\n lines.forEach((line, index) => {\n if (index) content.push(lineBreak())\n if (line) content.push({ type: \"text\", value: line })\n })\n if (content[content.length - 1]!.tagName === \"br\") content.push(lineBreak())\n return [paragraph(content, { preserveWhiteSpace: true })]\n }\n case \"blockquote\":\n return toEditorSchema(children)\n case \"p\":\n return [paragraph(toEditorSchema(children))]\n case \"li\": {\n const content: HtmlNode[] = []\n let run: HtmlNode[] = []\n const flush = () => {\n if (!run.every(isBlank)) content.push(paragraph(run))\n run = []\n }\n for (const child of toEditorSchema(children)) {\n if (child.type === \"element\" && SCHEMA_BLOCKS.has(child.tagName!)) {\n flush()\n content.push(child)\n } else {\n run.push(child)\n }\n }\n flush()\n // A list item starts with a paragraph, an empty one if it has no text (an empty item, an image)\n if (content[0]?.tagName !== \"p\") content.unshift(paragraph([]))\n return [{ ...node, children: content }]\n }\n case \"ul\":\n case \"ol\":\n return [{ ...node, children: toEditorSchema(children).filter((child) => !isBlank(child)) }]\n default:\n return SCHEMA_AS_PARAGRAPH.has(node.tagName!)\n ? [paragraph(toEditorSchema(children))]\n : [{ ...node, children: toEditorSchema(children) }]\n }\n })\n}\nfunction rehypeEditorSchema() {\n return (tree: HtmlNode) => {\n tree.children = toEditorSchema(tree.children ?? []).filter((child) => !isBlank(child))\n }\n}\n\n/**\n * The content before the editor exists, on the server and until it mounts: the markdown as the editor will show it,\n * in its schema and its own boxes (EditorContent's, then ProseMirror's), so the page does not move when ProseMirror\n * takes over, as in React. An empty editor shows its placeholder while it can be edited (`showOnlyWhenEditable`).\n */\nconst editorFirstFrame = (markdown: string, placeholder: string | undefined, disabled: boolean) => {\n const hint = placeholder && !disabled\n return h(\"div\", null, [\n h(\"div\", { class: [\"tiptap\", s.EditorContent] }, [\n markdown.trim()\n ? renderMarkdown({ children: markdown, remarkPlugins: [remarkWithoutHtml], rehypePlugins: [rehypeEditorSchema] })\n : h(\"p\", { class: hint ? \"is-editor-empty\" : undefined, \"data-placeholder\": hint ? placeholder : undefined }, [h(\"br\")]),\n ]),\n ])\n}\n\n/**\n * Compact rich text editor for markdown, with a formatting toolbar (bold,\n * italic, lists, links). Bind the markdown with `v-model:value`.\n */\nexport const MarkdownEditor = MarkdownEditorComponent\n\nexport type MarkdownEditorProps = InstanceType<typeof MarkdownEditorComponent>[\"$props\"]\n"]}
|
|
1
|
+
{"version":3,"file":"MarkdownEditor.js","sourceRoot":"","sources":["../../../../src/components/MarkdownEditor/MarkdownEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,CAAC,EACD,QAAQ,EACR,GAAG,EACH,KAAK,GAGN,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,YAAY,EAA6B,MAAM,cAAc,CAAA;AAEtE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EACL,wBAAwB,EACxB,oBAAoB,EACpB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GAGlB,MAAM,mCAAmC,CAAA;AAC1C,OAAO,EACL,IAAI,IAAI,QAAQ,EAChB,MAAM,IAAI,UAAU,EACpB,IAAI,IAAI,QAAQ,EAChB,IAAI,IAAI,QAAQ,EAChB,WAAW,IAAI,eAAe,GAC/B,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,UAAU,EA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useEditor } from \"@tiptap/vue-3\"\nimport { getMarkRange, type Editor as CoreEditor } from \"@tiptap/core\"\nimport type { Variants } from \"@plexui/styles/types\"\nimport { keepMovedFocus } from \"../../lib/helpers.js\"\nimport {\n markdownEditorExtensions,\n markdownEditorSchema,\n rehypeEditorSchema,\n remarkLineBreaks,\n remarkWithoutHtml,\n type MarkdownEditorFormat,\n type MarkdownEditorSchema,\n} from \"../../lib/markdownEditorSchema.js\"\nimport {\n Bold as BoldIcon,\n Italic as ItalicIcon,\n Link as LinkIcon,\n List as ListIcon,\n ListNumbers as ListNumbersIcon,\n} from \"../Icon/index.js\"\nimport { Tooltip } from \"../Tooltip/index.js\"\nimport { Button } from \"../Button/index.js\"\nimport { Dialog, DialogContent, DialogHeader, DialogTitle, DialogBody, DialogFooter } from \"../Dialog/index.js\"\nimport { Field } from \"../Field/index.js\"\nimport { Input } from \"../Input/index.js\"\nimport { flattenSlot } from \"../Tooltip/slot.js\"\nimport { renderMarkdown } from \"../Markdown/pipeline.js\"\nimport s from \"@plexui/styles/components/MarkdownEditor/MarkdownEditor.module.css\"\n\n// Vue port of packages/ui/src/components/MarkdownEditor/MarkdownEditor.tsx on\n// @tiptap/vue-3 with the same extensions, configured the same way, so\n// ProseMirror renders the same DOM and tiptap-markdown emits the same markdown.\n//\n// - The editor is created on mount (@tiptap/vue-3's `useEditor`, like React's\n// `immediatelyRender: false`) and destroyed on unmount.\n// - Value: `value` + `update:value` (`v-model:value`) and `change` mirror\n// React's `value` + `onChange`; `default-value` is the uncontrolled start.\n// As in React, a controlled value is only pushed into the editor when it\n// changes and differs from the editor's markdown.\n// - As in React, `update:value` / `change` also fire once when the editor is\n// created and whenever `disabled` changes (`setEditable` emits an update).\n// - Options React reads only when it creates the editor (`placeholder`,\n// `formats`, `breaks`, the initial content) are read once here too; `id`, `aria-label`,\n// `aria-labelledby`, `aria-describedby` and `aria-invalid` follow the\n// props, as React re-applies them on render.\n// - `toolbarEnd` is the `#toolbarEnd` slot. Like React, only `class` is\n// applied (to the container); other attributes are not forwarded.\n// - The shared Dialog owns focus trapping and closing. Its portal is not part\n// of the editor's click area, so editing a link preserves its selection.\n\ntype EditorLike = Pick<CoreEditor, \"isActive\" | \"state\">\n\nconst getMarkdown = (editor: CoreEditor) =>\n (editor.storage as unknown as Record<string, { getMarkdown?: () => string }>).markdown?.getMarkdown?.() ?? \"\"\n\n// A link inserted as a text node, not as `<a>` HTML: the markdown parser runs\n// with `html: false`, so HTML would land in the text as written\nconst linkText = (text: string, href: string) => ({\n type: \"text\",\n text,\n marks: [{ type: \"link\", attrs: { href } }],\n})\n\nexport const markdownEditorStyles = {\n toolbarButton: s.ToolbarButton,\n}\n\nexport type { MarkdownEditorFormat }\n\ntype LinkSelection = { from: number; to: number; doc: CoreEditor[\"state\"][\"doc\"] }\n\nconst LinkDialog = defineComponent({\n name: \"MarkdownEditorLinkDialog\",\n props: {\n open: { type: Boolean, required: true },\n initialUrl: { type: String, required: true },\n initialTitle: { type: String, required: true },\n isEditing: { type: Boolean, required: true },\n disabled: { type: Boolean, required: true },\n onSave: { type: Function as PropType<(url: string, title: string) => void>, required: true },\n onRemove: { type: Function as PropType<() => void>, required: true },\n onCancel: { type: Function as PropType<() => void>, required: true },\n onRestoreFocus: { type: Function as PropType<(event: Event) => void>, required: true },\n },\n setup(props) {\n const url = ref(props.initialUrl)\n const title = ref(props.initialTitle)\n watch(() => [props.open, props.initialUrl, props.initialTitle] as const, ([open, initialUrl, initialTitle]) => {\n if (open) { url.value = initialUrl; title.value = initialTitle }\n })\n return () => h(Dialog, {\n \"open\": props.open,\n \"onUpdate:open\": (next: boolean) => { if (!next) props.onCancel() },\n }, { default: () => h(DialogContent, {\n width: 450, mobileVariant: \"sheet\", showClose: false,\n onCloseAutoFocus: props.onRestoreFocus,\n }, { default: () => [\n h(DialogHeader, null, { default: () => h(DialogTitle, null, { default: () => \"Link\" }) }),\n h(DialogBody, null, { default: () => h(\"div\", {\n class: s.LinkDialogFields,\n onKeydown: (event: KeyboardEvent) => {\n if (event.key === \"Enter\" && !event.isComposing && event.target instanceof HTMLInputElement) {\n event.preventDefault()\n if (!props.disabled) props.onSave(url.value, title.value)\n }\n },\n }, [\n h(Field, { label: \"URL\" }, { default: () => h(Input, {\n type: \"url\", inputmode: \"url\", autocapitalize: \"none\", autocorrect: \"off\", spellcheck: false,\n placeholder: \"Enter URL\", value: url.value, disabled: props.disabled,\n \"onUpdate:value\": (value: string) => { url.value = value },\n }) }),\n h(Field, { label: \"Link title\" }, { default: () => h(Input, {\n placeholder: \"Enter link title\", value: title.value, disabled: props.disabled,\n \"onUpdate:value\": (value: string) => { title.value = value },\n }) }),\n ]) }),\n h(DialogFooter, null, { default: () => [\n props.isEditing ? h(Button, { color: \"danger\", variant: \"soft\", disabled: props.disabled, onClick: () => { if (!props.disabled) props.onRemove() } }, { default: () => \"Remove\" }) : null,\n h(Button, { color: \"secondary\", variant: \"soft\", onClick: () => props.onCancel() }, { default: () => \"Cancel\" }),\n h(Button, { color: \"primary\", disabled: props.disabled, onClick: () => { if (!props.disabled) props.onSave(url.value, title.value) } }, { default: () => \"Save\" }),\n ] }),\n ] }) })\n },\n})\n\nconst ToolbarButton = defineComponent({\n name: \"MarkdownEditorToolbarButton\",\n props: {\n tooltip: { type: String, required: true },\n active: { type: Boolean, default: false },\n disabled: { type: Boolean, default: false },\n icon: { type: [Object, Function] as PropType<Component>, required: true },\n onClick: { type: Function as PropType<() => void>, required: true },\n },\n setup(props) {\n return () =>\n h(\n Tooltip,\n { content: props.tooltip, compact: true },\n {\n default: () =>\n h(\n Button,\n {\n \"color\": \"secondary\", \"variant\": \"ghost\", \"size\": \"2xs\", \"iconSize\": \"sm\", \"uniform\": true, \"mobileMaterial\": \"flat\",\n \"class\": s.ToolbarButton,\n \"data-active\": props.active || undefined,\n \"selected\": props.active,\n // Formatting buttons are toggles: announce their on/off state\n \"aria-pressed\": props.active,\n // React DOM never calls onClick on a disabled button, even\n // for a dispatched event; Vue's listener would run\n \"onClick\": () => {\n if (!props.disabled) props.onClick()\n },\n \"disabled\": props.disabled,\n \"aria-label\": props.tooltip,\n },\n { default: () => h(props.icon) },\n ),\n },\n )\n },\n})\n\nconst MarkdownEditorComponent = defineComponent({\n name: \"MarkdownEditor\",\n inheritAttrs: false,\n props: {\n /** Visual style of the editor. @default \"outline\" */\n variant: { type: String as PropType<Variants<\"outline\" | \"soft\">>, default: \"outline\" },\n /** Disables editing and the toolbar. @default false */\n disabled: { type: Boolean, default: false },\n /** Marks the editor as invalid. @default false */\n invalid: { type: Boolean, default: false },\n /** Placeholder text when empty (read when the editor is created) */\n placeholder: String,\n /** Controlled value as a markdown string (`v-model:value`) */\n value: { type: String, default: undefined },\n /** Default value as a markdown string for uncontrolled mode */\n defaultValue: { type: String, default: undefined },\n /**\n * The formats the editor offers, read when the editor is created. A format left out has no toolbar button,\n * shortcut or input rule; pasted and incoming content keeps its text without it, and the markdown does not write it.\n * @default [\"bold\", \"italic\", \"orderedList\", \"bulletList\", \"link\"]\n */\n formats: { type: Array as PropType<MarkdownEditorFormat[]>, default: undefined },\n /**\n * A single newline is a line break, read and written as one \"\\n\", read when the editor is created. Without it a\n * line break is written as a backslash and a newline, and a single newline joins the lines. @default false\n */\n breaks: { type: Boolean, default: false },\n /** Minimum visible rows. @default 1 */\n rows: { type: Number, default: 1 },\n /** `id` of the editable element */\n id: String,\n /** Accessible name of the editable element; a `<label for>` cannot name a contenteditable region */\n ariaLabel: String,\n /** Id of the element that names the editor, such as a Field label */\n ariaLabelledby: String,\n /** `aria-describedby` of the editable element */\n ariaDescribedby: String,\n /** Sets `aria-invalid=\"true\"` on the editable element and the invalid style */\n ariaInvalid: { type: Boolean, default: undefined },\n },\n emits: {\n /** The editor's markdown after a change (`v-model:value`) */\n \"update:value\": (markdown: string) => typeof markdown === \"string\",\n /** Same as `update:value` (React's `onChange`) */\n \"change\": (markdown: string) => typeof markdown === \"string\",\n },\n setup(props, { slots, attrs, emit }) {\n // The schema is the editor's, made once with it, as the toolbar offers what the schema has\n const schema = markdownEditorSchema(props.formats, props.breaks)\n const focused = ref(false)\n const linkDialogOpen = ref(false)\n const linkDialogInitial = ref({ url: \"\", title: \"\" })\n const activeMarks = reactive({\n bold: false,\n italic: false,\n link: false,\n orderedList: false,\n bulletList: false,\n })\n const linkCanEnable = ref(false)\n const isControlled = () => props.value !== undefined\n let suppressChange = false\n let linkSelection: LinkSelection | null = null\n let restoreEditorFocus = false\n\n const syncToolbar = (e: EditorLike) => {\n Object.assign(activeMarks, {\n bold: e.isActive(\"bold\"),\n italic: e.isActive(\"italic\"),\n link: e.isActive(\"link\"),\n orderedList: e.isActive(\"orderedList\"),\n bulletList: e.isActive(\"bulletList\"),\n })\n linkCanEnable.value = !e.state.selection.empty || e.isActive(\"link\")\n }\n\n const editorAttributes = () => ({\n \"class\": s.EditorContent,\n \"role\": \"textbox\",\n \"aria-multiline\": \"true\",\n ...(props.id && { id: props.id }),\n ...(props.ariaLabel && { \"aria-label\": props.ariaLabel }),\n ...(props.ariaLabelledby && { \"aria-labelledby\": props.ariaLabelledby }),\n ...(props.ariaDescribedby && { \"aria-describedby\": props.ariaDescribedby }),\n ...(props.ariaInvalid && { \"aria-invalid\": \"true\" }),\n })\n\n const editor = useEditor({\n extensions: markdownEditorExtensions(schema, props.placeholder),\n content: props.value ?? props.defaultValue ?? \"\",\n editable: !props.disabled,\n editorProps: {\n attributes: editorAttributes(),\n },\n onFocus: () => {\n focused.value = true\n },\n onBlur: () => {\n focused.value = false\n },\n onUpdate: ({ editor: e }) => {\n if (suppressChange) return\n const md = getMarkdown(e)\n emit(\"update:value\", md)\n emit(\"change\", md)\n },\n onSelectionUpdate: ({ editor: e }) => syncToolbar(e),\n onTransaction: ({ editor: e }) => {\n syncToolbar(e)\n if (linkSelection && linkSelection.doc !== e.state.doc) {\n linkSelection = null\n restoreEditorFocus = false\n linkDialogOpen.value = false\n }\n },\n })\n\n // React re-applies the editor props on every render\n watch(editorAttributes, (attributes) => {\n editor.value?.setOptions({ editorProps: { attributes } })\n })\n\n watch(\n () => [editor.value, props.value, isControlled()] as const,\n ([instance, value, controlled]) => {\n if (!instance || !controlled) return\n const currentMd = getMarkdown(instance)\n if (value !== currentMd) {\n suppressChange = true\n instance.commands.setContent(value || \"\", { emitUpdate: false })\n suppressChange = false\n }\n },\n )\n\n watch(\n () => [editor.value, props.disabled] as const,\n ([instance, disabled]) => {\n if (instance) instance.setEditable(!disabled)\n if (disabled) {\n linkSelection = null\n restoreEditorFocus = false\n linkDialogOpen.value = false\n }\n },\n )\n\n const handleContainerMouseDown = (evt: MouseEvent) => {\n const instance = editor.value\n if (props.disabled || !instance) return\n const target = evt.target\n if (!(target instanceof Element) || !(evt.currentTarget instanceof Element) || !evt.currentTarget.contains(target)) return\n if (target.closest(\"button, [type='button'], [role='button'], a, input, label\")) return\n // A press in the text places the caret there itself\n if (instance.view.dom.contains(target)) return\n if (instance.isFocused) return\n evt.preventDefault()\n instance.commands.focus(\"end\")\n }\n\n const openLinkDialog = () => {\n const instance = editor.value\n if (!instance || props.disabled) return\n const url = instance.getAttributes(\"link\").href ?? \"\"\n const selection = instance.state.selection\n const range = selection.empty && instance.isActive(\"link\")\n ? getMarkRange(selection.$from, instance.schema.marks.link, { href: url })\n : selection\n if (!range) return\n linkSelection = { from: range.from, to: range.to, doc: instance.state.doc }\n restoreEditorFocus = true\n linkDialogInitial.value = { url, title: instance.state.doc.textBetween(range.from, range.to, \"\") }\n linkDialogOpen.value = true\n }\n const handleLinkSave = (url: string, title: string) => {\n const instance = editor.value\n const range = linkSelection\n if (!instance || props.disabled || !range) return\n linkDialogOpen.value = false\n if (range.doc !== instance.state.doc) { restoreEditorFocus = false; return }\n linkSelection = null\n const selectedText = instance.state.doc.textBetween(range.from, range.to, \"\")\n const chain = instance.chain().setTextSelection({ from: range.from, to: range.to })\n if (!url) chain.unsetLink().run()\n else if (title && title !== selectedText) chain.insertContent(linkText(title, url)).run()\n else chain.setLink({ href: url }).run()\n }\n const handleLinkRemove = () => {\n const instance = editor.value\n const range = linkSelection\n if (!instance || props.disabled || !range) return\n linkDialogOpen.value = false\n if (range.doc !== instance.state.doc) { restoreEditorFocus = false; return }\n linkSelection = null\n instance.chain().setTextSelection({ from: range.from, to: range.to }).unsetLink().run()\n }\n const handleLinkCancel = () => { linkDialogOpen.value = false }\n const handleRestoreFocus = (event: Event) => {\n keepMovedFocus(event)\n const shouldRestore = restoreEditorFocus && !event.defaultPrevented\n event.preventDefault()\n restoreEditorFocus = false\n linkSelection = null\n const instance = editor.value\n if (shouldRestore && instance && !instance.isDestroyed && !props.disabled) {\n const closingScope = event.target\n requestAnimationFrame(() => {\n if (instance.isDestroyed || !instance.isEditable) return\n const doc = instance.view.dom.ownerDocument\n const active = doc.activeElement\n if (active && active !== doc.body && !instance.view.dom.contains(active)\n && !(closingScope instanceof Node && closingScope.contains(active))) return\n // Check at the actual restore, then focus synchronously: Tiptap's\n // focus command queues another frame that could steal moved focus.\n instance.view.focus()\n })\n }\n }\n\n return () => {\n const { variant, disabled, invalid, ariaInvalid, rows } = props\n const isInvalid = invalid || ariaInvalid\n const minHeight = 20 * rows + 16\n // React renders the slot only for a truthy `toolbarEnd`\n const toolbarEnd = slots.toolbarEnd?.()\n const hasToolbarEnd = flattenSlot(toolbarEnd).length > 0\n const offered = schema.formats\n // Groups of the offered formats, a separator between two of them\n const groups = [\n [\n offered.has(\"bold\") && h(ToolbarButton, {\n tooltip: \"Bold\",\n active: activeMarks.bold,\n disabled,\n icon: BoldIcon,\n onClick: () => editor.value?.chain().focus().toggleBold().run(),\n }),\n offered.has(\"italic\") && h(ToolbarButton, {\n tooltip: \"Italic\",\n active: activeMarks.italic,\n disabled,\n icon: ItalicIcon,\n onClick: () => editor.value?.chain().focus().toggleItalic().run(),\n }),\n ],\n [\n offered.has(\"orderedList\") && h(ToolbarButton, {\n tooltip: \"Numbered list\",\n active: activeMarks.orderedList,\n disabled,\n icon: ListNumbersIcon,\n onClick: () => editor.value?.chain().focus().toggleOrderedList().run(),\n }),\n offered.has(\"bulletList\") && h(ToolbarButton, {\n tooltip: \"Bullet list\",\n active: activeMarks.bulletList,\n disabled,\n icon: ListIcon,\n onClick: () => editor.value?.chain().focus().toggleBulletList().run(),\n }),\n ],\n [\n offered.has(\"link\") && h(ToolbarButton, {\n tooltip: \"Link\",\n active: activeMarks.link,\n disabled: disabled || !linkCanEnable.value,\n icon: LinkIcon,\n onClick: openLinkDialog,\n }),\n ],\n ].map((group) => group.filter((button) => button !== false)).filter((group) => group.length > 0)\n\n return h(\n \"div\",\n {\n \"class\": [s.Container, attrs.class],\n \"data-variant\": variant,\n \"data-focused\": String(focused.value),\n \"data-disabled\": disabled ? \"\" : undefined,\n \"data-invalid\": isInvalid ? \"\" : undefined,\n \"onMousedown\": handleContainerMouseDown,\n },\n [\n groups.length || hasToolbarEnd\n ? h(\"div\", { class: s.Toolbar, onMousedown: (e: MouseEvent) => e.preventDefault() }, [\n h(\"div\", { class: s.ToolbarGroup }, [\n ...groups.flatMap((group, index) => [\n ...(index ? [h(\"div\", { \"class\": s.ToolbarSeparator, \"aria-hidden\": \"true\" })] : []),\n ...group,\n ]),\n ...(hasToolbarEnd\n ? [\n ...(groups.length ? [h(\"div\", { \"class\": s.ToolbarSeparator, \"aria-hidden\": \"true\" })] : []),\n h(\"div\", { class: s.ToolbarEnd }, toolbarEnd),\n ]\n : []),\n ]),\n ])\n : null,\n\n h(\"div\", { class: s.Editor, style: { minHeight: `${minHeight}px` } }, [\n editor.value\n ? h(EditorContent, { editor: editor.value })\n : editorFirstFrame(props.value ?? props.defaultValue ?? \"\", props.placeholder, props.disabled, schema),\n ]),\n\n h(LinkDialog, {\n open: linkDialogOpen.value,\n initialUrl: linkDialogInitial.value.url,\n initialTitle: linkDialogInitial.value.title,\n isEditing: !!linkDialogInitial.value.url,\n disabled,\n onRestoreFocus: handleRestoreFocus,\n onSave: handleLinkSave,\n onRemove: handleLinkRemove,\n onCancel: handleLinkCancel,\n }),\n ],\n )\n }\n },\n})\n\n/**\n * The content before the editor exists, on the server and until it mounts: the markdown as the editor will show it,\n * in its schema and its own boxes (EditorContent's, then ProseMirror's), so the page does not move when ProseMirror\n * takes over, as in React. An empty editor shows its placeholder while it can be edited (`showOnlyWhenEditable`).\n */\nconst editorFirstFrame = (markdown: string, placeholder: string | undefined, disabled: boolean, schema: MarkdownEditorSchema) => {\n const hint = placeholder && !disabled ? placeholder : undefined\n return h(\"div\", null, [\n h(\"div\", { class: [\"tiptap\", s.EditorContent] }, [\n markdown.trim()\n ? renderMarkdown({\n children: markdown,\n remarkPlugins: schema.breaks ? [remarkWithoutHtml, remarkLineBreaks] : [remarkWithoutHtml],\n rehypePlugins: [rehypeEditorSchema(schema, hint)],\n })\n : h(\"p\", { class: hint ? \"is-editor-empty\" : undefined, \"data-placeholder\": hint ? placeholder : undefined }, [h(\"br\")]),\n ]),\n ])\n}\n\n/**\n * Compact rich text editor for markdown, with a formatting toolbar (bold,\n * italic, lists, links). Bind the markdown with `v-model:value`.\n */\nexport const MarkdownEditor = MarkdownEditorComponent\n\nexport type MarkdownEditorProps = InstanceType<typeof MarkdownEditorComponent>[\"$props\"]\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/MarkdownEditor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/MarkdownEditor/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAuD,MAAM,qBAAqB,CAAA","sourcesContent":["export { MarkdownEditor, markdownEditorStyles, type MarkdownEditorFormat, type MarkdownEditorProps } from \"./MarkdownEditor.js\"\n"]}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import Document from "@tiptap/extension-document";
|
|
2
|
+
import Paragraph from "@tiptap/extension-paragraph";
|
|
3
|
+
import Text from "@tiptap/extension-text";
|
|
4
|
+
import BoldExtension from "@tiptap/extension-bold";
|
|
5
|
+
import ItalicExtension from "@tiptap/extension-italic";
|
|
6
|
+
import LinkExtension from "@tiptap/extension-link";
|
|
7
|
+
import BulletList from "@tiptap/extension-bullet-list";
|
|
8
|
+
import OrderedList from "@tiptap/extension-ordered-list";
|
|
9
|
+
import ListItem from "@tiptap/extension-list-item";
|
|
10
|
+
import History from "@tiptap/extension-history";
|
|
11
|
+
import Placeholder from "@tiptap/extension-placeholder";
|
|
12
|
+
import HardBreak from "@tiptap/extension-hard-break";
|
|
13
|
+
import { Markdown as MarkdownExtension } from "tiptap-markdown";
|
|
14
|
+
export const MARKDOWN_EDITOR_FORMATS = ["bold", "italic", "orderedList", "bulletList", "link"];
|
|
15
|
+
export const markdownEditorSchema = (formats = MARKDOWN_EDITOR_FORMATS, breaks = false) => ({ formats: new Set(formats), breaks });
|
|
16
|
+
const LISTS = [
|
|
17
|
+
["bulletList", "ul"],
|
|
18
|
+
["orderedList", "ol"],
|
|
19
|
+
];
|
|
20
|
+
// Where the line after a line break starts in the markdown being written, and the paragraph it is in
|
|
21
|
+
const lineStarts = new WeakMap();
|
|
22
|
+
// A line break before more text: "\n" with `breaks`, otherwise a backslash and a newline, a line break in any
|
|
23
|
+
// markdown. Breaks at the end of a paragraph write nothing, as in tiptap-markdown. With `breaks`, "\n" ends a line of
|
|
24
|
+
// text; a line with none (the paragraph's first, or one between two breaks) would be blank and end the paragraph, so
|
|
25
|
+
// its break is a backslash and a newline too
|
|
26
|
+
const lineBreak = (breaks) => HardBreak.extend({
|
|
27
|
+
addStorage() {
|
|
28
|
+
return {
|
|
29
|
+
...this.parent?.(),
|
|
30
|
+
markdown: {
|
|
31
|
+
serialize(state, node, parent, index) {
|
|
32
|
+
for (let i = index + 1; i < parent.childCount; i++) {
|
|
33
|
+
if (parent.child(i).type === node.type)
|
|
34
|
+
continue;
|
|
35
|
+
let line = "";
|
|
36
|
+
for (let j = index - 1; j >= 0 && parent.child(j).type !== node.type; j--)
|
|
37
|
+
line = (parent.child(j).text ?? "") + line;
|
|
38
|
+
state.write(breaks && /[^ \t]/.test(line) ? "\n" : "\\\n");
|
|
39
|
+
lineStarts.set(state, { at: state.out.length, parent });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
parse: {},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
// What opens a block at the start of a markdown line, after its white space: a "-" or "+" item, a "#" heading, a "1."
|
|
49
|
+
// or "1)" item. "*" is escaped wherever it is, ">" is written as ">"
|
|
50
|
+
const LINE_OPENER = /^(?:\d+(?=[.)](?:[ \t]|$))|(?=-|\+(?:[ \t]|$)|#{1,6}(?:[ \t]|$)))/;
|
|
51
|
+
// A line of "=" makes the line above it a heading
|
|
52
|
+
const HEADING_UNDERLINE = /^(?==+[ \t]*$)/;
|
|
53
|
+
const escapeHtml = (text) => text.replace(/</g, "<").replace(/>/g, ">");
|
|
54
|
+
// Text as tiptap-markdown writes it (with "<" and ">" as entities), escaping what would open a block at the start of
|
|
55
|
+
// a line, so the line keeps its text when the markdown is read again. After a line break the line continues the
|
|
56
|
+
// paragraph and is never code, so an opener is escaped after any white space, also white space written before it
|
|
57
|
+
// (a marked one is written outside its mark). At the start of a paragraph, as prosemirror-markdown does, after up to
|
|
58
|
+
// three spaces: four columns start code there, where an escape would show
|
|
59
|
+
const EditorText = Text.extend({
|
|
60
|
+
addStorage() {
|
|
61
|
+
return {
|
|
62
|
+
...this.parent?.(),
|
|
63
|
+
markdown: {
|
|
64
|
+
serialize(state, node, parent) {
|
|
65
|
+
const text = escapeHtml(node.text ?? "");
|
|
66
|
+
const lineStart = lineStarts.get(state);
|
|
67
|
+
const afterBreak = lineStart?.parent === parent && !state.atBlockStart && /^[ \t]*$/.test(state.out.slice(lineStart.at));
|
|
68
|
+
const space = (afterBreak ? /^[ \t]*/ : state.atBlockStart ? /^ {0,3}/ : null)?.exec(text)?.[0];
|
|
69
|
+
const rest = space === undefined ? "" : text.slice(space.length);
|
|
70
|
+
const opener = space === undefined ? null : LINE_OPENER.exec(rest) ?? (afterBreak ? HEADING_UNDERLINE.exec(rest) : null);
|
|
71
|
+
// The opener is escaped here; prosemirror-markdown's own escape at the start of a paragraph would escape it twice
|
|
72
|
+
state.atBlockStart = false;
|
|
73
|
+
if (!opener)
|
|
74
|
+
return state.text(text);
|
|
75
|
+
const at = space.length + opener[0].length;
|
|
76
|
+
state.text(`${text.slice(0, at)}\\`, false);
|
|
77
|
+
state.text(text.slice(at));
|
|
78
|
+
},
|
|
79
|
+
parse: {},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
// An item of a list the editor offers. An item of the other list is its paragraphs, not an item of the offered one,
|
|
85
|
+
// which ProseMirror would otherwise wrap it in
|
|
86
|
+
const listItemOf = (tags) => ListItem.extend({
|
|
87
|
+
parseHTML() {
|
|
88
|
+
return [{ tag: "li", getAttrs: (element) => (tags.has(element.parentElement?.localName ?? "") ? null : false) }];
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* The editor's extensions. A format left out has no mark or node: its shortcut and input rule are gone, and pasted or
|
|
93
|
+
* incoming content keeps its text without it, so the markdown going out does not write it either.
|
|
94
|
+
*/
|
|
95
|
+
export const markdownEditorExtensions = ({ formats, breaks }, placeholder) => {
|
|
96
|
+
const lists = LISTS.filter(([format]) => formats.has(format));
|
|
97
|
+
return [
|
|
98
|
+
Document,
|
|
99
|
+
Paragraph,
|
|
100
|
+
EditorText,
|
|
101
|
+
lineBreak(breaks),
|
|
102
|
+
...(formats.has("bold") ? [BoldExtension] : []),
|
|
103
|
+
...(formats.has("italic") ? [ItalicExtension] : []),
|
|
104
|
+
...(formats.has("link")
|
|
105
|
+
? [LinkExtension.configure({ openOnClick: false, HTMLAttributes: { rel: "noopener noreferrer nofollow" } })]
|
|
106
|
+
: []),
|
|
107
|
+
...(formats.has("bulletList") ? [BulletList] : []),
|
|
108
|
+
...(formats.has("orderedList") ? [OrderedList] : []),
|
|
109
|
+
...(lists.length === LISTS.length ? [ListItem] : lists.length ? [listItemOf(new Set(lists.map(([, tag]) => tag)))] : []),
|
|
110
|
+
History,
|
|
111
|
+
MarkdownExtension.configure({ html: false, breaks, transformPastedText: true, transformCopiedText: true }),
|
|
112
|
+
...(placeholder ? [Placeholder.configure({ placeholder })] : []),
|
|
113
|
+
];
|
|
114
|
+
};
|
|
115
|
+
// The editor reads markdown with `html: false` (markdown-it): HTML is not parsed, its characters are text, and the
|
|
116
|
+
// markdown around and inside it still is
|
|
117
|
+
export function remarkWithoutHtml() {
|
|
118
|
+
const data = this.data();
|
|
119
|
+
(data.micromarkExtensions ??= []).push({ disable: { null: ["htmlFlow", "htmlText"] } });
|
|
120
|
+
}
|
|
121
|
+
// The newlines of a text node's source, in order: a line ending, or a character reference markdown-it reads as a
|
|
122
|
+
// newline in the text (of at most seven decimal or six hexadecimal digits). A backslash escape is neither, so
|
|
123
|
+
// "\\ " is no reference
|
|
124
|
+
const SOURCE_NEWLINES = /\\[\s\S]|&(?:#0{0,5}1[03]|#[xX]0{0,5}[aAdD]|NewLine);|\r\n?|\n/g;
|
|
125
|
+
// With `breaks`, markdown-it reads a line ending in a paragraph as a line break (a newline from a character reference
|
|
126
|
+
// stays text). It drops the spaces at the end of the line, keeping a tab before them, and the spaces and tabs at the
|
|
127
|
+
// start of the next one. remark drops the white space at the end of a line from the text, so it is taken from the source
|
|
128
|
+
export function remarkLineBreaks() {
|
|
129
|
+
return (tree, file) => {
|
|
130
|
+
const source = String(file.value ?? "");
|
|
131
|
+
const split = (node) => {
|
|
132
|
+
if (node.type !== "text") {
|
|
133
|
+
if (node.children)
|
|
134
|
+
node.children = node.children.flatMap(split);
|
|
135
|
+
return [node];
|
|
136
|
+
}
|
|
137
|
+
const value = node.value ?? "";
|
|
138
|
+
const { start, end } = node.position ?? {};
|
|
139
|
+
const raw = start?.offset !== undefined && end?.offset !== undefined ? source.slice(start.offset, end.offset) : value;
|
|
140
|
+
// The newlines of the value in order: the source of each (a line ending or a reference) and, for a line ending,
|
|
141
|
+
// the white space before it
|
|
142
|
+
const newlines = [...raw.matchAll(SOURCE_NEWLINES)]
|
|
143
|
+
.filter(([match]) => !match.startsWith("\\"))
|
|
144
|
+
.map((match) => ({ source: match[0], before: /[ \t]*$/.exec(raw.slice(0, match.index))[0] }));
|
|
145
|
+
const lines = [""];
|
|
146
|
+
let index = 0;
|
|
147
|
+
for (let at = value.slice(index).search(/[\r\n]/); at >= 0; at = value.slice(index).search(/[\r\n]/)) {
|
|
148
|
+
const newline = newlines.shift() ?? { source: "\n", before: "" };
|
|
149
|
+
if (newline.source.startsWith("&")) {
|
|
150
|
+
lines[lines.length - 1] += value.slice(index, index + at + 1);
|
|
151
|
+
index += at + 1;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
// The end of the line as markdown-it reads it: the white space remark dropped, without its spaces at the end
|
|
155
|
+
// (white space from a character reference is text, and stays)
|
|
156
|
+
lines[lines.length - 1] += value.slice(index, index + at) + newline.before.replace(/ +$/, "");
|
|
157
|
+
lines.push("");
|
|
158
|
+
index += at + (newline.source === "\r\n" && value.startsWith("\r\n", index + at) ? 2 : 1);
|
|
159
|
+
}
|
|
160
|
+
lines[lines.length - 1] += value.slice(index);
|
|
161
|
+
return lines.flatMap((line, at) => {
|
|
162
|
+
const text = at ? line.replace(/^[ \t]+/, "") : line;
|
|
163
|
+
return [...(at ? [{ type: "break" }] : []), ...(text ? [{ ...node, value: text }] : [])];
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
split(tree);
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
// The editor's schema keeps paragraphs, line breaks and the formats it offers. ProseMirror parses anything else into
|
|
170
|
+
// them: a heading is a paragraph of its text, a code block a paragraph of its lines, a quote its paragraphs, inline
|
|
171
|
+
// code its text, an image or a rule nothing, the text of a list item sits in a paragraph, a mark left out is its text
|
|
172
|
+
// and a list left out its items' paragraphs. Outside a code block it collapses white space, as the page does; the
|
|
173
|
+
// editor's text keeps its spaces (white-space: break-spaces)
|
|
174
|
+
const SCHEMA_AS_PARAGRAPH = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
175
|
+
const SCHEMA_BLOCKS = new Set(["p", "ul", "ol"]);
|
|
176
|
+
const MARKS = new Map([["strong", "bold"], ["em", "italic"], ["a", "link"]]);
|
|
177
|
+
const textOf = (node) => node.value ?? (node.children ?? []).map(textOf).join("");
|
|
178
|
+
const isBlank = (node) => node.type === "text" && !node.value?.trim();
|
|
179
|
+
const lineBreakElement = () => ({ type: "element", tagName: "br", properties: {}, children: [] });
|
|
180
|
+
// White space of a paragraph's text as ProseMirror parses it: runs collapse to one space, none at the start of the
|
|
181
|
+
// paragraph, after a line break or after another space, none at its end
|
|
182
|
+
function collapseWhiteSpace(children) {
|
|
183
|
+
let previous = null;
|
|
184
|
+
let lineStart = true;
|
|
185
|
+
const walk = (nodes) => {
|
|
186
|
+
for (const node of nodes) {
|
|
187
|
+
if (node.type === "text") {
|
|
188
|
+
let value = (node.value ?? "").replace(/[ \t\r\n\f]+/g, " ");
|
|
189
|
+
if (value.startsWith(" ") && (lineStart || previous?.value?.endsWith(" ")))
|
|
190
|
+
value = value.slice(1);
|
|
191
|
+
node.value = value;
|
|
192
|
+
if (value) {
|
|
193
|
+
previous = node;
|
|
194
|
+
lineStart = false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if (node.tagName === "br") {
|
|
198
|
+
lineStart = true;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
walk(node.children ?? []);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
walk(children);
|
|
206
|
+
if (previous)
|
|
207
|
+
previous.value = previous.value.replace(/ $/, "");
|
|
208
|
+
}
|
|
209
|
+
const paragraph = (children, { preserveWhiteSpace = false } = {}) => {
|
|
210
|
+
if (!preserveWhiteSpace)
|
|
211
|
+
collapseWhiteSpace(children);
|
|
212
|
+
return {
|
|
213
|
+
type: "element",
|
|
214
|
+
tagName: "p",
|
|
215
|
+
properties: {},
|
|
216
|
+
// An empty paragraph keeps its line, as ProseMirror's trailing break does
|
|
217
|
+
children: children.every((child) => child.type === "text" && !child.value) ? [lineBreakElement()] : children,
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
// tiptap-markdown drops the newline markdown-it writes after an element, outside a code block: a line that follows
|
|
221
|
+
// bold, a link or code joins it without a space
|
|
222
|
+
const dropNewlineAfterElements = (nodes) => nodes.map((node, index) => index && node.type === "text" && nodes[index - 1].type === "element" && node.value?.startsWith("\n")
|
|
223
|
+
? { ...node, value: node.value.slice(1) }
|
|
224
|
+
: node);
|
|
225
|
+
function toEditorSchema(nodes, formats) {
|
|
226
|
+
// The blocks of a list item: its text in paragraphs, around its lists
|
|
227
|
+
const itemBlocks = (children) => {
|
|
228
|
+
const content = [];
|
|
229
|
+
let run = [];
|
|
230
|
+
const flush = () => {
|
|
231
|
+
if (!run.every(isBlank))
|
|
232
|
+
content.push(paragraph(run));
|
|
233
|
+
run = [];
|
|
234
|
+
};
|
|
235
|
+
for (const child of toEditorSchema(children, formats)) {
|
|
236
|
+
if (child.type === "element" && SCHEMA_BLOCKS.has(child.tagName)) {
|
|
237
|
+
flush();
|
|
238
|
+
content.push(child);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
run.push(child);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
flush();
|
|
245
|
+
return content;
|
|
246
|
+
};
|
|
247
|
+
return dropNewlineAfterElements(nodes).flatMap((node) => {
|
|
248
|
+
if (node.type !== "element")
|
|
249
|
+
return [node];
|
|
250
|
+
const children = node.children ?? [];
|
|
251
|
+
switch (node.tagName) {
|
|
252
|
+
case "img":
|
|
253
|
+
case "hr":
|
|
254
|
+
return [];
|
|
255
|
+
case "code":
|
|
256
|
+
return [{ type: "text", value: textOf(node) }];
|
|
257
|
+
case "pre": {
|
|
258
|
+
// ProseMirror keeps a code block's spaces and its newlines as line breaks, the last one followed by the
|
|
259
|
+
// trailing break of a paragraph that ends in a break
|
|
260
|
+
const lines = textOf(node).split("\n");
|
|
261
|
+
if (lines.every((line) => !line))
|
|
262
|
+
return [];
|
|
263
|
+
const content = [];
|
|
264
|
+
lines.forEach((line, index) => {
|
|
265
|
+
if (index)
|
|
266
|
+
content.push(lineBreakElement());
|
|
267
|
+
if (line)
|
|
268
|
+
content.push({ type: "text", value: line });
|
|
269
|
+
});
|
|
270
|
+
if (content[content.length - 1].tagName === "br")
|
|
271
|
+
content.push(lineBreakElement());
|
|
272
|
+
return [paragraph(content, { preserveWhiteSpace: true })];
|
|
273
|
+
}
|
|
274
|
+
case "blockquote":
|
|
275
|
+
return toEditorSchema(children, formats);
|
|
276
|
+
case "p":
|
|
277
|
+
return [paragraph(toEditorSchema(children, formats))];
|
|
278
|
+
case "li": {
|
|
279
|
+
const content = itemBlocks(children);
|
|
280
|
+
// A list item starts with a paragraph, an empty one if it has no text (an empty item, an image)
|
|
281
|
+
if (content[0]?.tagName !== "p")
|
|
282
|
+
content.unshift(paragraph([]));
|
|
283
|
+
return [{ ...node, children: content }];
|
|
284
|
+
}
|
|
285
|
+
case "ul":
|
|
286
|
+
case "ol": {
|
|
287
|
+
const items = children.filter((child) => child.tagName === "li");
|
|
288
|
+
return formats.has(node.tagName === "ul" ? "bulletList" : "orderedList")
|
|
289
|
+
? [{ ...node, children: toEditorSchema(items, formats) }]
|
|
290
|
+
: items.flatMap((item) => itemBlocks(item.children ?? []));
|
|
291
|
+
}
|
|
292
|
+
default: {
|
|
293
|
+
const mark = MARKS.get(node.tagName);
|
|
294
|
+
if (mark && !formats.has(mark))
|
|
295
|
+
return toEditorSchema(children, formats);
|
|
296
|
+
return SCHEMA_AS_PARAGRAPH.has(node.tagName)
|
|
297
|
+
? [paragraph(toEditorSchema(children, formats))]
|
|
298
|
+
: [{ ...node, children: toEditorSchema(children, formats) }];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The first frame's HTML in the editor's schema. A document left with no block is the empty paragraph ProseMirror
|
|
305
|
+
* gives it, with the placeholder the editor would show (`placeholder` only while it can be edited).
|
|
306
|
+
*/
|
|
307
|
+
export const rehypeEditorSchema = ({ formats }, placeholder) => function editorSchema() {
|
|
308
|
+
return (tree) => {
|
|
309
|
+
const blocks = toEditorSchema(tree.children ?? [], formats).filter((child) => !isBlank(child));
|
|
310
|
+
tree.children = blocks.length
|
|
311
|
+
? blocks
|
|
312
|
+
: [{
|
|
313
|
+
...paragraph([]),
|
|
314
|
+
properties: placeholder ? { className: ["is-editor-empty"], dataPlaceholder: placeholder } : {},
|
|
315
|
+
}];
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
//# sourceMappingURL=markdownEditorSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownEditorSchema.js","sourceRoot":"","sources":["../../../src/lib/markdownEditorSchema.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,4BAA4B,CAAA;AACjD,OAAO,SAAS,MAAM,6BAA6B,CAAA;AACnD,OAAO,IAAI,MAAM,wBAAwB,CAAA;AACzC,OAAO,aAAa,MAAM,wBAAwB,CAAA;AAClD,OAAO,eAAe,MAAM,0BAA0B,CAAA;AACtD,OAAO,aAAa,MAAM,wBAAwB,CAAA;AAClD,OAAO,UAAU,MAAM,+BAA+B,CAAA;AACtD,OAAO,WAAW,MAAM,gCAAgC,CAAA;AACxD,OAAO,QAAQ,MAAM,6BAA6B,CAAA;AAClD,OAAO,OAAO,MAAM,2BAA2B,CAAA;AAC/C,OAAO,WAAW,MAAM,+BAA+B,CAAA;AACvD,OAAO,SAAS,MAAM,8BAA8B,CAAA;AACpD,OAAO,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,iBAAiB,CAAA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;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,OAAO,EAAwB,EAAE,WAAoB,EAAE,EAAE,CAC5F,SAAS,YAAY;IACnB,OAAO,CAAC,IAAc,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;QAC9F,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM;YAC3B,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,CAAC;oBACC,GAAG,SAAS,CAAC,EAAE,CAAC;oBAChB,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,iBAAiB,CAAC,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE;iBAChG,CAAC,CAAA;IACR,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type { AnyExtension } from \"@tiptap/core\"\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\"\nimport Document from \"@tiptap/extension-document\"\nimport Paragraph from \"@tiptap/extension-paragraph\"\nimport Text from \"@tiptap/extension-text\"\nimport BoldExtension from \"@tiptap/extension-bold\"\nimport ItalicExtension from \"@tiptap/extension-italic\"\nimport LinkExtension from \"@tiptap/extension-link\"\nimport BulletList from \"@tiptap/extension-bullet-list\"\nimport OrderedList from \"@tiptap/extension-ordered-list\"\nimport ListItem from \"@tiptap/extension-list-item\"\nimport History from \"@tiptap/extension-history\"\nimport Placeholder from \"@tiptap/extension-placeholder\"\nimport HardBreak from \"@tiptap/extension-hard-break\"\nimport { Markdown as MarkdownExtension } from \"tiptap-markdown\"\n\n// The Markdown Editor's schema, shared by React and Vue: the TipTap extensions for the formats it offers, how its\n// markdown is written, and the first frame (its markdown as the editor will show it, before the editor exists)\n\nexport type MarkdownEditorFormat = \"bold\" | \"italic\" | \"orderedList\" | \"bulletList\" | \"link\"\n\nexport const MARKDOWN_EDITOR_FORMATS: readonly MarkdownEditorFormat[] = [\"bold\", \"italic\", \"orderedList\", \"bulletList\", \"link\"]\n\nexport type MarkdownEditorSchema = {\n /** The formats the editor offers: a toolbar button, its shortcut and input rule, and a mark or node in the schema */\n formats: ReadonlySet<MarkdownEditorFormat>\n /** A single newline is a line break, read and written as one \"\\n\" */\n breaks: boolean\n}\n\nexport const markdownEditorSchema = (\n formats: readonly MarkdownEditorFormat[] = MARKDOWN_EDITOR_FORMATS,\n breaks = false,\n): MarkdownEditorSchema => ({ formats: new Set(formats), breaks })\n\nconst LISTS = [\n [\"bulletList\", \"ul\"],\n [\"orderedList\", \"ol\"],\n] as const\n\n/* ------------------------------------------------------------------ */\n/* Writing markdown */\n/* ------------------------------------------------------------------ */\n\ntype SerializerState = {\n out: string\n atBlockStart: boolean\n write: (content?: string) => void\n text: (text: string, escape?: boolean) => void\n}\n\n// Where the line after a line break starts in the markdown being written, and the paragraph it is in\nconst lineStarts = new WeakMap<SerializerState, { at: number; parent: ProseMirrorNode }>()\n\n// A line break before more text: \"\\n\" with `breaks`, otherwise a backslash and a newline, a line break in any\n// markdown. Breaks at the end of a paragraph write nothing, as in tiptap-markdown. With `breaks`, \"\\n\" ends a line of\n// text; a line with none (the paragraph's first, or one between two breaks) would be blank and end the paragraph, so\n// its break is a backslash and a newline too\nconst lineBreak = (breaks: boolean) =>\n HardBreak.extend({\n addStorage() {\n return {\n ...this.parent?.(),\n markdown: {\n serialize(state: SerializerState, node: ProseMirrorNode, parent: ProseMirrorNode, index: number) {\n for (let i = index + 1; i < parent.childCount; i++) {\n if (parent.child(i).type === node.type) continue\n let line = \"\"\n for (let j = index - 1; j >= 0 && parent.child(j).type !== node.type; j--) line = (parent.child(j).text ?? \"\") + line\n state.write(breaks && /[^ \\t]/.test(line) ? \"\\n\" : \"\\\\\\n\")\n lineStarts.set(state, { at: state.out.length, parent })\n return\n }\n },\n parse: {},\n },\n }\n },\n })\n\n// What opens a block at the start of a markdown line, after its white space: a \"-\" or \"+\" item, a \"#\" heading, a \"1.\"\n// or \"1)\" item. \"*\" is escaped wherever it is, \">\" is written as \">\"\nconst LINE_OPENER = /^(?:\\d+(?=[.)](?:[ \\t]|$))|(?=-|\\+(?:[ \\t]|$)|#{1,6}(?:[ \\t]|$)))/\n// A line of \"=\" makes the line above it a heading\nconst HEADING_UNDERLINE = /^(?==+[ \\t]*$)/\nconst escapeHtml = (text: string) => text.replace(/</g, \"<\").replace(/>/g, \">\")\n\n// Text as tiptap-markdown writes it (with \"<\" and \">\" as entities), escaping what would open a block at the start of\n// a line, so the line keeps its text when the markdown is read again. After a line break the line continues the\n// paragraph and is never code, so an opener is escaped after any white space, also white space written before it\n// (a marked one is written outside its mark). At the start of a paragraph, as prosemirror-markdown does, after up to\n// three spaces: four columns start code there, where an escape would show\nconst EditorText = Text.extend({\n addStorage() {\n return {\n ...this.parent?.(),\n markdown: {\n serialize(state: SerializerState, node: ProseMirrorNode, parent: ProseMirrorNode) {\n const text = escapeHtml(node.text ?? \"\")\n const lineStart = lineStarts.get(state)\n const afterBreak = lineStart?.parent === parent && !state.atBlockStart && /^[ \\t]*$/.test(state.out.slice(lineStart.at))\n const space = (afterBreak ? /^[ \\t]*/ : state.atBlockStart ? /^ {0,3}/ : null)?.exec(text)?.[0]\n const rest = space === undefined ? \"\" : text.slice(space.length)\n const opener = space === undefined ? null : LINE_OPENER.exec(rest) ?? (afterBreak ? HEADING_UNDERLINE.exec(rest) : null)\n // The opener is escaped here; prosemirror-markdown's own escape at the start of a paragraph would escape it twice\n state.atBlockStart = false\n if (!opener) return state.text(text)\n const at = space!.length + opener[0].length\n state.text(`${text.slice(0, at)}\\\\`, false)\n state.text(text.slice(at))\n },\n parse: {},\n },\n }\n },\n})\n\n// An item of a list the editor offers. An item of the other list is its paragraphs, not an item of the offered one,\n// which ProseMirror would otherwise wrap it in\nconst listItemOf = (tags: ReadonlySet<string>) =>\n ListItem.extend({\n parseHTML() {\n return [{ tag: \"li\", getAttrs: (element: HTMLElement) => (tags.has(element.parentElement?.localName ?? \"\") ? null : false) }]\n },\n })\n\n/**\n * The editor's extensions. A format left out has no mark or node: its shortcut and input rule are gone, and pasted or\n * incoming content keeps its text without it, so the markdown going out does not write it either.\n */\nexport const markdownEditorExtensions = ({ formats, breaks }: MarkdownEditorSchema, placeholder?: string): AnyExtension[] => {\n const lists = LISTS.filter(([format]) => formats.has(format))\n return [\n Document,\n Paragraph,\n EditorText,\n lineBreak(breaks),\n ...(formats.has(\"bold\") ? [BoldExtension] : []),\n ...(formats.has(\"italic\") ? [ItalicExtension] : []),\n ...(formats.has(\"link\")\n ? [LinkExtension.configure({ openOnClick: false, HTMLAttributes: { rel: \"noopener noreferrer nofollow\" } })]\n : []),\n ...(formats.has(\"bulletList\") ? [BulletList] : []),\n ...(formats.has(\"orderedList\") ? [OrderedList] : []),\n ...(lists.length === LISTS.length ? [ListItem] : lists.length ? [listItemOf(new Set(lists.map(([, tag]) => tag)))] : []),\n History,\n MarkdownExtension.configure({ html: false, breaks, transformPastedText: true, transformCopiedText: true }),\n ...(placeholder ? [Placeholder.configure({ placeholder })] : []),\n ]\n}\n\n/* ------------------------------------------------------------------ */\n/* First frame */\n/* ------------------------------------------------------------------ */\n\n// Nodes of the markdown (mdast) and HTML (hast) trees the first frame rewrites\ntype MarkdownNode = {\n type: string\n value?: string\n position?: { start: { offset?: number }; end: { offset?: number } }\n children?: MarkdownNode[]\n}\ntype HtmlNode = {\n type: string\n tagName?: string\n value?: string\n properties?: Record<string, unknown>\n children?: HtmlNode[]\n}\n\n// The editor reads markdown with `html: false` (markdown-it): HTML is not parsed, its characters are text, and the\n// markdown around and inside it still is\nexport function remarkWithoutHtml(this: { data(): object }) {\n const data = this.data() as { micromarkExtensions?: unknown[] }\n ;(data.micromarkExtensions ??= []).push({ disable: { null: [\"htmlFlow\", \"htmlText\"] } })\n}\n\n// The newlines of a text node's source, in order: a line ending, or a character reference markdown-it reads as a\n// newline in the text (of at most seven decimal or six hexadecimal digits). A backslash escape is neither, so\n// \"\\\\ \" is no reference\nconst SOURCE_NEWLINES = /\\\\[\\s\\S]|&(?:#0{0,5}1[03]|#[xX]0{0,5}[aAdD]|NewLine);|\\r\\n?|\\n/g\n\n// With `breaks`, markdown-it reads a line ending in a paragraph as a line break (a newline from a character reference\n// stays text). It drops the spaces at the end of the line, keeping a tab before them, and the spaces and tabs at the\n// start of the next one. remark drops the white space at the end of a line from the text, so it is taken from the source\nexport function remarkLineBreaks() {\n return (tree: MarkdownNode, file: { value?: unknown }) => {\n const source = String(file.value ?? \"\")\n const split = (node: MarkdownNode): MarkdownNode[] => {\n if (node.type !== \"text\") {\n if (node.children) node.children = node.children.flatMap(split)\n return [node]\n }\n const value = node.value ?? \"\"\n const { start, end } = node.position ?? {}\n const raw = start?.offset !== undefined && end?.offset !== undefined ? source.slice(start.offset, end.offset) : value\n // The newlines of the value in order: the source of each (a line ending or a reference) and, for a line ending,\n // the white space before it\n const newlines = [...raw.matchAll(SOURCE_NEWLINES)]\n .filter(([match]) => !match.startsWith(\"\\\\\"))\n .map((match) => ({ source: match[0], before: /[ \\t]*$/.exec(raw.slice(0, match.index))![0] }))\n const lines = [\"\"]\n let index = 0\n for (let at = value.slice(index).search(/[\\r\\n]/); at >= 0; at = value.slice(index).search(/[\\r\\n]/)) {\n const newline = newlines.shift() ?? { source: \"\\n\", before: \"\" }\n if (newline.source.startsWith(\"&\")) {\n lines[lines.length - 1] += value.slice(index, index + at + 1)\n index += at + 1\n continue\n }\n // The end of the line as markdown-it reads it: the white space remark dropped, without its spaces at the end\n // (white space from a character reference is text, and stays)\n lines[lines.length - 1] += value.slice(index, index + at) + newline.before.replace(/ +$/, \"\")\n lines.push(\"\")\n index += at + (newline.source === \"\\r\\n\" && value.startsWith(\"\\r\\n\", index + at) ? 2 : 1)\n }\n lines[lines.length - 1] += value.slice(index)\n return lines.flatMap((line, at) => {\n const text = at ? line.replace(/^[ \\t]+/, \"\") : line\n return [...(at ? [{ type: \"break\" }] : []), ...(text ? [{ ...node, value: text }] : [])]\n })\n }\n split(tree)\n }\n}\n\n// The editor's schema keeps paragraphs, line breaks and the formats it offers. ProseMirror parses anything else into\n// them: a heading is a paragraph of its text, a code block a paragraph of its lines, a quote its paragraphs, inline\n// code its text, an image or a rule nothing, the text of a list item sits in a paragraph, a mark left out is its text\n// and a list left out its items' paragraphs. Outside a code block it collapses white space, as the page does; the\n// editor's text keeps its spaces (white-space: break-spaces)\nconst SCHEMA_AS_PARAGRAPH = new Set([\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"])\nconst SCHEMA_BLOCKS = new Set([\"p\", \"ul\", \"ol\"])\nconst MARKS = new Map<string, MarkdownEditorFormat>([[\"strong\", \"bold\"], [\"em\", \"italic\"], [\"a\", \"link\"]])\nconst textOf = (node: HtmlNode): string => node.value ?? (node.children ?? []).map(textOf).join(\"\")\nconst isBlank = (node: HtmlNode) => node.type === \"text\" && !node.value?.trim()\nconst lineBreakElement = (): HtmlNode => ({ type: \"element\", tagName: \"br\", properties: {}, children: [] })\n\n// White space of a paragraph's text as ProseMirror parses it: runs collapse to one space, none at the start of the\n// paragraph, after a line break or after another space, none at its end\nfunction collapseWhiteSpace(children: HtmlNode[]) {\n let previous: HtmlNode | null = null\n let lineStart = true\n const walk = (nodes: HtmlNode[]) => {\n for (const node of nodes) {\n if (node.type === \"text\") {\n let value = (node.value ?? \"\").replace(/[ \\t\\r\\n\\f]+/g, \" \")\n if (value.startsWith(\" \") && (lineStart || previous?.value?.endsWith(\" \"))) value = value.slice(1)\n node.value = value\n if (value) {\n previous = node\n lineStart = false\n }\n } else if (node.tagName === \"br\") {\n lineStart = true\n } else {\n walk(node.children ?? [])\n }\n }\n }\n walk(children)\n if (previous) (previous as HtmlNode).value = (previous as HtmlNode).value!.replace(/ $/, \"\")\n}\n\nconst paragraph = (children: HtmlNode[], { preserveWhiteSpace = false } = {}): HtmlNode => {\n if (!preserveWhiteSpace) collapseWhiteSpace(children)\n return {\n type: \"element\",\n tagName: \"p\",\n properties: {},\n // An empty paragraph keeps its line, as ProseMirror's trailing break does\n children: children.every((child) => child.type === \"text\" && !child.value) ? [lineBreakElement()] : children,\n }\n}\n\n// tiptap-markdown drops the newline markdown-it writes after an element, outside a code block: a line that follows\n// bold, a link or code joins it without a space\nconst dropNewlineAfterElements = (nodes: HtmlNode[]) =>\n nodes.map((node, index) =>\n index && node.type === \"text\" && nodes[index - 1]!.type === \"element\" && node.value?.startsWith(\"\\n\")\n ? { ...node, value: node.value.slice(1) }\n : node,\n )\n\nfunction toEditorSchema(nodes: HtmlNode[], formats: ReadonlySet<MarkdownEditorFormat>): HtmlNode[] {\n // The blocks of a list item: its text in paragraphs, around its lists\n const itemBlocks = (children: HtmlNode[]) => {\n const content: HtmlNode[] = []\n let run: HtmlNode[] = []\n const flush = () => {\n if (!run.every(isBlank)) content.push(paragraph(run))\n run = []\n }\n for (const child of toEditorSchema(children, formats)) {\n if (child.type === \"element\" && SCHEMA_BLOCKS.has(child.tagName!)) {\n flush()\n content.push(child)\n } else {\n run.push(child)\n }\n }\n flush()\n return content\n }\n\n return dropNewlineAfterElements(nodes).flatMap((node): HtmlNode[] => {\n if (node.type !== \"element\") return [node]\n const children = node.children ?? []\n switch (node.tagName) {\n case \"img\":\n case \"hr\":\n return []\n case \"code\":\n return [{ type: \"text\", value: textOf(node) }]\n case \"pre\": {\n // ProseMirror keeps a code block's spaces and its newlines as line breaks, the last one followed by the\n // trailing break of a paragraph that ends in a break\n const lines = textOf(node).split(\"\\n\")\n if (lines.every((line) => !line)) return []\n const content: HtmlNode[] = []\n lines.forEach((line, index) => {\n if (index) content.push(lineBreakElement())\n if (line) content.push({ type: \"text\", value: line })\n })\n if (content[content.length - 1]!.tagName === \"br\") content.push(lineBreakElement())\n return [paragraph(content, { preserveWhiteSpace: true })]\n }\n case \"blockquote\":\n return toEditorSchema(children, formats)\n case \"p\":\n return [paragraph(toEditorSchema(children, formats))]\n case \"li\": {\n const content = itemBlocks(children)\n // A list item starts with a paragraph, an empty one if it has no text (an empty item, an image)\n if (content[0]?.tagName !== \"p\") content.unshift(paragraph([]))\n return [{ ...node, children: content }]\n }\n case \"ul\":\n case \"ol\": {\n const items = children.filter((child) => child.tagName === \"li\")\n return formats.has(node.tagName === \"ul\" ? \"bulletList\" : \"orderedList\")\n ? [{ ...node, children: toEditorSchema(items, formats) }]\n : items.flatMap((item) => itemBlocks(item.children ?? []))\n }\n default: {\n const mark = MARKS.get(node.tagName!)\n if (mark && !formats.has(mark)) return toEditorSchema(children, formats)\n return SCHEMA_AS_PARAGRAPH.has(node.tagName!)\n ? [paragraph(toEditorSchema(children, formats))]\n : [{ ...node, children: toEditorSchema(children, formats) }]\n }\n }\n })\n}\n\n/**\n * The first frame's HTML in the editor's schema. A document left with no block is the empty paragraph ProseMirror\n * gives it, with the placeholder the editor would show (`placeholder` only while it can be edited).\n */\nexport const rehypeEditorSchema = ({ formats }: MarkdownEditorSchema, placeholder?: string) =>\n function editorSchema() {\n return (tree: HtmlNode) => {\n const blocks = toEditorSchema(tree.children ?? [], formats).filter((child) => !isBlank(child))\n tree.children = blocks.length\n ? blocks\n : [{\n ...paragraph([]),\n properties: placeholder ? { className: [\"is-editor-empty\"], dataPlaceholder: placeholder } : {},\n }]\n }\n }\n"]}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type PropType } from "vue";
|
|
2
2
|
import type { Variants } from "@plexui/styles/types";
|
|
3
|
+
import { type MarkdownEditorFormat } from "../../lib/markdownEditorSchema.js";
|
|
3
4
|
export declare const markdownEditorStyles: {
|
|
4
5
|
toolbarButton: string;
|
|
5
6
|
};
|
|
7
|
+
export type { MarkdownEditorFormat };
|
|
6
8
|
declare const MarkdownEditorComponent: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
7
9
|
/** Visual style of the editor. @default "outline" */
|
|
8
10
|
variant: {
|
|
@@ -31,6 +33,23 @@ declare const MarkdownEditorComponent: import("vue").DefineComponent<import("vue
|
|
|
31
33
|
type: StringConstructor;
|
|
32
34
|
default: undefined;
|
|
33
35
|
};
|
|
36
|
+
/**
|
|
37
|
+
* The formats the editor offers, read when the editor is created. A format left out has no toolbar button,
|
|
38
|
+
* shortcut or input rule; pasted and incoming content keeps its text without it, and the markdown does not write it.
|
|
39
|
+
* @default ["bold", "italic", "orderedList", "bulletList", "link"]
|
|
40
|
+
*/
|
|
41
|
+
formats: {
|
|
42
|
+
type: PropType<MarkdownEditorFormat[]>;
|
|
43
|
+
default: undefined;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* A single newline is a line break, read and written as one "\n", read when the editor is created. Without it a
|
|
47
|
+
* line break is written as a backslash and a newline, and a single newline joins the lines. @default false
|
|
48
|
+
*/
|
|
49
|
+
breaks: {
|
|
50
|
+
type: BooleanConstructor;
|
|
51
|
+
default: boolean;
|
|
52
|
+
};
|
|
34
53
|
/** Minimum visible rows. @default 1 */
|
|
35
54
|
rows: {
|
|
36
55
|
type: NumberConstructor;
|
|
@@ -84,6 +103,23 @@ declare const MarkdownEditorComponent: import("vue").DefineComponent<import("vue
|
|
|
84
103
|
type: StringConstructor;
|
|
85
104
|
default: undefined;
|
|
86
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* The formats the editor offers, read when the editor is created. A format left out has no toolbar button,
|
|
108
|
+
* shortcut or input rule; pasted and incoming content keeps its text without it, and the markdown does not write it.
|
|
109
|
+
* @default ["bold", "italic", "orderedList", "bulletList", "link"]
|
|
110
|
+
*/
|
|
111
|
+
formats: {
|
|
112
|
+
type: PropType<MarkdownEditorFormat[]>;
|
|
113
|
+
default: undefined;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* A single newline is a line break, read and written as one "\n", read when the editor is created. Without it a
|
|
117
|
+
* line break is written as a backslash and a newline, and a single newline joins the lines. @default false
|
|
118
|
+
*/
|
|
119
|
+
breaks: {
|
|
120
|
+
type: BooleanConstructor;
|
|
121
|
+
default: boolean;
|
|
122
|
+
};
|
|
87
123
|
/** Minimum visible rows. @default 1 */
|
|
88
124
|
rows: {
|
|
89
125
|
type: NumberConstructor;
|
|
@@ -113,6 +149,8 @@ declare const MarkdownEditorComponent: import("vue").DefineComponent<import("vue
|
|
|
113
149
|
variant: "soft" | "outline";
|
|
114
150
|
ariaInvalid: boolean;
|
|
115
151
|
rows: number;
|
|
152
|
+
formats: MarkdownEditorFormat[];
|
|
153
|
+
breaks: boolean;
|
|
116
154
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
117
155
|
/**
|
|
118
156
|
* Compact rich text editor for markdown, with a formatting toolbar (bold,
|
|
@@ -146,6 +184,23 @@ export declare const MarkdownEditor: import("vue").DefineComponent<import("vue")
|
|
|
146
184
|
type: StringConstructor;
|
|
147
185
|
default: undefined;
|
|
148
186
|
};
|
|
187
|
+
/**
|
|
188
|
+
* The formats the editor offers, read when the editor is created. A format left out has no toolbar button,
|
|
189
|
+
* shortcut or input rule; pasted and incoming content keeps its text without it, and the markdown does not write it.
|
|
190
|
+
* @default ["bold", "italic", "orderedList", "bulletList", "link"]
|
|
191
|
+
*/
|
|
192
|
+
formats: {
|
|
193
|
+
type: PropType<MarkdownEditorFormat[]>;
|
|
194
|
+
default: undefined;
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* A single newline is a line break, read and written as one "\n", read when the editor is created. Without it a
|
|
198
|
+
* line break is written as a backslash and a newline, and a single newline joins the lines. @default false
|
|
199
|
+
*/
|
|
200
|
+
breaks: {
|
|
201
|
+
type: BooleanConstructor;
|
|
202
|
+
default: boolean;
|
|
203
|
+
};
|
|
149
204
|
/** Minimum visible rows. @default 1 */
|
|
150
205
|
rows: {
|
|
151
206
|
type: NumberConstructor;
|
|
@@ -199,6 +254,23 @@ export declare const MarkdownEditor: import("vue").DefineComponent<import("vue")
|
|
|
199
254
|
type: StringConstructor;
|
|
200
255
|
default: undefined;
|
|
201
256
|
};
|
|
257
|
+
/**
|
|
258
|
+
* The formats the editor offers, read when the editor is created. A format left out has no toolbar button,
|
|
259
|
+
* shortcut or input rule; pasted and incoming content keeps its text without it, and the markdown does not write it.
|
|
260
|
+
* @default ["bold", "italic", "orderedList", "bulletList", "link"]
|
|
261
|
+
*/
|
|
262
|
+
formats: {
|
|
263
|
+
type: PropType<MarkdownEditorFormat[]>;
|
|
264
|
+
default: undefined;
|
|
265
|
+
};
|
|
266
|
+
/**
|
|
267
|
+
* A single newline is a line break, read and written as one "\n", read when the editor is created. Without it a
|
|
268
|
+
* line break is written as a backslash and a newline, and a single newline joins the lines. @default false
|
|
269
|
+
*/
|
|
270
|
+
breaks: {
|
|
271
|
+
type: BooleanConstructor;
|
|
272
|
+
default: boolean;
|
|
273
|
+
};
|
|
202
274
|
/** Minimum visible rows. @default 1 */
|
|
203
275
|
rows: {
|
|
204
276
|
type: NumberConstructor;
|
|
@@ -228,6 +300,7 @@ export declare const MarkdownEditor: import("vue").DefineComponent<import("vue")
|
|
|
228
300
|
variant: "soft" | "outline";
|
|
229
301
|
ariaInvalid: boolean;
|
|
230
302
|
rows: number;
|
|
303
|
+
formats: MarkdownEditorFormat[];
|
|
304
|
+
breaks: boolean;
|
|
231
305
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
232
306
|
export type MarkdownEditorProps = InstanceType<typeof MarkdownEditorComponent>["$props"];
|
|
233
|
-
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MarkdownEditor, markdownEditorStyles, type MarkdownEditorProps } from "./MarkdownEditor.js";
|
|
1
|
+
export { MarkdownEditor, markdownEditorStyles, type MarkdownEditorFormat, type MarkdownEditorProps } from "./MarkdownEditor.js";
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AnyExtension } from "@tiptap/core";
|
|
2
|
+
export type MarkdownEditorFormat = "bold" | "italic" | "orderedList" | "bulletList" | "link";
|
|
3
|
+
export declare const MARKDOWN_EDITOR_FORMATS: readonly MarkdownEditorFormat[];
|
|
4
|
+
export type MarkdownEditorSchema = {
|
|
5
|
+
/** The formats the editor offers: a toolbar button, its shortcut and input rule, and a mark or node in the schema */
|
|
6
|
+
formats: ReadonlySet<MarkdownEditorFormat>;
|
|
7
|
+
/** A single newline is a line break, read and written as one "\n" */
|
|
8
|
+
breaks: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const markdownEditorSchema: (formats?: readonly MarkdownEditorFormat[], breaks?: boolean) => MarkdownEditorSchema;
|
|
11
|
+
/**
|
|
12
|
+
* The editor's extensions. A format left out has no mark or node: its shortcut and input rule are gone, and pasted or
|
|
13
|
+
* incoming content keeps its text without it, so the markdown going out does not write it either.
|
|
14
|
+
*/
|
|
15
|
+
export declare const markdownEditorExtensions: ({ formats, breaks }: MarkdownEditorSchema, placeholder?: string) => AnyExtension[];
|
|
16
|
+
type MarkdownNode = {
|
|
17
|
+
type: string;
|
|
18
|
+
value?: string;
|
|
19
|
+
position?: {
|
|
20
|
+
start: {
|
|
21
|
+
offset?: number;
|
|
22
|
+
};
|
|
23
|
+
end: {
|
|
24
|
+
offset?: number;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
children?: MarkdownNode[];
|
|
28
|
+
};
|
|
29
|
+
type HtmlNode = {
|
|
30
|
+
type: string;
|
|
31
|
+
tagName?: string;
|
|
32
|
+
value?: string;
|
|
33
|
+
properties?: Record<string, unknown>;
|
|
34
|
+
children?: HtmlNode[];
|
|
35
|
+
};
|
|
36
|
+
export declare function remarkWithoutHtml(this: {
|
|
37
|
+
data(): object;
|
|
38
|
+
}): void;
|
|
39
|
+
export declare function remarkLineBreaks(): (tree: MarkdownNode, file: {
|
|
40
|
+
value?: unknown;
|
|
41
|
+
}) => void;
|
|
42
|
+
/**
|
|
43
|
+
* The first frame's HTML in the editor's schema. A document left with no block is the empty paragraph ProseMirror
|
|
44
|
+
* gives it, with the placeholder the editor would show (`placeholder` only while it can be edited).
|
|
45
|
+
*/
|
|
46
|
+
export declare const rehypeEditorSchema: ({ formats }: MarkdownEditorSchema, placeholder?: string) => () => (tree: HtmlNode) => void;
|
|
47
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plexui/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "Plex UI components for Vue 3, built on Reka UI and the shared @plexui/styles CSS",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@maskito/core": "5.2.2",
|
|
78
78
|
"@maskito/kit": "5.2.2",
|
|
79
79
|
"@maskito/vue": "5.2.2",
|
|
80
|
-
"@plexui/styles": "^0.1.
|
|
80
|
+
"@plexui/styles": "^0.1.43",
|
|
81
81
|
"@tanstack/table-core": "8.21.3",
|
|
82
82
|
"@tanstack/vue-table": "8.21.3",
|
|
83
83
|
"@tiptap/core": "3.21.0",
|