@toantranmei/editor 0.2.0 → 0.3.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.
Files changed (44) hide show
  1. package/README.md +109 -5
  2. package/dist/block-names-QblT9TgF.js +30 -0
  3. package/dist/block-names-QblT9TgF.js.map +1 -0
  4. package/dist/collaboration.js +42 -0
  5. package/dist/collaboration.js.map +1 -0
  6. package/dist/{css-BSGpc2It.js → css-el97DJfy.js} +201 -41
  7. package/dist/css-el97DJfy.js.map +1 -0
  8. package/dist/date-utils-DW99lT2W.js +1308 -0
  9. package/dist/date-utils-DW99lT2W.js.map +1 -0
  10. package/dist/index.js +2467 -2848
  11. package/dist/index.js.map +1 -1
  12. package/dist/nuxt.js +9 -8
  13. package/dist/nuxt.js.map +1 -1
  14. package/dist/render.js +445 -0
  15. package/dist/render.js.map +1 -0
  16. package/dist/style.css +1 -1
  17. package/dist/types/collaboration.d.ts +27 -0
  18. package/dist/types/components/MeiEditor.vue.d.ts +17 -3
  19. package/dist/types/components/MermaidDiagram.vue.d.ts +8 -5
  20. package/dist/types/composables/usePointerMoved.d.ts +10 -0
  21. package/dist/types/config.d.ts +3 -0
  22. package/dist/types/date-utils.d.ts +2 -2
  23. package/dist/types/define-block.d.ts +27 -1
  24. package/dist/types/extensions/code-block.d.ts +10 -0
  25. package/dist/types/extensions/code-languages.d.ts +2 -0
  26. package/dist/types/extensions/embed-url.d.ts +2 -0
  27. package/dist/types/extensions/embed.d.ts +2 -2
  28. package/dist/types/extensions/html-block.d.ts +2 -26
  29. package/dist/types/extensions/html-document.d.ts +26 -0
  30. package/dist/types/extensions/index.d.ts +6 -1
  31. package/dist/types/extensions/markdown-paste.d.ts +36 -0
  32. package/dist/types/index.d.ts +2 -1
  33. package/dist/types/locale.d.ts +2 -0
  34. package/dist/types/render/highlight.d.ts +4 -0
  35. package/dist/types/render/html.d.ts +14 -0
  36. package/dist/types/render/icons.d.ts +2 -0
  37. package/dist/types/render/index.d.ts +51 -0
  38. package/dist/types/render/mermaid.d.ts +13 -0
  39. package/dist/types/render/nodes.d.ts +17 -0
  40. package/dist/types/render/types.d.ts +102 -0
  41. package/dist/types/safe-url.d.ts +19 -0
  42. package/dist/types/theme/tokens.d.ts +202 -0
  43. package/package.json +23 -7
  44. package/dist/css-BSGpc2It.js.map +0 -1
@@ -0,0 +1,26 @@
1
+ export interface HtmlBlockOptions {
2
+ /**
3
+ * What the block's code may load from the network. `false` (default, like Notion):
4
+ * nothing. Images, fonts and scripts must be inlined. `true`: anything. A list of
5
+ * origins (`['https://cdn.jsdelivr.net']`): only those.
6
+ */
7
+ network: boolean | string[];
8
+ /** Largest `.html` file that can be uploaded, in KB. */
9
+ maxSize: number;
10
+ /** Height of a new block, in px. */
11
+ defaultHeight: number;
12
+ }
13
+ /** Block heights users can drag between, in px. */
14
+ export declare const HTML_MIN_HEIGHT = 120;
15
+ export declare const HTML_MAX_HEIGHT = 2000;
16
+ /**
17
+ * Content-Security-Policy for the sandboxed page. The iframe has no `allow-same-origin`,
18
+ * so the code can't touch the editor, its page, cookies or storage either way; the
19
+ * policy additionally blocks network requests unless `network` allows them.
20
+ */
21
+ export declare function htmlBlockCsp(network: HtmlBlockOptions['network']): string | null;
22
+ /**
23
+ * The iframe document: a strict CSP first (later policies can only tighten it), then
24
+ * the user's HTML.
25
+ */
26
+ export declare function htmlBlockDocument(code: string, network: HtmlBlockOptions['network']): string;
@@ -4,10 +4,15 @@ import { type BlockDefinition } from '../define-block';
4
4
  export interface MeiExtensionsOptions extends Partial<MeiConfigStorage> {
5
5
  /** Block definitions to load (their extensions and menu items). */
6
6
  blocks: BlockDefinition[];
7
+ /**
8
+ * Built-in undo / redo (StarterKit's `undoRedo`). Default true. Set false with
9
+ * `collaborationExtensions()` (`@toantranmei/editor/collaboration`), which brings Yjs undo.
10
+ */
11
+ undoRedo?: boolean;
7
12
  }
