editate 0.6.26 → 0.7.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.
@@ -4,8 +4,7 @@ import { Editor } from '../editor.js';
4
4
  /**
5
5
  * A plugin to make specific blocks read-only.
6
6
  *
7
- * Locked blocks can still be selected and copied, but operations editing them are cancelled,
8
- * except ones that unlock the block and ones targeting the root (e.g. undo / redo).
7
+ * Locked blocks can still be selected and copied, but operations editing them are cancelled with their transaction, except ones that unlock the block.
9
8
  */
10
9
  export declare function blockLockPlugin<T extends DocNode>(editor: Editor<T>, options: {
11
10
  /**
@@ -4,5 +4,6 @@ export { debugPlugin } from './debug.js';
4
4
  export { keymapPlugin } from './keymap.js';
5
5
  export { Undo, Redo, Undoable, Redoable, ClearHistory } from './history.js';
6
6
  export { scrollToSelectionPlugin } from './scrollToSelection.js';
7
+ export { nodeIdPlugin, NodeId } from './nodeId.js';
7
8
  export { selectionRectPlugin } from './selectionRect.js';
8
9
  export { singlelinePlugin } from './singleline.js';
@@ -0,0 +1,13 @@
1
+ import { DocNode, Node } from '../doc/types.js';
2
+ import { Editor } from '../editor.js';
3
+ /**
4
+ * A plugin to give immutable document nodes stable identifiers suitable for renderer keys.
5
+ *
6
+ * An id belongs to a node object and follows the node across edits.
7
+ * A node recreated by an operation takes over the id of the node it was derived from.
8
+ */
9
+ export declare function nodeIdPlugin<T extends DocNode>(editor: Editor<T>): void;
10
+ /**
11
+ * Get the stable identifier of the given node, which is assigned on the first call.
12
+ */
13
+ export declare function NodeId(editor: Editor, node: Node): string;
@@ -1,5 +1,5 @@
1
1
  import { Editor } from '../editor.js';
2
2
  /**
3
- * A plugin to restrict input to a single line
3
+ * A plugin to restrict input to a single line. It is required for a single line document of inline nodes.
4
4
  */
5
5
  export declare function singlelinePlugin(editor: Editor): void;
package/lib/queries.d.ts CHANGED
@@ -1,7 +1,15 @@
1
- import { InferInlineNode } from './doc/types-infer.js';
1
+ import { InferInlineNode, InferLeafBlockNode } from './doc/types-infer.js';
2
2
  import { DocNode, Range } from './doc/types.js';
3
3
  import { Editor } from './editor.js';
4
4
  /**
5
- * Get leaf nodes that intersect with the selection or specified range.
5
+ * Get leaf nodes that intersect with the selection or specified range. An empty leaf is included wherever the range reaches it.
6
6
  */
7
7
  export declare function LeavesInRange<T extends DocNode>(editor: Editor<T>, range?: Range): Generator<InferInlineNode<T>, void, void>;
8
+ /**
9
+ * Get leaf block nodes that intersect with the selection or specified range, with their offsets. An empty block is included wherever the range reaches it.
10
+ */
11
+ export declare function BlocksInRange<T extends DocNode>(editor: Editor<T>, range?: Range): Generator<[
12
+ node: InferLeafBlockNode<T>,
13
+ offset: number,
14
+ range: Range
15
+ ], void, void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "editate",
3
- "version": "0.6.26",
3
+ "version": "0.7.0",
4
4
  "description": "An experimental, type-safe, framework agnostic and small (5kB+) contenteditable state manager.",
5
5
  "main": "lib/index.cjs",
6
6
  "module": "lib/index.js",
@@ -21,7 +21,8 @@
21
21
  "scripts": {
22
22
  "build": "vite build",
23
23
  "tsc": "tsc -p . --noEmit",
24
- "test": "vitest --run --typecheck",
24
+ "test": "vitest --run --project unit",
25
+ "test:browser": "vitest --run --project browser",
25
26
  "format": "prettier '**/*.{js,ts,jsx,tsx}' --write --cache",
26
27
  "format:ci": "prettier '**/*.{js,ts,jsx,tsx}' -l",
27
28
  "storybook": "storybook dev -p 6006",
@@ -36,48 +37,49 @@
36
37
  "@standard-schema/spec": "^1.0.0"
37
38
  },
38
39
  "devDependencies": {
39
- "@chenglou/pretext": "^0.0.8",
40
- "@dnd-kit/helpers": "^0.5.0",
41
- "@dnd-kit/react": "^0.5.0",
42
- "@playwright/test": "^1.60.0",
43
- "@size-limit/preset-small-lib": "^12.0.0",
44
- "@storybook/addon-docs": "^10.4.0",
45
- "@storybook/react-vite": "^10.4.0",
46
- "@textlint/kernel": "^15.0.0",
47
- "@textlint/textlint-plugin-text": "^15.0.0",
40
+ "@chenglou/pretext": "^1.0.0",
41
+ "@dnd-kit/helpers": "^0.5.3",
42
+ "@dnd-kit/react": "^0.5.3",
43
+ "@non-standardworld/stone-engine.js": "^0.2.0",
44
+ "@playwright/test": "1.61.0",
45
+ "@size-limit/preset-small-lib": "^14.3.0",
46
+ "@storybook/addon-docs": "^10.6.6",
47
+ "@storybook/react-vite": "^10.6.6",
48
+ "@textlint/kernel": "^15.8.0",
49
+ "@textlint/textlint-plugin-text": "^15.8.0",
48
50
  "@types/prismjs": "^1.26.6",
49
- "@types/react": "^19.2.0",
50
- "@types/react-dom": "^19.2.0",
51
- "ai": "^7.0.42",
51
+ "@types/react": "^19.3.0",
52
+ "@types/react-dom": "^19.3.0",
53
+ "@vitest/browser-playwright": "^5.1.0",
54
+ "ai": "^7.0.164",
52
55
  "diff": "^9.0.0",
53
- "esbuild": "^0.28.0",
54
- "jsdom": "^30.0.0",
56
+ "jsdom": "^31.0.0",
55
57
  "kuromojin": "^3.0.1",
56
- "linkifyjs": "^4.3.1",
58
+ "linkifyjs": "^4.4.0",
57
59
  "node-emoji": "^2.2.0",
58
- "patch-package": "^8.0.0",
60
+ "patch-package": "^8.0.1",
59
61
  "path-browserify": "^1.0.1",
60
- "prettier": "^3.8.1",
62
+ "prettier": "^3.9.10",
61
63
  "prismjs": "^1.30.0",
62
- "react": "^19.2.6",
63
- "react-dom": "^19.2.6",
64
- "react-is": "^19.2.6",
64
+ "react": "^19.3.1",
65
+ "react-dom": "^19.3.1",
66
+ "react-is": "^19.3.1",
65
67
  "remark-gfm": "^4.0.1",
66
68
  "remark-parse": "^11.0.0",
67
- "rimraf": "6.1.3",
68
- "shiki": "^4.3.1",
69
- "size-limit": "^12.0.0",
70
- "storybook": "^10.4.0",
71
- "terser": "^5.48.0",
69
+ "rimraf": "6.1.4",
70
+ "shiki": "^4.6.0",
71
+ "size-limit": "^14.3.0",
72
+ "storybook": "^10.6.6",
73
+ "terser": "^5.51.2",
72
74
  "textlint-rule-preset-japanese": "^10.0.4",
73
75
  "typedoc": "^0.28.0",
74
76
  "typedoc-plugin-markdown": "^4.6.3",
75
77
  "typescript": "^6.0.0",
76
78
  "unified": "^11.0.5",
77
- "valibot": "^1.4.0",
78
- "vite": "^8.0.13",
79
+ "valibot": "^1.5.0",
80
+ "vite": "^8.3.6",
79
81
  "vite-plugin-dts": "^5.0.2",
80
- "vitest": "^4.1.6"
82
+ "vitest": "^5.1.0"
81
83
  },
82
84
  "repository": {
83
85
  "type": "git",