slate-vue3 0.0.2 → 0.0.3

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.md CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2024 Guan-Erjia
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Guan-Erjia
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,108 +1,108 @@
1
- [<img src="https://raw.githubusercontent.com/ianstormtaylor/slate/main/docs/images/banner.png" />](https://github.com/ianstormtaylor/slate/raw/main/docs/images/banner.png)
2
-
3
- <p align="center">
4
- slate-<a style="color: #087ea4" href="https://react.dev/">react</a> library implemented with <a style="color: #42b883" href="https://vuejs.org/">vue</a>
5
- </p>
6
- <br/>
7
-
8
- # Why use it?
9
-
10
- 1. Use vue internal response implementation to reduce the number of re-renderings
11
- 2. You can easily use vue-devtools to debug in a vue project
12
- 3. This library provides the same usage as slate-react
13
-
14
- # Demo
15
-
16
- Check out the [**live demo**](https://guan-erjia.github.io/slate-vue3/) of all of the examples
17
-
18
- # Hooks
19
-
20
- ## [useComposing](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-composing.ts)
21
-
22
- ```
23
- const useFocused: () => Ref<boolean, boolean>
24
- ```
25
-
26
- Get the current composing state of the editor. It deals with compositionstart, compositionupdate, compositionend events.
27
-
28
- Composition events are triggered by typing (composing) with a language that uses a composition character (e.g. Chinese, Japanese, Korean, etc.) example.
29
- Some basic Git commands are:
30
-
31
- ## [useFocused](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-focus.ts)
32
-
33
- ```
34
- const useFocused: () => Ref<boolean, boolean>
35
- ```
36
-
37
- Get the current focused state of the editor.
38
-
39
- ## [useReadOnly](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-read-only.ts)
40
-
41
- ```
42
- const useReadOnly: () => Ref<boolean, boolean>
43
- ```
44
-
45
- Get the current readOnly state of the editor.
46
-
47
- ## [useSelected](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-selected.ts)
48
-
49
- ```
50
- const useSelected: () => ComputedRef<boolean>
51
- ```
52
-
53
- Get the current selected state of an element.
54
-
55
- ## [useEditor](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-editor.ts)
56
-
57
- ```
58
- const useSlate: () => Editor;
59
- ```
60
-
61
- Get the current editor object from the React context. Re-renders the context whenever changes occur in the editor.
62
-
63
- ## [useSelection](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-selection.ts)
64
-
65
- ```
66
- const useSelection: () => ComputedRef<boolean>
67
- ```
68
-
69
- Get the current editor selection from the React context.
70
-
71
- # Packages
72
-
73
- **slate's codebase is monorepo managed with pnpm workspace**
74
-
75
- - [slate](https://github.com/Guan-Erjia/slate-vue3/tree/master/packages/slate)
76
- slate core logic, update synchronously with slate
77
- - [slate-dom](https://github.com/Guan-Erjia/slate-vue3/tree/master/packages/slate-dom)
78
- Implementation of slate on dom, update synchronously with slate-dom
79
- - [slate-vue](https://github.com/Guan-Erjia/slate-vue3/tree/master/packages/slate-vue)
80
- Vue components for rendering slate editors
81
- - [un-proxy-weakmap](https://github.com/Guan-Erjia/slate-vue3/tree/master/packages/un-proxy-weakmap)
82
- for special processing of proxy type data, obtain the raw pointer
83
-
84
- # compact files of slate
85
-
86
- **reactive implement**
87
-
88
- 1. packages/slate/src/interfaces/text.ts 115:115
89
- 2. packages/slate/src/create-editor.ts 94:94
90
- 3. packages/slate/src/transforms-node/set-nodes.ts 18:18
91
-
92
- **remove immer**
93
-
94
- 1. packages/slate/src/interfaces/node.ts 365:365
95
- 2. packages/slate/src/interfaces/point.ts 103:103
96
- 3. packages/slate/src/interfaces/range.ts 224:224
97
- 4. packages/slate/src/interfaces/transforms/general.ts 322:333
98
-
99
- **rewrite implement for WeakMap**
100
-
101
- 1. packages/un-proxy-weakmap/src/index.ts
102
- 2. packages/slate-dom/src/utils/weak-maps.ts
103
-
104
- **import types from globalThis in slate-dom**
105
- 1. packages/slate-dom/src/index.ts
106
- 2. packages/slate-dom/src/plugin/dom-editor.ts
107
- 3. packages/slate-dom/src/utils/dom.ts
108
-
1
+ [<img src="https://raw.githubusercontent.com/ianstormtaylor/slate/main/docs/images/banner.png" />](https://github.com/ianstormtaylor/slate/raw/main/docs/images/banner.png)
2
+
3
+ <p align="center">
4
+ slate-<a style="color: #087ea4" href="https://react.dev/">react</a> library implemented with <a style="color: #42b883" href="https://vuejs.org/">vue</a>
5
+ </p>
6
+ <br/>
7
+
8
+ # Why use it?
9
+
10
+ 1. Use vue internal response implementation to reduce the number of re-renderings
11
+ 2. You can easily use vue-devtools to debug in a vue project
12
+ 3. This library provides the same usage as slate-react
13
+
14
+ # Demo
15
+
16
+ Check out the [**live demo**](https://guan-erjia.github.io/slate-vue3/) of all of the examples
17
+
18
+ # Hooks
19
+
20
+ ## [useComposing](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-composing.ts)
21
+
22
+ ```
23
+ const useFocused: () => Ref<boolean, boolean>
24
+ ```
25
+
26
+ Get the current composing state of the editor. It deals with compositionstart, compositionupdate, compositionend events.
27
+
28
+ Composition events are triggered by typing (composing) with a language that uses a composition character (e.g. Chinese, Japanese, Korean, etc.) example.
29
+ Some basic Git commands are:
30
+
31
+ ## [useFocused](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-focus.ts)
32
+
33
+ ```
34
+ const useFocused: () => Ref<boolean, boolean>
35
+ ```
36
+
37
+ Get the current focused state of the editor.
38
+
39
+ ## [useReadOnly](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-read-only.ts)
40
+
41
+ ```
42
+ const useReadOnly: () => Ref<boolean, boolean>
43
+ ```
44
+
45
+ Get the current readOnly state of the editor.
46
+
47
+ ## [useSelected](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-selected.ts)
48
+
49
+ ```
50
+ const useSelected: () => ComputedRef<boolean>
51
+ ```
52
+
53
+ Get the current selected state of an element.
54
+
55
+ ## [useEditor](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-editor.ts)
56
+
57
+ ```
58
+ const useSlate: () => Editor;
59
+ ```
60
+
61
+ Get the current editor object from the React context. Re-renders the context whenever changes occur in the editor.
62
+
63
+ ## [useSelection](https://github.com/Guan-Erjia/slate-vue3/blob/master/packages/slate-vue/src/hooks/use-selection.ts)
64
+
65
+ ```
66
+ const useSelection: () => ComputedRef<boolean>
67
+ ```
68
+
69
+ Get the current editor selection from the React context.
70
+
71
+ # Packages
72
+
73
+ **slate's codebase is monorepo managed with pnpm workspace**
74
+
75
+ - [slate](https://github.com/Guan-Erjia/slate-vue3/tree/master/packages/slate)
76
+ slate core logic, update synchronously with slate
77
+ - [slate-dom](https://github.com/Guan-Erjia/slate-vue3/tree/master/packages/slate-dom)
78
+ Implementation of slate on dom, update synchronously with slate-dom
79
+ - [slate-vue](https://github.com/Guan-Erjia/slate-vue3/tree/master/packages/slate-vue)
80
+ Vue components for rendering slate editors
81
+ - [un-proxy-weakmap](https://github.com/Guan-Erjia/slate-vue3/tree/master/packages/un-proxy-weakmap)
82
+ for special processing of proxy type data, obtain the raw pointer
83
+
84
+ # compact files of slate
85
+
86
+ **reactive implement**
87
+
88
+ 1. packages/slate/src/interfaces/text.ts 115:115
89
+ 2. packages/slate/src/create-editor.ts 94:94
90
+ 3. packages/slate/src/transforms-node/set-nodes.ts 18:18
91
+
92
+ **remove immer**
93
+
94
+ 1. packages/slate/src/interfaces/node.ts 365:365
95
+ 2. packages/slate/src/interfaces/point.ts 103:103
96
+ 3. packages/slate/src/interfaces/range.ts 224:224
97
+ 4. packages/slate/src/interfaces/transforms/general.ts 322:333
98
+
99
+ **rewrite implement for WeakMap**
100
+
101
+ 1. packages/un-proxy-weakmap/src/index.ts
102
+ 2. packages/slate-dom/src/utils/weak-maps.ts
103
+
104
+ **import types from globalThis in slate-dom**
105
+ 1. packages/slate-dom/src/index.ts
106
+ 2. packages/slate-dom/src/plugin/dom-editor.ts
107
+ 3. packages/slate-dom/src/utils/dom.ts
108
+
package/dist/index.d.ts CHANGED
@@ -2509,13 +2509,17 @@ renderLeaf: (props: RenderLeafProps) => VNode;
2509
2509
  renderPlaceholder: (props: RenderPlaceholderProps) => JSX.Element;
2510
2510
  }, () => VNode<RendererNode, RendererElement, {
2511
2511
  [key: string]: any;
2512
- }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<{
2512
+ }>, {}, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, ("change" | "selectionchange" | "valuechange")[], "change" | "selectionchange" | "valuechange", PublicProps, Readonly<{
2513
2513
  editor: DOMEditor;
2514
2514
  decorate: (entry: NodeEntry) => DecoratedRange[];
2515
2515
  renderElement: (props: RenderElementProps) => VNode;
2516
2516
  renderLeaf: (props: RenderLeafProps) => VNode;
2517
2517
  renderPlaceholder: (props: RenderPlaceholderProps) => JSX.Element;
2518
- }> & Readonly<{}>, {
2518
+ }> & Readonly<{
2519
+ onChange?: ((...args: any[]) => any) | undefined;
2520
+ onSelectionchange?: ((...args: any[]) => any) | undefined;
2521
+ onValuechange?: ((...args: any[]) => any) | undefined;
2522
+ }>, {
2519
2523
  decorate: Function;
2520
2524
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
2521
2525
 
@@ -9582,10 +9582,7 @@ const withDOM = (editor, clipboardFormatKey = "x-slate-fragment") => {
9582
9582
  case "remove_node":
9583
9583
  case "merge_node":
9584
9584
  case "move_node":
9585
- case "split_node":
9586
- case "insert_text":
9587
- case "remove_text":
9588
- case "set_selection": {
9585
+ case "split_node": {
9589
9586
  IS_NODE_MAP_DIRTY.set(e2, true);
9590
9587
  }
9591
9588
  }
@@ -10016,6 +10013,7 @@ const isTextDecorationsEqual = (list, another) => {
10016
10013
  };
10017
10014
  const Slate = /* @__PURE__ */ defineComponent({
10018
10015
  name: "slate-editor",
10016
+ emits: ["change", "selectionchange", "valuechange"],
10019
10017
  props: {
10020
10018
  editor: {
10021
10019
  type: Object,
package/package.json CHANGED
@@ -1,77 +1,77 @@
1
- {
2
- "name": "slate-vue3",
3
- "version": "0.0.2",
4
- "type": "module",
5
- "workspaces": [
6
- "packages/*"
7
- ],
8
- "main": "dist/index.js",
9
- "module": "dist/index.js",
10
- "types": "dist/index.d.ts",
11
- "files": [
12
- "dist/"
13
- ],
14
- "scripts": {
15
- "dev": "vite",
16
- "build": "vite build",
17
- "preview": "vite preview",
18
- "build-all": "vite build --mode=lib"
19
- },
20
- "dependencies": {
21
- "direction": "^2.0.1",
22
- "is-hotkey": "^0.2.0",
23
- "lodash-es": "^4.17.21",
24
- "scroll-into-view-if-needed": "^3.1.0",
25
- "slate": "workspace:*",
26
- "slate-dom": "workspace:*",
27
- "slate-history": "^0.110.3",
28
- "slate-hyperscript": "^0.100.0",
29
- "slate-vue": "workspace:*",
30
- "vue": "^3.5.13",
31
- "vue-router": "^4.5.0"
32
- },
33
- "devDependencies": {
34
- "@faker-js/faker": "^9.4.0",
35
- "@types/is-hotkey": "^0.1.10",
36
- "@types/is-url": "^1.2.32",
37
- "@types/lodash-es": "^4.17.12",
38
- "@types/prismjs": "^1.26.5",
39
- "@vitejs/plugin-vue": "^5.2.1",
40
- "@vitejs/plugin-vue-jsx": "^4.1.1",
41
- "@vue/tsconfig": "^0.7.0",
42
- "image-extensions": "^1.1.0",
43
- "is-url": "^1.2.4",
44
- "prismjs": "^1.29.0",
45
- "typescript": "~5.7.2",
46
- "vite": "^6.0.11",
47
- "vite-plugin-dts": "^4.5.0",
48
- "vue-tsc": "^2.2.0"
49
- },
50
- "keywords": [
51
- "canvas",
52
- "contenteditable",
53
- "docs",
54
- "document",
55
- "edit",
56
- "editor",
57
- "editable",
58
- "html",
59
- "immutable",
60
- "markdown",
61
- "medium",
62
- "paper",
63
- "react",
64
- "rich",
65
- "richtext",
66
- "richtext",
67
- "slate",
68
- "slate-vue3",
69
- "text",
70
- "wysiwyg",
71
- "wysiwym"
72
- ],
73
- "repository": {
74
- "type": "git",
75
- "url": "https://github.com/Guan-Erjia/slate-vue3"
76
- }
77
- }
1
+ {
2
+ "name": "slate-vue3",
3
+ "version": "0.0.3",
4
+ "type": "module",
5
+ "workspaces": [
6
+ "packages/*"
7
+ ],
8
+ "main": "dist/index.js",
9
+ "module": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "files": [
12
+ "dist/"
13
+ ],
14
+ "scripts": {
15
+ "dev": "vite",
16
+ "build": "vite build",
17
+ "preview": "vite preview",
18
+ "build-all": "vite build --mode=lib"
19
+ },
20
+ "dependencies": {
21
+ "direction": "^2.0.1",
22
+ "is-hotkey": "^0.2.0",
23
+ "lodash-es": "^4.17.21",
24
+ "scroll-into-view-if-needed": "^3.1.0",
25
+ "slate": "workspace:*",
26
+ "slate-dom": "workspace:*",
27
+ "slate-history": "^0.110.3",
28
+ "slate-hyperscript": "^0.100.0",
29
+ "slate-vue": "workspace:*",
30
+ "vue": "^3.5.13",
31
+ "vue-router": "^4.5.0"
32
+ },
33
+ "devDependencies": {
34
+ "@faker-js/faker": "^9.4.0",
35
+ "@types/is-hotkey": "^0.1.10",
36
+ "@types/is-url": "^1.2.32",
37
+ "@types/lodash-es": "^4.17.12",
38
+ "@types/prismjs": "^1.26.5",
39
+ "@vitejs/plugin-vue": "^5.2.1",
40
+ "@vitejs/plugin-vue-jsx": "^4.1.1",
41
+ "@vue/tsconfig": "^0.7.0",
42
+ "image-extensions": "^1.1.0",
43
+ "is-url": "^1.2.4",
44
+ "prismjs": "^1.29.0",
45
+ "typescript": "~5.7.2",
46
+ "vite": "^6.0.11",
47
+ "vite-plugin-dts": "^4.5.0",
48
+ "vue-tsc": "^2.2.0"
49
+ },
50
+ "keywords": [
51
+ "canvas",
52
+ "contenteditable",
53
+ "docs",
54
+ "document",
55
+ "edit",
56
+ "editor",
57
+ "editable",
58
+ "html",
59
+ "immutable",
60
+ "markdown",
61
+ "medium",
62
+ "paper",
63
+ "react",
64
+ "rich",
65
+ "richtext",
66
+ "richtext",
67
+ "slate",
68
+ "slate-vue3",
69
+ "text",
70
+ "wysiwyg",
71
+ "wysiwym"
72
+ ],
73
+ "repository": {
74
+ "type": "git",
75
+ "url": "https://github.com/Guan-Erjia/slate-vue3"
76
+ }
77
+ }