dn-react-text-editor 0.1.1 → 0.2.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 (55) hide show
  1. package/README.md +14 -214
  2. package/dist/attach_file.d.mts +20 -18
  3. package/dist/attach_file.d.ts +20 -18
  4. package/dist/attach_file.js +18 -9
  5. package/dist/attach_file.mjs +18 -9
  6. package/dist/base64_file_uploader.d.mts +6 -0
  7. package/dist/base64_file_uploader.d.ts +6 -0
  8. package/dist/{plugins/trailing_paragraph.js → base64_file_uploader.js} +19 -22
  9. package/dist/base64_file_uploader.mjs +18 -0
  10. package/dist/commands.d.mts +23 -0
  11. package/dist/commands.d.ts +23 -0
  12. package/dist/commands.js +110 -0
  13. package/dist/commands.mjs +75 -0
  14. package/dist/create_text_editor.d.mts +28 -0
  15. package/dist/create_text_editor.d.ts +28 -0
  16. package/dist/create_text_editor.js +1082 -0
  17. package/dist/create_text_editor.mjs +1053 -0
  18. package/dist/html.d.mts +8 -0
  19. package/dist/html.d.ts +8 -0
  20. package/dist/html.js +136 -0
  21. package/dist/html.mjs +98 -0
  22. package/dist/index.d.mts +7 -4
  23. package/dist/index.d.ts +7 -4
  24. package/dist/index.js +790 -380
  25. package/dist/index.mjs +789 -377
  26. package/dist/input.d.mts +21 -0
  27. package/dist/input.d.ts +21 -0
  28. package/dist/input.js +70 -0
  29. package/dist/input.mjs +37 -0
  30. package/dist/plugins/drag_and_drop.d.mts +1 -1
  31. package/dist/plugins/drag_and_drop.d.ts +1 -1
  32. package/dist/plugins/drag_and_drop.js +3 -0
  33. package/dist/plugins/drag_and_drop.mjs +3 -0
  34. package/dist/plugins/highlighter.d.mts +6 -0
  35. package/dist/plugins/highlighter.d.ts +6 -0
  36. package/dist/plugins/highlighter.js +105 -0
  37. package/dist/plugins/highlighter.mjs +69 -0
  38. package/dist/plugins/keymap.js +17 -0
  39. package/dist/plugins/keymap.mjs +17 -0
  40. package/dist/schema.d.mts +2 -2
  41. package/dist/schema.d.ts +2 -2
  42. package/dist/schema.js +255 -14
  43. package/dist/schema.mjs +245 -14
  44. package/dist/text_editor_controller.d.mts +46 -0
  45. package/dist/text_editor_controller.d.ts +46 -0
  46. package/dist/text_editor_controller.js +503 -0
  47. package/dist/text_editor_controller.mjs +470 -0
  48. package/package.json +3 -1
  49. package/dist/plugins/trailing_paragraph.d.mts +0 -5
  50. package/dist/plugins/trailing_paragraph.d.ts +0 -5
  51. package/dist/plugins/trailing_paragraph.mjs +0 -21
  52. package/dist/text_editor.d.mts +0 -37
  53. package/dist/text_editor.d.ts +0 -37
  54. package/dist/text_editor.js +0 -720
  55. package/dist/text_editor.mjs +0 -687
package/README.md CHANGED
@@ -1,222 +1,22 @@
1
- # React Store Input
1
+ # React Text Editor
2
2
 
3
- The goal of this package is to make state management easier when using input elements in React.
3
+ A rich text editor component for React built on ProseMirror.
4
4
 