8
13
  /**
9
14
  * Editor core (always loaded) + the extensions of the given blocks.
10
15
  * Core: paragraphs, text marks, links, history, colors, slash menu, drag & drop,
11
16
  * block selection, block ids and the unknown-block fallback.
12
17
  */
13
- export declare function createExtensions({ blocks, ...config }: MeiExtensionsOptions): AnyExtension[];
18
+ export declare function createExtensions({ blocks, undoRedo, ...config }: MeiExtensionsOptions): AnyExtension[];
@@ -0,0 +1,36 @@
1
+ import { Extension, type JSONContent } from '@tiptap/core';
2
+ import type { Schema } from '@tiptap/pm/model';
3
+ /**
4
+ * Pasting Markdown as plain text (from a chat, a README, an LLM answer…) gives blocks instead of
5
+ * one paragraph per line (KS-BUG-11): headings, bullet / numbered / task lists (nested by
6
+ * indentation), quotes, fenced code, dividers, and inline bold, italic, strike, code and links
7
+ * (bare http(s) URLs too). Tiptap's paste rules are not run on the result: they would undo
8
+ * escapes (`\\*x\\*`) and the word rules (`__init__.py`).
9
+ *
10
+ * Converted only when the text clearly is Markdown (`looksLikeMarkdown`), at most
11
+ * `MARKDOWN_PASTE_MAX` characters, never inside a code block, never for "paste as plain text"
12
+ * (Shift+Mod+V) and never when the clipboard also has HTML. The parsers are linear in the input
13
+ * (no backtracking regexes, bounded nesting), so a pasted text can't freeze the tab.
14
+ */
15
+ /** Longer plain-text pastes are never converted. */
16
+ export declare const MARKDOWN_PASTE_MAX: number;
17
+ /**
18
+ * True when `text` clearly is Markdown: a heading, a closed code fence, a task item, or two list
19
+ * items of the same kind in a row. A lone "- Alice" signature or "1) apples" is not enough.
20
+ */
21
+ export declare function looksLikeMarkdown(text: string): boolean;
22
+ type Mark = {
23
+ type: string;
24
+ attrs?: Record<string, unknown>;
25
+ };
26
+ /**
27
+ * Inline Markdown → text nodes with marks (bold, italic, strike, code, link), bare http(s) URLs
28
+ * linked. Linear time; emphasis nested deeper than MAX_DEPTH stays text.
29
+ */
30
+ export declare function parseInline(text: string, marks?: Mark[], inLink?: boolean, depth?: number): JSONContent[];
31
+ /** Block Markdown → Tiptap JSON blocks (types are mapped to the schema by `fitToSchema`). */
32
+ export declare function markdownToBlocks(markdown: string, depth?: number): JSONContent[];
33
+ /** Replaces node / mark types the editor doesn't have (e.g. no task lists loaded) with plain ones. */
34
+ export declare function fitToSchema(node: JSONContent, schema: Schema): JSONContent;
35
+ export declare const MarkdownPaste: Extension<any, any>;
36
+ export {};
@@ -14,6 +14,7 @@ export { filterBlocks, isNode, type BlockType } from './block-items';
14
14
  export { collectExtensions, defineBlock, type BlockDefinition, type BlockSpec } from './define-block';
15
15
  export * from './blocks';
16
16
  export { ContentError, sanitizeContent, unwrapUnknown, wrapUnknown, type ContentIssue } from './content';
17
+ export { isSameOrigin, isWebUrl, safeUrl, type DataUrlPolicy } from './safe-url';
17
18
  export { GLOBAL_BLOCKS_KEY, GLOBAL_TOKENS_KEY } from './plugin-key';
18
19
  export { TableOfContents } from './extensions/toc';
