From 211ac83958e9c9f69f3d9777d4f4b106024bfa57 Mon Sep 17 00:00:00 2001 From: Matthew Lipski Date: Wed, 8 Oct 2025 10:45:18 +0200 Subject: [PATCH] Added unit tests to snapshot schema --- .../core/schema/__snapshots__/blocks.json | 1590 +++++++++++++++++ .../schema/__snapshots__/inlinecontent.json | 116 ++ .../core/schema/__snapshots__/styles.json | 353 ++++ tests/src/unit/core/schema/runTests.test.ts | 29 + 4 files changed, 2088 insertions(+) create mode 100644 tests/src/unit/core/schema/__snapshots__/blocks.json create mode 100644 tests/src/unit/core/schema/__snapshots__/inlinecontent.json create mode 100644 tests/src/unit/core/schema/__snapshots__/styles.json create mode 100644 tests/src/unit/core/schema/runTests.test.ts diff --git a/tests/src/unit/core/schema/__snapshots__/blocks.json b/tests/src/unit/core/schema/__snapshots__/blocks.json new file mode 100644 index 0000000000..b54e1b4d93 --- /dev/null +++ b/tests/src/unit/core/schema/__snapshots__/blocks.json @@ -0,0 +1,1590 @@ +{ + "audio": { + "config": { + "content": "none", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "caption": { + "default": "", + }, + "name": { + "default": "", + }, + "showPreview": { + "default": true, + }, + "url": { + "default": "", + }, + }, + "type": "audio", + }, + "extensions": undefined, + "implementation": { + "meta": { + "fileBlockAccept": [ + "audio/*", + ], + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "audio", + "parseHTML": [Function], + "priority": 111, + "renderHTML": [Function], + "selectable": true, + }, + "name": "audio", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "audio", + "parseHTML": [Function], + "priority": 111, + "renderHTML": [Function], + "selectable": true, + }, + "name": "audio", + "parent": null, + "type": "node", + }, + "parse": [Function], + "render": [Function], + "runsBefore": [ + "file", + ], + "toExternalHTML": [Function], + }, + }, + "bulletListItem": { + "config": { + "content": "inline", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "textColor": { + "default": "default", + }, + }, + "type": "bulletListItem", + }, + "extensions": [ + BlockNoteExtension { + "inputRules": [ + { + "find": /\^\[-\+\*\]\\s\$/, + "replace": [Function], + }, + ], + "key": "bullet-list-item-shortcuts", + "keyboardShortcuts": { + "Enter": [Function], + "Mod-Shift-8": [Function], + }, + "plugins": [], + "tiptapExtensions": undefined, + }, + ], + "implementation": { + "meta": { + "isolating": false, + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "bulletListItem", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "bulletListItem", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "bulletListItem", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "bulletListItem", + "parent": null, + "type": "node", + }, + "parse": [Function], + "parseContent": [Function], + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "checkListItem": { + "config": { + "content": "inline", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "checked": { + "default": false, + "type": "boolean", + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "textColor": { + "default": "default", + }, + }, + "type": "checkListItem", + }, + "extensions": [ + BlockNoteExtension { + "inputRules": [ + { + "find": /\\\[\\s\*\\\]\\s\$/, + "replace": [Function], + }, + { + "find": /\\\[\[Xx\]\\\]\\s\$/, + "replace": [Function], + }, + ], + "key": "check-list-item-shortcuts", + "keyboardShortcuts": { + "Enter": [Function], + "Mod-Shift-9": [Function], + }, + "plugins": [], + "tiptapExtensions": undefined, + }, + ], + "implementation": { + "meta": { + "isolating": false, + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "checkListItem", + "parseHTML": [Function], + "priority": 111, + "renderHTML": [Function], + "selectable": true, + }, + "name": "checkListItem", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "checkListItem", + "parseHTML": [Function], + "priority": 111, + "renderHTML": [Function], + "selectable": true, + }, + "name": "checkListItem", + "parent": null, + "type": "node", + }, + "parse": [Function], + "parseContent": [Function], + "render": [Function], + "runsBefore": [ + "bulletListItem", + ], + "toExternalHTML": [Function], + }, + }, + "codeBlock": { + "config": { + "content": "inline", + "propSchema": { + "language": { + "default": "text", + }, + }, + "type": "codeBlock", + }, + "extensions": [ + BlockNoteExtension { + "inputRules": undefined, + "key": "code-block-highlighter", + "keyboardShortcuts": undefined, + "plugins": [ + Plugin { + "key": "prosemirror-highlight$1", + "props": { + "decorations": [Function], + }, + "spec": { + "key": PluginKey { + "key": "prosemirror-highlight$1", + }, + "props": { + "decorations": [Function], + }, + "state": { + "apply": [Function], + "init": [Function], + }, + "view": [Function], + }, + }, + ], + "tiptapExtensions": undefined, + }, + BlockNoteExtension { + "inputRules": [ + { + "find": /\^```\(\.\*\?\)\\s\$/, + "replace": [Function], + }, + ], + "key": "code-block-keyboard-shortcuts", + "keyboardShortcuts": { + "Delete": [Function], + "Enter": [Function], + "Shift-Enter": [Function], + "Tab": [Function], + }, + "plugins": [], + "tiptapExtensions": undefined, + }, + ], + "implementation": { + "meta": { + "code": true, + "defining": true, + "isolating": false, + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": true, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "codeBlock", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "codeBlock", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": true, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "codeBlock", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "codeBlock", + "parent": null, + "type": "node", + }, + "parse": [Function], + "parseContent": [Function], + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "customParagraph": { + "config": { + "content": "inline", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "textColor": { + "default": "default", + }, + }, + "type": "customParagraph", + }, + "extensions": undefined, + "implementation": { + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "customParagraph", + "parseHTML": [Function], + "priority": undefined, + "renderHTML": [Function], + "selectable": true, + }, + "name": "customParagraph", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "customParagraph", + "parseHTML": [Function], + "priority": undefined, + "renderHTML": [Function], + "selectable": true, + }, + "name": "customParagraph", + "parent": null, + "type": "node", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "divider": { + "config": { + "content": "none", + "propSchema": {}, + "type": "divider", + }, + "extensions": [ + BlockNoteExtension { + "inputRules": [ + { + "find": /\^---\$/, + "replace": [Function], + }, + ], + "key": "divider-block-shortcuts", + "keyboardShortcuts": undefined, + "plugins": [], + "tiptapExtensions": undefined, + }, + ], + "implementation": { + "meta": { + "isolating": false, + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "divider", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "divider", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "divider", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "divider", + "parent": null, + "type": "node", + }, + "parse": [Function], + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "file": { + "config": { + "content": "none", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "caption": { + "default": "", + }, + "name": { + "default": "", + }, + "url": { + "default": "", + }, + }, + "type": "file", + }, + "extensions": undefined, + "implementation": { + "meta": { + "fileBlockAccept": [ + "*/*", + ], + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "file", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "file", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "file", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "file", + "parent": null, + "type": "node", + }, + "parse": [Function], + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "heading": { + "config": { + "content": "inline", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "isToggleable": { + "default": false, + "optional": true, + }, + "level": { + "default": 1, + "values": [ + 1, + 2, + 3, + 4, + 5, + 6, + ], + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "textColor": { + "default": "default", + }, + }, + "type": "heading", + }, + "extensions": [ + BlockNoteExtension { + "inputRules": [ + { + "find": /\^\(#\{1\}\)\\s\$/, + "replace": [Function], + }, + { + "find": /\^\(#\{2\}\)\\s\$/, + "replace": [Function], + }, + { + "find": /\^\(#\{3\}\)\\s\$/, + "replace": [Function], + }, + { + "find": /\^\(#\{4\}\)\\s\$/, + "replace": [Function], + }, + { + "find": /\^\(#\{5\}\)\\s\$/, + "replace": [Function], + }, + { + "find": /\^\(#\{6\}\)\\s\$/, + "replace": [Function], + }, + ], + "key": "heading-shortcuts", + "keyboardShortcuts": { + "Mod-Alt-1": [Function], + "Mod-Alt-2": [Function], + "Mod-Alt-3": [Function], + "Mod-Alt-4": [Function], + "Mod-Alt-5": [Function], + "Mod-Alt-6": [Function], + }, + "plugins": [], + "tiptapExtensions": undefined, + }, + ], + "implementation": { + "meta": { + "isolating": false, + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "heading", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "heading", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "heading", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "heading", + "parent": null, + "type": "node", + }, + "parse": [Function], + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "image": { + "config": { + "content": "none", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "caption": { + "default": "", + }, + "name": { + "default": "", + }, + "previewWidth": { + "default": undefined, + "type": "number", + }, + "showPreview": { + "default": true, + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "url": { + "default": "", + }, + }, + "type": "image", + }, + "extensions": undefined, + "implementation": { + "meta": { + "fileBlockAccept": [ + "image/*", + ], + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "image", + "parseHTML": [Function], + "priority": 111, + "renderHTML": [Function], + "selectable": true, + }, + "name": "image", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "image", + "parseHTML": [Function], + "priority": 111, + "renderHTML": [Function], + "selectable": true, + }, + "name": "image", + "parent": null, + "type": "node", + }, + "parse": [Function], + "render": [Function], + "runsBefore": [ + "file", + ], + "toExternalHTML": [Function], + }, + }, + "numberedListItem": { + "config": { + "content": "inline", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "start": { + "default": undefined, + "type": "number", + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "textColor": { + "default": "default", + }, + }, + "type": "numberedListItem", + }, + "extensions": [ + BlockNoteExtension { + "inputRules": [ + { + "find": /\^\(\\d\+\)\\\.\\s\$/, + "replace": [Function], + }, + ], + "key": "numbered-list-item-shortcuts", + "keyboardShortcuts": { + "Enter": [Function], + "Mod-Shift-7": [Function], + }, + "plugins": [ + Plugin { + "key": "numbered-list-indexing-decorations$", + "props": { + "decorations": [Function], + }, + "spec": { + "key": PluginKey { + "key": "numbered-list-indexing-decorations$", + }, + "props": { + "decorations": [Function], + }, + "state": { + "apply": [Function], + "init": [Function], + }, + }, + }, + ], + "tiptapExtensions": undefined, + }, + ], + "implementation": { + "meta": { + "isolating": false, + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "numberedListItem", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "numberedListItem", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "numberedListItem", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "numberedListItem", + "parent": null, + "type": "node", + }, + "parse": [Function], + "parseContent": [Function], + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "pageBreak": { + "config": { + "content": "none", + "propSchema": {}, + "type": "pageBreak", + }, + "extensions": undefined, + "implementation": { + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "pageBreak", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "pageBreak", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "pageBreak", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "pageBreak", + "parent": null, + "type": "node", + }, + "parse": [Function], + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "paragraph": { + "config": { + "content": "inline", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "textColor": { + "default": "default", + }, + }, + "type": "paragraph", + }, + "extensions": [ + BlockNoteExtension { + "inputRules": undefined, + "key": "paragraph-shortcuts", + "keyboardShortcuts": { + "Mod-Alt-0": [Function], + }, + "plugins": [], + "tiptapExtensions": undefined, + }, + ], + "implementation": { + "meta": { + "isolating": false, + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "paragraph", + "parseHTML": [Function], + "priority": 121, + "renderHTML": [Function], + "selectable": true, + }, + "name": "paragraph", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "paragraph", + "parseHTML": [Function], + "priority": 121, + "renderHTML": [Function], + "selectable": true, + }, + "name": "paragraph", + "parent": null, + "type": "node", + }, + "parse": [Function], + "render": [Function], + "runsBefore": [ + "default", + ], + "toExternalHTML": [Function], + }, + }, + "quote": { + "config": { + "content": "inline", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "textColor": { + "default": "default", + }, + }, + "type": "quote", + }, + "extensions": [ + BlockNoteExtension { + "inputRules": [ + { + "find": /\^>\\s\$/, + "replace": [Function], + }, + ], + "key": "quote-block-shortcuts", + "keyboardShortcuts": { + "Mod-Alt-q": [Function], + }, + "plugins": [], + "tiptapExtensions": undefined, + }, + ], + "implementation": { + "meta": { + "isolating": false, + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "quote", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "quote", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "quote", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "quote", + "parent": null, + "type": "node", + }, + "parse": [Function], + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "simpleCustomParagraph": { + "config": { + "content": "inline", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "textColor": { + "default": "default", + }, + }, + "type": "simpleCustomParagraph", + }, + "extensions": undefined, + "implementation": { + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "simpleCustomParagraph", + "parseHTML": [Function], + "priority": undefined, + "renderHTML": [Function], + "selectable": true, + }, + "name": "simpleCustomParagraph", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "simpleCustomParagraph", + "parseHTML": [Function], + "priority": undefined, + "renderHTML": [Function], + "selectable": true, + }, + "name": "simpleCustomParagraph", + "parent": null, + "type": "node", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "simpleImage": { + "config": { + "content": "none", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "caption": { + "default": "", + }, + "name": { + "default": "", + }, + "previewWidth": { + "default": undefined, + "type": "number", + }, + "showPreview": { + "default": true, + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "url": { + "default": "", + }, + }, + "type": "simpleImage", + }, + "extensions": undefined, + "implementation": { + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "simpleImage", + "parseHTML": [Function], + "priority": undefined, + "renderHTML": [Function], + "selectable": true, + }, + "name": "simpleImage", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "simpleImage", + "parseHTML": [Function], + "priority": undefined, + "renderHTML": [Function], + "selectable": true, + }, + "name": "simpleImage", + "parent": null, + "type": "node", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "table": { + "config": { + "content": "table", + "propSchema": { + "textColor": { + "default": "default", + }, + }, + "type": "table", + }, + "extensions": [ + BlockNoteExtension { + "inputRules": undefined, + "key": "table-extensions", + "keyboardShortcuts": undefined, + "plugins": [], + "tiptapExtensions": [ + _Extension { + "child": null, + "config": { + "addKeyboardShortcuts": [Function], + "addProseMirrorPlugins": [Function], + "extendNodeSchema": [Function], + "name": "BlockNoteTableExtension", + }, + "name": "BlockNoteTableExtension", + "parent": null, + "type": "extension", + }, + _Node { + "child": null, + "config": { + "content": "inline*", + "group": "tableContent", + "name": "tableParagraph", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "tableParagraph", + "parent": null, + "type": "node", + }, + _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addOptions": [Function], + "content": "tableContent+", + "isolating": true, + "name": "tableHeader", + "parseHTML": [Function], + "renderHTML": [Function], + "tableRole": "header_cell", + }, + "name": "tableHeader", + "parent": null, + "type": "node", + }, + _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addOptions": [Function], + "content": "tableContent+", + "isolating": true, + "name": "tableCell", + "parseHTML": [Function], + "renderHTML": [Function], + "tableRole": "cell", + }, + "name": "tableCell", + "parent": null, + "type": "node", + }, + _Node { + "child": null, + "config": { + "addOptions": [Function], + "content": "(tableCell | tableHeader)+", + "marks": "deletion insertion modification", + "name": "tableRow", + "parseHTML": [Function], + "renderHTML": [Function], + "tableRole": "row", + }, + "name": "tableRow", + "parent": null, + "type": "node", + }, + ], + }, + BlockNoteExtension { + "inputRules": undefined, + "key": "table-keyboard-delete", + "keyboardShortcuts": { + "Backspace": [Function], + }, + "plugins": [], + "tiptapExtensions": undefined, + }, + ], + "implementation": { + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addNodeView": [Function], + "addOptions": [Function], + "content": "tableRow+", + "group": "blockContent", + "isolating": true, + "marks": "deletion insertion modification", + "name": "table", + "parseHTML": [Function], + "renderHTML": [Function], + "tableRole": "table", + }, + "name": "table", + "parent": null, + "type": "node", + }, + "config": { + "addNodeView": [Function], + "content": "tableRow+", + "group": "blockContent", + "isolating": true, + "marks": "deletion insertion modification", + "name": "table", + "parseHTML": [Function], + "renderHTML": [Function], + "tableRole": "table", + }, + "name": "table", + "parent": null, + "type": "node", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "toggleListItem": { + "config": { + "content": "inline", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "textColor": { + "default": "default", + }, + }, + "type": "toggleListItem", + }, + "extensions": [ + BlockNoteExtension { + "inputRules": undefined, + "key": "toggle-list-item-shortcuts", + "keyboardShortcuts": { + "Enter": [Function], + "Mod-Shift-6": [Function], + }, + "plugins": [], + "tiptapExtensions": undefined, + }, + ], + "implementation": { + "meta": { + "isolating": false, + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "toggleListItem", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "toggleListItem", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "inline*", + "defining": true, + "group": "blockContent", + "isolating": false, + "name": "toggleListItem", + "parseHTML": [Function], + "priority": 101, + "renderHTML": [Function], + "selectable": true, + }, + "name": "toggleListItem", + "parent": null, + "type": "node", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "video": { + "config": { + "content": "none", + "propSchema": { + "backgroundColor": { + "default": "default", + }, + "caption": { + "default": "", + }, + "name": { + "default": "", + }, + "previewWidth": { + "default": undefined, + "type": "number", + }, + "showPreview": { + "default": true, + }, + "textAlignment": { + "default": "left", + "values": [ + "left", + "center", + "right", + "justify", + ], + }, + "url": { + "default": "", + }, + }, + "type": "video", + }, + "extensions": undefined, + "implementation": { + "meta": { + "fileBlockAccept": [ + "video/*", + ], + }, + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "video", + "parseHTML": [Function], + "priority": 111, + "renderHTML": [Function], + "selectable": true, + }, + "name": "video", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addNodeView": [Function], + "code": false, + "content": "", + "defining": true, + "group": "blockContent", + "isolating": true, + "name": "video", + "parseHTML": [Function], + "priority": 111, + "renderHTML": [Function], + "selectable": true, + }, + "name": "video", + "parent": null, + "type": "node", + }, + "parse": [Function], + "render": [Function], + "runsBefore": [ + "file", + ], + "toExternalHTML": [Function], + }, + }, +} \ No newline at end of file diff --git a/tests/src/unit/core/schema/__snapshots__/inlinecontent.json b/tests/src/unit/core/schema/__snapshots__/inlinecontent.json new file mode 100644 index 0000000000..6d7bec7453 --- /dev/null +++ b/tests/src/unit/core/schema/__snapshots__/inlinecontent.json @@ -0,0 +1,116 @@ +{ + "link": { + "config": "link", + "implementation": {}, + }, + "mention": { + "config": { + "content": "none", + "propSchema": { + "user": { + "default": "", + }, + }, + "type": "mention", + }, + "implementation": { + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addKeyboardShortcuts": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "atom": true, + "content": "", + "draggable": undefined, + "group": "inline", + "inline": true, + "name": "mention", + "parseHTML": [Function], + "renderHTML": [Function], + "selectable": false, + }, + "name": "mention", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addKeyboardShortcuts": [Function], + "addNodeView": [Function], + "atom": true, + "content": "", + "draggable": undefined, + "group": "inline", + "inline": true, + "name": "mention", + "parseHTML": [Function], + "renderHTML": [Function], + "selectable": false, + }, + "name": "mention", + "parent": null, + "type": "node", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "tag": { + "config": { + "content": "styled", + "propSchema": {}, + "type": "tag", + }, + "implementation": { + "node": _Node { + "child": _Node { + "child": null, + "config": { + "addAttributes": [Function], + "addKeyboardShortcuts": [Function], + "addNodeView": [Function], + "addOptions": [Function], + "atom": false, + "content": "inline*", + "draggable": undefined, + "group": "inline", + "inline": true, + "name": "tag", + "parseHTML": [Function], + "renderHTML": [Function], + "selectable": true, + }, + "name": "tag", + "parent": null, + "type": "node", + }, + "config": { + "addAttributes": [Function], + "addKeyboardShortcuts": [Function], + "addNodeView": [Function], + "atom": false, + "content": "inline*", + "draggable": undefined, + "group": "inline", + "inline": true, + "name": "tag", + "parseHTML": [Function], + "renderHTML": [Function], + "selectable": true, + }, + "name": "tag", + "parent": null, + "type": "node", + }, + "render": [Function], + "toExternalHTML": undefined, + }, + }, + "text": { + "config": "text", + "implementation": {}, + }, +} \ No newline at end of file diff --git a/tests/src/unit/core/schema/__snapshots__/styles.json b/tests/src/unit/core/schema/__snapshots__/styles.json new file mode 100644 index 0000000000..44cc9b468e --- /dev/null +++ b/tests/src/unit/core/schema/__snapshots__/styles.json @@ -0,0 +1,353 @@ +{ + "backgroundColor": { + "config": { + "propSchema": "string", + "type": "backgroundColor", + }, + "implementation": { + "mark": _Mark { + "child": _Mark { + "child": null, + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "addOptions": [Function], + "name": "backgroundColor", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "backgroundColor", + "parent": null, + "type": "mark", + }, + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "backgroundColor", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "backgroundColor", + "parent": null, + "type": "mark", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "bold": { + "config": { + "propSchema": "boolean", + "type": "bold", + }, + "implementation": { + "mark": _Mark { + "child": _Mark { + "child": null, + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "bold", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "bold", + "parent": null, + "type": "mark", + }, + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "bold", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "bold", + "parent": null, + "type": "mark", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "code": { + "config": { + "propSchema": "boolean", + "type": "code", + }, + "implementation": { + "mark": _Mark { + "child": _Mark { + "child": null, + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "code": true, + "excludes": "_", + "exitable": true, + "name": "code", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "code", + "parent": null, + "type": "mark", + }, + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "code": true, + "excludes": "_", + "exitable": true, + "name": "code", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "code", + "parent": null, + "type": "mark", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "fontSize": { + "config": { + "propSchema": "string", + "type": "fontSize", + }, + "implementation": { + "mark": _Mark { + "child": _Mark { + "child": null, + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "addOptions": [Function], + "name": "fontSize", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "fontSize", + "parent": null, + "type": "mark", + }, + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "fontSize", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "fontSize", + "parent": null, + "type": "mark", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "italic": { + "config": { + "propSchema": "boolean", + "type": "italic", + }, + "implementation": { + "mark": _Mark { + "child": _Mark { + "child": null, + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "italic", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "italic", + "parent": null, + "type": "mark", + }, + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "italic", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "italic", + "parent": null, + "type": "mark", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "small": { + "config": { + "propSchema": "boolean", + "type": "small", + }, + "implementation": { + "mark": _Mark { + "child": _Mark { + "child": null, + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "addOptions": [Function], + "name": "small", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "small", + "parent": null, + "type": "mark", + }, + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "small", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "small", + "parent": null, + "type": "mark", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "strike": { + "config": { + "propSchema": "boolean", + "type": "strike", + }, + "implementation": { + "mark": _Mark { + "child": _Mark { + "child": null, + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "strike", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "strike", + "parent": null, + "type": "mark", + }, + "config": { + "addCommands": [Function], + "addInputRules": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "addPasteRules": [Function], + "name": "strike", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "strike", + "parent": null, + "type": "mark", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "textColor": { + "config": { + "propSchema": "string", + "type": "textColor", + }, + "implementation": { + "mark": _Mark { + "child": _Mark { + "child": null, + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "addOptions": [Function], + "name": "textColor", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "textColor", + "parent": null, + "type": "mark", + }, + "config": { + "addAttributes": [Function], + "addMarkView": [Function], + "name": "textColor", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "textColor", + "parent": null, + "type": "mark", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, + "underline": { + "config": { + "propSchema": "boolean", + "type": "underline", + }, + "implementation": { + "mark": _Mark { + "child": _Mark { + "child": null, + "config": { + "addCommands": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "name": "underline", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "underline", + "parent": null, + "type": "mark", + }, + "config": { + "addCommands": [Function], + "addKeyboardShortcuts": [Function], + "addOptions": [Function], + "name": "underline", + "parseHTML": [Function], + "renderHTML": [Function], + }, + "name": "underline", + "parent": null, + "type": "mark", + }, + "render": [Function], + "toExternalHTML": [Function], + }, + }, +} \ No newline at end of file diff --git a/tests/src/unit/core/schema/runTests.test.ts b/tests/src/unit/core/schema/runTests.test.ts new file mode 100644 index 0000000000..739ab64771 --- /dev/null +++ b/tests/src/unit/core/schema/runTests.test.ts @@ -0,0 +1,29 @@ +import { describe, expect, it } from "vitest"; + +import { createTestEditor } from "../createTestEditor.js"; +import { testSchema } from "../testSchema.js"; + +// Tests for verifying that exporting blocks to other formats works as expected. +// Used for as many cases as possible to ensure each block or set of blocks is +// correctly converted into different formats. +describe("Schema test", () => { + const getEditor = createTestEditor(testSchema); + + it("Block specs test", async () => { + await expect(getEditor().schema.blockSpecs).toMatchFileSnapshot( + `./__snapshots__/blocks.json`, + ); + }); + + it("Inline content specs test", async () => { + await expect(getEditor().schema.inlineContentSpecs).toMatchFileSnapshot( + `./__snapshots__/inlinecontent.json`, + ); + }); + + it("Style specs test", async () => { + await expect(getEditor().schema.styleSpecs).toMatchFileSnapshot( + `./__snapshots__/styles.json`, + ); + }); +});