@plexui/vue 0.18.0 → 0.20.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 +2 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/Tabs/Tabs.js +12 -91
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/ToggleGroup/ToggleGroup.js +158 -0
- package/dist/es/components/ToggleGroup/ToggleGroup.js.map +1 -0
- package/dist/es/components/ToggleGroup/index.js +2 -0
- package/dist/es/components/ToggleGroup/index.js.map +1 -0
- package/dist/es/lib/markdownEditorSchema.js +175 -13
- package/dist/es/lib/markdownEditorSchema.js.map +1 -1
- package/dist/es/lib/rovingFocus.js +118 -0
- package/dist/es/lib/rovingFocus.js.map +1 -0
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts +10 -6
- package/dist/types/components/Tabs/Tabs.d.ts +7 -2
- package/dist/types/components/ToggleGroup/ToggleGroup.d.ts +154 -0
- package/dist/types/components/ToggleGroup/index.d.ts +1 -0
- package/dist/types/lib/markdownEditorSchema.d.ts +4 -3
- package/dist/types/lib/rovingFocus.d.ts +51 -0
- package/package.json +2 -2
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import { defaultMarkdownSerializer } from "@tiptap/pm/markdown";
|
|
3
|
+
import { DOMParser as ProseMirrorDOMParser } from "@tiptap/pm/model";
|
|
4
|
+
import { Plugin, PluginKey } from "@tiptap/pm/state";
|
|
1
5
|
import Document from "@tiptap/extension-document";
|
|
2
6
|
import Paragraph from "@tiptap/extension-paragraph";
|
|
3
7
|
import Text from "@tiptap/extension-text";
|
|
@@ -50,31 +54,97 @@ const lineBreak = (breaks) => HardBreak.extend({
|
|
|
50
54
|
const LINE_OPENER = /^(?:\d+(?=[.)](?:[ \t]|$))|(?=-|\+(?:[ \t]|$)|#{1,6}(?:[ \t]|$)))/;
|
|
51
55
|
// A line of "=" makes the line above it a heading
|
|
52
56
|
const HEADING_UNDERLINE = /^(?==+[ \t]*$)/;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
//
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
// A line of "|", ":" and at least one "-" makes the line above it the head of a table ("-" first is escaped already)
|
|
58
|
+
const TABLE_DELIMITER = /^(?=[|:][|: \t]*-[-|: \t]*$)/;
|
|
59
|
+
// A character reference markdown reads as its character: "&" and a name, or "#" and at most seven decimal or six
|
|
60
|
+
// hexadecimal digits, then ";". Its "&" is written as "&", so a typed "<" stays those four characters
|
|
61
|
+
const CHARACTER_REFERENCE = /&(?=#\d{1,7};|#[xX][\da-fA-F]{1,6};|[A-Za-z][A-Za-z\d]{1,31};)/g;
|
|
62
|
+
const escapeHtml = (text) => text.replace(CHARACTER_REFERENCE, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
63
|
+
// A letter, a mark or a digit: a run of "_" between two of them is inside a word, where it opens no emphasis
|
|
64
|
+
const WORD_CHARACTER = /[\p{L}\p{M}\p{N}]/u;
|
|
65
|
+
// Text escaped as prosemirror-markdown escapes it, but for "_": it keeps a "_" with a word character, or another "_",
|
|
66
|
+
// on each side, so "__s__" was "\__s_\_", read again as "_", an italic "s" and "_". A run of "_" stays as it is only
|
|
67
|
+
// inside a word, each "_" of any other is escaped
|
|
68
|
+
const writeEscaped = (state, text) => {
|
|
69
|
+
let at = 0;
|
|
70
|
+
for (const run of text.matchAll(/_+/g)) {
|
|
71
|
+
const end = run.index + run[0].length;
|
|
72
|
+
if (run.index > at)
|
|
73
|
+
state.text(text.slice(at, run.index));
|
|
74
|
+
const insideWord = WORD_CHARACTER.test(text[run.index - 1] ?? "") && WORD_CHARACTER.test(text[end] ?? "");
|
|
75
|
+
state.text(insideWord ? run[0] : run[0].replace(/_/g, "\\_"), false);
|
|
76
|
+
at = end;
|
|
77
|
+
}
|
|
78
|
+
if (at < text.length)
|
|
79
|
+
state.text(text.slice(at));
|
|
80
|
+
};
|
|
81
|
+
// Text as tiptap-markdown writes it (with "<" and ">" as entities, and the "&" of a character reference), escaping
|
|
82
|
+
// what would open a block at the start of a line, so the line keeps its text when the markdown is read again. After a
|
|
83
|
+
// line break the line continues the paragraph and is never code, so an opener is escaped after any white space, also
|
|
84
|
+
// white space written before it (a marked one is written outside its mark). At the start of a paragraph, as
|
|
85
|
+
// prosemirror-markdown does, after up to three spaces: four columns start code there, so white space that reaches
|
|
86
|
+
// them is not written (markdown would drop it anyway). The URL of an autolink is written as it is: markdown reads no
|
|
87
|
+
// escape or reference there
|
|
59
88
|
const EditorText = Text.extend({
|
|
60
89
|
addStorage() {
|
|
61
90
|
return {
|
|
62
91
|
...this.parent?.(),
|
|
63
92
|
markdown: {
|
|
64
93
|
serialize(state, node, parent) {
|
|
65
|
-
|
|
94
|
+
if (state.inAutolink) {
|
|
95
|
+
state.atBlockStart = false;
|
|
96
|
+
return state.text(node.text ?? "", false);
|
|
97
|
+
}
|
|
98
|
+
let text = escapeHtml(node.text ?? "");
|
|
99
|
+
// Four columns of white space start code at the start of a paragraph, and markdown drops less: none is written
|
|
100
|
+
const leading = state.atBlockStart ? /^[ \t]*/.exec(text)[0] : "";
|
|
101
|
+
if (leading.includes("\t") || leading.length >= 4)
|
|
102
|
+
text = text.slice(leading.length);
|
|
66
103
|
const lineStart = lineStarts.get(state);
|
|
67
104
|
const afterBreak = lineStart?.parent === parent && !state.atBlockStart && /^[ \t]*$/.test(state.out.slice(lineStart.at));
|
|
68
105
|
const space = (afterBreak ? /^[ \t]*/ : state.atBlockStart ? /^ {0,3}/ : null)?.exec(text)?.[0];
|
|
69
106
|
const rest = space === undefined ? "" : text.slice(space.length);
|
|
70
|
-
const opener = space === undefined
|
|
107
|
+
const opener = space === undefined
|
|
108
|
+
? null
|
|
109
|
+
: LINE_OPENER.exec(rest) ?? (afterBreak ? HEADING_UNDERLINE.exec(rest) ?? TABLE_DELIMITER.exec(rest) : null);
|
|
71
110
|
// The opener is escaped here; prosemirror-markdown's own escape at the start of a paragraph would escape it twice
|
|
72
111
|
state.atBlockStart = false;
|
|
73
112
|
if (!opener)
|
|
74
|
-
return state
|
|
113
|
+
return writeEscaped(state, text);
|
|
75
114
|
const at = space.length + opener[0].length;
|
|
76
115
|
state.text(`${text.slice(0, at)}\\`, false);
|
|
77
|
-
state
|
|
116
|
+
writeEscaped(state, text.slice(at));
|
|
117
|
+
},
|
|
118
|
+
parse: {},
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
},
|
|
122
|
+
});
|
|
123
|
+
// A link as prosemirror-markdown writes it, but a line ending of its title is a character reference: markdown reads a
|
|
124
|
+
// title over two lines, and a pasted one can start a block on the second ("# h"), which would end the paragraph and
|
|
125
|
+
// the link with it when read again. The "&" of a reference in the title is written as "&", as in text, and a
|
|
126
|
+
// backslash that would escape what follows (punctuation, the reference of a line ending, the closing quote) as two
|
|
127
|
+
const markdownLink = defaultMarkdownSerializer.marks.link;
|
|
128
|
+
const EditorLink = LinkExtension.extend({
|
|
129
|
+
addStorage() {
|
|
130
|
+
return {
|
|
131
|
+
...this.parent?.(),
|
|
132
|
+
markdown: {
|
|
133
|
+
serialize: {
|
|
134
|
+
...markdownLink,
|
|
135
|
+
close(state, mark, parent, index) {
|
|
136
|
+
const title = mark.attrs.title;
|
|
137
|
+
const attrs = title
|
|
138
|
+
? {
|
|
139
|
+
...mark.attrs,
|
|
140
|
+
title: title
|
|
141
|
+
.replace(/\\(?=[!-/:-@[-`{-~\r\n]|$)/g, "\\\\")
|
|
142
|
+
.replace(CHARACTER_REFERENCE, "&")
|
|
143
|
+
.replace(/\r\n?|\n/g, " "),
|
|
144
|
+
}
|
|
145
|
+
: mark.attrs;
|
|
146
|
+
return markdownLink.close(state, { ...mark, attrs }, parent, index);
|
|
147
|
+
},
|
|
78
148
|
},
|
|
79
149
|
parse: {},
|
|
80
150
|
},
|
|
@@ -88,13 +158,105 @@ const listItemOf = (tags) => ListItem.extend({
|
|
|
88
158
|
return [{ tag: "li", getAttrs: (element) => (tags.has(element.parentElement?.localName ?? "") ? null : false) }];
|
|
89
159
|
},
|
|
90
160
|
});
|
|
161
|
+
// Runs `wrap` in place of a markdown-it rule, which it can call, keeping the rule's place in the chains it ends
|
|
162
|
+
// (its `alt`, which Ruler.at would otherwise empty)
|
|
163
|
+
function wrapRule(ruler, name, wrap) {
|
|
164
|
+
const { fn, alt } = ruler.__rules__.find((rule) => rule.name === name);
|
|
165
|
+
ruler.at(name, wrap(fn), { alt: [...alt] });
|
|
166
|
+
}
|
|
167
|
+
// Blocks and inlines the editor never offers: pasted, their markers stay text, as typed. An image is read as one and
|
|
168
|
+
// kept as its source text (pasteMarkdownIt)
|
|
169
|
+
const NEVER_OFFERED = ["heading", "lheading", "blockquote", "code", "fence", "hr", "table", "backticks", "strikethrough"];
|
|
170
|
+
// The markdown-it that reads pasted text when a format is left out: the editor's own (its options and tiptap-markdown's
|
|
171
|
+
// renderer), without the rules of the formats left out and of the blocks never offered. An image is its source text,
|
|
172
|
+
// all of it, as markdown-it reads it (disabled, its "[...](...)" would be a link where links are offered). With one
|
|
173
|
+
// list left out, a line its marker opens is no list (and does not end a paragraph); with one of bold and italic left
|
|
174
|
+
// out, its delimiters are turned back into text
|
|
175
|
+
function pasteMarkdownIt(editorMd, parser, formats) {
|
|
176
|
+
const MarkdownItClass = editorMd.constructor;
|
|
177
|
+
const md = parser.withPatchedRenderer(new MarkdownItClass({ html: false, linkify: editorMd.options.linkify, breaks: editorMd.options.breaks }));
|
|
178
|
+
const rules = [...NEVER_OFFERED];
|
|
179
|
+
if (!formats.has("link"))
|
|
180
|
+
rules.push("link", "autolink", "reference");
|
|
181
|
+
if (!LISTS.some(([format]) => formats.has(format)))
|
|
182
|
+
rules.push("list");
|
|
183
|
+
if (!formats.has("bold") && !formats.has("italic"))
|
|
184
|
+
rules.push("emphasis");
|
|
185
|
+
md.disable(rules);
|
|
186
|
+
wrapRule(md.inline.ruler, "image", (image) => (state, silent) => {
|
|
187
|
+
const start = state.pos;
|
|
188
|
+
if (!image(state, true))
|
|
189
|
+
return false;
|
|
190
|
+
if (!silent)
|
|
191
|
+
state.push("text", "", 0).content = state.src.slice(start, state.pos);
|
|
192
|
+
return true;
|
|
193
|
+
});
|
|
194
|
+
if (formats.has("bulletList") !== formats.has("orderedList")) {
|
|
195
|
+
wrapRule(md.block.ruler, "list", (list) => (state, startLine, endLine, silent) => {
|
|
196
|
+
const marker = state.src.charCodeAt(state.bMarks[startLine] + state.tShift[startLine]);
|
|
197
|
+
const ordered = marker >= 0x30 && marker <= 0x39;
|
|
198
|
+
if (!formats.has(ordered ? "orderedList" : "bulletList"))
|
|
199
|
+
return false;
|
|
200
|
+
return list(state, startLine, endLine, silent);
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
if (formats.has("bold") !== formats.has("italic")) {
|
|
204
|
+
const leftOut = formats.has("bold") ? ["em_open", "em_close"] : ["strong_open", "strong_close"];
|
|
205
|
+
md.core.ruler.after("inline", "left_out_emphasis", ({ tokens }) => {
|
|
206
|
+
for (const token of tokens.flatMap((block) => block.children ?? [])) {
|
|
207
|
+
if (!leftOut.includes(token.type))
|
|
208
|
+
continue;
|
|
209
|
+
Object.assign(token, { type: "text", tag: "", nesting: 0, content: token.markup });
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
return md;
|
|
214
|
+
}
|
|
215
|
+
// Pasted text is read as markdown, as tiptap-markdown does, but the syntax of a format left out stays text with its
|
|
216
|
+
// markers, as it does when typed: "- one" pasted where lists are left out is the line "- one", not "one". Before
|
|
217
|
+
// tiptap-markdown's paste (its plugin comes later); pasted HTML and a plain-text paste (Shift) are left to it
|
|
218
|
+
const leftOutSyntaxPaste = (formats) => Extension.create({
|
|
219
|
+
name: "markdownEditorPaste",
|
|
220
|
+
priority: 1000,
|
|
221
|
+
addProseMirrorPlugins() {
|
|
222
|
+
const { editor } = this;
|
|
223
|
+
let md;
|
|
224
|
+
return [
|
|
225
|
+
new Plugin({
|
|
226
|
+
key: new PluginKey("markdownEditorPaste"),
|
|
227
|
+
props: {
|
|
228
|
+
clipboardTextParser(text, context, plainText) {
|
|
229
|
+
// No slice: the next parser reads it
|
|
230
|
+
if (plainText)
|
|
231
|
+
return null;
|
|
232
|
+
const { parser } = editor.storage.markdown;
|
|
233
|
+
const editorMd = parser.md;
|
|
234
|
+
md ??= pasteMarkdownIt(editorMd, parser, formats);
|
|
235
|
+
let html;
|
|
236
|
+
parser.md = md;
|
|
237
|
+
try {
|
|
238
|
+
html = parser.parse(text, { inline: true });
|
|
239
|
+
}
|
|
240
|
+
finally {
|
|
241
|
+
parser.md = editorMd;
|
|
242
|
+
}
|
|
243
|
+
const body = new window.DOMParser().parseFromString(`<body>${html}</body>`, "text/html").body;
|
|
244
|
+
return ProseMirrorDOMParser.fromSchema(editor.schema).parseSlice(body, { preserveWhitespace: true, context });
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
}),
|
|
248
|
+
];
|
|
249
|
+
},
|
|
250
|
+
});
|
|
91
251
|
/**
|
|
92
|
-
* The editor's extensions. A format left out has no mark or node: its shortcut and input rule are gone,
|
|
93
|
-
* incoming
|
|
252
|
+
* The editor's extensions. A format left out has no mark or node: its shortcut and input rule are gone, in pasted text
|
|
253
|
+
* its markers stay text, as typed, and pasted HTML and incoming markdown keep its text without it, so the markdown
|
|
254
|
+
* going out does not write it either.
|
|
94
255
|
*/
|
|
95
256
|
export const markdownEditorExtensions = ({ formats, breaks }, placeholder) => {
|
|
96
257
|
const lists = LISTS.filter(([format]) => formats.has(format));
|
|
97
258
|
return [
|
|
259
|
+
...(MARKDOWN_EDITOR_FORMATS.every((format) => formats.has(format)) ? [] : [leftOutSyntaxPaste(formats)]),
|
|
98
260
|
Document,
|
|
99
261
|
Paragraph,
|
|
100
262
|
EditorText,
|
|
@@ -102,7 +264,7 @@ export const markdownEditorExtensions = ({ formats, breaks }, placeholder) => {
|
|
|
102
264
|
...(formats.has("bold") ? [BoldExtension] : []),
|
|
103
265
|
...(formats.has("italic") ? [ItalicExtension] : []),
|
|
104
266
|
...(formats.has("link")
|
|
105
|
-
? [
|
|
267
|
+
? [EditorLink.configure({ openOnClick: false, HTMLAttributes: { rel: "noopener noreferrer nofollow" } })]
|
|
106
268
|
: []),
|
|
107
269
|
...(formats.has("bulletList") ? [BulletList] : []),
|
|
108
270
|
...(formats.has("orderedList") ? [OrderedList] : []),
|
|
@@ -1 +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;AAO/D,MAAM,CAAC,MAAM,uBAAuB,GAAoC,CAAC,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,CAAC,CAAA;AAS/H,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAClC,UAA2C,uBAAuB,EAClE,MAAM,GAAG,KAAK,EACQ,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,GAAG,CAAC,OAAO,CAAC,EA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AAE,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
|
+
{"version":3,"file":"markdownEditorSchema.js","sourceRoot":"","sources":["../../../src/lib/markdownEditorSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAqB,MAAM,cAAc,CAAA;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,EAAE,SAAS,IAAI,oBAAoB,EAAuD,MAAM,kBAAkB,CAAA;AACzH,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACpD,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,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AC,CAAC,EAAE;iBAChG,CAAC,CAAA;IACR,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import { Extension, type AnyExtension } from \"@tiptap/core\"\nimport { defaultMarkdownSerializer } from \"@tiptap/pm/markdown\"\nimport { DOMParser as ProseMirrorDOMParser, type Mark, type Node as ProseMirrorNode, type Slice } from \"@tiptap/pm/model\"\nimport { Plugin, PluginKey } from \"@tiptap/pm/state\"\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 /** Inside a link written as an autolink, \"<\" and \">\" around its URL */\n inAutolink?: 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]*$)/\n// A line of \"|\", \":\" and at least one \"-\" makes the line above it the head of a table (\"-\" first is escaped already)\nconst TABLE_DELIMITER = /^(?=[|:][|: \\t]*-[-|: \\t]*$)/\n// A character reference markdown reads as its character: \"&\" and a name, or \"#\" and at most seven decimal or six\n// hexadecimal digits, then \";\". Its \"&\" is written as \"&\", so a typed \"<\" stays those four characters\nconst CHARACTER_REFERENCE = /&(?=#\\d{1,7};|#[xX][\\da-fA-F]{1,6};|[A-Za-z][A-Za-z\\d]{1,31};)/g\nconst escapeHtml = (text: string) =>\n text.replace(CHARACTER_REFERENCE, \"&\").replace(/</g, \"<\").replace(/>/g, \">\")\n\n// A letter, a mark or a digit: a run of \"_\" between two of them is inside a word, where it opens no emphasis\nconst WORD_CHARACTER = /[\\p{L}\\p{M}\\p{N}]/u\n\n// Text escaped as prosemirror-markdown escapes it, but for \"_\": it keeps a \"_\" with a word character, or another \"_\",\n// on each side, so \"__s__\" was \"\\__s_\\_\", read again as \"_\", an italic \"s\" and \"_\". A run of \"_\" stays as it is only\n// inside a word, each \"_\" of any other is escaped\nconst writeEscaped = (state: SerializerState, text: string) => {\n let at = 0\n for (const run of text.matchAll(/_+/g)) {\n const end = run.index + run[0].length\n if (run.index > at) state.text(text.slice(at, run.index))\n const insideWord = WORD_CHARACTER.test(text[run.index - 1] ?? \"\") && WORD_CHARACTER.test(text[end] ?? \"\")\n state.text(insideWord ? run[0] : run[0].replace(/_/g, \"\\\\_\"), false)\n at = end\n }\n if (at < text.length) state.text(text.slice(at))\n}\n\n// Text as tiptap-markdown writes it (with \"<\" and \">\" as entities, and the \"&\" of a character reference), escaping\n// what would open a block at the start of a line, so the line keeps its text when the markdown is read again. After a\n// line break the line continues the paragraph and is never code, so an opener is escaped after any white space, also\n// white space written before it (a marked one is written outside its mark). At the start of a paragraph, as\n// prosemirror-markdown does, after up to three spaces: four columns start code there, so white space that reaches\n// them is not written (markdown would drop it anyway). The URL of an autolink is written as it is: markdown reads no\n// escape or reference there\nconst EditorText = Text.extend({\n addStorage() {\n return {\n ...this.parent?.(),\n markdown: {\n serialize(state: SerializerState, node: ProseMirrorNode, parent: ProseMirrorNode) {\n if (state.inAutolink) {\n state.atBlockStart = false\n return state.text(node.text ?? \"\", false)\n }\n let text = escapeHtml(node.text ?? \"\")\n // Four columns of white space start code at the start of a paragraph, and markdown drops less: none is written\n const leading = state.atBlockStart ? /^[ \\t]*/.exec(text)![0] : \"\"\n if (leading.includes(\"\\t\") || leading.length >= 4) text = text.slice(leading.length)\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 =\n space === undefined\n ? null\n : LINE_OPENER.exec(rest) ?? (afterBreak ? HEADING_UNDERLINE.exec(rest) ?? TABLE_DELIMITER.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 writeEscaped(state, text)\n const at = space!.length + opener[0].length\n state.text(`${text.slice(0, at)}\\\\`, false)\n writeEscaped(state, text.slice(at))\n },\n parse: {},\n },\n }\n },\n})\n\n// A link as prosemirror-markdown writes it, but a line ending of its title is a character reference: markdown reads a\n// title over two lines, and a pasted one can start a block on the second (\"# h\"), which would end the paragraph and\n// the link with it when read again. The \"&\" of a reference in the title is written as \"&\", as in text, and a\n// backslash that would escape what follows (punctuation, the reference of a line ending, the closing quote) as two\nconst markdownLink = defaultMarkdownSerializer.marks.link!\nconst EditorLink = LinkExtension.extend({\n addStorage() {\n return {\n ...this.parent?.(),\n markdown: {\n serialize: {\n ...markdownLink,\n close(state: SerializerState, mark: Mark, parent: ProseMirrorNode, index: number) {\n const title = mark.attrs.title as string | null | undefined\n const attrs = title\n ? {\n ...mark.attrs,\n title: title\n .replace(/\\\\(?=[!-/:-@[-`{-~\\r\\n]|$)/g, \"\\\\\\\\\")\n .replace(CHARACTER_REFERENCE, \"&\")\n .replace(/\\r\\n?|\\n/g, \" \"),\n }\n : mark.attrs\n return (markdownLink.close as (...args: unknown[]) => string)(state, { ...mark, attrs }, parent, index)\n },\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/* Pasting text */\n/* ------------------------------------------------------------------ */\n\n// The parts of markdown-it and of tiptap-markdown's parser that pasting uses\ntype MarkdownItToken = { type: string; tag: string; nesting: number; markup: string; content: string; children: MarkdownItToken[] | null }\ntype InlineState = { pos: number; src: string; push: (type: string, tag: string, nesting: number) => MarkdownItToken }\ntype InlineRule = (state: InlineState, silent: boolean) => boolean\ntype BlockState = { src: string; bMarks: number[]; tShift: number[] }\ntype BlockRule = (state: BlockState, startLine: number, endLine: number, silent: boolean) => boolean\ntype Ruler<Rule> = {\n __rules__: { name: string; fn: Rule; alt: string[] }[]\n at: (name: string, fn: Rule, options: { alt: string[] }) => void\n}\ntype MarkdownIt = {\n options: { linkify?: boolean; breaks?: boolean }\n disable: (rules: string[]) => MarkdownIt\n core: { ruler: { after: (rule: string, name: string, fn: (state: { tokens: MarkdownItToken[] }) => void) => void } }\n block: { ruler: Ruler<BlockRule> }\n inline: { ruler: Ruler<InlineRule> }\n}\n\n// Runs `wrap` in place of a markdown-it rule, which it can call, keeping the rule's place in the chains it ends\n// (its `alt`, which Ruler.at would otherwise empty)\nfunction wrapRule<Rule>(ruler: Ruler<Rule>, name: string, wrap: (rule: Rule) => Rule) {\n const { fn, alt } = ruler.__rules__.find((rule) => rule.name === name)!\n ruler.at(name, wrap(fn), { alt: [...alt] })\n}\ntype MarkdownParser = {\n md: MarkdownIt\n parse: (content: string, options: { inline: boolean }) => string\n withPatchedRenderer: (md: MarkdownIt) => MarkdownIt\n}\n\n// Blocks and inlines the editor never offers: pasted, their markers stay text, as typed. An image is read as one and\n// kept as its source text (pasteMarkdownIt)\nconst NEVER_OFFERED = [\"heading\", \"lheading\", \"blockquote\", \"code\", \"fence\", \"hr\", \"table\", \"backticks\", \"strikethrough\"]\n\n\n// The markdown-it that reads pasted text when a format is left out: the editor's own (its options and tiptap-markdown's\n// renderer), without the rules of the formats left out and of the blocks never offered. An image is its source text,\n// all of it, as markdown-it reads it (disabled, its \"[...](...)\" would be a link where links are offered). With one\n// list left out, a line its marker opens is no list (and does not end a paragraph); with one of bold and italic left\n// out, its delimiters are turned back into text\nfunction pasteMarkdownIt(editorMd: MarkdownIt, parser: MarkdownParser, formats: ReadonlySet<MarkdownEditorFormat>) {\n const MarkdownItClass = editorMd.constructor as new (options: object) => MarkdownIt\n const md = parser.withPatchedRenderer(\n new MarkdownItClass({ html: false, linkify: editorMd.options.linkify, breaks: editorMd.options.breaks }),\n )\n const rules = [...NEVER_OFFERED]\n if (!formats.has(\"link\")) rules.push(\"link\", \"autolink\", \"reference\")\n if (!LISTS.some(([format]) => formats.has(format))) rules.push(\"list\")\n if (!formats.has(\"bold\") && !formats.has(\"italic\")) rules.push(\"emphasis\")\n md.disable(rules)\n wrapRule(md.inline.ruler, \"image\", (image) => (state, silent) => {\n const start = state.pos\n if (!image(state, true)) return false\n if (!silent) state.push(\"text\", \"\", 0).content = state.src.slice(start, state.pos)\n return true\n })\n if (formats.has(\"bulletList\") !== formats.has(\"orderedList\")) {\n wrapRule(md.block.ruler, \"list\", (list) => (state, startLine, endLine, silent) => {\n const marker = state.src.charCodeAt(state.bMarks[startLine]! + state.tShift[startLine]!)\n const ordered = marker >= 0x30 && marker <= 0x39\n if (!formats.has(ordered ? \"orderedList\" : \"bulletList\")) return false\n return list(state, startLine, endLine, silent)\n })\n }\n if (formats.has(\"bold\") !== formats.has(\"italic\")) {\n const leftOut = formats.has(\"bold\") ? [\"em_open\", \"em_close\"] : [\"strong_open\", \"strong_close\"]\n md.core.ruler.after(\"inline\", \"left_out_emphasis\", ({ tokens }) => {\n for (const token of tokens.flatMap((block) => block.children ?? [])) {\n if (!leftOut.includes(token.type)) continue\n Object.assign(token, { type: \"text\", tag: \"\", nesting: 0, content: token.markup })\n }\n })\n }\n return md\n}\n\n// Pasted text is read as markdown, as tiptap-markdown does, but the syntax of a format left out stays text with its\n// markers, as it does when typed: \"- one\" pasted where lists are left out is the line \"- one\", not \"one\". Before\n// tiptap-markdown's paste (its plugin comes later); pasted HTML and a plain-text paste (Shift) are left to it\nconst leftOutSyntaxPaste = (formats: ReadonlySet<MarkdownEditorFormat>) =>\n Extension.create({\n name: \"markdownEditorPaste\",\n priority: 1000,\n addProseMirrorPlugins() {\n const { editor } = this\n let md: MarkdownIt | undefined\n return [\n new Plugin({\n key: new PluginKey(\"markdownEditorPaste\"),\n props: {\n clipboardTextParser(text, context, plainText) {\n // No slice: the next parser reads it\n if (plainText) return null as unknown as Slice\n const { parser } = (editor.storage as unknown as { markdown: { parser: MarkdownParser } }).markdown\n const editorMd = parser.md\n md ??= pasteMarkdownIt(editorMd, parser, formats)\n let html: string\n parser.md = md\n try {\n html = parser.parse(text, { inline: true })\n } finally {\n parser.md = editorMd\n }\n const body = new window.DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\").body\n return ProseMirrorDOMParser.fromSchema(editor.schema).parseSlice(body, { preserveWhitespace: true, context })\n },\n },\n }),\n ]\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, in pasted text\n * its markers stay text, as typed, and pasted HTML and incoming markdown keep its text without it, so the markdown\n * 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 ...(MARKDOWN_EDITOR_FORMATS.every((format) => formats.has(format)) ? [] : [leftOutSyntaxPaste(formats)]),\n Document,\n Paragraph,\n EditorText,\n lineBreak(breaks),\n ...(formats.has(\"bold\") ? [BoldExtension] : []),\n ...(formats.has(\"italic\") ? [ItalicExtension] : []),\n ...(formats.has(\"link\")\n ? [EditorLink.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"]}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { defineComponent, h } from "vue";
|
|
2
|
+
// Radix RovingFocusGroup and composeEventHandlers behaviour on top of Reka's RovingFocusGroup and RovingFocusItem,
|
|
3
|
+
// shared by the Radix ToggleGroup ports (Tabs, ToggleGroup).
|
|
4
|
+
// Radix RovingFocusGroup's focusFirst
|
|
5
|
+
export const focusFirst = (candidates) => {
|
|
6
|
+
const previouslyFocused = document.activeElement;
|
|
7
|
+
for (const candidate of candidates) {
|
|
8
|
+
if (candidate === previouslyFocused)
|
|
9
|
+
return;
|
|
10
|
+
candidate.focus({ preventScroll: false });
|
|
11
|
+
if (document.activeElement !== previouslyFocused)
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
export const callHandlers = (handlers, event) => {
|
|
16
|
+
for (const handler of Array.isArray(handlers) ? handlers : [handlers]) {
|
|
17
|
+
if (typeof handler === "function")
|
|
18
|
+
handler(event);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
// Events a caller's handler called preventDefault() on. React's synthetic
|
|
22
|
+
// event reports that call in `defaultPrevented` even when the native event is
|
|
23
|
+
// not cancelable (focus), for every later handler of the same event.
|
|
24
|
+
const preventedEvents = new WeakSet();
|
|
25
|
+
export const isPrevented = (event) => event.defaultPrevented || preventedEvents.has(event);
|
|
26
|
+
export const callCallerHandlers = (handlers, event) => {
|
|
27
|
+
if (!handlers)
|
|
28
|
+
return;
|
|
29
|
+
const preventDefault = event.preventDefault;
|
|
30
|
+
event.preventDefault = () => {
|
|
31
|
+
preventedEvents.add(event);
|
|
32
|
+
preventDefault.call(event);
|
|
33
|
+
};
|
|
34
|
+
try {
|
|
35
|
+
callHandlers(handlers, event);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
Reflect.deleteProperty(event, "preventDefault");
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
// Internal: the element a group and its items render through Reka's
|
|
42
|
+
// RovingFocusGroup and RovingFocusItem with `asChild` (Tabs, ToggleGroup). Reka merges its
|
|
43
|
+
// handlers into these attrs and would run them before the caller's. Radix
|
|
44
|
+
// composes them the other way (composeEventHandlers): the caller's handler
|
|
45
|
+
// runs first, and Radix skips its own once the event is default-prevented.
|
|
46
|
+
// So the caller's listeners for the `composed` events arrive separately in
|
|
47
|
+
// `listeners` and are composed that way here.
|
|
48
|
+
// React's onBlur is the bubbling focusout: Radix ends a Shift+Tab out of the group (its tab stop given back to the
|
|
49
|
+
// group) once focus leaves any item, where Reka's handler listens to the group's own blur. So Reka's blur handler
|
|
50
|
+
// runs on focusout, after the caller's focusout listeners; the caller's blur listeners stay on blur.
|
|
51
|
+
const INTERNAL_EVENT = { onFocusout: "onBlur" };
|
|
52
|
+
export const RovingElement = defineComponent({
|
|
53
|
+
name: "RovingElement",
|
|
54
|
+
inheritAttrs: false,
|
|
55
|
+
props: {
|
|
56
|
+
/** The element, or a component that renders one (such as Button) */
|
|
57
|
+
as: { type: [String, Object], required: true },
|
|
58
|
+
elementRef: Object,
|
|
59
|
+
/** Events whose Reka handler Radix composes after the caller's */
|
|
60
|
+
composed: { type: Array, required: true },
|
|
61
|
+
/** The caller's listeners for the `composed` events */
|
|
62
|
+
listeners: { type: Object, default: () => ({}) },
|
|
63
|
+
},
|
|
64
|
+
setup(props, { attrs, slots }) {
|
|
65
|
+
// The caller's `.once` listeners that have run, by event, as Vue removes a `.once` listener from its element
|
|
66
|
+
// once it has run: a new callback in its place does not run again, one detached and added again does
|
|
67
|
+
const ranOnce = new Set();
|
|
68
|
+
return () => {
|
|
69
|
+
const rest = { ...attrs };
|
|
70
|
+
// Every composed event gets a listener, a caller's or not, so the element has it from the start: Reka adds
|
|
71
|
+
// its item keydown listener once the item is mounted, after it, so a caller's keydown added later still
|
|
72
|
+
// runs first and can cancel the arrow keys (Reka skips a default-prevented keydown)
|
|
73
|
+
const handlers = {};
|
|
74
|
+
for (const key of props.composed) {
|
|
75
|
+
const onceKey = `${key}Once`;
|
|
76
|
+
const caller = props.listeners[key];
|
|
77
|
+
const callerOnce = props.listeners[onceKey];
|
|
78
|
+
if (!callerOnce)
|
|
79
|
+
ranOnce.delete(onceKey);
|
|
80
|
+
const internal = key === "onBlur" ? undefined : attrs[INTERNAL_EVENT[key] ?? key];
|
|
81
|
+
delete rest[key];
|
|
82
|
+
handlers[key] = (event) => {
|
|
83
|
+
callCallerHandlers(caller, event);
|
|
84
|
+
if (callerOnce && !ranOnce.has(onceKey)) {
|
|
85
|
+
ranOnce.add(onceKey);
|
|
86
|
+
callCallerHandlers(callerOnce, event);
|
|
87
|
+
}
|
|
88
|
+
if (!isPrevented(event))
|
|
89
|
+
callHandlers(internal, event);
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const elementProps = { ...rest, ...handlers, ref: props.elementRef };
|
|
93
|
+
// A component takes its content as a slot, an element as children
|
|
94
|
+
return typeof props.as === "string"
|
|
95
|
+
? h(props.as, elementProps, slots.default?.())
|
|
96
|
+
: h(props.as, elementProps, { default: () => slots.default?.() });
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
/** Splits the caller's listeners for `keys`, `.once` ones (`onFocusOnce`) too, from the other attributes. */
|
|
101
|
+
export const splitListeners = (attrs, keys) => {
|
|
102
|
+
const listeners = {};
|
|
103
|
+
const rest = {};
|
|
104
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
105
|
+
if (keys.includes(key) || (key.endsWith("Once") && keys.includes(key.slice(0, -4))))
|
|
106
|
+
listeners[key] = value;
|
|
107
|
+
else
|
|
108
|
+
rest[key] = value;
|
|
109
|
+
}
|
|
110
|
+
return { listeners, rest };
|
|
111
|
+
};
|
|
112
|
+
// Radix RovingFocusGroup composes mousedown, focus and blur (React's, a focusout); its items
|
|
113
|
+
// mousedown, focus and keydown (Reka's keydown is its own listener, which skips a default-prevented event). An
|
|
114
|
+
// item's focusout and blur go through the wrapper too: focusout cannot be cancelled natively, and React's item
|
|
115
|
+
// onBlur that calls preventDefault keeps the group's Shift+Tab state as the event bubbles to it
|
|
116
|
+
export const GROUP_COMPOSED = ["onMousedown", "onFocus", "onBlur", "onFocusout"];
|
|
117
|
+
export const ITEM_COMPOSED = ["onMousedown", "onFocus", "onKeydown", "onFocusout", "onBlur"];
|
|
118
|
+
//# sourceMappingURL=rovingFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rovingFocus.js","sourceRoot":"","sources":["../../../src/lib/rovingFocus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,CAAC,EAA2C,MAAM,KAAK,CAAA;AAEjF,mHAAmH;AACnH,6DAA6D;AAE7D,sCAAsC;AACtC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,UAAyB,EAAE,EAAE;IACtD,MAAM,iBAAiB,GAAG,QAAQ,CAAC,aAAa,CAAA;IAChD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,SAAS,KAAK,iBAAiB;YAAE,OAAM;QAC3C,SAAS,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAA;QACzC,IAAI,QAAQ,CAAC,aA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M,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAAE,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;;YACtG,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;IACxB,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;AAC5B,CAAC,CAAA;AAED,6FAA6F;AAC7F,+GAA+G;AAC/G,+GAA+G;AAC/G,gGAAgG;AAChG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAA;AAChF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,aAAa,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAA","sourcesContent":["import { defineComponent, h, type Component, type PropType, type Ref } from \"vue\"\n\n// Radix RovingFocusGroup and composeEventHandlers behaviour on top of Reka's RovingFocusGroup and RovingFocusItem,\n// shared by the Radix ToggleGroup ports (Tabs, ToggleGroup).\n\n// Radix RovingFocusGroup's focusFirst\nexport const focusFirst = (candidates: HTMLElement[]) => {\n const previouslyFocused = document.activeElement\n for (const candidate of candidates) {\n if (candidate === previouslyFocused) return\n candidate.focus({ preventScroll: false })\n if (document.activeElement !== previouslyFocused) return\n }\n}\n\nexport const callHandlers = (handlers: unknown, event: Event) => {\n for (const handler of Array.isArray(handlers) ? handlers : [handlers]) {\n if (typeof handler === \"function\") handler(event)\n }\n}\n\n// Events a caller's handler called preventDefault() on. React's synthetic\n// event reports that call in `defaultPrevented` even when the native event is\n// not cancelable (focus), for every later handler of the same event.\nconst preventedEvents = new WeakSet<Event>()\n\nexport const isPrevented = (event: Event) => event.defaultPrevented || preventedEvents.has(event)\n\nexport const callCallerHandlers = (handlers: unknown, event: Event) => {\n if (!handlers) return\n const preventDefault = event.preventDefault\n event.preventDefault = () => {\n preventedEvents.add(event)\n preventDefault.call(event)\n }\n try {\n callHandlers(handlers, event)\n } finally {\n Reflect.deleteProperty(event, \"preventDefault\")\n }\n}\n\n// Internal: the element a group and its items render through Reka's\n// RovingFocusGroup and RovingFocusItem with `asChild` (Tabs, ToggleGroup). Reka merges its\n// handlers into these attrs and would run them before the caller's. Radix\n// composes them the other way (composeEventHandlers): the caller's handler\n// runs first, and Radix skips its own once the event is default-prevented.\n// So the caller's listeners for the `composed` events arrive separately in\n// `listeners` and are composed that way here.\n// React's onBlur is the bubbling focusout: Radix ends a Shift+Tab out of the group (its tab stop given back to the\n// group) once focus leaves any item, where Reka's handler listens to the group's own blur. So Reka's blur handler\n// runs on focusout, after the caller's focusout listeners; the caller's blur listeners stay on blur.\nconst INTERNAL_EVENT: Record<string, string> = { onFocusout: \"onBlur\" }\n\nexport const RovingElement = defineComponent({\n name: \"RovingElement\",\n inheritAttrs: false,\n props: {\n /** The element, or a component that renders one (such as Button) */\n as: { type: [String, Object] as PropType<string | Component>, required: true },\n elementRef: Object as PropType<Ref<HTMLElement | null>>,\n /** Events whose Reka handler Radix composes after the caller's */\n composed: { type: Array as PropType<string[]>, required: true },\n /** The caller's listeners for the `composed` events */\n listeners: { type: Object as PropType<Record<string, unknown>>, default: () => ({}) },\n },\n setup(props, { attrs, slots }) {\n // The caller's `.once` listeners that have run, by event, as Vue removes a `.once` listener from its element\n // once it has run: a new callback in its place does not run again, one detached and added again does\n const ranOnce = new Set<string>()\n\n return () => {\n const rest: Record<string, unknown> = { ...attrs }\n // Every composed event gets a listener, a caller's or not, so the element has it from the start: Reka adds\n // its item keydown listener once the item is mounted, after it, so a caller's keydown added later still\n // runs first and can cancel the arrow keys (Reka skips a default-prevented keydown)\n const handlers: Record<string, (event: Event) => void> = {}\n for (const key of props.composed) {\n const onceKey = `${key}Once`\n const caller = props.listeners[key]\n const callerOnce = props.listeners[onceKey]\n if (!callerOnce) ranOnce.delete(onceKey)\n const internal = key === \"onBlur\" ? undefined : attrs[INTERNAL_EVENT[key] ?? key]\n delete rest[key]\n handlers[key] = (event: Event) => {\n callCallerHandlers(caller, event)\n if (callerOnce && !ranOnce.has(onceKey)) {\n ranOnce.add(onceKey)\n callCallerHandlers(callerOnce, event)\n }\n if (!isPrevented(event)) callHandlers(internal, event)\n }\n }\n const elementProps = { ...rest, ...handlers, ref: props.elementRef }\n // A component takes its content as a slot, an element as children\n return typeof props.as === \"string\"\n ? h(props.as, elementProps, slots.default?.())\n : h(props.as, elementProps, { default: () => slots.default?.() })\n }\n },\n})\n\n/** Splits the caller's listeners for `keys`, `.once` ones (`onFocusOnce`) too, from the other attributes. */\nexport const splitListeners = (attrs: Record<string, unknown>, keys: string[]) => {\n const listeners: Record<string, unknown> = {}\n const rest: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(attrs)) {\n if (keys.includes(key) || (key.endsWith(\"Once\") && keys.includes(key.slice(0, -4)))) listeners[key] = value\n else rest[key] = value\n }\n return { listeners, rest }\n}\n\n// Radix RovingFocusGroup composes mousedown, focus and blur (React's, a focusout); its items\n// mousedown, focus and keydown (Reka's keydown is its own listener, which skips a default-prevented event). An\n// item's focusout and blur go through the wrapper too: focusout cannot be cancelled natively, and React's item\n// onBlur that calls preventDefault keeps the group's Shift+Tab state as the event bubbles to it\nexport const GROUP_COMPOSED = [\"onMousedown\", \"onFocus\", \"onBlur\", \"onFocusout\"]\nexport const ITEM_COMPOSED = [\"onMousedown\", \"onFocus\", \"onKeydown\", \"onFocusout\", \"onBlur\"]\n"]}
|