5
- It eliminates repetitive code required to implement state changes and subscriptions for input elements, and provides a simple interface.
6
-
7
- At the same time, it allows you to use all the attributes originally provided by the input tag as-is, without needing to learn this package.
8
-
9
- ## Get Started
10
-
11
- This is a simple example of how to use this package.
12
-
13
- ```tsx
14
- import { useFormStore } from "dn-react-input";
15
-
16
- export default function App() {
17
- const store = useFormStore({
18
- email: "",
19
- password: "",
20
- });
21
-
22
- const submit = async () => {
23
- const { email, password } = store.state;
24
-
25
- alert(`Email: ${email}\nPassword: ${password}`);
26
- };
27
-
28
- return (
29
- <form
30
- onSubmit={(e) => {
31
- e.preventDefault();
32
- submit();
33
- }}
34
- >
35
- <store.input name="email" type="email" />
36
- <store.input name="password" type="password" />
37
- <button type="submit">Submit</button>
38
- </form>
39
- );
40
- }
41
- ```
42
-
43
- ## How to define state?
44
-
45
- You can define any state you want as an object when calling `useStore`.
46
-
47
- ```tsx
48
- function Component() {
49
- ...
50
-
51
- const store = useStore({
52
- email: "",
53
- password: "",
54
- rememberMe: false,
55
- });
56
-
57
- ...
58
- }
59
- ```
60
-
61
- It's a single source of truth for your form state.
62
-
63
- ## How to get input values?
64
-
65
- You can access the current values of the input elements through the `state` property of the store.
66
-
67
- ```tsx
68
- function Component() {
69
- ...
70
-
71
- const submit = () => {
72
- const { email, password, rememberMe } = store.state;
73
- };
74
-
75
- ...
76
- }
77
- ```
78
-
79
- ## How to add input elements?
80
-
81
- You can add input elements using the `Input` component provided by the store. There are 'Select' and 'Textarea' components as well.
82
-
83
- ```tsx
84
- import { Input } from "dn-react-input";
85
-
86
- function Component() {
87
- ...
88
-
89
- return (
90
- <form>
91
- <Input store={store} name="email" type="email" />
92
- <Input store={store} name="password" type="password" />
93
- <Input store={store} name="rememberMe" type="checkbox" />
94
- </form>
95
- );
96
- }
97
- ```
98
-
99
- If you want to avoid passing the store to each input component, use `useStoreInput`. This hook provides input components that are already connected to the store.
100
-
101
- ```tsx
102
- import { useStoreInput } from "dn-react-input";
103
-
104
- function Component() {
105
- ...
106
- const Input = useStoreInput(store);
107
-
108
- return (
109
- <form>
110
- <Input.input name="email" type="email" />
111
- <Input.input name="password" type="password" />
112
- <Input.input name="rememberMe" type="checkbox" />
113
- </form>
114
- );
115
- }
116
- ```
117
-
118
- `useFormStore` is a facade that combines `useStore` and `useStoreInput` for convenience.
119
-
120
- ```tsx
121
- import { useFormStore } from "dn-react-input";
122
-
123
- function Component() {
124
- ...
125
- const store = useFormStore({
126
- email: "",
127
- password: "",
128
- rememberMe: false,
129
- });
130
-
131
- return (
132
- <form>
133
- <store.input name="email" type="email" />
134
- <store.input name="password" type="password" />
135
- <store.input name="rememberMe" type="checkbox" />
136
- </form>
137
- );
138
- }
139
- ```
140
-
141
- ## How to render components on state changes?
142
-
143
- If you want to render a component only when specific parts of the state change, use the `useSelector` hook.
144
-
145
- ```tsx
146
- import { useSelector } from "dn-react-input";
147
-
148
- function Component() {
149
- ...
150
- const email = useSelector(store, (state) => state.email);
151
-
152
- return <div>Your email is: {email}</div>;
153
- }
154
- ```
155
-
156
- If you want to render components in an inline manner, use the `createRender` function. By using this, you can avoid creating separate components for each part of the state you want to track.
157
-
158
- ```tsx
159
- import { createRender } from "dn-react-input";
160
-
161
- function Component() {
162
- ...
163
- return (
164
- <div>
165
- {createRender(store, (state) => <p>{state.email}</p>)}
166
- {createRender(store, (state) => <p>{state.password}</p>)}
167
- </div>
168
- );
169
- }
170
- ```
171
-
172
- ## How to subscribe to state changes?
173
-
174
- You can subscribe to state changes using the `subscribe` method of the store.
175
-
176
- ```tsx
177
- function Component() {
178
- ...
179
- useEffect(() => {
180
- const unsubscribe = store.subscribe((state) => {
181
- console.log(`State changed`, state);
182
- });
183
-
184
- return () => {
185
- unsubscribe();
186
- };
187
- }, []);
188
-
189
- ...
190
- }
191
- ```
192
-
193
- ## How to update state manually?
194
-
195
- You can update the state manually using the `dispatch` method of the store.
196
-
197
- ```tsx
198
- function Component() {
199
- ...
200
- const updateEmail = () => {
201
- store.dispatch({ email: "ohjinsu98@icloud.com" });
202
- };
203
-
204
- return <button onClick={updateEmail}>Update Email</button>;
205
- }
206
- ```
207
-
208
- The `dispatch` method uses immerjs internally to update the state, so you can also use a function to update the state based on the previous state.
5
+ ## Example
209
6
 