19
20
  export { MathBlock, MathInline } from './extensions/math';
@@ -30,7 +31,7 @@ export { BlockSelection, TURN_INTO_SHORTCUTS } from './extensions/block-selectio
30
31
  export { COLORS, type ColorName } from './colors';
31
32
  export { BgColor, BlockColor, COLORABLE_BLOCKS, TextColor } from './extensions/color-marks';
32
33
  export { baseTokensCss, component as componentTokens, defineTokens, overridesCss, PALETTE_NAMES, primitive as primitiveTokens, semanticDark as semanticDarkTokens, semanticLight as semanticLightTokens, type PaletteName, type ThemeMode, type ThemeTokens, } from './theme';
33
- export { en, locales, resolveMessages, vi, type BlockGroup, type EditorMessages, type LocaleName, type PartialMessages } from './locale';
34
+ export { en, locales, resolveMessages, vi, zh, type BlockGroup, type EditorMessages, type LocaleName, type PartialMessages } from './locale';
34
35
  export { blockNodeView } from './nodeviews/renderer';
35
36
  export { useClickOutside } from './composables/useClickOutside';
36
37
  export { useEditable } from './composables/useEditable';
@@ -212,9 +212,11 @@ export interface EditorMessages {
212
212
  }
213
213
  export declare const vi: EditorMessages;
214
214
  export declare const en: EditorMessages;
215
+ export declare const zh: EditorMessages;
215
216
  export declare const locales: {
216
217
  vi: EditorMessages;
217
218
  en: EditorMessages;
219
+ zh: EditorMessages;
218
220
  };
219
221
  export type LocaleName = keyof typeof locales;
