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/dist/schema.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
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
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/schema.tsx
@@ -25,7 +35,75 @@ __export(schema_exports, {
25
35
  module.exports = __toCommonJS(schema_exports);
26
36
  var import_prosemirror_model = require("prosemirror-model");
27
37
  var import_prosemirror_schema_list = require("prosemirror-schema-list");
28
- function createSchema() {
38
+
39
+ // src/plugins/highlighter.ts
40
+ var import_highlight = __toESM(require("highlight.js"));
41
+ var import_bash = __toESM(require("highlight.js/lib/languages/bash"));
42
+ var import_c = __toESM(require("highlight.js/lib/languages/c"));
43
+ var import_cpp = __toESM(require("highlight.js/lib/languages/cpp"));
44
+ var import_css = __toESM(require("highlight.js/lib/languages/css"));
45
+ var import_java = __toESM(require("highlight.js/lib/languages/java"));
46
+ var import_typescript = __toESM(require("highlight.js/lib/languages/typescript"));
47
+ var import_javascript = __toESM(require("highlight.js/lib/languages/javascript"));
48
+ var import_json = __toESM(require("highlight.js/lib/languages/json"));
49
+ var import_xml = __toESM(require("highlight.js/lib/languages/xml"));
50
+ var import_python = __toESM(require("highlight.js/lib/languages/python"));
51
+ var import_dart = __toESM(require("highlight.js/lib/languages/dart"));
52
+ var import_csharp = __toESM(require("highlight.js/lib/languages/csharp"));
53
+ var import_markdown = __toESM(require("highlight.js/lib/languages/markdown"));
54
+ var import_nginx = __toESM(require("highlight.js/lib/languages/nginx"));
55
+ var import_php = __toESM(require("highlight.js/lib/languages/php"));
56
+ var import_ruby = __toESM(require("highlight.js/lib/languages/ruby"));
57
+ var import_sql = __toESM(require("highlight.js/lib/languages/sql"));
58
+ var import_swift = __toESM(require("highlight.js/lib/languages/swift"));
59
+ var import_yaml = __toESM(require("highlight.js/lib/languages/yaml"));
60
+ var import_rust = __toESM(require("highlight.js/lib/languages/rust"));
61
+ import_highlight.default.registerLanguage("bash", import_bash.default);
62
+ import_highlight.default.registerLanguage("c", import_c.default);
63
+ import_highlight.default.registerLanguage("cpp", import_cpp.default);
64
+ import_highlight.default.registerLanguage("css", import_css.default);
65
+ import_highlight.default.registerLanguage("java", import_java.default);
66
+ import_highlight.default.registerLanguage("markdown", import_markdown.default);
67
+ import_highlight.default.registerLanguage("nginx", import_nginx.default);
68
+ import_highlight.default.registerLanguage("php", import_php.default);
69
+ import_highlight.default.registerLanguage("ruby", import_ruby.default);
70
+ import_highlight.default.registerLanguage("sql", import_sql.default);
71
+ import_highlight.default.registerLanguage("swift", import_swift.default);
72
+ import_highlight.default.registerLanguage("yaml", import_yaml.default);
73
+ import_highlight.default.registerLanguage("rust", import_rust.default);
74
+ import_highlight.default.registerLanguage("json", import_json.default);
75
+ import_highlight.default.registerLanguage("javascript", import_javascript.default);
76
+ import_highlight.default.registerLanguage("typescript", import_typescript.default);
77
+ import_highlight.default.registerLanguage("xml", import_xml.default);
78
+ import_highlight.default.registerLanguage("python", import_python.default);
79
+ import_highlight.default.registerLanguage("dart", import_dart.default);
80
+ import_highlight.default.registerLanguage("csharp", import_csharp.default);
81
+ var supportedLanguages = [
82
+ "bash",
83
+ "c",
84
+ "cpp",
85
+ "css",
86
+ "java",
87
+ "markdown",
88
+ "nginx",
89
+ "php",
90
+ "ruby",
91
+ "sql",
92
+ "swift",
93
+ "yaml",
94
+ "rust",
95
+ "json",
96
+ "javascript",
97
+ "typescript",
98
+ "xml",
99
+ "python",
100
+ "dart",
101
+ "csharp"
102
+ ];
103
+ var highlighter = import_highlight.default;
104
+
105
+ // src/schema.tsx
106
+ function createSchema(spec = { nodes: {}, marks: {} }) {
29
107
  const customSchema = new import_prosemirror_model.Schema({
30
108
  nodes: {
31
109
  doc: { content: "block+" },
@@ -191,7 +269,176 @@ function createSchema() {
191
269
  }
192
270
  ];
193
271
  }
194
- }
272
+ },
273
+ video: {
274
+ inline: false,
275
+ group: "block",
276
+ draggable: true,
277
+ attrs: {
278
+ src: { validate: "string" },
279
+ title: {
280
+ default: null,
281
+ validate: "string|null"
282
+ },
283
+ width: {
284
+ default: null,
285
+ validate: "number|null"
286
+ },
287
+ height: {
288
+ default: null,
289
+ validate: "number|null"
290
+ },
291
+ poster: {
292
+ default: null,
293
+ validate: "string|null"
294
+ }
295
+ },
296
+ parseDOM: [
297
+ {
298
+ tag: "video",
299
+ getAttrs(dom) {
300
+ return {
301
+ src: dom.getAttribute("src"),
302
+ title: dom.getAttribute("title"),
303
+ width: dom.getAttribute("width"),
304
+ height: dom.getAttribute("height"),
305
+ poster: dom.getAttribute("poster")
306
+ };
307
+ }
308
+ }
309
+ ],
310
+ toDOM(node) {
311
+ const { src, title, width, height, poster } = node.attrs;
312
+ return [
313
+ "video",
314
+ {
315
+ src,
316
+ title,
317
+ poster,
318
+ width,
319
+ height,
320
+ playsinline: "true",
321
+ controls: "controls",
322
+ style: `aspect-ratio: ${width} / ${height}`
323
+ }
324
+ ];
325
+ }
326
+ },
327
+ iframe: {
328
+ group: "block",
329
+ draggable: true,
330
+ attrs: {
331
+ src: { validate: "string" },
332
+ title: {
333
+ default: null,
334
+ validate: "string|null"
335
+ },
336
+ width: {
337
+ default: null,
338
+ validate: "number|null"
339
+ },
340
+ height: {
341
+ default: null,
342
+ validate: "number|null"
343
+ },
344
+ allow: {
345
+ default: null,
346
+ validate: "string|null"
347
+ },
348
+ allowfullscreen: {
349
+ default: null,
350
+ validate: "string|null"
351
+ },
352
+ referrerPolicy: {
353
+ default: null,
354
+ validate: "string|null"
355
+ },
356
+ style: {
357
+ default: null,
358
+ validate: "string|null"
359
+ }
360
+ },
361
+ parseDOM: [
362
+ {
363
+ tag: "iframe[src]",
364
+ getAttrs(dom) {
365
+ return {
366
+ src: dom.getAttribute("src"),
367
+ title: dom.getAttribute("title"),
368
+ width: dom.getAttribute("width"),
369
+ height: dom.getAttribute("height"),
370
+ style: dom.getAttribute("style"),
371
+ allow: dom.getAttribute("allow"),
372
+ allowfullscreen: dom.getAttribute("allowfullscreen"),
373
+ referrerpolicy: dom.getAttribute("referrerpolicy")
374
+ };
375
+ }
376
+ }
377
+ ],
378
+ toDOM(node) {
379
+ const {
380
+ src,
381
+ title,
382
+ width,
383
+ height,
384
+ allow,
385
+ allowfullscreen,
386
+ referrerpolicy,
387
+ style
388
+ } = node.attrs;
389
+ return [
390
+ "iframe",
391
+ {
392
+ src,
393
+ title,
394
+ width,
395
+ height,
396
+ style,
397
+ allow,
398
+ allowfullscreen,
399
+ referrerpolicy,
400
+ frameborder: "0"
401
+ }
402
+ ];
403
+ }
404
+ },
405
+ blockquote: {
406
+ content: "block+",
407
+ group: "block",
408
+ defining: true,
409
+ parseDOM: [{ tag: "blockquote" }],
410
+ toDOM() {
411
+ return ["blockquote", 0];
412
+ }
413
+ },
414
+ code_block: {
415
+ content: "text*",
416
+ marks: "",
417
+ group: "block",
418
+ code: true,
419
+ defining: true,
420
+ parseDOM: [{ tag: "pre", preserveWhitespace: "full" }],
421
+ toDOM(node) {
422
+ const auto = highlighter.highlightAuto(
423
+ node.textContent,
424
+ supportedLanguages
425
+ );
426
+ return [
427
+ "pre",
428
+ {
429
+ class: "hljs"
430
+ },
431
+ [
432
+ "code",
433
+ {
434
+ class: `language-${auto.language}`
435
+ },
436
+ 0
437
+ ]
438
+ ];
439
+ }
440
+ },
441
+ ...spec.nodes
195
442
  },
196
443
  marks: {
197
444
  link: {
@@ -215,11 +462,7 @@ function createSchema() {
215
462
  const { href, title } = node.attrs;
216
463
  const target = "_blank";
217
464
  const rel = "noopener noreferrer";
218
- return [
219
- "a",
220
- { href, title: title || href, target, rel },
221
- 0
222
- ];
465
+ return ["a", { href, title: title || href, target, rel }, 0];
223
466
  }
224
467
  },
225
468
  bold: {
@@ -267,15 +510,13 @@ function createSchema() {
267
510
  toDOM() {
268
511
  return ["u", 0];
269
512
  }
270
- }
271
- }
513
+ },
514
+ ...spec.marks
515
+ },
516
+ topNode: spec.topNode
272
517
  });
