dn-react-router-toolkit 0.2.3 → 0.2.5

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 (57) hide show
  1. package/dist/auth/client/provider.d.mts +2 -4
  2. package/dist/auth/client/provider.d.ts +2 -4
  3. package/dist/auth/client/provider.js +3 -4
  4. package/dist/auth/client/provider.mjs +3 -4
  5. package/dist/auth/jwt_manager.js +1 -1
  6. package/dist/auth/jwt_manager.mjs +1 -1
  7. package/dist/file/cdn.d.mts +3 -2
  8. package/dist/file/cdn.d.ts +3 -2
  9. package/dist/file/client/drop_file_input.js +36 -10
  10. package/dist/file/client/drop_file_input.mjs +36 -10
  11. package/dist/file/client/file_uploader.js +36 -10
  12. package/dist/file/client/file_uploader.mjs +36 -10
  13. package/dist/file/client/metadata.d.mts +5 -1
  14. package/dist/file/client/metadata.d.ts +5 -1
  15. package/dist/file/client/metadata.js +36 -10
  16. package/dist/file/client/metadata.mjs +36 -10
  17. package/dist/index.d.mts +1 -0
  18. package/dist/index.d.ts +1 -0
  19. package/dist/index.js +7 -0
  20. package/dist/index.mjs +6 -0
  21. package/dist/sleep.d.mts +3 -0
  22. package/dist/sleep.d.ts +3 -0
  23. package/dist/sleep.js +32 -0
  24. package/dist/sleep.mjs +7 -0
  25. package/dist/text_editor/attach_media.d.mts +16 -0
  26. package/dist/text_editor/attach_media.d.ts +16 -0
  27. package/dist/text_editor/attach_media.js +237 -0
  28. package/dist/text_editor/attach_media.mjs +210 -0
  29. package/dist/text_editor/plugins/drag_and_drop.d.mts +13 -0
  30. package/dist/text_editor/plugins/drag_and_drop.d.ts +13 -0
  31. package/dist/text_editor/plugins/drag_and_drop.js +59 -0
  32. package/dist/text_editor/plugins/drag_and_drop.mjs +34 -0
  33. package/dist/text_editor/plugins/keymap.d.mts +5 -0
  34. package/dist/text_editor/plugins/keymap.d.ts +5 -0
  35. package/dist/text_editor/plugins/keymap.js +40 -0
  36. package/dist/text_editor/plugins/keymap.mjs +15 -0
  37. package/dist/text_editor/plugins/placehoder.d.mts +5 -0
  38. package/dist/text_editor/plugins/placehoder.d.ts +5 -0
  39. package/dist/text_editor/plugins/placehoder.js +112 -0
  40. package/dist/text_editor/plugins/placehoder.mjs +87 -0
  41. package/dist/text_editor/plugins/trailing_paragraph.d.mts +5 -0
  42. package/dist/text_editor/plugins/trailing_paragraph.d.ts +5 -0
  43. package/dist/text_editor/plugins/trailing_paragraph.js +46 -0
  44. package/dist/text_editor/plugins/trailing_paragraph.mjs +21 -0
  45. package/dist/text_editor/plugins/upload_placeholder.d.mts +7 -0
  46. package/dist/text_editor/plugins/upload_placeholder.d.ts +7 -0
  47. package/dist/text_editor/plugins/upload_placeholder.js +94 -0
  48. package/dist/text_editor/plugins/upload_placeholder.mjs +68 -0
  49. package/dist/text_editor/schema.d.mts +9 -0
  50. package/dist/text_editor/schema.d.ts +9 -0
  51. package/dist/text_editor/schema.js +354 -0
  52. package/dist/text_editor/schema.mjs +319 -0
  53. package/dist/text_editor/text_editor.d.mts +44 -0
  54. package/dist/text_editor/text_editor.d.ts +44 -0
  55. package/dist/text_editor/text_editor.js +830 -0
  56. package/dist/text_editor/text_editor.mjs +802 -0
  57. package/package.json +14 -2
