xiaodao-editor 0.1.19 → 0.1.21

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 (36) hide show
  1. package/README.ZH.md +191 -68
  2. package/README.md +230 -78
  3. package/dist/block-editor.js +10444 -20908
  4. package/dist/block-editor.umd.cjs +30 -285
  5. package/dist/core/Editor.d.ts +32 -0
  6. package/dist/core/command/primitiveCommands.d.ts +1 -1
  7. package/dist/core/plugin/Plugin.d.ts +45 -5
  8. package/dist/core/state/EditorState.d.ts +5 -2
  9. package/dist/core/state/invert.d.ts +2 -2
  10. package/dist/core/types.d.ts +1 -1
  11. package/dist/extensions/Equation.d.ts +73 -8
  12. package/dist/extensions/Image.d.ts +54 -17
  13. package/dist/extensions/OrderedList.d.ts +1 -1
  14. package/dist/extensions/Paragraph.d.ts +1 -1
  15. package/dist/extensions/Table.d.ts +1 -1
  16. package/dist/extensions/math/ast.d.ts +140 -0
  17. package/dist/extensions/math/index.d.ts +18 -0
  18. package/dist/extensions/math/parser.d.ts +5 -0
  19. package/dist/extensions/math/renderHtml.d.ts +5 -0
  20. package/dist/extensions/math/renderTree.d.ts +16 -0
  21. package/dist/extensions/math/renderVNode.d.ts +4 -0
  22. package/dist/extensions/math/symbols.d.ts +37 -0
  23. package/dist/extensions/math/tokens.d.ts +22 -0
  24. package/dist/extensions/tableModel.d.ts +6 -6
  25. package/dist/i18n.d.ts +2 -2
  26. package/dist/index.d.ts +6 -3
  27. package/dist/style.css +1 -1
  28. package/dist/view/BlockEditor.vue.d.ts +0 -30
  29. package/dist/view/BlockList.vue.d.ts +2 -2
  30. package/dist/view/context.d.ts +11 -2
  31. package/dist/view/imageUpload.d.ts +20 -14
  32. package/dist/view/ui/icons.d.ts +22 -22
  33. package/dist/view/ui/inputRulesEngine.d.ts +2 -2
  34. package/dist/view/ui/popup.d.ts +1 -1
  35. package/dist/view/urlUtils.d.ts +2 -2
  36. package/package.json +2 -3
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Tokenizer for the built-in math renderer.
3
+ *
4
+ * The tokenizer is deliberately dumb: it recognises the *shape* of the input
5
+ * (commands, braces, scripts, delimiters, ...) and never tries to understand
6
+ * mathematical structure. Structure is the parser's job.
7
+ *
8
+ * Single pass, O(n), no backtracking.
9
+ */
10
+ export type TokenKind = 'command' | 'char' | 'number' | 'operator' | 'lbrace' | 'rbrace' | 'lbracket' | 'rbracket' | 'lparen' | 'rparen' | 'sup' | 'sub' | 'amp' | 'newline' | 'space';
11
+ export interface Token {
12
+ readonly kind: TokenKind;
13
+ /** For `command`, the name WITHOUT the leading backslash. */
14
+ readonly value: string;
15
+ readonly start: number;
16
+ readonly end: number;
17
+ }
18
+ /**
19
+ * Split a LaTeX-ish math expression into tokens. Never throws: any character
20
+ * that is not otherwise recognised becomes an `operator` token.
21
+ */
22
+ export declare function tokenize(source: string): Token[];
@@ -1,6 +1,6 @@
1
1
  import { InlineSeq, JSONValue } from '../core/types';
