@fibery/prosemirror-schema 1.6.1 → 3.0.0-next.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 (56) hide show
  1. package/LICENSE +214 -0
  2. package/lib/index.d.ts +1 -0
  3. package/lib/index.js +17 -848
  4. package/lib/src/create-schema.d.ts +11 -0
  5. package/lib/src/create-schema.js +81 -0
  6. package/lib/src/marks/highlight.d.ts +2 -0
  7. package/lib/src/marks/highlight.js +68 -0
  8. package/lib/src/marks/hint-query.d.ts +2 -0
  9. package/lib/src/marks/hint-query.js +23 -0
  10. package/lib/src/marks/link.d.ts +2 -0
  11. package/lib/src/marks/link.js +13 -0
  12. package/lib/src/marks/linked-highlight.d.ts +8 -0
  13. package/lib/src/marks/linked-highlight.js +58 -0
  14. package/lib/src/marks/strike.d.ts +2 -0
  15. package/lib/src/marks/strike.js +7 -0
  16. package/lib/src/marks/types/mark.d.ts +3 -0
  17. package/lib/src/marks/types/mark.js +2 -0
  18. package/lib/src/marks/underline.d.ts +2 -0
  19. package/lib/src/marks/underline.js +7 -0
  20. package/lib/src/nodes/check-item.d.ts +11 -0
  21. package/lib/src/nodes/check-item.js +34 -0
  22. package/lib/src/nodes/check-list.d.ts +13 -0
  23. package/lib/src/nodes/check-list.js +31 -0
  24. package/lib/src/nodes/code-block.d.ts +2 -0
  25. package/lib/src/nodes/code-block.js +99 -0
  26. package/lib/src/nodes/entity.d.ts +11 -0
  27. package/lib/src/nodes/entity.js +35 -0
  28. package/lib/src/nodes/fibery-section.d.ts +3 -0
  29. package/lib/src/nodes/fibery-section.js +30 -0
  30. package/lib/src/nodes/fibery-view.d.ts +2 -0
  31. package/lib/src/nodes/fibery-view.js +32 -0
  32. package/lib/src/nodes/heading.d.ts +4 -0
  33. package/lib/src/nodes/heading.js +65 -0
  34. package/lib/src/nodes/image-block.d.ts +2 -0
  35. package/lib/src/nodes/image-block.js +35 -0
  36. package/lib/src/nodes/important.d.ts +2 -0
  37. package/lib/src/nodes/important.js +11 -0
  38. package/lib/src/nodes/media.d.ts +4 -0
  39. package/lib/src/nodes/media.js +33 -0
  40. package/lib/src/nodes/mention.d.ts +11 -0
  41. package/lib/src/nodes/mention.js +35 -0
  42. package/lib/src/nodes/note.d.ts +2 -0
  43. package/lib/src/nodes/note.js +11 -0
  44. package/lib/src/nodes/paragraph.d.ts +2 -0
  45. package/lib/src/nodes/paragraph.js +20 -0
  46. package/lib/src/nodes/table-nodes.d.ts +1 -0
  47. package/lib/src/nodes/table-nodes.js +21 -0
  48. package/lib/src/nodes/types/inline-content.d.ts +7 -0
  49. package/lib/src/nodes/types/inline-content.js +2 -0
  50. package/lib/src/nodes/types/text.d.ts +5 -0
  51. package/lib/src/nodes/types/text.js +2 -0
  52. package/lib/src/nodes/video.d.ts +2 -0
  53. package/lib/src/nodes/video.js +49 -0
  54. package/lib/test-helpers/index.d.ts +4 -0
  55. package/lib/test-helpers/index.js +21 -0
  56. package/package.json +19 -18
