@plexui/vue 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js +84 -216
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/MarkdownEditor/index.js.map +1 -1
- package/dist/es/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 +318 -0
- package/dist/es/lib/markdownEditorSchema.js.map +1 -0
- 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 +74 -1
- package/dist/types/components/MarkdownEditor/index.d.ts +1 -1
- 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 +47 -0
- package/dist/types/lib/rovingFocus.d.ts +51 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToggleGroup.js","sourceRoot":"","sources":["../../../../src/components/ToggleGroup/ToggleGroup.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EACL,QAAQ,EACR,eAAe,EACf,CAAC,EACD,MAAM,EACN,OAAO,EACP,GAAG,GAIJ,MAAM,KAAK,CAAA;AACZ,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAE3D,OAAO,CAAC,MAAM,8DAA8D,CAAA;AAC5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ACxB,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,SAA+B,CAAC;oBACtD,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW;oBACtC,SAAS,EAAE,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM;oBACrC,MAAM,EAAE,IAAI;oBACZ,MAAM,EAAE,IAAI;oBACZ,SAAS,EAAE,OAAO;oBAClB,gGAAgG;oBAChG,uGAAuG;oBACvG,oFAAoF;oBACpF,OAAO,EAAE,QAAQ;oBACjB,eAAe,EAAE,SAAS;oBAC1B,SAAS,EAAE,WAAW;iBACvB,EACD,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,CACrC;aACJ,CACF,CAAA;QACH,CAAC,CAAA;IACH,CAAC;CACF,CAAC,CAAA","sourcesContent":["import clsx from \"clsx\"\nimport {\n computed,\n defineComponent,\n h,\n inject,\n provide,\n ref,\n type ComputedRef,\n type InjectionKey,\n type PropType,\n} from \"vue\"\nimport { RovingFocusGroup, RovingFocusItem } from \"reka-ui\"\nimport type { ControlSize, SemanticColors } from \"@plexui/styles/types\"\nimport s from \"@plexui/styles/components/ToggleGroup/ToggleGroup.module.css\"\nimport {\n GROUP_COMPOSED,\n ITEM_COMPOSED,\n RovingElement,\n focusFirst,\n splitListeners,\n} from \"../../lib/rovingFocus.js\"\nimport { Button } from \"../Button/index.js\"\n\n// Vue port of packages/ui/src/components/ToggleGroup/ToggleGroup.tsx: the same DOM (a toolbar of Buttons with\n// `aria-pressed`) and the same behaviour. React builds on Radix ToggleGroup type=\"multiple\". Reka's ToggleGroup\n// runs its toggle before the caller's click handler and enters the group by attributes Radix does not render, so\n// the multiple-select part of Radix ToggleGroup and Toggle is inlined here, and keyboard focus comes from Reka's\n// RovingFocusGroup and RovingFocusItem, the roving tabindex Radix uses. React's `value` + `onChange` become\n// `value` + `update:value` (`v-model:value`) and `change`.\n\ntype ToggleGroupColor = SemanticColors<\n \"primary\" | \"secondary\" | \"danger\" | \"success\" | \"info\" | \"discovery\" | \"caution\" | \"warning\"\n>\n\ntype ToggleGroupContext = ComputedRef<{\n value: readonly string[]\n color: ToggleGroupColor\n size: ControlSize\n pill: boolean\n uniform: boolean\n disabled: boolean\n toggle: (item: string) => void\n}>\n\nconst TOGGLE_GROUP: InjectionKey<ToggleGroupContext> = Symbol(\"ToggleGroup\")\n\ntype ExposedRovingFocusGroup = { getItems: () => { ref: HTMLElement }[] }\n\n/**\n * A row of buttons that each stay pressed or not, any number at a time, such as the days an alarm repeats on.\n * For one choice out of several, use SegmentedControl or RadioGroup.\n */\nexport const ToggleGroup = defineComponent({\n name: \"ToggleGroup\",\n inheritAttrs: false,\n props: {\n /** The values of the pressed items (controlled). Bind with `v-model:value`. */\n value: { type: Array as PropType<string[]>, default: undefined },\n /** The values of the items pressed when the group is first rendered (uncontrolled). @default [] */\n defaultValue: { type: Array as PropType<string[]>, default: () => [] },\n /** The fill of a pressed item, a solid button in this color. An item that is not pressed is a soft secondary button. @default \"primary\" */\n color: { type: String as PropType<ToggleGroupColor>, default: \"primary\" },\n /** The size of the items, as the Button sizes. @default \"md\" */\n size: { type: String as PropType<ControlSize>, default: \"md\" },\n /** Fully rounded items. With `uniform`, each item is a circle. @default false */\n pill: { type: Boolean, default: false },\n /** Items as wide as they are tall, for a letter or an icon. @default false */\n uniform: { type: Boolean, default: false },\n /** Fills the width of its container and spreads the items across it, the first and the last at the edges. @default false */\n block: { type: Boolean, default: false },\n /** Disables every item. @default false */\n disabled: { type: Boolean, default: false },\n /** The reading direction of the items, which the arrow keys follow. @default \"ltr\" */\n dir: { type: String as PropType<\"ltr\" | \"rtl\">, default: undefined },\n },\n emits: {\n /** The pressed items changed */\n \"update:value\": (value: string[]) => Array.isArray(value),\n /** The pressed items changed (React `onChange`), a newly pressed one last */\n change: (value: string[]) => Array.isArray(value),\n },\n setup(props, { attrs, emit, slots }) {\n const internalValue = ref<string[]>([...props.defaultValue])\n const value = computed(() => props.value ?? internalValue.value)\n const groupRef = ref<ExposedRovingFocusGroup | null>(null)\n\n // Radix ToggleGroup type=\"multiple\": a pressed item is added last, a released one removed\n const toggle = (item: string) => {\n const next = value.value.includes(item) ? value.value.filter((pressed) => pressed !== item) : [...value.value, item]\n if (props.value === undefined) internalValue.value = next\n emit(\"update:value\", next)\n emit(\"change\", next)\n }\n\n provide(\n TOGGLE_GROUP,\n computed(() => ({\n value: value.value,\n color: props.color,\n size: props.size,\n pill: props.pill,\n uniform: props.uniform,\n disabled: props.disabled,\n toggle,\n })),\n )\n\n // Radix enters the group on the pressed item, then the one focused last, then the first. Reka looks for\n // attributes Radix does not render and for item ids these buttons do not have, so its entry is replaced.\n const handleEntryFocus = (event: Event) => {\n event.preventDefault()\n const items = (groupRef.value?.getItems() ?? [])\n .map((item) => item.ref)\n .filter((item) => !item.hasAttribute(\"disabled\"))\n const pressedItem = items.find((item) => item.getAttribute(\"data-state\") === \"on\")\n const currentItem = items.find((item) => item.getAttribute(\"tabindex\") === \"0\")\n focusFirst([pressedItem, currentItem, ...items].filter((item): item is HTMLElement => !!item))\n }\n\n return () => {\n const { class: className, ...otherAttrs } = attrs\n const { listeners, rest: restAttrs } = splitListeners(otherAttrs, GROUP_COMPOSED)\n return h(\n RovingFocusGroup,\n { ref: groupRef, asChild: true, loop: true, dir: props.dir, onEntryFocus: handleEntryFocus },\n {\n default: () =>\n h(\n RovingElement,\n {\n \"as\": \"div\",\n \"composed\": GROUP_COMPOSED,\n \"listeners\": listeners,\n // `dir` comes from RovingFocusGroup (\"ltr\" unless set), like Radix\n ...restAttrs,\n // Radix ToggleGroup type=\"multiple\" (radix-ui 1.8) is a toolbar: one tab stop, the arrow keys between items\n \"role\": \"toolbar\",\n \"class\": clsx(s.ToggleGroup, className as string | undefined),\n \"data-slot\": \"toggle-group\",\n \"data-block\": props.block ? \"\" : undefined,\n },\n { default: () => slots.default?.() },\n ),\n },\n )\n }\n },\n})\n\n/** One button of a ToggleGroup, pressed while its `value` is in the group's value. */\nexport const ToggleGroupItem = defineComponent({\n name: \"ToggleGroupItem\",\n inheritAttrs: false,\n props: {\n /** The value of the item, in the group's `value` while it is pressed. */\n value: { type: String, required: true },\n /** Disables the item. @default false */\n disabled: { type: Boolean, default: false },\n },\n emits: {\n /** A click, before the item is pressed or released; `event.preventDefault()` keeps it as it is */\n click: (event: MouseEvent) => {\n void event\n return true\n },\n },\n setup(props, { attrs, emit, slots }) {\n const group = inject(TOGGLE_GROUP, null)\n if (!group) throw new Error(\"ToggleGroupItem must be rendered inside a ToggleGroup\")\n\n return () => {\n const { value, color, size, pill, uniform, toggle } = group.value\n const disabled = group.value.disabled || props.disabled\n const pressed = value.includes(props.value)\n const { class: className, ...otherAttrs } = attrs\n const { listeners, rest: restAttrs } = splitListeners(otherAttrs, ITEM_COMPOSED)\n\n // Radix Toggle: the caller's click handler runs first and can cancel the toggle. An emitted event, so a\n // `.once` listener runs first too.\n const handleClick = (event: MouseEvent) => {\n // React does not dispatch mouse handlers on a disabled button\n if (disabled) return\n emit(\"click\", event)\n if (event.defaultPrevented) return\n toggle(props.value)\n }\n\n return h(\n RovingFocusItem,\n { asChild: true, focusable: !disabled, active: pressed },\n {\n default: () =>\n h(\n RovingElement,\n {\n \"as\": Button,\n \"composed\": ITEM_COMPOSED,\n \"listeners\": listeners,\n ...restAttrs,\n // Radix Toggle's state; Reka's RovingFocusItem marks the active item, which Radix does not\n \"aria-pressed\": pressed,\n \"data-state\": pressed ? \"on\" : \"off\",\n \"data-active\": undefined,\n \"class\": clsx(s.Item, className as string | undefined),\n \"color\": pressed ? color : \"secondary\",\n \"variant\": pressed ? \"solid\" : \"soft\",\n \"size\": size,\n \"pill\": pill,\n \"uniform\": uniform,\n // Inert rather than Button's disabled look, which paints a pressed and a released item alike: a\n // disabled item keeps its state at half opacity (ToggleGroup.module.css). Reka's RovingFocusItem marks\n // an item that cannot take focus `data-disabled`, which would bring that look back.\n \"inert\": disabled,\n \"data-disabled\": undefined,\n \"onClick\": handleClick,\n },\n { default: () => slots.default?.() },\n ),\n },\n )\n }\n },\n})\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/ToggleGroup/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA","sourcesContent":["export { ToggleGroup, ToggleGroupItem } from \"./ToggleGroup.js\"\n"]}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import Document from "@tiptap/extension-document";
|
|
2
|
+
import Paragraph from "@tiptap/extension-paragraph";
|
|
3
|
+
import Text from "@tiptap/extension-text";
|
|
4
|
+
import BoldExtension from "@tiptap/extension-bold";
|
|
5
|
+
import ItalicExtension from "@tiptap/extension-italic";
|
|
6
|
+
import LinkExtension from "@tiptap/extension-link";
|
|
7
|
+
import BulletList from "@tiptap/extension-bullet-list";
|
|
8
|
+
import OrderedList from "@tiptap/extension-ordered-list";
|
|
9
|
+
import ListItem from "@tiptap/extension-list-item";
|
|
10
|
+
import History from "@tiptap/extension-history";
|
|
11
|
+
import Placeholder from "@tiptap/extension-placeholder";
|
|
12
|
+
import HardBreak from "@tiptap/extension-hard-break";
|
|
13
|
+
import { Markdown as MarkdownExtension } from "tiptap-markdown";
|
|
14
|
+
export const MARKDOWN_EDITOR_FORMATS = ["bold", "italic", "orderedList", "bulletList", "link"];
|
|
15
|
+
export const markdownEditorSchema = (formats = MARKDOWN_EDITOR_FORMATS, breaks = false) => ({ formats: new Set(formats), breaks });
|
|
16
|
+
const LISTS = [
|
|
17
|
+
["bulletList", "ul"],
|
|
18
|
+
["orderedList", "ol"],
|
|
19
|
+
];
|
|
20
|
+
// Where the line after a line break starts in the markdown being written, and the paragraph it is in
|
|
21
|
+
const lineStarts = new WeakMap();
|
|
22
|
+
// A line break before more text: "\n" with `breaks`, otherwise a backslash and a newline, a line break in any
|
|
23
|
+
// markdown. Breaks at the end of a paragraph write nothing, as in tiptap-markdown. With `breaks`, "\n" ends a line of
|
|
24
|
+
// text; a line with none (the paragraph's first, or one between two breaks) would be blank and end the paragraph, so
|
|
25
|
+
// its break is a backslash and a newline too
|
|
26
|
+
const lineBreak = (breaks) => HardBreak.extend({
|
|
27
|
+
addStorage() {
|
|
28
|
+
return {
|
|
29
|
+
...this.parent?.(),
|
|
30
|
+
markdown: {
|
|
31
|
+
serialize(state, node, parent, index) {
|
|
32
|
+
for (let i = index + 1; i < parent.childCount; i++) {
|
|
33
|
+
if (parent.child(i).type === node.type)
|
|
34
|
+
continue;
|
|
35
|
+
let line = "";
|
|
36
|
+
for (let j = index - 1; j >= 0 && parent.child(j).type !== node.type; j--)
|
|
37
|
+
line = (parent.child(j).text ?? "") + line;
|
|
38
|
+
state.write(breaks && /[^ \t]/.test(line) ? "\n" : "\\\n");
|
|
39
|
+
lineStarts.set(state, { at: state.out.length, parent });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
parse: {},
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
// What opens a block at the start of a markdown line, after its white space: a "-" or "+" item, a "#" heading, a "1."
|
|
49
|
+
// or "1)" item. "*" is escaped wherever it is, ">" is written as ">"
|
|
50
|
+
const LINE_OPENER = /^(?:\d+(?=[.)](?:[ \t]|$))|(?=-|\+(?:[ \t]|$)|#{1,6}(?:[ \t]|$)))/;
|
|
51
|
+
// A line of "=" makes the line above it a heading
|
|
52
|
+
const HEADING_UNDERLINE = /^(?==+[ \t]*$)/;
|
|
53
|
+
const escapeHtml = (text) => text.replace(/</g, "<").replace(/>/g, ">");
|
|
54
|
+
// Text as tiptap-markdown writes it (with "<" and ">" as entities), escaping what would open a block at the start of
|
|
55
|
+
// a line, so the line keeps its text when the markdown is read again. After a line break the line continues the
|
|
56
|
+
// paragraph and is never code, so an opener is escaped after any white space, also white space written before it
|
|
57
|
+
// (a marked one is written outside its mark). At the start of a paragraph, as prosemirror-markdown does, after up to
|
|
58
|
+
// three spaces: four columns start code there, where an escape would show
|
|
59
|
+
const EditorText = Text.extend({
|
|
60
|
+
addStorage() {
|
|
61
|
+
return {
|
|
62
|
+
...this.parent?.(),
|
|
63
|
+
markdown: {
|
|
64
|
+
serialize(state, node, parent) {
|
|
65
|
+
const text = escapeHtml(node.text ?? "");
|
|
66
|
+
const lineStart = lineStarts.get(state);
|
|
67
|
+
const afterBreak = lineStart?.parent === parent && !state.atBlockStart && /^[ \t]*$/.test(state.out.slice(lineStart.at));
|
|
68
|
+
const space = (afterBreak ? /^[ \t]*/ : state.atBlockStart ? /^ {0,3}/ : null)?.exec(text)?.[0];
|
|
69
|
+
const rest = space === undefined ? "" : text.slice(space.length);
|
|
70
|
+
const opener = space === undefined ? null : LINE_OPENER.exec(rest) ?? (afterBreak ? HEADING_UNDERLINE.exec(rest) : null);
|
|
71
|
+
// The opener is escaped here; prosemirror-markdown's own escape at the start of a paragraph would escape it twice
|
|
72
|
+
state.atBlockStart = false;
|
|
73
|
+
if (!opener)
|
|
74
|
+
return state.text(text);
|
|
75
|
+
const at = space.length + opener[0].length;
|
|
76
|
+
state.text(`${text.slice(0, at)}\\`, false);
|
|
77
|
+
state.text(text.slice(at));
|
|
78
|
+
},
|
|
79
|
+
parse: {},
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
// An item of a list the editor offers. An item of the other list is its paragraphs, not an item of the offered one,
|
|
85
|
+
// which ProseMirror would otherwise wrap it in
|
|
86
|
+
const listItemOf = (tags) => ListItem.extend({
|
|
87
|
+
parseHTML() {
|
|
88
|
+
return [{ tag: "li", getAttrs: (element) => (tags.has(element.parentElement?.localName ?? "") ? null : false) }];
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
/**
|
|
92
|
+
* The editor's extensions. A format left out has no mark or node: its shortcut and input rule are gone, and pasted or
|
|
93
|
+
* incoming content keeps its text without it, so the markdown going out does not write it either.
|
|
94
|
+
*/
|
|
95
|
+
export const markdownEditorExtensions = ({ formats, breaks }, placeholder) => {
|
|
96
|
+
const lists = LISTS.filter(([format]) => formats.has(format));
|
|
97
|
+
return [
|
|
98
|
+
Document,
|
|
99
|
+
Paragraph,
|
|
100
|
+
EditorText,
|
|
101
|
+
lineBreak(breaks),
|
|
102
|
+
...(formats.has("bold") ? [BoldExtension] : []),
|
|
103
|
+
...(formats.has("italic") ? [ItalicExtension] : []),
|
|
104
|
+
...(formats.has("link")
|
|
105
|
+
? [LinkExtension.configure({ openOnClick: false, HTMLAttributes: { rel: "noopener noreferrer nofollow" } })]
|
|
106
|
+
: []),
|
|
107
|
+
...(formats.has("bulletList") ? [BulletList] : []),
|
|
108
|
+
...(formats.has("orderedList") ? [OrderedList] : []),
|
|
109
|
+
...(lists.length === LISTS.length ? [ListItem] : lists.length ? [listItemOf(new Set(lists.map(([, tag]) => tag)))] : []),
|
|
110
|
+
History,
|
|
111
|
+
MarkdownExtension.configure({ html: false, breaks, transformPastedText: true, transformCopiedText: true }),
|
|
112
|
+
...(placeholder ? [Placeholder.configure({ placeholder })] : []),
|
|
113
|
+
];
|
|
114
|
+
};
|
|
115
|
+
// The editor reads markdown with `html: false` (markdown-it): HTML is not parsed, its characters are text, and the
|
|
116
|
+
// markdown around and inside it still is
|
|
117
|
+
export function remarkWithoutHtml() {
|
|
118
|
+
const data = this.data();
|
|
119
|
+
(data.micromarkExtensions ??= []).push({ disable: { null: ["htmlFlow", "htmlText"] } });
|
|
120
|
+
}
|
|
121
|
+
// The newlines of a text node's source, in order: a line ending, or a character reference markdown-it reads as a
|
|
122
|
+
// newline in the text (of at most seven decimal or six hexadecimal digits). A backslash escape is neither, so
|
|
123
|
+
// "\\ " is no reference
|
|
124
|
+
const SOURCE_NEWLINES = /\\[\s\S]|&(?:#0{0,5}1[03]|#[xX]0{0,5}[aAdD]|NewLine);|\r\n?|\n/g;
|
|
125
|
+
// With `breaks`, markdown-it reads a line ending in a paragraph as a line break (a newline from a character reference
|
|
126
|
+
// stays text). It drops the spaces at the end of the line, keeping a tab before them, and the spaces and tabs at the
|
|
127
|
+
// start of the next one. remark drops the white space at the end of a line from the text, so it is taken from the source
|
|
128
|
+
export function remarkLineBreaks() {
|
|
129
|
+
return (tree, file) => {
|
|
130
|
+
const source = String(file.value ?? "");
|
|
131
|
+
const split = (node) => {
|
|
132
|
+
if (node.type !== "text") {
|
|
133
|
+
if (node.children)
|
|
134
|
+
node.children = node.children.flatMap(split);
|
|
135
|
+
return [node];
|
|
136
|
+
}
|
|
137
|
+
const value = node.value ?? "";
|
|
138
|
+
const { start, end } = node.position ?? {};
|
|
139
|
+
const raw = start?.offset !== undefined && end?.offset !== undefined ? source.slice(start.offset, end.offset) : value;
|
|
140
|
+
// The newlines of the value in order: the source of each (a line ending or a reference) and, for a line ending,
|
|
141
|
+
// the white space before it
|
|
142
|
+
const newlines = [...raw.matchAll(SOURCE_NEWLINES)]
|
|
143
|
+
.filter(([match]) => !match.startsWith("\\"))
|
|
144
|
+
.map((match) => ({ source: match[0], before: /[ \t]*$/.exec(raw.slice(0, match.index))[0] }));
|
|
145
|
+
const lines = [""];
|
|
146
|
+
let index = 0;
|
|
147
|
+
for (let at = value.slice(index).search(/[\r\n]/); at >= 0; at = value.slice(index).search(/[\r\n]/)) {
|
|
148
|
+
const newline = newlines.shift() ?? { source: "\n", before: "" };
|
|
149
|
+
if (newline.source.startsWith("&")) {
|
|
150
|
+
lines[lines.length - 1] += value.slice(index, index + at + 1);
|
|
151
|
+
index += at + 1;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
// The end of the line as markdown-it reads it: the white space remark dropped, without its spaces at the end
|
|
155
|
+
// (white space from a character reference is text, and stays)
|
|
156
|
+
lines[lines.length - 1] += value.slice(index, index + at) + newline.before.replace(/ +$/, "");
|
|
157
|
+
lines.push("");
|
|
158
|
+
index += at + (newline.source === "\r\n" && value.startsWith("\r\n", index + at) ? 2 : 1);
|
|
159
|
+
}
|
|
160
|
+
lines[lines.length - 1] += value.slice(index);
|
|
161
|
+
return lines.flatMap((line, at) => {
|
|
162
|
+
const text = at ? line.replace(/^[ \t]+/, "") : line;
|
|
163
|
+
return [...(at ? [{ type: "break" }] : []), ...(text ? [{ ...node, value: text }] : [])];
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
split(tree);
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
// The editor's schema keeps paragraphs, line breaks and the formats it offers. ProseMirror parses anything else into
|
|
170
|
+
// them: a heading is a paragraph of its text, a code block a paragraph of its lines, a quote its paragraphs, inline
|
|
171
|
+
// code its text, an image or a rule nothing, the text of a list item sits in a paragraph, a mark left out is its text
|
|
172
|
+
// and a list left out its items' paragraphs. Outside a code block it collapses white space, as the page does; the
|
|
173
|
+
// editor's text keeps its spaces (white-space: break-spaces)
|
|
174
|
+
const SCHEMA_AS_PARAGRAPH = new Set(["h1", "h2", "h3", "h4", "h5", "h6"]);
|
|
175
|
+
const SCHEMA_BLOCKS = new Set(["p", "ul", "ol"]);
|
|
176
|
+
const MARKS = new Map([["strong", "bold"], ["em", "italic"], ["a", "link"]]);
|
|
177
|
+
const textOf = (node) => node.value ?? (node.children ?? []).map(textOf).join("");
|
|
178
|
+
const isBlank = (node) => node.type === "text" && !node.value?.trim();
|
|
179
|
+
const lineBreakElement = () => ({ type: "element", tagName: "br", properties: {}, children: [] });
|
|
180
|
+
// White space of a paragraph's text as ProseMirror parses it: runs collapse to one space, none at the start of the
|
|
181
|
+
// paragraph, after a line break or after another space, none at its end
|
|
182
|
+
function collapseWhiteSpace(children) {
|
|
183
|
+
let previous = null;
|
|
184
|
+
let lineStart = true;
|
|
185
|
+
const walk = (nodes) => {
|
|
186
|
+
for (const node of nodes) {
|
|
187
|
+
if (node.type === "text") {
|
|
188
|
+
let value = (node.value ?? "").replace(/[ \t\r\n\f]+/g, " ");
|
|
189
|
+
if (value.startsWith(" ") && (lineStart || previous?.value?.endsWith(" ")))
|
|
190
|
+
value = value.slice(1);
|
|
191
|
+
node.value = value;
|
|
192
|
+
if (value) {
|
|
193
|
+
previous = node;
|
|
194
|
+
lineStart = false;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else if (node.tagName === "br") {
|
|
198
|
+
lineStart = true;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
walk(node.children ?? []);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
walk(children);
|
|
206
|
+
if (previous)
|
|
207
|
+
previous.value = previous.value.replace(/ $/, "");
|
|
208
|
+
}
|
|
209
|
+
const paragraph = (children, { preserveWhiteSpace = false } = {}) => {
|
|
210
|
+
if (!preserveWhiteSpace)
|
|
211
|
+
collapseWhiteSpace(children);
|
|
212
|
+
return {
|
|
213
|
+
type: "element",
|
|
214
|
+
tagName: "p",
|
|
215
|
+
properties: {},
|
|
216
|
+
// An empty paragraph keeps its line, as ProseMirror's trailing break does
|
|
217
|
+
children: children.every((child) => child.type === "text" && !child.value) ? [lineBreakElement()] : children,
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
// tiptap-markdown drops the newline markdown-it writes after an element, outside a code block: a line that follows
|
|
221
|
+
// bold, a link or code joins it without a space
|
|
222
|
+
const dropNewlineAfterElements = (nodes) => nodes.map((node, index) => index && node.type === "text" && nodes[index - 1].type === "element" && node.value?.startsWith("\n")
|
|
223
|
+
? { ...node, value: node.value.slice(1) }
|
|
224
|
+
: node);
|
|
225
|
+
function toEditorSchema(nodes, formats) {
|
|
226
|
+
// The blocks of a list item: its text in paragraphs, around its lists
|
|
227
|
+
const itemBlocks = (children) => {
|
|
228
|
+
const content = [];
|
|
229
|
+
let run = [];
|
|
230
|
+
const flush = () => {
|
|
231
|
+
if (!run.every(isBlank))
|
|
232
|
+
content.push(paragraph(run));
|
|
233
|
+
run = [];
|
|
234
|
+
};
|
|
235
|
+
for (const child of toEditorSchema(children, formats)) {
|
|
236
|
+
if (child.type === "element" && SCHEMA_BLOCKS.has(child.tagName)) {
|
|
237
|
+
flush();
|
|
238
|
+
content.push(child);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
run.push(child);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
flush();
|
|
245
|
+
return content;
|
|
246
|
+
};
|
|
247
|
+
return dropNewlineAfterElements(nodes).flatMap((node) => {
|
|
248
|
+
if (node.type !== "element")
|
|
249
|
+
return [node];
|
|
250
|
+
const children = node.children ?? [];
|
|
251
|
+
switch (node.tagName) {
|
|
252
|
+
case "img":
|
|
253
|
+
case "hr":
|
|
254
|
+
return [];
|
|
255
|
+
case "code":
|
|
256
|
+
return [{ type: "text", value: textOf(node) }];
|
|
257
|
+
case "pre": {
|
|
258
|
+
// ProseMirror keeps a code block's spaces and its newlines as line breaks, the last one followed by the
|
|
259
|
+
// trailing break of a paragraph that ends in a break
|
|
260
|
+
const lines = textOf(node).split("\n");
|
|
261
|
+
if (lines.every((line) => !line))
|
|
262
|
+
return [];
|
|
263
|
+
const content = [];
|
|
264
|
+
lines.forEach((line, index) => {
|
|
265
|
+
if (index)
|
|
266
|
+
content.push(lineBreakElement());
|
|
267
|
+
if (line)
|
|
268
|
+
content.push({ type: "text", value: line });
|
|
269
|
+
});
|
|
270
|
+
if (content[content.length - 1].tagName === "br")
|
|
271
|
+
content.push(lineBreakElement());
|
|
272
|
+
return [paragraph(content, { preserveWhiteSpace: true })];
|
|
273
|
+
}
|
|
274
|
+
case "blockquote":
|
|
275
|
+
return toEditorSchema(children, formats);
|
|
276
|
+
case "p":
|
|
277
|
+
return [paragraph(toEditorSchema(children, formats))];
|
|
278
|
+
case "li": {
|
|
279
|
+
const content = itemBlocks(children);
|
|
280
|
+
// A list item starts with a paragraph, an empty one if it has no text (an empty item, an image)
|
|
281
|
+
if (content[0]?.tagName !== "p")
|
|
282
|
+
content.unshift(paragraph([]));
|
|
283
|
+
return [{ ...node, children: content }];
|
|
284
|
+
}
|
|
285
|
+
case "ul":
|
|
286
|
+
case "ol": {
|
|
287
|
+
const items = children.filter((child) => child.tagName === "li");
|
|
288
|
+
return formats.has(node.tagName === "ul" ? "bulletList" : "orderedList")
|
|
289
|
+
? [{ ...node, children: toEditorSchema(items, formats) }]
|
|
290
|
+
: items.flatMap((item) => itemBlocks(item.children ?? []));
|
|
291
|
+
}
|
|
292
|
+
default: {
|
|
293
|
+
const mark = MARKS.get(node.tagName);
|
|
294
|
+
if (mark && !formats.has(mark))
|
|
295
|
+
return toEditorSchema(children, formats);
|
|
296
|
+
return SCHEMA_AS_PARAGRAPH.has(node.tagName)
|
|
297
|
+
? [paragraph(toEditorSchema(children, formats))]
|
|
298
|
+
: [{ ...node, children: toEditorSchema(children, formats) }];
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* The first frame's HTML in the editor's schema. A document left with no block is the empty paragraph ProseMirror
|
|
305
|
+
* gives it, with the placeholder the editor would show (`placeholder` only while it can be edited).
|
|
306
|
+
*/
|
|
307
|
+
export const rehypeEditorSchema = ({ formats }, placeholder) => function editorSchema() {
|
|
308
|
+
return (tree) => {
|
|
309
|
+
const blocks = toEditorSchema(tree.children ?? [], formats).filter((child) => !isBlank(child));
|
|
310
|
+
tree.children = blocks.length
|
|
311
|
+
? blocks
|
|
312
|
+
: [{
|
|
313
|
+
...paragraph([]),
|
|
314
|
+
properties: placeholder ? { className: ["is-editor-empty"], dataPlaceholder: placeholder } : {},
|
|
315
|
+
}];
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
//# sourceMappingURL=markdownEditorSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markdownEditorSchema.js","sourceRoot":"","sources":["../../../src/lib/markdownEditorSchema.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,4BAA4B,CAAA;AACjD,OAAO,SAAS,MA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,CAAC,CAAA;gBACrC,IAAI,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;oBAAE,OAAO,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;gBACxE,OAAO,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAQ,CAAC;oBAC3C,CAAC,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;oBAChD,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC,CAAA;YAChE,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EAAE,OAAO,EAAwB,EAAE,WAAoB,EAAE,EAAE,CAC5F,SAAS,YAAY;IACnB,OAAO,CAAC,IAAc,EAAE,EAAE;QACxB,MAAM,MAAM,GAAG,cAAc,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAA;QAC9F,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,MAAM;YAC3B,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,CAAC;oBACC,GAAG,SAAS,CAAC,EAAE,CAAC;oBAChB,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,iBAAiB,CAAC,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE;iBAChG,CAAC,CAAA;IACR,CAAC,CAAA;AACH,CAAC,CAAA","sourcesContent":["import type { AnyExtension } from \"@tiptap/core\"\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\"\nimport Document from \"@tiptap/extension-document\"\nimport Paragraph from \"@tiptap/extension-paragraph\"\nimport Text from \"@tiptap/extension-text\"\nimport BoldExtension from \"@tiptap/extension-bold\"\nimport ItalicExtension from \"@tiptap/extension-italic\"\nimport LinkExtension from \"@tiptap/extension-link\"\nimport BulletList from \"@tiptap/extension-bullet-list\"\nimport OrderedList from \"@tiptap/extension-ordered-list\"\nimport ListItem from \"@tiptap/extension-list-item\"\nimport History from \"@tiptap/extension-history\"\nimport Placeholder from \"@tiptap/extension-placeholder\"\nimport HardBreak from \"@tiptap/extension-hard-break\"\nimport { Markdown as MarkdownExtension } from \"tiptap-markdown\"\n\n// The Markdown Editor's schema, shared by React and Vue: the TipTap extensions for the formats it offers, how its\n// markdown is written, and the first frame (its markdown as the editor will show it, before the editor exists)\n\nexport type MarkdownEditorFormat = \"bold\" | \"italic\" | \"orderedList\" | \"bulletList\" | \"link\"\n\nexport const MARKDOWN_EDITOR_FORMATS: readonly MarkdownEditorFormat[] = [\"bold\", \"italic\", \"orderedList\", \"bulletList\", \"link\"]\n\nexport type MarkdownEditorSchema = {\n /** The formats the editor offers: a toolbar button, its shortcut and input rule, and a mark or node in the schema */\n formats: ReadonlySet<MarkdownEditorFormat>\n /** A single newline is a line break, read and written as one \"\\n\" */\n breaks: boolean\n}\n\nexport const markdownEditorSchema = (\n formats: readonly MarkdownEditorFormat[] = MARKDOWN_EDITOR_FORMATS,\n breaks = false,\n): MarkdownEditorSchema => ({ formats: new Set(formats), breaks })\n\nconst LISTS = [\n [\"bulletList\", \"ul\"],\n [\"orderedList\", \"ol\"],\n] as const\n\n/* ------------------------------------------------------------------ */\n/* Writing markdown */\n/* ------------------------------------------------------------------ */\n\ntype SerializerState = {\n out: string\n atBlockStart: boolean\n write: (content?: string) => void\n text: (text: string, escape?: boolean) => void\n}\n\n// Where the line after a line break starts in the markdown being written, and the paragraph it is in\nconst lineStarts = new WeakMap<SerializerState, { at: number; parent: ProseMirrorNode }>()\n\n// A line break before more text: \"\\n\" with `breaks`, otherwise a backslash and a newline, a line break in any\n// markdown. Breaks at the end of a paragraph write nothing, as in tiptap-markdown. With `breaks`, \"\\n\" ends a line of\n// text; a line with none (the paragraph's first, or one between two breaks) would be blank and end the paragraph, so\n// its break is a backslash and a newline too\nconst lineBreak = (breaks: boolean) =>\n HardBreak.extend({\n addStorage() {\n return {\n ...this.parent?.(),\n markdown: {\n serialize(state: SerializerState, node: ProseMirrorNode, parent: ProseMirrorNode, index: number) {\n for (let i = index + 1; i < parent.childCount; i++) {\n if (parent.child(i).type === node.type) continue\n let line = \"\"\n for (let j = index - 1; j >= 0 && parent.child(j).type !== node.type; j--) line = (parent.child(j).text ?? \"\") + line\n state.write(breaks && /[^ \\t]/.test(line) ? \"\\n\" : \"\\\\\\n\")\n lineStarts.set(state, { at: state.out.length, parent })\n return\n }\n },\n parse: {},\n },\n }\n },\n })\n\n// What opens a block at the start of a markdown line, after its white space: a \"-\" or \"+\" item, a \"#\" heading, a \"1.\"\n// or \"1)\" item. \"*\" is escaped wherever it is, \">\" is written as \">\"\nconst LINE_OPENER = /^(?:\\d+(?=[.)](?:[ \\t]|$))|(?=-|\\+(?:[ \\t]|$)|#{1,6}(?:[ \\t]|$)))/\n// A line of \"=\" makes the line above it a heading\nconst HEADING_UNDERLINE = /^(?==+[ \\t]*$)/\nconst escapeHtml = (text: string) => text.replace(/</g, \"<\").replace(/>/g, \">\")\n\n// Text as tiptap-markdown writes it (with \"<\" and \">\" as entities), escaping what would open a block at the start of\n// a line, so the line keeps its text when the markdown is read again. After a line break the line continues the\n// paragraph and is never code, so an opener is escaped after any white space, also white space written before it\n// (a marked one is written outside its mark). At the start of a paragraph, as prosemirror-markdown does, after up to\n// three spaces: four columns start code there, where an escape would show\nconst EditorText = Text.extend({\n addStorage() {\n return {\n ...this.parent?.(),\n markdown: {\n serialize(state: SerializerState, node: ProseMirrorNode, parent: ProseMirrorNode) {\n const text = escapeHtml(node.text ?? \"\")\n const lineStart = lineStarts.get(state)\n const afterBreak = lineStart?.parent === parent && !state.atBlockStart && /^[ \\t]*$/.test(state.out.slice(lineStart.at))\n const space = (afterBreak ? /^[ \\t]*/ : state.atBlockStart ? /^ {0,3}/ : null)?.exec(text)?.[0]\n const rest = space === undefined ? \"\" : text.slice(space.length)\n const opener = space === undefined ? null : LINE_OPENER.exec(rest) ?? (afterBreak ? HEADING_UNDERLINE.exec(rest) : null)\n // The opener is escaped here; prosemirror-markdown's own escape at the start of a paragraph would escape it twice\n state.atBlockStart = false\n if (!opener) return state.text(text)\n const at = space!.length + opener[0].length\n state.text(`${text.slice(0, at)}\\\\`, false)\n state.text(text.slice(at))\n },\n parse: {},\n },\n }\n },\n})\n\n// An item of a list the editor offers. An item of the other list is its paragraphs, not an item of the offered one,\n// which ProseMirror would otherwise wrap it in\nconst listItemOf = (tags: ReadonlySet<string>) =>\n ListItem.extend({\n parseHTML() {\n return [{ tag: \"li\", getAttrs: (element: HTMLElement) => (tags.has(element.parentElement?.localName ?? \"\") ? null : false) }]\n },\n })\n\n/**\n * The editor's extensions. A format left out has no mark or node: its shortcut and input rule are gone, and pasted or\n * incoming content keeps its text without it, so the markdown going out does not write it either.\n */\nexport const markdownEditorExtensions = ({ formats, breaks }: MarkdownEditorSchema, placeholder?: string): AnyExtension[] => {\n const lists = LISTS.filter(([format]) => formats.has(format))\n return [\n Document,\n Paragraph,\n EditorText,\n lineBreak(breaks),\n ...(formats.has(\"bold\") ? [BoldExtension] : []),\n ...(formats.has(\"italic\") ? [ItalicExtension] : []),\n ...(formats.has(\"link\")\n ? [LinkExtension.configure({ openOnClick: false, HTMLAttributes: { rel: \"noopener noreferrer nofollow\" } })]\n : []),\n ...(formats.has(\"bulletList\") ? [BulletList] : []),\n ...(formats.has(\"orderedList\") ? [OrderedList] : []),\n ...(lists.length === LISTS.length ? [ListItem] : lists.length ? [listItemOf(new Set(lists.map(([, tag]) => tag)))] : []),\n History,\n MarkdownExtension.configure({ html: false, breaks, transformPastedText: true, transformCopiedText: true }),\n ...(placeholder ? [Placeholder.configure({ placeholder })] : []),\n ]\n}\n\n/* ------------------------------------------------------------------ */\n/* First frame */\n/* ------------------------------------------------------------------ */\n\n// Nodes of the markdown (mdast) and HTML (hast) trees the first frame rewrites\ntype MarkdownNode = {\n type: string\n value?: string\n position?: { start: { offset?: number }; end: { offset?: number } }\n children?: MarkdownNode[]\n}\ntype HtmlNode = {\n type: string\n tagName?: string\n value?: string\n properties?: Record<string, unknown>\n children?: HtmlNode[]\n}\n\n// The editor reads markdown with `html: false` (markdown-it): HTML is not parsed, its characters are text, and the\n// markdown around and inside it still is\nexport function remarkWithoutHtml(this: { data(): object }) {\n const data = this.data() as { micromarkExtensions?: unknown[] }\n ;(data.micromarkExtensions ??= []).push({ disable: { null: [\"htmlFlow\", \"htmlText\"] } })\n}\n\n// The newlines of a text node's source, in order: a line ending, or a character reference markdown-it reads as a\n// newline in the text (of at most seven decimal or six hexadecimal digits). A backslash escape is neither, so\n// \"\\\\ \" is no reference\nconst SOURCE_NEWLINES = /\\\\[\\s\\S]|&(?:#0{0,5}1[03]|#[xX]0{0,5}[aAdD]|NewLine);|\\r\\n?|\\n/g\n\n// With `breaks`, markdown-it reads a line ending in a paragraph as a line break (a newline from a character reference\n// stays text). It drops the spaces at the end of the line, keeping a tab before them, and the spaces and tabs at the\n// start of the next one. remark drops the white space at the end of a line from the text, so it is taken from the source\nexport function remarkLineBreaks() {\n return (tree: MarkdownNode, file: { value?: unknown }) => {\n const source = String(file.value ?? \"\")\n const split = (node: MarkdownNode): MarkdownNode[] => {\n if (node.type !== \"text\") {\n if (node.children) node.children = node.children.flatMap(split)\n return [node]\n }\n const value = node.value ?? \"\"\n const { start, end } = node.position ?? {}\n const raw = start?.offset !== undefined && end?.offset !== undefined ? source.slice(start.offset, end.offset) : value\n // The newlines of the value in order: the source of each (a line ending or a reference) and, for a line ending,\n // the white space before it\n const newlines = [...raw.matchAll(SOURCE_NEWLINES)]\n .filter(([match]) => !match.startsWith(\"\\\\\"))\n .map((match) => ({ source: match[0], before: /[ \\t]*$/.exec(raw.slice(0, match.index))![0] }))\n const lines = [\"\"]\n let index = 0\n for (let at = value.slice(index).search(/[\\r\\n]/); at >= 0; at = value.slice(index).search(/[\\r\\n]/)) {\n const newline = newlines.shift() ?? { source: \"\\n\", before: \"\" }\n if (newline.source.startsWith(\"&\")) {\n lines[lines.length - 1] += value.slice(index, index + at + 1)\n index += at + 1\n continue\n }\n // The end of the line as markdown-it reads it: the white space remark dropped, without its spaces at the end\n // (white space from a character reference is text, and stays)\n lines[lines.length - 1] += value.slice(index, index + at) + newline.before.replace(/ +$/, \"\")\n lines.push(\"\")\n index += at + (newline.source === \"\\r\\n\" && value.startsWith(\"\\r\\n\", index + at) ? 2 : 1)\n }\n lines[lines.length - 1] += value.slice(index)\n return lines.flatMap((line, at) => {\n const text = at ? line.replace(/^[ \\t]+/, \"\") : line\n return [...(at ? [{ type: \"break\" }] : []), ...(text ? [{ ...node, value: text }] : [])]\n })\n }\n split(tree)\n }\n}\n\n// The editor's schema keeps paragraphs, line breaks and the formats it offers. ProseMirror parses anything else into\n// them: a heading is a paragraph of its text, a code block a paragraph of its lines, a quote its paragraphs, inline\n// code its text, an image or a rule nothing, the text of a list item sits in a paragraph, a mark left out is its text\n// and a list left out its items' paragraphs. Outside a code block it collapses white space, as the page does; the\n// editor's text keeps its spaces (white-space: break-spaces)\nconst SCHEMA_AS_PARAGRAPH = new Set([\"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\"])\nconst SCHEMA_BLOCKS = new Set([\"p\", \"ul\", \"ol\"])\nconst MARKS = new Map<string, MarkdownEditorFormat>([[\"strong\", \"bold\"], [\"em\", \"italic\"], [\"a\", \"link\"]])\nconst textOf = (node: HtmlNode): string => node.value ?? (node.children ?? []).map(textOf).join(\"\")\nconst isBlank = (node: HtmlNode) => node.type === \"text\" && !node.value?.trim()\nconst lineBreakElement = (): HtmlNode => ({ type: \"element\", tagName: \"br\", properties: {}, children: [] })\n\n// White space of a paragraph's text as ProseMirror parses it: runs collapse to one space, none at the start of the\n// paragraph, after a line break or after another space, none at its end\nfunction collapseWhiteSpace(children: HtmlNode[]) {\n let previous: HtmlNode | null = null\n let lineStart = true\n const walk = (nodes: HtmlNode[]) => {\n for (const node of nodes) {\n if (node.type === \"text\") {\n let value = (node.value ?? \"\").replace(/[ \\t\\r\\n\\f]+/g, \" \")\n if (value.startsWith(\" \") && (lineStart || previous?.value?.endsWith(\" \"))) value = value.slice(1)\n node.value = value\n if (value) {\n previous = node\n lineStart = false\n }\n } else if (node.tagName === \"br\") {\n lineStart = true\n } else {\n walk(node.children ?? [])\n }\n }\n }\n walk(children)\n if (previous) (previous as HtmlNode).value = (previous as HtmlNode).value!.replace(/ $/, \"\")\n}\n\nconst paragraph = (children: HtmlNode[], { preserveWhiteSpace = false } = {}): HtmlNode => {\n if (!preserveWhiteSpace) collapseWhiteSpace(children)\n return {\n type: \"element\",\n tagName: \"p\",\n properties: {},\n // An empty paragraph keeps its line, as ProseMirror's trailing break does\n children: children.every((child) => child.type === \"text\" && !child.value) ? [lineBreakElement()] : children,\n }\n}\n\n// tiptap-markdown drops the newline markdown-it writes after an element, outside a code block: a line that follows\n// bold, a link or code joins it without a space\nconst dropNewlineAfterElements = (nodes: HtmlNode[]) =>\n nodes.map((node, index) =>\n index && node.type === \"text\" && nodes[index - 1]!.type === \"element\" && node.value?.startsWith(\"\\n\")\n ? { ...node, value: node.value.slice(1) }\n : node,\n )\n\nfunction toEditorSchema(nodes: HtmlNode[], formats: ReadonlySet<MarkdownEditorFormat>): HtmlNode[] {\n // The blocks of a list item: its text in paragraphs, around its lists\n const itemBlocks = (children: HtmlNode[]) => {\n const content: HtmlNode[] = []\n let run: HtmlNode[] = []\n const flush = () => {\n if (!run.every(isBlank)) content.push(paragraph(run))\n run = []\n }\n for (const child of toEditorSchema(children, formats)) {\n if (child.type === \"element\" && SCHEMA_BLOCKS.has(child.tagName!)) {\n flush()\n content.push(child)\n } else {\n run.push(child)\n }\n }\n flush()\n return content\n }\n\n return dropNewlineAfterElements(nodes).flatMap((node): HtmlNode[] => {\n if (node.type !== \"element\") return [node]\n const children = node.children ?? []\n switch (node.tagName) {\n case \"img\":\n case \"hr\":\n return []\n case \"code\":\n return [{ type: \"text\", value: textOf(node) }]\n case \"pre\": {\n // ProseMirror keeps a code block's spaces and its newlines as line breaks, the last one followed by the\n // trailing break of a paragraph that ends in a break\n const lines = textOf(node).split(\"\\n\")\n if (lines.every((line) => !line)) return []\n const content: HtmlNode[] = []\n lines.forEach((line, index) => {\n if (index) content.push(lineBreakElement())\n if (line) content.push({ type: \"text\", value: line })\n })\n if (content[content.length - 1]!.tagName === \"br\") content.push(lineBreakElement())\n return [paragraph(content, { preserveWhiteSpace: true })]\n }\n case \"blockquote\":\n return toEditorSchema(children, formats)\n case \"p\":\n return [paragraph(toEditorSchema(children, formats))]\n case \"li\": {\n const content = itemBlocks(children)\n // A list item starts with a paragraph, an empty one if it has no text (an empty item, an image)\n if (content[0]?.tagName !== \"p\") content.unshift(paragraph([]))\n return [{ ...node, children: content }]\n }\n case \"ul\":\n case \"ol\": {\n const items = children.filter((child) => child.tagName === \"li\")\n return formats.has(node.tagName === \"ul\" ? \"bulletList\" : \"orderedList\")\n ? [{ ...node, children: toEditorSchema(items, formats) }]\n : items.flatMap((item) => itemBlocks(item.children ?? []))\n }\n default: {\n const mark = MARKS.get(node.tagName!)\n if (mark && !formats.has(mark)) return toEditorSchema(children, formats)\n return SCHEMA_AS_PARAGRAPH.has(node.tagName!)\n ? [paragraph(toEditorSchema(children, formats))]\n : [{ ...node, children: toEditorSchema(children, formats) }]\n }\n }\n })\n}\n\n/**\n * The first frame's HTML in the editor's schema. A document left with no block is the empty paragraph ProseMirror\n * gives it, with the placeholder the editor would show (`placeholder` only while it can be edited).\n */\nexport const rehypeEditorSchema = ({ formats }: MarkdownEditorSchema, placeholder?: string) =>\n function editorSchema() {\n return (tree: HtmlNode) => {\n const blocks = toEditorSchema(tree.children ?? [], formats).filter((child) => !isBlank(child))\n tree.children = blocks.length\n ? blocks\n : [{\n ...paragraph([]),\n properties: placeholder ? { className: [\"is-editor-empty\"], dataPlaceholder: placeholder } : {},\n }]\n }\n }\n"]}
|
|
@@ -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,aAAa,KAAK,iBAAiB;YAAE,OAAM;IAC1D,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,QAAiB,EAAE,KAAY,EAAE,EAAE;IAC9D,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;QACtE,IAAI,OAAO,OAAO,KAAK,UAAU;YAAE,OAAO,CAAC,KAAK,CAAC,CAAA;IACnD,CAAC;AACH,CAAC,CAAA;AAED,0EAA0E;AAC1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D,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"]}
|