@usememos/editor 26.10.13 → 26.10.15
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 +59 -14
- package/dist/base.css +101 -13
- 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 +1144 -148
- package/dist/index.js.map +4 -4
- package/dist/react.js.map +2 -2
- package/dist/style.css +215 -13
- package/dist/theme.css +37 -3
- 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/lower.d.ts +11 -1
- package/dist/types/markdown/options.d.ts +14 -0
- package/dist/types/markdown/serialize.d.ts +8 -0
- package/dist/types/model.d.ts +62 -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 +14 -2
- package/dist/types/view/reveal.d.ts +1 -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 WeakM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W,WAAsB,OAAc;AAClE;AAGA,IAAM,mBAAmB,oBAAI,QAAiC;AAE9D,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
|
@@ -39,10 +39,103 @@
|
|
|
39
39
|
margin-top: 16px;
|
|
40
40
|
margin-bottom: 4px;
|
|
41
41
|
}
|
|
42
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-quote-continued] {
|
|
43
|
+
margin-bottom: 0;
|
|
44
|
+
}
|
|
42
45
|
:is(.mbe-root, .mbe-flow) > blockquote[data-quote-joined] {
|
|
43
|
-
margin-top:
|
|
46
|
+
margin-top: 0;
|
|
47
|
+
padding-top: var(--mbe-block-gap);
|
|
48
|
+
}
|
|
49
|
+
:is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-quote-joined] {
|
|
50
|
+
margin-top: 0;
|
|
51
|
+
}
|
|
52
|
+
:is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-quote-joined]:not([data-list-start]) {
|
|
53
|
+
padding-top: 2px;
|
|
54
|
+
}
|
|
55
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout] {
|
|
56
|
+
--mbe-callout-pad: 12px;
|
|
57
|
+
position: relative;
|
|
58
|
+
padding-block: var(--mbe-callout-pad);
|
|
59
|
+
padding-inline: calc(var(--mbe-callout-pad) + 28px) 16px;
|
|
60
|
+
}
|
|
61
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-joined] {
|
|
44
62
|
padding-top: var(--mbe-block-gap);
|
|
45
63
|
}
|
|
64
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-continued] {
|
|
65
|
+
padding-bottom: 0;
|
|
66
|
+
}
|
|
67
|
+
.mbe-root .mbe-callout-icon {
|
|
68
|
+
position: absolute;
|
|
69
|
+
top: var(--mbe-callout-pad);
|
|
70
|
+
inset-inline-start: calc(var(--mbe-callout-pad) - 2px);
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
width: 24px;
|
|
75
|
+
height: 1.5em;
|
|
76
|
+
height: 1lh;
|
|
77
|
+
user-select: none;
|
|
78
|
+
-webkit-user-select: none;
|
|
79
|
+
}
|
|
80
|
+
.mbe-root .mbe-callout-icon > .mbe-icon {
|
|
81
|
+
width: 18px;
|
|
82
|
+
height: 18px;
|
|
83
|
+
}
|
|
84
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-quote-joined] > .mbe-callout-icon {
|
|
85
|
+
display: none;
|
|
86
|
+
}
|
|
87
|
+
.mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-icon {
|
|
88
|
+
cursor: pointer;
|
|
89
|
+
}
|
|
90
|
+
:is(.mbe-root, .mbe-flow) > .mbe-details {
|
|
91
|
+
display: flex;
|
|
92
|
+
align-items: flex-start;
|
|
93
|
+
}
|
|
94
|
+
.mbe-root .mbe-details > .mbe-content {
|
|
95
|
+
flex: 1;
|
|
96
|
+
min-width: 0;
|
|
97
|
+
position: relative;
|
|
98
|
+
}
|
|
99
|
+
.mbe-root .mbe-details-marker {
|
|
100
|
+
flex: none;
|
|
101
|
+
display: flex;
|
|
102
|
+
align-items: center;
|
|
103
|
+
justify-content: center;
|
|
104
|
+
width: var(--mbe-indent-size);
|
|
105
|
+
height: 1.5em;
|
|
106
|
+
height: 1lh;
|
|
107
|
+
user-select: none;
|
|
108
|
+
-webkit-user-select: none;
|
|
109
|
+
}
|
|
110
|
+
.mbe-root .mbe-details-toggle {
|
|
111
|
+
display: inline-flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
justify-content: center;
|
|
114
|
+
border: 0;
|
|
115
|
+
background: none;
|
|
116
|
+
padding: 2px;
|
|
117
|
+
font: inherit;
|
|
118
|
+
color: inherit;
|
|
119
|
+
cursor: pointer;
|
|
120
|
+
}
|
|
121
|
+
.mbe-root .mbe-details-toggle > .mbe-icon {
|
|
122
|
+
transition: transform 0.12s ease;
|
|
123
|
+
transform: rotate(90deg);
|
|
124
|
+
}
|
|
125
|
+
.mbe-root .mbe-details[data-collapsed] .mbe-details-toggle > .mbe-icon {
|
|
126
|
+
transform: none;
|
|
127
|
+
}
|
|
128
|
+
.mbe-root .mbe-details[data-collapsed]:dir(rtl) .mbe-details-toggle > .mbe-icon {
|
|
129
|
+
transform: scaleX(-1);
|
|
130
|
+
}
|
|
131
|
+
:is(.mbe-root, .mbe-flow) > .mbe-details-end.mbe-block {
|
|
132
|
+
display: block;
|
|
133
|
+
height: 0;
|
|
134
|
+
margin: 0;
|
|
135
|
+
}
|
|
136
|
+
:is(.mbe-root, .mbe-flow) > [data-section-hidden] {
|
|
137
|
+
display: none !important;
|
|
138
|
+
}
|
|
46
139
|
:is(.mbe-root, .mbe-flow) > .mbe-list-item {
|
|
47
140
|
display: flex;
|
|
48
141
|
align-items: flex-start;
|
|
@@ -51,21 +144,36 @@
|
|
|
51
144
|
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-list-start] {
|
|
52
145
|
margin-top: var(--mbe-block-gap);
|
|
53
146
|
}
|
|
54
|
-
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="1"] {
|
|
147
|
+
:is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="1"] {
|
|
55
148
|
padding-inline-start: var(--mbe-indent-size);
|
|
56
149
|
}
|
|
57
|
-
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="2"] {
|
|
150
|
+
:is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="2"] {
|
|
58
151
|
padding-inline-start: calc(2 * var(--mbe-indent-size));
|
|
59
152
|
}
|
|
60
|
-
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="3"] {
|
|
153
|
+
:is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="3"] {
|
|
61
154
|
padding-inline-start: calc(3 * var(--mbe-indent-size));
|
|
62
155
|
}
|
|
63
|
-
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="4"] {
|
|
156
|
+
:is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="4"] {
|
|
64
157
|
padding-inline-start: calc(4 * var(--mbe-indent-size));
|
|
65
158
|
}
|
|
66
|
-
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="5"] {
|
|
159
|
+
:is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="5"] {
|
|
67
160
|
padding-inline-start: calc(5 * var(--mbe-indent-size));
|
|
68
161
|
}
|
|
162
|
+
:is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-indent="1"] > .mbe-marker {
|
|
163
|
+
margin-inline-start: var(--mbe-indent-size);
|
|
164
|
+
}
|
|
165
|
+
:is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-indent="2"] > .mbe-marker {
|
|
166
|
+
margin-inline-start: calc(2 * var(--mbe-indent-size));
|
|
167
|
+
}
|
|
168
|
+
:is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-indent="3"] > .mbe-marker {
|
|
169
|
+
margin-inline-start: calc(3 * var(--mbe-indent-size));
|
|
170
|
+
}
|
|
171
|
+
:is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-indent="4"] > .mbe-marker {
|
|
172
|
+
margin-inline-start: calc(4 * var(--mbe-indent-size));
|
|
173
|
+
}
|
|
174
|
+
:is(.mbe-root, .mbe-flow) > blockquote.mbe-list-item[data-indent="5"] > .mbe-marker {
|
|
175
|
+
margin-inline-start: calc(5 * var(--mbe-indent-size));
|
|
176
|
+
}
|
|
69
177
|
.mbe-root .mbe-marker {
|
|
70
178
|
flex: none;
|
|
71
179
|
box-sizing: border-box;
|
|
@@ -261,6 +369,9 @@
|
|
|
261
369
|
text-align: start;
|
|
262
370
|
outline: none;
|
|
263
371
|
}
|
|
372
|
+
:is(.mbe-root, .mbe-flow) > [data-in-section] {
|
|
373
|
+
margin-inline-start: calc(var(--mbe-section-depth, 0) * var(--mbe-indent-size));
|
|
374
|
+
}
|
|
264
375
|
:is(.mbe-root, .mbe-flow) > .mbe-block:first-child {
|
|
265
376
|
margin-top: 0;
|
|
266
377
|
}
|
|
@@ -272,8 +383,9 @@
|
|
|
272
383
|
}
|
|
273
384
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
274
385
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
275
|
-
.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
|
|
386
|
+
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
|
|
387
|
+
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
388
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
|
|
277
389
|
opacity: 0.5;
|
|
278
390
|
pointer-events: none;
|
|
279
391
|
position: absolute;
|
|
@@ -284,8 +396,9 @@
|
|
|
284
396
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before {
|
|
285
397
|
content: var(--mbe-slash-hint, "");
|
|
286
398
|
}
|
|
287
|
-
.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
|
|
399
|
+
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
|
|
400
|
+
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
401
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
|
|
289
402
|
content: attr(data-hint);
|
|
290
403
|
}
|
|
291
404
|
.mbe-root > .mbe-widget {
|
|
@@ -308,6 +421,7 @@
|
|
|
308
421
|
}
|
|
309
422
|
.mbe-menu,
|
|
310
423
|
.mbe-toolbar,
|
|
424
|
+
.mbe-link-card,
|
|
311
425
|
.mbe-input-popover {
|
|
312
426
|
position: fixed;
|
|
313
427
|
background: Canvas;
|
|
@@ -352,6 +466,10 @@
|
|
|
352
466
|
.mbe-suggestion-menu {
|
|
353
467
|
max-width: 360px;
|
|
354
468
|
}
|
|
469
|
+
.mbe-emoji-menu .mbe-menu-icon {
|
|
470
|
+
font-size: 18px;
|
|
471
|
+
line-height: 1;
|
|
472
|
+
}
|
|
355
473
|
.mbe-suggestion-menu .mbe-menu-label {
|
|
356
474
|
min-width: 0;
|
|
357
475
|
overflow: hidden;
|
|
@@ -462,6 +580,27 @@
|
|
|
462
580
|
gap: 4px;
|
|
463
581
|
padding: 4px;
|
|
464
582
|
}
|
|
583
|
+
.mbe-link-card {
|
|
584
|
+
box-sizing: border-box;
|
|
585
|
+
display: flex;
|
|
586
|
+
align-items: center;
|
|
587
|
+
gap: 2px;
|
|
588
|
+
padding: 4px;
|
|
589
|
+
max-width: min(420px, calc(100vw - 16px));
|
|
590
|
+
}
|
|
591
|
+
.mbe-link-card-url {
|
|
592
|
+
flex: 0 1 auto;
|
|
593
|
+
min-width: 0;
|
|
594
|
+
padding: 0 6px;
|
|
595
|
+
overflow: hidden;
|
|
596
|
+
text-overflow: ellipsis;
|
|
597
|
+
white-space: nowrap;
|
|
598
|
+
color: LinkText;
|
|
599
|
+
}
|
|
600
|
+
.mbe-tool:disabled {
|
|
601
|
+
opacity: 0.4;
|
|
602
|
+
cursor: default;
|
|
603
|
+
}
|
|
465
604
|
.mbe-image-frame {
|
|
466
605
|
position: fixed;
|
|
467
606
|
pointer-events: none;
|
|
@@ -571,6 +710,11 @@
|
|
|
571
710
|
0 2px 4px -2px light-dark(rgb(0 0 0 / 0.1), transparent);
|
|
572
711
|
--mbe-block-code-bg: color-mix(in oklab, var(--mbe-code-bg) 45%, transparent);
|
|
573
712
|
--mbe-quote-border: color-mix(in oklab, var(--mbe-muted) 25%, transparent);
|
|
713
|
+
--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)));
|
|
714
|
+
--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)));
|
|
715
|
+
--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)));
|
|
716
|
+
--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)));
|
|
717
|
+
--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
718
|
}
|
|
575
719
|
:where([data-theme=light]) :is(.mbe-root, .mbe-ui),
|
|
576
720
|
.mbe-root[data-theme=light],
|
|
@@ -671,9 +815,56 @@
|
|
|
671
815
|
padding-inline-start: 12px;
|
|
672
816
|
color: var(--mbe-muted);
|
|
673
817
|
}
|
|
818
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout] {
|
|
819
|
+
color: inherit;
|
|
820
|
+
border-inline-start: 0;
|
|
821
|
+
border-radius: var(--mbe-radius);
|
|
822
|
+
background: color-mix(in oklab, var(--mbe-callout) 10%, transparent);
|
|
823
|
+
}
|
|
824
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-joined] {
|
|
825
|
+
border-start-start-radius: 0;
|
|
826
|
+
border-start-end-radius: 0;
|
|
827
|
+
}
|
|
828
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-continued] {
|
|
829
|
+
border-end-start-radius: 0;
|
|
830
|
+
border-end-end-radius: 0;
|
|
831
|
+
}
|
|
832
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=note] {
|
|
833
|
+
--mbe-callout: var(--mbe-callout-note);
|
|
834
|
+
}
|
|
835
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=tip] {
|
|
836
|
+
--mbe-callout: var(--mbe-callout-tip);
|
|
837
|
+
}
|
|
838
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=important] {
|
|
839
|
+
--mbe-callout: var(--mbe-callout-important);
|
|
840
|
+
}
|
|
841
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=warning] {
|
|
842
|
+
--mbe-callout: var(--mbe-callout-warning);
|
|
843
|
+
}
|
|
844
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=caution] {
|
|
845
|
+
--mbe-callout: var(--mbe-callout-caution);
|
|
846
|
+
}
|
|
847
|
+
.mbe-root .mbe-callout-icon {
|
|
848
|
+
color: var(--mbe-callout);
|
|
849
|
+
border-radius: 4px;
|
|
850
|
+
}
|
|
851
|
+
.mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-icon:hover {
|
|
852
|
+
background: color-mix(in oklab, var(--mbe-callout) 14%, transparent);
|
|
853
|
+
}
|
|
674
854
|
.mbe-root .mbe-marker {
|
|
675
855
|
color: var(--mbe-muted);
|
|
676
856
|
}
|
|
857
|
+
.mbe-root .mbe-details-toggle {
|
|
858
|
+
color: var(--mbe-muted);
|
|
859
|
+
border-radius: 4px;
|
|
860
|
+
}
|
|
861
|
+
.mbe-root .mbe-details-toggle:hover {
|
|
862
|
+
color: var(--mbe-text);
|
|
863
|
+
background: var(--mbe-hover);
|
|
864
|
+
}
|
|
865
|
+
:is(.mbe-root, .mbe-flow) > .mbe-details {
|
|
866
|
+
font-weight: 500;
|
|
867
|
+
}
|
|
677
868
|
.mbe-root .mbe-checkbox {
|
|
678
869
|
appearance: none;
|
|
679
870
|
-webkit-appearance: none;
|
|
@@ -840,8 +1031,9 @@
|
|
|
840
1031
|
}
|
|
841
1032
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
842
1033
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
843
|
-
.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
|
|
1034
|
+
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
|
|
1035
|
+
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
1036
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
|
|
845
1037
|
color: var(--mbe-muted);
|
|
846
1038
|
opacity: 0.7;
|
|
847
1039
|
}
|
|
@@ -853,6 +1045,7 @@
|
|
|
853
1045
|
}
|
|
854
1046
|
.mbe-menu,
|
|
855
1047
|
.mbe-toolbar,
|
|
1048
|
+
.mbe-link-card,
|
|
856
1049
|
.mbe-input-popover {
|
|
857
1050
|
color: var(--mbe-text);
|
|
858
1051
|
background: var(--mbe-popup-bg);
|
|
@@ -894,9 +1087,18 @@
|
|
|
894
1087
|
font-size: 12px;
|
|
895
1088
|
color: var(--mbe-muted);
|
|
896
1089
|
}
|
|
897
|
-
.mbe-toolbar
|
|
1090
|
+
.mbe-toolbar,
|
|
1091
|
+
.mbe-link-card {
|
|
898
1092
|
border-radius: calc(var(--mbe-radius) + 2px);
|
|
899
1093
|
}
|
|
1094
|
+
.mbe-link-card-url {
|
|
1095
|
+
font-size: 13px;
|
|
1096
|
+
color: var(--mbe-link);
|
|
1097
|
+
text-decoration: none;
|
|
1098
|
+
}
|
|
1099
|
+
.mbe-link-card-url:hover {
|
|
1100
|
+
text-decoration: underline;
|
|
1101
|
+
}
|
|
900
1102
|
.mbe-tool {
|
|
901
1103
|
border-radius: 7px;
|
|
902
1104
|
}
|
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: the icon, and a tint of it behind the text. */
|
|
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,31 @@
|
|
|
114
120
|
color: var(--mbe-muted);
|
|
115
121
|
}
|
|
116
122
|
|
|
123
|
+
/* Callouts: a soft tint of the type's color behind body-colored text, with
|
|
124
|
+
the icon in the type's color and no border. Only the outer corners of a
|
|
125
|
+
callout are rounded. */
|
|
126
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout] {
|
|
127
|
+
color: inherit;
|
|
128
|
+
border-inline-start: 0;
|
|
129
|
+
border-radius: var(--mbe-radius);
|
|
130
|
+
background: color-mix(in oklab, var(--mbe-callout) 10%, transparent);
|
|
131
|
+
}
|
|
132
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-joined] { border-start-start-radius: 0; border-start-end-radius: 0; }
|
|
133
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-continued] { border-end-start-radius: 0; border-end-end-radius: 0; }
|
|
134
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='note'] { --mbe-callout: var(--mbe-callout-note); }
|
|
135
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='tip'] { --mbe-callout: var(--mbe-callout-tip); }
|
|
136
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='important'] { --mbe-callout: var(--mbe-callout-important); }
|
|
137
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='warning'] { --mbe-callout: var(--mbe-callout-warning); }
|
|
138
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='caution'] { --mbe-callout: var(--mbe-callout-caution); }
|
|
139
|
+
.mbe-root .mbe-callout-icon { color: var(--mbe-callout); border-radius: 4px; }
|
|
140
|
+
.mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-icon:hover { background: color-mix(in oklab, var(--mbe-callout) 14%, transparent); }
|
|
141
|
+
|
|
117
142
|
/* Lists */
|
|
118
143
|
.mbe-root .mbe-marker { color: var(--mbe-muted); }
|
|
144
|
+
/* Collapsible sections: a muted toggle and a medium-weight title. */
|
|
145
|
+
.mbe-root .mbe-details-toggle { color: var(--mbe-muted); border-radius: 4px; }
|
|
146
|
+
.mbe-root .mbe-details-toggle:hover { color: var(--mbe-text); background: var(--mbe-hover); }
|
|
147
|
+
:is(.mbe-root, .mbe-flow) > .mbe-details { font-weight: 500; }
|
|
119
148
|
/* appearance: none, so a disabled checkbox in read-only is not greyed out. */
|
|
120
149
|
.mbe-root .mbe-checkbox {
|
|
121
150
|
appearance: none;
|
|
@@ -211,8 +240,9 @@
|
|
|
211
240
|
/* Placeholders and hints */
|
|
212
241
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
213
242
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
214
|
-
.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
|
|
243
|
+
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
|
|
244
|
+
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
245
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
|
|
216
246
|
color: var(--mbe-muted);
|
|
217
247
|
opacity: 0.7;
|
|
218
248
|
}
|
|
@@ -227,6 +257,7 @@
|
|
|
227
257
|
}
|
|
228
258
|
.mbe-menu,
|
|
229
259
|
.mbe-toolbar,
|
|
260
|
+
.mbe-link-card,
|
|
230
261
|
.mbe-input-popover {
|
|
231
262
|
color: var(--mbe-text);
|
|
232
263
|
background: var(--mbe-popup-bg);
|
|
@@ -244,7 +275,10 @@
|
|
|
244
275
|
.mbe-menu-loading { color: var(--mbe-muted); }
|
|
245
276
|
.mbe-menu-detail { font-size: 12px; color: var(--mbe-muted); }
|
|
246
277
|
|
|
247
|
-
.mbe-toolbar
|
|
278
|
+
.mbe-toolbar,
|
|
279
|
+
.mbe-link-card { border-radius: calc(var(--mbe-radius) + 2px); }
|
|
280
|
+
.mbe-link-card-url { font-size: 13px; color: var(--mbe-link); text-decoration: none; }
|
|
281
|
+
.mbe-link-card-url:hover { text-decoration: underline; }
|
|
248
282
|
.mbe-tool { border-radius: 7px; }
|
|
249
283
|
.mbe-tool:hover,
|
|
250
284
|
.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 blocks that form one blockquote with the block `blockId`: its
|
|
125
|
+
* neighbours in the same quote or callout. Null when the block is not in 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 block `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.
|