273
518
  const prosemirrorSchema = new import_prosemirror_model.Schema({
274
- nodes: (0, import_prosemirror_schema_list.addListNodes)(
275
- customSchema.spec.nodes,
276
- "paragraph block*",
277
- "block"
278
- ),
519
+ nodes: (0, import_prosemirror_schema_list.addListNodes)(customSchema.spec.nodes, "paragraph block*", "block"),
279
520
  marks: customSchema.spec.marks
280
521
  });
281
522
  return prosemirrorSchema;
package/dist/schema.mjs CHANGED
@@ -1,7 +1,75 @@
1
1
  // src/schema.tsx
2
2
  import { Schema } from "prosemirror-model";
3
3
  import { addListNodes } from "prosemirror-schema-list";
4
- function createSchema() {
4
+
5
+ // src/plugins/highlighter.ts
6
+ import hljs from "highlight.js";
7
+ import bash from "highlight.js/lib/languages/bash";
8
+ import c from "highlight.js/lib/languages/c";
9
+ import cpp from "highlight.js/lib/languages/cpp";
10
+ import css from "highlight.js/lib/languages/css";
11
+ import java from "highlight.js/lib/languages/java";
12
+ import ts from "highlight.js/lib/languages/typescript";
13
+ import js from "highlight.js/lib/languages/javascript";
14
+ import json from "highlight.js/lib/languages/json";
15
+ import xml from "highlight.js/lib/languages/xml";
16
+ import python from "highlight.js/lib/languages/python";
17
+ import dart from "highlight.js/lib/languages/dart";
18
+ import csharp from "highlight.js/lib/languages/csharp";
19
+ import markdown from "highlight.js/lib/languages/markdown";
20
+ import nginx from "highlight.js/lib/languages/nginx";
21
+ import php from "highlight.js/lib/languages/php";
22
+ import ruby from "highlight.js/lib/languages/ruby";
23
+ import sql from "highlight.js/lib/languages/sql";
24
+ import swift from "highlight.js/lib/languages/swift";
25
+ import yaml from "highlight.js/lib/languages/yaml";
26
+ import rust from "highlight.js/lib/languages/rust";
27
+ hljs.registerLanguage("bash", bash);
28
+ hljs.registerLanguage("c", c);
29
+ hljs.registerLanguage("cpp", cpp);
30
+ hljs.registerLanguage("css", css);
31
+ hljs.registerLanguage("java", java);
32
+ hljs.registerLanguage("markdown", markdown);
33
+ hljs.registerLanguage("nginx", nginx);
34
+ hljs.registerLanguage("php", php);
35
+ hljs.registerLanguage("ruby", ruby);
36
+ hljs.registerLanguage("sql", sql);
37
+ hljs.registerLanguage("swift", swift);
38
+ hljs.registerLanguage("yaml", yaml);
39
+ hljs.registerLanguage("rust", rust);
40
+ hljs.registerLanguage("json", json);
41
+ hljs.registerLanguage("javascript", js);
42
+ hljs.registerLanguage("typescript", ts);
43
+ hljs.registerLanguage("xml", xml);
44
+ hljs.registerLanguage("python", python);
45
+ hljs.registerLanguage("dart", dart);
46
+ hljs.registerLanguage("csharp", csharp);
47
+ var supportedLanguages = [
48
+ "bash",
49
+ "c",
50
+ "cpp",
51
+ "css",
52
+ "java",
53
+ "markdown",
54
+ "nginx",
55
+ "php",
56
+ "ruby",
57
+ "sql",
58
+ "swift",
59
+ "yaml",
60
+ "rust",
61
+ "json",
62
+ "javascript",
63
+ "typescript",
64
+ "xml",
65
+ "python",
66
+ "dart",
67
+ "csharp"
68
+ ];
69
+ var highlighter = hljs;
70
+
71
+ // src/schema.tsx
72
+ function createSchema(spec = { nodes: {}, marks: {} }) {
5
73
  const customSchema = new Schema({
6
74
  nodes: {
7
75
  doc: { content: "block+" },
@@ -167,7 +235,176 @@ function createSchema() {
167
235
  }
168
236
  ];
169
237
  }
170
- }
238
+ },
239
+ video: {
240
+ inline: false,
241
+ group: "block",
242
+ draggable: true,
243
+ attrs: {
244
+ src: { validate: "string" },
245
+ title: {
246
+ default: null,
247
+ validate: "string|null"
248
+ },
249
+ width: {
250
+ default: null,
251
+ validate: "number|null"
252
+ },
253
+ height: {
254
+ default: null,
255
+ validate: "number|null"
256
+ },
257
+ poster: {
258
+ default: null,
259
+ validate: "string|null"
260
+ }
261
+ },
262
+ parseDOM: [
263
+ {
264
+ tag: "video",
265
+ getAttrs(dom) {
266
+ return {
267
+ src: dom.getAttribute("src"),
268
+ title: dom.getAttribute("title"),
269
+ width: dom.getAttribute("width"),
270
+ height: dom.getAttribute("height"),
271
+ poster: dom.getAttribute("poster")
272
+ };
273
+ }
274
+ }
275
+ ],
276
+ toDOM(node) {
277
+ const { src, title, width, height, poster } = node.attrs;
278
+ return [
279
+ "video",
280
+ {
281
+ src,
282
+ title,
283
+ poster,
284
+ width,
285
+ height,
286
+ playsinline: "true",
287
+ controls: "controls",
288
+ style: `aspect-ratio: ${width} / ${height}`
289
+ }
290
+ ];
291
+ }
292
+ },
293
+ iframe: {
294
+ group: "block",
295
+ draggable: true,
296
+ attrs: {
297
+ src: { validate: "string" },
298
+ title: {
299
+ default: null,
300
+ validate: "string|null"
301
+ },
302
+ width: {
303
+ default: null,
304
+ validate: "number|null"
305
+ },
306
+ height: {
307
+ default: null,
308
+ validate: "number|null"
309
+ },
310
+ allow: {
311
+ default: null,
312
+ validate: "string|null"
313
+ },
314
+ allowfullscreen: {
315
+ default: null,
316
+ validate: "string|null"
317
+ },
318
+ referrerPolicy: {
319
+ default: null,
320
+ validate: "string|null"
321
+ },
322
+ style: {
323
+ default: null,
324
+ validate: "string|null"
325
+ }
326
+ },
327
+ parseDOM: [
328
+ {
329
+ tag: "iframe[src]",
330
+ getAttrs(dom) {
331
+ return {
332
+ src: dom.getAttribute("src"),
333
+ title: dom.getAttribute("title"),
334
+ width: dom.getAttribute("width"),
335
+ height: dom.getAttribute("height"),
336
+ style: dom.getAttribute("style"),
337
+ allow: dom.getAttribute("allow"),
338
+ allowfullscreen: dom.getAttribute("allowfullscreen"),
339
+ referrerpolicy: dom.getAttribute("referrerpolicy")
340
+ };
341
+ }
342
+ }
343
+ ],
344
+ toDOM(node) {
345
+ const {
346
+ src,
347
+ title,
348
+ width,
349
+ height,
350
+ allow,
351
+ allowfullscreen,
352
+ referrerpolicy,
353
+ style
354
+ } = node.attrs;
355
+ return [
356
+ "iframe",
357
+ {
358
+ src,
359
+ title,
360
+ width,
361
+ height,
362
+ style,
363
+ allow,
364
+ allowfullscreen,
365
+ referrerpolicy,
366
+ frameborder: "0"
367
+ }
368
+ ];
369
+ }
370
+ },
371
+ blockquote: {
372
+ content: "block+",
373
+ group: "block",
374
+ defining: true,
375
+ parseDOM: [{ tag: "blockquote" }],
376
+ toDOM() {
377
+ return ["blockquote", 0];
378
+ }
379
+ },
380
+ code_block: {
381
+ content: "text*",
382
+ marks: "",
383
+ group: "block",
384
+ code: true,
385
+ defining: true,
386
+ parseDOM: [{ tag: "pre", preserveWhitespace: "full" }],
387
+ toDOM(node) {
388
+ const auto = highlighter.highlightAuto(
389
+ node.textContent,
390
+ supportedLanguages
391
+ );
392
+ return [
393
+ "pre",
394
+ {
395
+ class: "hljs"
396
+ },
397
+ [
398
+ "code",
399
+ {
400
+ class: `language-${auto.language}`
401
+ },
402
+ 0
403
+ ]
404
+ ];
405
+ }
406
+ },
407
+ ...spec.nodes
171
408
  },