220
222
  type DeepPartial<T> = {
@@ -0,0 +1,4 @@
1
+ /** Grammar name for a code block language (aliases resolved), or null when unknown / plain text. */
2
+ export declare function grammarFor(language: string | null | undefined): string | null;
3
+ /** Highlighted, escaped HTML for `code` (plain escaped text when the language is unknown). */
4
+ export declare function highlightCode(code: string, language: string | null | undefined): string;
@@ -0,0 +1,14 @@
1
+ import type { UrlKind } from './types';
2
+ /** Escapes text for HTML text and (quoted) attribute values. */
3
+ export declare function escapeHtml(value: unknown): string;
4
+ /** ` name="value"`, or '' for null / undefined / false. `true` renders a bare attribute. */
5
+ export declare function attr(name: string, value: unknown): string;
6
+ /**
7
+ * Returns the URL when it is safe for `kind`, else null. Allowed: `http:`, `https:`,
8
+ * `mailto:` (links only) and relative URLs; `data:` media for `media`; inert `data:` files
9
+ * for `download`. Iframes (`frame`) need an absolute http(s) URL. Control characters and
10
+ * whitespace inside the scheme (`java\tscript:`) are stripped before checking, like browsers do.
11
+ */
12
+ export declare function safeUrl(url: unknown, kind?: UrlKind): string | null;
13
+ /** True for absolute http(s) URLs (opened in a new tab by default). */
14
+ export declare const isExternal: (url: string) => boolean;
@@ -0,0 +1,2 @@
1
+ /** `<svg class="lucide">` markup for a built-in icon name ('' when unknown). */
2
+ export declare function icon(name: string, className?: string): string;
@@ -0,0 +1,51 @@
1
+ /**
2
+ * `@toantranmei/editor/render`: editor JSON → static HTML, on the server or in the browser.
3
+ *
4
+ * No DOM, no Vue, no ProseMirror schema: a single pass over the JSON that emits the same
5
+ * markup and `me-*` classes as the editor's node views, so `@toantranmei/editor/style.css`
6
+ * styles it like a read-only editor. Every text and attribute is escaped, URLs are
7
+ * allow-listed (see `safeUrl`), embeds and HTML blocks are sandboxed iframes.
8
+ */
9
+ import type { JSONContent } from '@tiptap/core';
10
+ import { type HeadingEntry } from './nodes';
11
+ import type { KatexLike, RenderOptions } from './types';
12
+ export type { BlockRenderers, JSONMark, KatexLike, MarkRenderer, MentionTarget, NodeRenderer, RenderBlock, RenderContext, RenderOptions, ResolvedLink, UrlKind, } from './types';
13
+ export { attr, escapeHtml, safeUrl } from './html';
14
+ export { highlightCode } from './highlight';
15
+ export { hydrateMermaid, type HydrateMermaidOptions } from './mermaid';
16
+ import { baseTokensCss, overridesCss } from '../theme/css';
17
+ import type { ThemeTokens } from '../theme/tokens';
18
+ export { baseTokensCss, overridesCss };
19
+ /** Per-render state shared by the built-in renderers. */
20
+ export interface RenderState {
21
+ headings: HeadingEntry[];
22
+ anchorOf: WeakMap<JSONContent, string>;
23
+ katex: KatexLike | null;
24
+ htmlOptions: {
25
+ network: boolean | string[];
26
+ defaultHeight: number;
27
+ };
28
+ }
29
+ /**
30
+ * Renders editor JSON (`editor.getJSON()`, or ProseMirror JSON from the server) to HTML.
31
+ * Synchronous and DOM-free; pass `katex` to render equations (or use `renderHTMLAsync`).
32
+ *
33
+ * @example
34
+ * import { renderHTML } from '@toantranmei/editor/render'
35
+ * const html = renderHTML(doc, { locale: 'vi', blocks: [pageBlockRender], resolveLink: id => ({ href: `/p/${id}`, title }) })
36
+ */
37
+ export declare function renderHTML(doc: JSONContent | null | undefined, options?: RenderOptions): string;
38
+ /** True when the document contains equations (math blocks or inline math). */
39
+ export declare function hasMath(doc: JSONContent | null | undefined): boolean;
40
+ /**
41
+ * Like `renderHTML`, but loads KaTeX (optional peer `katex`) when the document has math
42
+ * and `options.katex` isn't given. Falls back to TeX source if KaTeX isn't installed.
43
+ */
44
+ export declare function renderHTMLAsync(doc: JSONContent | null | undefined, options?: RenderOptions): Promise<string>;
45
+ /**
46
+ * `<style id="mei-editor-tokens">` with the editor's default design tokens (light + dark).
47
+ * The editor injects them at runtime; server-rendered pages put this in `<head>` (next to
48
+ * `style.css`). A `<MeiEditor>` mounted later on the page reuses it instead of adding another.
49
+ * `overrides` (token overrides) are appended, unlayered, for `.me-scope`.
50
+ */
51
+ export declare function renderTokensStyle(overrides?: ThemeTokens): string;
@@ -0,0 +1,13 @@
1
+ export interface HydrateMermaidOptions {
2
+ /** Dark diagrams. Default: `<html class="dark">`. */
3
+ dark?: boolean;
4
+ }
5
+ /**
6
+ * Browser only: turns the `<pre class="mermaid">` blocks of a rendered page into diagrams.
7
+ * Loads the optional peer `mermaid` on first use; does nothing when there are no diagrams.
8
+ * Uses `securityLevel: 'strict'` (labels sanitized, no click handlers), like the editor.
9
+ *
10
+ * @example
11
+ * onMounted(() => hydrateMermaid(articleEl.value))
12
+ */
13
+ export declare function hydrateMermaid(root?: ParentNode | null, options?: HydrateMermaidOptions): Promise<void>;
@@ -0,0 +1,17 @@
1
+ import type { JSONContent } from '@tiptap/core';
2
+ import type { MarkRenderer, NodeRenderer } from './types';
3
+ export interface HeadingEntry {
4
+ level: number;
5
+ text: string;
6
+ id: string;
7
+ }
8
+ /**
9
+ * Headings and toggle headings, in document order, with their anchor ids: the block id
10
+ * (what "Copy link to block" uses) or, for documents without ids, a unique slug of the text.
11
+ */
12
+ export declare function collectHeadings(doc: JSONContent | null | undefined): {
13
+ headings: HeadingEntry[];
14
+ anchorOf: WeakMap<JSONContent, string>;
15
+ };
16
+ export declare const builtinNodes: Record<string, NodeRenderer>;
17
+ export declare const builtinMarks: Record<string, MarkRenderer>;
@@ -0,0 +1,102 @@
1
+ import type { JSONContent } from '@tiptap/core';
2
+ import type { EditorMessages, LocaleName, PartialMessages } from '../locale';
3
+ /** A mark as stored in the document JSON. */
4
+ export interface JSONMark {
5
+ type: string;
6
+ attrs?: Record<string, any>;
7
+ }
8
+ /** Where a page link points, from `resolveLink`. `null`: not found / no access. */
9
+ export interface ResolvedLink {
10
+ href: string;
11
+ title?: string | null;
12
+ /** Emoji (or short text) shown before the title. */
13
+ icon?: string | null;
14
+ }
15
+ /** URL contexts for `safeUrl`. */
16
+ export type UrlKind =
17
+ /** `<a href>`: http(s), mailto, relative. */
18
+ 'link'
19
+ /** `<img src>` / `<audio src>` / `<video src>`: link + `data:image|audio|video/*`. */
20
+ | 'media'
21
+ /** `<a href download>` for attachments: link + inert `data:` files. */
22
+ | 'download'
23
+ /** `<iframe src>`: absolute http(s) only. */
24
+ | 'frame';
25
+ /** Minimal KaTeX surface used by the renderer (`import katex from 'katex'`). */
26
+ export interface KatexLike {
27
+ renderToString: (tex: string, options?: Record<string, unknown>) => string;
28
+ }
29
+ /** Helpers handed to block render hooks. */
30
+ export interface RenderContext {
31
+ locale: LocaleName;
32
+ /** Editor messages for `locale` (with block messages and overrides merged). */
33
+ messages: EditorMessages;
34
+ options: RenderOptions;
35
+ /** Renders the node's children (blocks or inline content). */
36
+ children: (node: JSONContent) => string;
37
+ /** Renders any node (or a whole `doc`), e.g. content loaded from elsewhere. */
38
+ render: (node: JSONContent) => string;
39
+ /** ` data-id="…" data-text-color="…" data-bg-color="…"` for a block (leading space, escaped). */
40
+ blockAttrs: (node: JSONContent) => string;
41
+ /** Escapes text / attribute values (`& < > " '`). */
42
+ escape: (value: unknown) => string;
43
+ /** ` name="value"` (escaped), or '' when value is null / undefined / false. */
44
+ attr: (name: string, value: unknown) => string;
45
+ /** The URL when its scheme is allowed for `kind`, else null. */
46
+ safeUrl: (url: unknown, kind?: UrlKind) => string | null;
47
+ /** Plain text content of a node. */
48
+ text: (node: JSONContent) => string;
49
+ /** Inline SVG for a built-in icon name (`file`, `fileText`, `audio`, `video`, `download`). */
50
+ icon: (name: string) => string;
51
+ }
52
+ export type NodeRenderer = (node: JSONContent, ctx: RenderContext) => string;
53
+ export type MarkRenderer = (mark: JSONMark, inner: string, ctx: RenderContext) => string;
54
+ /** What a block contributes to `renderHTML` (BlockDefinition `render`). */
55
+ export interface BlockRenderers {
56
+ nodes?: Record<string, NodeRenderer>;
57
+ marks?: Record<string, MarkRenderer>;
58
+ }
59
+ /** Anything with render hooks: a BlockDefinition or a light `{ name, render }` object. */
60
+ export interface RenderBlock {
61
+ name?: string;
62
+ options?: any;
63
+ render?: BlockRenderers;
64
+ }
65
+ export interface MentionTarget {
66
+ id: string;
67
+ label?: string | null;
68
+ kind: 'user' | 'page' | 'date';
69
+ href?: string | null;
70
+ }
71
+ export interface RenderOptions {
72
+ /**
73
+ * Blocks whose render hooks are used (BlockDefinitions, e.g. the editor's block list, or
74
+ * `{ name, render }`). Built-in blocks always render; options of `html` are read from here.
75
+ */
76
+ blocks?: RenderBlock[];
77
+ /** UI strings (TOC title, "Untitled"…) and date formats. Default `'vi'`. */
78
+ locale?: LocaleName;
79
+ messages?: PartialMessages;
80
+ /** Resolves a page id (page links, `@toantranmei/page-block`). `null`: missing / no access. */
81
+ resolveLink?: (pageId: string) => ResolvedLink | null;
82
+ /** Link for a person / page mention. Default: the mention's stored `href`. */
83
+ mentionHref?: (mention: MentionTarget) => string | null;
84
+ /**
85
+ * KaTeX for math blocks (`import katex from 'katex'`). Without it equations render as
86
+ * escaped TeX source. `renderHTMLAsync` loads it automatically when a document has math.
87
+ */
88
+ katex?: KatexLike | null;
89
+ /**
90
+ * Wrap the HTML in the editor's scope (`.me-scope.me-root.me-render > .me-content`) so
91
+ * `@toantranmei/editor/style.css` styles it. Default true.
92
+ */
93
+ wrap?: boolean;
94
+ /** Color mode of the wrapper: `auto` follows `<html class="dark">`. */
95
+ theme?: 'auto' | 'light' | 'dark';
96
+ /** Extra classes on the wrapper. */
97
+ className?: string;
98
+ /** Open external links in a new tab (`target="_blank" rel="noopener noreferrer"`). Default true. */
99
+ externalLinksInNewTab?: boolean;
100
+ /** Extra data for custom block renderers (e.g. database rows, synced block content). */
101
+ data?: Record<string, unknown>;
102
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Which `data:` URLs a block may load: `image` (only `data:image/*`), `any`, or `none`.
3
+ */
4
+ export type DataUrlPolicy = 'image' | 'any' | 'none';
5
+ /**
6
+ * URLs from document content (pasted, synced, imported) before they reach `src`, `href` or
7
+ * `window.open`: http(s), `blob:`, URLs without a scheme and the allowed `data:` URLs. Anything
8
+ * else — `javascript:`, `data:text/html`, `vbscript:`, URLs with control characters — gives `null`.
9
+ *
10
+ * URLs without a scheme take the page's: paths (`/api/v1/files/<id>`, `a.png`) are same-origin,
11
+ * while `//cdn.example.com/a.png` (and `\\host`, `/\host`, which browsers read the same way) are
12
+ * http(s) URLs on another host — as safe as any https URL, but not same-origin. Use `isSameOrigin`
13
+ * when that matters.
14
+ */
15
+ export declare function safeUrl(src: unknown, data?: DataUrlPolicy): string | null;
16
+ /** True when `url` (resolved against the page) is on the page's origin. */
17
+ export declare function isSameOrigin(url: string, base?: string): boolean;
18
+ /** True when `url` (resolved against the page) is an http(s) URL. */
19
+ export declare function isWebUrl(url: string, base?: string): boolean;
@@ -465,6 +465,208 @@ export declare const component: {
465
465
  avatarSize: string;
466
466
  popoverWidth: string;
467
467
  };
468
+ /** Sub-page / link-to-page rows (`@toantranmei/page-block`). */
469
+ pageLink: {
470
+ color: string;
471
+ hoverBg: string;
472
+ radius: string;
473
+ padding: string;
474
+ gap: string;
475
+ fontWeight: string;
476
+ iconSize: string;
477
+ iconColor: string;
478
+ underline: string;
479
+ underlineHover: string;
480
+ mutedColor: string;
481
+ missingColor: string;
482
+ popoverWidth: string;
483
+ };
484
+ /** Database block (`@toantranmei/database-block`): header, tabs, toolbar, table and the other views. */
485
+ database: {
486
+ gap: string;
487
+ titleSize: string;
488
+ titleWeight: string;
489
+ titleColor: string;
490
+ titlePlaceholder: string;
491
+ fontSize: string;
492
+ mutedColor: string;
493
+ faintColor: string;
494
+ border: string;
495
+ radius: string;
496
+ hoverBg: string;
497
+ bg: string;
498
+ /** Scroll area of an inline database; a full-page one uses `fullHeight`. */
499
+ maxHeight: string;
500
+ fullHeight: string;
501
+ /** Tabs + toolbar row. */
502
+ tabGap: string;
503
+ tabPadding: string;
504
+ tabActiveColor: string;
505
+ tabIndicator: string;
506
+ toolbarGap: string;
507
+ toolbarButtonActive: string;
508
+ searchWidth: string;
509
+ /** Table. Row/header heights are also read by the virtualizer (px). */
510
+ rowHeight: string;
511
+ headerHeight: string;
512
+ footerHeight: string;
513
+ groupHeaderHeight: string;
514
+ headerColor: string;
515
+ headerBg: string;
516
+ headerWeight: string;
517
+ cellPaddingX: string;
518
+ cellMinWidth: string;
519
+ cellDefaultWidth: string;
520
+ selectColWidth: string;
521
+ handleColWidth: string;
522
+ activeRing: string;
523
+ activeRingWidth: string;
524
+ selectedBg: string;
525
+ placeholderBg: string;
526
+ placeholderRadius: string;
527
+ resizeHandle: string;
528
+ resizeHandleWidth: string;
529
+ dropIndicator: string;
530
+ dropIndicatorWidth: string;
531
+ editorBg: string;
532
+ editorShadow: string;
533
+ editorMinHeight: string;
534
+ readOnlyColor: string;
535
+ linkColor: string;
536
+ aggregateColor: string;
537
+ errorColor: string;
538
+ /** Select / multi-select / status / person / relation chips. */
539
+ tagHeight: string;
540
+ tagPadding: string;
541
+ tagRadius: string;
542
+ tagGap: string;
543
+ tagFontSize: string;
544
+ defaultTagBg: string;
545
+ defaultTagText: string;
546
+ swatchSize: string;
547
+ avatarSize: string;
548
+ avatarRadius: string;
549
+ /** Popovers: menus, filter / sort builders, property editor. */
550
+ menuWidth: string;
551
+ builderWidth: string;
552
+ formulaHeight: string;
553
+ dangerColor: string;
554
+ warningBg: string;
555
+ warningText: string;
556
+ /** Board. */
557
+ columnWidth: string;
558
+ columnGap: string;
559
+ columnBg: string;
560
+ cardBg: string;
561
+ cardBorder: string;
562
+ cardRadius: string;
563
+ cardPadding: string;
564
+ cardGap: string;
565
+ cardShadow: string;
566
+ dropBg: string;
567
+ /** Calendar. */
568
+ calendarCellHeight: string;
569
+ calendarTodayBg: string;
570
+ calendarTodayText: string;
571
+ calendarOutsideBg: string;
572
+ /** Timeline: width of one day at each scale (px, read by the view). */
573
+ timelineDay: string;
574
+ timelineWeek: string;
575
+ timelineMonth: string;
576
+ timelineRowHeight: string;
577
+ timelineLabelWidth: string;
578
+ barBg: string;
579
+ barBorder: string;
580
+ barRadius: string;
581
+ barHeight: string;
582
+ todayLine: string;
583
+ /** Gallery card widths per size, cover height. */
584
+ gallerySmall: string;
585
+ galleryMedium: string;
586
+ galleryLarge: string;
587
+ coverHeight: string;
588
+ coverBg: string;
589
+ /** Pivot. */
590
+ pivotHeaderBg: string;
591
+ pivotTotalWeight: string;
592
+ /** Full-page database link row. */
593
+ linkIconSize: string;
594
+ };
595
+ /** Charts (`@toantranmei/chart-block`), also used by the database chart view. */
596
+ chart: {
597
+ height: string;
598
+ padding: string;
599
+ text: string;
600
+ title: string;
601
+ axis: string;
602
+ splitLine: string;
603
+ tooltipBg: string;
604
+ tooltipText: string;
605
+ tooltipBorder: string;
606
+ fontSize: string;
607
+ fontFamily: string;
608
+ series1: string;
609
+ series2: string;
610
+ series3: string;
611
+ series4: string;
612
+ series5: string;
613
+ series6: string;
614
+ series7: string;
615
+ series8: string;
616
+ series9: string;
617
+ /** Standalone block: data grid and config panel. */
618
+ cellWidth: string;
619
+ gridMaxHeight: string;
620
+ panelGap: string;
621
+ emptyColor: string;
622
+ };
623
+ /** Comment highlights, gutter badges and the side panel (`@toantranmei/comments`). */
624
+ comments: {
625
+ highlight: string;
626
+ highlightActive: string;
627
+ underline: string;
628
+ badgeBg: string;
629
+ badgeColor: string;
630
+ badgeActiveBg: string;
631
+ badgeActiveColor: string;
632
+ badgeSize: string;
633
+ badgeOffset: string;
634
+ badgeFontSize: string;
635
+ panelWidth: string;
636
+ panelBg: string;
637
+ panelBorder: string;
638
+ panelPadding: string;
639
+ threadGap: string;
640
+ threadRadius: string;
641
+ threadBorder: string;
642
+ threadActiveBorder: string;
643
+ threadPadding: string;
644
+ quoteColor: string;
645
+ quoteBorder: string;
646
+ avatarSize: string;
647
+ metaColor: string;
648
+ metaFontSize: string;
649
+ bodyFontSize: string;
650
+ composerMinHeight: string;
651
+ composerBg: string;
652
+ composerPadding: string;
653
+ composerWidth: string;
654
+ };
655
+ /** Synced block frame (`@toantranmei/synced-block`). */
656
+ synced: {
657
+ border: string;
658
+ borderWidth: string;
659
+ radius: string;
660
+ padding: string;
661
+ labelColor: string;
662
+ labelBg: string;
663
+ labelFontSize: string;
664
+ labelPadding: string;
665
+ labelOffset: string;
666
+ hoverBorder: string;
667
+ emptyColor: string;
668
+ gap: string;
669
+ };
468
670
  datepicker: {
469
671
  width: string;
470
672
  cell: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toantranmei/editor",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Notion-style block editor for Vue 3 and Nuxt, built on Tiptap.",
5
5
  "keywords": [
6
6
  "vue",
@@ -41,6 +41,14 @@
41
41
  "types": "./dist/types/nuxt.d.ts",
42
42
  "import": "./dist/nuxt.js"
43
43
  },
44
+ "./collaboration": {
45
+ "types": "./dist/types/collaboration.d.ts",
46
+ "import": "./dist/collaboration.js"
47
+ },
48
+ "./render": {
49
+ "types": "./dist/types/render/index.d.ts",
50
+ "import": "./dist/render.js"
51
+ },
44
52
  "./style.css": "./dist/style.css"
45
53
  },
46
54
  "sideEffects": [
@@ -50,7 +58,8 @@
50
58
  "@nuxt/kit": "^4.0.0",
51
59
  "katex": "^0.19.1",
52
60
  "mermaid": "^12.2.0",
53
- "vue": "^3.5.0"
61
+ "vue": "^3.5.0",
62
+ "yjs": "^13.6.0"
54
63
  },
55
64
  "peerDependenciesMeta": {
56
65
  "@nuxt/kit": {
@@ -61,6 +70,9 @@
61
70
  },
62
71
  "mermaid": {
63
72
  "optional": true
73
+ },
74
+ "yjs": {
75
+ "optional": true
64
76
  }
65
77
  },
66
78
  "dependencies": {
@@ -86,24 +98,27 @@
86
98
  "@tiptap/starter-kit": "3.32.0",
87
99
  "@tiptap/suggestion": "3.32.0",
88
100
  "@tiptap/vue-3": "3.32.0",
89
- "@tiptap/y-tiptap": "^3.0.7",
101
+ "@tiptap/y-tiptap": "3.0.11",
90
102
  "emojibase-data": "^18.0.0",
91
103
  "highlight.js": "^11.11.0",
92
104
  "lowlight": "^3.3.0",
93
- "y-protocols": "^1.0.6",
94
- "yjs": "^13.6.0"
105
+ "y-protocols": "^1.0.6"
95
106
  },
96
107
  "devDependencies": {
97
108
  "@nuxt/kit": "^4.6.2",
98
109
  "@nuxt/schema": "^4.6.2",
99
110
  "@types/node": "^26.6.5",
100
111
  "@vitejs/plugin-vue": "^6.0.10",
112
+ "@vue/test-utils": "^2.4.6",
113
+ "happy-dom": "21.0.4",
101
114
  "katex": "^0.19.1",
102
115
  "mermaid": "^12.2.0",
103
116
  "typescript": "~5.9.3",
104
117
  "vite": "^8.3.5",
118
+ "vitest": "5.0.5",
105
119
  "vue": "^3.5.0",
106
- "vue-tsc": "^3.0.0"
120
+ "vue-tsc": "^3.0.0",
121
+ "yjs": "^13.6.0"
107
122
  },
108
123
  "publishConfig": {
109
124
  "access": "public"
@@ -116,6 +131,7 @@
116
131
  "dev": "vite build --watch",
117
132
  "typecheck": "vue-tsc --noEmit -p tsconfig.json",
118
133
  "check:deps": "node scripts/check-deps.mjs",
119
- "check:styles": "node scripts/check-styles.mjs"
134
+ "check:styles": "node scripts/check-styles.mjs",
135
+ "test": "vitest run"
120
136
  }
121
137
  }