@usememos/editor 26.10.11 → 26.10.13
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 +2 -1
- package/dist/base.css +52 -31
- package/dist/index.js +211 -29
- package/dist/index.js.map +3 -3
- package/dist/react.js.map +2 -2
- package/dist/style.css +167 -54
- package/dist/theme.css +61 -24
- package/dist/types/editor.d.ts +6 -0
- package/dist/types/labels.d.ts +1 -0
- package/dist/types/markdown/htmlSection.d.ts +28 -0
- package/dist/types/markdown/serialize.d.ts +2 -1
- package/dist/types/react/index.d.ts +1 -1
- package/dist/types/view/dom.d.ts +5 -0
- package/package.json +1 -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 | '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 | '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;AAyIjB;AA/FT,IAAM,OAAO,CAAC,eAAe,YAAY,cAAc,cAAc,cAAc,eAAe,SAAS,YAAY;AAGvH,IAAM,eAAe,CAAC,gBAA6C,cAAc,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,IAAI;AAc1G,IAAM,iBAAiB,WAAW,SAASA,gBAAe,OAA4B,KAAkC;AAC7H,QAAM,YAAY,OAAuB,IAAI;AAC7C,QAAM,YAAY,O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ACd,QAAI,CAAC,QAAQ;AACX,eAAS,IAAI;AACb;AAAA,IACF;AACA,aAAS,OAAO,OAAO,WAAW,KAAK,CAAC;AACxC,WAAO,OAAO,GAAG,oBAAoB,CAAC,EAAE,OAAAA,OAAM,MAAM,SAAS,OAAOA,MAAK,CAAC,CAAC;AAAA,EAE7E,GAAG,CAAC,QAAQ,IAAI,CAAC;AACjB,SAAO;AACT;AASO,SAAS,cAAc,EAAE,QAAQ,WAAW,MAAM,GAAuB;AAC9E,QAAM,YAAY,OAAuB,IAAI;AAC7C,YAAU,MAAM;AACd,UAAM,OAAO,UAAU;AACvB,QAAI,CAAC,UAAU,CAAC,KAAM;AACtB,SAAK,YAAY,OAAO,IAAI;AAC5B,UAAM,YAAY,iBAAiB,IAAI,MAAM;AAC7C,QAAI,WAAW;AACb,uBAAiB,OAAO,MAAM;AAC9B,aAAO,SAAS,MAAM,SAAS;AAAA,IACjC;AACA,WAAO,MAAM;AACX,UAAI,OAAO,KAAK,eAAe,KAAM,MAAK,YAAY,OAAO,IAAI;AAAA,IACnE;AAAA,EACF,GAAG,CAAC,MAAM,CAAC;AACX,SAAO,oBAAC,SAAI,KAAK,WAAW,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
|
@@ -11,9 +11,10 @@
|
|
|
11
11
|
caret-color: currentColor;
|
|
12
12
|
position: relative;
|
|
13
13
|
}
|
|
14
|
-
.mbe-root > .mbe-block {
|
|
14
|
+
:is(.mbe-root, .mbe-flow) > .mbe-block {
|
|
15
15
|
margin: var(--mbe-block-gap) 0;
|
|
16
16
|
position: relative;
|
|
17
|
+
display: flow-root;
|
|
17
18
|
}
|
|
18
19
|
.mbe-root.mbe-block-selecting {
|
|
19
20
|
caret-color: transparent;
|
|
@@ -27,42 +28,42 @@
|
|
|
27
28
|
content-visibility: auto;
|
|
28
29
|
contain-intrinsic-size: auto 24px;
|
|
29
30
|
}
|
|
30
|
-
.mbe-root > :is(h1, h2).mbe-block {
|
|
31
|
+
:is(.mbe-root, .mbe-flow) > :is(h1, h2).mbe-block {
|
|
31
32
|
margin-top: 20px;
|
|
32
33
|
}
|
|
33
|
-
.mbe-root > h3.mbe-block {
|
|
34
|
+
:is(.mbe-root, .mbe-flow) > h3.mbe-block {
|
|
34
35
|
margin-top: 20px;
|
|
35
36
|
margin-bottom: 6px;
|
|
36
37
|
}
|
|
37
|
-
.mbe-root > :is(h4, h5, h6).mbe-block {
|
|
38
|
+
:is(.mbe-root, .mbe-flow) > :is(h4, h5, h6).mbe-block {
|
|
38
39
|
margin-top: 16px;
|
|
39
40
|
margin-bottom: 4px;
|
|
40
41
|
}
|
|
41
|
-
.mbe-root > blockquote[data-quote-joined] {
|
|
42
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-quote-joined] {
|
|
42
43
|
margin-top: calc(-1 * var(--mbe-block-gap));
|
|
43
44
|
padding-top: var(--mbe-block-gap);
|
|
44
45
|
}
|
|
45
|
-
.mbe-root > .mbe-list-item {
|
|
46
|
+
:is(.mbe-root, .mbe-flow) > .mbe-list-item {
|
|
46
47
|
display: flex;
|
|
47
48
|
align-items: flex-start;
|
|
48
49
|
margin: 2px 0;
|
|
49
50
|
}
|
|
50
|
-
.mbe-root > .mbe-list-item[data-list-start] {
|
|
51
|
+
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-list-start] {
|
|
51
52
|
margin-top: var(--mbe-block-gap);
|
|
52
53
|
}
|
|
53
|
-
.mbe-root > .mbe-list-item[data-indent="1"] {
|
|
54
|
+
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="1"] {
|
|
54
55
|
padding-inline-start: var(--mbe-indent-size);
|
|
55
56
|
}
|
|
56
|
-
.mbe-root > .mbe-list-item[data-indent="2"] {
|
|
57
|
+
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="2"] {
|
|
57
58
|
padding-inline-start: calc(2 * var(--mbe-indent-size));
|
|
58
59
|
}
|
|
59
|
-
.mbe-root > .mbe-list-item[data-indent="3"] {
|
|
60
|
+
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="3"] {
|
|
60
61
|
padding-inline-start: calc(3 * var(--mbe-indent-size));
|
|
61
62
|
}
|
|
62
|
-
.mbe-root > .mbe-list-item[data-indent="4"] {
|
|
63
|
+
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="4"] {
|
|
63
64
|
padding-inline-start: calc(4 * var(--mbe-indent-size));
|
|
64
65
|
}
|
|
65
|
-
.mbe-root > .mbe-list-item[data-indent="5"] {
|
|
66
|
+
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="5"] {
|
|
66
67
|
padding-inline-start: calc(5 * var(--mbe-indent-size));
|
|
67
68
|
}
|
|
68
69
|
.mbe-root .mbe-marker {
|
|
@@ -182,51 +183,88 @@
|
|
|
182
183
|
padding: 0;
|
|
183
184
|
width: 12em;
|
|
184
185
|
}
|
|
185
|
-
.mbe-root > .mbe-code pre,
|
|
186
|
-
.mbe-root > pre.mbe-raw {
|
|
186
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code pre,
|
|
187
|
+
:is(.mbe-root, .mbe-flow) > pre.mbe-raw {
|
|
187
188
|
white-space: pre-wrap;
|
|
188
189
|
tab-size: 2;
|
|
189
190
|
}
|
|
190
|
-
.mbe-root > .mbe-code pre {
|
|
191
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code pre {
|
|
191
192
|
margin: 0;
|
|
192
193
|
}
|
|
193
|
-
.mbe-root > .mbe-code pre code {
|
|
194
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code pre code {
|
|
194
195
|
display: block;
|
|
195
196
|
}
|
|
196
|
-
.mbe-root > .mbe-view-block {
|
|
197
|
+
:is(.mbe-root, .mbe-flow) > .mbe-view-block {
|
|
197
198
|
overflow-x: auto;
|
|
198
199
|
overflow-y: hidden;
|
|
199
200
|
}
|
|
200
|
-
.mbe-root > .mbe-view-block > * {
|
|
201
|
+
:is(.mbe-root, .mbe-flow) > .mbe-view-block > * {
|
|
201
202
|
margin-block: 0;
|
|
202
203
|
}
|
|
203
|
-
.mbe-root
|
|
204
|
+
.mbe-root .mbe-view-block.mbe-view-html {
|
|
205
|
+
white-space: normal;
|
|
206
|
+
}
|
|
207
|
+
.mbe-root .mbe-view-html .mbe-flow {
|
|
208
|
+
white-space: pre-wrap;
|
|
209
|
+
margin-block: var(--mbe-block-gap);
|
|
210
|
+
}
|
|
211
|
+
.mbe-root .mbe-view-html :is(p, blockquote, pre, ul, ol, dl, table, details, figure, hr, h1, h2, h3, h4, h5, h6):not(.mbe-flow *) {
|
|
212
|
+
margin-block: var(--mbe-block-gap);
|
|
213
|
+
}
|
|
214
|
+
.mbe-root .mbe-view-html :is(ul, ol):not(.mbe-flow *) {
|
|
215
|
+
padding-inline-start: var(--mbe-indent-size);
|
|
216
|
+
}
|
|
217
|
+
.mbe-root .mbe-view-html ul:not(.mbe-flow *) {
|
|
218
|
+
list-style: disc;
|
|
219
|
+
}
|
|
220
|
+
.mbe-root .mbe-view-html ol:not(.mbe-flow *) {
|
|
221
|
+
list-style: decimal;
|
|
222
|
+
}
|
|
223
|
+
.mbe-root .mbe-view-html pre:not(.mbe-flow *) {
|
|
224
|
+
white-space: pre;
|
|
225
|
+
overflow-x: auto;
|
|
226
|
+
}
|
|
227
|
+
.mbe-root .mbe-view-html summary:not(.mbe-flow *) {
|
|
228
|
+
cursor: pointer;
|
|
229
|
+
}
|
|
230
|
+
.mbe-root .mbe-view-html img:not(.mbe-flow *) {
|
|
231
|
+
max-width: 100%;
|
|
232
|
+
}
|
|
233
|
+
.mbe-root .mbe-view-html :is(details, blockquote, li, td, th, div, section):not(.mbe-flow *) > :first-child,
|
|
234
|
+
.mbe-root .mbe-view-block.mbe-view-html > :first-child {
|
|
235
|
+
margin-top: 0;
|
|
236
|
+
}
|
|
237
|
+
.mbe-root .mbe-view-html :is(details, blockquote, li, td, th, div, section):not(.mbe-flow *) > :last-child,
|
|
238
|
+
.mbe-root .mbe-view-block.mbe-view-html > :last-child {
|
|
239
|
+
margin-bottom: 0;
|
|
240
|
+
}
|
|
241
|
+
:is(.mbe-root, .mbe-flow) > .mbe-divider.mbe-block {
|
|
204
242
|
margin: 16px 0;
|
|
205
243
|
padding: 4px 0;
|
|
206
244
|
cursor: default;
|
|
207
245
|
}
|
|
208
|
-
.mbe-root > .mbe-divider hr {
|
|
246
|
+
:is(.mbe-root, .mbe-flow) > .mbe-divider hr {
|
|
209
247
|
margin: 0;
|
|
210
248
|
}
|
|
211
|
-
.mbe-root > .mbe-table {
|
|
249
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table {
|
|
212
250
|
overflow-x: auto;
|
|
213
251
|
}
|
|
214
|
-
.mbe-root > .mbe-table table {
|
|
252
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table table {
|
|
215
253
|
border-collapse: separate;
|
|
216
254
|
border-spacing: 0;
|
|
217
255
|
}
|
|
218
|
-
.mbe-root > .mbe-table th,
|
|
219
|
-
.mbe-root > .mbe-table td {
|
|
256
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table th,
|
|
257
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table td {
|
|
220
258
|
padding: 4px 8px;
|
|
221
259
|
min-width: 4em;
|
|
222
260
|
vertical-align: top;
|
|
223
261
|
text-align: start;
|
|
224
262
|
outline: none;
|
|
225
263
|
}
|
|
226
|
-
.mbe-root > .mbe-block:first-child {
|
|
264
|
+
:is(.mbe-root, .mbe-flow) > .mbe-block:first-child {
|
|
227
265
|
margin-top: 0;
|
|
228
266
|
}
|
|
229
|
-
.mbe-root > .mbe-block:last-child {
|
|
267
|
+
:is(.mbe-root, .mbe-flow) > .mbe-block:last-child {
|
|
230
268
|
margin-bottom: 0;
|
|
231
269
|
}
|
|
232
270
|
.mbe-root .mbe-empty-content {
|
|
@@ -234,8 +272,8 @@
|
|
|
234
272
|
}
|
|
235
273
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
236
274
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
237
|
-
.mbe-root > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
238
|
-
.mbe-root > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::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 {
|
|
239
277
|
opacity: 0.5;
|
|
240
278
|
pointer-events: none;
|
|
241
279
|
position: absolute;
|
|
@@ -246,8 +284,8 @@
|
|
|
246
284
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before {
|
|
247
285
|
content: var(--mbe-slash-hint, "");
|
|
248
286
|
}
|
|
249
|
-
.mbe-root > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
250
|
-
.mbe-root > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before {
|
|
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 {
|
|
251
289
|
content: attr(data-hint);
|
|
252
290
|
}
|
|
253
291
|
.mbe-root > .mbe-widget {
|
|
@@ -551,26 +589,26 @@
|
|
|
551
589
|
color: var(--mbe-text);
|
|
552
590
|
background: var(--mbe-bg);
|
|
553
591
|
}
|
|
554
|
-
.mbe-root > :is(h1, h2, h3, h4, h5, h6) {
|
|
592
|
+
:is(.mbe-root, .mbe-flow) > :is(h1, h2, h3, h4, h5, h6) {
|
|
555
593
|
font-weight: 600;
|
|
556
594
|
}
|
|
557
|
-
.mbe-root > h1 {
|
|
595
|
+
:is(.mbe-root, .mbe-flow) > h1 {
|
|
558
596
|
font-size: 24px;
|
|
559
597
|
line-height: 32px;
|
|
560
598
|
}
|
|
561
|
-
.mbe-root > h2 {
|
|
599
|
+
:is(.mbe-root, .mbe-flow) > h2 {
|
|
562
600
|
font-size: 20px;
|
|
563
601
|
line-height: 28px;
|
|
564
602
|
}
|
|
565
|
-
.mbe-root > h3 {
|
|
603
|
+
:is(.mbe-root, .mbe-flow) > h3 {
|
|
566
604
|
font-size: 18px;
|
|
567
605
|
line-height: 26px;
|
|
568
606
|
}
|
|
569
|
-
.mbe-root > :is(h4, h5, h6) {
|
|
607
|
+
:is(.mbe-root, .mbe-flow) > :is(h4, h5, h6) {
|
|
570
608
|
font-size: 16px;
|
|
571
609
|
line-height: 24px;
|
|
572
610
|
}
|
|
573
|
-
.mbe-root > h6 {
|
|
611
|
+
:is(.mbe-root, .mbe-flow) > h6 {
|
|
574
612
|
color: var(--mbe-muted);
|
|
575
613
|
}
|
|
576
614
|
.mbe-root > .mbe-block.mbe-block-selected {
|
|
@@ -620,7 +658,7 @@
|
|
|
620
658
|
.mbe-root.mbe-readonly .mbe-footnote-ref {
|
|
621
659
|
cursor: pointer;
|
|
622
660
|
}
|
|
623
|
-
.mbe-root > .mbe-footnote {
|
|
661
|
+
:is(.mbe-root, .mbe-flow) > .mbe-footnote {
|
|
624
662
|
font-size: 0.875em;
|
|
625
663
|
color: var(--mbe-muted);
|
|
626
664
|
}
|
|
@@ -628,7 +666,7 @@
|
|
|
628
666
|
margin-inline-end: 0.375em;
|
|
629
667
|
color: var(--mbe-link);
|
|
630
668
|
}
|
|
631
|
-
.mbe-root > blockquote {
|
|
669
|
+
:is(.mbe-root, .mbe-flow) > blockquote {
|
|
632
670
|
border-inline-start: 3px solid var(--mbe-quote-border);
|
|
633
671
|
padding-inline-start: 12px;
|
|
634
672
|
color: var(--mbe-muted);
|
|
@@ -648,7 +686,7 @@
|
|
|
648
686
|
border-color: var(--mbe-accent);
|
|
649
687
|
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
|
|
650
688
|
}
|
|
651
|
-
.mbe-root > .mbe-code:not(.mbe-view-block) {
|
|
689
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code:not(.mbe-view-block) {
|
|
652
690
|
background: var(--mbe-block-code-bg);
|
|
653
691
|
border-radius: var(--mbe-radius);
|
|
654
692
|
overflow: hidden;
|
|
@@ -677,58 +715,133 @@
|
|
|
677
715
|
.mbe-root .mbe-code-copy.mbe-copied {
|
|
678
716
|
color: var(--mbe-accent);
|
|
679
717
|
}
|
|
680
|
-
.mbe-root > .mbe-code pre,
|
|
681
|
-
.mbe-root > pre.mbe-raw {
|
|
718
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code pre,
|
|
719
|
+
:is(.mbe-root, .mbe-flow) > pre.mbe-raw {
|
|
682
720
|
font-size: 14px;
|
|
683
721
|
line-height: 22px;
|
|
684
722
|
font-family: var(--mbe-mono);
|
|
685
723
|
}
|
|
686
|
-
.mbe-root > .mbe-code pre {
|
|
724
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code pre {
|
|
687
725
|
padding: 2px 12px 10px;
|
|
688
726
|
}
|
|
689
|
-
.mbe-root > .mbe-code pre code {
|
|
727
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code pre code {
|
|
690
728
|
background: none;
|
|
691
729
|
padding: 0;
|
|
692
730
|
border-radius: 0;
|
|
693
731
|
font: inherit;
|
|
694
732
|
}
|
|
695
|
-
.mbe-root > pre.mbe-raw {
|
|
733
|
+
:is(.mbe-root, .mbe-flow) > pre.mbe-raw {
|
|
696
734
|
color: var(--mbe-muted);
|
|
697
735
|
}
|
|
698
|
-
.mbe-root
|
|
736
|
+
.mbe-root .mbe-view-html blockquote:not(.mbe-flow *) {
|
|
737
|
+
border-inline-start: 3px solid var(--mbe-quote-border);
|
|
738
|
+
padding-inline-start: 12px;
|
|
739
|
+
color: var(--mbe-muted);
|
|
740
|
+
}
|
|
741
|
+
.mbe-root .mbe-view-html pre:not(.mbe-flow *) {
|
|
742
|
+
background: var(--mbe-block-code-bg);
|
|
743
|
+
border-radius: var(--mbe-radius);
|
|
744
|
+
padding: 10px 12px;
|
|
745
|
+
font-size: 14px;
|
|
746
|
+
line-height: 22px;
|
|
747
|
+
font-family: var(--mbe-mono);
|
|
748
|
+
}
|
|
749
|
+
.mbe-root .mbe-view-html pre code:not(.mbe-flow *) {
|
|
750
|
+
background: none;
|
|
751
|
+
padding: 0;
|
|
752
|
+
border-radius: 0;
|
|
753
|
+
font: inherit;
|
|
754
|
+
}
|
|
755
|
+
.mbe-root .mbe-view-html :is(h1, h2, h3, h4, h5, h6):not(.mbe-flow *) {
|
|
756
|
+
font-weight: 600;
|
|
757
|
+
}
|
|
758
|
+
.mbe-root .mbe-view-html h1:not(.mbe-flow *) {
|
|
759
|
+
font-size: 24px;
|
|
760
|
+
line-height: 32px;
|
|
761
|
+
}
|
|
762
|
+
.mbe-root .mbe-view-html h2:not(.mbe-flow *) {
|
|
763
|
+
font-size: 20px;
|
|
764
|
+
line-height: 28px;
|
|
765
|
+
}
|
|
766
|
+
.mbe-root .mbe-view-html h3:not(.mbe-flow *) {
|
|
767
|
+
font-size: 18px;
|
|
768
|
+
line-height: 26px;
|
|
769
|
+
}
|
|
770
|
+
.mbe-root .mbe-view-html h6:not(.mbe-flow *) {
|
|
771
|
+
color: var(--mbe-muted);
|
|
772
|
+
}
|
|
773
|
+
.mbe-root .mbe-view-html hr:not(.mbe-flow *) {
|
|
774
|
+
border: none;
|
|
775
|
+
border-top: 1px solid var(--mbe-border);
|
|
776
|
+
}
|
|
777
|
+
.mbe-root .mbe-view-html a:not(.mbe-link) {
|
|
778
|
+
color: var(--mbe-link);
|
|
779
|
+
text-decoration: underline;
|
|
780
|
+
text-underline-offset: 2px;
|
|
781
|
+
}
|
|
782
|
+
.mbe-root .mbe-view-html table:not(.mbe-flow *) {
|
|
783
|
+
border-collapse: collapse;
|
|
784
|
+
font-size: 14px;
|
|
785
|
+
line-height: 20px;
|
|
786
|
+
}
|
|
787
|
+
.mbe-root .mbe-view-html :is(th, td):not(.mbe-flow *) {
|
|
788
|
+
border: 1px solid var(--mbe-border);
|
|
789
|
+
padding: 6px 10px;
|
|
790
|
+
text-align: start;
|
|
791
|
+
vertical-align: top;
|
|
792
|
+
}
|
|
793
|
+
.mbe-root .mbe-view-html th:not(.mbe-flow *) {
|
|
794
|
+
font-weight: 500;
|
|
795
|
+
background: var(--mbe-block-code-bg);
|
|
796
|
+
}
|
|
797
|
+
.mbe-root .mbe-view-html kbd {
|
|
798
|
+
font-family: var(--mbe-mono);
|
|
799
|
+
font-size: 0.8125em;
|
|
800
|
+
line-height: 1;
|
|
801
|
+
padding: 2px 5px;
|
|
802
|
+
border: 1px solid var(--mbe-border);
|
|
803
|
+
border-bottom-width: 2px;
|
|
804
|
+
border-radius: 4px;
|
|
805
|
+
background: var(--mbe-block-code-bg);
|
|
806
|
+
}
|
|
807
|
+
.mbe-root .mbe-view-html mark {
|
|
808
|
+
background: color-mix(in oklab, #facc15 40%, transparent);
|
|
809
|
+
color: inherit;
|
|
810
|
+
}
|
|
811
|
+
:is(.mbe-root, .mbe-flow) > .mbe-divider hr {
|
|
699
812
|
border: none;
|
|
700
813
|
border-top: 1px solid var(--mbe-border);
|
|
701
814
|
}
|
|
702
|
-
.mbe-root > .mbe-table table {
|
|
815
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table table {
|
|
703
816
|
font-size: 14px;
|
|
704
817
|
line-height: 20px;
|
|
705
818
|
border: 1px solid var(--mbe-border);
|
|
706
819
|
border-radius: var(--mbe-radius);
|
|
707
820
|
}
|
|
708
|
-
.mbe-root > .mbe-table :is(th, td) {
|
|
821
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td) {
|
|
709
822
|
padding: 6px 10px;
|
|
710
823
|
min-width: 8em;
|
|
711
824
|
}
|
|
712
|
-
.mbe-root > .mbe-table :is(th, td):not(:first-child) {
|
|
825
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td):not(:first-child) {
|
|
713
826
|
border-inline-start: 1px solid var(--mbe-border);
|
|
714
827
|
}
|
|
715
|
-
.mbe-root > .mbe-table tr:not(:first-child) > * {
|
|
828
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table tr:not(:first-child) > * {
|
|
716
829
|
border-top: 1px solid var(--mbe-border);
|
|
717
830
|
}
|
|
718
|
-
.mbe-root > .mbe-table th {
|
|
831
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table th {
|
|
719
832
|
font-weight: 500;
|
|
720
833
|
background: var(--mbe-block-code-bg);
|
|
721
834
|
}
|
|
722
|
-
.mbe-root > .mbe-table tr:first-child > :first-child {
|
|
835
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table tr:first-child > :first-child {
|
|
723
836
|
border-start-start-radius: calc(var(--mbe-radius) - 1px);
|
|
724
837
|
}
|
|
725
|
-
.mbe-root > .mbe-table tr:first-child > :last-child {
|
|
838
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table tr:first-child > :last-child {
|
|
726
839
|
border-start-end-radius: calc(var(--mbe-radius) - 1px);
|
|
727
840
|
}
|
|
728
841
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
729
842
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
730
|
-
.mbe-root > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
731
|
-
.mbe-root > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::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 {
|
|
732
845
|
color: var(--mbe-muted);
|
|
733
846
|
opacity: 0.7;
|
|
734
847
|
}
|
package/dist/theme.css
CHANGED
|
@@ -65,12 +65,12 @@
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
/* Headings: close to the body size. */
|
|
68
|
-
.mbe-root > :is(h1, h2, h3, h4, h5, h6) { font-weight: 600; }
|
|
69
|
-
.mbe-root > h1 { font-size: 24px; line-height: 32px; }
|
|
70
|
-
.mbe-root > h2 { font-size: 20px; line-height: 28px; }
|
|
71
|
-
.mbe-root > h3 { font-size: 18px; line-height: 26px; }
|
|
72
|
-
.mbe-root > :is(h4, h5, h6) { font-size: 16px; line-height: 24px; }
|
|
73
|
-
.mbe-root > h6 { color: var(--mbe-muted); }
|
|
68
|
+
:is(.mbe-root, .mbe-flow) > :is(h1, h2, h3, h4, h5, h6) { font-weight: 600; }
|
|
69
|
+
:is(.mbe-root, .mbe-flow) > h1 { font-size: 24px; line-height: 32px; }
|
|
70
|
+
:is(.mbe-root, .mbe-flow) > h2 { font-size: 20px; line-height: 28px; }
|
|
71
|
+
:is(.mbe-root, .mbe-flow) > h3 { font-size: 18px; line-height: 26px; }
|
|
72
|
+
:is(.mbe-root, .mbe-flow) > :is(h4, h5, h6) { font-size: 16px; line-height: 24px; }
|
|
73
|
+
:is(.mbe-root, .mbe-flow) > h6 { color: var(--mbe-muted); }
|
|
74
74
|
|
|
75
75
|
/* Block selection */
|
|
76
76
|
.mbe-root > .mbe-block.mbe-block-selected {
|
|
@@ -104,11 +104,11 @@
|
|
|
104
104
|
/* Footnotes, rendered: a reference is a small raised label, a definition a small muted note. */
|
|
105
105
|
.mbe-root .mbe-footnote-ref { font-size: 0.75em; line-height: 0; color: var(--mbe-link); }
|
|
106
106
|
.mbe-root.mbe-readonly .mbe-footnote-ref { cursor: pointer; }
|
|
107
|
-
.mbe-root > .mbe-footnote { font-size: 0.875em; color: var(--mbe-muted); }
|
|
107
|
+
:is(.mbe-root, .mbe-flow) > .mbe-footnote { font-size: 0.875em; color: var(--mbe-muted); }
|
|
108
108
|
.mbe-root .mbe-footnote-label { margin-inline-end: 0.375em; color: var(--mbe-link); }
|
|
109
109
|
|
|
110
110
|
/* Quote */
|
|
111
|
-
.mbe-root > blockquote {
|
|
111
|
+
:is(.mbe-root, .mbe-flow) > blockquote {
|
|
112
112
|
border-inline-start: 3px solid var(--mbe-quote-border);
|
|
113
113
|
padding-inline-start: 12px;
|
|
114
114
|
color: var(--mbe-muted);
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
/* Code: a quiet panel, with the language as a small label above the code. */
|
|
134
|
-
.mbe-root > .mbe-code:not(.mbe-view-block) {
|
|
134
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code:not(.mbe-view-block) {
|
|
135
135
|
background: var(--mbe-block-code-bg);
|
|
136
136
|
border-radius: var(--mbe-radius);
|
|
137
137
|
overflow: hidden;
|
|
@@ -144,38 +144,75 @@
|
|
|
144
144
|
.mbe-root .mbe-code-copy:hover { color: var(--mbe-text); background: var(--mbe-hover); }
|
|
145
145
|
.mbe-root .mbe-code-copy.mbe-copied { color: var(--mbe-accent); }
|
|
146
146
|
/* Block source text: code blocks and raw blocks. */
|
|
147
|
-
.mbe-root > .mbe-code pre,
|
|
148
|
-
.mbe-root > pre.mbe-raw { font-size: 14px; line-height: 22px; font-family: var(--mbe-mono); }
|
|
149
|
-
.mbe-root > .mbe-code pre { padding: 2px 12px 10px; }
|
|
150
|
-
.mbe-root > .mbe-code pre code { background: none; padding: 0; border-radius: 0; font: inherit; }
|
|
147
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code pre,
|
|
148
|
+
:is(.mbe-root, .mbe-flow) > pre.mbe-raw { font-size: 14px; line-height: 22px; font-family: var(--mbe-mono); }
|
|
149
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code pre { padding: 2px 12px 10px; }
|
|
150
|
+
:is(.mbe-root, .mbe-flow) > .mbe-code pre code { background: none; padding: 0; border-radius: 0; font: inherit; }
|
|
151
151
|
|
|
152
152
|
/* Raw blocks: Markdown kept as source (HTML, structure the editor cannot hold, extension syntax) */
|
|
153
|
-
.mbe-root > pre.mbe-raw { color: var(--mbe-muted); }
|
|
153
|
+
:is(.mbe-root, .mbe-flow) > pre.mbe-raw { color: var(--mbe-muted); }
|
|
154
|
+
|
|
155
|
+
/* Rendered HTML: its elements look like the Markdown they stand for, as on GitHub. */
|
|
156
|
+
.mbe-root .mbe-view-html blockquote:not(.mbe-flow *) {
|
|
157
|
+
border-inline-start: 3px solid var(--mbe-quote-border);
|
|
158
|
+
padding-inline-start: 12px;
|
|
159
|
+
color: var(--mbe-muted);
|
|
160
|
+
}
|
|
161
|
+
.mbe-root .mbe-view-html pre:not(.mbe-flow *) {
|
|
162
|
+
background: var(--mbe-block-code-bg);
|
|
163
|
+
border-radius: var(--mbe-radius);
|
|
164
|
+
padding: 10px 12px;
|
|
165
|
+
font-size: 14px;
|
|
166
|
+
line-height: 22px;
|
|
167
|
+
font-family: var(--mbe-mono);
|
|
168
|
+
}
|
|
169
|
+
.mbe-root .mbe-view-html pre code:not(.mbe-flow *) { background: none; padding: 0; border-radius: 0; font: inherit; }
|
|
170
|
+
.mbe-root .mbe-view-html :is(h1, h2, h3, h4, h5, h6):not(.mbe-flow *) { font-weight: 600; }
|
|
171
|
+
.mbe-root .mbe-view-html h1:not(.mbe-flow *) { font-size: 24px; line-height: 32px; }
|
|
172
|
+
.mbe-root .mbe-view-html h2:not(.mbe-flow *) { font-size: 20px; line-height: 28px; }
|
|
173
|
+
.mbe-root .mbe-view-html h3:not(.mbe-flow *) { font-size: 18px; line-height: 26px; }
|
|
174
|
+
.mbe-root .mbe-view-html h6:not(.mbe-flow *) { color: var(--mbe-muted); }
|
|
175
|
+
.mbe-root .mbe-view-html hr:not(.mbe-flow *) { border: none; border-top: 1px solid var(--mbe-border); }
|
|
176
|
+
.mbe-root .mbe-view-html a:not(.mbe-link) { color: var(--mbe-link); text-decoration: underline; text-underline-offset: 2px; }
|
|
177
|
+
.mbe-root .mbe-view-html table:not(.mbe-flow *) { border-collapse: collapse; font-size: 14px; line-height: 20px; }
|
|
178
|
+
.mbe-root .mbe-view-html :is(th, td):not(.mbe-flow *) { border: 1px solid var(--mbe-border); padding: 6px 10px; text-align: start; vertical-align: top; }
|
|
179
|
+
.mbe-root .mbe-view-html th:not(.mbe-flow *) { font-weight: 500; background: var(--mbe-block-code-bg); }
|
|
180
|
+
.mbe-root .mbe-view-html kbd {
|
|
181
|
+
font-family: var(--mbe-mono);
|
|
182
|
+
font-size: 0.8125em;
|
|
183
|
+
line-height: 1;
|
|
184
|
+
padding: 2px 5px;
|
|
185
|
+
border: 1px solid var(--mbe-border);
|
|
186
|
+
border-bottom-width: 2px;
|
|
187
|
+
border-radius: 4px;
|
|
188
|
+
background: var(--mbe-block-code-bg);
|
|
189
|
+
}
|
|
190
|
+
.mbe-root .mbe-view-html mark { background: color-mix(in oklab, #facc15 40%, transparent); color: inherit; }
|
|
154
191
|
|
|
155
192
|
/* Divider */
|
|
156
|
-
.mbe-root > .mbe-divider hr { border: none; border-top: 1px solid var(--mbe-border); }
|
|
193
|
+
:is(.mbe-root, .mbe-flow) > .mbe-divider hr { border: none; border-top: 1px solid var(--mbe-border); }
|
|
157
194
|
|
|
158
195
|
/* Table: a light grid around every cell and a shaded header row, as in
|
|
159
196
|
Notion and Outline. Separate borders, so the outer corners can be round. */
|
|
160
|
-
.mbe-root > .mbe-table table {
|
|
197
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table table {
|
|
161
198
|
font-size: 14px;
|
|
162
199
|
line-height: 20px;
|
|
163
200
|
border: 1px solid var(--mbe-border);
|
|
164
201
|
border-radius: var(--mbe-radius);
|
|
165
202
|
}
|
|
166
|
-
.mbe-root > .mbe-table :is(th, td) { padding: 6px 10px; min-width: 8em; }
|
|
167
|
-
.mbe-root > .mbe-table :is(th, td):not(:first-child) { border-inline-start: 1px solid var(--mbe-border); }
|
|
168
|
-
.mbe-root > .mbe-table tr:not(:first-child) > * { border-top: 1px solid var(--mbe-border); }
|
|
169
|
-
.mbe-root > .mbe-table th { font-weight: 500; background: var(--mbe-block-code-bg); }
|
|
203
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td) { padding: 6px 10px; min-width: 8em; }
|
|
204
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table :is(th, td):not(:first-child) { border-inline-start: 1px solid var(--mbe-border); }
|
|
205
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table tr:not(:first-child) > * { border-top: 1px solid var(--mbe-border); }
|
|
206
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table th { font-weight: 500; background: var(--mbe-block-code-bg); }
|
|
170
207
|
/* The header's fill stays inside the round corners. */
|
|
171
|
-
.mbe-root > .mbe-table tr:first-child > :first-child { border-start-start-radius: calc(var(--mbe-radius) - 1px); }
|
|
172
|
-
.mbe-root > .mbe-table tr:first-child > :last-child { border-start-end-radius: calc(var(--mbe-radius) - 1px); }
|
|
208
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table tr:first-child > :first-child { border-start-start-radius: calc(var(--mbe-radius) - 1px); }
|
|
209
|
+
:is(.mbe-root, .mbe-flow) > .mbe-table tr:first-child > :last-child { border-start-end-radius: calc(var(--mbe-radius) - 1px); }
|
|
173
210
|
|
|
174
211
|
/* Placeholders and hints */
|
|
175
212
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
176
213
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
177
|
-
.mbe-root > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
178
|
-
.mbe-root > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::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 {
|
|
179
216
|
color: var(--mbe-muted);
|
|
180
217
|
opacity: 0.7;
|
|
181
218
|
}
|
package/dist/types/editor.d.ts
CHANGED
|
@@ -81,6 +81,12 @@ export interface EditorOptions {
|
|
|
81
81
|
popupContainer?: HTMLElement;
|
|
82
82
|
/** IDs of built-in slash menu items to show, in order, or false for no slash menu. See SLASH_ITEM_IDS. */
|
|
83
83
|
slashMenu?: false | readonly SlashItemId[];
|
|
84
|
+
/**
|
|
85
|
+
* Shows `labels.slashHint` in the empty paragraph that has the caret.
|
|
86
|
+
* Default false. Has no effect when `slashMenu` is false. Fixed for the
|
|
87
|
+
* editor's lifetime.
|
|
88
|
+
*/
|
|
89
|
+
slashHint?: boolean;
|
|
84
90
|
/** Shortcut for `on('change')`, with the new Markdown. */
|
|
85
91
|
onChange?: (markdown: string, editor: Editor) => void;
|
|
86
92
|
/** Shortcut for `on('submit')`, with the current Markdown. */
|
package/dist/types/labels.d.ts
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Block } from '../model.js';
|
|
2
|
+
import type { BlockNode } from './ast.js';
|
|
3
|
+
import { type MarkdownOptions } from './options.js';
|
|
4
|
+
/**
|
|
5
|
+
* When top-level block `i` is an HTML block that leaves elements open, the
|
|
6
|
+
* index of the HTML block that closes them all. Returns `i` when there is
|
|
7
|
+
* nothing to join, including when the elements are never closed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function htmlSectionEnd(nodes: readonly BlockNode[], i: number): number;
|
|
10
|
+
/** Marks where the blocks of slot `index` go in a section's HTML. Private-use characters, so they never meet real text. */
|
|
11
|
+
export declare const slotMarker: (index: number) => string;
|
|
12
|
+
/** Finds slot markers in text. */
|
|
13
|
+
export declare const SLOT_MARKER: RegExp;
|
|
14
|
+
export interface HtmlSection {
|
|
15
|
+
/**
|
|
16
|
+
* The section's HTML, with each run of Markdown blocks replaced by
|
|
17
|
+
* `slotMarker(index)` on a line of its own between blank lines.
|
|
18
|
+
*/
|
|
19
|
+
readonly html: string;
|
|
20
|
+
/** The Markdown between the tags, as blocks, one list per slot. */
|
|
21
|
+
readonly slots: readonly (readonly Block[])[];
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Splits an HTML block's source into its HTML and the Markdown between its
|
|
25
|
+
* tags, as CommonMark reads it. Null when the source holds no Markdown
|
|
26
|
+
* blocks: it is all HTML.
|
|
27
|
+
*/
|
|
28
|
+
export declare function splitHtmlSection(source: string, options?: MarkdownOptions): HtmlSection | null;
|