@usememos/editor 26.10.14 → 26.10.16
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 +48 -10
- package/dist/base.css +58 -18
- package/dist/index.js +1014 -263
- package/dist/index.js.map +4 -4
- package/dist/react.js +2 -2
- package/dist/react.js.map +2 -2
- package/dist/style.css +86 -19
- package/dist/theme.css +17 -6
- package/dist/types/clipboard/fromHtml.d.ts +7 -0
- package/dist/types/commands.d.ts +3 -3
- package/dist/types/editor.d.ts +28 -1
- package/dist/types/extensions/tags.d.ts +13 -10
- package/dist/types/history.d.ts +11 -2
- package/dist/types/index.d.ts +1 -0
- package/dist/types/markdown/autolink.d.ts +14 -6
- package/dist/types/markdown/lower.d.ts +14 -3
- package/dist/types/model.d.ts +40 -3
- package/dist/types/react/index.d.ts +2 -2
- package/dist/types/sourceMode.d.ts +71 -0
- package/dist/types/theme.d.ts +1 -1
- package/dist/types/view/dom.d.ts +11 -1
- package/dist/types/view/reveal.d.ts +1 -1
- package/dist/types/widgets.d.ts +2 -0
- package/package.json +1 -1
package/dist/react.js
CHANGED
|
@@ -3,7 +3,7 @@ import { Editor } from "@usememos/editor";
|
|
|
3
3
|
import { forwardRef, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { flushSync } from "react-dom";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
var LIVE = ["placeholder", "editable", "taskToggle", "attributes", "resolveUrl", "onLinkClick", "theme", "extensions"];
|
|
6
|
+
var LIVE = ["placeholder", "mode", "editable", "taskToggle", "attributes", "resolveUrl", "onLinkClick", "theme", "extensions"];
|
|
7
7
|
var extensionKey = (extensions) => (extensions ?? []).map((e) => e.name).join("\n");
|
|
8
8
|
var MarkdownEditor = forwardRef(function MarkdownEditor2(props, ref) {
|
|
9
9
|
const container = useRef(null);
|
|
@@ -81,7 +81,7 @@ function useLiveOptions(editorRef, props) {
|
|
|
81
81
|
let any = false;
|
|
82
82
|
for (const key of LIVE) {
|
|
83
83
|
if (props[key] === applied.current.props[key]) continue;
|
|
84
|
-
changed[key] = key === "editable" ? props.editable ?? true : key === "taskToggle" ? props.taskToggle ?? false : props[key];
|
|
84
|
+
changed[key] = key === "editable" ? props.editable ?? true : key === "mode" ? props.mode ?? "rich" : key === "taskToggle" ? props.taskToggle ?? false : props[key];
|
|
85
85
|
any = true;
|
|
86
86
|
}
|
|
87
87
|
applied.current = { editor, props: { ...props } };
|
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 | 'linkCard'\n | 'slashMenu'\n | 'slashHint'\n | 'labels'\n | 'icons'\n>;\n\nexport interface MarkdownEditorProps extends EditorProps {\n /** Markdown. The editor updates only when this is not a value it emitted itself. */\n value?: string;\n /** Initial Markdown for uncontrolled use. */\n defaultValue?: string;\n /** Called after document changes, at most once per animation frame. */\n onChange?: (markdown: string) => void;\n /** Called on Mod+Enter or Ctrl+Enter with the current Markdown. */\n onSubmit?: (markdown: string) => void;\n onFocus?: () => void;\n onBlur?: () => void;\n className?: string;\n style?: CSSProperties;\n}\n\n/** Options that `setOptions` applies without recreating the editor. `extensions` updates suggestion callbacks only. */\nconst LIVE = ['placeholder', 'editable', 'taskToggle', 'attributes', 'resolveUrl', 'onLinkClick', 'theme', 'extensions'] as const;\n\n/** The extension list's identity for recreating the editor: names, so an inline array does not recreate it on every render. */\nconst extensionKey = (extensions: EditorOptions['extensions']) => (extensions ?? []).map((e) => e.name).join('\\n');\n\n/**\n * The editor as a controlled React component. A `ref` gives the core `Editor`.\n *\n * `placeholder`, `editable`, `taskToggle`, `attributes`, `resolveUrl`, `onLinkClick` and `theme` update live.\n * A change to the names in `extensions` recreates the editor, keeping its\n * Markdown; with the same names, the callbacks of `suggestion()` extensions\n * (`items`, `command`, `match`, `allow`) update live. Other props are read\n * when the editor is created; change the component's `key` to apply new values.\n *\n * A `value` that arrives while an input method is composing text is applied\n * when the composition ends, so it does not break the composition.\n */\nexport const MarkdownEditor = forwardRef(function MarkdownEditor(props: MarkdownEditorProps, ref: ForwardedRef<Editor | null>) {\n const container = useRef<HTMLDivElement>(null);\n const editorRef = useRef<Editor | null>(null);\n // Values the editor emitted that the parent has not passed back yet, oldest\n // first. While the user keeps typing, React may hand back an older one;\n // those echoes must not reset the document.\n const pending = useRef<string[]>([]);\n // An outside value that arrived during IME composition.\n const deferred = useRef<string | null>(null);\n // Callbacks are read through a ref so changing them does not recreate the editor.\n const latest = useRef(props);\n latest.current = props;\n const extensions = extensionKey(props.extensions);\n\n useEffect(() => {\n const { value, defaultValue, onChange, onSubmit, onFocus, onBlur, className, style, ...options } = latest.current;\n const previous = editorRef.current;\n const editor = new Editor({\n ...options,\n element: container.current!,\n content: previous?.getMarkdown() ?? value ?? defaultValue ?? '',\n onChange: (markdown) => {\n pending.current.push(markdown);\n if (pending.current.length > 100) pending.current.shift();\n // Render the parent's update now, as React does for a native input's\n // onChange. Left to React's scheduler, it can still be waiting when\n // the parent sets a new value (clearing the box on submit) that equals\n // the value it last rendered; the value effect would then not run.\n flushSync(() => latest.current.onChange?.(markdown));\n },\n onSubmit: (markdown) => latest.current.onSubmit?.(markdown),\n onFocus: () => latest.current.onFocus?.(),\n onBlur: () => latest.current.onBlur?.(),\n });\n editorRef.current = editor;\n pending.current = [];\n assignRef(ref, editor);\n const root = container.current!;\n const onCompositionEnd = () => {\n // Runs after the editor's own compositionend handler, which was added first.\n const value = deferred.current;\n deferred.current = null;\n if (value !== null && value !== editor.getMarkdown()) {\n pending.current = [];\n editor.setMarkdown(value);\n }\n };\n root.addEventListener('compositionend', onCompositionEnd);\n return () => {\n root.removeEventListener('compositionend', onCompositionEnd);\n editor.destroy();\n if (editorRef.current === editor) editorRef.current = null;\n assignRef(ref, null);\n };\n // Recreate only when the extension names change; see the note on the component.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [extensions]);\n\n useEffect(() => {\n const editor = editorRef.current;\n if (!editor || props.value === undefined) return;\n const echo = pending.current.indexOf(props.value);\n if (echo >= 0) {\n // The parent caught up to a value the editor emitted.\n pending.current.splice(0, echo + 1);\n return;\n }\n if (props.value === editor.getMarkdown()) return;\n if (editor.isComposing) {\n deferred.current = props.value;\n return;\n }\n pending.current = [];\n editor.setMarkdown(props.value);\n }, [props.value]);\n\n useLiveOptions(editorRef, props);\n\n return <div ref={container} className={props.className} style={props.style} />;\n});\n\n/** Applies the live options when they change. */\nfunction useLiveOptions(editorRef: { current: Editor | null }, props: EditorProps): void {\n const applied = useRef<{ editor: Editor | null; props: Partial<EditorProps> }>({ editor: null, props: {} });\n useEffect(() => {\n const editor = editorRef.current;\n if (!editor) return;\n if (applied.current.editor !== editor) {\n // A new editor was created with these props.\n applied.current = { editor, props: { ...props } };\n return;\n }\n const changed: Partial<Pick<EditorOptions, (typeof LIVE)[number]>> = {};\n let any = false;\n for (const key of LIVE) {\n if (props[key] === applied.current.props[key]) continue;\n (changed as Record<string, unknown>)[key] = key === 'editable' ? (props.editable ?? true) : key === 'taskToggle' ? (props.taskToggle ?? false) : props[key];\n any = true;\n }\n applied.current = { editor, props: { ...props } };\n if (any) editor.setOptions(changed);\n });\n}\n\n/**\n * Creates an editor for the lifetime of the component, or until a value in\n * `deps` changes. Returns null until the editor exists. Pair it with\n * `<EditorContent editor={editor} />`, which shows it.\n *\n * Callbacks in `options` are read when called, so they may change between\n * renders without recreating the editor. So do the callbacks of\n * `suggestion()` extensions, matched by name.\n */\nexport function useEditor(options: Omit<EditorOptions, 'element'>, deps: readonly unknown[] = []): Editor | null {\n const [editor, setEditor] = useState<Editor | null>(null);\n const latest = useRef(options);\n latest.current = options;\n\n useEffect(() => {\n if (editor && options.extensions) editor.setOptions({ extensions: options.extensions });\n }, [editor, options.extensions]);\n\n useEffect(() => {\n const o = latest.current;\n const element = document.createElement('div');\n const instance = new Editor({\n ...o,\n element,\n // A detached element cannot take focus; EditorContent focuses once mounted.\n autofocus: false,\n onChange: (markdown, e) => latest.current.onChange?.(markdown, e),\n onSubmit: (markdown, e) => latest.current.onSubmit?.(markdown, e),\n onFocus: (e) => latest.current.onFocus?.(e),\n onBlur: (e) => latest.current.onBlur?.(e),\n onLinkClick: (ctx) => latest.current.onLinkClick?.(ctx),\n });\n if (o.autofocus) pendingAutofocus.set(instance, o.autofocus === 'end' ? 'end' : 'start');\n setEditor(instance);\n return () => {\n instance.destroy();\n setEditor(null);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, deps);\n\n return editor;\n}\n\n/**\n * The open autocomplete popup of `editor`, or of its suggestion `name`, and\n * a re-render on each change. With `render: false` on a suggestion, draw your\n * own popup from it: put it at `state.anchorRect()`, give the listbox\n * `id={state.listboxId}` and each option `id={state.optionId(i)}`, highlight\n * `state.active`, and call `editor.suggestion.accept(i)` on click.\n */\nexport function useSuggestion(editor: Editor | null, name?: string): SuggestionState | null {\n const select = (state: SuggestionState | null | undefined) => (state && (name === undefined || state.name === name) ? state : null);\n const [state, setState] = useState<SuggestionState | null>(() => select(editor?.suggestion.state));\n useEffect(() => {\n if (!editor) {\n setState(null);\n return;\n }\n setState(select(editor.suggestion.state));\n return editor.on('suggestionChange', ({ state }) => setState(select(state)));\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [editor, name]);\n return state;\n}\n\nexport interface EditorContentProps {\n editor: Editor | null;\n className?: string;\n style?: CSSProperties;\n}\n\n/** Shows an editor created with `useEditor`. */\nexport function EditorContent({ editor, className, style }: EditorContentProps) {\n const container = useRef<HTMLDivElement>(null);\n useEffect(() => {\n const host = container.current;\n if (!editor || !host) return;\n host.appendChild(editor.root);\n const autofocus = pendingAutofocus.get(editor);\n if (autofocus) {\n pendingAutofocus.delete(editor);\n editor.commands.focus(autofocus);\n }\n return () => {\n if (editor.root.parentNode === host) host.removeChild(editor.root);\n };\n }, [editor]);\n return <div ref={container} className={className} style={style} />;\n}\n\n/** Where to focus an editor from `useEditor` once `EditorContent` mounts it. */\nconst pendingAutofocus = new WeakMap<Editor, 'start' | 'end'>();\n\nfunction assignRef<T>(ref: ForwardedRef<T>, value: T): 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 | 'mode'\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', 'mode', '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`, `mode`, `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 === 'mode' ? (props.mode ?? 'rich') : 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;AA2IjB;AA/FT,IAAM,OAAO,CAAC,eAAe,QAAQ,YAAY,cAAc,cAAc,cAAc,eAAe,SAAS,YAAY;AAG/H,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,OAAsB,IAAI;AAI5C,QAAM,UAAU,OAAiB,C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,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
|
@@ -39,21 +39,52 @@
|
|
|
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;
|
|
44
47
|
padding-top: var(--mbe-block-gap);
|
|
45
48
|
}
|
|
46
|
-
.mbe-root .mbe-
|
|
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] {
|
|
62
|
+
padding-top: var(--mbe-block-gap);
|
|
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);
|
|
47
71
|
display: flex;
|
|
48
72
|
align-items: center;
|
|
49
|
-
|
|
73
|
+
justify-content: center;
|
|
74
|
+
width: 24px;
|
|
75
|
+
height: 1.5em;
|
|
76
|
+
height: 1lh;
|
|
50
77
|
user-select: none;
|
|
51
78
|
-webkit-user-select: none;
|
|
52
79
|
}
|
|
53
|
-
|
|
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 {
|
|
54
85
|
display: none;
|
|
55
86
|
}
|
|
56
|
-
.mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-
|
|
87
|
+
.mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-icon {
|
|
57
88
|
cursor: pointer;
|
|
58
89
|
}
|
|
59
90
|
:is(.mbe-root, .mbe-flow) > .mbe-details {
|
|
@@ -113,21 +144,36 @@
|
|
|
113
144
|
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-list-start] {
|
|
114
145
|
margin-top: var(--mbe-block-gap);
|
|
115
146
|
}
|
|
116
|
-
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="1"] {
|
|
147
|
+
:is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="1"] {
|
|
117
148
|
padding-inline-start: var(--mbe-indent-size);
|
|
118
149
|
}
|
|
119
|
-
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="2"] {
|
|
150
|
+
:is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="2"] {
|
|
120
151
|
padding-inline-start: calc(2 * var(--mbe-indent-size));
|
|
121
152
|
}
|
|
122
|
-
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="3"] {
|
|
153
|
+
:is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="3"] {
|
|
123
154
|
padding-inline-start: calc(3 * var(--mbe-indent-size));
|
|
124
155
|
}
|
|
125
|
-
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="4"] {
|
|
156
|
+
:is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="4"] {
|
|
126
157
|
padding-inline-start: calc(4 * var(--mbe-indent-size));
|
|
127
158
|
}
|
|
128
|
-
:is(.mbe-root, .mbe-flow) > .mbe-list-item[data-indent="5"] {
|
|
159
|
+
:is(.mbe-root, .mbe-flow) > div.mbe-list-item[data-indent="5"] {
|
|
129
160
|
padding-inline-start: calc(5 * var(--mbe-indent-size));
|
|
130
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
|
+
}
|
|
131
177
|
.mbe-root .mbe-marker {
|
|
132
178
|
flex: none;
|
|
133
179
|
box-sizing: border-box;
|
|
@@ -250,6 +296,11 @@
|
|
|
250
296
|
white-space: pre-wrap;
|
|
251
297
|
tab-size: 2;
|
|
252
298
|
}
|
|
299
|
+
.mbe-root > .mbe-source {
|
|
300
|
+
white-space: pre-wrap;
|
|
301
|
+
tab-size: 4;
|
|
302
|
+
overflow-wrap: anywhere;
|
|
303
|
+
}
|
|
253
304
|
:is(.mbe-root, .mbe-flow) > .mbe-code pre {
|
|
254
305
|
margin: 0;
|
|
255
306
|
}
|
|
@@ -337,20 +388,22 @@
|
|
|
337
388
|
}
|
|
338
389
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
339
390
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
340
|
-
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
391
|
+
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
|
|
341
392
|
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
342
|
-
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before
|
|
393
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before,
|
|
394
|
+
.mbe-root > .mbe-source.mbe-empty:only-child > .mbe-source-text::before {
|
|
343
395
|
opacity: 0.5;
|
|
344
396
|
pointer-events: none;
|
|
345
397
|
position: absolute;
|
|
346
398
|
}
|
|
347
|
-
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before
|
|
399
|
+
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
400
|
+
.mbe-root > .mbe-source.mbe-empty:only-child > .mbe-source-text::before {
|
|
348
401
|
content: var(--mbe-placeholder, "");
|
|
349
402
|
}
|
|
350
403
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before {
|
|
351
404
|
content: var(--mbe-slash-hint, "");
|
|
352
405
|
}
|
|
353
|
-
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
406
|
+
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
|
|
354
407
|
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
355
408
|
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before {
|
|
356
409
|
content: attr(data-hint);
|
|
@@ -771,7 +824,17 @@
|
|
|
771
824
|
}
|
|
772
825
|
:is(.mbe-root, .mbe-flow) > blockquote[data-callout] {
|
|
773
826
|
color: inherit;
|
|
774
|
-
border-inline-start
|
|
827
|
+
border-inline-start: 0;
|
|
828
|
+
border-radius: var(--mbe-radius);
|
|
829
|
+
background: color-mix(in oklab, var(--mbe-callout) 10%, transparent);
|
|
830
|
+
}
|
|
831
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-joined] {
|
|
832
|
+
border-start-start-radius: 0;
|
|
833
|
+
border-start-end-radius: 0;
|
|
834
|
+
}
|
|
835
|
+
:is(.mbe-root, .mbe-flow) > blockquote[data-callout][data-quote-continued] {
|
|
836
|
+
border-end-start-radius: 0;
|
|
837
|
+
border-end-end-radius: 0;
|
|
775
838
|
}
|
|
776
839
|
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=note] {
|
|
777
840
|
--mbe-callout: var(--mbe-callout-note);
|
|
@@ -788,9 +851,12 @@
|
|
|
788
851
|
:is(.mbe-root, .mbe-flow) > blockquote[data-callout=caution] {
|
|
789
852
|
--mbe-callout: var(--mbe-callout-caution);
|
|
790
853
|
}
|
|
791
|
-
.mbe-root .mbe-callout-
|
|
854
|
+
.mbe-root .mbe-callout-icon {
|
|
792
855
|
color: var(--mbe-callout);
|
|
793
|
-
|
|
856
|
+
border-radius: 4px;
|
|
857
|
+
}
|
|
858
|
+
.mbe-root:not(.mbe-readonly) > blockquote > .mbe-callout-icon:hover {
|
|
859
|
+
background: color-mix(in oklab, var(--mbe-callout) 14%, transparent);
|
|
794
860
|
}
|
|
795
861
|
.mbe-root .mbe-marker {
|
|
796
862
|
color: var(--mbe-muted);
|
|
@@ -972,9 +1038,10 @@
|
|
|
972
1038
|
}
|
|
973
1039
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
974
1040
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
975
|
-
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
1041
|
+
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
|
|
976
1042
|
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
977
|
-
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before
|
|
1043
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before,
|
|
1044
|
+
.mbe-root > .mbe-source.mbe-empty:only-child > .mbe-source-text::before {
|
|
978
1045
|
color: var(--mbe-muted);
|
|
979
1046
|
opacity: 0.7;
|
|
980
1047
|
}
|
package/dist/theme.css
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
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,
|
|
44
|
+
/* Callout colors: the icon, and a tint of it behind the text. */
|
|
45
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
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
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)));
|
|
@@ -120,14 +120,24 @@
|
|
|
120
120
|
color: var(--mbe-muted);
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
/* Callouts: the type's color
|
|
124
|
-
|
|
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; }
|
|
125
134
|
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='note'] { --mbe-callout: var(--mbe-callout-note); }
|
|
126
135
|
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='tip'] { --mbe-callout: var(--mbe-callout-tip); }
|
|
127
136
|
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='important'] { --mbe-callout: var(--mbe-callout-important); }
|
|
128
137
|
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='warning'] { --mbe-callout: var(--mbe-callout-warning); }
|
|
129
138
|
:is(.mbe-root, .mbe-flow) > blockquote[data-callout='caution'] { --mbe-callout: var(--mbe-callout-caution); }
|
|
130
|
-
.mbe-root .mbe-callout-
|
|
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); }
|
|
131
141
|
|
|
132
142
|
/* Lists */
|
|
133
143
|
.mbe-root .mbe-marker { color: var(--mbe-muted); }
|
|
@@ -230,9 +240,10 @@
|
|
|
230
240
|
/* Placeholders and hints */
|
|
231
241
|
.mbe-root > .mbe-paragraph.mbe-empty:only-child::before,
|
|
232
242
|
.mbe-root > .mbe-paragraph.mbe-empty.mbe-show-hint::before,
|
|
233
|
-
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote)::before,
|
|
243
|
+
.mbe-root:not(.mbe-readonly) > .mbe-empty[data-hint]:is(h1, h2, h3, h4, h5, h6, blockquote:not(.mbe-list-item))::before,
|
|
234
244
|
.mbe-root:not(.mbe-readonly) > .mbe-list-item.mbe-empty[data-hint] > .mbe-content::before,
|
|
235
|
-
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before
|
|
245
|
+
.mbe-root:not(.mbe-readonly) > .mbe-details.mbe-empty[data-hint] > .mbe-content::before,
|
|
246
|
+
.mbe-root > .mbe-source.mbe-empty:only-child > .mbe-source-text::before {
|
|
236
247
|
color: var(--mbe-muted);
|
|
237
248
|
opacity: 0.7;
|
|
238
249
|
}
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
import { type Doc } from '../model.js';
|
|
2
2
|
export declare function htmlToDoc(html: string, parser?: DOMParser): Doc;
|
|
3
|
+
/**
|
|
4
|
+
* Whether clipboard HTML only lays out and colors plain text, as code
|
|
5
|
+
* editors and terminals write it: lines as `<div>`s of colored `<span>`s,
|
|
6
|
+
* with no headings, lists, links or bold. Markdown copied from such an app
|
|
7
|
+
* arrives this way, so its plain text is read as Markdown instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isStyledText(html: string): boolean;
|
package/dist/types/commands.d.ts
CHANGED
|
@@ -121,14 +121,14 @@ export type BlockTypeSpec = {
|
|
|
121
121
|
*/
|
|
122
122
|
export declare function setBlockType(state: EditorState, spec: BlockTypeSpec): EditorState;
|
|
123
123
|
/**
|
|
124
|
-
* The
|
|
125
|
-
* neighbours
|
|
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
126
|
*/
|
|
127
127
|
export declare function quoteRun(state: EditorState, blockId: string): {
|
|
128
128
|
start: number;
|
|
129
129
|
end: number;
|
|
130
130
|
} | null;
|
|
131
|
-
/** Sets the callout of the whole blockquote with the
|
|
131
|
+
/** Sets the callout of the whole blockquote with the block `blockId`; null makes it a plain quote. */
|
|
132
132
|
export declare function setCallout(state: EditorState, blockId: string, callout: CalloutType | null): EditorState;
|
|
133
133
|
/** The blocks the selection touches whose type the block type commands change. */
|
|
134
134
|
export declare function convertibleBlocks(state: EditorState): Exclude<TextBlock, RawBlock>[];
|
package/dist/types/editor.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { type Block, type CalloutType, type EditorState, type HeadingLevel, type
|
|
|
10
10
|
import { type ToolbarItem } from './ui/toolbar.js';
|
|
11
11
|
import { type ResolveUrl } from './view/dom.js';
|
|
12
12
|
import { type Theme } from './theme.js';
|
|
13
|
+
import { type EditorMode } from './sourceMode.js';
|
|
13
14
|
export interface EditorOptions {
|
|
14
15
|
/** The element the editor renders into. */
|
|
15
16
|
element: HTMLElement;
|
|
@@ -25,6 +26,8 @@ export interface EditorOptions {
|
|
|
25
26
|
editable?: boolean;
|
|
26
27
|
/** While `editable` is false, lets the user tick and untick task items. Default false. */
|
|
27
28
|
taskToggle?: boolean;
|
|
29
|
+
/** `'source'` shows the whole document as its Markdown text. Default `'rich'`. */
|
|
30
|
+
mode?: EditorMode;
|
|
28
31
|
/** Focus on creation: `true` or `'start'` puts the caret at the start, `'end'` at the end. */
|
|
29
32
|
autofocus?: boolean | 'start' | 'end';
|
|
30
33
|
/** Attributes for the editable root, such as `autocorrect` or `aria-label`. */
|
|
@@ -101,7 +104,7 @@ export interface EditorOptions {
|
|
|
101
104
|
onBlur?: (editor: Editor) => void;
|
|
102
105
|
}
|
|
103
106
|
/** Options that `setOptions` can change while the editor runs. */
|
|
104
|
-
export type RuntimeOptions = Pick<EditorOptions, 'placeholder' | 'editable' | 'taskToggle' | 'attributes' | 'resolveUrl' | 'onLinkClick' | 'theme' | 'extensions'>;
|
|
107
|
+
export type RuntimeOptions = Pick<EditorOptions, 'placeholder' | 'editable' | 'taskToggle' | 'mode' | 'attributes' | 'resolveUrl' | 'onLinkClick' | 'theme' | 'extensions'>;
|
|
105
108
|
export interface EditorEvents {
|
|
106
109
|
/** After document changes, at most once per animation frame. */
|
|
107
110
|
change: {
|
|
@@ -250,6 +253,10 @@ export declare class Editor {
|
|
|
250
253
|
/** The Markdown dialect: options plus the syntax of extensions. */
|
|
251
254
|
private readonly markdown;
|
|
252
255
|
private readonly history;
|
|
256
|
+
/** Rich blocks, or the whole document as text in one block (see sourceMode.ts). */
|
|
257
|
+
private modeValue;
|
|
258
|
+
/** A mode switch asked for during a composition, applied when it settles. */
|
|
259
|
+
private pendingMode;
|
|
253
260
|
private readonly renderer;
|
|
254
261
|
private composing;
|
|
255
262
|
/**
|
|
@@ -345,6 +352,8 @@ export declare class Editor {
|
|
|
345
352
|
get state(): EditorState;
|
|
346
353
|
/** True while an input method (IME) is composing text. Replacing the document now would break the composition. */
|
|
347
354
|
get isComposing(): boolean;
|
|
355
|
+
/** `'rich'` or `'source'`: the mode the editor shows now. */
|
|
356
|
+
get mode(): EditorMode;
|
|
348
357
|
get isEditable(): boolean;
|
|
349
358
|
/** True after `destroy()`. The editor then ignores every call that would change it; `getMarkdown()` still returns its last Markdown. */
|
|
350
359
|
get isDestroyed(): boolean;
|
|
@@ -387,6 +396,20 @@ export declare class Editor {
|
|
|
387
396
|
* by name; other changes to extensions need a new editor.
|
|
388
397
|
*/
|
|
389
398
|
setOptions(options: RuntimeOptions): void;
|
|
399
|
+
/**
|
|
400
|
+
* Shows the document as blocks or as its Markdown text. The text does not
|
|
401
|
+
* change, so this emits no `change` and records no undo step. During a
|
|
402
|
+
* composition the switch waits for it to settle.
|
|
403
|
+
*/
|
|
404
|
+
private setMode;
|
|
405
|
+
/** Rich blocks to text: the text is `getMarkdown()`; the selection and widgets keep their blocks. */
|
|
406
|
+
private enterSource;
|
|
407
|
+
/** Text to rich blocks, loaded as `setMarkdown` does, so the text saves byte for byte. */
|
|
408
|
+
private leaveSource;
|
|
409
|
+
/** Loads text as the document's blocks, with an empty paragraph for empty text, and makes its source current. */
|
|
410
|
+
private loadSource;
|
|
411
|
+
/** A history entry, in the current mode: an entry made in the other mode is serialized or loaded. */
|
|
412
|
+
private restore;
|
|
390
413
|
/** Subscribes to an event. Returns a function that unsubscribes. */
|
|
391
414
|
on<K extends keyof EditorEvents>(type: K, handler: (payload: EditorEvents[K]) => void): () => void;
|
|
392
415
|
private emit;
|
|
@@ -397,6 +420,8 @@ export declare class Editor {
|
|
|
397
420
|
run(command: (state: EditorState) => EditorState | null, kind?: ChangeKind): boolean;
|
|
398
421
|
private createCommands;
|
|
399
422
|
private toggleMark;
|
|
423
|
+
/** `insertMarkdown` in source mode: the Markdown is inserted as text. */
|
|
424
|
+
private insertSourceMarkdown;
|
|
400
425
|
private undo;
|
|
401
426
|
private redo;
|
|
402
427
|
/** Scrolls the editor and the elements around it so the caret is visible. */
|
|
@@ -505,6 +530,8 @@ export declare class Editor {
|
|
|
505
530
|
/** Events from the code-language input and other form controls inside the root are not editor input. */
|
|
506
531
|
private fromControl;
|
|
507
532
|
private onBeforeInput;
|
|
533
|
+
/** Input that works differently on text in source mode. Returns true when handled. */
|
|
534
|
+
private onSourceInput;
|
|
508
535
|
private typeText;
|
|
509
536
|
/**
|
|
510
537
|
* True for input the `input` handler can read back from the DOM: text typed
|
|
@@ -15,19 +15,22 @@ export interface TagsOptions {
|
|
|
15
15
|
readonly scan?: TagScanner;
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
|
-
* The default tag grammar
|
|
19
|
-
* by `/`. A segment
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
18
|
+
* The default tag grammar, memos': `#` and one or more segments separated
|
|
19
|
+
* by `/`. A segment is letters, digits and other Unicode identifier
|
|
20
|
+
* characters (XID_Continue), `-`, `+`, `&`, emoji, and an apostrophe between
|
|
21
|
+
* two letters (`#tag's`); it does not start with a combining mark. Anything
|
|
22
|
+
* may come before the `#` (`3pm#work`), and a `#` inside an emoji (the keycap `#`)
|
|
23
|
+
* starts no tag. `#2024` is a tag. A trailing `/` is not part of a tag.
|
|
24
24
|
*/
|
|
25
25
|
export declare function scanTags(text: string, from?: number, to?: number): Generator<TextRange>;
|
|
26
26
|
/**
|
|
27
|
-
* The default mention grammar: `@` and
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* `
|
|
27
|
+
* The default mention grammar, memos' usernames: `@` and up to 36 ASCII
|
|
28
|
+
* letters, digits and `-`, starting and ending with a letter or digit. The
|
|
29
|
+
* character before the `@` is not a username character (`中文@dave` is a
|
|
30
|
+
* mention, `foo@bar` is not); formatting that starts right at the `@`
|
|
31
|
+
* counts as a boundary, as its delimiter does in the Markdown. A name that
|
|
32
|
+
* runs on into a character it cannot hold, such as `-` at the end or an
|
|
33
|
+
* accented letter (`@alicé`), is no mention.
|
|
31
34
|
*/
|
|
32
35
|
export declare function scanMentions(text: string, from?: number, to?: number): Generator<TextRange>;
|
|
33
36
|
/** `#tag` highlighting and `\#` escapes. */
|
package/dist/types/history.d.ts
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
|
+
import type { MarkdownSource } from './markdown/source.js';
|
|
1
2
|
import type { EditorState } from './model.js';
|
|
2
3
|
export type ChangeKind = 'typing' | 'other';
|
|
4
|
+
/** A restored entry: the state, and the source to save it with. */
|
|
5
|
+
export interface Restored {
|
|
6
|
+
state: EditorState;
|
|
7
|
+
source: MarkdownSource;
|
|
8
|
+
}
|
|
3
9
|
export declare class History {
|
|
10
|
+
private readonly source;
|
|
4
11
|
private undoStack;
|
|
5
12
|
private redoStack;
|
|
6
13
|
private lastKind;
|
|
7
14
|
private lastTime;
|
|
15
|
+
/** `source` reads the source current when an entry is recorded. */
|
|
16
|
+
constructor(source: () => MarkdownSource);
|
|
8
17
|
/** Call before applying a change, with the state the change starts from. */
|
|
9
18
|
record(before: EditorState, kind: ChangeKind, now?: number): void;
|
|
10
19
|
clear(): void;
|
|
11
20
|
/** Ends the current typing group, e.g. when the caret moves. */
|
|
12
21
|
breakGroup(): void;
|
|
13
|
-
undo(current: EditorState):
|
|
14
|
-
redo(current: EditorState):
|
|
22
|
+
undo(current: EditorState): Restored | null;
|
|
23
|
+
redo(current: EditorState): Restored | null;
|
|
15
24
|
/** Moves the newest entry of `from` back into the document, and the current state onto `to`. */
|
|
16
25
|
private step;
|
|
17
26
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { parseMarkdown } from './markdown/parse.js';
|
|
|
8
8
|
export { parseInline } from './markdown/inline.js';
|
|
9
9
|
export { serializeMarkdown, serializeInline, type SerializeOptions } from './markdown/serialize.js';
|
|
10
10
|
export { loadMarkdown, type MarkdownSource } from './markdown/source.js';
|
|
11
|
+
export type { EditorMode } from './sourceMode.js';
|
|
11
12
|
export type { MarkdownOptions } from './markdown/options.js';
|
|
12
13
|
export { docToHtml } from './clipboard/toHtml.js';
|
|
13
14
|
export { htmlToDoc } from './clipboard/fromHtml.js';
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Whether a URL literal may start after `prev
|
|
3
|
-
* start of
|
|
2
|
+
* Whether a URL literal may start after `prev`, as in cmark-gfm. A `www.`
|
|
3
|
+
* literal starts at the start of the text, after a space, tab or line break, or after `*`,
|
|
4
|
+
* `_`, `~` or `(`. A scheme starts after anything but an ASCII letter, which
|
|
5
|
+
* would be part of the scheme: `0http://a.b` holds a link, `xhttp://a.b` none.
|
|
4
6
|
*/
|
|
5
|
-
export declare function isLiteralBoundary(prev: string | undefined): boolean;
|
|
7
|
+
export declare function isLiteralBoundary(prev: string | undefined, www: boolean): boolean;
|
|
6
8
|
/**
|
|
7
9
|
* A `www.`, `http(s)://` or `ftp://` literal starting at `pos`: its end
|
|
8
|
-
* (exclusive) and link destination, or null.
|
|
9
|
-
* before `pos`.
|
|
10
|
+
* (exclusive) and link destination, or null. `www.` and the scheme may be in
|
|
11
|
+
* any case, as on github.com. The caller checks the boundary before `pos`.
|
|
10
12
|
*/
|
|
11
13
|
export declare function urlLiteralAt(text: string, pos: number): {
|
|
12
14
|
end: number;
|
|
13
15
|
href: string;
|
|
14
16
|
} | null;
|
|
15
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* E-mail literals in plain text, as cmark-gfm finds them: `[from, to)`
|
|
19
|
+
* ranges. Before the "@", ASCII letters, digits, ".", "+", "-" and "_";
|
|
20
|
+
* after it, letters, digits, "-", "_" and periods followed by a letter or
|
|
21
|
+
* digit, with at least one period. The address ends with a letter, so
|
|
22
|
+
* `react@0.11.1` is not one.
|
|
23
|
+
*/
|
|
16
24
|
export declare function emailLiterals(text: string): {
|
|
17
25
|
from: number;
|
|
18
26
|
to: number;
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
import { type Block, type Span } from '../model.js';
|
|
1
|
+
import { type Block, type CalloutType, type Span } from '../model.js';
|
|
2
2
|
import { type BlockNode, type InlineNode } from './ast.js';
|
|
3
3
|
import { type MarkdownOptions } from './options.js';
|
|
4
4
|
/**
|
|
5
5
|
* Lowers one top-level block node. Structure the model cannot hold becomes
|
|
6
|
-
* one raw Markdown block holding `source`, the node's Markdown.
|
|
6
|
+
* one raw Markdown block holding `source`, the node's Markdown. `before` is
|
|
7
|
+
* the last block lowered before it.
|
|
7
8
|
*/
|
|
8
|
-
export declare function lowerTopLevel(node: BlockNode, options: MarkdownOptions, source: string): Block[];
|
|
9
|
+
export declare function lowerTopLevel(node: BlockNode, options: MarkdownOptions, source: string, before?: Block): Block[];
|
|
10
|
+
/** Lowers one block node, or returns null when the model cannot hold its structure (see `fitsModel`). */
|
|
11
|
+
export declare function lowerIfFits(node: BlockNode, options: MarkdownOptions, before?: Block): Block[] | null;
|
|
9
12
|
export declare function lowerInlines(nodes: readonly InlineNode[], options?: MarkdownOptions): Span[];
|
|
13
|
+
/**
|
|
14
|
+
* A GitHub alert: the first paragraph starts with a marker such as `[!NOTE]`
|
|
15
|
+
* alone on its line. Returns its type and the paragraph's content after the marker line.
|
|
16
|
+
*/
|
|
17
|
+
export declare function calloutOf(children: readonly BlockNode[]): {
|
|
18
|
+
type: CalloutType;
|
|
19
|
+
rest: readonly InlineNode[];
|
|
20
|
+
} | null;
|