2
2
  export interface TableCellData {
3
- /** Cell content reuses the editor's InlineSeq so rich inline marks
3
+ /** Cell content: reuses the editor's InlineSeq so rich inline marks
4
4
  * (bold/italic/link/code) are first-class inside cells. */
5
5
  readonly content: InlineSeq;
6
6
  /** How many rows this cell spans (≥ 1). 1 = no row span. */
@@ -76,13 +76,13 @@ export declare function coerceTableAttrs(raw: Readonly<Record<string, unknown>>)
76
76
  * rowspan/colspan > 1 we mark the covered cells accordingly (setting
77
77
  * content=[], rowspan=colspan=1, covered=true so the renderer skips).
78
78
  *
79
- * Clamps out-of-bounds spans to the actual grid this prevents malformed
79
+ * Clamps out-of-bounds spans to the actual grid: this prevents malformed
80
80
  * input from ever producing a cell with a span larger than the grid.
81
81
  */
82
82
  export declare function recomputeCovered(cells: readonly (readonly TableCellData[])[], rows: number, cols: number): TableCellData[][];
83
83
  /** Insert a new row before `beforeRow` (0 ≤ beforeRow ≤ rows). When
84
84
  * beforeRow === rows appends at the bottom. New row cells are empty
85
- * clones of the row above (same column spans but only if they start
85
+ * clones of the row above (same column spans: but only if they start
86
86
  * on the row being cloned). Otherwise plain empty cells. */
87
87
  export declare function insertRow(attrs: TableAttrs, beforeRow: number): TableAttrs;
88
88
  /** Remove row `rowIndex`. When the last row is removed we still keep 1 row
@@ -142,8 +142,8 @@ export declare function toggleCellsMark(attrs: TableAttrs, positions: readonly {
142
142
  * always the top-left. Existing merges inside the rect are flattened.
143
143
  *
144
144
  * Content policy: ONLY the cell that originally occupied the top-left
145
- * anchor position (rs, cs) or the anchor of the merged block that covers
146
- * it contributes its InlineSeq to the merged cell. Every other cell's
145
+ * anchor position (rs, cs), or the anchor of the merged block that covers
146
+ * it, contributes its InlineSeq to the merged cell. Every other cell's
147
147
  * content is discarded (matches Notion's "first cell wins" semantics).
148
148
  * The anchor's cell-level attrs (cellType / align / bgColor) are also
149
149
  * preserved unchanged.
@@ -157,7 +157,7 @@ export declare function splitCell(attrs: TableAttrs, row: number, col: number):
157
157
  * This is the operation triggered by the "Split cells" toolbar button
158
158
  * when the user has a multi-cell selection. Each merged cell inside the
159
159
  * (expanded) rect is split independently using the same rule as splitCell
160
- * above its data stays on its own top-left position. */
160
+ * above: its data stays on its own top-left position. */
161
161
  export declare function splitCellsInRect(attrs: TableAttrs, r1: number, c1: number, r2: number, c2: number): TableAttrs;
162
162
  /** Toggle the header-row flag on/off. */
163
163
  export declare function toggleHeaderRow(attrs: TableAttrs): TableAttrs;
package/dist/i18n.d.ts CHANGED
@@ -13,7 +13,7 @@ export interface I18nBundle {
13
13
  /**
14
14
  * Reactive refs for locale and theme. These are provided directly (not
15
15
  * wrapped in an object) so that each consumer's `t()` function accesses
16
- * `localeRef.value` a plain ref read which Vue's reactivity system
16
+ * `localeRef.value` (a plain ref read), which Vue's reactivity system
17
17
  * tracks reliably across <Teleport> boundaries.
18
18
  */
19
19
  export declare const localeKey: InjectionKey<Ref<Locale>>;
@@ -22,7 +22,7 @@ export declare function provideI18n(locale: Ref<Locale>, theme: Ref<Theme>): voi
22
22
  /**
23
23
  * Access the i18n/theme bundle within a child component. Each call
24
24
  * injects the raw locale/theme refs and builds a fresh `t()` that reads
25
- * `localeRef.value` directly no computed, no closure-over-computed.
25
+ * `localeRef.value` directly: no computed, no closure-over-computed.
26
26
  *
27
27
  * When the parent updates `localeRef.value`, every template or computed
28
28
  * that called `t('key')` re-renders because the ref read was tracked
package/dist/index.d.ts CHANGED
@@ -20,9 +20,12 @@ export { HeadingExtension } from './extensions/Heading';
20
20
  export { KeymapExtension } from './extensions/Keymap';
21
21
  export { HistoryExtension } from './extensions/History';
22
22
  export { ImageExtension } from './extensions/Image';
23
- export type { ImageAttrs } from './extensions/Image';
24
- export { EquationExtension } from './extensions/Equation';
25
- export type { EquationAttrs } from './extensions/Equation';
23
+ export { createImageExtension, CANCEL_IMAGE_UPLOAD_COMMAND, START_IMAGE_UPLOAD_METHOD, } from './extensions/Image';
24
+ export type { ImageAttrs, ImageExtensionOptions } from './extensions/Image';
25
+ export { EquationExtension, createEquationExtension, builtinEquationRenderer, EquationBlock, renderEquation, } from './extensions/Equation';
26
+ export type { EquationAttrs, EquationDiagnostic, EquationExtensionOptions, EquationRenderer, EquationRenderOptions, EquationRenderResult, RenderResult, } from './extensions/Equation';
27
+ export { parseMath, SUPPORTED_COMMANDS } from './extensions/math';
28
+ export type { MathNode, ParseResult as MathParseResult } from './extensions/math';
26
29
  export { TableExtension } from './extensions/Table';
27
30
  export type { TableAttrs, TableCellData } from './extensions/tableModel';
28
31
  export { DividerExtension } from './extensions/Divider';