@usememos/editor 26.10.13 → 26.10.14
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/README.md +57 -12
- package/dist/base.css +54 -2
- package/dist/emoji-data-WTFGY3MU.js +6 -0
- package/dist/emoji-data-WTFGY3MU.js.map +7 -0
- package/dist/emoji.js +74 -0
- package/dist/emoji.js.map +7 -0
- package/dist/index.js +942 -92
- package/dist/index.js.map +4 -4
- package/dist/react.js.map +2 -2
- package/dist/style.css +147 -4
- package/dist/theme.css +26 -2
- package/dist/types/commands.d.ts +48 -3
- package/dist/types/editor.d.ts +59 -3
- package/dist/types/emoji/data.d.ts +1 -0
- package/dist/types/emoji/index.d.ts +21 -0
- package/dist/types/emoji/search.d.ts +17 -0
- package/dist/types/icons.d.ts +39 -0
- package/dist/types/labels.d.ts +20 -0
- package/dist/types/markdown/blocks.d.ts +2 -0
- package/dist/types/markdown/htmlSection.d.ts +10 -1
- package/dist/types/markdown/inline.d.ts +2 -0
- package/dist/types/markdown/options.d.ts +14 -0
- package/dist/types/markdown/serialize.d.ts +8 -0
- package/dist/types/model.d.ts +42 -5
- package/dist/types/react/index.d.ts +1 -1
- package/dist/types/theme.d.ts +8 -0
- package/dist/types/ui/linkCard.d.ts +46 -0
- package/dist/types/view/dom.d.ts +7 -1
- package/package.json +5 -1
package/dist/react.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/react/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Editor, type EditorOptions, type SuggestionState } from '@usememos/editor';\nimport { type CSSProperties, type ForwardedRef, forwardRef, useEffect, useRef, useState } from 'react';\nimport { flushSync } from 'react-dom';\n\nexport type { Editor, SuggestionState } from '@usememos/editor';\n\n/** Constructor options that the React components take as props. */\ntype EditorProps = Pick<\n EditorOptions,\n | 'markdown'\n | 'extensions'\n | 'placeholder'\n | 'editable'\n | 'taskToggle'\n | 'autofocus'\n | 'attributes'\n | 'resolveUrl'\n | 'referrerPolicy'\n | 'headingIds'\n | 'onLinkClick'\n | 'theme'\n | 'toolbar'\n | 'slashMenu'\n | 'slashHint'\n | 'labels'\n | 'icons'\n>;\n\nexport interface MarkdownEditorProps extends EditorProps {\n /** Markdown. The editor updates only when this is not a value it emitted itself. */\n value?: string;\n /** Initial Markdown for uncontrolled use. */\n defaultValue?: string;\n /** Called after document changes, at most once per animation frame. */\n onChange?: (markdown: string) => void;\n /** Called on Mod+Enter or Ctrl+Enter with the current Markdown. */\n onSubmit?: (markdown: string) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n className?: string;\n style?: CSSProperties;\n}\n\n/** Options that `setOptions` applies without recreating the editor. `extensions` updates suggestion callbacks only. */\nconst LIVE = ['placeholder', 'editable', 'taskToggle', 'attributes', 'resolveUrl', 'onLinkClick', 'theme', 'extensions'] as const;\n\n/** The extension list's identity for recreating the editor: names, so an inline array does not recreate it on every render. */\nconst extensionKey = (extensions: EditorOptions['extensions']) => (extensions ?? []).map((e) => e.name).join('\\n');\n\n/**\n * The editor as a controlled React component. A `ref` gives the core `Editor`.\n *\n * `placeholder`, `editable`, `taskToggle`, `attributes`, `resolveUrl`, `onLinkClick` and `theme` update live.\n * A change to the names in `extensions` recreates the editor, keeping its\n * Markdown; with the same names, the callbacks of `suggestion()` extensions\n * (`items`, `command`, `match`, `allow`) update live. Other props are read\n * when the editor is created; change the component's `key` to apply new values.\n *\n * A `value` that arrives while an input method is composing text is applied\n * when the composition ends, so it does not break the composition.\n */\nexport const MarkdownEditor = forwardRef(function MarkdownEditor(props: MarkdownEditorProps, ref: ForwardedRef<Editor | null>) {\n const container = useRef<HTMLDivElement>(null);\n const editorRef = useRef<Editor | null>(null);\n // Values the editor emitted that the parent has not passed back yet, oldest\n // first. While the user keeps typing, React may hand back an older one;\n // those echoes must not reset the document.\n const pending = useRef<string[]>([]);\n // An outside value that arrived during IME composition.\n const deferred = useRef<string | null>(null);\n // Callbacks are read through a ref so changing them does not recreate the editor.\n const latest = useRef(props);\n latest.current = props;\n const extensions = extensionKey(props.extensions);\n\n useEffect(() => {\n const { value, defaultValue, onChange, onSubmit, onFocus, onBlur, className, style, ...options } = latest.current;\n const previous = editorRef.current;\n const editor = new Editor({\n ...options,\n element: container.current!,\n content: previous?.getMarkdown() ?? value ?? defaultValue ?? '',\n onChange: (markdown) => {\n pending.current.push(markdown);\n if (pending.current.length > 100) pending.current.shift();\n // Render the parent's update now, as React does for a native input's\n // onChange. Left to React's scheduler, it can still be waiting when\n // the parent sets a new value (clearing the box on submit) that equals\n // the value it last rendered; the value effect would then not run.\n flushSync(() => latest.current.onChange?.(markdown));\n },\n onSubmit: (markdown) => latest.current.onSubmit?.(markdown),\n onFocus: () => latest.current.onFocus?.(),\n onBlur: () => latest.current.onBlur?.(),\n });\n editorRef.current = editor;\n pending.current = [];\n assignRef(ref, editor);\n const root = container.current!;\n const onCompositionEnd = () => {\n // Runs after the editor's own compositionend handler, which was added first.\n const value = deferred.current;\n deferred.current = null;\n if (value !== null && value !== editor.getMarkdown()) {\n pending.current = [];\n editor.setMarkdown(value);\n }\n };\n root.addEventListener('compositionend', onCompositionEnd);\n return () => {\n root.removeEventListener('compositionend', onCompositionEnd);\n editor.destroy();\n if (editorRef.current === editor) editorRef.current = null;\n assignRef(ref, null);\n };\n // Recreate only when the extension names change; see the note on the component.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [extensions]);\n\n useEffect(() => {\n const editor = editorRef.current;\n if (!editor || props.value === undefined) return;\n const echo = pending.current.indexOf(props.value);\n if (echo >= 0) {\n // The parent caught up to a value the editor emitted.\n pending.current.splice(0, echo + 1);\n return;\n }\n if (props.value === editor.getMarkdown()) return;\n if (editor.isComposing) {\n deferred.current = props.value;\n return;\n }\n pending.current = [];\n editor.setMarkdown(props.value);\n }, [props.value]);\n\n useLiveOptions(editorRef, props);\n\n return <div ref={container} className={props.className} style={props.style} />;\n});\n\n/** Applies the live options when they change. */\nfunction useLiveOptions(editorRef: { current: Editor | null }, props: EditorProps): void {\n const applied = useRef<{ editor: Editor | null; props: Partial<EditorProps> }>({ editor: null, props: {} });\n useEffect(() => {\n const editor = editorRef.current;\n if (!editor) return;\n if (applied.current.editor !== editor) {\n // A new editor was created with these props.\n applied.current = { editor, props: { ...props } };\n return;\n }\n const changed: Partial<Pick<EditorOptions, (typeof LIVE)[number]>> = {};\n let any = false;\n for (const key of LIVE) {\n if (props[key] === applied.current.props[key]) continue;\n (changed as Record<string, unknown>)[key] = key === 'editable' ? (props.editable ?? true) : key === 'taskToggle' ? (props.taskToggle ?? false) : props[key];\n any = true;\n }\n applied.current = { editor, props: { ...props } };\n if (any) editor.setOptions(changed);\n });\n}\n\n/**\n * Creates an editor for the lifetime of the component, or until a value in\n * `deps` changes. Returns null until the editor exists. Pair it with\n * `<EditorContent editor={editor} />`, which shows it.\n *\n * Callbacks in `options` are read when called, so they may change between\n * renders without recreating the editor. So do the callbacks of\n * `suggestion()` extensions, matched by name.\n */\nexport function useEditor(options: Omit<EditorOptions, 'element'>, deps: readonly unknown[] = []): Editor | null {\n const [editor, setEditor] = useState<Editor | null>(null);\n const latest = useRef(options);\n latest.current = options;\n\n useEffect(() => {\n if (editor && options.extensions) editor.setOptions({ extensions: options.extensions });\n }, [editor, options.extensions]);\n\n useEffect(() => {\n const o = latest.current;\n const element = document.createElement('div');\n const instance = new Editor({\n ...o,\n element,\n // A detached element cannot take focus; EditorContent focuses once mounted.\n autofocus: false,\n onChange: (markdown, e) => latest.current.onChange?.(markdown, e),\n onSubmit: (markdown, e) => latest.current.onSubmit?.(markdown, e),\n onFocus: (e) => latest.current.onFocus?.(e),\n onBlur: (e) => latest.current.onBlur?.(e),\n onLinkClick: (ctx) => latest.current.onLinkClick?.(ctx),\n });\n if (o.autofocus) pendingAutofocus.set(instance, o.autofocus === 'end' ? 'end' : 'start');\n setEditor(instance);\n return () => {\n instance.destroy();\n setEditor(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return editor;\n}\n\n/**\n * The open autocomplete popup of `editor`, or of its suggestion `name`, and\n * a re-render on each change. With `render: false` on a suggestion, draw your\n * own popup from it: put it at `state.anchorRect()`, give the listbox\n * `id={state.listboxId}` and each option `id={state.optionId(i)}`, highlight\n * `state.active`, and call `editor.suggestion.accept(i)` on click.\n */\nexport function useSuggestion(editor: Editor | null, name?: string): SuggestionState | null {\n const select = (state: SuggestionState | null | undefined) => (state && (name === undefined || state.name === name) ? state : null);\n const [state, setState] = useState<SuggestionState | null>(() => select(editor?.suggestion.state));\n useEffect(() => {\n if (!editor) {\n setState(null);\n return;\n }\n setState(select(editor.suggestion.state));\n return editor.on('suggestionChange', ({ state }) => setState(select(state)));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [editor, name]);\n return state;\n}\n\nexport interface EditorContentProps {\n editor: Editor | null;\n className?: string;\n style?: CSSProperties;\n}\n\n/** Shows an editor created with `useEditor`. */\nexport function EditorContent({ editor, className, style }: EditorContentProps) {\n const container = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const host = container.current;\n if (!editor || !host) return;\n host.appendChild(editor.root);\n const autofocus = pendingAutofocus.get(editor);\n if (autofocus) {\n pendingAutofocus.delete(editor);\n editor.commands.focus(autofocus);\n }\n return () => {\n if (editor.root.parentNode === host) host.removeChild(editor.root);\n };\n }, [editor]);\n return <div ref={container} className={className} style={style} />;\n}\n\n/** Where to focus an editor from `useEditor` once `EditorContent` mounts it. */\nconst pendingAutofocus = new WeakMap<Editor, 'start' | 'end'>();\n\nfunction assignRef<T>(ref: ForwardedRef<T>, value: T): void {\n if (typeof ref === 'function') ref(value);\n else if (ref) ref.current = value;\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,cAAwD;AACjE,SAAgD,YAAY,WAAW,QAAQ,gBAAgB;AAC/F,SAAS,iBAAiB;
|
|
4
|
+
"sourcesContent": ["import { Editor, type EditorOptions, type SuggestionState } from '@usememos/editor';\nimport { type CSSProperties, type ForwardedRef, forwardRef, useEffect, useRef, useState } from 'react';\nimport { flushSync } from 'react-dom';\n\nexport type { Editor, SuggestionState } from '@usememos/editor';\n\n/** Constructor options that the React components take as props. */\ntype EditorProps = Pick<\n EditorOptions,\n | 'markdown'\n | 'extensions'\n | 'placeholder'\n | 'editable'\n | 'taskToggle'\n | 'autofocus'\n | 'attributes'\n | 'resolveUrl'\n | 'referrerPolicy'\n | 'headingIds'\n | 'onLinkClick'\n | 'theme'\n | 'toolbar'\n | 'linkCard'\n | 'slashMenu'\n | 'slashHint'\n | 'labels'\n | 'icons'\n>;\n\nexport interface MarkdownEditorProps extends EditorProps {\n /** Markdown. The editor updates only when this is not a value it emitted itself. */\n value?: string;\n /** Initial Markdown for uncontrolled use. */\n defaultValue?: string;\n /** Called after document changes, at most once per animation frame. */\n onChange?: (markdown: string) => void;\n /** Called on Mod+Enter or Ctrl+Enter with the current Markdown. */\n onSubmit?: (markdown: string) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n className?: string;\n style?: CSSProperties;\n}\n\n/** Options that `setOptions` applies without recreating the editor. `extensions` updates suggestion callbacks only. */\nconst LIVE = ['placeholder', 'editable', 'taskToggle', 'attributes', 'resolveUrl', 'onLinkClick', 'theme', 'extensions'] as const;\n\n/** The extension list's identity for recreating the editor: names, so an inline array does not recreate it on every render. */\nconst extensionKey = (extensions: EditorOptions['extensions']) => (extensions ?? []).map((e) => e.name).join('\\n');\n\n/**\n * The editor as a controlled React component. A `ref` gives the core `Editor`.\n *\n * `placeholder`, `editable`, `taskToggle`, `attributes`, `resolveUrl`, `onLinkClick` and `theme` update live.\n * A change to the names in `extensions` recreates the editor, keeping its\n * Markdown; with the same names, the callbacks of `suggestion()` extensions\n * (`items`, `command`, `match`, `allow`) update live. Other props are read\n * when the editor is created; change the component's `key` to apply new values.\n *\n * A `value` that arrives while an input method is composing text is applied\n * when the composition ends, so it does not break the composition.\n */\nexport const MarkdownEditor = forwardRef(function MarkdownEditor(props: MarkdownEditorProps, ref: ForwardedRef<Editor | null>) {\n const container = useRef<HTMLDivElement>(null);\n const editorRef = useRef<Editor | null>(null);\n // Values the editor emitted that the parent has not passed back yet, oldest\n // first. While the user keeps typing, React may hand back an older one;\n // those echoes must not reset the document.\n const pending = useRef<string[]>([]);\n // An outside value that arrived during IME composition.\n const deferred = useRef<string | null>(null);\n // Callbacks are read through a ref so changing them does not recreate the editor.\n const latest = useRef(props);\n latest.current = props;\n const extensions = extensionKey(props.extensions);\n\n useEffect(() => {\n const { value, defaultValue, onChange, onSubmit, onFocus, onBlur, className, style, ...options } = latest.current;\n const previous = editorRef.current;\n const editor = new Editor({\n ...options,\n element: container.current!,\n content: previous?.getMarkdown() ?? value ?? defaultValue ?? '',\n onChange: (markdown) => {\n pending.current.push(markdown);\n if (pending.current.length > 100) pending.current.shift();\n // Render the parent's update now, as React does for a native input's\n // onChange. Left to React's scheduler, it can still be waiting when\n // the parent sets a new value (clearing the box on submit) that equals\n // the value it last rendered; the value effect would then not run.\n flushSync(() => latest.current.onChange?.(markdown));\n },\n onSubmit: (markdown) => latest.current.onSubmit?.(markdown),\n onFocus: () => latest.current.onFocus?.(),\n onBlur: () => latest.current.onBlur?.(),\n });\n editorRef.current = editor;\n pending.current = [];\n assignRef(ref, editor);\n const root = container.current!;\n const onCompositionEnd = () => {\n // Runs after the editor's own compositionend handler, which was added first.\n const value = deferred.current;\n deferred.current = null;\n if (value !== null && value !== editor.getMarkdown()) {\n pending.current = [];\n editor.setMarkdown(value);\n }\n };\n root.addEventListener('compositionend', onCompositionEnd);\n return () => {\n root.removeEventListener('compositionend', onCompositionEnd);\n editor.destroy();\n if (editorRef.current === editor) editorRef.current = null;\n assignRef(ref, null);\n };\n // Recreate only when the extension names change; see the note on the component.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [extensions]);\n\n useEffect(() => {\n const editor = editorRef.current;\n if (!editor || props.value === undefined) return;\n const echo = pending.current.indexOf(props.value);\n if (echo >= 0) {\n // The parent caught up to a value the editor emitted.\n pending.current.splice(0, echo + 1);\n return;\n }\n if (props.value === editor.getMarkdown()) return;\n if (editor.isComposing) {\n deferred.current = props.value;\n return;\n }\n pending.current = [];\n editor.setMarkdown(props.value);\n }, [props.value]);\n\n useLiveOptions(editorRef, props);\n\n return <div ref={container} className={props.className} style={props.style} />;\n});\n\n/** Applies the live options when they change. */\nfunction useLiveOptions(editorRef: { current: Editor | null }, props: EditorProps): void {\n const applied = useRef<{ editor: Editor | null; props: Partial<EditorProps> }>({ editor: null, props: {} });\n useEffect(() => {\n const editor = editorRef.current;\n if (!editor) return;\n if (applied.current.editor !== editor) {\n // A new editor was created with these props.\n applied.current = { editor, props: { ...props } };\n return;\n }\n const changed: Partial<Pick<EditorOptions, (typeof LIVE)[number]>> = {};\n let any = false;\n for (const key of LIVE) {\n if (props[key] === applied.current.props[key]) continue;\n (changed as Record<string, unknown>)[key] = key === 'editable' ? (props.editable ?? true) : key === 'taskToggle' ? (props.taskToggle ?? false) : props[key];\n any = true;\n }\n applied.current = { editor, props: { ...props } };\n if (any) editor.setOptions(changed);\n });\n}\n\n/**\n * Creates an editor for the lifetime of the component, or until a value in\n * `deps` changes. Returns null until the editor exists. Pair it with\n * `<EditorContent editor={editor} />`, which shows it.\n *\n * Callbacks in `options` are read when called, so they may change between\n * renders without recreating the editor. So do the callbacks of\n * `suggestion()` extensions, matched by name.\n */\nexport function useEditor(options: Omit<EditorOptions, 'element'>, deps: readonly unknown[] = []): Editor | null {\n const [editor, setEditor] = useState<Editor | null>(null);\n const latest = useRef(options);\n latest.current = options;\n\n useEffect(() => {\n if (editor && options.extensions) editor.setOptions({ extensions: options.extensions });\n }, [editor, options.extensions]);\n\n useEffect(() => {\n const o = latest.current;\n const element = document.createElement('div');\n const instance = new Editor({\n ...o,\n element,\n // A detached element cannot take focus; EditorContent focuses once mounted.\n autofocus: false,\n onChange: (markdown, e) => latest.current.onChange?.(markdown, e),\n onSubmit: (markdown, e) => latest.current.onSubmit?.(markdown, e),\n onFocus: (e) => latest.current.onFocus?.(e),\n onBlur: (e) => latest.current.onBlur?.(e),\n onLinkClick: (ctx) => latest.current.onLinkClick?.(ctx),\n });\n if (o.autofocus) pendingAutofocus.set(instance, o.autofocus === 'end' ? 'end' : 'start');\n setEditor(instance);\n return () => {\n instance.destroy();\n setEditor(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return editor;\n}\n\n/**\n * The open autocomplete popup of `editor`, or of its suggestion `name`, and\n * a re-render on each change. With `render: false` on a suggestion, draw your\n * own popup from it: put it at `state.anchorRect()`, give the listbox\n * `id={state.listboxId}` and each option `id={state.optionId(i)}`, highlight\n * `state.active`, and call `editor.suggestion.accept(i)` on click.\n */\nexport function useSuggestion(editor: Editor | null, name?: string): SuggestionState | null {\n const select = (state: SuggestionState | null | undefined) => (state && (name === undefined || state.name === name) ? state : null);\n const [state, setState] = useState<SuggestionState | null>(() => select(editor?.suggestion.state));\n useEffect(() => {\n if (!editor) {\n setState(null);\n return;\n }\n setState(select(editor.suggestion.state));\n return editor.on('suggestionChange', ({ state }) => setState(select(state)));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [editor, name]);\n return state;\n}\n\nexport interface EditorContentProps {\n editor: Editor | null;\n className?: string;\n style?: CSSProperties;\n}\n\n/** Shows an editor created with `useEditor`. */\nexport function EditorContent({ editor, className, style }: EditorContentProps) {\n const container = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const host = container.current;\n if (!editor || !host) return;\n host.appendChild(editor.root);\n const autofocus = pendingAutofocus.get(editor);\n if (autofocus) {\n pendingAutofocus.delete(editor);\n editor.commands.focus(autofocus);\n }\n return () => {\n if (editor.root.parentNode === host) host.removeChild(editor.root);\n };\n }, [editor]);\n return <div ref={container} className={className} style={style} />;\n}\n\n/** Where to focus an editor from `useEditor` once `EditorContent` mounts it. */\nconst pendingAutofocus = new WeakMap<Editor, 'start' | 'end'>();\n\nfunction assignRef<T>(ref: ForwardedRef<T>, value: T):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9D,SAAS,UAAa,KAAsB,OAAgB;AAC1D,MAAI,OAAO,QAAQ,WAAY,KAAI,KAAK;AAAA,WAC/B,IAAK,KAAI,UAAU;AAC9B;",
|
|
6
6
|
"names": ["MarkdownEditor", "value", "state"]
|
|
7
7
|
}
|
package/dist/style.css
CHANGED
|
@@ -43,6 +43,68 @@
|
|
|
43
43
|
margin-top: calc(-1 * var(--mbe-block-gap));
|
|
44
44
|
padding-top: var(--mbe-block-gap);
|
|
45
45
|
}
|
|
46
|
+
.mbe-root .mbe-callout-title {
|
|
47
|
+
display: flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
gap: 8px;
|
|
50
|
+
user-select: none;
|
|
51
|
+
-webkit-user-select: none;
|
|
52
|
+
}
|
|
53
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-quote-joined] > .mbe-callout-title {
|
|
54
|
+
display: none;
|
|
55
|
+
}
|
|
56
|
+
.mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-title {
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
}
|
|
59
|
+
:is(.mbe-root, .mbe-flow) > .mbe-details {
|
|
60
|
+
display: flex;
|
|
61
|
+
align-items: flex-start;
|
|
62
|
+
}
|
|
63
|
+
.mbe-root .mbe-details > .mbe-content {
|
|
64
|
+
flex: 1;
|
|
65
|
+
min-width: 0;
|
|
66
|
+
position: relative;
|
|
67
|
+
}
|
|
68
|
+
.mbe-root .mbe-details-marker {
|
|
69
|
+
flex: none;
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
width: var(--mbe-indent-size);
|
|
74
|
+
height: 1.5em;
|
|
75
|
+
height: 1lh;
|
|
76
|
+
user-select: none;
|
|
77
|
+
-webkit-user-select: none;
|
|
78
|
+
}
|
|
79
|
+
.mbe-root .mbe-details-toggle {
|
|
80
|
+
display: inline-flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
border: 0;
|
|
84
|
+
background: none;
|
|
85
|
+
padding: 2px;
|
|
86
|
+
font: inherit;
|
|
87
|
+
color: inherit;
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
}
|
|
90
|
+
.mbe-root .mbe-details-toggle > .mbe-icon {
|
|
91
|
+
transition: transform 0.12s ease;
|
|
92
|
+
transform: rotate(90deg);
|
|
93
|
+
}
|
|
94
|
+
.mbe-root .mbe-details[data-collapsed] .mbe-details-toggle > .mbe-icon {
|
|
95
|
+
transform: none;
|
|
96
|
+
}
|
|
97
|
+
.mbe-root .mbe-details[data-collapsed]:dir(rtl) .mbe-details-toggle > .mbe-icon {
|
|
98
|
+
transform: scaleX(-1);
|
|
99
|
+
}
|
|
100
|
+
:is(.mbe-root, .mbe-flow) > .mbe-details-end.mbe-block {
|
|
101
|
+
display: block;
|
|
102
|
+
height: 0;
|
|
103
|
+
margin: 0;
|
|
104
|
+
}
|
|
105
|
+
:is(.mbe-root, .mbe-flow) > [data-section-hidden] {
|
|
106
|
+
display: none !important;
|
|
107
|
+
}
|
|
46
108
|
:is(.mbe-root, .mbe-flow) > .mbe-list-item {
|
|
47
109
|
display: flex;
|
|
48
110
|
align-items: flex-start;
|
|
@@ -261,6 +323,9 @@
|
|
|
261
323
|
text-align: start;
|
|
262
324
|
outline: none;
|
|
263
325
|
}
|
|
326
|
+
:is(.mbe-root, .mbe-flow) > [data-in-section] {
|
|
327
|
+
margin-inline-start: calc(var(--mbe-section-depth, 0) * var(--mbe-indent-size));
|
|
328
|
+
}
|
|
264
329
|
:is(.mbe-root, .mbe-flow) > .mbe-block:first-child {
|
|
265
330
|
margin-top: 0;
|
|
266
331
|
}
|
|
@@ -273,7 +338,8 @@
|
|
|
273
338
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
274
339
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
275
340
|
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
276
|
-
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before
|
|
341
|
+
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
342
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
|
|
277
343
|
opacity: 0.5;
|
|
278
344
|
pointer-events: none;
|
|
279
345
|
position: absolute;
|
|
@@ -285,7 +351,8 @@
|
|
|
285
351
|
content: var(--mbe-slash-hint, "");
|
|
286
352
|
}
|
|
287
353
|
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
288
|
-
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before
|
|
354
|
+
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
355
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
|
|
289
356
|
content: attr(data-hint);
|
|
290
357
|
}
|
|
291
358
|
.mbe-root > .mbe-widget {
|
|
@@ -308,6 +375,7 @@
|
|
|
308
375
|
}
|
|
309
376
|
.mbe-menu,
|
|
310
377
|
.mbe-toolbar,
|
|
378
|
+
.mbe-link-card,
|
|
311
379
|
.mbe-input-popover {
|
|
312
380
|
position: fixed;
|
|
313
381
|
background: Canvas;
|
|
@@ -352,6 +420,10 @@
|
|
|
352
420
|
.mbe-suggestion-menu {
|
|
353
421
|
max-width: 360px;
|
|
354
422
|
}
|
|
423
|
+
.mbe-emoji-menu .mbe-menu-icon {
|
|
424
|
+
font-size: 18px;
|
|
425
|
+
line-height: 1;
|
|
426
|
+
}
|
|
355
427
|
.mbe-suggestion-menu .mbe-menu-label {
|
|
356
428
|
min-width: 0;
|
|
357
429
|
overflow: hidden;
|
|
@@ -462,6 +534,27 @@
|
|
|
462
534
|
gap: 4px;
|
|
463
535
|
padding: 4px;
|
|
464
536
|
}
|
|
537
|
+
.mbe-link-card {
|
|
538
|
+
box-sizing: border-box;
|
|
539
|
+
display: flex;
|
|
540
|
+
align-items: center;
|
|
541
|
+
gap: 2px;
|
|
542
|
+
padding: 4px;
|
|
543
|
+
max-width: min(420px, calc(100vw - 16px));
|
|
544
|
+
}
|
|
545
|
+
.mbe-link-card-url {
|
|
546
|
+
flex: 0 1 auto;
|
|
547
|
+
min-width: 0;
|
|
548
|
+
padding: 0 6px;
|
|
549
|
+
overflow: hidden;
|
|
550
|
+
text-overflow: ellipsis;
|
|
551
|
+
white-space: nowrap;
|
|
552
|
+
color: LinkText;
|
|
553
|
+
}
|
|
554
|
+
.mbe-tool:disabled {
|
|
555
|
+
opacity: 0.4;
|
|
556
|
+
cursor: default;
|
|
557
|
+
}
|
|
465
558
|
.mbe-image-frame {
|
|
466
559
|
position: fixed;
|
|
467
560
|
pointer-events: none;
|
|
@@ -571,6 +664,11 @@
|
|
|
571
664
|
0 2px 4px -2px light-dark(rgb(0 0 0 / 0.1), transparent);
|
|
572
665
|
--mbe-block-code-bg: color-mix(in oklab, var(--mbe-code-bg) 45%, transparent);
|
|
573
666
|
--mbe-quote-border: color-mix(in oklab, var(--mbe-muted) 25%, transparent);
|
|
667
|
+
--mbe-callout-note: light-dark(var(--mbe-callout-note-light, oklch(0.55 0.17 255)), var(--mbe-callout-note-dark, oklch(0.68 0.15 255)));
|
|
668
|
+
--mbe-callout-tip: light-dark(var(--mbe-callout-tip-light, oklch(0.52 0.13 150)), var(--mbe-callout-tip-dark, oklch(0.72 0.17 150)));
|
|
669
|
+
--mbe-callout-important: light-dark(var(--mbe-callout-important-light, oklch(0.52 0.2 295)), var(--mbe-callout-important-dark, oklch(0.7 0.15 295)));
|
|
670
|
+
--mbe-callout-warning: light-dark(var(--mbe-callout-warning-light, oklch(0.55 0.12 75)), var(--mbe-callout-warning-dark, oklch(0.74 0.14 80)));
|
|
671
|
+
--mbe-callout-caution: light-dark(var(--mbe-callout-caution-light, oklch(0.55 0.2 25)), var(--mbe-callout-caution-dark, oklch(0.68 0.19 25)));
|
|
574
672
|
}
|
|
575
673
|
:where([data-theme=light]) :is(.mbe-root, .mbe-ui),
|
|
576
674
|
.mbe-root[data-theme=light],
|
|
@@ -671,9 +769,43 @@
|
|
|
671
769
|
padding-inline-start: 12px;
|
|
672
770
|
color: var(--mbe-muted);
|
|
673
771
|
}
|
|
772
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout] {
|
|
773
|
+
color: inherit;
|
|
774
|
+
border-inline-start-color: var(--mbe-callout);
|
|
775
|
+
}
|
|
776
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=note] {
|
|
777
|
+
--mbe-callout: var(--mbe-callout-note);
|
|
778
|
+
}
|
|
779
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=tip] {
|
|
780
|
+
--mbe-callout: var(--mbe-callout-tip);
|
|
781
|
+
}
|
|
782
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=important] {
|
|
783
|
+
--mbe-callout: var(--mbe-callout-important);
|
|
784
|
+
}
|
|
785
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=warning] {
|
|
786
|
+
--mbe-callout: var(--mbe-callout-warning);
|
|
787
|
+
}
|
|
788
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=caution] {
|
|
789
|
+
--mbe-callout: var(--mbe-callout-caution);
|
|
790
|
+
}
|
|
791
|
+
.mbe-root .mbe-callout-title {
|
|
792
|
+
color: var(--mbe-callout);
|
|
793
|
+
font-weight: 500;
|
|
794
|
+
}
|
|
674
795
|
.mbe-root .mbe-marker {
|
|
675
796
|
color: var(--mbe-muted);
|
|
676
797
|
}
|
|
798
|
+
.mbe-root .mbe-details-toggle {
|
|
799
|
+
color: var(--mbe-muted);
|
|
800
|
+
border-radius: 4px;
|
|
801
|
+
}
|
|
802
|
+
.mbe-root .mbe-details-toggle:hover {
|
|
803
|
+
color: var(--mbe-text);
|
|
804
|
+
background: var(--mbe-hover);
|
|
805
|
+
}
|
|
806
|
+
:is(.mbe-root, .mbe-flow) > .mbe-details {
|
|
807
|
+
font-weight: 500;
|
|
808
|
+
}
|
|
677
809
|
.mbe-root .mbe-checkbox {
|
|
678
810
|
appearance: none;
|
|
679
811
|
-webkit-appearance: none;
|
|
@@ -841,7 +973,8 @@
|
|
|
841
973
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
842
974
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
843
975
|
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
844
|
-
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before
|
|
976
|
+
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
977
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
|
|
845
978
|
color: var(--mbe-muted);
|
|
846
979
|
opacity: 0.7;
|
|
847
980
|
}
|
|
@@ -853,6 +986,7 @@
|
|
|
853
986
|
}
|
|
854
987
|
.mbe-menu,
|
|
855
988
|
.mbe-toolbar,
|
|
989
|
+
.mbe-link-card,
|
|
856
990
|
.mbe-input-popover {
|
|
857
991
|
color: var(--mbe-text);
|
|
858
992
|
background: var(--mbe-popup-bg);
|
|
@@ -894,9 +1028,18 @@
|
|
|
894
1028
|
font-size: 12px;
|
|
895
1029
|
color: var(--mbe-muted);
|
|
896
1030
|
}
|
|
897
|
-
.mbe-toolbar
|
|
1031
|
+
.mbe-toolbar,
|
|
1032
|
+
.mbe-link-card {
|
|
898
1033
|
border-radius: calc(var(--mbe-radius) + 2px);
|
|
899
1034
|
}
|
|
1035
|
+
.mbe-link-card-url {
|
|
1036
|
+
font-size: 13px;
|
|
1037
|
+
color: var(--mbe-link);
|
|
1038
|
+
text-decoration: none;
|
|
1039
|
+
}
|
|
1040
|
+
.mbe-link-card-url:hover {
|
|
1041
|
+
text-decoration: underline;
|
|
1042
|
+
}
|
|
900
1043
|
.mbe-tool {
|
|
901
1044
|
border-radius: 7px;
|
|
902
1045
|
}
|
package/dist/theme.css
CHANGED
|
@@ -41,6 +41,12 @@
|
|
|
41
41
|
0 2px 4px -2px light-dark(rgb(0 0 0 / 0.1), transparent);
|
|
42
42
|
--mbe-block-code-bg: color-mix(in oklab, var(--mbe-code-bg) 45%, transparent);
|
|
43
43
|
--mbe-quote-border: color-mix(in oklab, var(--mbe-muted) 25%, transparent);
|
|
44
|
+
/* Callout colors, close to GitHub's alerts. */
|
|
45
|
+
--mbe-callout-note: light-dark(var(--mbe-callout-note-light, oklch(0.55 0.17 255)), var(--mbe-callout-note-dark, oklch(0.68 0.15 255)));
|
|
46
|
+
--mbe-callout-tip: light-dark(var(--mbe-callout-tip-light, oklch(0.52 0.13 150)), var(--mbe-callout-tip-dark, oklch(0.72 0.17 150)));
|
|
47
|
+
--mbe-callout-important: light-dark(var(--mbe-callout-important-light, oklch(0.52 0.2 295)), var(--mbe-callout-important-dark, oklch(0.7 0.15 295)));
|
|
48
|
+
--mbe-callout-warning: light-dark(var(--mbe-callout-warning-light, oklch(0.55 0.12 75)), var(--mbe-callout-warning-dark, oklch(0.74 0.14 80)));
|
|
49
|
+
--mbe-callout-caution: light-dark(var(--mbe-callout-caution-light, oklch(0.55 0.2 25)), var(--mbe-callout-caution-dark, oklch(0.68 0.19 25)));
|
|
44
50
|
}
|
|
45
51
|
:where([data-theme='light']) :is(.mbe-root, .mbe-ui),
|
|
46
52
|
.mbe-root[data-theme='light'],
|
|
@@ -114,8 +120,21 @@
|
|
|
114
120
|
color: var(--mbe-muted);
|
|
115
121
|
}
|
|
116
122
|
|
|
123
|
+
/* Callouts: the type's color on the border and the title; the text keeps the body color. */
|
|
124
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout] { color: inherit; border-inline-start-color: var(--mbe-callout); }
|
|
125
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='note'] { --mbe-callout: var(--mbe-callout-note); }
|
|
126
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='tip'] { --mbe-callout: var(--mbe-callout-tip); }
|
|
127
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='important'] { --mbe-callout: var(--mbe-callout-important); }
|
|
128
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='warning'] { --mbe-callout: var(--mbe-callout-warning); }
|
|
129
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='caution'] { --mbe-callout: var(--mbe-callout-caution); }
|
|
130
|
+
.mbe-root .mbe-callout-title { color: var(--mbe-callout); font-weight: 500; }
|
|
131
|
+
|
|
117
132
|
/* Lists */
|
|
118
133
|
.mbe-root .mbe-marker { color: var(--mbe-muted); }
|
|
134
|
+
/* Collapsible sections: a muted toggle and a medium-weight title. */
|
|
135
|
+
.mbe-root .mbe-details-toggle { color: var(--mbe-muted); border-radius: 4px; }
|
|
136
|
+
.mbe-root .mbe-details-toggle:hover { color: var(--mbe-text); background: var(--mbe-hover); }
|
|
137
|
+
:is(.mbe-root, .mbe-flow) > .mbe-details { font-weight: 500; }
|
|
119
138
|
/* appearance: none, so a disabled checkbox in read-only is not greyed out. */
|
|
120
139
|
.mbe-root .mbe-checkbox {
|
|
121
140
|
appearance: none;
|
|
@@ -212,7 +231,8 @@
|
|
|
212
231
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
213
232
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
214
233
|
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
215
|
-
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before
|
|
234
|
+
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
235
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
|
|
216
236
|
color: var(--mbe-muted);
|
|
217
237
|
opacity: 0.7;
|
|
218
238
|
}
|
|
@@ -227,6 +247,7 @@
|
|
|
227
247
|
}
|
|
228
248
|
.mbe-menu,
|
|
229
249
|
.mbe-toolbar,
|
|
250
|
+
.mbe-link-card,
|
|
230
251
|
.mbe-input-popover {
|
|
231
252
|
color: var(--mbe-text);
|
|
232
253
|
background: var(--mbe-popup-bg);
|
|
@@ -244,7 +265,10 @@
|
|
|
244
265
|
.mbe-menu-loading { color: var(--mbe-muted); }
|
|
245
266
|
.mbe-menu-detail { font-size: 12px; color: var(--mbe-muted); }
|
|
246
267
|
|
|
247
|
-
.mbe-toolbar
|
|
268
|
+
.mbe-toolbar,
|
|
269
|
+
.mbe-link-card { border-radius: calc(var(--mbe-radius) + 2px); }
|
|
270
|
+
.mbe-link-card-url { font-size: 13px; color: var(--mbe-link); text-decoration: none; }
|
|
271
|
+
.mbe-link-card-url:hover { text-decoration: underline; }
|
|
248
272
|
.mbe-tool { border-radius: 7px; }
|
|
249
273
|
.mbe-tool:hover,
|
|
250
274
|
.mbe-tool.mbe-open { background: var(--mbe-hover); }
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Block, type EditorState, type HeadingLevel, type ImageAlign, type ImageAtom, type ListType, type Mark, type Position, type Selection, type TableBlock, type RawBlock, type TextBlock, type Align } from './model.js';
|
|
1
|
+
import { type Block, type CalloutType, type EditorState, type HeadingLevel, type ImageAlign, type ImageAtom, type ListType, type Mark, type Position, type Selection, type TableBlock, type RawBlock, type TextBlock, type Align } from './model.js';
|
|
2
2
|
import type { InlineSyntax } from './markdown/options.js';
|
|
3
3
|
export type Command = (state: EditorState) => EditorState;
|
|
4
4
|
/** A copy of a block with a new ID. */
|
|
@@ -23,10 +23,30 @@ export declare function insertText(state: EditorState, text: string): EditorStat
|
|
|
23
23
|
* text; a wrapped line counts as one.
|
|
24
24
|
*/
|
|
25
25
|
export declare function exitBlock(state: EditorState, dir: 1 | -1): EditorState;
|
|
26
|
+
/** Adds an empty paragraph at the end of the document, with the caret in it. */
|
|
27
|
+
export declare function appendParagraph(state: EditorState): EditorState;
|
|
26
28
|
/** Shift+Enter: a hard line break. A newline in code; nothing in a table cell. */
|
|
27
29
|
export declare function insertLineBreak(state: EditorState): EditorState;
|
|
28
30
|
/** Enter. */
|
|
29
31
|
export declare function splitBlock(state: EditorState): EditorState;
|
|
32
|
+
/** Enter in the title of a collapsed section: the new line goes after the section. */
|
|
33
|
+
export declare function splitCollapsedTitle(state: EditorState): EditorState;
|
|
34
|
+
/** The index of the `detailsEnd` that closes the section titled at `index`, or null. */
|
|
35
|
+
export declare function sectionEnd(blocks: readonly Block[], index: number): number | null;
|
|
36
|
+
/** The index of the title of the section that the `detailsEnd` at `index` closes, or null. */
|
|
37
|
+
export declare function sectionTitle(blocks: readonly Block[], index: number): number | null;
|
|
38
|
+
/**
|
|
39
|
+
* Blocks with every collapsible section whole: an end with no open section
|
|
40
|
+
* is dropped, and a title whose end is missing becomes a paragraph. Returns
|
|
41
|
+
* `blocks` itself when they already are.
|
|
42
|
+
*/
|
|
43
|
+
export declare function closeSections(blocks: readonly Block[]): readonly Block[];
|
|
44
|
+
/**
|
|
45
|
+
* Keeps collapsible sections whole after an edit (see `closeSections`), so
|
|
46
|
+
* removing a title or an end unwraps its section. A caret on an end moves to
|
|
47
|
+
* the end of the text before it.
|
|
48
|
+
*/
|
|
49
|
+
export declare function balanceSections(state: EditorState): EditorState;
|
|
30
50
|
/** True if every character of the selection carries the mark (or, collapsed, the next typed text will). */
|
|
31
51
|
export declare function isMarkActive(state: EditorState, mark: Mark): boolean;
|
|
32
52
|
export declare function toggleMark(state: EditorState, mark: Mark): EditorState;
|
|
@@ -75,8 +95,11 @@ export type BlockTypeSpec = {
|
|
|
75
95
|
} | {
|
|
76
96
|
type: 'listItem';
|
|
77
97
|
listType: ListType;
|
|
78
|
-
}
|
|
98
|
+
}
|
|
99
|
+
/** A quote, or with `callout` a callout of that type. */
|
|
100
|
+
| {
|
|
79
101
|
type: 'quote';
|
|
102
|
+
callout?: CalloutType;
|
|
80
103
|
} | {
|
|
81
104
|
type: 'code';
|
|
82
105
|
language?: string;
|
|
@@ -86,6 +109,10 @@ export type BlockTypeSpec = {
|
|
|
86
109
|
cols?: number;
|
|
87
110
|
} | {
|
|
88
111
|
type: 'divider';
|
|
112
|
+
}
|
|
113
|
+
/** A collapsible section: the block becomes its title, and an empty line its body. */
|
|
114
|
+
| {
|
|
115
|
+
type: 'details';
|
|
89
116
|
};
|
|
90
117
|
/**
|
|
91
118
|
* Changes the type of every text block touched by the selection. Text and IDs
|
|
@@ -93,6 +120,16 @@ export type BlockTypeSpec = {
|
|
|
93
120
|
* is the exception: adjacent blocks become one code block, a line per block.
|
|
94
121
|
*/
|
|
95
122
|
export declare function setBlockType(state: EditorState, spec: BlockTypeSpec): EditorState;
|
|
123
|
+
/**
|
|
124
|
+
* The quote blocks that form one blockquote with the quote `blockId`: its
|
|
125
|
+
* neighbours with the same callout. Null when the block is not a quote.
|
|
126
|
+
*/
|
|
127
|
+
export declare function quoteRun(state: EditorState, blockId: string): {
|
|
128
|
+
start: number;
|
|
129
|
+
end: number;
|
|
130
|
+
} | null;
|
|
131
|
+
/** Sets the callout of the whole blockquote with the quote `blockId`; null makes it a plain quote. */
|
|
132
|
+
export declare function setCallout(state: EditorState, blockId: string, callout: CalloutType | null): EditorState;
|
|
96
133
|
/** The blocks the selection touches whose type the block type commands change. */
|
|
97
134
|
export declare function convertibleBlocks(state: EditorState): Exclude<TextBlock, RawBlock>[];
|
|
98
135
|
/**
|
|
@@ -153,7 +190,15 @@ export type TableAction = {
|
|
|
153
190
|
export declare function tableAction(state: EditorState, action: TableAction): EditorState;
|
|
154
191
|
/** Tab / Shift+Tab in a table: next or previous cell. Tab in the last cell adds a row. */
|
|
155
192
|
export declare function moveCell(state: EditorState, delta: 1 | -1): EditorState;
|
|
156
|
-
|
|
193
|
+
/**
|
|
194
|
+
* Turns a paragraph into another block type when the text before the caret
|
|
195
|
+
* is a Markdown marker such as "# " or "- ". `dialect` turns off the markers
|
|
196
|
+
* for callouts and collapsible sections, as the Markdown options do.
|
|
197
|
+
*/
|
|
198
|
+
export declare function applyBlockInputRules(state: EditorState, dialect?: {
|
|
199
|
+
callouts?: boolean;
|
|
200
|
+
details?: boolean;
|
|
201
|
+
}): EditorState | null;
|
|
157
202
|
/**
|
|
158
203
|
* Inline shortcuts: typing the closing delimiter of `**x**`, `*x*`, `_x_`,
|
|
159
204
|
* `` `x` `` or `~~x~~` applies the mark and removes the delimiters.
|
package/dist/types/editor.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { type MarkdownOptions } from './markdown/options.js';
|
|
|
6
6
|
import type { Extension } from './extension.js';
|
|
7
7
|
import { type SuggestionState } from './suggest/controller.js';
|
|
8
8
|
import { type Widget, type WidgetRender } from './widgets.js';
|
|
9
|
-
import { type Block, type EditorState, type HeadingLevel, type Position, type Selection } from './model.js';
|
|
9
|
+
import { type Block, type CalloutType, type EditorState, type HeadingLevel, type Position, type Selection } from './model.js';
|
|
10
10
|
import { type ToolbarItem } from './ui/toolbar.js';
|
|
11
11
|
import { type ResolveUrl } from './view/dom.js';
|
|
12
12
|
import { type Theme } from './theme.js';
|
|
@@ -73,6 +73,12 @@ export interface EditorOptions {
|
|
|
73
73
|
toolbar?: boolean | {
|
|
74
74
|
items?: readonly ToolbarItem[];
|
|
75
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Shows the link card while editing: the link's URL and buttons to open,
|
|
78
|
+
* copy, edit and remove it, when the pointer rests on a link or the caret
|
|
79
|
+
* is inside one. Default true.
|
|
80
|
+
*/
|
|
81
|
+
linkCard?: boolean;
|
|
76
82
|
/**
|
|
77
83
|
* The element menus, the toolbar and other popups are appended to.
|
|
78
84
|
* Default: the nearest open `<dialog>` or `aria-modal` ancestor of
|
|
@@ -141,6 +147,8 @@ export interface SuggestionApi {
|
|
|
141
147
|
}
|
|
142
148
|
/** Names `isActive` and `getAttributes` understand. */
|
|
143
149
|
export type ActiveName = 'bold' | 'italic' | 'strike' | 'code' | 'link' | 'paragraph' | 'heading' | 'bulletList' | 'orderedList' | 'taskList' | 'blockquote' | 'codeBlock' | 'table' | 'divider' | 'raw'
|
|
150
|
+
/** The title of a collapsible section. */
|
|
151
|
+
| 'details'
|
|
144
152
|
/** The selection is exactly one image. */
|
|
145
153
|
| 'image';
|
|
146
154
|
/** A position that survives reloading the same Markdown: a block index and an offset. */
|
|
@@ -180,6 +188,16 @@ export interface EditorCommands {
|
|
|
180
188
|
toggleOrderedList(): boolean;
|
|
181
189
|
toggleTaskList(): boolean;
|
|
182
190
|
toggleBlockquote(): boolean;
|
|
191
|
+
/** Turns the selected blocks into a callout of `type` (default `note`), or back into paragraphs when they are one already. */
|
|
192
|
+
toggleCallout(attrs?: {
|
|
193
|
+
type?: CalloutType;
|
|
194
|
+
}): boolean;
|
|
195
|
+
/** Changes the type of the callout with the caret, or turns the quote with the caret into a callout; `null` makes it a plain quote. */
|
|
196
|
+
setCallout(attrs: {
|
|
197
|
+
type: CalloutType | null;
|
|
198
|
+
}): boolean;
|
|
199
|
+
/** Turns the block with the caret into the title of a collapsible section with an empty body, or, on a title, removes the section and keeps its blocks. */
|
|
200
|
+
toggleDetails(): boolean;
|
|
183
201
|
toggleCodeBlock(attrs?: {
|
|
184
202
|
language?: string;
|
|
185
203
|
}): boolean;
|
|
@@ -218,7 +236,7 @@ export interface EditorCommands {
|
|
|
218
236
|
/** Scrolls the caret (the selection's focus end) into view, in scrolling containers and the window. */
|
|
219
237
|
scrollIntoView(): boolean;
|
|
220
238
|
}
|
|
221
|
-
export declare const SLASH_ITEM_IDS: readonly ["text", "heading1", "heading2", "heading3", "bulletList", "numberedList", "todoList", "quote", "code", "table", "divider"];
|
|
239
|
+
export declare const SLASH_ITEM_IDS: readonly ["text", "heading1", "heading2", "heading3", "heading4", "bulletList", "numberedList", "todoList", "quote", "callout", "details", "code", "table", "divider"];
|
|
222
240
|
export type SlashItemId = (typeof SLASH_ITEM_IDS)[number];
|
|
223
241
|
export declare class Editor {
|
|
224
242
|
/** The editable element the editor renders into: `options.element`, or for `useEditor`, the element `<EditorContent>` mounts. */
|
|
@@ -289,6 +307,9 @@ export declare class Editor {
|
|
|
289
307
|
/** The link popover, and the field for an image's alt text. */
|
|
290
308
|
private readonly inputPopover;
|
|
291
309
|
private readonly blockHandle;
|
|
310
|
+
/** Collapsible sections shown collapsed, by the ID of their title. View state: not saved, not undone. */
|
|
311
|
+
private readonly collapsed;
|
|
312
|
+
private readonly linkCard;
|
|
292
313
|
private readonly resizeHandles;
|
|
293
314
|
/** The selected image's element, which carries the selected class. */
|
|
294
315
|
private selectedImageEl;
|
|
@@ -329,7 +350,7 @@ export declare class Editor {
|
|
|
329
350
|
get isDestroyed(): boolean;
|
|
330
351
|
/** True if `name` applies at the selection: a mark on the selected text, or the type of the block with the caret. */
|
|
331
352
|
isActive(name: ActiveName, attrs?: Readonly<Record<string, unknown>>): boolean;
|
|
332
|
-
/** Attributes of `name` at the selection: `src`, `alt`, `title`, `align`, `width`, `height` and `block` (true for an image block) for a selected image, `href` for a link, `level` for a heading, `language` for a code block, `checked` for a task, `syntax` for a raw block. */
|
|
353
|
+
/** Attributes of `name` at the selection: `src`, `alt`, `title`, `align`, `width`, `height` and `block` (true for an image block) for a selected image, `href` for a link, `level` for a heading, `language` for a code block, `checked` for a task, `syntax` for a raw block, `callout` for a callout, `open` (saved as `<details open>`) and `collapsed` (shown collapsed now) for a section title. */
|
|
333
354
|
getAttributes(name: ActiveName): Record<string, unknown>;
|
|
334
355
|
getSelection(): Selection;
|
|
335
356
|
/**
|
|
@@ -546,6 +567,8 @@ export declare class Editor {
|
|
|
546
567
|
*/
|
|
547
568
|
private clickBelowLastBlock;
|
|
548
569
|
private onClick;
|
|
570
|
+
/** Opens a resolved link URL, as a click on a link does: through `onLinkClick`, else in a new tab. */
|
|
571
|
+
private openHref;
|
|
549
572
|
/** Copies the code of the code block holding `button`, and shows that it did for a moment. */
|
|
550
573
|
private copyCode;
|
|
551
574
|
/** The code block language input. */
|
|
@@ -567,6 +590,10 @@ export declare class Editor {
|
|
|
567
590
|
/** The blocks of the block selection, in document order. Empty when the selection is text. */
|
|
568
591
|
get selectedBlocks(): readonly Block[];
|
|
569
592
|
private blockRange;
|
|
593
|
+
/** `range` grown so that a collapsible section with its title or its end in it is in it whole. */
|
|
594
|
+
private wholeSections;
|
|
595
|
+
/** The next block a block selection moves to from `index`: blocks shown on screen, not section ends. */
|
|
596
|
+
private nextSelectable;
|
|
570
597
|
/** Selects whole blocks, from the block `anchor` to the block `head`. */
|
|
571
598
|
private selectBlockRange;
|
|
572
599
|
/** Leaves block selection, keeping the hidden caret as a collapsed selection. */
|
|
@@ -588,6 +615,8 @@ export declare class Editor {
|
|
|
588
615
|
private blockMenuSections;
|
|
589
616
|
/** The Align row of the block menu: a submenu of Left, Center and Right with the current one checked. */
|
|
590
617
|
private alignMenuItem;
|
|
618
|
+
/** True if the blocks `a` and `b` are in the same callout. */
|
|
619
|
+
private inSameCallout;
|
|
591
620
|
private closeBlockMenu;
|
|
592
621
|
/**
|
|
593
622
|
* A press anywhere but the block menu or the block handle closes the block menu,
|
|
@@ -595,6 +624,33 @@ export declare class Editor {
|
|
|
595
624
|
*/
|
|
596
625
|
private onDocumentPointerDown;
|
|
597
626
|
private updateUi;
|
|
627
|
+
/**
|
|
628
|
+
* Collapses or expands the collapsible section titled by the block
|
|
629
|
+
* `blockId`. This changes the view only: the Markdown, history and events
|
|
630
|
+
* stay as they are. A caret inside a section that collapses moves to the
|
|
631
|
+
* end of its title. Returns false when the block is not a section title.
|
|
632
|
+
*/
|
|
633
|
+
setSectionCollapsed(blockId: string, collapsed: boolean): boolean;
|
|
634
|
+
/** True when the section titled by `blockId` is shown collapsed. */
|
|
635
|
+
isSectionCollapsed(blockId: string): boolean;
|
|
636
|
+
/** Sections that are not saved open start collapsed, as a Markdown renderer shows them. */
|
|
637
|
+
private collapseClosedSections;
|
|
638
|
+
/** Expands the collapsed sections around the selection's focus, so the caret is never hidden. */
|
|
639
|
+
private expandAroundSelection;
|
|
640
|
+
/** Blocks the caret passes over: dividers, section ends, and blocks inside a collapsed section. */
|
|
641
|
+
private skipsCaret;
|
|
642
|
+
/** The link the caret is inside, not at its edge, with its element. */
|
|
643
|
+
private caretLink;
|
|
644
|
+
/** The document position where a rendered link starts. */
|
|
645
|
+
private linkStart;
|
|
646
|
+
/** The link a rendered link element shows, or null for one outside the document's blocks. */
|
|
647
|
+
private linkTargetOf;
|
|
648
|
+
/** The selection of a link's whole text, from a rendered link element. */
|
|
649
|
+
private linkSelection;
|
|
650
|
+
/** Opens the link popover for a link, as Mod+K does with the caret in it. */
|
|
651
|
+
private editLink;
|
|
652
|
+
/** Removes a link and keeps its text, as one undo step. */
|
|
653
|
+
private removeLink;
|
|
598
654
|
/** Marks the selected image's element, and hides the browser's selection highlight over it. */
|
|
599
655
|
private paintSelectedImage;
|
|
600
656
|
/** The selected image of `state` and its element, or null. */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EMOJI_DATA: string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Extension } from '@usememos/editor';
|
|
2
|
+
import { type Emoji } from './search.js';
|
|
3
|
+
export { type Emoji, parseEmoji, searchEmoji } from './search.js';
|
|
4
|
+
export interface EmojiOptions {
|
|
5
|
+
/** The suggestion's name, for `editor.suggestion.open(name)`. Default `emoji`. */
|
|
6
|
+
readonly name?: string;
|
|
7
|
+
/** Most emoji shown. Default 8. */
|
|
8
|
+
readonly limit?: number;
|
|
9
|
+
/** Characters typed after `:` before the popup opens, so `:)` and `a :b` stay quiet. Default 2. Ctrl+Space opens it sooner. */
|
|
10
|
+
readonly minLength?: number;
|
|
11
|
+
/** Accessible name of the popup. Default `Emoji`. */
|
|
12
|
+
readonly label?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Every emoji the extension offers, loaded once on first use. */
|
|
15
|
+
export declare function loadEmoji(): Promise<readonly Emoji[]>;
|
|
16
|
+
/**
|
|
17
|
+
* Emoji autocomplete: typing `:` and two letters at the start of a word lists
|
|
18
|
+
* emoji by GitHub's names and tags (`:tada`, `:party`). A pick replaces the
|
|
19
|
+
* typed name with the emoji, so the Markdown holds the character itself.
|
|
20
|
+
*/
|
|
21
|
+
export declare function emoji(options?: EmojiOptions): Extension;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface Emoji {
|
|
2
|
+
/** The character, such as "🎉". */
|
|
3
|
+
readonly emoji: string;
|
|
4
|
+
/** Its names, the first the main one, such as ["tada"]. Typed as `:tada:` on GitHub. */
|
|
5
|
+
readonly names: readonly string[];
|
|
6
|
+
/** Other words it is found by, such as ["party"]. */
|
|
7
|
+
readonly tags: readonly string[];
|
|
8
|
+
}
|
|
9
|
+
/** Reads the lines of `data.ts`: the emoji, its names and its tags, separated by tabs. */
|
|
10
|
+
export declare function parseEmoji(data: string): Emoji[];
|
|
11
|
+
/**
|
|
12
|
+
* Emoji whose names or tags match `query`, best first: a name equal to it,
|
|
13
|
+
* a name starting with it, a word of a name starting with it ("smile" finds
|
|
14
|
+
* "sweat_smile"), a tag starting with it, then a name containing it. Within
|
|
15
|
+
* a rank the data's order is kept, which puts common emoji first.
|
|
16
|
+
*/
|
|
17
|
+
export declare function searchEmoji(emoji: readonly Emoji[], query: string, limit?: number): Emoji[];
|