package/lib/index.js CHANGED
@@ -1,848 +1,17 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ "use strict";
3
- /******/ // The require scope
4
- /******/ var __webpack_require__ = {};
5
- /******/
6
- /************************************************************************/
7
- /******/ /* webpack/runtime/define property getters */
8
- /******/ (() => {
9
- /******/ // define getter functions for harmony exports
10
- /******/ __webpack_require__.d = (exports, definition) => {
11
- /******/ for(var key in definition) {
12
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14
- /******/ }
15
- /******/ }
16
- /******/ };
17
- /******/ })();
18
- /******/
19
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
20
- /******/ (() => {
21
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22
- /******/ })();
23
- /******/
24
- /******/ /* webpack/runtime/make namespace object */
25
- /******/ (() => {
26
- /******/ // define __esModule on exports
27
- /******/ __webpack_require__.r = (exports) => {
28
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
29
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
30
- /******/ }
31
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
32
- /******/ };
33
- /******/ })();
34
- /******/
35
- /************************************************************************/
36
- var __webpack_exports__ = {};
37
- // ESM COMPAT FLAG
38
- __webpack_require__.r(__webpack_exports__);
39
-
40
- // EXPORTS
41
- __webpack_require__.d(__webpack_exports__, {
42
- "createSchema": () => (/* reexport */ createSchema)
43
- });
44
-
45
- ;// CONCATENATED MODULE: external "prosemirror-model"
46
- const external_prosemirror_model_namespaceObject = require("prosemirror-model");
47
- ;// CONCATENATED MODULE: external "prosemirror-schema-basic"
48
- const external_prosemirror_schema_basic_namespaceObject = require("prosemirror-schema-basic");
49
- ;// CONCATENATED MODULE: external "prosemirror-schema-list"
50
- const external_prosemirror_schema_list_namespaceObject = require("prosemirror-schema-list");
51
- ;// CONCATENATED MODULE: external "prosemirror-tables"
52
- const external_prosemirror_tables_namespaceObject = require("prosemirror-tables");
53
- ;// CONCATENATED MODULE: ./src/nodes/table-nodes.ts
54
- // @ts-ignore
55
-
56
- const tableNodes = (0,external_prosemirror_tables_namespaceObject.tableNodes)({
57
- tableGroup: "block",
58
- cellContent: "block+",
59
- cellAttributes: {
60
- background: {
61
- default: null,
62
-
63
- getFromDOM(dom) {
64
- return dom.style.backgroundColor || null;
65
- },
66
-
67
- setDOMAttr(value, attrs) {
68
- if (value) {
69
- attrs.style = (attrs.style || "") + "background-color: ".concat(value, ";");
70
- }
71
- }
72
-
73
- }
74
- }
75
- });
76
- ;// CONCATENATED MODULE: ./src/nodes/paragraph.ts
77
- const paragraph = {
78
- content: "inline*",
79
- group: "block",
80
- attrs: {
81
- guid: {
82
- default: ""
83
- }
84
- },
85
- parseDOM: [{
86
- tag: "p",
87
- getAttrs: dom => ({
88
- guid: dom.getAttribute("data-guid")
89
- })
90
- }],
91
-
92
- toDOM(node) {
93
- const {
94
- guid
95
- } = node.attrs;
96
- return ["p", {
97
- "data-guid": guid
98
- }, 0];
99
- }
100
-
101
- };
102
- ;// CONCATENATED MODULE: ./src/nodes/heading.ts
103
- const DEFAULT_GUID = "";
104
- const makeHeading = ({
105
- headingToDOM
106
- }) => ({
107
- content: "inline*",
108
- group: "block",
109
- attrs: {
110
- level: {
111
- default: 1
112
- },
113
- guid: {
114
- default: DEFAULT_GUID
115
- }
116
- },
117
- defining: true,
118
- parseDOM: [{
119
- tag: "h1",
120
- getAttrs: dom => ({
121
- level: 1,
122
- guid: dom.getAttribute("guid") || DEFAULT_GUID
123
- })
124
- }, {
125
- tag: "h2",
126
- getAttrs: dom => ({
127
- level: 2,
128
- guid: dom.getAttribute("guid") || DEFAULT_GUID
129
- })
130
- }, {
131
- tag: "h3",
132
- getAttrs: dom => ({
133
- level: 3,
134
- guid: dom.getAttribute("guid") || DEFAULT_GUID
135
- })
136
- }, {
137
- tag: "h4",
138
- getAttrs: dom => ({
139
- level: 4,
140
- guid: dom.getAttribute("guid") || DEFAULT_GUID
141
- })
142
- }, {
143
- tag: "h5",
144
- getAttrs: dom => ({
145
- level: 5,
146
- guid: dom.getAttribute("guid") || DEFAULT_GUID
147
- })
148
- }, {
149
- tag: "h6",
150
- getAttrs: dom => ({
151
- level: 6,
152
- guid: dom.getAttribute("guid") || DEFAULT_GUID
153
- })
154
- }],
155
-
156
- toDOM(node) {
157
- if (headingToDOM) {
158
- return headingToDOM(node);
159
- }
160
-
161
- const {
162
- guid
163
- } = node.attrs;
164
- return ["h" + node.attrs.level, {
165
- guid
166
- }, 0];
167
- }
168
-
169
- });
170
- ;// CONCATENATED MODULE: ./src/nodes/media.ts
171
- const makeMedia = ({
172
- mediaToDom
173
- }) => ({
174
- inline: false,
175
- attrs: {
176
- url: {}
177
- },
178
- group: "block",
179
- draggable: true,
180
- parseDOM: [{
181
- tag: "div[data-url]",
182
-
183
- getAttrs(dom) {
184
- return {
185
- url: dom.getAttribute("data-url")
186
- };
187
- }
188
-
189
- }],
190
-
191
- toDOM(node) {
192
- if (mediaToDom) {
193
- return mediaToDom(node);
194
- }
195
-
196
- const {
197
- url
198
- } = node.attrs;
199
- const attrs = {
200
- "data-url": url,
201
- contenteditable: "false"
202
- };
203
- return ["div", attrs, url];
204
- }
205
-
206
- });
207
- ;// CONCATENATED MODULE: ./src/nodes/note.ts
208
- const note = {
209
- content: "inline*",
210
- group: "block",
211
-
212
- toDOM() {
213
- return ["div", {
214
- class: "fibery-note"
215
- }, ["p", 0]];
216
- },
217
-
218
- parseDOM: [{
219
- tag: "div.fibery-note"
220
- }]
221
- };
222
- ;// CONCATENATED MODULE: ./src/nodes/important.ts
223
- const important = {
224
- content: "inline*",
225
- group: "block",
226
- parseDOM: [{
227
- tag: "div.fibery-important"
228
- }],
229
-
230
- toDOM() {
231
- return ["div", {
232
- class: "fibery-important"
233
- }, ["p", 0]];
234
- }
235
-
236
- };
237
- ;// CONCATENATED MODULE: ./src/nodes/image-block.ts
238
- const imageBlock = {
239
- attrs: {
240
- src: {},
241
- alt: {
242
- default: null
243
- },
244
- title: {
245
- default: null
246
- }
247
- },
248
- // ----------------
249
- inline: false,
250
- // inline: true,
251
- group: "block",
252
- // group: "inline",
253
- content: "inline*",
254
- atom: true,
255
- // ----------------
256
- draggable: true,
257
- parseDOM: [{
258
- tag: "img[src]",
259
-
260
- getAttrs(domNode) {
261
- const dom = domNode;
262
- return {
263
- src: dom.getAttribute("src"),
264
- title: dom.getAttribute("title"),
265
- alt: dom.getAttribute("alt")
266
- };
267
- }
268
-
269
- }],
270
-
271
- toDOM(node) {
272
- const {
273
- src,
274
- alt,
275
- title
276
- } = node.attrs; // return ["img", {src, alt, title}];
277
-
278
- return ["div", {}, ["img", {
279
- src,
280
- alt,
281
- title
282
- }]];
283
- }
284
-
285
- };
286
- ;// CONCATENATED MODULE: ./src/nodes/entity.ts
287
- const entity = {
288
- inline: true,
289
- group: "inline",
290
- selectable: false,
291
- attrs: {
292
- id: {
293
- default: ""
294
- },
295
- text: {
296
- default: ""
297
- },
298
- typeId: {
299
- default: ""
300
- }
301
- },
302
- parseDOM: [{
303
- tag: "span[data-entity-id]",
304
- getAttrs: domNode => {
305
- const dom = domNode;
306
- return {
307
- id: dom.getAttribute("data-entity-id"),
308
- text: dom.textContent,
309
- typeId: dom.getAttribute("data-entity-type-id")
310
- };
311
- }
312
- }],
313
-
314
- toDOM(node) {
315
- const {
316
- id,
317
- typeId,
318
- text
319
- } = node.attrs;
320
- const attrs = {
321
- "data-entity-id": id,
322
- "data-entity-type-id": typeId,
323
- contenteditable: "false"
324
- };
325
- return ["span", attrs, text];
326
- }
327
-
328
- };
329
- ;// CONCATENATED MODULE: ./src/nodes/mention.ts
330
- const mention = {
331
- inline: true,
332
- group: "inline",
333
- selectable: false,
334
- attrs: {
335
- id: {
336
- default: ""
337
- },
338
- name: {
339
- default: ""
340
- },
341
- typeId: {
342
- default: ""
343
- }
344
- },
345
- parseDOM: [{
346
- tag: "span[data-mention-id]",
347
- getAttrs: domNode => {
348
- const dom = domNode;
349
- return {
350
- id: dom.getAttribute("data-mention-id"),
351
- name: dom.textContent,
352
- typeId: dom.getAttribute("data-mention-type-id")
353
- };
354
- }
355
- }],
356
-
357
- toDOM(node) {
358
- const {
359
- id,
360
- typeId,
361
- name
362
- } = node.attrs;
363
- const attrs = {
364
- "data-mention-id": id,
365
- "data-mention-type-id": typeId,
366
- contenteditable: "false"
367
- };
368
- return ["span", attrs, name];
369
- }
370
-
371
- };
372
- ;// CONCATENATED MODULE: external "uuid"
373
- const external_uuid_namespaceObject = require("uuid");
374
- ;// CONCATENATED MODULE: ./src/nodes/check-list.ts
375
-
376
- const check_list = {
377
- group: "block",
378
- defining: true,
379
- selectable: false,
380
- content: "(check_item)+ (check_item|check_list)*",
381
- attrs: {
382
- id: {
383
- default: ""
384
- }
385
- },
386
- parseDOM: [{
387
- tag: "div[data-check-list-id]",
388
- // Default priority is 50. We normaly don't change this but since this node type is
389
- // also used by ordered-list we need to make sure that we run this parser first.
390
- priority: 100,
391
- getAttrs: () => ({
392
- id: (0,external_uuid_namespaceObject.v4)()
393
- })
394
- }],
395
-
396
- toDOM(node) {
397
- const {
398
- id
399
- } = node.attrs;
400
- const attrs = {
401
- "data-check-list-id": id
402
- };
403
- return ["div", attrs, 0];
404
- }
405
-
406
- };
407
- ;// CONCATENATED MODULE: ./src/nodes/check-item.ts
408
-
409
- const check_item = {
410
- content: "inline*",
411
- defining: true,
412
- selectable: false,
413
- marks: "_",
414
- attrs: {
415
- id: {
416
- default: ""
417
- },
418
- state: {
419
- default: "TODO"
420
- }
421
- },
422
- parseDOM: [{
423
- tag: "div[data-check-item-id]",
424
- // Default priority is 50. We normally don't change this but since this node type is
425
- // also used by list-item we need to make sure that we run this parser first.
426
- priority: 100,
427
- getAttrs: dom => ({
428
- id: (0,external_uuid_namespaceObject.v4)(),
429
- state: dom.getAttribute("data-check-item-state")
430
- })
431
- }],
432
-
433
- toDOM(node) {
434
- const {
435
- id,
436
- state
437
- } = node.attrs;
438
- const attrs = {
439
- "data-check-item-id": id,
440
- "data-check-item-state": state
441
- };
442
- return ["div", attrs, 0];
443
- }
444
-
445
- };
446
- ;// CONCATENATED MODULE: ./src/nodes/code-block.ts
447
-
448
-
449
- const getLanguageFromEditorStyle = dom => {
450
- return dom.getAttribute("data-language") || undefined;
451
- }; // example of BB style:
452
- // <div class="codehilite language-javascript"><pre><span>hello world</span><span>\n</span></pre></div>
453
-
454
-
455
- const getLanguageFromBitbucketStyle = dom => {
456
- if (dom && dom.classList.contains("codehilite")) {
457
- // code block html from Bitbucket always contains an extra new line
458
- return extractLanguageFromClass(dom.className);
459
- }
460
-
461
- return undefined;
462
- }; // If there is a child code element, check that for data-language
463
-
464
-
465
- const getLanguageFromCode = dom => {
466
- const firstChild = dom.firstElementChild;
467
-
468
- if (firstChild && firstChild.nodeName === "CODE") {
469
- return firstChild.getAttribute("data-language") || undefined;
470
- }
471
-
472
- return undefined;
473
- };
474
-
475
- const extractLanguageFromClass = className => {
476
- const languageRegex = /(?:^|\s)language-([^\s]+)/;
477
- const result = languageRegex.exec(className);
478
-
479
- if (result && result[1]) {
480
- return result[1];
481
- }
482
-
483
- return undefined;
484
- };
485
-
486
- const removeLastNewLine = dom => {
487
- const parent = dom && dom.parentElement;
488
-
489
- if (parent && parent.classList.contains("codehilite")) {
490
- dom.textContent = dom.textContent.replace(/\n$/, "");
491
- }
492
-
493
- return dom;
494
- };
495
-
496
- const code_block = {
497
- content: "text*",
498
- marks: "",
499
- group: "block",
500
- code: true,
501
- defining: true,
502
- attrs: {
503
- language: {
504
- default: null
505
- }
506
- },
507
- parseDOM: [{
508
- tag: "pre",
509
- preserveWhitespace: "full",
510
- getAttrs: domNode => {
511
- const dom = domNode;
512
- const language = getLanguageFromBitbucketStyle(dom.parentElement) || getLanguageFromEditorStyle(dom.parentElement) || getLanguageFromCode(dom) || dom.getAttribute("data-language");
513
- removeLastNewLine(dom);
514
- return {
515
- language
516
- };
517
- }
518
- }, // Handle VSCode paste
519
- {
520
- tag: "div[style]",
521
- preserveWhitespace: "full",
522
- getAttrs: domNode => {
523
- const dom = domNode;
524
-
525
- if (dom.style.whiteSpace === "pre" || dom.style.fontFamily && dom.style.fontFamily.toLowerCase().indexOf("monospace") > -1) {
526
- return {};
527
- }
528
-
529
- return false;
530
- },
531
- getContent: (domNode, schema) => {
532
- const dom = domNode;
533
- const code = Array.from(dom.children).map(child => child.textContent).filter(x => x !== undefined).join("\n");
534
- return code ? external_prosemirror_model_namespaceObject.Fragment.from(schema.text(code)) : external_prosemirror_model_namespaceObject.Fragment.empty;
535
- }
536
- }, // Handle GitHub/Gist paste
537
- {
538
- tag: "table[style]",
539
- preserveWhitespace: "full",
540
- getAttrs: dom => {
541
- if (dom.querySelector('td[class*="blob-code"]')) {
542
- return {};
543
- }
544
-
545
- return false;
546
- }
547
- }],
548
-
549
- toDOM(node) {
550
- return ["pre", ["code", {
551
- "data-language": node.attrs.language
552
- }, 0]];
553
- }
554
-
555
- };
556
- ;// CONCATENATED MODULE: ./src/nodes/video.ts
557
- const DEFAULT_VIDEO_WIDTH = 400;
558
- const DEFAULT_VIDEO_HEIGHT = 200;
559
- const video = {
560
- inline: false,
561
- attrs: {
562
- src: {},
563
- type: {},
564
- width: {
565
- default: DEFAULT_VIDEO_WIDTH
566
- },
567
- height: {
568
- default: DEFAULT_VIDEO_HEIGHT
569
- },
570
- title: {
571
- default: ""
572
- },
573
- alignment: {
574
- default: ":alignment/block-center"
575
- }
576
- },
577
- group: "block",
578
- draggable: true,
579
- parseDOM: [{
580
- tag: "video",
581
-
582
- getAttrs(domNode) {
583
- const dom = domNode;
584
- return {
585
- src: dom.getAttribute("src"),
586
- type: dom.getAttribute("type"),
587
- width: Number(dom.getAttribute("width")) || DEFAULT_VIDEO_WIDTH,
588
- height: Number(dom.getAttribute("height")) || DEFAULT_VIDEO_HEIGHT,
589
- title: dom.getAttribute("title")
590
- };
591
- }
592
-
593
- }],
594
-
595
- toDOM(node) {
596
- const {
597
- src,
598
- type,
599
- width = DEFAULT_VIDEO_WIDTH,
600
- height = DEFAULT_VIDEO_HEIGHT,
601
- title
602
- } = node.attrs;
603
- return ["video", {
604
- src,
605
- type,
606
- width,
607
- height,
608
- title,
609
- playsinline: "",
610
- controls: "",
611
- preload: "metadata"
612
- }];
613
- }
614
-
615
- };
616
- ;// CONCATENATED MODULE: ./src/marks/strike.ts
617
- const strike = {
618
- parseDOM: [{
619
- tag: "strike"
620
- }, {
621
- style: "text-decoration=line-through"
622
- }],
623
- toDOM: () => ["strike"]
624
- };
625
- ;// CONCATENATED MODULE: ./src/marks/underline.ts
626
- const underline = {
627
- parseDOM: [{
628
- tag: "u"
629
- }, {
630
- style: "text-decoration=underline"
631
- }],
632
- toDOM: () => ["u"]
633
- };
634
- ;// CONCATENATED MODULE: ./src/marks/hint-query.ts
635
- const hintQuery = {
636
- excludes: "searchQuery",
637
- inclusive: true,
638
- group: "searchQuery",
639
- attrs: {
640
- trigger: {
641
- default: ""
642
- },
643
- guid: {
644
- default: ""
645
- }
646
- },
647
- parseDOM: [{
648
- tag: "span[data-hint-query]"
649
- }],
650
-
651
- toDOM(node) {
652
- return ["span", {
653
- "data-hint-query": "true",
654
- "data-trigger": node.attrs.trigger,
655
- "data-guid": node.attrs.guid
656
- }];
657
- }
658
-
659
- };
660
- ;// CONCATENATED MODULE: ./src/marks/highlight.ts
661
- const highlight = {
662
- attrs: {
663
- color: {
664
- default: "#FFE4B5"
665
- },
666
- guid: {
667
- default: ""
668
- }
669
- },
670
- parseDOM: [{
671
- tag: "span[data-highlight]",
672
- getAttrs: domNode => {
673
- const dom = domNode;
674
- return {
675
- color: dom.style.backgroundColor || "#FFE4B5"
676
- };
677
- }
678
- }],
679
-
680
- toDOM(node) {
681
- return ["span", {
682
- "data-highlight": "true",
683
- "data-guid": node.attrs.guid,
684
- style: "background-color:".concat(node.attrs.color)
685
- }];
686
- }
687
-
688
- };
689
- ;// CONCATENATED MODULE: ./src/marks/linked-highlight.js
690
- const hyphenatePascal = str => str.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/([A-Z]{2})[a-z]/, "$1-").toLowerCase();
691
-
692
- const createMark = (markType, sharedColorGenerator) => {
693
- const markTag = "span.".concat(markType);
694
- const markClassName = "".concat(markType);
695
-
696
- const preserveBool = attr => attr === "true" ? true : attr === "false" ? false : attr;
697
-
698
- return {
699
- attrs: {
700
- id: {},
701
- meta: {
702
- default: {}
703
- }
704
- },
705
- inclusive: false,
706
- parseDOM: [{
707
- tag: markTag,
708
- getAttrs: ({
709
- dataset
710
- }) => {
711
- return {
712
- id: dataset.id || false,
713
- meta: Object.keys(dataset).filter(key => key !== "id" && dataset[key] !== "false").reduce((out, key) => ({ ...out,
714
- [key]: preserveBool(JSON.parse(dataset[key]))
715
- }), {
716
- type: markType
717
- })
718
- };
719
- }
720
- }],
721
- toDOM: ({
722
- attrs
723
- }) => {
724
- const {
725
- id,
726
- meta
727
- } = attrs;
728
- const {
729
- hidden = false
730
- } = meta;
731
- const {
732
- typeId
733
- } = meta.links && meta.links.length > 0 ? meta.links[0] : {};
734
- const color = sharedColorGenerator ? sharedColorGenerator.generate(typeId) : "#eeeeee";
735
- return [markTag, {
736
- class: [markClassName, hidden ? "".concat(markClassName, "--collapsed") : ""].join(" "),
737
- contenteditable: !hidden,
738
- style: color ? "background-color:".concat(color) : "",
739
- "data-id": id,
740
- ...Object.keys(meta).filter(key => meta[key] !== false) // remove specials
741
- .reduce((out, key) => ({ ...out,
742
- ["data-".concat(hyphenatePascal(key))]: JSON.stringify(meta[key])
743
- }), {})
744
- }];
745
- }
746
- };
747
- };
748
-
749
- const makeLinkedHighlight = ({
750
- sharedColorGenerator
751
- }) => {
752
- return createMark("linkedhighlight", sharedColorGenerator);
753
- };
754
- ;// CONCATENATED MODULE: ./src/marks/link.ts
755
- const makeLink = baseLink => {
756
- return { ...baseLink,
757
-
758
- toDOM(node) {
759
- const {
760
- href,
761
- title
762
- } = node.attrs;
763
- return ["a", {
764
- href,
765
- title,
766
- target: "_blank"
767
- }, 0];
768
- }
769
-
770
- };
771
- };
772
- ;// CONCATENATED MODULE: ./src/create-schema.ts
773
- // @ts-ignore
774
-
775
- // @ts-ignore
776
-
777
-
778
-
779
-
780
-
781
-
782
-
783
-
784
-
785
-
786
-
787
-
788
-
789
-
790
-
791
-
792
-
793
-
794
-
795
-
796
-
797
- const createSchema = ({
798
- sharedColorGenerator = null,
799
- headingToDOM = null,
800
- mediaToDom = null,
801
- isImageBlockEnabled = false
802
- } = {}) => {
803
- external_prosemirror_schema_basic_namespaceObject.nodes.code_block = code_block;
804
- external_prosemirror_schema_basic_namespaceObject.nodes.paragraph = paragraph;
805
- external_prosemirror_schema_basic_namespaceObject.nodes.heading = makeHeading({
806
- headingToDOM
807
- });
808
- external_prosemirror_schema_basic_namespaceObject.marks.link = makeLink(external_prosemirror_schema_basic_namespaceObject.marks.link);
809
- const base = new external_prosemirror_model_namespaceObject.Schema({
810
- nodes: external_prosemirror_schema_basic_namespaceObject.nodes,
811
- marks: external_prosemirror_schema_basic_namespaceObject.marks
812
- });
813
- const customNodes = {
814
- note: note,
815
- important: important,
816
- entity: entity,
817
- mention: mention,
818
- media: makeMedia({
819
- mediaToDom
820
- }),
821
- check_item: check_item,
822
- check_list: check_list,
823
- video: video
824
- };
825
- let actualNodes = (0,external_prosemirror_schema_list_namespaceObject.addListNodes)(base.spec.nodes, "paragraph block*", "block").append(tableNodes).append(customNodes);
826
-
827
- if (isImageBlockEnabled) {
828
- actualNodes = actualNodes.addToStart("imageBlock", imageBlock);
829
- } else {
830
- actualNodes = actualNodes.addToEnd("imageBlock", imageBlock);
831
- }
832
-
833
- return new external_prosemirror_model_namespaceObject.Schema({
834
- nodes: actualNodes,
835
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
836
- // @ts-ignore
837
- marks: base.spec.marks // eslint-disable-next-line @typescript-eslint/ban-ts-comment
838
- // @ts-ignore
839
- .addToEnd("strike", strike).addToEnd("underline", underline).addToEnd("hintQuery", hintQuery).addToEnd("highlight", highlight).addToEnd("linkedhighlight", makeLinkedHighlight({
840
- sharedColorGenerator
841
- }))
842
- });
843
- };
844
- ;// CONCATENATED MODULE: ./index.ts
845
-
846
- module.exports = __webpack_exports__;
847
- /******/ })()
848
- ;
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./src/create-schema"), exports);