github.com/cozy/cozy-stack@v0.0.0-20240327093429-939e4a21320e/model/note/schema.go (about) 1 package note 2 3 import ( 4 "encoding/json" 5 "sync" 6 ) 7 8 // DefaultSchemaSpecs returns the prosemirror schema used when importing files. 9 func DefaultSchemaSpecs() map[string]interface{} { 10 loadSchemaOnce.Do(func() { 11 raw := []byte(defaultSchemaString) 12 if err := json.Unmarshal(raw, &defaultSchemaSpecs); err != nil { 13 panic(err) 14 } 15 }) 16 return defaultSchemaSpecs 17 } 18 19 var defaultSchemaSpecs map[string]interface{} 20 var loadSchemaOnce sync.Once 21 22 const defaultSchemaString = ` 23 { 24 "marks": [ 25 [ 26 "link", 27 { 28 "attrs": { 29 "__confluenceMetadata": { 30 "default": null 31 }, 32 "href": {} 33 }, 34 "excludes": "link color", 35 "group": "link", 36 "inclusive": false, 37 "parseDOM": [ 38 { 39 "tag": "[data-block-link]" 40 }, 41 { 42 "context": "paragraph/|heading/|mediaSingle/|taskItem/|decisionItem/", 43 "tag": "a[href]" 44 }, 45 { 46 "tag": "a[href]" 47 } 48 ] 49 } 50 ], 51 [ 52 "em", 53 { 54 "group": "fontStyle", 55 "inclusive": true, 56 "parseDOM": [ 57 { 58 "tag": "i" 59 }, 60 { 61 "tag": "em" 62 }, 63 { 64 "style": "font-style=italic" 65 } 66 ] 67 } 68 ], 69 [ 70 "strong", 71 { 72 "group": "fontStyle", 73 "inclusive": true, 74 "parseDOM": [ 75 { 76 "tag": "strong" 77 }, 78 { 79 "tag": "b" 80 }, 81 { 82 "tag": "span" 83 } 84 ] 85 } 86 ], 87 [ 88 "textColor", 89 { 90 "attrs": { 91 "color": {} 92 }, 93 "group": "color", 94 "inclusive": true, 95 "parseDOM": [ 96 { 97 "style": "color" 98 } 99 ] 100 } 101 ], 102 [ 103 "strike", 104 { 105 "group": "fontStyle", 106 "inclusive": true, 107 "parseDOM": [ 108 { 109 "tag": "strike" 110 }, 111 { 112 "tag": "s" 113 }, 114 { 115 "tag": "del" 116 }, 117 { 118 "style": "text-decoration" 119 } 120 ] 121 } 122 ], 123 [ 124 "subsup", 125 { 126 "attrs": { 127 "type": { 128 "default": "sub" 129 } 130 }, 131 "group": "fontStyle", 132 "inclusive": true, 133 "parseDOM": [ 134 { 135 "attrs": { 136 "type": "sub" 137 }, 138 "tag": "sub" 139 }, 140 { 141 "attrs": { 142 "type": "sup" 143 }, 144 "tag": "sup" 145 }, 146 { 147 "style": "vertical-align=super", 148 "tag": "span" 149 }, 150 { 151 "style": "vertical-align=sub", 152 "tag": "span" 153 } 154 ] 155 } 156 ], 157 [ 158 "underline", 159 { 160 "group": "fontStyle", 161 "inclusive": true, 162 "parseDOM": [ 163 { 164 "tag": "u" 165 }, 166 { 167 "style": "text-decoration" 168 } 169 ] 170 } 171 ], 172 [ 173 "code", 174 { 175 "excludes": "fontStyle link searchQuery color", 176 "inclusive": true, 177 "parseDOM": [ 178 { 179 "preserveWhitespace": true, 180 "tag": "span.code" 181 }, 182 { 183 "preserveWhitespace": true, 184 "tag": "code" 185 }, 186 { 187 "preserveWhitespace": true, 188 "tag": "tt" 189 }, 190 { 191 "preserveWhitespace": true, 192 "tag": "span" 193 } 194 ] 195 } 196 ], 197 [ 198 "typeAheadQuery", 199 { 200 "attrs": { 201 "trigger": { 202 "default": "" 203 } 204 }, 205 "group": "searchQuery", 206 "inclusive": true, 207 "parseDOM": [ 208 { 209 "tag": "span[data-type-ahead-query]" 210 } 211 ] 212 } 213 ], 214 [ 215 "alignment", 216 { 217 "attrs": { 218 "align": {} 219 }, 220 "excludes": "alignment indentation", 221 "group": "alignment", 222 "parseDOM": [ 223 { 224 "tag": "div.fabric-editor-block-mark" 225 } 226 ] 227 } 228 ], 229 [ 230 "breakout", 231 { 232 "attrs": { 233 "mode": { 234 "default": "wide" 235 } 236 }, 237 "inclusive": false, 238 "parseDOM": [ 239 { 240 "tag": "div.fabric-editor-breakout-mark" 241 } 242 ], 243 "spanning": false 244 } 245 ], 246 [ 247 "indentation", 248 { 249 "attrs": { 250 "level": {} 251 }, 252 "excludes": "indentation alignment", 253 "group": "indentation", 254 "parseDOM": [ 255 { 256 "tag": "div.fabric-editor-indentation-mark" 257 } 258 ] 259 } 260 ], 261 [ 262 "unsupportedMark", 263 { 264 "attrs": { 265 "originalValue": {} 266 } 267 } 268 ], 269 [ 270 "unsupportedNodeAttribute", 271 { 272 "attrs": { 273 "type": {}, 274 "unsupported": {} 275 } 276 } 277 ] 278 ], 279 "nodes": [ 280 [ 281 "date", 282 { 283 "attrs": { 284 "timestamp": { 285 "default": "" 286 } 287 }, 288 "group": "inline", 289 "inline": true, 290 "parseDOM": [ 291 { 292 "tag": "span[data-node-type=\"date\"]" 293 } 294 ], 295 "selectable": true 296 } 297 ], 298 [ 299 "status", 300 { 301 "attrs": { 302 "color": { 303 "default": "" 304 }, 305 "localId": { 306 "default": "dfab1003-a025-425f-869b-4592431ae618" 307 }, 308 "style": { 309 "default": "" 310 }, 311 "text": { 312 "default": "" 313 } 314 }, 315 "group": "inline", 316 "inline": true, 317 "parseDOM": [ 318 { 319 "tag": "span[data-node-type=\"status\"]" 320 } 321 ], 322 "selectable": true 323 } 324 ], 325 [ 326 "doc", 327 { 328 "content": "(block)+", 329 "marks": "alignment breakout indentation link unsupportedMark unsupportedNodeAttribute" 330 } 331 ], 332 [ 333 "paragraph", 334 { 335 "content": "inline*", 336 "group": "block", 337 "marks": "strong code em link strike subsup textColor typeAheadQuery underline unsupportedMark unsupportedNodeAttribute", 338 "parseDOM": [ 339 { 340 "tag": "p" 341 } 342 ], 343 "selectable": false 344 } 345 ], 346 [ 347 "text", 348 { 349 "group": "inline" 350 } 351 ], 352 [ 353 "bulletList", 354 { 355 "content": "listItem+", 356 "group": "block", 357 "marks": "unsupportedMark unsupportedNodeAttribute", 358 "parseDOM": [ 359 { 360 "tag": "ul" 361 } 362 ], 363 "selectable": false 364 } 365 ], 366 [ 367 "orderedList", 368 { 369 "content": "listItem+", 370 "group": "block", 371 "marks": "unsupportedMark unsupportedNodeAttribute", 372 "parseDOM": [ 373 { 374 "tag": "ol" 375 } 376 ], 377 "selectable": false 378 } 379 ], 380 [ 381 "listItem", 382 { 383 "content": "(paragraph | mediaSingle | codeBlock) (paragraph | bulletList | orderedList | mediaSingle | codeBlock)*", 384 "defining": true, 385 "marks": "link unsupportedMark unsupportedNodeAttribute", 386 "parseDOM": [ 387 { 388 "tag": "li" 389 } 390 ], 391 "selectable": false 392 } 393 ], 394 [ 395 "heading", 396 { 397 "attrs": { 398 "level": { 399 "default": 1 400 } 401 }, 402 "content": "inline*", 403 "defining": true, 404 "group": "block", 405 "parseDOM": [ 406 { 407 "attrs": { 408 "level": 1 409 }, 410 "tag": "h1" 411 }, 412 { 413 "attrs": { 414 "level": 2 415 }, 416 "tag": "h2" 417 }, 418 { 419 "attrs": { 420 "level": 3 421 }, 422 "tag": "h3" 423 }, 424 { 425 "attrs": { 426 "level": 4 427 }, 428 "tag": "h4" 429 }, 430 { 431 "attrs": { 432 "level": 5 433 }, 434 "tag": "h5" 435 }, 436 { 437 "attrs": { 438 "level": 6 439 }, 440 "tag": "h6" 441 } 442 ], 443 "selectable": false 444 } 445 ], 446 [ 447 "blockquote", 448 { 449 "content": "paragraph+", 450 "defining": true, 451 "group": "block", 452 "parseDOM": [ 453 { 454 "tag": "blockquote" 455 } 456 ], 457 "selectable": false 458 } 459 ], 460 [ 461 "codeBlock", 462 { 463 "attrs": { 464 "language": { 465 "default": null 466 }, 467 "uniqueId": { 468 "default": null 469 } 470 }, 471 "code": true, 472 "content": "text*", 473 "defining": true, 474 "group": "block", 475 "marks": "unsupportedMark unsupportedNodeAttribute", 476 "parseDOM": [ 477 { 478 "preserveWhitespace": "full", 479 "tag": "pre" 480 }, 481 { 482 "preserveWhitespace": "full", 483 "tag": "div[style]" 484 }, 485 { 486 "preserveWhitespace": "full", 487 "tag": "table[style]" 488 }, 489 { 490 "preserveWhitespace": "full", 491 "tag": "div.code-block" 492 } 493 ] 494 } 495 ], 496 [ 497 "rule", 498 { 499 "group": "block", 500 "parseDOM": [ 501 { 502 "tag": "hr" 503 } 504 ] 505 } 506 ], 507 [ 508 "panel", 509 { 510 "attrs": { 511 "panelType": { 512 "default": "info" 513 } 514 }, 515 "content": "(paragraph | heading | bulletList | orderedList )+", 516 "group": "block", 517 "marks": "unsupportedMark unsupportedNodeAttribute", 518 "parseDOM": [ 519 { 520 "tag": "div[data-panel-type]" 521 } 522 ] 523 } 524 ], 525 [ 526 "confluenceUnsupportedBlock", 527 { 528 "attrs": { 529 "cxhtml": { 530 "default": null 531 } 532 }, 533 "group": "block", 534 "parseDOM": [ 535 { 536 "tag": "div[data-node-type=\"confluenceUnsupportedBlock\"]" 537 } 538 ] 539 } 540 ], 541 [ 542 "confluenceUnsupportedInline", 543 { 544 "atom": true, 545 "attrs": { 546 "cxhtml": { 547 "default": null 548 } 549 }, 550 "group": "inline", 551 "inline": true, 552 "parseDOM": [ 553 { 554 "tag": "div[data-node-type=\"confluenceUnsupportedInline\"]" 555 } 556 ] 557 } 558 ], 559 [ 560 "unsupportedBlock", 561 { 562 "atom": true, 563 "attrs": { 564 "originalValue": { 565 "default": {} 566 } 567 }, 568 "group": "block", 569 "inline": false, 570 "parseDOM": [ 571 { 572 "tag": "[data-node-type=\"unsupportedBlock\"]" 573 } 574 ], 575 "selectable": true 576 } 577 ], 578 [ 579 "unsupportedInline", 580 { 581 "attrs": { 582 "originalValue": { 583 "default": {} 584 } 585 }, 586 "group": "inline", 587 "inline": true, 588 "parseDOM": [ 589 { 590 "tag": "[data-node-type=\"unsupportedInline\"]" 591 } 592 ], 593 "selectable": true 594 } 595 ], 596 [ 597 "hardBreak", 598 { 599 "group": "inline", 600 "inline": true, 601 "parseDOM": [ 602 { 603 "tag": "br" 604 } 605 ], 606 "selectable": false 607 } 608 ], 609 [ 610 "mediaSingle", 611 { 612 "atom": true, 613 "attrs": { 614 "layout": { 615 "default": "center" 616 }, 617 "width": { 618 "default": null 619 } 620 }, 621 "content": "media | media ( unsupportedBlock)", 622 "group": "block", 623 "inline": false, 624 "marks": "unsupportedMark unsupportedNodeAttribute link", 625 "parseDOM": [ 626 { 627 "tag": "div[data-node-type=\"mediaSingle\"]" 628 } 629 ], 630 "selectable": true 631 } 632 ], 633 [ 634 "table", 635 { 636 "attrs": { 637 "__autoSize": { 638 "default": false 639 }, 640 "isNumberColumnEnabled": { 641 "default": false 642 }, 643 "layout": { 644 "default": "default" 645 } 646 }, 647 "content": "tableRow+", 648 "group": "block", 649 "isolating": true, 650 "marks": "unsupportedMark unsupportedNodeAttribute", 651 "parseDOM": [ 652 { 653 "tag": "table" 654 } 655 ], 656 "selectable": false, 657 "tableRole": "table" 658 } 659 ], 660 [ 661 "media", 662 { 663 "attrs": { 664 "__contextId": { 665 "default": null 666 }, 667 "__displayType": { 668 "default": null 669 }, 670 "__external": { 671 "default": false 672 }, 673 "__fileMimeType": { 674 "default": null 675 }, 676 "__fileName": { 677 "default": null 678 }, 679 "__fileSize": { 680 "default": null 681 }, 682 "alt": { 683 "default": null 684 }, 685 "collection": { 686 "default": "" 687 }, 688 "height": { 689 "default": null 690 }, 691 "id": { 692 "default": "" 693 }, 694 "occurrenceKey": { 695 "default": null 696 }, 697 "type": { 698 "default": "file" 699 }, 700 "url": { 701 "default": null 702 }, 703 "width": { 704 "default": null 705 } 706 }, 707 "parseDOM": [ 708 { 709 "tag": "div[data-node-type=\"media\"]" 710 }, 711 { 712 "ignore": true, 713 "tag": "img[src^=\"data:image\"]" 714 }, 715 { 716 "tag": "img:not(.smart-link-icon)" 717 } 718 ], 719 "selectable": true 720 } 721 ], 722 [ 723 "tableHeader", 724 { 725 "attrs": { 726 "background": { 727 "default": null 728 }, 729 "colspan": { 730 "default": 1 731 }, 732 "colwidth": { 733 "default": null 734 }, 735 "rowspan": { 736 "default": 1 737 } 738 }, 739 "content": "(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaSingle | decisionList | taskList )+", 740 "isolating": true, 741 "marks": "link alignment unsupportedMark unsupportedNodeAttribute", 742 "parseDOM": [ 743 { 744 "tag": "th" 745 } 746 ], 747 "selectable": false, 748 "tableRole": "header_cell" 749 } 750 ], 751 [ 752 "decisionList", 753 { 754 "attrs": { 755 "localId": { 756 "default": "" 757 } 758 }, 759 "content": "decisionItem+", 760 "defining": true, 761 "group": "block", 762 "marks": "unsupportedMark unsupportedNodeAttribute", 763 "parseDOM": [ 764 { 765 "priority": 100, 766 "tag": "ol[data-node-type=\"decisionList\"]" 767 } 768 ], 769 "selectable": false 770 } 771 ], 772 [ 773 "tableRow", 774 { 775 "content": "(tableCell | tableHeader)+", 776 "marks": "unsupportedMark unsupportedNodeAttribute", 777 "parseDOM": [ 778 { 779 "tag": "tr" 780 } 781 ], 782 "selectable": false, 783 "tableRole": "row" 784 } 785 ], 786 [ 787 "decisionItem", 788 { 789 "attrs": { 790 "localId": { 791 "default": "" 792 }, 793 "state": { 794 "default": "DECIDED" 795 } 796 }, 797 "content": "inline*", 798 "defining": true, 799 "marks": "_", 800 "parseDOM": [ 801 { 802 "priority": 100, 803 "tag": "li[data-decision-local-id]" 804 } 805 ] 806 } 807 ], 808 [ 809 "tableCell", 810 { 811 "attrs": { 812 "background": { 813 "default": null 814 }, 815 "colspan": { 816 "default": 1 817 }, 818 "colwidth": { 819 "default": null 820 }, 821 "rowspan": { 822 "default": 1 823 } 824 }, 825 "content": "(paragraph | panel | blockquote | orderedList | bulletList | rule | heading | codeBlock | mediaSingle | decisionList | taskList | unsupportedBlock)+", 826 "isolating": true, 827 "marks": "link alignment unsupportedMark unsupportedNodeAttribute", 828 "parseDOM": [ 829 { 830 "ignore": true, 831 "tag": ".ak-renderer-table-number-column" 832 }, 833 { 834 "tag": "td" 835 } 836 ], 837 "selectable": false, 838 "tableRole": "cell" 839 } 840 ], 841 [ 842 "taskList", 843 { 844 "attrs": { 845 "localId": { 846 "default": "" 847 } 848 }, 849 "content": "taskItem+ (taskItem|taskList)*", 850 "defining": true, 851 "group": "block", 852 "marks": "unsupportedMark unsupportedNodeAttribute", 853 "parseDOM": [ 854 { 855 "priority": 100, 856 "tag": "div[data-node-type=\"actionList\"]" 857 } 858 ], 859 "selectable": false 860 } 861 ], 862 [ 863 "taskItem", 864 { 865 "attrs": { 866 "localId": { 867 "default": "" 868 }, 869 "state": { 870 "default": "TODO" 871 } 872 }, 873 "content": "inline*", 874 "defining": true, 875 "marks": "_", 876 "parseDOM": [ 877 { 878 "priority": 100, 879 "tag": "div[data-task-local-id]" 880 } 881 ], 882 "selectable": false 883 } 884 ] 885 ], 886 "version": 4 887 } 888 `