210
7
  ```tsx
211
- function Component() {
212
- ...
8
+ import { TextEditor } from "dn-react-text-editor";
213
9
 
214
- const updateEmail = () => {
215
- store.dispatch((state) => {
216
- state.email = "ohjinsu98@icloud.com";
217
- });
218
- };
10
+ const TextEditor = useTextEditor();
219
11
 
220
- return <button onClick={updateEmail}>Update Email</button>;
12
+ function App() {
13
+ return (
14
+ <TextEditor
15
+ placeholder="Write something..."
16
+ onChange={(e) => {
17
+ console.log(e.target.value);
18
+ }}
19
+ />
20
+ );
221
21
  }
222
22
  ```
@@ -3,26 +3,28 @@ import { createSchema } from './schema.mjs';
3
3
  import 'orderedmap';
4
4
  import 'prosemirror-model';
5
5
 
6
- type AttachFile = (view: EditorView, files: File[]) => Promise<void>;
6
+ type GenerateMetadata = (file: File) => Promise<{
7
+ width?: number;
8
+ height?: number;
9
+ poster?: string;
10
+ }> | {
11
+ width?: number;
12
+ height?: number;
13
+ poster?: string;
14
+ };
15
+ type UploadFile = (file: File) => Promise<{
16
+ src: string;
17
+ alt?: string;
18
+ }> | {
19
+ src: string;
20
+ alt?: string;
21
+ };
7
22
  type AttachFileOptions = {
8
23
  schema: ReturnType<typeof createSchema>;
9
- generateMetadata?: (file: File) => Promise<{
10
- width?: number;
11
- height?: number;
12
- poster?: string;
13
- }> | {
14
- width?: number;
15
- height?: number;
16
- poster?: string;
17
- };
18
- uploadFile?: (file: File) => Promise<{
19
- src: string;
20
- alt?: string;
21
- }> | {
22
- src: string;
23
- alt?: string;
24
- };
24
+ generateMetadata?: GenerateMetadata;
25
+ uploadFile?: UploadFile;
25
26
  };
27
+ type AttachFile = (view: EditorView, files: File[]) => Promise<void>;
26
28
  declare function createAttachFile({ schema, generateMetadata, uploadFile, }: AttachFileOptions): AttachFile;
27
29
 
28
- export { type AttachFile, createAttachFile };
30
+ export { type AttachFile, type AttachFileOptions, type GenerateMetadata, type UploadFile, createAttachFile };
@@ -3,26 +3,28 @@ import { createSchema } from './schema.js';
3
3
  import 'orderedmap';
4
4
  import 'prosemirror-model';
5
5
 
6
- type AttachFile = (view: EditorView, files: File[]) => Promise<void>;
6
+ type GenerateMetadata = (file: File) => Promise<{
7
+ width?: number;
8
+ height?: number;
9
+ poster?: string;
10
+ }> | {
11
+ width?: number;
12
+ height?: number;
13
+ poster?: string;
14
+ };
15
+ type UploadFile = (file: File) => Promise<{
16
+ src: string;
17
+ alt?: string;
18
+ }> | {
19
+ src: string;
20
+ alt?: string;
21
+ };
7
22
  type AttachFileOptions = {
8
23
  schema: ReturnType<typeof createSchema>;
9
- generateMetadata?: (file: File) => Promise<{
10
- width?: number;
11
- height?: number;
12
- poster?: string;
13
- }> | {
14
- width?: number;
15
- height?: number;
16
- poster?: string;
17
- };
18
- uploadFile?: (file: File) => Promise<{
19
- src: string;
20
- alt?: string;
21
- }> | {
22
- src: string;
23
- alt?: string;
24
- };
24
+ generateMetadata?: GenerateMetadata;
25
+ uploadFile?: UploadFile;
25
26
  };
