@plexui/ui 0.36.0 → 0.38.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/DateInput/DateInput.js +29 -30
- package/dist/es/components/DateInput/DateInput.js.map +1 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js +25 -171
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/MarkdownEditor/index.js.map +1 -1
- package/dist/es/components/Sidebar/Sidebar.js +14 -8
- package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/es/lib/dateInputText.js +201 -0
- package/dist/es/lib/dateInputText.js.map +1 -0
- package/dist/es/lib/markdownEditorSchema.js +318 -0
- package/dist/es/lib/markdownEditorSchema.js.map +1 -0
- package/dist/es/lib/phoneDrawer.js +27 -0
- package/dist/es/lib/phoneDrawer.js.map +1 -1
- package/dist/types/components/DateInput/DateInput.d.ts +1 -1
- package/dist/types/components/MarkdownEditor/MarkdownEditor.d.ts +15 -1
- package/dist/types/components/MarkdownEditor/index.d.ts +1 -1
- package/dist/types/lib/dateInputText.d.ts +54 -0
- package/dist/types/lib/markdownEditorSchema.d.ts +47 -0
- package/dist/types/lib/phoneDrawer.d.ts +7 -0
- package/package.json +2 -2
|
@@ -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;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,EAAE,MAAM,EAAE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C,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"]}
|
|
@@ -158,6 +158,33 @@ export const drawerTabbables = (drawer) => Array.from(drawer.querySelectorAll(TA
|
|
|
158
158
|
(typeof element.checkVisibility !== "function" || element.checkVisibility({ visibilityProperty: true })));
|
|
159
159
|
/** The first control of the open drawer, or the drawer itself */
|
|
160
160
|
export const drawerInitialFocus = (drawer) => drawerTabbables(drawer)[0] ?? drawer;
|
|
161
|
+
const MENU_BUTTON = "[data-sidebar-mobile-menu-button]";
|
|
162
|
+
const PROVIDER = "[data-mobile-menu]";
|
|
163
|
+
/** Focus can go there: connected, not disabled, not inert or hidden, visible */
|
|
164
|
+
const canTakeFocus = (element) => element instanceof HTMLElement &&
|
|
165
|
+
element.isConnected &&
|
|
166
|
+
!element.matches(":disabled") &&
|
|
167
|
+
!element.closest("[inert], [hidden]") &&
|
|
168
|
+
(typeof element.checkVisibility !== "function" || element.checkVisibility({ visibilityProperty: true }));
|
|
169
|
+
/**
|
|
170
|
+
* Focuses where focus goes when the drawer closes: the control that opened it, or, when that cannot take focus (it
|
|
171
|
+
* sat in another drawer that has closed since, it is gone, or it was the page itself), the menu button of this
|
|
172
|
+
* drawer's provider, then any menu button on the page. The first that takes focus; `null` when none does. A drawer
|
|
173
|
+
* that has already left the page has no provider around it, so `root` is the provider taken while it was open.
|
|
174
|
+
*/
|
|
175
|
+
export const returnDrawerFocus = (opener, drawer, root = drawer.closest(PROVIDER)) => {
|
|
176
|
+
// The provider's own menu buttons, not those of a provider inside it
|
|
177
|
+
const own = [...(root?.querySelectorAll(MENU_BUTTON) ?? [])].filter((button) => button.closest(PROVIDER) === root);
|
|
178
|
+
const candidates = [opener, ...own, ...document.querySelectorAll(MENU_BUTTON)];
|
|
179
|
+
for (const candidate of candidates) {
|
|
180
|
+
if (!canTakeFocus(candidate) || drawer.contains(candidate) || candidate === candidate.ownerDocument.body)
|
|
181
|
+
continue;
|
|
182
|
+
candidate.focus({ preventScroll: true });
|
|
183
|
+
if (candidate.ownerDocument.activeElement === candidate)
|
|
184
|
+
return candidate;
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
};
|
|
161
188
|
/**
|
|
162
189
|
* Tab from the last control goes to the first and Shift+Tab from the first to the last, so focus stays in the open
|
|
163
190
|
* drawer. A layer over it in a portal (a menu, a dialog) keeps its own Tab.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phoneDrawer.js","sourceRoot":"","sources":["../../../src/lib/phoneDrawer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAClC,yFAAyF;AACzF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AACnC,sGAAsG;AACtG,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;AACxC,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AA0BpC,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAoB,EAAE,CACvD,gBAAgB,CAAC,MAAM,CAAC,CAAC,gBAA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aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACrC,CAAC;SAAM,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QAC9C,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,KAAK,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;IACtC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CAAC,KAAoB,EAAE,MAAmB,EAAE,KAAiB;IACjG,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,IAAI,KAAK,CAAC,gBAAgB;QAAE,OAAM;IAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,CAAA;IAC7C,IAAI,CAAC,IAAI;QAAE,OAAM;IACjB,MAAM,WAAW,GAAG,CAAC,IAAW,EAAE,EAAE;QAClC,IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QAChD,oGAAoG;QACpG,IAAI,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,gBAAgB;YAAE,OAAM;QACpD,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,KAAK,EAAE,CAAA;IACT,CAAC,CAAA;IACD,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["/**\n * The phone drawer of Sidebar, shared by React and Vue (one copy per package, kept identical by lib-sync).\n *\n * - It follows the finger: a swipe in from the edge it lives behind opens it, a swipe back toward that edge closes\n * it, and either finishes on release by how far and how fast the finger went. The drawer says its edge in\n * `--sidebar-drawer-edge` (`left` or `right`). While a finger drags it, the root carries `data-mobile-dragging`\n * and `--sidebar-drawer-progress` (0 closed to 1 open), and the styles place the drawer by them.\n * - While it is open, Tab goes round its controls (the page behind is inert), and Escape closes it once every other\n * listener has had the key, so a menu or dialog over the drawer takes its own Escape first.\n */\n\n/** How far in from its edge a swipe that opens the drawer may start */\nexport const DRAWER_EDGE_ZONE = 24\n/** How far a finger moves before the swipe is taken as horizontal or left to the page */\nexport const DRAWER_SWIPE_SLOP = 10\n/** A release faster than this, in px/ms, finishes the swipe in its direction whatever the distance */\nexport const DRAWER_SWIPE_VELOCITY = 0.3\n/** A finger held still this long, in ms, before it lifts lets go by distance alone */\nexport const DRAWER_SWIPE_HOLD = 100\n\nexport type DrawerSwipeOptions = {\n /** The element that holds the drawer and the page, where the drag state is written */\n root: HTMLElement\n /** The drawer itself */\n drawer: HTMLElement\n isOpen: () => boolean\n setOpen: (open: boolean) => void\n /** False turns the gesture off (a wide layout) */\n enabled?: () => boolean\n}\n\ntype Drag = {\n x: number\n y: number\n lastX: number\n lastTime: number\n velocity: number\n open: boolean\n edge: \"left\" | \"right\"\n travel: number\n state: \"pending\" | \"dragging\" | \"ignored\"\n progress: number\n}\n\nconst edgeOf = (drawer: HTMLElement): \"left\" | \"right\" =>\n getComputedStyle(drawer).getPropertyValue(\"--sidebar-drawer-edge\").trim() === \"left\" ? \"left\" : \"right\"\n\n/** The distance the drawer travels: its own width when it slides in beside the page, else its container's width */\nconst travelOf = (drawer: HTMLElement, root: HTMLElement, edge: \"left\" | \"right\") => {\n if (edge === \"left\") return drawer.getBoundingClientRect().width || root.getBoundingClientRect().width\n const container = drawer.offsetParent instanceof HTMLElement ? drawer.offsetParent : null\n return container?.clientWidth || window.innerWidth\n}\n\n/**\n * A finger on a slider, on an element that takes horizontal touches itself (`touch-action` without `pan-x`, such\n * as the Slider) or in a row that scrolls sideways moves that, not the drawer\n */\nconst ownsHorizontalSwipe = (target: EventTarget | null, root: HTMLElement) => {\n for (let node = target instanceof Element ? target : null; node && node !== root; node = node.parentElement) {\n if ((node instanceof HTMLInputElement && node.type === \"range\") || node.getAttribute(\"role\") === \"slider\") return true\n const style = getComputedStyle(node)\n if (/^(none|pan-y|pinch-zoom)/.test(style.touchAction) && !style.touchAction.includes(\"pan-x\")) return true\n if (node.scrollWidth > node.clientWidth && /auto|scroll/.test(style.overflowX)) return true\n }\n return false\n}\n\n/**\n * A popover or menu open over the drawer (the Radix and Reka popper wrappers) keeps the touch: swiping the drawer\n * away from under it would leave it open on an inert trigger. A modal dialog's overlay already covers the drawer.\n */\nconst layerOpen = (root: HTMLElement) =>\n root.ownerDocument.querySelector(\"[data-radix-popper-content-wrapper], [data-reka-popper-content-wrapper]\") !== null\n\n/** Starts the gesture on `root`; returns the cleanup */\nexport function attachDrawerSwipe({ root, drawer, isOpen, setOpen, enabled = () => true }: DrawerSwipeOptions) {\n let drag: Drag | null = null\n\n const setProgress = (progress: number) => {\n root.style.setProperty(\"--sidebar-drawer-progress\", String(progress))\n }\n\n const end = (commit: boolean, time = 0) => {\n const current = drag\n drag = null\n if (!current || current.state !== \"dragging\") return\n let next = current.open\n if (commit) {\n // Velocity in the opening direction is positive; a finger that stopped before lifting has none\n const velocity = time - current.lastTime > DRAWER_SWIPE_HOLD ? 0 : current.velocity\n const opening = current.edge === \"left\" ? velocity : -velocity\n next = opening > DRAWER_SWIPE_VELOCITY ? true : opening < -DRAWER_SWIPE_VELOCITY ? false : current.progress > 0.5\n }\n if (next !== current.open) setOpen(next)\n // The drawer leaves the finger once the new state is on the page, so it animates from where it was let go\n requestAnimationFrame(() => {\n root.removeAttribute(\"data-mobile-dragging\")\n root.style.removeProperty(\"--sidebar-drawer-progress\")\n })\n }\n\n const onTouchStart = (event: TouchEvent) => {\n // A second finger cancels a swipe under way, and the drawer goes back to where it was\n end(false)\n if (event.touches.length !== 1 || !enabled() || layerOpen(root) || ownsHorizontalSwipe(event.target, root)) return\n const touch = event.touches[0]!\n const open = isOpen()\n const edge = edgeOf(drawer)\n if (!open) {\n const bounds = root.getBoundingClientRect()\n const fromEdge = edge === \"left\" ? touch.clientX - bounds.left : bounds.right - touch.clientX\n if (fromEdge < 0 || fromEdge > DRAWER_EDGE_ZONE) return\n }\n drag = {\n x: touch.clientX,\n y: touch.clientY,\n lastX: touch.clientX,\n lastTime: event.timeStamp,\n velocity: 0,\n open,\n edge,\n travel: Math.max(1, travelOf(drawer, root, edge)),\n state: \"pending\",\n progress: open ? 1 : 0,\n }\n }\n\n const onTouchMove = (event: TouchEvent) => {\n if (!drag || drag.state === \"ignored\") return\n // A second finger put down outside the root shows only here\n if (event.touches.length !== 1) {\n end(false)\n return\n }\n const touch = event.touches[0]\n if (!touch) return\n const dx = touch.clientX - drag.x\n const dy = touch.clientY - drag.y\n // Toward the open drawer is positive\n const toward = drag.edge === \"left\" ? dx : -dx\n if (drag.state === \"pending\") {\n if (Math.abs(dx) < DRAWER_SWIPE_SLOP && Math.abs(dy) < DRAWER_SWIPE_SLOP) return\n const horizontal = Math.abs(dx) > Math.abs(dy)\n if (!horizontal || (drag.open ? toward >= 0 : toward <= 0)) {\n drag.state = \"ignored\"\n return\n }\n drag.state = \"dragging\"\n root.setAttribute(\"data-mobile-dragging\", \"\")\n }\n if (event.cancelable) event.preventDefault()\n const elapsed = event.timeStamp - drag.lastTime\n if (elapsed > 0) drag.velocity = (touch.clientX - drag.lastX) / elapsed\n drag.lastX = touch.clientX\n drag.lastTime = event.timeStamp\n drag.progress = Math.min(1, Math.max(0, (drag.open ? 1 : 0) + toward / drag.travel))\n setProgress(drag.progress)\n }\n\n // A finger lifted while another stays on the screen cancels the swipe\n const onTouchEnd = (event: TouchEvent) => end(event.touches.length === 0, event.timeStamp)\n const onTouchCancel = () => end(false)\n\n root.addEventListener(\"touchstart\", onTouchStart, { passive: true })\n root.addEventListener(\"touchmove\", onTouchMove, { passive: false })\n root.addEventListener(\"touchend\", onTouchEnd)\n root.addEventListener(\"touchcancel\", onTouchCancel)\n return () => {\n root.removeEventListener(\"touchstart\", onTouchStart)\n root.removeEventListener(\"touchmove\", onTouchMove)\n root.removeEventListener(\"touchend\", onTouchEnd)\n root.removeEventListener(\"touchcancel\", onTouchCancel)\n root.removeAttribute(\"data-mobile-dragging\")\n root.style.removeProperty(\"--sidebar-drawer-progress\")\n }\n}\n\nconst TABBABLE =\n 'a[href], area[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), iframe, [contenteditable]:not([contenteditable=\"false\"]), [tabindex]'\n\n/** The controls Tab reaches in the drawer, in order: not disabled (a disabled fieldset too), not in a closed submenu, not hidden */\nexport const drawerTabbables = (drawer: HTMLElement) =>\n Array.from(drawer.querySelectorAll<HTMLElement>(TABBABLE)).filter(\n (element) =>\n element.tabIndex >= 0 &&\n !element.matches(\":disabled\") &&\n !element.closest(\"[inert], [hidden]\") &&\n (typeof element.checkVisibility !== \"function\" || element.checkVisibility({ visibilityProperty: true })),\n )\n\n/** The first control of the open drawer, or the drawer itself */\nexport const drawerInitialFocus = (drawer: HTMLElement) => drawerTabbables(drawer)[0] ?? drawer\n\n/**\n * Tab from the last control goes to the first and Shift+Tab from the first to the last, so focus stays in the open\n * drawer. A layer over it in a portal (a menu, a dialog) keeps its own Tab.\n */\nexport function loopDrawerFocus(event: KeyboardEvent, drawer: HTMLElement) {\n if (event.key !== \"Tab\" || event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return\n if (!(event.target instanceof Node) || !drawer.contains(event.target)) return\n const items = drawerTabbables(drawer)\n const active = drawer.ownerDocument.activeElement\n const first = items[0]\n const last = items[items.length - 1]\n if (!first || !last) {\n event.preventDefault()\n drawer.focus({ preventScroll: true })\n } else if (event.shiftKey && (active === first || active === drawer)) {\n event.preventDefault()\n last.focus({ preventScroll: true })\n } else if (!event.shiftKey && active === last) {\n event.preventDefault()\n first.focus({ preventScroll: true })\n }\n}\n\n/**\n * Escape pressed in the open drawer closes it when the key reaches the window unprevented: a menu, popover or dialog\n * over the drawer has its listener on the way there and takes the key first, however it listens.\n */\nexport function closeOnUnhandledEscape(event: KeyboardEvent, drawer: HTMLElement, close: () => void) {\n if (event.key !== \"Escape\" || event.defaultPrevented) return\n const view = drawer.ownerDocument.defaultView\n if (!view) return\n const afterOthers = (late: Event) => {\n view.removeEventListener(\"keydown\", afterOthers)\n // A listener that stopped the key on its way leaves this one to the next key, which only removes it\n if (late !== event || event.defaultPrevented) return\n event.preventDefault()\n close()\n }\n view.addEventListener(\"keydown\", afterOthers)\n}\n"]}
|
|
1
|
+
{"version":3,"file":"phoneDrawer.js","sourceRoot":"","sources":["../../../src/lib/phoneDrawer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,uEAAuE;AACvE,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,CAAA;AAClC,yFAAyF;AACzF,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAA;AACnC,sGAAsG;AACtG,MAAM,CAAC,MAAM,qBAAqB,GAAG,GAAG,CAAA;AACxC,sFAAsF;AACtF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAA;AA0BpC,MAAM,MAAM,GAAG,CAAC,MAAmB,EAAoB,EAAE,CACvD,gBAAgB,CAAC,MAAM,CAAC,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAA;AAEzG,mHAAmH;AACnH,MAAM,QAAQ,GAAG,CAAC,MAAmB,EAAE,IAAiB,EAAE,IAAsB,EAAE,EAAE;IAClF,IAAI,IAAI,KAAK,MAAM;QAAE,OAAO,MAAM,CAAC,qBAAqB,EAAE,CAAC,KAAK,IAAI,IAAI,CAAC,qBAAqB,EAAE,CAAC,KAAK,CAAA;IACtG,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,YAAY,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAA;IACzF,OAAO,SAAS,EAAE,WAAW,IAAI,MAAM,CAAC,UAAU,CAAA;AACpD,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,mBAAmB,GAAG,CAAC,MAA0B,EAAE,IAAiB,EAAE,EAAE;IAC5E,KAAK,IAAI,IAAI,GAAG,MAAM,YA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IAAI,CAAC,mBAAmB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QAChD,oGAAoG;QACpG,IAAI,IAAI,KAAK,KAAK,IAAI,KAAK,CAAC,gBAAgB;YAAE,OAAM;QACpD,KAAK,CAAC,cAAc,EAAE,CAAA;QACtB,KAAK,EAAE,CAAA;IACT,CAAC,CAAA;IACD,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;AAC/C,CAAC","sourcesContent":["/**\n * The phone drawer of Sidebar, shared by React and Vue (one copy per package, kept identical by lib-sync).\n *\n * - It follows the finger: a swipe in from the edge it lives behind opens it, a swipe back toward that edge closes\n * it, and either finishes on release by how far and how fast the finger went. The drawer says its edge in\n * `--sidebar-drawer-edge` (`left` or `right`). While a finger drags it, the root carries `data-mobile-dragging`\n * and `--sidebar-drawer-progress` (0 closed to 1 open), and the styles place the drawer by them.\n * - While it is open, Tab goes round its controls (the page behind is inert), and Escape closes it once every other\n * listener has had the key, so a menu or dialog over the drawer takes its own Escape first.\n */\n\n/** How far in from its edge a swipe that opens the drawer may start */\nexport const DRAWER_EDGE_ZONE = 24\n/** How far a finger moves before the swipe is taken as horizontal or left to the page */\nexport const DRAWER_SWIPE_SLOP = 10\n/** A release faster than this, in px/ms, finishes the swipe in its direction whatever the distance */\nexport const DRAWER_SWIPE_VELOCITY = 0.3\n/** A finger held still this long, in ms, before it lifts lets go by distance alone */\nexport const DRAWER_SWIPE_HOLD = 100\n\nexport type DrawerSwipeOptions = {\n /** The element that holds the drawer and the page, where the drag state is written */\n root: HTMLElement\n /** The drawer itself */\n drawer: HTMLElement\n isOpen: () => boolean\n setOpen: (open: boolean) => void\n /** False turns the gesture off (a wide layout) */\n enabled?: () => boolean\n}\n\ntype Drag = {\n x: number\n y: number\n lastX: number\n lastTime: number\n velocity: number\n open: boolean\n edge: \"left\" | \"right\"\n travel: number\n state: \"pending\" | \"dragging\" | \"ignored\"\n progress: number\n}\n\nconst edgeOf = (drawer: HTMLElement): \"left\" | \"right\" =>\n getComputedStyle(drawer).getPropertyValue(\"--sidebar-drawer-edge\").trim() === \"left\" ? \"left\" : \"right\"\n\n/** The distance the drawer travels: its own width when it slides in beside the page, else its container's width */\nconst travelOf = (drawer: HTMLElement, root: HTMLElement, edge: \"left\" | \"right\") => {\n if (edge === \"left\") return drawer.getBoundingClientRect().width || root.getBoundingClientRect().width\n const container = drawer.offsetParent instanceof HTMLElement ? drawer.offsetParent : null\n return container?.clientWidth || window.innerWidth\n}\n\n/**\n * A finger on a slider, on an element that takes horizontal touches itself (`touch-action` without `pan-x`, such\n * as the Slider) or in a row that scrolls sideways moves that, not the drawer\n */\nconst ownsHorizontalSwipe = (target: EventTarget | null, root: HTMLElement) => {\n for (let node = target instanceof Element ? target : null; node && node !== root; node = node.parentElement) {\n if ((node instanceof HTMLInputElement && node.type === \"range\") || node.getAttribute(\"role\") === \"slider\") return true\n const style = getComputedStyle(node)\n if (/^(none|pan-y|pinch-zoom)/.test(style.touchAction) && !style.touchAction.includes(\"pan-x\")) return true\n if (node.scrollWidth > node.clientWidth && /auto|scroll/.test(style.overflowX)) return true\n }\n return false\n}\n\n/**\n * A popover or menu open over the drawer (the Radix and Reka popper wrappers) keeps the touch: swiping the drawer\n * away from under it would leave it open on an inert trigger. A modal dialog's overlay already covers the drawer.\n */\nconst layerOpen = (root: HTMLElement) =>\n root.ownerDocument.querySelector(\"[data-radix-popper-content-wrapper], [data-reka-popper-content-wrapper]\") !== null\n\n/** Starts the gesture on `root`; returns the cleanup */\nexport function attachDrawerSwipe({ root, drawer, isOpen, setOpen, enabled = () => true }: DrawerSwipeOptions) {\n let drag: Drag | null = null\n\n const setProgress = (progress: number) => {\n root.style.setProperty(\"--sidebar-drawer-progress\", String(progress))\n }\n\n const end = (commit: boolean, time = 0) => {\n const current = drag\n drag = null\n if (!current || current.state !== \"dragging\") return\n let next = current.open\n if (commit) {\n // Velocity in the opening direction is positive; a finger that stopped before lifting has none\n const velocity = time - current.lastTime > DRAWER_SWIPE_HOLD ? 0 : current.velocity\n const opening = current.edge === \"left\" ? velocity : -velocity\n next = opening > DRAWER_SWIPE_VELOCITY ? true : opening < -DRAWER_SWIPE_VELOCITY ? false : current.progress > 0.5\n }\n if (next !== current.open) setOpen(next)\n // The drawer leaves the finger once the new state is on the page, so it animates from where it was let go\n requestAnimationFrame(() => {\n root.removeAttribute(\"data-mobile-dragging\")\n root.style.removeProperty(\"--sidebar-drawer-progress\")\n })\n }\n\n const onTouchStart = (event: TouchEvent) => {\n // A second finger cancels a swipe under way, and the drawer goes back to where it was\n end(false)\n if (event.touches.length !== 1 || !enabled() || layerOpen(root) || ownsHorizontalSwipe(event.target, root)) return\n const touch = event.touches[0]!\n const open = isOpen()\n const edge = edgeOf(drawer)\n if (!open) {\n const bounds = root.getBoundingClientRect()\n const fromEdge = edge === \"left\" ? touch.clientX - bounds.left : bounds.right - touch.clientX\n if (fromEdge < 0 || fromEdge > DRAWER_EDGE_ZONE) return\n }\n drag = {\n x: touch.clientX,\n y: touch.clientY,\n lastX: touch.clientX,\n lastTime: event.timeStamp,\n velocity: 0,\n open,\n edge,\n travel: Math.max(1, travelOf(drawer, root, edge)),\n state: \"pending\",\n progress: open ? 1 : 0,\n }\n }\n\n const onTouchMove = (event: TouchEvent) => {\n if (!drag || drag.state === \"ignored\") return\n // A second finger put down outside the root shows only here\n if (event.touches.length !== 1) {\n end(false)\n return\n }\n const touch = event.touches[0]\n if (!touch) return\n const dx = touch.clientX - drag.x\n const dy = touch.clientY - drag.y\n // Toward the open drawer is positive\n const toward = drag.edge === \"left\" ? dx : -dx\n if (drag.state === \"pending\") {\n if (Math.abs(dx) < DRAWER_SWIPE_SLOP && Math.abs(dy) < DRAWER_SWIPE_SLOP) return\n const horizontal = Math.abs(dx) > Math.abs(dy)\n if (!horizontal || (drag.open ? toward >= 0 : toward <= 0)) {\n drag.state = \"ignored\"\n return\n }\n drag.state = \"dragging\"\n root.setAttribute(\"data-mobile-dragging\", \"\")\n }\n if (event.cancelable) event.preventDefault()\n const elapsed = event.timeStamp - drag.lastTime\n if (elapsed > 0) drag.velocity = (touch.clientX - drag.lastX) / elapsed\n drag.lastX = touch.clientX\n drag.lastTime = event.timeStamp\n drag.progress = Math.min(1, Math.max(0, (drag.open ? 1 : 0) + toward / drag.travel))\n setProgress(drag.progress)\n }\n\n // A finger lifted while another stays on the screen cancels the swipe\n const onTouchEnd = (event: TouchEvent) => end(event.touches.length === 0, event.timeStamp)\n const onTouchCancel = () => end(false)\n\n root.addEventListener(\"touchstart\", onTouchStart, { passive: true })\n root.addEventListener(\"touchmove\", onTouchMove, { passive: false })\n root.addEventListener(\"touchend\", onTouchEnd)\n root.addEventListener(\"touchcancel\", onTouchCancel)\n return () => {\n root.removeEventListener(\"touchstart\", onTouchStart)\n root.removeEventListener(\"touchmove\", onTouchMove)\n root.removeEventListener(\"touchend\", onTouchEnd)\n root.removeEventListener(\"touchcancel\", onTouchCancel)\n root.removeAttribute(\"data-mobile-dragging\")\n root.style.removeProperty(\"--sidebar-drawer-progress\")\n }\n}\n\nconst TABBABLE =\n 'a[href], area[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), iframe, [contenteditable]:not([contenteditable=\"false\"]), [tabindex]'\n\n/** The controls Tab reaches in the drawer, in order: not disabled (a disabled fieldset too), not in a closed submenu, not hidden */\nexport const drawerTabbables = (drawer: HTMLElement) =>\n Array.from(drawer.querySelectorAll<HTMLElement>(TABBABLE)).filter(\n (element) =>\n element.tabIndex >= 0 &&\n !element.matches(\":disabled\") &&\n !element.closest(\"[inert], [hidden]\") &&\n (typeof element.checkVisibility !== \"function\" || element.checkVisibility({ visibilityProperty: true })),\n )\n\n/** The first control of the open drawer, or the drawer itself */\nexport const drawerInitialFocus = (drawer: HTMLElement) => drawerTabbables(drawer)[0] ?? drawer\n\nconst MENU_BUTTON = \"[data-sidebar-mobile-menu-button]\"\nconst PROVIDER = \"[data-mobile-menu]\"\n\n/** Focus can go there: connected, not disabled, not inert or hidden, visible */\nconst canTakeFocus = (element: Element | null): element is HTMLElement =>\n element instanceof HTMLElement &&\n element.isConnected &&\n !element.matches(\":disabled\") &&\n !element.closest(\"[inert], [hidden]\") &&\n (typeof element.checkVisibility !== \"function\" || element.checkVisibility({ visibilityProperty: true }))\n\n/**\n * Focuses where focus goes when the drawer closes: the control that opened it, or, when that cannot take focus (it\n * sat in another drawer that has closed since, it is gone, or it was the page itself), the menu button of this\n * drawer's provider, then any menu button on the page. The first that takes focus; `null` when none does. A drawer\n * that has already left the page has no provider around it, so `root` is the provider taken while it was open.\n */\nexport const returnDrawerFocus = (\n opener: Element | null,\n drawer: HTMLElement,\n root: Element | null = drawer.closest(PROVIDER),\n): HTMLElement | null => {\n // The provider's own menu buttons, not those of a provider inside it\n const own = [...(root?.querySelectorAll(MENU_BUTTON) ?? [])].filter((button) => button.closest(PROVIDER) === root)\n const candidates = [opener, ...own, ...document.querySelectorAll(MENU_BUTTON)]\n for (const candidate of candidates) {\n if (!canTakeFocus(candidate) || drawer.contains(candidate) || candidate === candidate.ownerDocument.body) continue\n candidate.focus({ preventScroll: true })\n if (candidate.ownerDocument.activeElement === candidate) return candidate\n }\n return null\n}\n\n/**\n * Tab from the last control goes to the first and Shift+Tab from the first to the last, so focus stays in the open\n * drawer. A layer over it in a portal (a menu, a dialog) keeps its own Tab.\n */\nexport function loopDrawerFocus(event: KeyboardEvent, drawer: HTMLElement) {\n if (event.key !== \"Tab\" || event.defaultPrevented || event.altKey || event.ctrlKey || event.metaKey) return\n if (!(event.target instanceof Node) || !drawer.contains(event.target)) return\n const items = drawerTabbables(drawer)\n const active = drawer.ownerDocument.activeElement\n const first = items[0]\n const last = items[items.length - 1]\n if (!first || !last) {\n event.preventDefault()\n drawer.focus({ preventScroll: true })\n } else if (event.shiftKey && (active === first || active === drawer)) {\n event.preventDefault()\n last.focus({ preventScroll: true })\n } else if (!event.shiftKey && active === last) {\n event.preventDefault()\n first.focus({ preventScroll: true })\n }\n}\n\n/**\n * Escape pressed in the open drawer closes it when the key reaches the window unprevented: a menu, popover or dialog\n * over the drawer has its listener on the way there and takes the key first, however it listens.\n */\nexport function closeOnUnhandledEscape(event: KeyboardEvent, drawer: HTMLElement, close: () => void) {\n if (event.key !== \"Escape\" || event.defaultPrevented) return\n const view = drawer.ownerDocument.defaultView\n if (!view) return\n const afterOthers = (late: Event) => {\n view.removeEventListener(\"keydown\", afterOthers)\n // A listener that stopped the key on its way leaves this one to the next key, which only removes it\n if (late !== event || event.defaultPrevented) return\n event.preventDefault()\n close()\n }\n view.addEventListener(\"keydown\", afterOthers)\n}\n"]}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type Variants } from "../../types.js";
|
|
2
|
+
import { type MarkdownEditorFormat } from "../../lib/markdownEditorSchema.js";
|
|
2
3
|
export declare const markdownEditorStyles: {
|
|
3
4
|
toolbarButton: string;
|
|
4
5
|
};
|
|
6
|
+
export type { MarkdownEditorFormat };
|
|
5
7
|
export type MarkdownEditorProps = {
|
|
6
8
|
/**
|
|
7
9
|
* @default outline
|
|
@@ -25,6 +27,18 @@ export type MarkdownEditorProps = {
|
|
|
25
27
|
*/
|
|
26
28
|
defaultValue?: string;
|
|
27
29
|
onChange?: (markdown: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* The formats the editor offers, read when the editor is created. A format left out has no toolbar button, shortcut
|
|
32
|
+
* or input rule; pasted and incoming content keeps its text without it, and the markdown does not write it
|
|
33
|
+
* @default ["bold", "italic", "orderedList", "bulletList", "link"]
|
|
34
|
+
*/
|
|
35
|
+
formats?: MarkdownEditorFormat[];
|
|
36
|
+
/**
|
|
37
|
+
* A single newline is a line break, read and written as one "\n", read when the editor is created. Without it a
|
|
38
|
+
* line break is written as a backslash and a newline, and a single newline joins the lines
|
|
39
|
+
* @default false
|
|
40
|
+
*/
|
|
41
|
+
breaks?: boolean;
|
|
28
42
|
toolbarEnd?: React.ReactNode;
|
|
29
43
|
/**
|
|
30
44
|
* @default 1
|
|
@@ -39,4 +53,4 @@ export type MarkdownEditorProps = {
|
|
|
39
53
|
"aria-describedby"?: string;
|
|
40
54
|
"aria-invalid"?: boolean;
|
|
41
55
|
};
|
|
42
|
-
export declare function MarkdownEditor({ variant, disabled, invalid, placeholder, value, defaultValue, onChange, toolbarEnd, rows, className, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "aria-invalid": ariaInvalid, }: MarkdownEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
56
|
+
export declare function MarkdownEditor({ variant, disabled, invalid, placeholder, value, defaultValue, onChange, formats, breaks, toolbarEnd, rows, className, id, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, "aria-describedby": ariaDescribedby, "aria-invalid": ariaInvalid, }: MarkdownEditorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { MarkdownEditor, markdownEditorStyles, type MarkdownEditorProps } from "./MarkdownEditor.js";
|
|
1
|
+
export { MarkdownEditor, markdownEditorStyles, type MarkdownEditorFormat, type MarkdownEditorProps } from "./MarkdownEditor.js";
|