@usememos/editor 0.0.0-stage → 26.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +246 -2
- package/dist/base.css +218 -0
- package/dist/entities.dom.js +14 -0
- package/dist/entities.dom.js.map +7 -0
- package/dist/entities.js +17 -0
- package/dist/entities.js.map +7 -0
- package/dist/index.js +7304 -0
- package/dist/index.js.map +7 -0
- package/dist/react.js +143 -0
- package/dist/react.js.map +7 -0
- package/dist/style.css +592 -0
- package/dist/theme.css +214 -0
- package/dist/types/clipboard/fromHtml.d.ts +2 -0
- package/dist/types/clipboard/toHtml.d.ts +4 -0
- package/dist/types/commands.d.ts +168 -0
- package/dist/types/decorations.d.ts +40 -0
- package/dist/types/editor.d.ts +408 -0
- package/dist/types/extension.d.ts +70 -0
- package/dist/types/extensions/fileHandler.d.ts +28 -0
- package/dist/types/extensions/footnotes.d.ts +2 -0
- package/dist/types/extensions/keymap.d.ts +2 -0
- package/dist/types/extensions/math.d.ts +15 -0
- package/dist/types/extensions/suggestion.d.ts +51 -0
- package/dist/types/extensions/tags.d.ts +34 -0
- package/dist/types/extensions/textDecorator.d.ts +17 -0
- package/dist/types/history.d.ts +17 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/keymap.d.ts +12 -0
- package/dist/types/labels.d.ts +41 -0
- package/dist/types/markdown/ast.d.ts +129 -0
- package/dist/types/markdown/autolink.d.ts +21 -0
- package/dist/types/markdown/blocks.d.ts +4 -0
- package/dist/types/markdown/entities.d.ts +2 -0
- package/dist/types/markdown/entities.dom.d.ts +2 -0
- package/dist/types/markdown/html.d.ts +2 -0
- package/dist/types/markdown/inline.d.ts +35 -0
- package/dist/types/markdown/lower.d.ts +9 -0
- package/dist/types/markdown/options.d.ts +75 -0
- package/dist/types/markdown/parse.d.ts +4 -0
- package/dist/types/markdown/serialize.d.ts +24 -0
- package/dist/types/markdown/source.d.ts +30 -0
- package/dist/types/model.d.ts +205 -0
- package/dist/types/react/index.d.ts +47 -0
- package/dist/types/theme.d.ts +87 -0
- package/dist/types/ui/handle.d.ts +16 -0
- package/dist/types/ui/popup.d.ts +58 -0
- package/dist/types/ui/toolbar.d.ts +28 -0
- package/dist/types/view/dom.d.ts +85 -0
- package/dist/types/view/reveal.d.ts +12 -0
- package/dist/types/widgets.d.ts +26 -0
- package/package.json +58 -4
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Editor, type EditorOptions } from '@usememos/editor';
|
|
2
|
+
import { type CSSProperties } from 'react';
|
|
3
|
+
export type { Editor } from '@usememos/editor';
|
|
4
|
+
/** Constructor options that the React components take as props. */
|
|
5
|
+
type EditorProps = Pick<EditorOptions, 'markdown' | 'extensions' | 'placeholder' | 'editable' | 'autofocus' | 'attributes' | 'resolveImageSrc' | 'theme' | 'toolbar' | 'slashMenu' | 'labels'>;
|
|
6
|
+
export interface MarkdownEditorProps extends EditorProps {
|
|
7
|
+
/** Markdown. The editor updates only when this is not a value it emitted itself. */
|
|
8
|
+
value?: string;
|
|
9
|
+
/** Initial Markdown for uncontrolled use. */
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
/** Called after document changes, at most once per animation frame. */
|
|
12
|
+
onChange?: (markdown: string) => void;
|
|
13
|
+
/** Called on Mod+Enter or Ctrl+Enter with the current Markdown. */
|
|
14
|
+
onSubmit?: (markdown: string) => void;
|
|
15
|
+
onFocus?: () => void;
|
|
16
|
+
onBlur?: () => void;
|
|
17
|
+
className?: string;
|
|
18
|
+
style?: CSSProperties;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The editor as a controlled React component. A `ref` gives the core `Editor`.
|
|
22
|
+
*
|
|
23
|
+
* `placeholder`, `editable`, `attributes`, `resolveImageSrc` and `theme` update live.
|
|
24
|
+
* A change to the names in `extensions` recreates the editor, keeping its
|
|
25
|
+
* Markdown. Other props are read when the editor is created; change the
|
|
26
|
+
* component's `key` to apply new values.
|
|
27
|
+
*
|
|
28
|
+
* A `value` that arrives while an input method is composing text is applied
|
|
29
|
+
* when the composition ends, so it does not break the composition.
|
|
30
|
+
*/
|
|
31
|
+
export declare const MarkdownEditor: import("react").ForwardRefExoticComponent<MarkdownEditorProps & import("react").RefAttributes<Editor | null>>;
|
|
32
|
+
/**
|
|
33
|
+
* Creates an editor for the lifetime of the component, or until a value in
|
|
34
|
+
* `deps` changes. Returns null until the editor exists. Pair it with
|
|
35
|
+
* `<EditorContent editor={editor} />`, which shows it.
|
|
36
|
+
*
|
|
37
|
+
* Callbacks in `options` are read when called, so they may change between
|
|
38
|
+
* renders without recreating the editor.
|
|
39
|
+
*/
|
|
40
|
+
export declare function useEditor(options: Omit<EditorOptions, 'element'>, deps?: readonly unknown[]): Editor | null;
|
|
41
|
+
export interface EditorContentProps {
|
|
42
|
+
editor: Editor | null;
|
|
43
|
+
className?: string;
|
|
44
|
+
style?: CSSProperties;
|
|
45
|
+
}
|
|
46
|
+
/** Shows an editor created with `useEditor`. */
|
|
47
|
+
export declare function EditorContent({ editor, className, style }: EditorContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { HeadingLevel } from './model.js';
|
|
2
|
+
/**
|
|
3
|
+
* Classes added to each rendered element of a type, next to the editor's own
|
|
4
|
+
* `mbe-*` classes, in editing and read-only alike. Keys use the names of
|
|
5
|
+
* `isActive`, plus `image` and `token`. Values are class strings, such as Tailwind utilities.
|
|
6
|
+
*/
|
|
7
|
+
export interface ThemeClasses {
|
|
8
|
+
/** `<p>` */
|
|
9
|
+
readonly paragraph?: string;
|
|
10
|
+
/** `<h1>` to `<h6>`, by level. */
|
|
11
|
+
readonly heading?: Readonly<Partial<Record<HeadingLevel, string>>>;
|
|
12
|
+
/** `<blockquote>`, one per quote paragraph. */
|
|
13
|
+
readonly blockquote?: string;
|
|
14
|
+
/** Each list item of that type. Blocks are flat, so there is no list container. */
|
|
15
|
+
readonly bulletList?: string;
|
|
16
|
+
readonly orderedList?: string;
|
|
17
|
+
readonly taskList?: string;
|
|
18
|
+
/** The code block's frame, around its language bar and `<pre>`. */
|
|
19
|
+
readonly codeBlock?: string;
|
|
20
|
+
/** The table's frame, around the `<table>`. */
|
|
21
|
+
readonly table?: string;
|
|
22
|
+
/** The `<hr>` of a divider. */
|
|
23
|
+
readonly divider?: string;
|
|
24
|
+
/** Raw blocks: Markdown kept as source, or rendered by a view. */
|
|
25
|
+
readonly raw?: string;
|
|
26
|
+
/** `<img>` */
|
|
27
|
+
readonly image?: string;
|
|
28
|
+
/** `<strong>`, `<em>`, `<s>` and inline `<code>`. */
|
|
29
|
+
readonly bold?: string;
|
|
30
|
+
readonly italic?: string;
|
|
31
|
+
readonly strike?: string;
|
|
32
|
+
readonly code?: string;
|
|
33
|
+
/** `<a>` */
|
|
34
|
+
readonly link?: string;
|
|
35
|
+
/** Inline tokens of an extension syntax, as source or rendered, by syntax name, such as `math`. */
|
|
36
|
+
readonly token?: Readonly<Record<string, string>>;
|
|
37
|
+
}
|
|
38
|
+
/** Colors for one color scheme. Any CSS color. */
|
|
39
|
+
export interface ThemeColors {
|
|
40
|
+
readonly text?: string;
|
|
41
|
+
readonly muted?: string;
|
|
42
|
+
readonly background?: string;
|
|
43
|
+
readonly accent?: string;
|
|
44
|
+
/** Defaults to `accent`. */
|
|
45
|
+
readonly link?: string;
|
|
46
|
+
readonly codeBackground?: string;
|
|
47
|
+
readonly border?: string;
|
|
48
|
+
/** Menus, the toolbar and the link popover. */
|
|
49
|
+
readonly popupBackground?: string;
|
|
50
|
+
/** Defaults to `border`. */
|
|
51
|
+
readonly popupBorder?: string;
|
|
52
|
+
/** Highlighted menu items and toolbar buttons. */
|
|
53
|
+
readonly hover?: string;
|
|
54
|
+
readonly danger?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Values written as --mbe-* custom properties on the root and on popups. Numbers are pixels. */
|
|
57
|
+
export interface ThemeTokens {
|
|
58
|
+
/** Colors in the light scheme. Missing values keep the default. */
|
|
59
|
+
readonly light?: ThemeColors;
|
|
60
|
+
/** Colors in the dark scheme. Missing values keep the default dark palette. */
|
|
61
|
+
readonly dark?: ThemeColors;
|
|
62
|
+
readonly font?: string;
|
|
63
|
+
readonly mono?: string;
|
|
64
|
+
readonly fontSize?: string | number;
|
|
65
|
+
readonly lineHeight?: string | number;
|
|
66
|
+
readonly radius?: string | number;
|
|
67
|
+
readonly blockGap?: string | number;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* `auto` follows `prefers-color-scheme`, or `data-theme="light"` or
|
|
71
|
+
* `data-theme="dark"` on the root or an ancestor. `inherit` follows the
|
|
72
|
+
* page's `color-scheme`, for apps that switch it themselves.
|
|
73
|
+
*/
|
|
74
|
+
export type ColorScheme = 'auto' | 'light' | 'dark' | 'inherit';
|
|
75
|
+
export interface Theme {
|
|
76
|
+
readonly classes?: ThemeClasses;
|
|
77
|
+
readonly tokens?: ThemeTokens;
|
|
78
|
+
/** Default `auto`. */
|
|
79
|
+
readonly colorScheme?: ColorScheme;
|
|
80
|
+
}
|
|
81
|
+
/** Merges class maps; a later map wins for the same key, and `heading` and `token` merge per entry. */
|
|
82
|
+
export declare function mergeClasses(maps: readonly (ThemeClasses | undefined)[]): ThemeClasses;
|
|
83
|
+
/**
|
|
84
|
+
* The custom properties for `tokens`. Colors go in `--mbe-<name>-light` and
|
|
85
|
+
* `--mbe-<name>-dark`, which the stylesheet picks between with `light-dark()`.
|
|
86
|
+
*/
|
|
87
|
+
export declare function tokenProperties(tokens: ThemeTokens | undefined): Map<string, string>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Editor } from '../editor.js';
|
|
2
|
+
export declare class BlockHandle {
|
|
3
|
+
private readonly editor;
|
|
4
|
+
private readonly el;
|
|
5
|
+
private blockId;
|
|
6
|
+
private hideTimer;
|
|
7
|
+
private readonly cleanup;
|
|
8
|
+
constructor(editor: Editor);
|
|
9
|
+
private onMove;
|
|
10
|
+
/** Shows the handle next to a block. */
|
|
11
|
+
showFor(blockId: string): void;
|
|
12
|
+
hide(): void;
|
|
13
|
+
private scheduleHide;
|
|
14
|
+
private cancelHide;
|
|
15
|
+
destroy(): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
type Placement = 'below' | 'above';
|
|
2
|
+
export declare const isMac: boolean;
|
|
3
|
+
/** True on touch devices, which have no hover and show their own menu over a selection. */
|
|
4
|
+
export declare const isTouch: () => boolean;
|
|
5
|
+
export declare class Popup {
|
|
6
|
+
private readonly owner;
|
|
7
|
+
readonly el: HTMLElement;
|
|
8
|
+
private open;
|
|
9
|
+
constructor(owner: HTMLElement, className: string);
|
|
10
|
+
get isOpen(): boolean;
|
|
11
|
+
/** Shows the popup next to `rect` (viewport coordinates), flipping to stay on screen. */
|
|
12
|
+
show(rect: {
|
|
13
|
+
left: number;
|
|
14
|
+
top: number;
|
|
15
|
+
bottom: number;
|
|
16
|
+
right?: number;
|
|
17
|
+
}, placement?: Placement, gap?: number): void;
|
|
18
|
+
hide(): void;
|
|
19
|
+
destroy(): void;
|
|
20
|
+
private copyTheme;
|
|
21
|
+
}
|
|
22
|
+
export interface MenuItem {
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
/** Short glyph shown before the label. */
|
|
26
|
+
icon?: string;
|
|
27
|
+
/** Extra words that match when filtering. */
|
|
28
|
+
aliases?: string[];
|
|
29
|
+
danger?: boolean;
|
|
30
|
+
run: () => void;
|
|
31
|
+
}
|
|
32
|
+
export interface MenuSection {
|
|
33
|
+
title?: string;
|
|
34
|
+
items: MenuItem[];
|
|
35
|
+
}
|
|
36
|
+
/** A list of options with a highlighted item, driven by the keyboard (`aria-activedescendant`) or the mouse. */
|
|
37
|
+
export declare class Menu {
|
|
38
|
+
readonly popup: Popup;
|
|
39
|
+
private items;
|
|
40
|
+
private index;
|
|
41
|
+
private readonly id;
|
|
42
|
+
/** Called after an item runs. */
|
|
43
|
+
onPicked: (() => void) | null;
|
|
44
|
+
constructor(owner: HTMLElement, className: string, role?: 'listbox' | 'menu');
|
|
45
|
+
get el(): HTMLElement;
|
|
46
|
+
get isOpen(): boolean;
|
|
47
|
+
get activeDescendant(): string | null;
|
|
48
|
+
setSections(sections: MenuSection[], emptyLabel?: string): void;
|
|
49
|
+
get count(): number;
|
|
50
|
+
highlight(i: number): void;
|
|
51
|
+
move(delta: number): void;
|
|
52
|
+
pick(i?: number): void;
|
|
53
|
+
hide(): void;
|
|
54
|
+
destroy(): void;
|
|
55
|
+
}
|
|
56
|
+
/** Case-insensitive match of a query against an item's label and aliases (a substring, also with spaces ignored). */
|
|
57
|
+
export declare function matches(item: Pick<MenuItem, 'label' | 'aliases'>, query: string): boolean;
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Editor } from '../editor.js';
|
|
2
|
+
export declare class FormatToolbar {
|
|
3
|
+
private readonly editor;
|
|
4
|
+
private readonly popup;
|
|
5
|
+
private readonly markButtons;
|
|
6
|
+
private readonly linkButton;
|
|
7
|
+
constructor(editor: Editor);
|
|
8
|
+
get isOpen(): boolean;
|
|
9
|
+
show(): void;
|
|
10
|
+
hide(): void;
|
|
11
|
+
destroy(): void;
|
|
12
|
+
private update;
|
|
13
|
+
}
|
|
14
|
+
/** A small input for a link URL. Enter applies, Escape cancels, an empty value removes the link. */
|
|
15
|
+
export declare class LinkPopover {
|
|
16
|
+
private readonly popup;
|
|
17
|
+
private readonly input;
|
|
18
|
+
private readonly removeButton;
|
|
19
|
+
private done;
|
|
20
|
+
constructor(editor: Editor);
|
|
21
|
+
get isOpen(): boolean;
|
|
22
|
+
contains(node: Node): boolean;
|
|
23
|
+
open(rect: DOMRect, value: string, done: (href: string | null) => void): void;
|
|
24
|
+
/** Closes without changing anything and without refocusing the editor. */
|
|
25
|
+
private close;
|
|
26
|
+
private finish;
|
|
27
|
+
destroy(): void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type Block, type Cell, type Doc, type Inline, type Position } from '../model.js';
|
|
2
|
+
import type { SyntaxView } from '../extension.js';
|
|
3
|
+
import type { Labels } from '../labels.js';
|
|
4
|
+
import type { ThemeClasses } from '../theme.js';
|
|
5
|
+
import { type Decoration } from '../decorations.js';
|
|
6
|
+
export declare const BLOCK_ATTR = "data-block-id";
|
|
7
|
+
/** Only these URL schemes become clickable `href`s. Others are kept in the model but not linked. */
|
|
8
|
+
export declare function safeHref(href: string): string | null;
|
|
9
|
+
/** What rendering needs besides the block. */
|
|
10
|
+
export interface RenderContext {
|
|
11
|
+
readonly doc: Document;
|
|
12
|
+
readonly labels: Labels;
|
|
13
|
+
readonly resolveImageSrc?: (src: string) => string;
|
|
14
|
+
/** Decorations for a text container. */
|
|
15
|
+
readonly decorate?: (block: Block, content: Inline, cell?: Cell) => readonly Decoration[];
|
|
16
|
+
/** Syntaxes that have a view. */
|
|
17
|
+
readonly views?: ReadonlyMap<string, SyntaxView>;
|
|
18
|
+
/** A token or raw block of an extension syntax, rendered; null shows its source. */
|
|
19
|
+
readonly view?: (syntax: string, source: string, kind: 'inline' | 'block') => HTMLElement | null;
|
|
20
|
+
/** Theme classes for rendered elements. */
|
|
21
|
+
readonly classes: ThemeClasses;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Which views of one block show their source: `REVEAL_BLOCK` for a whole raw
|
|
25
|
+
* block, or `tokenKey(cell, from)` for a token.
|
|
26
|
+
*/
|
|
27
|
+
export type BlockReveal = ReadonlySet<string>;
|
|
28
|
+
export declare const REVEAL_BLOCK = "block";
|
|
29
|
+
export declare function tokenKey(cell: Cell | undefined, from: number): string;
|
|
30
|
+
export declare function sameReveal(a: BlockReveal | undefined, b: BlockReveal | undefined): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Keyed reconciliation. Blocks are immutable, so a block whose object is the
|
|
33
|
+
* same as last render keeps its DOM element untouched.
|
|
34
|
+
*/
|
|
35
|
+
export declare class BlockRenderer {
|
|
36
|
+
private readonly root;
|
|
37
|
+
private readonly labels;
|
|
38
|
+
private rendered;
|
|
39
|
+
/** Last number written into each ordered item's marker, keyed by element. */
|
|
40
|
+
private readonly numbers;
|
|
41
|
+
/** Maps an image `src` to the URL to display. Set before a full render. */
|
|
42
|
+
resolveImageSrc?: (src: string) => string;
|
|
43
|
+
/** Decorations for a text container. */
|
|
44
|
+
decorate?: RenderContext['decorate'];
|
|
45
|
+
/** Widget elements to place after a block. */
|
|
46
|
+
widgetsAfter?: (blockId: string) => readonly HTMLElement[] | undefined;
|
|
47
|
+
/** Views of extension syntaxes, by syntax name. */
|
|
48
|
+
views?: ReadonlyMap<string, SyntaxView>;
|
|
49
|
+
/** Theme classes for rendered elements. Set before a full render. */
|
|
50
|
+
classes: ThemeClasses;
|
|
51
|
+
/** Per block, the views that show their source. A block re-renders when its entry changes. */
|
|
52
|
+
revealed: ReadonlyMap<string, BlockReveal>;
|
|
53
|
+
/**
|
|
54
|
+
* Rendered views by kind, syntax and source, least recently used first.
|
|
55
|
+
* Cloned on reuse: typing re-renders a block and every formula in it.
|
|
56
|
+
*/
|
|
57
|
+
private readonly viewCache;
|
|
58
|
+
constructor(root: HTMLElement, labels: Labels);
|
|
59
|
+
private context;
|
|
60
|
+
private renderView;
|
|
61
|
+
/**
|
|
62
|
+
* `force` re-renders every block. `lazy` (with a full render) lets blocks
|
|
63
|
+
* skip layout while off screen; use it only when loading a document.
|
|
64
|
+
*/
|
|
65
|
+
render(doc: Doc, force?: boolean, lazy?: boolean): void;
|
|
66
|
+
elementFor(id: string): HTMLElement | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Keeps a block's element for a new version of the block, when the browser
|
|
69
|
+
* has already edited the element to show it (during IME composition).
|
|
70
|
+
* Only the empty state is updated, so a placeholder does not cover the text.
|
|
71
|
+
*/
|
|
72
|
+
adopt(block: Block): void;
|
|
73
|
+
/** Forget a block's element so the next render rebuilds it, e.g. after the browser edited it during IME composition. */
|
|
74
|
+
invalidate(id: string): void;
|
|
75
|
+
}
|
|
76
|
+
export declare function contentElement(blockEl: HTMLElement, cell?: Cell): HTMLElement | null;
|
|
77
|
+
/** Index of a node among its parent's child nodes. */
|
|
78
|
+
export declare function childIndex(node: Node): number;
|
|
79
|
+
/** Plain text of a content element as the browser currently has it, with atoms as one character. */
|
|
80
|
+
export declare function domText(contentEl: HTMLElement): string;
|
|
81
|
+
export declare function domToPosition(root: HTMLElement, node: Node, offset: number): Position | null;
|
|
82
|
+
export declare function positionToDom(blockEl: HTMLElement, pos: Position): {
|
|
83
|
+
node: Node;
|
|
84
|
+
offset: number;
|
|
85
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SyntaxView } from '../extension.js';
|
|
2
|
+
import { type EditorState, type Position, type RawBlock } from '../model.js';
|
|
3
|
+
import { type BlockReveal } from './dom.js';
|
|
4
|
+
/** Per block, the views that show their source. Empty when `active` is false (read-only or unfocused). */
|
|
5
|
+
export declare function revealedViews(state: EditorState, views: ReadonlyMap<string, SyntaxView>, active: boolean): Map<string, BlockReveal>;
|
|
6
|
+
export declare function sameRevealed(a: ReadonlyMap<string, BlockReveal>, b: ReadonlyMap<string, BlockReveal>): boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Where the caret goes in a rendered raw block's source: past its opening
|
|
9
|
+
* line going forward (such as a `$$` fence), at the end of its next-to-last
|
|
10
|
+
* line going back or on a click.
|
|
11
|
+
*/
|
|
12
|
+
export declare function viewEntry(block: RawBlock, forward: boolean): Position;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface WidgetRender {
|
|
2
|
+
/** Fills the widget's element. May return a cleanup function, called before the next render and on removal. */
|
|
3
|
+
(element: HTMLElement): void | (() => void);
|
|
4
|
+
}
|
|
5
|
+
export interface Widget {
|
|
6
|
+
/** The element the widget renders into. It is not editable text. */
|
|
7
|
+
readonly element: HTMLElement;
|
|
8
|
+
/** The block the widget is shown after. */
|
|
9
|
+
readonly blockId: string;
|
|
10
|
+
readonly isRemoved: boolean;
|
|
11
|
+
/** Renders again, with a new render function if given. */
|
|
12
|
+
update(render?: WidgetRender): void;
|
|
13
|
+
remove(): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class WidgetImpl implements Widget {
|
|
16
|
+
readonly element: HTMLElement;
|
|
17
|
+
private render;
|
|
18
|
+
private readonly onRemove;
|
|
19
|
+
blockId: string;
|
|
20
|
+
isRemoved: boolean;
|
|
21
|
+
private cleanup;
|
|
22
|
+
constructor(element: HTMLElement, blockId: string, render: WidgetRender, onRemove: (widget: WidgetImpl) => void);
|
|
23
|
+
update(render?: WidgetRender): void;
|
|
24
|
+
remove(): void;
|
|
25
|
+
private paint;
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usememos/editor",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "26.10.0",
|
|
4
|
+
"description": "A block editor for standard Markdown. Zero runtime dependencies, with an optional React component.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"markdown",
|
|
7
|
+
"editor",
|
|
8
|
+
"block-editor",
|
|
9
|
+
"wysiwyg",
|
|
10
|
+
"commonmark",
|
|
11
|
+
"gfm",
|
|
12
|
+
"react"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/usememos/editor.git",
|
|
18
|
+
"directory": "packages/editor"
|
|
19
|
+
},
|
|
20
|
+
"type": "module",
|
|
21
|
+
"sideEffects": [
|
|
22
|
+
"*.css"
|
|
23
|
+
],
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"types": "./dist/types/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/types/index.d.ts",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./react": {
|
|
34
|
+
"types": "./dist/types/react/index.d.ts",
|
|
35
|
+
"default": "./dist/react.js"
|
|
36
|
+
},
|
|
37
|
+
"./style.css": "./dist/style.css",
|
|
38
|
+
"./base.css": "./dist/base.css",
|
|
39
|
+
"./theme.css": "./dist/theme.css",
|
|
40
|
+
"./package.json": "./package.json"
|
|
41
|
+
},
|
|
42
|
+
"imports": {
|
|
43
|
+
"#entities": {
|
|
44
|
+
"browser": "./dist/entities.dom.js",
|
|
45
|
+
"default": "./dist/entities.js"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "node scripts/build.mjs",
|
|
50
|
+
"prepack": "npm run build"
|
|
51
|
+
},
|
|
52
|
+
"peerDependencies": {
|
|
53
|
+
"react": ">=18"
|
|
54
|
+
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"react": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|