@@ -0,0 +1,354 @@
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/text_editor/schema.tsx
31
+ var schema_exports = {};
32
+ __export(schema_exports, {
33
+ createSchema: () => createSchema
34
+ });
35
+ module.exports = __toCommonJS(schema_exports);
36
+ var import_prosemirror_model = require("prosemirror-model");
37
+ var import_prosemirror_schema_list = require("prosemirror-schema-list");
38
+
39
+ // src/file/responsive_image.tsx
40
+ var import_react = __toESM(require("react"));
41
+ var sizes = [
42
+ 64,
43
+ 128,
44
+ 256,
45
+ 320,
46
+ 480,
47
+ 640,
48
+ 768,
49
+ 1080,
50
+ 1200,
51
+ 1536,
52
+ 1920,
53
+ 2560,
54
+ 3840
55
+ ];
56
+ var generateSrc = (cdnOrigin, src, width, height, ratio, image = {}) => {
57
+ const searchParams = new URLSearchParams();
58
+ if (image.width) {
59
+ searchParams.set("w", image.width.toString());
60
+ }
61
+ if (width) {
62
+ searchParams.set("w", width.toString());
63
+ if (ratio) {
64
+ searchParams.set("h", Math.round(width / ratio).toString());
65
+ }
66
+ }
67
+ if (image.height) {
68
+ searchParams.set("h", image.height.toString());
69
+ }
70
+ if (height) {
71
+ searchParams.set("h", height.toString());
72
+ }
73
+ const search = searchParams.toString() ? `?${searchParams.toString()}` : "";
74
+ if (!src.includes(cdnOrigin)) {
75
+ return src;
76
+ }
77
+ return `${encodeURI(decodeURI(src))}${search}`;
78
+ };
79
+ function generateSrcSet(cdnOrigin, image, ratio, props = {}) {
80
+ const src = typeof image === "string" ? image : image.src;
81
+ const isGif = src.endsWith(".gif");
82
+ if (isGif) {
83
+ return void 0;
84
+ }
85
+ if (props.width) {
86
+ return [1, 2, 3].map((scale) => {
87
+ const genWidth = Number(props.width) * scale;
88
+ return `${generateSrc(
89
+ cdnOrigin,
90
+ src,
91
+ genWidth,
92
+ props.height ? Number(props.height) * scale : ratio ? Math.round(genWidth / ratio) : void 0
93
+ )} ${scale}x`;
94
+ }).join(", ");
95
+ }
96
+ return sizes.map(
97
+ (size) => `${generateSrc(cdnOrigin, src, size, void 0, ratio, props)} ${size}w`
98
+ ).join(", ");
99
+ }
100
+
101
+ // src/text_editor/schema.tsx
102
+ function createSchema({ cdnOrigin }) {
103
+ const customSchema = new import_prosemirror_model.Schema({
104
+ nodes: {
105
+ doc: { content: "block+" },
106
+ paragraph: {
107
+ attrs: { align: { default: null } },
108
+ content: "inline*",
109
+ group: "block",
110
+ parseDOM: [
111
+ {
112
+ tag: "p",
113
+ getAttrs(dom) {
114
+ return {
115
+ align: dom.style.textAlign || null
116
+ };
117
+ }
118
+ }
119
+ ],
120
+ toDOM(node) {
121
+ return [
122
+ "p",
123
+ {
124
+ style: node.attrs.align ? `text-align: ${node.attrs.align}` : null
125
+ },
126
+ 0
127
+ ];
128
+ }
129
+ },
130
+ text: {
131
+ group: "inline"
132
+ },
133
+ hard_break: {
134
+ inline: true,
135
+ group: "inline",
136
+ selectable: false,
137
+ parseDOM: [{ tag: "br" }],
138
+ toDOM() {
139
+ return ["br"];
140
+ }
141
+ },
142
+ heading: {
143
+ attrs: { level: { default: 1 }, align: { default: null } },
144
+ content: "inline*",
145
+ group: "block",
146
+ defining: true,
147
+ parseDOM: [
148
+ {
149
+ tag: "h1",
150
+ getAttrs(node) {
151
+ return {
152
+ level: 1,
153
+ algin: node.style.textAlign || null
154
+ };
155
+ }
156
+ },
157
+ {
158
+ tag: "h2",
159
+ getAttrs(node) {
160
+ return {
161
+ level: 2,
162
+ algin: node.style.textAlign || null
163
+ };
164
+ }
165
+ },
166
+ {
167
+ tag: "h3",
168
+ getAttrs(node) {
169
+ return {
170
+ level: 3,
171
+ algin: node.style.textAlign || null
172
+ };
173
+ }
174
+ },
175
+ {
176
+ tag: "h4",
177
+ getAttrs(node) {
178
+ return {
179
+ level: 4,
180
+ algin: node.style.textAlign || null
181
+ };
182
+ }
183
+ },
184
+ {
185
+ tag: "h5",
186
+ getAttrs(node) {
187
+ return {
188
+ level: 5,
189
+ algin: node.style.textAlign || null
190
+ };
191
+ }
192
+ },
193
+ {
194
+ tag: "h6",
195
+ getAttrs(node) {
196
+ return {
197
+ level: 6,
198
+ algin: node.style.textAlign || null
199
+ };
200
+ }
201
+ }
202
+ ],
203
+ toDOM(node) {
204
+ return [
205
+ "h" + node.attrs.level,
206
+ {
207
+ id: node.textContent.toLowerCase().replace(/\s+/g, "-"),
208
+ style: node.attrs.align ? `text-align: ${node.attrs.align};` : null
209
+ },
210
+ 0
211
+ ];
212
+ }
213
+ },
214
+ horizontal_rule: {
215
+ group: "block",
216
+ parseDOM: [{ tag: "hr" }],
217
+ toDOM() {
218
+ return ["hr"];
219
+ }
220
+ },
221
+ image: {
222
+ attrs: {
223
+ src: { validate: "string" },
224
+ alt: { default: null, validate: "string|null" },
225
+ title: {
226
+ default: null,
227
+ validate: "string|null"
228
+ },
229
+ width: {
230
+ default: null,
231
+ validate: "number|null"
232
+ },
233
+ height: {
234
+ default: null,
235
+ validate: "number|null"
236
+ }
237
+ },
238
+ inline: true,
239
+ group: "inline",
240
+ draggable: true,
241
+ parseDOM: [
242
+ {
243
+ tag: "img",
244
+ getAttrs(dom) {
245
+ return {
246
+ src: dom.getAttribute("src"),
247
+ title: dom.getAttribute("title"),
248
+ alt: dom.getAttribute("alt"),
249
+ width: dom.getAttribute("width"),
250
+ height: dom.getAttribute("height")
251
+ };
252
+ }
253
+ }
254
+ ],
255
+ toDOM(node) {
256
+ const { src, alt, title, width, height } = node.attrs;
257
+ return [
258
+ "img",
259
+ {
260
+ src,
261
+ alt,
262
+ title,
263
+ width,
264
+ height,
265
+ srcSet: cdnOrigin ? generateSrcSet(cdnOrigin, src) : void 0,
266
+ sizes: cdnOrigin ? "(max-width: 768px) 100vw, 768px" : void 0
267
+ }
268
+ ];
269
+ }
270
+ }
271
+ },
272
+ marks: {
273
+ link: {
274
+ attrs: {
275
+ href: { default: "" },
276
+ title: { default: null }
277
+ },
278
+ inclusive: false,
279
+ parseDOM: [
280
+ {
281
+ tag: "a[href]",
282
+ getAttrs(dom) {
283
+ return {
284
+ href: dom.getAttribute("href"),
285
+ title: dom.getAttribute("title")
286
+ };
287
+ }
288
+ }
289
+ ],
290
+ toDOM(node) {
291
+ const { href, title } = node.attrs;
292
+ const target = "_blank";
293
+ const rel = "noopener noreferrer";
294
+ return ["a", { href, title: title || href, target, rel }, 0];
295
+ }
296
+ },
297
+ bold: {
298
+ parseDOM: [
299
+ { tag: "strong" },
300
+ {
301
+ tag: "b",
302
+ getAttrs: (node) => node.style.fontWeight != "normal" && null
303
+ },
304
+ {
305
+ style: "font-weight=400",
306
+ clearMark: (m) => m.type.name == "strong"
307
+ },
308
+ {
309
+ style: "font-weight",
310
+ getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
311
+ }
312
+ ],
313
+ toDOM() {
314
+ return ["strong", 0];
315
+ }
316
+ },
317
+ italic: {
318
+ parseDOM: [
319
+ { tag: "em" },
320
+ { tag: "i" },
321
+ { style: "font-style=italic" },
322
+ {
323
+ style: "font-style=normal",
324
+ clearMark: (m) => m.type.name == "em"
325
+ }
326
+ ],
327
+ toDOM() {
328
+ return ["em", 0];
329
+ }
330
+ },
331
+ underline: {
332
+ parseDOM: [
333
+ { tag: "u" },
334
+ {
335
+ style: "text-decoration",
336
+ getAttrs: (value) => value === "underline" && null
337
+ }
338
+ ],
339
+ toDOM() {
340
+ return ["u", 0];
341
+ }
342
+ }
343
+ }
344
+ });
345
+ const prosemirrorSchema = new import_prosemirror_model.Schema({
346
+ nodes: (0, import_prosemirror_schema_list.addListNodes)(customSchema.spec.nodes, "paragraph block*", "block"),
347
+ marks: customSchema.spec.marks
348
+ });
349
+ return prosemirrorSchema;
350
+ }
351
+ // Annotate the CommonJS export names for ESM import in node:
352
+ 0 && (module.exports = {
353
+ createSchema
354
+ });
@@ -0,0 +1,319 @@
1
+ // src/text_editor/schema.tsx
2
+ import { Schema } from "prosemirror-model";
3
+ import { addListNodes } from "prosemirror-schema-list";
4
+
5
+ // src/file/responsive_image.tsx
6
+ import React from "react";
7
+ var sizes = [
8
+ 64,
9
+ 128,
10
+ 256,
11
+ 320,
12
+ 480,
13
+ 640,
14
+ 768,
15
+ 1080,
16
+ 1200,
17
+ 1536,
18
+ 1920,
19
+ 2560,
20
+ 3840
21
+ ];
22
+ var generateSrc = (cdnOrigin, src, width, height, ratio, image = {}) => {
23
+ const searchParams = new URLSearchParams();
24
+ if (image.width) {
25
+ searchParams.set("w", image.width.toString());
26
+ }
27
+ if (width) {
28
+ searchParams.set("w", width.toString());
29
+ if (ratio) {
30
+ searchParams.set("h", Math.round(width / ratio).toString());
31
+ }
32
+ }
33
+ if (image.height) {
34
+ searchParams.set("h", image.height.toString());
35
+ }
36
+ if (height) {
37
+ searchParams.set("h", height.toString());
38
+ }
39
+ const search = searchParams.toString() ? `?${searchParams.toString()}` : "";
40
+ if (!src.includes(cdnOrigin)) {
41
+ return src;
42
+ }
43
+ return `${encodeURI(decodeURI(src))}${search}`;
44
+ };
45
+ function generateSrcSet(cdnOrigin, image, ratio, props = {}) {
46
+ const src = typeof image === "string" ? image : image.src;
47
+ const isGif = src.endsWith(".gif");
48
+ if (isGif) {
49
+ return void 0;
50
+ }
51
+ if (props.width) {
52
+ return [1, 2, 3].map((scale) => {
53
+ const genWidth = Number(props.width) * scale;
54
+ return `${generateSrc(
55
+ cdnOrigin,
56
+ src,
57
+ genWidth,
58
+ props.height ? Number(props.height) * scale : ratio ? Math.round(genWidth / ratio) : void 0
59
+ )} ${scale}x`;
60
+ }).join(", ");
61
+ }
62
+ return sizes.map(
63
+ (size) => `${generateSrc(cdnOrigin, src, size, void 0, ratio, props)} ${size}w`
64
+ ).join(", ");
65
+ }
66
+
67
+ // src/text_editor/schema.tsx
68
+ function createSchema({ cdnOrigin }) {
69
+ const customSchema = new Schema({
70
+ nodes: {
71
+ doc: { content: "block+" },
72
+ paragraph: {
73
+ attrs: { align: { default: null } },
74
+ content: "inline*",
75
+ group: "block",
76
+ parseDOM: [
77
+ {
78
+ tag: "p",
79
+ getAttrs(dom) {
80
+ return {
81
+ align: dom.style.textAlign || null
82
+ };
83
+ }
84
+ }
85
+ ],
86
+ toDOM(node) {
87
+ return [
88
+ "p",
89
+ {
90
+ style: node.attrs.align ? `text-align: ${node.attrs.align}` : null
91
+ },
92
+ 0
93
+ ];
94
+ }
95
+ },
96
+ text: {
97
+ group: "inline"
98
+ },
99
+ hard_break: {
100
+ inline: true,
101
+ group: "inline",
102
+ selectable: false,
103
+ parseDOM: [{ tag: "br" }],
104
+ toDOM() {
105
+ return ["br"];
106
+ }
107
+ },
108
+ heading: {
109
+ attrs: { level: { default: 1 }, align: { default: null } },
110
+ content: "inline*",
111
+ group: "block",
112
+ defining: true,
113
+ parseDOM: [
114
+ {
115
+ tag: "h1",
116
+ getAttrs(node) {
117
+ return {
118
+ level: 1,
119
+ algin: node.style.textAlign || null
120
+ };
121
+ }
122
+ },
123
+ {
124
+ tag: "h2",
125
+ getAttrs(node) {
126
+ return {
127
+ level: 2,
128
+ algin: node.style.textAlign || null
129
+ };
130
+ }
131
+ },
132
+ {
133
+ tag: "h3",
134
+ getAttrs(node) {
135
+ return {
136
+ level: 3,
137
+ algin: node.style.textAlign || null
138
+ };
139
+ }
140
+ },
141
+ {
142
+ tag: "h4",
143
+ getAttrs(node) {
144
+ return {
145
+ level: 4,
146
+ algin: node.style.textAlign || null
147
+ };
148
+ }
149
+ },
150
+ {
151
+ tag: "h5",
152
+ getAttrs(node) {
153
+ return {
154
+ level: 5,
155
+ algin: node.style.textAlign || null
156
+ };
157
+ }
158
+ },
159
+ {
160
+ tag: "h6",
161
+ getAttrs(node) {
162
+ return {
163
+ level: 6,
164
+ algin: node.style.textAlign || null
165
+ };
166
+ }
167
+ }
168
+ ],
169
+ toDOM(node) {
170
+ return [
171
+ "h" + node.attrs.level,
172
+ {
173
+ id: node.textContent.toLowerCase().replace(/\s+/g, "-"),
174
+ style: node.attrs.align ? `text-align: ${node.attrs.align};` : null
175
+ },
176
+ 0
177
+ ];
178
+ }
179
+ },
180
+ horizontal_rule: {
181
+ group: "block",
182
+ parseDOM: [{ tag: "hr" }],
183
+ toDOM() {
184
+ return ["hr"];
185
+ }
186
+ },
187
+ image: {
188
+ attrs: {
189
+ src: { validate: "string" },
190
+ alt: { default: null, validate: "string|null" },
191
+ title: {
192
+ default: null,
193
+ validate: "string|null"
194
+ },
195
+ width: {
196
+ default: null,
197
+ validate: "number|null"
198
+ },
199
+ height: {
200
+ default: null,
201
+ validate: "number|null"
202
+ }
203
+ },
204
+ inline: true,
205
+ group: "inline",
206
+ draggable: true,
207
+ parseDOM: [
208
+ {
209
+ tag: "img",
210
+ getAttrs(dom) {
211
+ return {
212
+ src: dom.getAttribute("src"),
213
+ title: dom.getAttribute("title"),
214
+ alt: dom.getAttribute("alt"),
215
+ width: dom.getAttribute("width"),
216
+ height: dom.getAttribute("height")
217
+ };
218
+ }
219
+ }
220
+ ],
221
+ toDOM(node) {
222
+ const { src, alt, title, width, height } = node.attrs;
223
+ return [
224
+ "img",
225
+ {
226
+ src,
227
+ alt,
228
+ title,
229
+ width,
230
+ height,
231
+ srcSet: cdnOrigin ? generateSrcSet(cdnOrigin, src) : void 0,
232
+ sizes: cdnOrigin ? "(max-width: 768px) 100vw, 768px" : void 0
233
+ }
234
+ ];
235
+ }
236
+ }
237
+ },
238
+ marks: {
239
+ link: {
240
+ attrs: {
241
+ href: { default: "" },
242
+ title: { default: null }
243
+ },
244
+ inclusive: false,
245
+ parseDOM: [
246
+ {
247
+ tag: "a[href]",
248
+ getAttrs(dom) {
249
+ return {
250
+ href: dom.getAttribute("href"),
251
+ title: dom.getAttribute("title")
252
+ };
253
+ }
254
+ }
255
+ ],
256
+ toDOM(node) {
257
+ const { href, title } = node.attrs;
258
+ const target = "_blank";
259
+ const rel = "noopener noreferrer";
260
+ return ["a", { href, title: title || href, target, rel }, 0];
261
+ }
262
+ },
263
+ bold: {
264
+ parseDOM: [
265
+ { tag: "strong" },
266
+ {
267
+ tag: "b",
268
+ getAttrs: (node) => node.style.fontWeight != "normal" && null
269
+ },
270
+ {
271
+ style: "font-weight=400",
272
+ clearMark: (m) => m.type.name == "strong"
273
+ },
274
+ {
275
+ style: "font-weight",
276
+ getAttrs: (value) => /^(bold(er)?|[5-9]\d{2,})$/.test(value) && null
277
+ }
278
+ ],
279
+ toDOM() {
280
+ return ["strong", 0];
281
+ }
282
+ },
283
+ italic: {
284
+ parseDOM: [
285
+ { tag: "em" },
286
+ { tag: "i" },
287
+ { style: "font-style=italic" },
288
+ {
289
+ style: "font-style=normal",
290
+ clearMark: (m) => m.type.name == "em"
291
+ }
292
+ ],
293
+ toDOM() {
294
+ return ["em", 0];
295
+ }
296
+ },
297
+ underline: {
298
+ parseDOM: [
299
+ { tag: "u" },
300
+ {
301
+ style: "text-decoration",
302
+ getAttrs: (value) => value === "underline" && null
303
+ }
304
+ ],
305
+ toDOM() {
306
+ return ["u", 0];
307
+ }
308
+ }
309
+ }
310
+ });
311
+ const prosemirrorSchema = new Schema({
312
+ nodes: addListNodes(customSchema.spec.nodes, "paragraph block*", "block"),
313
+ marks: customSchema.spec.marks
314
+ });
315
+ return prosemirrorSchema;
316
+ }
317
+ export {
318
+ createSchema
319
+ };
@@ -0,0 +1,44 @@
1
+ import * as orderedmap from 'orderedmap';
2
+ import * as prosemirror_model from 'prosemirror-model';
3
+ import { Node, Attrs, Fragment, Mark } from 'prosemirror-model';
4
+ import React from 'react';
5
+ import { EditorStateConfig } from 'prosemirror-state';
6
+ import { EditorView, DirectEditorProps } from 'prosemirror-view';
7
+ import { FileUploader } from '../file/client/file_uploader.mjs';
8
+
9
+ type TextEditorProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
10
+ name?: string;
11
+ state?: Partial<EditorStateConfig>;
12
+ editor?: Partial<DirectEditorProps>;
13
+ placeholder?: string;
14
+ defaultValue?: string;
15
+ onHTMLChanged?: (html: string) => void;
16
+ };
17
+ declare function createTextEditor<TFile extends {
18
+ key: string;
19
+ }>({ fileUploader, cdnOrigin, }?: {
20
+ fileUploader?: FileUploader<TFile>;
21
+ cdnOrigin?: string;
22
+ }): {
23
+ schema: prosemirror_model.Schema<keyof orderedmap.default<prosemirror_model.NodeSpec>, keyof orderedmap.default<prosemirror_model.MarkSpec>>;
24
+ useTextEditor: () => {
25
+ readonly schema: prosemirror_model.Schema<keyof orderedmap.default<prosemirror_model.NodeSpec>, keyof orderedmap.default<prosemirror_model.MarkSpec>>;
26
+ readonly view: React.RefObject<EditorView | null>;
27
+ readonly commands: {
28
+ readonly attachMedia: (files: File[]) => Promise<Node[] | undefined>;
29
+ readonly toggleMark: <T extends string | number>(type: T, attrs?: Attrs, options?: {
30
+ removeWhenPresent?: boolean;
31
+ enterInlineAtoms?: boolean;
32
+ includeWhitespace?: boolean;
33
+ }) => void;
34
+ readonly setBlockType: <T extends string | number>(type: T, attrs?: Attrs) => void;
35
+ readonly insertNode: (type: string, attrs?: Attrs, content?: Fragment | Node | Node[], marks?: Mark[]) => void;
36
+ readonly setHTML: (html: string) => void;
37
+ };
38
+ readonly Component: ({ name, placeholder, className, defaultValue, onClick, onHTMLChanged, editor, state, ...props }: TextEditorProps) => React.JSX.Element;
39
+ readonly serialize: () => string;
40
+ readonly getTextContent: () => string;
41
+ };
42
+ };
43
+
44
+ export { type TextEditorProps, createTextEditor as default };