27
+ type AttachFile = (view: EditorView, files: File[]) => Promise<void>;
26
28
  declare function createAttachFile({ schema, generateMetadata, uploadFile, }: AttachFileOptions): AttachFile;
27
29
 
28
- export { type AttachFile, createAttachFile };
30
+ export { type AttachFile, type AttachFileOptions, type GenerateMetadata, type UploadFile, createAttachFile };
@@ -90,16 +90,27 @@ var findPlaceholder = (state, id) => {
90
90
  return found.length ? found[0].from : null;
91
91
  };
92
92
 
93
+ // src/base64_file_uploader.ts
94
+ var base64FileUploader = async (file) => {
95
+ const base64 = await new Promise((resolve, reject) => {
96
+ const reader = new FileReader();
97
+ reader.onload = () => {
98
+ resolve(reader.result);
99
+ };
100
+ reader.onerror = reject;
101
+ reader.readAsDataURL(file);
102
+ });
103
+ return {
104
+ src: base64,
105
+ alt: file.name
106
+ };
107
+ };
108
+
93
109
  // src/attach_file.tsx
94
110
  function createAttachFile({
95
111
  schema,
96
112
  generateMetadata,
97
- uploadFile = (file) => {
98
- return {
99
- src: URL.createObjectURL(file),
100
- alt: file.name
101
- };
102
- }
113
+ uploadFile = base64FileUploader
103
114
  }) {
104
115
  const attachEachFile = async (view, file, pos) => {
105
116
  const metadata = generateMetadata ? await generateMetadata(file) : {};
@@ -151,9 +162,7 @@ function createAttachFile({
151
162
  }
152
163
  view.dispatch(tr2.replaceWith($pos, $pos, node));
153
164
  } catch (e) {
154
- view.dispatch(
155
- tr.setMeta(uploadPlaceholderPlugin, { remove: { id } })
156
- );
165
+ view.dispatch(tr.setMeta(uploadPlaceholderPlugin, { remove: { id } }));
157
166
  }
158
167
  };
159
168
  return async (view, files, pos) => {
@@ -66,16 +66,27 @@ var findPlaceholder = (state, id) => {
66
66
  return found.length ? found[0].from : null;
67
67
  };
68
68
 
69
+ // src/base64_file_uploader.ts
70
+ var base64FileUploader = async (file) => {
71
+ const base64 = await new Promise((resolve, reject) => {
72
+ const reader = new FileReader();
73
+ reader.onload = () => {
74
+ resolve(reader.result);
75
+ };
76
+ reader.onerror = reject;
77
+ reader.readAsDataURL(file);
78
+ });
79
+ return {
80
+ src: base64,
81
+ alt: file.name
82
+ };
83
+ };
84
+
69
85
  // src/attach_file.tsx
70
86
  function createAttachFile({
71
87
  schema,
72
88
  generateMetadata,
73
- uploadFile = (file) => {
74
- return {
75
- src: URL.createObjectURL(file),
76
- alt: file.name
77
- };
78
- }
89
+ uploadFile = base64FileUploader
79
90
  }) {
80
91
  const attachEachFile = async (view, file, pos) => {
81
92
  const metadata = generateMetadata ? await generateMetadata(file) : {};
@@ -127,9 +138,7 @@ function createAttachFile({
127
138
  }
128
139
  view.dispatch(tr2.replaceWith($pos, $pos, node));
129
140
  } catch (e) {
130
- view.dispatch(
131
- tr.setMeta(uploadPlaceholderPlugin, { remove: { id } })
132
- );
141
+ view.dispatch(tr.setMeta(uploadPlaceholderPlugin, { remove: { id } }));
133
142
  }
134
143
  };
135
144
  return async (view, files, pos) => {
@@ -0,0 +1,6 @@
1
+ declare const base64FileUploader: (file: File) => Promise<{
2
+ src: string;
3
+ alt: string;
4
+ }>;
5
+
6
+ export { base64FileUploader };
@@ -0,0 +1,6 @@
1
+ declare const base64FileUploader: (file: File) => Promise<{
2
+ src: string;
3
+ alt: string;
4
+ }>;
5
+
6
+ export { base64FileUploader };
@@ -17,30 +17,27 @@ var __copyProps = (to, from, except, desc) => {
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
 
20
- // src/plugins/trailing_paragraph.tsx
21
- var trailing_paragraph_exports = {};
22
- __export(trailing_paragraph_exports, {
23
- trailingParagraph: () => trailingParagraph
20
+ // src/base64_file_uploader.ts
21
+ var base64_file_uploader_exports = {};
22
+ __export(base64_file_uploader_exports, {
23
+ base64FileUploader: () => base64FileUploader
24
24
  });
25
- module.exports = __toCommonJS(trailing_paragraph_exports);
26
- var import_prosemirror_state = require("prosemirror-state");
27
- function trailingParagraph() {
28
- return new import_prosemirror_state.Plugin({
29
- appendTransaction(transactions, oldState, newState) {
30
- const doc = newState.doc;
31
- const lastNode = doc.lastChild;
32
- if (lastNode && lastNode.type.name !== "paragraph") {
33
- const paragraphType = newState.schema.nodes.paragraph;
34
- const tr = newState.tr;
35
- const endPos = doc.content.size;
36
- tr.insert(endPos, paragraphType.create());
37
- return tr;
38
- }
39
- return null;
40
- }
25
+ module.exports = __toCommonJS(base64_file_uploader_exports);
26
+ var base64FileUploader = async (file) => {
27
+ const base64 = await new Promise((resolve, reject) => {
28
+ const reader = new FileReader();
29
+ reader.onload = () => {
30
+ resolve(reader.result);
31
+ };
32
+ reader.onerror = reject;
33
+ reader.readAsDataURL(file);
41
34
  });
42
- }
35
+ return {
36
+ src: base64,
37
+ alt: file.name
38
+ };
39
+ };
43
40
  // Annotate the CommonJS export names for ESM import in node:
44
41
  0 && (module.exports = {
45
- trailingParagraph
42
+ base64FileUploader
46
43
  });
@@ -0,0 +1,18 @@
1
+ // src/base64_file_uploader.ts
2
+ var base64FileUploader = async (file) => {
3
+ const base64 = await new Promise((resolve, reject) => {
4
+ const reader = new FileReader();
5
+ reader.onload = () => {
6
+ resolve(reader.result);
7
+ };
8
+ reader.onerror = reject;
9
+ reader.readAsDataURL(file);
10
+ });
11
+ return {
12
+ src: base64,
13
+ alt: file.name
14
+ };
15
+ };
16
+ export {
17
+ base64FileUploader
18
+ };
@@ -0,0 +1,23 @@
1
+ import { Schema, NodeType, Attrs } from 'prosemirror-model';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { AttachFile } from './attach_file.mjs';
4
+ import './schema.mjs';
5
+ import 'orderedmap';
6
+
7
+ declare const createCommands: (schema: Schema, view: EditorView, options?: {
8
+ attachFile?: AttachFile;
9
+ }) => {
10
+ isBlockTypeActive: (node: NodeType, attrs?: Attrs | null, excludes?: NodeType[]) => false | undefined;
11
+ setBlockType: (node: string, attrs?: Attrs | null) => void;
12
+ toggleBlockType: (node: string, attrs?: Attrs | null) => void;
13
+ toggleMark: (mark: string, attrs?: Attrs | null, options?: {
14
+ removeWhenPresent?: boolean;
15
+ enterInlineAtoms?: boolean;
16
+ includeWhitespace?: boolean;
17
+ }) => void;
18
+ wrapInList: (listType: string, attrs?: Attrs | null) => void;
19
+ clear: () => void;
20
+ attachFile: (files: File[]) => void;
21
+ };
22
+
23
+ export { createCommands };
@@ -0,0 +1,23 @@
1
+ import { Schema, NodeType, Attrs } from 'prosemirror-model';
2
+ import { EditorView } from 'prosemirror-view';
3
+ import { AttachFile } from './attach_file.js';
4
+ import './schema.js';
5
+ import 'orderedmap';
6
+
7
+ declare const createCommands: (schema: Schema, view: EditorView, options?: {
8
+ attachFile?: AttachFile;
9
+ }) => {
10
+ isBlockTypeActive: (node: NodeType, attrs?: Attrs | null, excludes?: NodeType[]) => false | undefined;
11
+ setBlockType: (node: string, attrs?: Attrs | null) => void;
12
+ toggleBlockType: (node: string, attrs?: Attrs | null) => void;
13
+ toggleMark: (mark: string, attrs?: Attrs | null, options?: {
14
+ removeWhenPresent?: boolean;
15
+ enterInlineAtoms?: boolean;
16
+ includeWhitespace?: boolean;
17
+ }) => void;
18
+ wrapInList: (listType: string, attrs?: Attrs | null) => void;
19
+ clear: () => void;
20
+ attachFile: (files: File[]) => void;
21
+ };
22
+
23
+ export { createCommands };
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/commands.tsx
31
+ var commands_exports = {};
32
+ __export(commands_exports, {
33
+ createCommands: () => createCommands
34
+ });
35
+ module.exports = __toCommonJS(commands_exports);
36
+ var commands = __toESM(require("prosemirror-commands"));
37
+ var schemaList = __toESM(require("prosemirror-schema-list"));
38
+ var createCommands = (schema, view, options = {}) => {
39
+ {
40
+ const isBlockTypeActive = (node, attrs, excludes = []) => {
41
+ const state = view.state;
42
+ const ranges = state.selection.ranges;
43
+ let active = false;
44
+ for (const range of ranges) {
45
+ const { $from, $to } = range;
46
+ state.doc.nodesBetween($from.pos, $to.pos, (n) => {
47
+ if (active) {
48
+ return true;
49
+ }
50
+ if (n.type !== node || excludes.includes(n.type)) {
51
+ return;
52
+ }
53
+ if (!attrs || Object.keys(attrs).every((key) => n.attrs[key] === attrs[key])) {
54
+ active = true;
55
+ }
56
+ });
57
+ return active;
58
+ }
59
+ };
60
+ const setBlockType2 = (node, attrs) => {
61
+ view.focus();
62
+ const nodeType = schema.nodes[node];
63
+ const command = commands.setBlockType(nodeType, attrs);
64
+ command(view.state, view.dispatch);
65
+ };
66
+ const toggleBlockType = (node, attrs) => {
67
+ view.focus();
68
+ const nodeType = schema.nodes[node];
69
+ const command = commands.setBlockType(nodeType, attrs);
70
+ if (isBlockTypeActive(nodeType, attrs)) {
71
+ command(view.state, view.dispatch);
72
+ }
73
+ };
74
+ const toggleMark2 = (mark, attrs, options2) => {
75
+ view.focus();
76
+ const markType = schema.marks[mark];
77
+ const command = commands.toggleMark(markType, attrs, options2);
78
+ command(view.state, view.dispatch);
79
+ };
80
+ const wrapInList2 = (listType, attrs) => {
81
+ view.focus();
82
+ const nodeType = schema.nodes[listType];
83
+ const command = schemaList.wrapInList(nodeType, attrs);
84
+ command(view.state, view.dispatch);
85
+ };
86
+ const clear = () => {
87
+ const tr = view.state.tr.replaceWith(
88
+ 0,
89
+ view.state.doc.content.size,
90
+ schema.nodes.doc.createAndFill()
91
+ );
92
+ view.dispatch(tr);
93
+ };
94
+ return {
95
+ isBlockTypeActive,
96
+ setBlockType: setBlockType2,
97
+ toggleBlockType,
98
+ toggleMark: toggleMark2,
99
+ wrapInList: wrapInList2,
100
+ clear,
101
+ attachFile: (files) => {
102
+ options.attachFile?.(view, files);
103
+ }
104
+ };
105
+ }
106
+ };
107
+ // Annotate the CommonJS export names for ESM import in node:
108
+ 0 && (module.exports = {
109
+ createCommands
110
+ });