172
409
  marks: {
173
410
  link: {
@@ -191,11 +428,7 @@ function createSchema() {
191
428
  const { href, title } = node.attrs;
192
429
  const target = "_blank";
193
430
  const rel = "noopener noreferrer";
194
- return [
195
- "a",
196
- { href, title: title || href, target, rel },
197
- 0
198
- ];
431
+ return ["a", { href, title: title || href, target, rel }, 0];
199
432
  }
200
433
  },
201
434
  bold: {
@@ -243,15 +476,13 @@ function createSchema() {
243
476
  toDOM() {
244
477
  return ["u", 0];
245
478
  }
246
- }
247
- }
479
+ },
480
+ ...spec.marks
481
+ },
482
+ topNode: spec.topNode
248
483
  });
249
484
  const prosemirrorSchema = new Schema({
250
- nodes: addListNodes(
251
- customSchema.spec.nodes,
252
- "paragraph block*",
253
- "block"
254
- ),
485
+ nodes: addListNodes(customSchema.spec.nodes, "paragraph block*", "block"),
255
486
  marks: customSchema.spec.marks
256
487
  });
257
488
  return prosemirrorSchema;
@@ -0,0 +1,46 @@
1
+ import * as prosemirror_model from 'prosemirror-model';
2
+ import { Schema } from 'prosemirror-model';
3
+ import { EditorStateConfig, Transaction } from 'prosemirror-state';
4
+ import { DirectEditorProps, EditorView } from 'prosemirror-view';
5
+ import { GenerateMetadata, UploadFile } from './attach_file.mjs';
6
+ import { Subject } from 'rxjs';
7
+ import './schema.mjs';
8
+ import 'orderedmap';
9
+
10
+ type TextEditorControllerProps = {
11
+ mode?: "html" | "text";
12
+ state?: Partial<EditorStateConfig>;
13
+ editor?: Partial<DirectEditorProps>;
14
+ defaultValue?: string | readonly string[] | number;
15
+ updateDelay?: number;
16
+ placeholder?: string;
17
+ };
18
+ type CreateTextEditorOptions = {
19
+ className?: string;
20
+ style?: string;
21
+ attachFile?: {
22
+ generateMetadata?: GenerateMetadata;
23
+ uploadFile?: UploadFile;
24
+ };
25
+ };
26
+ declare function createTextEditorController(container: HTMLElement, schema: Schema, options: CreateTextEditorOptions, { mode, state, editor, defaultValue, updateDelay, placeholder, }: TextEditorControllerProps): {
27
+ schema: Schema<any, any>;
28
+ view: EditorView;
29
+ subject: Subject<Transaction>;
30
+ value: string;
31
+ commands: {
32
+ isBlockTypeActive: (node: prosemirror_model.NodeType, attrs?: prosemirror_model.Attrs | null, excludes?: prosemirror_model.NodeType[]) => false | undefined;
33
+ setBlockType: (node: string, attrs?: prosemirror_model.Attrs | null) => void;
34
+ toggleBlockType: (node: string, attrs?: prosemirror_model.Attrs | null) => void;
35
+ toggleMark: (mark: string, attrs?: prosemirror_model.Attrs | null, options?: {
36
+ removeWhenPresent?: boolean;
37
+ enterInlineAtoms?: boolean;
38
+ includeWhitespace?: boolean;
39
+ }) => void;
40
+ wrapInList: (listType: string, attrs?: prosemirror_model.Attrs | null) => void;
41
+ clear: () => void;
42
+ attachFile: (files: File[]) => void;
43
+ };
44
+ };
45
+
46
+ export { type CreateTextEditorOptions, type TextEditorControllerProps, createTextEditorController };
@@ -0,0 +1,46 @@
1
+ import * as prosemirror_model from 'prosemirror-model';
2
+ import { Schema } from 'prosemirror-model';
3
+ import { EditorStateConfig, Transaction } from 'prosemirror-state';
4
+ import { DirectEditorProps, EditorView } from 'prosemirror-view';
5
+ import { GenerateMetadata, UploadFile } from './attach_file.js';
6
+ import { Subject } from 'rxjs';
7
+ import './schema.js';
8
+ import 'orderedmap';
9
+
10
+ type TextEditorControllerProps = {
11
+ mode?: "html" | "text";
12
+ state?: Partial<EditorStateConfig>;
13
+ editor?: Partial<DirectEditorProps>;
14
+ defaultValue?: string | readonly string[] | number;
15
+ updateDelay?: number;
16
+ placeholder?: string;
17
+ };
18
+ type CreateTextEditorOptions = {
19
+ className?: string;
20
+ style?: string;
21
+ attachFile?: {
22
+ generateMetadata?: GenerateMetadata;
23
+ uploadFile?: UploadFile;
24
+ };
25
+ };
26
+ declare function createTextEditorController(container: HTMLElement, schema: Schema, options: CreateTextEditorOptions, { mode, state, editor, defaultValue, updateDelay, placeholder, }: TextEditorControllerProps): {
27
+ schema: Schema<any, any>;
28
+ view: EditorView;
29
+ subject: Subject<Transaction>;
30
+ value: string;
31
+ commands: {
32
+ isBlockTypeActive: (node: prosemirror_model.NodeType, attrs?: prosemirror_model.Attrs | null, excludes?: prosemirror_model.NodeType[]) => false | undefined;
33
+ setBlockType: (node: string, attrs?: prosemirror_model.Attrs | null) => void;
34
+ toggleBlockType: (node: string, attrs?: prosemirror_model.Attrs | null) => void;
35
+ toggleMark: (mark: string, attrs?: prosemirror_model.Attrs | null, options?: {
36
+ removeWhenPresent?: boolean;
37
+ enterInlineAtoms?: boolean;
38
+ includeWhitespace?: boolean;
39
+ }) => void;
40
+ wrapInList: (listType: string, attrs?: prosemirror_model.Attrs | null) => void;
41
+ clear: () => void;
42
+ attachFile: (files: File[]) => void;
43
+ };
44
+ };
45
+
46
+ export { type CreateTextEditorOptions, type TextEditorControllerProps, createTextEditorController };