diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteImage.html b/packages/core/src/api/clipboard/__snapshots__/external/pasteImage.html deleted file mode 100644 index cab1cac6f1..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/external/pasteImage.html +++ /dev/null @@ -1,153 +0,0 @@ -[ - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph", - "type": "text", - }, - ], - "id": "0", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, - { - "children": [], - "content": undefined, - "id": "4", - "props": { - "backgroundColor": "default", - "caption": "", - "name": "", - "previewWidth": 512, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - { - "children": [], - "content": { - "columnWidths": [ - undefined, - undefined, - ], - "headerCols": undefined, - "headerRows": undefined, - "rows": [ - { - "cells": [ - { - "content": [ - { - "styles": {}, - "text": "Table Cell", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - { - "content": [ - { - "styles": {}, - "text": "Table Cell", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - ], - }, - { - "cells": [ - { - "content": [ - { - "styles": {}, - "text": "Table Cell", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - { - "content": [ - { - "styles": {}, - "text": "Table Cell", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - ], - }, - ], - "type": "tableContent", - }, - "id": "1", - "props": { - "textColor": "default", - }, - "type": "table", - }, - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Custom Paragraph", - "type": "text", - }, - ], - "id": "2", - "props": {}, - "type": "customParagraph", - }, - { - "children": [], - "content": [], - "id": "3", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, -] \ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteTable.html b/packages/core/src/api/clipboard/__snapshots__/external/pasteTable.html deleted file mode 100644 index b2724689d2..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/external/pasteTable.html +++ /dev/null @@ -1,233 +0,0 @@ -[ - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph", - "type": "text", - }, - ], - "id": "0", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, - { - "children": [], - "content": { - "columnWidths": [ - undefined, - undefined, - ], - "headerCols": undefined, - "headerRows": undefined, - "rows": [ - { - "cells": [ - { - "content": [ - { - "styles": {}, - "text": "Cell 1", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - { - "content": [ - { - "styles": {}, - "text": "Cell 2", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - ], - }, - { - "cells": [ - { - "content": [ - { - "styles": {}, - "text": "Cell 3", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - { - "content": [ - { - "styles": {}, - "text": "Cell 4", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - ], - }, - ], - "type": "tableContent", - }, - "id": "4", - "props": { - "textColor": "default", - }, - "type": "table", - }, - { - "children": [], - "content": { - "columnWidths": [ - undefined, - undefined, - ], - "headerCols": undefined, - "headerRows": undefined, - "rows": [ - { - "cells": [ - { - "content": [ - { - "styles": {}, - "text": "Table Cell", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - { - "content": [ - { - "styles": {}, - "text": "Table Cell", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - ], - }, - { - "cells": [ - { - "content": [ - { - "styles": {}, - "text": "Table Cell", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - { - "content": [ - { - "styles": {}, - "text": "Table Cell", - "type": "text", - }, - ], - "props": { - "backgroundColor": "default", - "colspan": 1, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "type": "tableCell", - }, - ], - }, - ], - "type": "tableContent", - }, - "id": "1", - "props": { - "textColor": "default", - }, - "type": "table", - }, - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Custom Paragraph", - "type": "text", - }, - ], - "id": "2", - "props": {}, - "type": "customParagraph", - }, - { - "children": [], - "content": [], - "id": "3", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, -] \ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/basicBlocks.html b/packages/core/src/api/clipboard/__snapshots__/internal/basicBlocks.html deleted file mode 100644 index ca208287e2..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/basicBlocks.html +++ /dev/null @@ -1 +0,0 @@ -

Paragraph

Heading

  1. Numbered List Item

console.log("Hello World");

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Add image

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/basicBlocksWithProps.html b/packages/core/src/api/clipboard/__snapshots__/internal/basicBlocksWithProps.html deleted file mode 100644 index eeaec68e38..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/basicBlocksWithProps.html +++ /dev/null @@ -1 +0,0 @@ -

Paragraph

Heading

  1. Numbered List Item

console.log("Hello World");

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

1280px-Placeholder_view_vector.svg.png
Placeholder

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/childToParent.html b/packages/core/src/api/clipboard/__snapshots__/internal/childToParent.html deleted file mode 100644 index a899fb60fe..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/childToParent.html +++ /dev/null @@ -1 +0,0 @@ -

Heading 1

Nested Paragraph 1

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/childrenToNextParent.html b/packages/core/src/api/clipboard/__snapshots__/internal/childrenToNextParent.html deleted file mode 100644 index 851b8973d6..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/childrenToNextParent.html +++ /dev/null @@ -1 +0,0 @@ -

Nested Paragraph 1

Nested Paragraph 2

Nested Paragraph 3

Heading 2

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/childrenToNextParentsChildren.html b/packages/core/src/api/clipboard/__snapshots__/internal/childrenToNextParentsChildren.html deleted file mode 100644 index ba81a3a20a..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/childrenToNextParentsChildren.html +++ /dev/null @@ -1 +0,0 @@ -

Nested Paragraph 1

Nested Paragraph 2

Nested Paragraph 3

Heading 2

Nested Paragraph 1

Nested Paragraph 2

Nested Paragraph 3

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/image.html b/packages/core/src/api/clipboard/__snapshots__/internal/image.html deleted file mode 100644 index 09248e5920..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/image.html +++ /dev/null @@ -1 +0,0 @@ -BlockNote image

Nested Paragraph

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/multipleChildren.html b/packages/core/src/api/clipboard/__snapshots__/internal/multipleChildren.html deleted file mode 100644 index 8bb03060e1..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/multipleChildren.html +++ /dev/null @@ -1 +0,0 @@ -

Nested Paragraph 1

Nested Paragraph 2

Nested Paragraph 3

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/multipleStyledText.html b/packages/core/src/api/clipboard/__snapshots__/internal/multipleStyledText.html deleted file mode 100644 index a9991463bc..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/multipleStyledText.html +++ /dev/null @@ -1 +0,0 @@ -BoldItalicRegular \ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/nestedImage.html b/packages/core/src/api/clipboard/__snapshots__/internal/nestedImage.html deleted file mode 100644 index 4e181d251c..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/nestedImage.html +++ /dev/null @@ -1 +0,0 @@ -

BoldItalicRegular

BlockNote image

Nested Paragraph

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html b/packages/core/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html deleted file mode 100644 index c5c4d1fc71..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/paragraphInCustomBlock.html +++ /dev/null @@ -1 +0,0 @@ -Paragraph \ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/partialChildToParent.html b/packages/core/src/api/clipboard/__snapshots__/internal/partialChildToParent.html deleted file mode 100644 index f4d82fbae5..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/partialChildToParent.html +++ /dev/null @@ -1 +0,0 @@ -

ding 1

Nested

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/styledText.html b/packages/core/src/api/clipboard/__snapshots__/internal/styledText.html deleted file mode 100644 index 03d564343b..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/styledText.html +++ /dev/null @@ -1 +0,0 @@ -Italic \ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/tableAllCells.html b/packages/core/src/api/clipboard/__snapshots__/internal/tableAllCells.html deleted file mode 100644 index 5a0ce46217..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/tableAllCells.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/tableCell.html b/packages/core/src/api/clipboard/__snapshots__/internal/tableCell.html deleted file mode 100644 index c4cc0e05d3..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/tableCell.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/tableCellText.html b/packages/core/src/api/clipboard/__snapshots__/internal/tableCellText.html deleted file mode 100644 index cd55158ac5..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/tableCellText.html +++ /dev/null @@ -1 +0,0 @@ -Table Cell \ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/tableRow.html b/packages/core/src/api/clipboard/__snapshots__/internal/tableRow.html deleted file mode 100644 index ffa15acbb9..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/tableRow.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/internal/unstyledText.html b/packages/core/src/api/clipboard/__snapshots__/internal/unstyledText.html deleted file mode 100644 index ea9503c08c..0000000000 --- a/packages/core/src/api/clipboard/__snapshots__/internal/unstyledText.html +++ /dev/null @@ -1 +0,0 @@ -Regular \ No newline at end of file diff --git a/packages/core/src/api/clipboard/clipboardExternal.test.ts b/packages/core/src/api/clipboard/clipboardExternal.test.ts deleted file mode 100644 index d34d1d2fed..0000000000 --- a/packages/core/src/api/clipboard/clipboardExternal.test.ts +++ /dev/null @@ -1,157 +0,0 @@ -import { Node } from "prosemirror-model"; -import { Selection, TextSelection } from "prosemirror-state"; -import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest"; - -import { PartialBlock } from "../../blocks/defaultBlocks.js"; -import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js"; -import { initializeESMDependencies } from "../../util/esmDependencies.js"; -import { doPaste } from "../testUtil/paste.js"; -import { schema } from "./testUtil.js"; - -type SelectionTestCase = { - testName: string; - createSelection: (doc: Node) => Selection; -} & ( - | { - html: string; - } - | { - plainText: string; - } -); - -// These tests are meant to test the pasting of external HTML in the editor. -// Each test case has an HTML string to be pasted, and a selection in the editor -// to paste at. -describe("Test external clipboard HTML", () => { - const initialContent: PartialBlock[] = [ - { - type: "paragraph", - content: "Paragraph", - }, - { - type: "table", - content: { - type: "tableContent", - rows: [ - { - cells: ["Table Cell", "Table Cell"], - }, - { - cells: ["Table Cell", "Table Cell"], - }, - ], - }, - }, - { - type: "customParagraph", - content: "Custom Paragraph", - }, - { - type: "paragraph", - }, - ]; - - let editor: BlockNoteEditor; - const div = document.createElement("div"); - - beforeEach(() => { - editor.replaceBlocks(editor.document, initialContent); - }); - - beforeAll(async () => { - (window as any).__TEST_OPTIONS = (window as any).__TEST_OPTIONS || {}; - - editor = BlockNoteEditor.create({ schema }); - editor.mount(div); - - await initializeESMDependencies(); - }); - - afterAll(() => { - editor.mount(undefined); - editor._tiptapEditor.destroy(); - editor = undefined as any; - - delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS; - }); - - // Sets the editor selection to the given start and end positions, then - // pastes the HTML and compares it the document after to a snapshot. - async function testPasteExternalHTML(testCase: SelectionTestCase) { - if (!editor.prosemirrorView) { - throw new Error("Editor view not initialized."); - } - - editor.transact((tr) => tr.setSelection(testCase.createSelection(tr.doc))); - - doPaste( - editor.prosemirrorView, - "plainText" in testCase ? testCase.plainText : "", - "html" in testCase ? testCase.html : "", - "plainText" in testCase, - new ClipboardEvent("paste") - ); - - await expect(editor.document).toMatchFileSnapshot( - `./__snapshots__/external/${testCase.testName}.html` - ); - } - - const testCases: SelectionTestCase[] = [ - { - testName: "pasteEndOfParagraph", - createSelection: (doc) => TextSelection.create(doc, 12), - html: `

Paragraph

`, - }, - { - testName: "pasteEndOfParagraphText", - createSelection: (doc) => TextSelection.create(doc, 12), - plainText: `Paragraph`, - }, - { - testName: "pasteImage", - createSelection: (doc) => TextSelection.create(doc, 12), - html: ``, - }, - { - testName: "pasteTable", - createSelection: (doc) => TextSelection.create(doc, 12), - html: ` - - - - - - - - -
Cell 1Cell 2
Cell 3Cell 4
`, - }, - { - testName: "pasteTableInExistingTable", - createSelection: (doc) => TextSelection.create(doc, 73), - html: ` - - - - - - - - -
Cell 1Cell 2
Cell 3Cell 4
`, - }, - { - testName: "pasteParagraphInCustomBlock", - createSelection: (doc) => TextSelection.create(doc, 80, 96), - html: `

Paragraph

`, - }, - ]; - - for (const testCase of testCases) { - it(`${testCase.testName}`, async () => { - await testPasteExternalHTML(testCase); - }); - } -}); diff --git a/packages/core/src/api/clipboard/clipboardInternal.test.ts b/packages/core/src/api/clipboard/clipboardInternal.test.ts deleted file mode 100644 index 6462cdbc79..0000000000 --- a/packages/core/src/api/clipboard/clipboardInternal.test.ts +++ /dev/null @@ -1,431 +0,0 @@ -import { Node } from "prosemirror-model"; -import { NodeSelection, Selection, TextSelection } from "prosemirror-state"; -import { CellSelection } from "prosemirror-tables"; -import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest"; - -import { PartialBlock } from "../../blocks/defaultBlocks.js"; -import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js"; -import { initializeESMDependencies } from "../../util/esmDependencies.js"; -import { doPaste } from "../testUtil/paste.js"; -import { schema } from "./testUtil.js"; -import { selectedFragmentToHTML } from "./toClipboard/copyExtension.js"; - -type SelectionTestCase = { - testName: string; - createCopySelection: (doc: Node) => Selection; - createPasteSelection?: (doc: Node) => Selection; -}; - -// These tests are meant to test the copying of user selections in the editor. -// The test cases used for the other HTML conversion tests are not suitable here -// as they are represented in the BlockNote API, whereas here we want to test -// ProseMirror/TipTap selections directly. -describe("Test ProseMirror selection clipboard HTML", () => { - const initialContent: PartialBlock[] = [ - { - type: "heading", - props: { - level: 2, - textColor: "red", - }, - content: "Heading 1", - children: [ - { - type: "paragraph", - content: "Nested Paragraph 1", - }, - { - type: "paragraph", - content: "Nested Paragraph 2", - }, - { - type: "paragraph", - content: "Nested Paragraph 3", - }, - ], - }, - { - type: "heading", - props: { - level: 2, - textColor: "red", - }, - content: "Heading 2", - children: [ - { - type: "paragraph", - content: "Nested Paragraph 1", - }, - { - type: "paragraph", - content: "Nested Paragraph 2", - }, - { - type: "paragraph", - content: "Nested Paragraph 3", - }, - ], - }, - { - type: "heading", - props: { - level: 2, - textColor: "red", - }, - content: [ - { - type: "text", - text: "Bold", - styles: { - bold: true, - }, - }, - { - type: "text", - text: "Italic", - styles: { - italic: true, - }, - }, - { - type: "text", - text: "Regular", - styles: {}, - }, - ], - children: [ - { - type: "image", - props: { - url: "https://ralfvanveen.com/wp-content/uploads/2021/06/Placeholder-_-Glossary.svg", - }, - children: [ - { - type: "paragraph", - content: "Nested Paragraph", - }, - ], - }, - ], - }, - { - type: "table", - content: { - type: "tableContent", - rows: [ - { - cells: ["Table Cell", "Table Cell"], - }, - { - cells: ["Table Cell", "Table Cell"], - }, - ], - }, - // Not needed as selections starting in table cells will get snapped to - // the table boundaries. - // children: [ - // { - // type: "table", - // content: { - // type: "tableContent", - // rows: [ - // { - // cells: ["Table Cell", "Table Cell"], - // }, - // { - // cells: ["Table Cell", "Table Cell"], - // }, - // ], - // }, - // }, - // ], - }, - { - type: "paragraph", - content: "Paragraph", - }, - { - type: "customParagraph", - content: "Paragraph", - }, - { - type: "paragraph", - content: "Paragraph", - }, - { - type: "heading", - content: "Heading", - }, - { - type: "numberedListItem", - content: "Numbered List Item", - }, - { - type: "bulletListItem", - content: "Bullet List Item", - }, - { - type: "checkListItem", - content: "Check List Item", - }, - { - type: "codeBlock", - content: 'console.log("Hello World");', - }, - { - type: "table", - content: { - type: "tableContent", - rows: [ - { - cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]], - }, - { - cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]], - }, - { - cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]], - }, - ], - }, - }, - { - type: "image", - }, - { - type: "paragraph", - props: { - textColor: "red", - }, - content: "Paragraph", - }, - { - type: "heading", - props: { - level: 2, - }, - content: "Heading", - }, - { - type: "numberedListItem", - props: { - start: 2, - }, - content: "Numbered List Item", - }, - { - type: "bulletListItem", - props: { - backgroundColor: "red", - }, - content: "Bullet List Item", - }, - { - type: "checkListItem", - props: { - checked: true, - }, - content: "Check List Item", - }, - { - type: "codeBlock", - props: { - language: "typescript", - }, - content: 'console.log("Hello World");', - }, - { - type: "table", - content: { - type: "tableContent", - rows: [ - { - cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]], - }, - { - cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]], - }, - { - cells: [["Table Cell"], ["Table Cell"], ["Table Cell"]], - }, - ], - }, - }, - { - type: "image", - props: { - name: "1280px-Placeholder_view_vector.svg.png", - url: "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Placeholder_view_vector.svg/1280px-Placeholder_view_vector.svg.png", - caption: "Placeholder", - showPreview: true, - previewWidth: 256, - }, - }, - { - type: "paragraph", - }, - ]; - - let editor: BlockNoteEditor; - const div = document.createElement("div"); - - beforeEach(() => { - editor.replaceBlocks(editor.document, initialContent); - }); - - beforeAll(async () => { - (window as any).__TEST_OPTIONS = (window as any).__TEST_OPTIONS || {}; - - editor = BlockNoteEditor.create({ schema }); - editor.mount(div); - - await initializeESMDependencies(); - }); - - afterAll(() => { - editor.mount(undefined); - editor._tiptapEditor.destroy(); - editor = undefined as any; - - delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS; - }); - - // Sets the editor selection to the given start and end positions, then - // exports the selected content to HTML and compares it to a snapshot. - async function testSelection(testCase: SelectionTestCase) { - if (!editor.prosemirrorView) { - throw new Error("Editor view not initialized."); - } - - editor.transact((tr) => - tr.setSelection(testCase.createCopySelection(tr.doc)) - ); - - const { clipboardHTML, externalHTML } = selectedFragmentToHTML( - editor.prosemirrorView, - editor - ); - - await expect(externalHTML).toMatchFileSnapshot( - `./__snapshots__/internal/${testCase.testName}.html` - ); - - if (testCase.createPasteSelection) { - editor.transact((tr) => - tr.setSelection(testCase.createPasteSelection!(tr.doc)) - ); - } - - const originalDocument = editor.document; - doPaste( - editor.prosemirrorView, - "text", - clipboardHTML, - false, - new ClipboardEvent("paste") - ); - const newDocument = editor.document; - - expect(newDocument).toStrictEqual(originalDocument); - } - - const testCases: SelectionTestCase[] = [ - // TODO: Consider adding test cases for nested blocks & double nested blocks. - // Copy/paste all of first heading's children. - { - testName: "multipleChildren", - createCopySelection: (doc) => TextSelection.create(doc, 16, 78), - }, - // Copy/paste from start of first heading to end of its first child. - { - testName: "childToParent", - createCopySelection: (doc) => TextSelection.create(doc, 3, 34), - }, - // Copy/paste from middle of first heading to the middle of its first child. - { - testName: "partialChildToParent", - createCopySelection: (doc) => TextSelection.create(doc, 6, 23), - }, - // Copy/paste from start of first heading's first child to end of second - // heading's content (does not include second heading's children). - { - testName: "childrenToNextParent", - createCopySelection: (doc) => TextSelection.create(doc, 16, 93), - }, - // Copy/paste from start of first heading's first child to end of second - // heading's last child. - { - testName: "childrenToNextParentsChildren", - createCopySelection: (doc) => TextSelection.create(doc, 16, 159), - }, - // Copy/paste "Regular" text inside third heading. - { - testName: "unstyledText", - createCopySelection: (doc) => TextSelection.create(doc, 175, 182), - }, - // Copy/paste "Italic" text inside third heading. - { - testName: "styledText", - createCopySelection: (doc) => TextSelection.create(doc, 169, 175), - }, - // Copy/paste third heading's content (does not include third heading's - // children). - { - testName: "multipleStyledText", - createCopySelection: (doc) => TextSelection.create(doc, 165, 182), - }, - // Copy/paste the image block content. - { - testName: "image", - createCopySelection: (doc) => NodeSelection.create(doc, 185), - }, - // Copy/paste from start of third heading to end of it's last descendant. - { - testName: "nestedImage", - createCopySelection: (doc) => TextSelection.create(doc, 165, 205), - }, - // Copy/paste text in first cell of the table. - { - testName: "tableCellText", - createCopySelection: (doc) => TextSelection.create(doc, 216, 226), - }, - // Copy/paste first cell of the table. - // TODO: External HTML is wrapped in unnecessary `tr` element. - { - testName: "tableCell", - createCopySelection: (doc) => CellSelection.create(doc, 214), - }, - // Copy/paste first row of the table. - { - testName: "tableRow", - createCopySelection: (doc) => CellSelection.create(doc, 214, 228), - }, - // Copy/paste all cells of the table. - { - testName: "tableAllCells", - createCopySelection: (doc) => CellSelection.create(doc, 214, 258), - }, - // Copy regular paragraph content and paste over custom block content. - { - testName: "paragraphInCustomBlock", - createCopySelection: (doc) => TextSelection.create(doc, 277, 286), - createPasteSelection: (doc) => TextSelection.create(doc, 290, 299), - }, - // Copy/paste basic blocks. - { - testName: "basicBlocks", - createCopySelection: (doc) => TextSelection.create(doc, 303, 558), - }, - // Copy/paste basic blocks with props. - { - testName: "basicBlocksWithProps", - createCopySelection: (doc) => TextSelection.create(doc, 558, 813), - }, - ]; - - for (const testCase of testCases) { - it(`${testCase.testName}`, async () => { - await testSelection(testCase); - }); - } -}); diff --git a/packages/core/src/api/clipboard/testUtil.ts b/packages/core/src/api/clipboard/testUtil.ts deleted file mode 100644 index 33bcf8305b..0000000000 --- a/packages/core/src/api/clipboard/testUtil.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { createBlockSpec } from "../../schema/index.js"; -import { BlockNoteSchema } from "../../editor/BlockNoteSchema.js"; -import { defaultBlockSpecs } from "../../blocks/defaultBlocks.js"; - -const CustomParagraph = createBlockSpec( - { - type: "customParagraph", - content: "inline", - propSchema: {}, - }, - { - render: () => { - const customParagraph = document.createElement("p"); - - return { - dom: customParagraph, - contentDOM: customParagraph, - }; - }, - } -); -export const schema = BlockNoteSchema.create({ - blockSpecs: { - ...defaultBlockSpecs, - customParagraph: CustomParagraph as any, - }, -}); diff --git a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/contains-newlines/external.html b/packages/core/src/api/exporters/html/__snapshots__/codeBlock/contains-newlines/external.html deleted file mode 100644 index 8de18f9605..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/contains-newlines/external.html +++ /dev/null @@ -1 +0,0 @@ -
const hello = 'world';
console.log(hello);
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/contains-newlines/internal.html b/packages/core/src/api/exporters/html/__snapshots__/codeBlock/contains-newlines/internal.html deleted file mode 100644 index d8a93830eb..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/contains-newlines/internal.html +++ /dev/null @@ -1,3 +0,0 @@ -
const hello = 'world';
-console.log(hello);
-
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/external.html b/packages/core/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/external.html deleted file mode 100644 index 8db77070b5..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/external.html +++ /dev/null @@ -1 +0,0 @@ -
console.log('Hello, world!');
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/internal.html b/packages/core/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/internal.html deleted file mode 100644 index ef3a373f9a..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/defaultLanguage/internal.html +++ /dev/null @@ -1 +0,0 @@ -
console.log('Hello, world!');
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/empty/external.html b/packages/core/src/api/exporters/html/__snapshots__/codeBlock/empty/external.html deleted file mode 100644 index 22baaf1757..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/empty/external.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/empty/internal.html b/packages/core/src/api/exporters/html/__snapshots__/codeBlock/empty/internal.html deleted file mode 100644 index abe6b97dc8..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/empty/internal.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/python/external.html b/packages/core/src/api/exporters/html/__snapshots__/codeBlock/python/external.html deleted file mode 100644 index 4872e5904f..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/python/external.html +++ /dev/null @@ -1 +0,0 @@ -
print('Hello, world!')
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/python/internal.html b/packages/core/src/api/exporters/html/__snapshots__/codeBlock/python/internal.html deleted file mode 100644 index fee165d05a..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/codeBlock/python/internal.html +++ /dev/null @@ -1 +0,0 @@ -
print('Hello, world!')
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/complex/misc/external.html b/packages/core/src/api/exporters/html/__snapshots__/complex/misc/external.html deleted file mode 100644 index eee2368524..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/complex/misc/external.html +++ /dev/null @@ -1 +0,0 @@ -

Heading 2

Paragraph

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/complex/misc/internal.html b/packages/core/src/api/exporters/html/__snapshots__/complex/misc/internal.html deleted file mode 100644 index efec8f89d3..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/complex/misc/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Heading 2

Paragraph

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/customBlock/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/customBlock/basic/external.html deleted file mode 100644 index 2e4d2094e3..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/customBlock/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -
Custom customBlock
Custom customBlock
with
line breaks
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/customBlock/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/customBlock/basic/internal.html deleted file mode 100644 index 382b54c065..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/customBlock/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -
Custom customBlock
Custom customBlock
with
line breaks
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/customParagraph/basic/external.html deleted file mode 100644 index 1930c65a95..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

Hello World

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/customParagraph/basic/internal.html deleted file mode 100644 index 46cfe14e45..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Custom Paragraph

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/lineBreaks/external.html b/packages/core/src/api/exporters/html/__snapshots__/customParagraph/lineBreaks/external.html deleted file mode 100644 index 1930c65a95..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/lineBreaks/external.html +++ /dev/null @@ -1 +0,0 @@ -

Hello World

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/lineBreaks/internal.html b/packages/core/src/api/exporters/html/__snapshots__/customParagraph/lineBreaks/internal.html deleted file mode 100644 index a004965707..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/lineBreaks/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Line 1
Line 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/nested/external.html b/packages/core/src/api/exporters/html/__snapshots__/customParagraph/nested/external.html deleted file mode 100644 index d1017bf473..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -

Hello World

Hello World

Hello World

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/nested/internal.html b/packages/core/src/api/exporters/html/__snapshots__/customParagraph/nested/internal.html deleted file mode 100644 index 7688d5c7c0..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Custom Paragraph

Nested Custom Paragraph 1

Nested Custom Paragraph 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/styled/external.html b/packages/core/src/api/exporters/html/__snapshots__/customParagraph/styled/external.html deleted file mode 100644 index d56197b21a..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/styled/external.html +++ /dev/null @@ -1 +0,0 @@ -

Hello World

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/styled/internal.html b/packages/core/src/api/exporters/html/__snapshots__/customParagraph/styled/internal.html deleted file mode 100644 index aec9bca191..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/customParagraph/styled/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Plain Red Text Blue Background Mixed Colors

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/file/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/file/basic/external.html deleted file mode 100644 index 2fef8bae04..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/file/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/file/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/file/basic/internal.html deleted file mode 100644 index a219d1be53..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/file/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/file/button/internal.html b/packages/core/src/api/exporters/html/__snapshots__/file/button/internal.html deleted file mode 100644 index 8b639920d1..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/file/button/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Add file

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/file/nested/external.html b/packages/core/src/api/exporters/html/__snapshots__/file/nested/external.html deleted file mode 100644 index 76ff9df2a3..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/file/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/file/nested/internal.html b/packages/core/src/api/exporters/html/__snapshots__/file/nested/internal.html deleted file mode 100644 index 72208b450c..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/file/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -

example

Caption

example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/file/noCaption/internal.html b/packages/core/src/api/exporters/html/__snapshots__/file/noCaption/internal.html deleted file mode 100644 index 490e9fead0..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/file/noCaption/internal.html +++ /dev/null @@ -1 +0,0 @@ -

example

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/file/noName/external.html b/packages/core/src/api/exporters/html/__snapshots__/file/noName/external.html deleted file mode 100644 index b29226235b..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/file/noName/external.html +++ /dev/null @@ -1 +0,0 @@ -
exampleURL

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/file/noName/internal.html b/packages/core/src/api/exporters/html/__snapshots__/file/noName/internal.html deleted file mode 100644 index c16f385f31..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/file/noName/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/fontSize/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/fontSize/basic/external.html deleted file mode 100644 index f6e857fdfe..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/fontSize/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

This is text with a custom fontSize

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/fontSize/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/fontSize/basic/internal.html deleted file mode 100644 index 717b1ad7d4..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/fontSize/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

This is text with a custom fontSize

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/basic/external.html deleted file mode 100644 index e64f4a3a23..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

Text1
Text2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/basic/internal.html deleted file mode 100644 index a88858f652..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Text1
Text2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/between-links/external.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/between-links/external.html deleted file mode 100644 index ccc63111c8..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/between-links/external.html +++ /dev/null @@ -1 +0,0 @@ -

Link1
Link2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/between-links/internal.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/between-links/internal.html deleted file mode 100644 index f710f08741..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/between-links/internal.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/end/external.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/end/external.html deleted file mode 100644 index dac217f275..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/end/external.html +++ /dev/null @@ -1 +0,0 @@ -

Text1

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/end/internal.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/end/internal.html deleted file mode 100644 index d441ef69af..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/end/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Text1

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/link/external.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/link/external.html deleted file mode 100644 index 5e3a2e2cc4..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/link/external.html +++ /dev/null @@ -1 +0,0 @@ -

Link1
Link1

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/link/internal.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/link/internal.html deleted file mode 100644 index eb0b99808d..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/link/internal.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/multiple/external.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/multiple/external.html deleted file mode 100644 index 89dd31150d..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/multiple/external.html +++ /dev/null @@ -1 +0,0 @@ -

Text1
Text2
Text3

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/multiple/internal.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/multiple/internal.html deleted file mode 100644 index 5ae6ac8b30..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/multiple/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Text1
Text2
Text3

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/only/external.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/only/external.html deleted file mode 100644 index 1d98fbbf16..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/only/external.html +++ /dev/null @@ -1 +0,0 @@ -


\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/only/internal.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/only/internal.html deleted file mode 100644 index c78443c0ac..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/only/internal.html +++ /dev/null @@ -1 +0,0 @@ -


\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/start/external.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/start/external.html deleted file mode 100644 index 3504d3778d..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/start/external.html +++ /dev/null @@ -1 +0,0 @@ -


Text1

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/start/internal.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/start/internal.html deleted file mode 100644 index 436596e499..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/start/internal.html +++ /dev/null @@ -1 +0,0 @@ -


Text1

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/styles/external.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/styles/external.html deleted file mode 100644 index e2e96c2cfe..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/styles/external.html +++ /dev/null @@ -1 +0,0 @@ -

Text1
Text2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/styles/internal.html b/packages/core/src/api/exporters/html/__snapshots__/hardbreak/styles/internal.html deleted file mode 100644 index f08d9c579f..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/hardbreak/styles/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Text1
Text2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/image/basic/external.html deleted file mode 100644 index 9295cf8f38..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -
example
Caption
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/image/basic/internal.html deleted file mode 100644 index 4861c132e7..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/button/internal.html b/packages/core/src/api/exporters/html/__snapshots__/image/button/internal.html deleted file mode 100644 index 1af0abaabd..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/button/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Add image

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/nested/external.html b/packages/core/src/api/exporters/html/__snapshots__/image/nested/external.html deleted file mode 100644 index 9c87fef63d..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -
Caption
Caption
Caption
Caption
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/nested/internal.html b/packages/core/src/api/exporters/html/__snapshots__/image/nested/internal.html deleted file mode 100644 index 41ce95a083..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -
Caption

Caption

Caption

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/noCaption/external.html b/packages/core/src/api/exporters/html/__snapshots__/image/noCaption/external.html deleted file mode 100644 index 22408bfc12..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/noCaption/external.html +++ /dev/null @@ -1 +0,0 @@ -example \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/noCaption/internal.html b/packages/core/src/api/exporters/html/__snapshots__/image/noCaption/internal.html deleted file mode 100644 index 416651286a..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/noCaption/internal.html +++ /dev/null @@ -1 +0,0 @@ -
example
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/noName/external.html b/packages/core/src/api/exporters/html/__snapshots__/image/noName/external.html deleted file mode 100644 index df180bf54e..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/noName/external.html +++ /dev/null @@ -1 +0,0 @@ -
Caption
Caption
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/noName/internal.html b/packages/core/src/api/exporters/html/__snapshots__/image/noName/internal.html deleted file mode 100644 index 4ca54f0aea..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/noName/internal.html +++ /dev/null @@ -1 +0,0 @@ -
Caption

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/noPreview/external.html b/packages/core/src/api/exporters/html/__snapshots__/image/noPreview/external.html deleted file mode 100644 index 591a3abb43..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/noPreview/external.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/noPreview/internal.html b/packages/core/src/api/exporters/html/__snapshots__/image/noPreview/internal.html deleted file mode 100644 index a91118a162..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/image/noPreview/internal.html +++ /dev/null @@ -1 +0,0 @@ -

example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/link/adjacent/external.html b/packages/core/src/api/exporters/html/__snapshots__/link/adjacent/external.html deleted file mode 100644 index 849c727028..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/link/adjacent/external.html +++ /dev/null @@ -1 +0,0 @@ -

WebsiteWebsite2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/link/adjacent/internal.html b/packages/core/src/api/exporters/html/__snapshots__/link/adjacent/internal.html deleted file mode 100644 index e11c631cac..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/link/adjacent/internal.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/link/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/link/basic/external.html deleted file mode 100644 index 3873eaa8ba..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/link/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

Website

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/link/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/link/basic/internal.html deleted file mode 100644 index 5d7d50c2bc..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/link/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/link/styled/external.html b/packages/core/src/api/exporters/html/__snapshots__/link/styled/external.html deleted file mode 100644 index 3304968a98..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/link/styled/external.html +++ /dev/null @@ -1 +0,0 @@ -

Website

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/link/styled/internal.html b/packages/core/src/api/exporters/html/__snapshots__/link/styled/internal.html deleted file mode 100644 index 84e54b7e4a..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/link/styled/internal.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/lists/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/lists/basic/external.html deleted file mode 100644 index ed9e33e52a..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/lists/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -
  • Bullet List Item 1

  • Bullet List Item 2

  1. Numbered List Item 1

  2. Numbered List Item 2

  • Check List Item 1

  • Check List Item 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/lists/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/lists/basic/internal.html deleted file mode 100644 index 5c8448a855..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/lists/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Bullet List Item 1

Bullet List Item 2

Numbered List Item 1

Numbered List Item 2

Check List Item 1

Check List Item 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/lists/nested/external.html b/packages/core/src/api/exporters/html/__snapshots__/lists/nested/external.html deleted file mode 100644 index 73877536f1..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/lists/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -
  • Bullet List Item 1

  • Bullet List Item 2

    1. Numbered List Item 1

    2. Numbered List Item 2

      • Check List Item 1

      • Check List Item 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/lists/nested/internal.html b/packages/core/src/api/exporters/html/__snapshots__/lists/nested/internal.html deleted file mode 100644 index 47dc2ccffc..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/lists/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Bullet List Item 1

Bullet List Item 2

Numbered List Item 1

Numbered List Item 2

Check List Item 1

Check List Item 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/mention/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/mention/basic/external.html deleted file mode 100644 index 967b6d2fd7..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/mention/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

I enjoy working with @Matthew

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/mention/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/mention/basic/internal.html deleted file mode 100644 index fa3e3e8414..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/mention/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

I enjoy working with @Matthew

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/pageBreak/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/pageBreak/basic/internal.html deleted file mode 100644 index f4303a5ad1..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/pageBreak/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paragraph/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/paragraph/basic/internal.html deleted file mode 100644 index 7a7fe019c2..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paragraph/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Paragraph

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paragraph/empty/internal.html b/packages/core/src/api/exporters/html/__snapshots__/paragraph/empty/internal.html deleted file mode 100644 index 96547312cd..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paragraph/empty/internal.html +++ /dev/null @@ -1 +0,0 @@ -

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/external.html b/packages/core/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/external.html deleted file mode 100644 index 02b91a8da0..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/external.html +++ /dev/null @@ -1 +0,0 @@ -

Line 1
Line 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/internal.html b/packages/core/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/internal.html deleted file mode 100644 index 4463caa33e..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paragraph/lineBreaks/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Line 1
Line 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paragraph/nested/external.html b/packages/core/src/api/exporters/html/__snapshots__/paragraph/nested/external.html deleted file mode 100644 index 9490db41f4..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paragraph/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -

Paragraph

Nested Paragraph 1

Nested Paragraph 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paragraph/nested/internal.html b/packages/core/src/api/exporters/html/__snapshots__/paragraph/nested/internal.html deleted file mode 100644 index 79557fb3a3..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paragraph/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Paragraph

Nested Paragraph 1

Nested Paragraph 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paragraph/styled/external.html b/packages/core/src/api/exporters/html/__snapshots__/paragraph/styled/external.html deleted file mode 100644 index 402117f50b..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paragraph/styled/external.html +++ /dev/null @@ -1 +0,0 @@ -

Plain Red Text Blue Background Mixed Colors

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paragraph/styled/internal.html b/packages/core/src/api/exporters/html/__snapshots__/paragraph/styled/internal.html deleted file mode 100644 index fa01c74894..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paragraph/styled/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Plain Red Text Blue Background Mixed Colors

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-mixed-nested-lists.json b/packages/core/src/api/exporters/html/__snapshots__/paste/parse-mixed-nested-lists.json deleted file mode 100644 index 1acc524e82..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-mixed-nested-lists.json +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "id": "1", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "2", - "type": "numberedListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Nested Numbered List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "3", - "type": "numberedListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Nested Numbered List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "4", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-nested-lists-with-paragraphs.json b/packages/core/src/api/exporters/html/__snapshots__/paste/parse-nested-lists-with-paragraphs.json deleted file mode 100644 index 6c5bcf5056..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-nested-lists-with-paragraphs.json +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "id": "1", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "2", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Nested Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "3", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Nested Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "4", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-nested-lists.json b/packages/core/src/api/exporters/html/__snapshots__/paste/parse-nested-lists.json deleted file mode 100644 index 6c5bcf5056..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-nested-lists.json +++ /dev/null @@ -1,70 +0,0 @@ -[ - { - "id": "1", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "2", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Nested Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "3", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Nested Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "4", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/external.html deleted file mode 100644 index eff23b23a3..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

Custom Paragraph

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/internal.html deleted file mode 100644 index d8f1f1cf02..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Custom Paragraph

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/external.html deleted file mode 100644 index 7f3f7817a5..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -

Custom Paragraph

Nested Custom Paragraph 1

Nested Custom Paragraph 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/internal.html deleted file mode 100644 index 8dfb4fdd8a..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Custom Paragraph

Nested Custom Paragraph 1

Nested Custom Paragraph 2

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/external.html deleted file mode 100644 index 639e0a20bd..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/external.html +++ /dev/null @@ -1 +0,0 @@ -

Plain Red Text Blue Background Mixed Colors

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/internal.html deleted file mode 100644 index c0922dcb84..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleCustomParagraph/styled/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Plain Red Text Blue Background Mixed Colors

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleFile/basic/external.html deleted file mode 100644 index a7d4b8d146..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -
exampleURL

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleFile/basic/internal.html deleted file mode 100644 index 7f5bec940c..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -
exampleURL

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/button/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleFile/button/external.html deleted file mode 100644 index 26f6f1a3ea..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/button/external.html +++ /dev/null @@ -1 +0,0 @@ -

Add file

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/button/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleFile/button/internal.html deleted file mode 100644 index 3933e1ccf3..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/button/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Add file

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/nested/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleFile/nested/external.html deleted file mode 100644 index e0cffe581c..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -
exampleURL

Caption

exampleURL

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/nested/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleFile/nested/internal.html deleted file mode 100644 index 079d157fe0..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleFile/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -
exampleURL

Caption

exampleURL

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html deleted file mode 100644 index 76bc3d4ceb..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html deleted file mode 100644 index 7e827005d2..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/button/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/button/external.html deleted file mode 100644 index b8f59a9535..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/button/external.html +++ /dev/null @@ -1 +0,0 @@ -

Add image

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/button/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/button/internal.html deleted file mode 100644 index 89600026f7..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/button/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Add image

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html deleted file mode 100644 index 773dd9cb8f..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html deleted file mode 100644 index ffedb462fa..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html deleted file mode 100644 index 2a44ef4fc3..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noCaption/external.html +++ /dev/null @@ -1 +0,0 @@ -
example
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html deleted file mode 100644 index a594242e00..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noCaption/internal.html +++ /dev/null @@ -1 +0,0 @@ -
example
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html deleted file mode 100644 index fb302b1c46..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noName/external.html +++ /dev/null @@ -1 +0,0 @@ -
Caption

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html deleted file mode 100644 index 0afeec0b4f..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noName/internal.html +++ /dev/null @@ -1 +0,0 @@ -
Caption

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html deleted file mode 100644 index e32f659eac..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noPreview/external.html +++ /dev/null @@ -1 +0,0 @@ -

example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html b/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html deleted file mode 100644 index 12568d4971..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/simpleImage/noPreview/internal.html +++ /dev/null @@ -1 +0,0 @@ -

example

Caption

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/small/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/small/basic/external.html deleted file mode 100644 index 8bfcd2ed1d..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/small/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

This is a small text

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/small/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/small/basic/internal.html deleted file mode 100644 index 2c4b0446df..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/small/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

This is a small text

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/allColWidths/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/allColWidths/external.html deleted file mode 100644 index fca2730213..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/allColWidths/external.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/allColWidths/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/allColWidths/internal.html deleted file mode 100644 index 7247411a1e..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/allColWidths/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/basic/external.html deleted file mode 100644 index ce73c75aa8..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/basic/internal.html deleted file mode 100644 index f00383b3d6..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/external.html deleted file mode 100644 index 03ecb174b0..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/external.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/internal.html deleted file mode 100644 index 972eb90512..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/headerCols/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/external.html deleted file mode 100644 index 9306b01089..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/external.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/internal.html deleted file mode 100644 index b07ff89563..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/headerRows/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/external.html deleted file mode 100644 index 4c1d3e7203..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/external.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/internal.html deleted file mode 100644 index 95f848187d..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/headersRows/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/external.html deleted file mode 100644 index 780396996c..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/external.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/internal.html deleted file mode 100644 index 10e00b6852..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/mixedCellColors/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/mixedColWidths/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/mixedColWidths/external.html deleted file mode 100644 index c7018c749b..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/mixedColWidths/external.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/mixedColWidths/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/mixedColWidths/internal.html deleted file mode 100644 index b2b6765da5..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/mixedColWidths/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/external.html b/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/external.html deleted file mode 100644 index 1e0671ec07..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/external.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/internal.html b/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/internal.html deleted file mode 100644 index 49f80e058f..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/table/mixedRowspansAndColspans/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

Table Cell

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/tag/basic/external.html b/packages/core/src/api/exporters/html/__snapshots__/tag/basic/external.html deleted file mode 100644 index d6e63c9cec..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/tag/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

I love #BlockNote

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/tag/basic/internal.html b/packages/core/src/api/exporters/html/__snapshots__/tag/basic/internal.html deleted file mode 100644 index dcb80c2f33..0000000000 --- a/packages/core/src/api/exporters/html/__snapshots__/tag/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

I love #BlockNote

\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/htmlConversion.test.ts b/packages/core/src/api/exporters/html/htmlConversion.test.ts deleted file mode 100644 index efae08cc13..0000000000 --- a/packages/core/src/api/exporters/html/htmlConversion.test.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it } from "vitest"; - -import { PartialBlock } from "../../../blocks/defaultBlocks.js"; -import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js"; -import { - addIdsToBlocks, - partialBlocksToBlocksForTesting, -} from "../../../index.js"; -import { - BlockSchema, - InlineContentSchema, - StyleSchema, -} from "../../../schema/index.js"; -import { initializeESMDependencies } from "../../../util/esmDependencies.js"; -import { customBlocksTestCases } from "../../testUtil/cases/customBlocks.js"; -import { customInlineContentTestCases } from "../../testUtil/cases/customInlineContent.js"; -import { customStylesTestCases } from "../../testUtil/cases/customStyles.js"; -import { defaultSchemaTestCases } from "../../testUtil/cases/defaultSchema.js"; -import { createExternalHTMLExporter } from "./externalHTMLExporter.js"; -import { createInternalHTMLSerializer } from "./internalHTMLSerializer.js"; - -async function convertToHTMLAndCompareSnapshots< - B extends BlockSchema, - I extends InlineContentSchema, - S extends StyleSchema ->( - editor: BlockNoteEditor, - blocks: PartialBlock[], - snapshotDirectory: string, - snapshotName: string -) { - addIdsToBlocks(blocks); - - const serializer = createInternalHTMLSerializer(editor.pmSchema, editor); - const internalHTML = serializer.serializeBlocks(blocks, {}); - const internalHTMLSnapshotPath = - "./__snapshots__/" + - snapshotDirectory + - "/" + - snapshotName + - "/internal.html"; - await expect(internalHTML).toMatchFileSnapshot(internalHTMLSnapshotPath); - - // turn the internalHTML back into blocks, and make sure no data was lost - const fullBlocks = partialBlocksToBlocksForTesting(editor.schema, blocks); - const parsed = await editor.tryParseHTMLToBlocks(internalHTML); - - expect(parsed).toStrictEqual(fullBlocks); - - await initializeESMDependencies(); - // Create the "external" HTML, which is a cleaned up HTML representation, but lossy - const exporter = createExternalHTMLExporter(editor.pmSchema, editor); - const externalHTML = exporter.exportBlocks(blocks, {}); - const externalHTMLSnapshotPath = - "./__snapshots__/" + - snapshotDirectory + - "/" + - snapshotName + - "/external.html"; - await expect(externalHTML).toMatchFileSnapshot(externalHTMLSnapshotPath); -} - -const testCases = [ - defaultSchemaTestCases, - customBlocksTestCases, - customStylesTestCases, - customInlineContentTestCases, -]; - -describe("Test HTML conversion", () => { - for (const testCase of testCases) { - describe("Case: " + testCase.name, () => { - let editor: BlockNoteEditor; - const div = document.createElement("div"); - beforeEach(() => { - editor = testCase.createEditor(); - - // Note that we don't necessarily need to mount a root - // Currently, we do mount to a root so that it reflects the "production" use-case more closely. - - // However, it would be nice to increased converage and share the same set of tests for these cases: - // - does render to a root - // - does not render to a root - // - runs in server (jsdom) environment using server-util - editor.mount(div); - }); - - afterEach(() => { - editor.mount(undefined); - editor._tiptapEditor.destroy(); - editor = undefined as any; - - delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS; - }); - - for (const document of testCase.documents) { - // eslint-disable-next-line no-loop-func - it("Convert " + document.name + " to HTML", async () => { - const nameSplit = document.name.split("/"); - await convertToHTMLAndCompareSnapshots( - editor, - document.blocks, - nameSplit[0], - nameSplit[1] - ); - }); - } - }); - } -}); diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/customBlock/basic/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/customBlock/basic/markdown.md deleted file mode 100644 index a757429e4f..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/customBlock/basic/markdown.md +++ /dev/null @@ -1,5 +0,0 @@ -Custom customBlock - -Custom customBlock\ -with\ -line breaks diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/basic/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/basic/markdown.md deleted file mode 100644 index 557db03de9..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/basic/markdown.md +++ /dev/null @@ -1 +0,0 @@ -Hello World diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/lineBreaks/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/lineBreaks/markdown.md deleted file mode 100644 index 557db03de9..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/lineBreaks/markdown.md +++ /dev/null @@ -1 +0,0 @@ -Hello World diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/nested/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/nested/markdown.md deleted file mode 100644 index f4f110c5fb..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/nested/markdown.md +++ /dev/null @@ -1,5 +0,0 @@ -Hello World - -Hello World - -Hello World diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/styled/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/styled/markdown.md deleted file mode 100644 index 557db03de9..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/customParagraph/styled/markdown.md +++ /dev/null @@ -1 +0,0 @@ -Hello World diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/fontSize/basic/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/fontSize/basic/markdown.md deleted file mode 100644 index a14913bf9b..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/fontSize/basic/markdown.md +++ /dev/null @@ -1 +0,0 @@ -This is text with a custom fontSize diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/image/basic/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/image/basic/markdown.md deleted file mode 100644 index b350ae21e0..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/image/basic/markdown.md +++ /dev/null @@ -1,3 +0,0 @@ -![example](exampleURL) - -Caption diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/image/nested/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/image/nested/markdown.md deleted file mode 100644 index 7a13551364..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/image/nested/markdown.md +++ /dev/null @@ -1,7 +0,0 @@ -![Caption](exampleURL) - -Caption - -![Caption](exampleURL) - -Caption diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/image/noCaption/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/image/noCaption/markdown.md deleted file mode 100644 index 2c05062cd4..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/image/noCaption/markdown.md +++ /dev/null @@ -1 +0,0 @@ -![example](exampleURL) diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/image/noName/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/image/noName/markdown.md deleted file mode 100644 index c6b5864d90..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/image/noName/markdown.md +++ /dev/null @@ -1,3 +0,0 @@ -![Caption](exampleURL) - -Caption diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/mention/basic/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/mention/basic/markdown.md deleted file mode 100644 index b6a2ae25b3..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/mention/basic/markdown.md +++ /dev/null @@ -1 +0,0 @@ -I enjoy working with @Matthew diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/basic/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/basic/markdown.md deleted file mode 100644 index fd50b044f8..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/basic/markdown.md +++ /dev/null @@ -1 +0,0 @@ -Custom Paragraph diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/nested/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/nested/markdown.md deleted file mode 100644 index 147effc747..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/nested/markdown.md +++ /dev/null @@ -1,5 +0,0 @@ -Custom Paragraph - -Nested Custom Paragraph 1 - -Nested Custom Paragraph 2 diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/styled/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/styled/markdown.md deleted file mode 100644 index 4f45e63c5c..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleCustomParagraph/styled/markdown.md +++ /dev/null @@ -1 +0,0 @@ -Plain Red Text Blue Background Mixed Colors diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleFile/basic/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleFile/basic/markdown.md deleted file mode 100644 index 4cca42f87d..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleFile/basic/markdown.md +++ /dev/null @@ -1,3 +0,0 @@ -exampleURL - -Caption diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleFile/button/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleFile/button/markdown.md deleted file mode 100644 index 8d3fa6a207..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleFile/button/markdown.md +++ /dev/null @@ -1 +0,0 @@ -Add file diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleFile/nested/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleFile/nested/markdown.md deleted file mode 100644 index c170d952c5..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleFile/nested/markdown.md +++ /dev/null @@ -1,7 +0,0 @@ -exampleURL - -Caption - -exampleURL - -Caption diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md deleted file mode 100644 index b350ae21e0..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/basic/markdown.md +++ /dev/null @@ -1,3 +0,0 @@ -![example](exampleURL) - -Caption diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/button/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/button/markdown.md deleted file mode 100644 index 02184caf8a..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/button/markdown.md +++ /dev/null @@ -1 +0,0 @@ -Add image diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md deleted file mode 100644 index 27ac3f5776..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/nested/markdown.md +++ /dev/null @@ -1,7 +0,0 @@ -![example](exampleURL) - -Caption - -![example](exampleURL) - -Caption diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md deleted file mode 100644 index 2c05062cd4..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/noCaption/markdown.md +++ /dev/null @@ -1 +0,0 @@ -![example](exampleURL) diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md deleted file mode 100644 index c6b5864d90..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/noName/markdown.md +++ /dev/null @@ -1,3 +0,0 @@ -![Caption](exampleURL) - -Caption diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/noPreview/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/noPreview/markdown.md deleted file mode 100644 index 07b71c0ea6..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/simpleImage/noPreview/markdown.md +++ /dev/null @@ -1,3 +0,0 @@ -example - -Caption diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/small/basic/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/small/basic/markdown.md deleted file mode 100644 index 02738ab95b..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/small/basic/markdown.md +++ /dev/null @@ -1 +0,0 @@ -This is a small text diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/tag/basic/markdown.md b/packages/core/src/api/exporters/markdown/__snapshots__/tag/basic/markdown.md deleted file mode 100644 index 8adc77839a..0000000000 --- a/packages/core/src/api/exporters/markdown/__snapshots__/tag/basic/markdown.md +++ /dev/null @@ -1 +0,0 @@ -I love #BlockNote diff --git a/packages/core/src/api/exporters/markdown/markdownExporter.test.ts b/packages/core/src/api/exporters/markdown/markdownExporter.test.ts deleted file mode 100644 index 3502f6ddbb..0000000000 --- a/packages/core/src/api/exporters/markdown/markdownExporter.test.ts +++ /dev/null @@ -1,86 +0,0 @@ -import fs from "node:fs"; -import path from "node:path"; -import { afterEach, beforeEach, describe, expect, it } from "vitest"; -import { PartialBlock } from "../../../blocks/defaultBlocks.js"; -import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js"; -import { BlockSchema } from "../../../schema/blocks/types.js"; -import { InlineContentSchema } from "../../../schema/inlineContent/types.js"; -import { StyleSchema } from "../../../schema/styles/types.js"; -import { customBlocksTestCases } from "../../testUtil/cases/customBlocks.js"; -import { customInlineContentTestCases } from "../../testUtil/cases/customInlineContent.js"; -import { customStylesTestCases } from "../../testUtil/cases/customStyles.js"; -import { defaultSchemaTestCases } from "../../testUtil/cases/defaultSchema.js"; -import { partialBlocksToBlocksForTesting } from "../../testUtil/partialBlockTestUtil.js"; - -async function convertToMarkdownAndCompareSnapshots< - B extends BlockSchema, - I extends InlineContentSchema, - S extends StyleSchema ->( - editor: BlockNoteEditor, - blocks: PartialBlock[], - snapshotDirectory: string, - snapshotName: string -) { - const fullBlocks = partialBlocksToBlocksForTesting(editor.schema, blocks); - const md = await editor.blocksToMarkdownLossy(fullBlocks); - const snapshotPath = - "./__snapshots__/" + - snapshotDirectory + - "/" + - snapshotName + - "/markdown.md"; - - // vitest empty snapshots are broken on CI. might be fixed on next vitest, use workaround for now - if (!md.length && process.env.CI) { - if ( - fs.readFileSync(path.join(__dirname, snapshotPath), "utf8").length === 0 - ) { - // both are empty, so it's fine - return; - } - } - await expect(md).toMatchFileSnapshot(snapshotPath); -} - -const testCases = [ - defaultSchemaTestCases, - customBlocksTestCases, - customStylesTestCases, - customInlineContentTestCases, -]; - -describe("markdownExporter", () => { - for (const testCase of testCases) { - describe("Case: " + testCase.name, () => { - let editor: BlockNoteEditor; - const div = document.createElement("div"); - - beforeEach(() => { - editor = testCase.createEditor(); - editor.mount(div); - }); - - afterEach(() => { - editor.mount(undefined); - editor._tiptapEditor.destroy(); - editor = undefined as any; - - delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS; - }); - - for (const document of testCase.documents) { - // eslint-disable-next-line no-loop-func - it("Convert " + document.name + " to Markdown", async () => { - const nameSplit = document.name.split("/"); - await convertToMarkdownAndCompareSnapshots( - editor, - document.blocks, - nameSplit[0], - nameSplit[1] - ); - }); - } - }); - } -}); diff --git a/packages/core/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap b/packages/core/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap deleted file mode 100644 index cfc33073f3..0000000000 --- a/packages/core/src/api/nodeConversions/__snapshots__/nodeConversions.test.ts.snap +++ /dev/null @@ -1,3473 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert customParagraph/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Custom Paragraph", - "type": "text", - }, - ], - "type": "customParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert customParagraph/lineBreaks to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Line 1", - "type": "text", - }, - { - "type": "hardBreak", - }, - { - "text": "Line 2", - "type": "text", - }, - ], - "type": "customParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert customParagraph/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Custom Paragraph", - "type": "text", - }, - ], - "type": "customParagraph", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Nested Custom Paragraph 1", - "type": "text", - }, - ], - "type": "customParagraph", - }, - ], - "type": "blockContainer", - }, - { - "attrs": { - "backgroundColor": "default", - "id": "3", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Nested Custom Paragraph 2", - "type": "text", - }, - ], - "type": "customParagraph", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert customParagraph/styled to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "pink", - "id": "1", - "textColor": "orange", - }, - "content": [ - { - "attrs": { - "textAlignment": "center", - }, - "content": [ - { - "text": "Plain ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "red", - }, - "type": "textColor", - }, - ], - "text": "Red Text ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "blue", - }, - "type": "backgroundColor", - }, - ], - "text": "Blue Background ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "red", - }, - "type": "textColor", - }, - { - "attrs": { - "stringValue": "blue", - }, - "type": "backgroundColor", - }, - ], - "text": "Mixed Colors", - "type": "text", - }, - ], - "type": "customParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleCustomParagraph/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Custom Paragraph", - "type": "text", - }, - ], - "type": "simpleCustomParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleCustomParagraph/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Custom Paragraph", - "type": "text", - }, - ], - "type": "simpleCustomParagraph", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Nested Custom Paragraph 1", - "type": "text", - }, - ], - "type": "simpleCustomParagraph", - }, - ], - "type": "blockContainer", - }, - { - "attrs": { - "backgroundColor": "default", - "id": "3", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Nested Custom Paragraph 2", - "type": "text", - }, - ], - "type": "simpleCustomParagraph", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleCustomParagraph/styled to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "pink", - "id": "1", - "textColor": "orange", - }, - "content": [ - { - "attrs": { - "textAlignment": "center", - }, - "content": [ - { - "text": "Plain ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "red", - }, - "type": "textColor", - }, - ], - "text": "Red Text ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "blue", - }, - "type": "backgroundColor", - }, - ], - "text": "Blue Background ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "red", - }, - "type": "textColor", - }, - { - "attrs": { - "stringValue": "blue", - }, - "type": "backgroundColor", - }, - ], - "text": "Mixed Colors", - "type": "text", - }, - ], - "type": "simpleCustomParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "simpleImage", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/button to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "", - "name": "", - "previewWidth": 512, - "showPreview": true, - "textAlignment": "left", - "url": "", - }, - "type": "simpleImage", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "simpleImage", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "simpleImage", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/noCaption to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "", - "name": "example", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "simpleImage", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/noName to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "simpleImage", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom blocks schema > Convert simpleImage/noPreview to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "previewWidth": 256, - "showPreview": false, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "simpleImage", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom inline content schema > Convert mention/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "I enjoy working with ", - "type": "text", - }, - { - "attrs": { - "user": "Matthew", - }, - "type": "mention", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom inline content schema > Convert tag/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "I love ", - "type": "text", - }, - { - "content": [ - { - "text": "BlockNote", - "type": "text", - }, - ], - "type": "tag", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom style schema > Convert fontSize/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "marks": [ - { - "attrs": { - "stringValue": "18px", - }, - "type": "fontSize", - }, - ], - "text": "This is text with a custom fontSize", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: custom style schema > Convert small/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "marks": [ - { - "type": "small", - }, - ], - "text": "This is a small text", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert codeBlock/contains-newlines to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "language": "javascript", - }, - "content": [ - { - "text": "const hello = 'world'; -console.log(hello); -", - "type": "text", - }, - ], - "type": "codeBlock", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert codeBlock/defaultLanguage to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "language": "text", - }, - "content": [ - { - "text": "console.log('Hello, world!');", - "type": "text", - }, - ], - "type": "codeBlock", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert codeBlock/empty to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "language": "text", - }, - "type": "codeBlock", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert codeBlock/python to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "language": "python", - }, - "content": [ - { - "text": "print('Hello, world!')", - "type": "text", - }, - ], - "type": "codeBlock", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert complex/misc to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "blue", - "id": "1", - "textColor": "yellow", - }, - "content": [ - { - "attrs": { - "level": 2, - "textAlignment": "right", - }, - "content": [ - { - "marks": [ - { - "type": "bold", - }, - { - "type": "underline", - }, - ], - "text": "Heading ", - "type": "text", - }, - { - "marks": [ - { - "type": "italic", - }, - { - "type": "strike", - }, - ], - "text": "2", - "type": "text", - }, - ], - "type": "heading", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "red", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Paragraph", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", - }, - { - "attrs": { - "backgroundColor": "default", - "id": "3", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "type": "bulletListItem", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert file/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "url": "exampleURL", - }, - "type": "file", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert file/button to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "", - "name": "", - "url": "", - }, - "type": "file", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert file/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "url": "exampleURL", - }, - "type": "file", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "url": "exampleURL", - }, - "type": "file", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert file/noCaption to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "", - "name": "example", - "url": "exampleURL", - }, - "type": "file", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert file/noName to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "", - "url": "exampleURL", - }, - "type": "file", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert hardbreak/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Text1", - "type": "text", - }, - { - "type": "hardBreak", - }, - { - "text": "Text2", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert hardbreak/between-links to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "marks": [ - { - "attrs": { - "class": null, - "href": "https://www.website.com", - "rel": "noopener noreferrer nofollow", - "target": "_blank", - }, - "type": "link", - }, - ], - "text": "Link1", - "type": "text", - }, - { - "type": "hardBreak", - }, - { - "marks": [ - { - "attrs": { - "class": null, - "href": "https://www.website2.com", - "rel": "noopener noreferrer nofollow", - "target": "_blank", - }, - "type": "link", - }, - ], - "text": "Link2", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert hardbreak/end to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Text1", - "type": "text", - }, - { - "type": "hardBreak", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert hardbreak/link to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "marks": [ - { - "attrs": { - "class": null, - "href": "https://www.website.com", - "rel": "noopener noreferrer nofollow", - "target": "_blank", - }, - "type": "link", - }, - ], - "text": "Link1", - "type": "text", - }, - { - "type": "hardBreak", - }, - { - "marks": [ - { - "attrs": { - "class": null, - "href": "https://www.website.com", - "rel": "noopener noreferrer nofollow", - "target": "_blank", - }, - "type": "link", - }, - ], - "text": "Link1", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert hardbreak/multiple to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Text1", - "type": "text", - }, - { - "type": "hardBreak", - }, - { - "text": "Text2", - "type": "text", - }, - { - "type": "hardBreak", - }, - { - "text": "Text3", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert hardbreak/only to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "type": "hardBreak", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert hardbreak/start to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "type": "hardBreak", - }, - { - "text": "Text1", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert hardbreak/styles to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Text1", - "type": "text", - }, - { - "type": "hardBreak", - }, - { - "marks": [ - { - "type": "bold", - }, - ], - "text": "Text2", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert image/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert image/button to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "", - "name": "", - "previewWidth": 512, - "showPreview": true, - "textAlignment": "left", - "url": "", - }, - "type": "image", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert image/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert image/noCaption to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "", - "name": "example", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert image/noName to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert image/noPreview to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "previewWidth": 256, - "showPreview": false, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert link/adjacent to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "marks": [ - { - "attrs": { - "class": null, - "href": "https://www.website.com", - "rel": "noopener noreferrer nofollow", - "target": "_blank", - }, - "type": "link", - }, - ], - "text": "Website", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "class": null, - "href": "https://www.website2.com", - "rel": "noopener noreferrer nofollow", - "target": "_blank", - }, - "type": "link", - }, - ], - "text": "Website2", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert link/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "marks": [ - { - "attrs": { - "class": null, - "href": "https://www.website.com", - "rel": "noopener noreferrer nofollow", - "target": "_blank", - }, - "type": "link", - }, - ], - "text": "Website", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert link/styled to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "marks": [ - { - "type": "bold", - }, - { - "attrs": { - "class": null, - "href": "https://www.website.com", - "rel": "noopener noreferrer nofollow", - "target": "_blank", - }, - "type": "link", - }, - ], - "text": "Web", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "class": null, - "href": "https://www.website.com", - "rel": "noopener noreferrer nofollow", - "target": "_blank", - }, - "type": "link", - }, - ], - "text": "site", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert lists/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Bullet List Item 1", - "type": "text", - }, - ], - "type": "bulletListItem", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert lists/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Bullet List Item 1", - "type": "text", - }, - ], - "type": "bulletListItem", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert pageBreak/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "type": "pageBreak", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert paragraph/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Paragraph", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert paragraph/empty to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert paragraph/lineBreaks to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Line 1", - "type": "text", - }, - { - "type": "hardBreak", - }, - { - "text": "Line 2", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert paragraph/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Paragraph", - "type": "text", - }, - ], - "type": "paragraph", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Nested Paragraph 1", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", - }, - { - "attrs": { - "backgroundColor": "default", - "id": "3", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Nested Paragraph 2", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert paragraph/styled to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "pink", - "id": "1", - "textColor": "orange", - }, - "content": [ - { - "attrs": { - "textAlignment": "center", - }, - "content": [ - { - "text": "Plain ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "red", - }, - "type": "textColor", - }, - ], - "text": "Red Text ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "blue", - }, - "type": "backgroundColor", - }, - ], - "text": "Blue Background ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "red", - }, - "type": "textColor", - }, - { - "attrs": { - "stringValue": "blue", - }, - "type": "backgroundColor", - }, - ], - "text": "Mixed Colors", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/allColWidths to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 100, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 200, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 100, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 200, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 100, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 200, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - ], - "type": "table", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - ], - "type": "table", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/headerCols to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableHeader", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableHeader", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableHeader", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - ], - "type": "table", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/headerRows to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableHeader", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableHeader", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableHeader", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - ], - "type": "table", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/mixedCellColors to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "content": [ - { - "attrs": { - "backgroundColor": "red", - "colspan": 1, - "colwidth": [ - 100, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "blue", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "blue", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "yellow", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "red", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 100, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 100, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - ], - "type": "table", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/mixedColWidths to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 100, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 100, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 100, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": null, - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - ], - "type": "table", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test BlockNote-Prosemirror conversion > Case: default schema > Convert table/mixedRowspansAndColspans to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "content": [ - { - "attrs": { - "backgroundColor": "red", - "colspan": 2, - "colwidth": [ - 100, - 200, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "blue", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "yellow", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "red", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 100, - ], - "rowspan": 2, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 2, - "colwidth": [ - 200, - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 200, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - { - "attrs": { - "backgroundColor": "default", - "colspan": 1, - "colwidth": [ - 300, - ], - "rowspan": 1, - "textAlignment": "left", - "textColor": "default", - }, - "content": [ - { - "content": [ - { - "text": "Table Cell", - "type": "text", - }, - ], - "type": "tableParagraph", - }, - ], - "type": "tableCell", - }, - ], - "type": "tableRow", - }, - ], - "type": "table", - }, - ], - "type": "blockContainer", -} -`; diff --git a/packages/core/src/api/nodeConversions/nodeConversions.test.ts b/packages/core/src/api/nodeConversions/nodeConversions.test.ts deleted file mode 100644 index 8c8e040deb..0000000000 --- a/packages/core/src/api/nodeConversions/nodeConversions.test.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it } from "vitest"; - -import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js"; - -import { PartialBlock } from "../../blocks/defaultBlocks.js"; -import { customBlocksTestCases } from "../testUtil/cases/customBlocks.js"; -import { customInlineContentTestCases } from "../testUtil/cases/customInlineContent.js"; -import { customStylesTestCases } from "../testUtil/cases/customStyles.js"; -import { defaultSchemaTestCases } from "../testUtil/cases/defaultSchema.js"; -import { - addIdsToBlock, - partialBlockToBlockForTesting, -} from "../testUtil/partialBlockTestUtil.js"; -import { blockToNode } from "./blockToNode.js"; -import { nodeToBlock } from "./nodeToBlock.js"; - -function validateConversion( - block: PartialBlock, - editor: BlockNoteEditor -) { - addIdsToBlock(block); - const node = blockToNode(block, editor.pmSchema); - - expect(node).toMatchSnapshot(); - - const outputBlock = nodeToBlock(node, editor.pmSchema); - - const fullOriginalBlock = partialBlockToBlockForTesting( - editor.schema.blockSchema, - block - ); - - expect(outputBlock).toStrictEqual(fullOriginalBlock); -} - -const testCases = [ - defaultSchemaTestCases, - customStylesTestCases, - customInlineContentTestCases, - customBlocksTestCases, -]; - -describe("Test BlockNote-Prosemirror conversion", () => { - for (const testCase of testCases) { - describe("Case: " + testCase.name, () => { - let editor: BlockNoteEditor; - const div = document.createElement("div"); - - beforeEach(() => { - editor = testCase.createEditor(); - // Note that we don't necessarily need to mount a root - // Currently, we do mount to a root so that it reflects the "production" use-case more closely. - - // However, it would be nice to increased converage and share the same set of tests for these cases: - // - does render to a root - // - does not render to a root - // - runs in server (jsdom) environment using server-util - editor.mount(div); - }); - - afterEach(() => { - editor.mount(undefined); - editor._tiptapEditor.destroy(); - editor = undefined as any; - - delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS; - }); - - for (const document of testCase.documents) { - // eslint-disable-next-line no-loop-func - it("Convert " + document.name + " to/from prosemirror", () => { - // NOTE: only converts first block - validateConversion(document.blocks[0], editor); - }); - } - }); - } -}); diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-2-tables.json b/packages/core/src/api/parsers/html/__snapshots__/parse-2-tables.json deleted file mode 100644 index 7983dc88c2..0000000000 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-2-tables.json +++ /dev/null @@ -1,129 +0,0 @@ -[ - { - "id": "1", - "type": "table", - "props": { - "textColor": "default" - }, - "content": { - "type": "tableContent", - "columnWidths": [ - null - ], - "rows": [ - { - "cells": [ - { - "type": "tableCell", - "content": [ - { - "type": "text", - "text": "Company", - "styles": { - "underline": true - } - } - ], - "props": { - "colspan": 1, - "rowspan": 1, - "backgroundColor": "default", - "textColor": "default", - "textAlignment": "left" - } - } - ] - }, - { - "cells": [ - { - "type": "tableCell", - "content": [ - { - "type": "text", - "text": "Example Company Inc.", - "styles": { - "bold": true - } - }, - { - "type": "text", - "text": "\n \nName: [Company Representative]\nTitle: Chief Executive Officer", - "styles": {} - } - ], - "props": { - "colspan": 1, - "rowspan": 1, - "backgroundColor": "default", - "textColor": "default", - "textAlignment": "left" - } - } - ] - } - ] - }, - "children": [] - }, - { - "id": "2", - "type": "table", - "props": { - "textColor": "default" - }, - "content": { - "type": "tableContent", - "columnWidths": [ - null - ], - "rows": [ - { - "cells": [ - { - "type": "tableCell", - "content": [ - { - "type": "text", - "text": "Advisor", - "styles": { - "underline": true - } - } - ], - "props": { - "colspan": 1, - "rowspan": 1, - "backgroundColor": "default", - "textColor": "default", - "textAlignment": "left" - } - } - ] - }, - { - "cells": [ - { - "type": "tableCell", - "content": [ - { - "type": "text", - "text": "[Advisor Name]", - "styles": {} - } - ], - "props": { - "colspan": 1, - "rowspan": 1, - "backgroundColor": "default", - "textColor": "default", - "textAlignment": "left" - } - } - ] - } - ] - }, - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-codeblocks.json b/packages/core/src/api/parsers/html/__snapshots__/parse-codeblocks.json deleted file mode 100644 index 6387ab020d..0000000000 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-codeblocks.json +++ /dev/null @@ -1,62 +0,0 @@ -[ - { - "id": "1", - "type": "codeBlock", - "props": { - "language": "text" - }, - "content": [ - { - "type": "text", - "text": "console.log(\"Should default to JS\")", - "styles": {} - } - ], - "children": [] - }, - { - "id": "2", - "type": "codeBlock", - "props": { - "language": "typescript" - }, - "content": [ - { - "type": "text", - "text": "console.log(\"Should parse TS from data-language\")", - "styles": {} - } - ], - "children": [] - }, - { - "id": "3", - "type": "codeBlock", - "props": { - "language": "python" - }, - "content": [ - { - "type": "text", - "text": "print(\"Should parse Python from language- class\")", - "styles": {} - } - ], - "children": [] - }, - { - "id": "4", - "type": "codeBlock", - "props": { - "language": "typescript" - }, - "content": [ - { - "type": "text", - "text": "console.log(\"Should prioritize TS from data-language over language- class\")", - "styles": {} - } - ], - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/complex.json b/packages/core/src/api/parsers/markdown/__snapshots__/pasted/complex.json deleted file mode 100644 index e0d619a9e6..0000000000 --- a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/complex.json +++ /dev/null @@ -1,319 +0,0 @@ -[ - { - "id": "19", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "# Heading 1", - "styles": {} - } - ], - "children": [] - }, - { - "id": "20", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "## Heading 2", - "styles": {} - } - ], - "children": [] - }, - { - "id": "21", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "### Heading 3", - "styles": {} - } - ], - "children": [] - }, - { - "id": "22", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Paragraph", - "styles": {} - } - ], - "children": [] - }, - { - "id": "23", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "P**ara***grap*h", - "styles": {} - } - ], - "children": [] - }, - { - "id": "24", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "P*ara*~~grap~~h", - "styles": {} - } - ], - "children": [] - }, - { - "id": "25", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "26", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "27", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": " * Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "28", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": " * Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "29", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": " Paragraph", - "styles": {} - } - ], - "children": [] - }, - { - "id": "30", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": " 1. Numbered List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "31", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": " 2. Numbered List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "32", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": " 3. Numbered List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "33", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": " 1. Numbered List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "34", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": " * Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "35", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": " * Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "36", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "37", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [], - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/issue-226-1.json b/packages/core/src/api/parsers/markdown/__snapshots__/pasted/issue-226-1.json deleted file mode 100644 index 3c17433c13..0000000000 --- a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/issue-226-1.json +++ /dev/null @@ -1,81 +0,0 @@ -[ - { - "id": "5", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "- 📝 item1", - "styles": {} - } - ], - "children": [] - }, - { - "id": "6", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "- ⚙️ item2", - "styles": {} - } - ], - "children": [] - }, - { - "id": "7", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "- 🔗 item3", - "styles": {} - } - ], - "children": [] - }, - { - "id": "8", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "# h1", - "styles": {} - } - ], - "children": [] - }, - { - "id": "9", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [], - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/issue-226-2.json b/packages/core/src/api/parsers/markdown/__snapshots__/pasted/issue-226-2.json deleted file mode 100644 index 3ee19cf3ee..0000000000 --- a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/issue-226-2.json +++ /dev/null @@ -1,165 +0,0 @@ -[ - { - "id": "9", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* a", - "styles": {} - } - ], - "children": [] - }, - { - "id": "10", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* b", - "styles": {} - } - ], - "children": [] - }, - { - "id": "11", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* c", - "styles": {} - } - ], - "children": [] - }, - { - "id": "12", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* d", - "styles": {} - } - ], - "children": [] - }, - { - "id": "13", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "anything", - "styles": {} - } - ], - "children": [] - }, - { - "id": "14", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "[a link](", - "styles": {} - }, - { - "type": "link", - "href": "http://example.com", - "content": [ - { - "type": "text", - "text": "http://example.com", - "styles": {} - } - ] - }, - { - "type": "text", - "text": ")", - "styles": {} - } - ], - "children": [] - }, - { - "id": "15", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* another", - "styles": {} - } - ], - "children": [] - }, - { - "id": "16", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* list", - "styles": {} - } - ], - "children": [] - }, - { - "id": "17", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [], - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/nested.json b/packages/core/src/api/parsers/markdown/__snapshots__/pasted/nested.json deleted file mode 100644 index 84e352628a..0000000000 --- a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/nested.json +++ /dev/null @@ -1,81 +0,0 @@ -[ - { - "id": "5", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "# Heading", - "styles": {} - } - ], - "children": [] - }, - { - "id": "6", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Paragraph", - "styles": {} - } - ], - "children": [] - }, - { - "id": "7", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "8", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": " 1. Numbered List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "9", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [], - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/non-nested.json b/packages/core/src/api/parsers/markdown/__snapshots__/pasted/non-nested.json deleted file mode 100644 index f72ab28fa1..0000000000 --- a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/non-nested.json +++ /dev/null @@ -1,81 +0,0 @@ -[ - { - "id": "5", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "# Heading", - "styles": {} - } - ], - "children": [] - }, - { - "id": "6", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Paragraph", - "styles": {} - } - ], - "children": [] - }, - { - "id": "7", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "* Bullet List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "8", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "1. Numbered List Item", - "styles": {} - } - ], - "children": [] - }, - { - "id": "9", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [], - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/styled.json b/packages/core/src/api/parsers/markdown/__snapshots__/pasted/styled.json deleted file mode 100644 index 43eeaff32d..0000000000 --- a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/styled.json +++ /dev/null @@ -1,61 +0,0 @@ -[ - { - "id": "0", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Bold", - "styles": { - "bold": true - } - }, - { - "type": "text", - "text": " ", - "styles": {} - }, - { - "type": "text", - "text": "Italic", - "styles": { - "italic": true - } - }, - { - "type": "text", - "text": " ", - "styles": {} - }, - { - "type": "text", - "text": "Strikethrough", - "styles": { - "strike": true - } - }, - { - "type": "text", - "text": " ***Multiple***", - "styles": {} - } - ], - "children": [] - }, - { - "id": "2", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [], - "children": [] - } -] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/parseMarkdown.test.ts b/packages/core/src/api/parsers/markdown/parseMarkdown.test.ts deleted file mode 100644 index c8766028e9..0000000000 --- a/packages/core/src/api/parsers/markdown/parseMarkdown.test.ts +++ /dev/null @@ -1,135 +0,0 @@ -import { describe, expect, it } from "vitest"; -import { BlockNoteEditor } from "../../../index.js"; -import { doPaste } from "../../testUtil/paste.js"; - -async function parseMarkdownAndCompareSnapshots( - md: string, - snapshotName: string -) { - const editor = BlockNoteEditor.create(); - const div = document.createElement("div"); - editor.mount(div); - const blocks = await editor.tryParseMarkdownToBlocks(md); - - const snapshotPath = "./__snapshots__/" + snapshotName + ".json"; - await expect(JSON.stringify(blocks, undefined, 2)).toMatchFileSnapshot( - snapshotPath - ); - - if (!editor.prosemirrorView) { - throw new Error("Editor view not initialized."); - } - - doPaste(editor.prosemirrorView, md, null, true, new ClipboardEvent("paste")); - - const pastedSnapshotPath = "./__snapshots__/pasted/" + snapshotName + ".json"; - await expect(JSON.stringify(editor.document, undefined, 2)).toMatchFileSnapshot( - pastedSnapshotPath - ); - - editor.mount(undefined); -} - -describe("Parse Markdown", () => { - it("Convert non-nested Markdown to blocks", async () => { - const markdown = `# Heading - -Paragraph - -* Bullet List Item - -1. Numbered List Item - `; - await parseMarkdownAndCompareSnapshots(markdown, "non-nested"); - }); - - // Failing due to nested block parsing bug. - it("Convert nested Markdown to blocks", async () => { - const markdown = `# Heading - -Paragraph - -* Bullet List Item - - 1. Numbered List Item -`; - await parseMarkdownAndCompareSnapshots(markdown, "nested"); - }); - - it("Convert styled Markdown to blocks", async () => { - const markdown = `**Bold** *Italic* ~~Strikethrough~~ ***Multiple***`; - await parseMarkdownAndCompareSnapshots(markdown, "styled"); - }); - - it("Convert complex Markdown to blocks", async () => { - const markdown = `# Heading 1 - -## Heading 2 - -### Heading 3 - -Paragraph - -P**ara***grap*h - -P*ara*~~grap~~h - -* Bullet List Item - -* Bullet List Item - - * Bullet List Item - - * Bullet List Item - - Paragraph - - 1. Numbered List Item - - 2. Numbered List Item - - 3. Numbered List Item - - 1. Numbered List Item - - * Bullet List Item - - * Bullet List Item - -* Bullet List Item`; - await parseMarkdownAndCompareSnapshots(markdown, "complex"); - }); - - it("whitespace bold", async () => { - const markdown = `hello **beautiful ** world`; - await parseMarkdownAndCompareSnapshots(markdown, "whitespace bold"); - }); -}); - -describe("Issue 226", () => { - it("Case 1", async () => { - const markdown = ` -- 📝 item1 -- ⚙️ item2 -- 🔗 item3 - -# h1 -`; - await parseMarkdownAndCompareSnapshots(markdown, "issue-226-1"); - }); - - it("Case 2", async () => { - const markdown = `* a -* b -* c -* d - -anything - -[a link](http://example.com) - -* another -* list`; - await parseMarkdownAndCompareSnapshots(markdown, "issue-226-2"); - }); -}); diff --git a/packages/core/src/api/testUtil/cases/customBlocks.ts b/packages/core/src/api/testUtil/cases/customBlocks.ts deleted file mode 100644 index 7da9894b38..0000000000 --- a/packages/core/src/api/testUtil/cases/customBlocks.ts +++ /dev/null @@ -1,342 +0,0 @@ -import { EditorTestCases } from "../index.js"; - -import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js"; -import { - imagePropSchema, - imageRender, -} from "../../../blocks/ImageBlockContent/ImageBlockContent.js"; -import { - DefaultInlineContentSchema, - DefaultStyleSchema, - defaultBlockSpecs, -} from "../../../blocks/defaultBlocks.js"; -import { defaultProps } from "../../../blocks/defaultProps.js"; -import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js"; -import { BlockNoteSchema } from "../../../editor/BlockNoteSchema.js"; -import { createBlockSpec } from "../../../schema/index.js"; - -// This is a modified version of the default image block that does not implement -// a `toExternalHTML` function. It's used to test if the custom serializer by -// default serializes custom blocks using their `render` function. -const SimpleImage = createBlockSpec( - { - type: "simpleImage", - propSchema: imagePropSchema, - content: "none", - }, - { - render: (block, editor) => imageRender(block as any, editor as any), - } -); - -const CustomParagraph = createBlockSpec( - { - type: "customParagraph", - propSchema: defaultProps, - content: "inline", - }, - { - render: () => { - const paragraph = document.createElement("p"); - paragraph.className = "custom-paragraph"; - - return { - dom: paragraph, - contentDOM: paragraph, - }; - }, - toExternalHTML: () => { - const paragraph = document.createElement("p"); - paragraph.className = "custom-paragraph"; - paragraph.innerHTML = "Hello World"; - - return { - dom: paragraph, - }; - }, - } -); - -const SimpleCustomParagraph = createBlockSpec( - { - type: "simpleCustomParagraph", - propSchema: defaultProps, - content: "inline", - }, - { - render: () => { - const paragraph = document.createElement("p"); - paragraph.className = "simple-custom-paragraph"; - - return { - dom: paragraph, - contentDOM: paragraph, - }; - }, - } -); - -const schema = BlockNoteSchema.create({ - blockSpecs: { - ...defaultBlockSpecs, - simpleImage: SimpleImage, - customParagraph: CustomParagraph, - simpleCustomParagraph: SimpleCustomParagraph, - }, -}); - -export const customBlocksTestCases: EditorTestCases< - typeof schema.blockSchema, - DefaultInlineContentSchema, - DefaultStyleSchema -> = { - name: "custom blocks schema", - createEditor: () => { - return BlockNoteEditor.create({ - schema, - uploadFile: uploadToTmpFilesDotOrg_DEV_ONLY, - }); - }, - documents: [ - // Because images need to fetch the download URL async, their output HTML is - // initially rendered without a `src` attribute, which is reflected in the - // tests. - { - name: "simpleImage/button", - blocks: [ - { - type: "simpleImage", - }, - ], - }, - { - name: "simpleImage/basic", - blocks: [ - { - type: "simpleImage", - props: { - name: "example", - url: "exampleURL", - caption: "Caption", - previewWidth: 256, - }, - }, - ], - }, - { - name: "simpleImage/noName", - blocks: [ - { - type: "simpleImage", - props: { - url: "exampleURL", - caption: "Caption", - previewWidth: 256, - }, - }, - ], - }, - { - name: "simpleImage/noCaption", - blocks: [ - { - type: "simpleImage", - props: { - name: "example", - url: "exampleURL", - previewWidth: 256, - }, - }, - ], - }, - { - name: "simpleImage/noPreview", - blocks: [ - { - type: "simpleImage", - props: { - name: "example", - url: "exampleURL", - caption: "Caption", - showPreview: false, - previewWidth: 256, - }, - }, - ], - }, - { - name: "simpleImage/nested", - blocks: [ - { - type: "simpleImage", - props: { - name: "example", - url: "exampleURL", - caption: "Caption", - previewWidth: 256, - }, - children: [ - { - type: "simpleImage", - props: { - name: "example", - url: "exampleURL", - caption: "Caption", - previewWidth: 256, - }, - }, - ], - }, - ], - }, - { - name: "customParagraph/basic", - blocks: [ - { - type: "customParagraph", - content: "Custom Paragraph", - }, - ], - }, - { - name: "customParagraph/styled", - blocks: [ - { - type: "customParagraph", - props: { - textAlignment: "center", - textColor: "orange", - backgroundColor: "pink", - }, - content: [ - { - type: "text", - styles: {}, - text: "Plain ", - }, - { - type: "text", - styles: { - textColor: "red", - }, - text: "Red Text ", - }, - { - type: "text", - styles: { - backgroundColor: "blue", - }, - text: "Blue Background ", - }, - { - type: "text", - styles: { - textColor: "red", - backgroundColor: "blue", - }, - text: "Mixed Colors", - }, - ], - }, - ], - }, - { - name: "customParagraph/nested", - blocks: [ - { - type: "customParagraph", - content: "Custom Paragraph", - children: [ - { - type: "customParagraph", - content: "Nested Custom Paragraph 1", - }, - { - type: "customParagraph", - content: "Nested Custom Paragraph 2", - }, - ], - }, - ], - }, - { - name: "customParagraph/lineBreaks", - blocks: [ - { - type: "customParagraph", - content: "Line 1\nLine 2", - }, - ], - }, - { - name: "simpleCustomParagraph/basic", - blocks: [ - { - type: "simpleCustomParagraph", - content: "Custom Paragraph", - }, - ], - }, - { - name: "simpleCustomParagraph/styled", - blocks: [ - { - type: "simpleCustomParagraph", - props: { - textAlignment: "center", - textColor: "orange", - backgroundColor: "pink", - }, - content: [ - { - type: "text", - styles: {}, - text: "Plain ", - }, - { - type: "text", - styles: { - textColor: "red", - }, - text: "Red Text ", - }, - { - type: "text", - styles: { - backgroundColor: "blue", - }, - text: "Blue Background ", - }, - { - type: "text", - styles: { - textColor: "red", - backgroundColor: "blue", - }, - text: "Mixed Colors", - }, - ], - }, - ], - }, - { - name: "simpleCustomParagraph/nested", - blocks: [ - { - type: "simpleCustomParagraph", - content: "Custom Paragraph", - children: [ - { - type: "simpleCustomParagraph", - content: "Nested Custom Paragraph 1", - }, - { - type: "simpleCustomParagraph", - content: "Nested Custom Paragraph 2", - }, - ], - }, - ], - }, - ], -}; diff --git a/packages/core/src/api/testUtil/cases/customInlineContent.ts b/packages/core/src/api/testUtil/cases/customInlineContent.ts deleted file mode 100644 index 106ba91379..0000000000 --- a/packages/core/src/api/testUtil/cases/customInlineContent.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { EditorTestCases } from "../index.js"; - -import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js"; -import { - DefaultBlockSchema, - DefaultStyleSchema, - defaultInlineContentSpecs, -} from "../../../blocks/defaultBlocks.js"; -import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js"; -import { BlockNoteSchema } from "../../../editor/BlockNoteSchema.js"; -import { createInlineContentSpec } from "../../../schema/inlineContent/createSpec.js"; - -const mention = createInlineContentSpec( - { - type: "mention" as const, - propSchema: { - user: { - default: "", - }, - }, - content: "none", - }, - { - render: (ic) => { - const dom = document.createElement("span"); - dom.appendChild(document.createTextNode("@" + ic.props.user)); - - return { - dom, - }; - }, - } -); - -const tag = createInlineContentSpec( - { - type: "tag" as const, - propSchema: {}, - content: "styled", - }, - { - render: () => { - const dom = document.createElement("span"); - dom.textContent = "#"; - - const contentDOM = document.createElement("span"); - dom.appendChild(contentDOM); - - return { - dom, - contentDOM, - }; - }, - } -); - -const schema = BlockNoteSchema.create({ - inlineContentSpecs: { - ...defaultInlineContentSpecs, - mention, - tag, - }, -}); - -export const customInlineContentTestCases: EditorTestCases< - DefaultBlockSchema, - typeof schema.inlineContentSchema, - DefaultStyleSchema -> = { - name: "custom inline content schema", - createEditor: () => { - return BlockNoteEditor.create({ - uploadFile: uploadToTmpFilesDotOrg_DEV_ONLY, - schema, - }); - }, - documents: [ - { - name: "mention/basic", - blocks: [ - { - type: "paragraph", - content: [ - "I enjoy working with ", - { - type: "mention", - props: { - user: "Matthew", - }, - content: undefined, - }, - ], - }, - ], - }, - { - name: "tag/basic", - blocks: [ - { - type: "paragraph", - content: [ - "I love ", - { - type: "tag", - // props: {}, - content: "BlockNote", - }, - ], - }, - ], - }, - ], -}; diff --git a/packages/core/src/api/testUtil/cases/customStyles.ts b/packages/core/src/api/testUtil/cases/customStyles.ts deleted file mode 100644 index 0ee9e01706..0000000000 --- a/packages/core/src/api/testUtil/cases/customStyles.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { EditorTestCases } from "../index.js"; - -import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js"; -import { - DefaultBlockSchema, - DefaultInlineContentSchema, - defaultStyleSpecs, -} from "../../../blocks/defaultBlocks.js"; -import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js"; -import { BlockNoteSchema } from "../../../editor/BlockNoteSchema.js"; -import { createStyleSpec } from "../../../schema/styles/createSpec.js"; - -const small = createStyleSpec( - { - type: "small", - propSchema: "boolean", - }, - { - render: () => { - const dom = document.createElement("small"); - return { - dom, - contentDOM: dom, - }; - }, - } -); - -const fontSize = createStyleSpec( - { - type: "fontSize", - propSchema: "string", - }, - { - render: (value) => { - const dom = document.createElement("span"); - dom.setAttribute("style", "font-size: " + value); - return { - dom, - contentDOM: dom, - }; - }, - } -); - -const schema = BlockNoteSchema.create({ - styleSpecs: { - ...defaultStyleSpecs, - small, - fontSize, - }, -}); - -export const customStylesTestCases: EditorTestCases< - DefaultBlockSchema, - DefaultInlineContentSchema, - typeof schema.styleSchema -> = { - name: "custom style schema", - createEditor: () => { - return BlockNoteEditor.create({ - uploadFile: uploadToTmpFilesDotOrg_DEV_ONLY, - schema, - }); - }, - documents: [ - { - name: "small/basic", - blocks: [ - { - type: "paragraph", - content: [ - { - type: "text", - text: "This is a small text", - styles: { - small: true, - }, - }, - ], - }, - ], - }, - { - name: "fontSize/basic", - blocks: [ - { - type: "paragraph", - content: [ - { - type: "text", - text: "This is text with a custom fontSize", - styles: { - fontSize: "18px", - }, - }, - ], - }, - ], - }, - ], -}; diff --git a/packages/core/src/api/testUtil/index.ts b/packages/core/src/api/testUtil/index.ts deleted file mode 100644 index 3413613f6c..0000000000 --- a/packages/core/src/api/testUtil/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { PartialBlock } from "../../blocks/defaultBlocks.js"; -import { BlockNoteEditor } from "../../editor/BlockNoteEditor.js"; -import { BlockSchema } from "../../schema/blocks/types.js"; -import { InlineContentSchema } from "../../schema/inlineContent/types.js"; -import { StyleSchema } from "../../schema/styles/types.js"; -import { NoInfer } from "../../util/typescript.js"; - -export type EditorTestCases< - B extends BlockSchema, - I extends InlineContentSchema, - S extends StyleSchema -> = { - name: string; - createEditor: () => BlockNoteEditor; - documents: Array<{ - name: string; - blocks: PartialBlock, NoInfer, NoInfer>[]; - }>; -}; diff --git a/packages/core/src/api/testUtil/paste.ts b/packages/core/src/api/testUtil/paste.ts deleted file mode 100644 index a25874313f..0000000000 --- a/packages/core/src/api/testUtil/paste.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Slice } from "@tiptap/pm/model"; -import { EditorView } from "@tiptap/pm/view"; -import * as pmView from "@tiptap/pm/view"; - -function sliceSingleNode(slice: Slice) { - return slice.openStart === 0 && - slice.openEnd === 0 && - slice.content.childCount === 1 - ? slice.content.firstChild - : null; -} - -// This function is a copy of the `doPaste` function from `@tiptap/pm/view`, -// but made to work in a JSDOM environment. To do this, the `tr.scrollIntoView` -// call has been removed. -// https://github.com/ProseMirror/prosemirror-view/blob/17b508f618c944c54776f8ddac45edcb49970796/src/input.ts#L624 -export function doPaste( - view: EditorView, - text: string, - html: string | null, - preferPlain: boolean, - event: ClipboardEvent -) { - const slice = (pmView as any).__parseFromClipboard( - view, - text, - html, - preferPlain, - view.state.selection.$from - ); - if ( - view.someProp("handlePaste", (f) => f(view, event, slice || Slice.empty)) - ) { - return true; - } - if (!slice) { - return false; - } - - const singleNode = sliceSingleNode(slice); - const tr = singleNode - ? view.state.tr.replaceSelectionWith(singleNode, preferPlain) - : view.state.tr.replaceSelection(slice); - view.dispatch(tr.setMeta("paste", true).setMeta("uiEvent", "paste")); - return true; -} diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index d872af5368..be7060c85d 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -3,7 +3,6 @@ export * from "./api/exporters/html/externalHTMLExporter.js"; export * from "./api/exporters/html/internalHTMLSerializer.js"; export * from "./api/getBlockInfoFromPos.js"; export * from "./api/nodeUtil.js"; -export * from "./api/testUtil/index.js"; export * from "./blocks/AudioBlockContent/AudioBlockContent.js"; export * from "./blocks/CodeBlockContent/CodeBlockContent.js"; export * from "./blocks/FileBlockContent/FileBlockContent.js"; @@ -59,10 +58,12 @@ export * from "./util/typescript.js"; export type { CodeBlockOptions } from "./blocks/CodeBlockContent/CodeBlockContent.js"; export { UnreachableCaseError, assertEmpty } from "./util/typescript.js"; -// for testing from react (TODO: move): +// Unit testing +export { selectedFragmentToHTML } from "./api/clipboard/toClipboard/copyExtension.js"; + +// Node conversions export * from "./api/nodeConversions/blockToNode.js"; export * from "./api/nodeConversions/nodeToBlock.js"; -export * from "./api/testUtil/partialBlockTestUtil.js"; export * from "./extensions/UniqueID/UniqueID.js"; // for server-util (TODO: maybe move): diff --git a/packages/react/src/test/__snapshots__/fontSize/basic/external.html b/packages/react/src/test/__snapshots__/fontSize/basic/external.html deleted file mode 100644 index f10ad63bc8..0000000000 --- a/packages/react/src/test/__snapshots__/fontSize/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

This is text with a custom fontSize

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/fontSize/basic/internal.html b/packages/react/src/test/__snapshots__/fontSize/basic/internal.html deleted file mode 100644 index 4b0f00259b..0000000000 --- a/packages/react/src/test/__snapshots__/fontSize/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

This is text with a custom fontSize

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/mention/basic/external.html b/packages/react/src/test/__snapshots__/mention/basic/external.html deleted file mode 100644 index 967b6d2fd7..0000000000 --- a/packages/react/src/test/__snapshots__/mention/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

I enjoy working with @Matthew

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/mention/basic/internal.html b/packages/react/src/test/__snapshots__/mention/basic/internal.html deleted file mode 100644 index b429a68a6f..0000000000 --- a/packages/react/src/test/__snapshots__/mention/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

I enjoy working with @Matthew

diff --git a/packages/react/src/test/__snapshots__/nodeConversion.test.tsx.snap b/packages/react/src/test/__snapshots__/nodeConversion.test.tsx.snap deleted file mode 100644 index a550b082c5..0000000000 --- a/packages/react/src/test/__snapshots__/nodeConversion.test.tsx.snap +++ /dev/null @@ -1,816 +0,0 @@ -// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactContextParagraph/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "React Context Paragraph", - "type": "text", - }, - ], - "type": "reactContextParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactCustomParagraph/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "React Custom Paragraph", - "type": "text", - }, - ], - "type": "reactCustomParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactCustomParagraph/lineBreaks to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Line 1", - "type": "text", - }, - { - "type": "hardBreak", - }, - { - "text": "Line 2", - "type": "text", - }, - ], - "type": "reactCustomParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactCustomParagraph/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "React Custom Paragraph", - "type": "text", - }, - ], - "type": "reactCustomParagraph", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Nested React Custom Paragraph 1", - "type": "text", - }, - ], - "type": "reactCustomParagraph", - }, - ], - "type": "blockContainer", - }, - { - "attrs": { - "backgroundColor": "default", - "id": "3", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Nested React Custom Paragraph 2", - "type": "text", - }, - ], - "type": "reactCustomParagraph", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactCustomParagraph/styled to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "pink", - "id": "1", - "textColor": "orange", - }, - "content": [ - { - "attrs": { - "textAlignment": "center", - }, - "content": [ - { - "text": "Plain ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "red", - }, - "type": "textColor", - }, - ], - "text": "Red Text ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "blue", - }, - "type": "backgroundColor", - }, - ], - "text": "Blue Background ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "red", - }, - "type": "textColor", - }, - { - "attrs": { - "stringValue": "blue", - }, - "type": "backgroundColor", - }, - ], - "text": "Mixed Colors", - "type": "text", - }, - ], - "type": "reactCustomParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactFile/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "url": "exampleURL", - }, - "type": "file", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactFile/button to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "", - "name": "", - "url": "", - }, - "type": "file", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactFile/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "url": "exampleURL", - }, - "type": "file", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "url": "exampleURL", - }, - "type": "file", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactFile/noCaption to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "", - "name": "example", - "url": "exampleURL", - }, - "type": "file", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactFile/noName to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "", - "url": "exampleURL", - }, - "type": "file", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactImage/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactImage/button to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "", - "name": "", - "previewWidth": 512, - "showPreview": true, - "textAlignment": "left", - "url": "", - }, - "type": "image", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactImage/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactImage/noCaption to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "", - "name": "example", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactImage/noName to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "", - "previewWidth": 256, - "showPreview": true, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert reactImage/noPreview to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "caption": "Caption", - "name": "example", - "previewWidth": 256, - "showPreview": false, - "textAlignment": "left", - "url": "exampleURL", - }, - "type": "image", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert simpleReactCustomParagraph/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "React Custom Paragraph", - "type": "text", - }, - ], - "type": "simpleReactCustomParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert simpleReactCustomParagraph/nested to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Custom React Paragraph", - "type": "text", - }, - ], - "type": "simpleReactCustomParagraph", - }, - { - "content": [ - { - "attrs": { - "backgroundColor": "default", - "id": "2", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Nested React Custom Paragraph 1", - "type": "text", - }, - ], - "type": "simpleReactCustomParagraph", - }, - ], - "type": "blockContainer", - }, - { - "attrs": { - "backgroundColor": "default", - "id": "3", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "Nested React Custom Paragraph 2", - "type": "text", - }, - ], - "type": "simpleReactCustomParagraph", - }, - ], - "type": "blockContainer", - }, - ], - "type": "blockGroup", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react block schema > Convert simpleReactCustomParagraph/styled to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "pink", - "id": "1", - "textColor": "orange", - }, - "content": [ - { - "attrs": { - "textAlignment": "center", - }, - "content": [ - { - "text": "Plain ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "red", - }, - "type": "textColor", - }, - ], - "text": "Red Text ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "blue", - }, - "type": "backgroundColor", - }, - ], - "text": "Blue Background ", - "type": "text", - }, - { - "marks": [ - { - "attrs": { - "stringValue": "red", - }, - "type": "textColor", - }, - { - "attrs": { - "stringValue": "blue", - }, - "type": "backgroundColor", - }, - ], - "text": "Mixed Colors", - "type": "text", - }, - ], - "type": "simpleReactCustomParagraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react inline content schema > Convert mention/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "I enjoy working with ", - "type": "text", - }, - { - "attrs": { - "user": "Matthew", - }, - "type": "mention", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react inline content schema > Convert tag/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "text": "I love ", - "type": "text", - }, - { - "content": [ - { - "text": "BlockNote", - "type": "text", - }, - ], - "type": "tag", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react style schema > Convert fontSize/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "marks": [ - { - "attrs": { - "stringValue": "18px", - }, - "type": "fontSize", - }, - ], - "text": "This is text with a custom fontSize", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; - -exports[`Test React BlockNote-Prosemirror conversion > Case: custom react style schema > Convert small/basic to/from prosemirror 1`] = ` -{ - "attrs": { - "backgroundColor": "default", - "id": "1", - "textColor": "default", - }, - "content": [ - { - "attrs": { - "textAlignment": "left", - }, - "content": [ - { - "marks": [ - { - "type": "small", - }, - ], - "text": "This is a small text", - "type": "text", - }, - ], - "type": "paragraph", - }, - ], - "type": "blockContainer", -} -`; diff --git a/packages/react/src/test/__snapshots__/reactContextParagraph/basic/internal.html b/packages/react/src/test/__snapshots__/reactContextParagraph/basic/internal.html deleted file mode 100644 index 91fe557415..0000000000 --- a/packages/react/src/test/__snapshots__/reactContextParagraph/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -
React Context Paragraph
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactCustomParagraph/basic/internal.html b/packages/react/src/test/__snapshots__/reactCustomParagraph/basic/internal.html deleted file mode 100644 index c9e89afa27..0000000000 --- a/packages/react/src/test/__snapshots__/reactCustomParagraph/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

React Custom Paragraph

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactCustomParagraph/lineBreaks/internal.html b/packages/react/src/test/__snapshots__/reactCustomParagraph/lineBreaks/internal.html deleted file mode 100644 index c824a4f200..0000000000 --- a/packages/react/src/test/__snapshots__/reactCustomParagraph/lineBreaks/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Line 1
Line 2

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactCustomParagraph/nested/external.html b/packages/react/src/test/__snapshots__/reactCustomParagraph/nested/external.html deleted file mode 100644 index bc678da1a8..0000000000 --- a/packages/react/src/test/__snapshots__/reactCustomParagraph/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -

Hello World

Hello World

Hello World

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactCustomParagraph/nested/internal.html b/packages/react/src/test/__snapshots__/reactCustomParagraph/nested/internal.html deleted file mode 100644 index a1c64daac7..0000000000 --- a/packages/react/src/test/__snapshots__/reactCustomParagraph/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -

React Custom Paragraph

Nested React Custom Paragraph 1

Nested React Custom Paragraph 2

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactCustomParagraph/styled/external.html b/packages/react/src/test/__snapshots__/reactCustomParagraph/styled/external.html deleted file mode 100644 index bf4097c8e1..0000000000 --- a/packages/react/src/test/__snapshots__/reactCustomParagraph/styled/external.html +++ /dev/null @@ -1 +0,0 @@ -

Hello World

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactCustomParagraph/styled/internal.html b/packages/react/src/test/__snapshots__/reactCustomParagraph/styled/internal.html deleted file mode 100644 index eebeaab1cb..0000000000 --- a/packages/react/src/test/__snapshots__/reactCustomParagraph/styled/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Plain Red Text Blue Background Mixed Colors

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactFile/basic/external.html b/packages/react/src/test/__snapshots__/reactFile/basic/external.html deleted file mode 100644 index 2fef8bae04..0000000000 --- a/packages/react/src/test/__snapshots__/reactFile/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactFile/basic/internal.html b/packages/react/src/test/__snapshots__/reactFile/basic/internal.html deleted file mode 100644 index ea52dffd75..0000000000 --- a/packages/react/src/test/__snapshots__/reactFile/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

example

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactFile/button/internal.html b/packages/react/src/test/__snapshots__/reactFile/button/internal.html deleted file mode 100644 index 907517c5c2..0000000000 --- a/packages/react/src/test/__snapshots__/reactFile/button/internal.html +++ /dev/null @@ -1 +0,0 @@ -
Add file
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactFile/nested/external.html b/packages/react/src/test/__snapshots__/reactFile/nested/external.html deleted file mode 100644 index 76ff9df2a3..0000000000 --- a/packages/react/src/test/__snapshots__/reactFile/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

example

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactFile/nested/internal.html b/packages/react/src/test/__snapshots__/reactFile/nested/internal.html deleted file mode 100644 index c387803036..0000000000 --- a/packages/react/src/test/__snapshots__/reactFile/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -

example

Caption

example

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactFile/noCaption/internal.html b/packages/react/src/test/__snapshots__/reactFile/noCaption/internal.html deleted file mode 100644 index 25dd7ea3ae..0000000000 --- a/packages/react/src/test/__snapshots__/reactFile/noCaption/internal.html +++ /dev/null @@ -1 +0,0 @@ -

example

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactFile/noName/external.html b/packages/react/src/test/__snapshots__/reactFile/noName/external.html deleted file mode 100644 index b29226235b..0000000000 --- a/packages/react/src/test/__snapshots__/reactFile/noName/external.html +++ /dev/null @@ -1 +0,0 @@ -
exampleURL

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactFile/noName/internal.html b/packages/react/src/test/__snapshots__/reactFile/noName/internal.html deleted file mode 100644 index 05f6bbbb63..0000000000 --- a/packages/react/src/test/__snapshots__/reactFile/noName/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/basic/external.html b/packages/react/src/test/__snapshots__/reactImage/basic/external.html deleted file mode 100644 index 9295cf8f38..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -
example
Caption
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/basic/internal.html b/packages/react/src/test/__snapshots__/reactImage/basic/internal.html deleted file mode 100644 index 326340c0c2..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -
Caption

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/button/internal.html b/packages/react/src/test/__snapshots__/reactImage/button/internal.html deleted file mode 100644 index 9b2a2f447f..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/button/internal.html +++ /dev/null @@ -1 +0,0 @@ -
Add image
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/nested/external.html b/packages/react/src/test/__snapshots__/reactImage/nested/external.html deleted file mode 100644 index 18ff318b71..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -
example
Caption
example
Caption
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/nested/internal.html b/packages/react/src/test/__snapshots__/reactImage/nested/internal.html deleted file mode 100644 index 0e44c4e14a..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -
Caption

Caption

Caption

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/noCaption/external.html b/packages/react/src/test/__snapshots__/reactImage/noCaption/external.html deleted file mode 100644 index 22408bfc12..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/noCaption/external.html +++ /dev/null @@ -1 +0,0 @@ -example \ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/noCaption/internal.html b/packages/react/src/test/__snapshots__/reactImage/noCaption/internal.html deleted file mode 100644 index ea8c668159..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/noCaption/internal.html +++ /dev/null @@ -1 +0,0 @@ -
BlockNote image
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/noName/external.html b/packages/react/src/test/__snapshots__/reactImage/noName/external.html deleted file mode 100644 index df180bf54e..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/noName/external.html +++ /dev/null @@ -1 +0,0 @@ -
Caption
Caption
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/noName/internal.html b/packages/react/src/test/__snapshots__/reactImage/noName/internal.html deleted file mode 100644 index e06868f523..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/noName/internal.html +++ /dev/null @@ -1 +0,0 @@ -
Caption

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/noPreview/external.html b/packages/react/src/test/__snapshots__/reactImage/noPreview/external.html deleted file mode 100644 index 591a3abb43..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/noPreview/external.html +++ /dev/null @@ -1 +0,0 @@ -
example

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/noPreview/internal.html b/packages/react/src/test/__snapshots__/reactImage/noPreview/internal.html deleted file mode 100644 index e465f950ad..0000000000 --- a/packages/react/src/test/__snapshots__/reactImage/noPreview/internal.html +++ /dev/null @@ -1 +0,0 @@ -

example

Caption

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/basic/internal.html b/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/basic/internal.html deleted file mode 100644 index 10e606f71a..0000000000 --- a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

React Custom Paragraph

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/nested/external.html b/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/nested/external.html deleted file mode 100644 index a8354335ca..0000000000 --- a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/nested/external.html +++ /dev/null @@ -1 +0,0 @@ -

Custom React Paragraph

Nested React Custom Paragraph 1

Nested React Custom Paragraph 2

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/nested/internal.html b/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/nested/internal.html deleted file mode 100644 index 17437945b5..0000000000 --- a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/nested/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Custom React Paragraph

Nested React Custom Paragraph 1

Nested React Custom Paragraph 2

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/styled/external.html b/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/styled/external.html deleted file mode 100644 index 9312451d94..0000000000 --- a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/styled/external.html +++ /dev/null @@ -1 +0,0 @@ -

Plain Red Text Blue Background Mixed Colors

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/styled/internal.html b/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/styled/internal.html deleted file mode 100644 index 4d9598bcca..0000000000 --- a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/styled/internal.html +++ /dev/null @@ -1 +0,0 @@ -

Plain Red Text Blue Background Mixed Colors

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/small/basic/external.html b/packages/react/src/test/__snapshots__/small/basic/external.html deleted file mode 100644 index 8bfcd2ed1d..0000000000 --- a/packages/react/src/test/__snapshots__/small/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

This is a small text

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/small/basic/internal.html b/packages/react/src/test/__snapshots__/small/basic/internal.html deleted file mode 100644 index 2c4b0446df..0000000000 --- a/packages/react/src/test/__snapshots__/small/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

This is a small text

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/tag/basic/external.html b/packages/react/src/test/__snapshots__/tag/basic/external.html deleted file mode 100644 index d6e63c9cec..0000000000 --- a/packages/react/src/test/__snapshots__/tag/basic/external.html +++ /dev/null @@ -1 +0,0 @@ -

I love #BlockNote

\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/tag/basic/internal.html b/packages/react/src/test/__snapshots__/tag/basic/internal.html deleted file mode 100644 index dcb80c2f33..0000000000 --- a/packages/react/src/test/__snapshots__/tag/basic/internal.html +++ /dev/null @@ -1 +0,0 @@ -

I love #BlockNote

\ No newline at end of file diff --git a/packages/react/src/test/htmlConversion.test.tsx b/packages/react/src/test/htmlConversion.test.tsx deleted file mode 100644 index 2c3c15633d..0000000000 --- a/packages/react/src/test/htmlConversion.test.tsx +++ /dev/null @@ -1,123 +0,0 @@ -// @vitest-environment jsdom - -import { - BlockNoteEditor, - BlockSchema, - InlineContentSchema, - PartialBlock, - StyleSchema, - addIdsToBlocks, - createExternalHTMLExporter, - createInternalHTMLSerializer, - partialBlocksToBlocksForTesting, -} from "@blocknote/core"; - -import { flushSync } from "react-dom"; -import { Root, createRoot } from "react-dom/client"; -import { afterEach, beforeEach, describe, expect, it } from "vitest"; -import { BlockNoteViewRaw } from "../editor/BlockNoteView.js"; -import { - TestContext, - customReactBlockSchemaTestCases, -} from "./testCases/customReactBlocks.js"; -import { customReactInlineContentTestCases } from "./testCases/customReactInlineContent.js"; -import { customReactStylesTestCases } from "./testCases/customReactStyles.js"; - -// TODO: code same from @blocknote/core, maybe create separate test util package -async function convertToHTMLAndCompareSnapshots< - B extends BlockSchema, - I extends InlineContentSchema, - S extends StyleSchema ->( - editor: BlockNoteEditor, - blocks: PartialBlock[], - snapshotDirectory: string, - snapshotName: string -) { - addIdsToBlocks(blocks); - const serializer = createInternalHTMLSerializer(editor.pmSchema, editor); - const internalHTML = serializer.serializeBlocks(blocks, {}); - const internalHTMLSnapshotPath = - "./__snapshots__/" + - snapshotDirectory + - "/" + - snapshotName + - "/internal.html"; - await expect(internalHTML).toMatchFileSnapshot(internalHTMLSnapshotPath); - - // turn the internalHTML back into blocks, and make sure no data was lost - const fullBlocks = partialBlocksToBlocksForTesting(editor.schema, blocks); - const parsed = await editor.tryParseHTMLToBlocks(internalHTML); - - expect(parsed).toStrictEqual(fullBlocks); - - // Create the "external" HTML, which is a cleaned up HTML representation, but lossy - const exporter = createExternalHTMLExporter(editor.pmSchema, editor); - const externalHTML = exporter.exportBlocks(blocks, {}); - const externalHTMLSnapshotPath = - "./__snapshots__/" + - snapshotDirectory + - "/" + - snapshotName + - "/external.html"; - await expect(externalHTML).toMatchFileSnapshot(externalHTMLSnapshotPath); -} - -const testCases = [ - customReactBlockSchemaTestCases, - customReactStylesTestCases, - customReactInlineContentTestCases, -]; - -describe("Test React HTML conversion", () => { - for (const testCase of testCases) { - describe("Case: " + testCase.name, () => { - let editor: BlockNoteEditor; - // Note that we don't necessarily need to mount a root (unless we need a React Context) - // Currently, we do mount to a root so that it reflects the "production" use-case more closely. - - // However, it would be nice to increased converage and share the same set of tests for these cases: - // - does render to a root - // - does not render to a root - // - runs in server (jsdom) environment using server-util - let root: Root; - const div = document.createElement("div"); - - beforeEach(() => { - editor = testCase.createEditor(); - - const el = ( - - - - ); - root = createRoot(div); - flushSync(() => { - // eslint-disable-next-line testing-library/no-render-in-setup - root.render(el); - }); - }); - - afterEach(() => { - root.unmount(); - editor._tiptapEditor.destroy(); - editor = undefined as any; - - delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS; - }); - - for (const document of testCase.documents) { - // eslint-disable-next-line no-loop-func - it("Convert " + document.name + " to HTML", async () => { - const nameSplit = document.name.split("/"); - await convertToHTMLAndCompareSnapshots( - editor, - document.blocks, - nameSplit[0], - nameSplit[1] - ); - }); - } - }); - } -}); diff --git a/packages/react/src/test/nodeConversion.test.tsx b/packages/react/src/test/nodeConversion.test.tsx deleted file mode 100644 index 8b1e3c8bc9..0000000000 --- a/packages/react/src/test/nodeConversion.test.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import { afterEach, beforeEach, describe, expect, it } from "vitest"; - -import { - BlockNoteEditor, - PartialBlock, - UniqueID, - blockToNode, - partialBlockToBlockForTesting, - nodeToBlock, -} from "@blocknote/core"; -import { flushSync } from "react-dom"; -import { Root, createRoot } from "react-dom/client"; -import { BlockNoteViewRaw } from "../editor/BlockNoteView.js"; -import { customReactBlockSchemaTestCases } from "./testCases/customReactBlocks.js"; -import { customReactInlineContentTestCases } from "./testCases/customReactInlineContent.js"; -import { customReactStylesTestCases } from "./testCases/customReactStyles.js"; - -function addIdsToBlock(block: PartialBlock) { - if (!block.id) { - block.id = UniqueID.options.generateID(); - } - for (const child of block.children || []) { - addIdsToBlock(child); - } -} - -function validateConversion( - block: PartialBlock, - editor: BlockNoteEditor -) { - addIdsToBlock(block); - const node = blockToNode(block, editor.pmSchema); - - expect(node).toMatchSnapshot(); - - const outputBlock = nodeToBlock(node, editor.pmSchema); - - const fullOriginalBlock = partialBlockToBlockForTesting( - editor.schema.blockSchema, - block - ); - - expect(outputBlock).toStrictEqual(fullOriginalBlock); -} - -const testCases = [ - customReactBlockSchemaTestCases, - customReactStylesTestCases, - customReactInlineContentTestCases, -]; - -describe("Test React BlockNote-Prosemirror conversion", () => { - for (const testCase of testCases) { - describe("Case: " + testCase.name, () => { - let editor: BlockNoteEditor; - // Note that we don't necessarily need to mount a root (unless we need a React Context) - // Currently, we do mount to a root so that it reflects the "production" use-case more closely. - - // However, it would be nice to increased converage and share the same set of tests for these cases: - // - does render to a root - // - does not render to a root - // - runs in server (jsdom) environment using server-util - let root: Root; - const div = document.createElement("div"); - - beforeEach(() => { - editor = testCase.createEditor(); - - const el = ; - root = createRoot(div); - flushSync(() => { - // eslint-disable-next-line testing-library/no-render-in-setup - root.render(el); - }); - }); - - afterEach(() => { - root.unmount(); - editor._tiptapEditor.destroy(); - editor = undefined as any; - - delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS; - }); - - for (const document of testCase.documents) { - // eslint-disable-next-line no-loop-func - it("Convert " + document.name + " to/from prosemirror", () => { - // NOTE: only converts first block - validateConversion(document.blocks[0], editor); - }); - } - }); - } -}); diff --git a/packages/react/src/test/testCases/customReactInlineContent.tsx b/packages/react/src/test/testCases/customReactInlineContent.tsx deleted file mode 100644 index 17c53d7d76..0000000000 --- a/packages/react/src/test/testCases/customReactInlineContent.tsx +++ /dev/null @@ -1,102 +0,0 @@ -import { - BlockNoteEditor, - BlockNoteSchema, - DefaultBlockSchema, - DefaultStyleSchema, - EditorTestCases, - defaultInlineContentSpecs, - uploadToTmpFilesDotOrg_DEV_ONLY, -} from "@blocknote/core"; -import { createReactInlineContentSpec } from "../../schema/ReactInlineContentSpec.js"; - -const mention = createReactInlineContentSpec( - { - type: "mention", - propSchema: { - user: { - default: "", - }, - }, - content: "none", - }, - { - render: (props) => { - return @{props.inlineContent.props.user}; - }, - } -); - -const tag = createReactInlineContentSpec( - { - type: "tag", - propSchema: {}, - content: "styled", - }, - { - render: (props) => { - return ( - - # - - ); - }, - } -); - -const schema = BlockNoteSchema.create({ - inlineContentSpecs: { - ...defaultInlineContentSpecs, - tag, - mention, - }, -}); - -export const customReactInlineContentTestCases: EditorTestCases< - DefaultBlockSchema, - typeof schema.inlineContentSchema, - DefaultStyleSchema -> = { - name: "custom react inline content schema", - createEditor: () => { - return BlockNoteEditor.create({ - uploadFile: uploadToTmpFilesDotOrg_DEV_ONLY, - schema, - }); - }, - documents: [ - { - name: "mention/basic", - blocks: [ - { - type: "paragraph", - content: [ - "I enjoy working with ", - { - type: "mention", - props: { - user: "Matthew", - }, - content: undefined, - } as const, - ], - }, - ], - }, - { - name: "tag/basic", - blocks: [ - { - type: "paragraph", - content: [ - "I love ", - { - type: "tag", - // props: {}, - content: "BlockNote", - } as const, - ], - }, - ], - }, - ], -}; diff --git a/packages/react/src/test/testCases/customReactStyles.tsx b/packages/react/src/test/testCases/customReactStyles.tsx deleted file mode 100644 index 3b4c717178..0000000000 --- a/packages/react/src/test/testCases/customReactStyles.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import { - BlockNoteEditor, - BlockNoteSchema, - DefaultBlockSchema, - DefaultInlineContentSchema, - EditorTestCases, - defaultStyleSpecs, - uploadToTmpFilesDotOrg_DEV_ONLY, -} from "@blocknote/core"; -import { createReactStyleSpec } from "../../schema/ReactStyleSpec.js"; - -const small = createReactStyleSpec( - { - type: "small", - propSchema: "boolean", - }, - { - render: (props) => { - return ; - }, - } -); - -const fontSize = createReactStyleSpec( - { - type: "fontSize", - propSchema: "string", - }, - { - render: (props) => { - return ( - - ); - }, - } -); - -const schema = BlockNoteSchema.create({ - styleSpecs: { - ...defaultStyleSpecs, - small, - fontSize, - }, -}); - -export const customReactStylesTestCases: EditorTestCases< - DefaultBlockSchema, - DefaultInlineContentSchema, - typeof schema.styleSchema -> = { - name: "custom react style schema", - createEditor: () => { - return BlockNoteEditor.create({ - uploadFile: uploadToTmpFilesDotOrg_DEV_ONLY, - schema, - }); - }, - documents: [ - { - name: "small/basic", - blocks: [ - { - type: "paragraph", - content: [ - { - type: "text", - text: "This is a small text", - styles: { - small: true, - }, - }, - ], - }, - ], - }, - { - name: "fontSize/basic", - blocks: [ - { - type: "paragraph", - content: [ - { - type: "text", - text: "This is text with a custom fontSize", - styles: { - fontSize: "18px", - }, - }, - ], - }, - ], - }, - ], -}; diff --git a/packages/core/src/api/testUtil/partialBlockTestUtil.ts b/packages/xl-multi-column/src/test/conversions/formatConversionTestUtil.ts similarity index 93% rename from packages/core/src/api/testUtil/partialBlockTestUtil.ts rename to packages/xl-multi-column/src/test/conversions/formatConversionTestUtil.ts index 8c6a15f623..a71cdbda08 100644 --- a/packages/core/src/api/testUtil/partialBlockTestUtil.ts +++ b/packages/xl-multi-column/src/test/conversions/formatConversionTestUtil.ts @@ -1,21 +1,20 @@ -import { Block, PartialBlock } from "../../blocks/defaultBlocks.js"; -import { BlockNoteSchema } from "../../editor/BlockNoteSchema.js"; -import UniqueID from "../../extensions/UniqueID/UniqueID.js"; import { + Block, + BlockNoteSchema, BlockSchema, - PartialTableCell, - TableCell, - TableContent, -} from "../../schema/blocks/types.js"; -import { InlineContent, InlineContentSchema, - PartialInlineContent, - StyledText, isPartialLinkInlineContent, isStyledTextInlineContent, -} from "../../schema/inlineContent/types.js"; -import { StyleSchema } from "../../schema/styles/types.js"; + PartialBlock, + PartialInlineContent, + PartialTableCell, + StyledText, + StyleSchema, + TableCell, + TableContent, + UniqueID, +} from "@blocknote/core"; function textShorthandToStyledText( content: string | StyledText[] = "" diff --git a/packages/xl-multi-column/src/test/conversions/htmlConversion.test.ts b/packages/xl-multi-column/src/test/conversions/htmlConversion.test.ts index dcb75d2c35..a72bd83a24 100644 --- a/packages/xl-multi-column/src/test/conversions/htmlConversion.test.ts +++ b/packages/xl-multi-column/src/test/conversions/htmlConversion.test.ts @@ -6,13 +6,15 @@ import { InlineContentSchema, PartialBlock, StyleSchema, - addIdsToBlocks, createExternalHTMLExporter, createInternalHTMLSerializer, - partialBlocksToBlocksForTesting, } from "@blocknote/core"; import { afterEach, beforeEach, describe, expect, it } from "vitest"; +import { + addIdsToBlocks, + partialBlocksToBlocksForTesting, +} from "./formatConversionTestUtil.js"; import { multiColumnSchemaTestCases } from "./testCases.js"; // TODO: code same from @blocknote/core, maybe create separate test util package diff --git a/packages/xl-multi-column/src/test/conversions/nodeConversion.test.ts b/packages/xl-multi-column/src/test/conversions/nodeConversion.test.ts index aa1a77b000..80e4da3d0b 100644 --- a/packages/xl-multi-column/src/test/conversions/nodeConversion.test.ts +++ b/packages/xl-multi-column/src/test/conversions/nodeConversion.test.ts @@ -6,9 +6,9 @@ import { UniqueID, blockToNode, nodeToBlock, - partialBlockToBlockForTesting, } from "@blocknote/core"; +import { partialBlockToBlockForTesting } from "./formatConversionTestUtil.js"; import { multiColumnSchemaTestCases } from "./testCases.js"; function addIdsToBlock(block: PartialBlock) { diff --git a/packages/xl-multi-column/src/test/conversions/testCases.ts b/packages/xl-multi-column/src/test/conversions/testCases.ts index fd3ba6dbeb..376cf02b43 100644 --- a/packages/xl-multi-column/src/test/conversions/testCases.ts +++ b/packages/xl-multi-column/src/test/conversions/testCases.ts @@ -1,12 +1,9 @@ -import { BlockNoteEditor, EditorTestCases } from "@blocknote/core"; +import { BlockNoteEditor } from "@blocknote/core"; import { testEditorSchema } from "../setupTestEnv.js"; -export const multiColumnSchemaTestCases: EditorTestCases< - typeof testEditorSchema.blockSchema, - typeof testEditorSchema.inlineContentSchema, - typeof testEditorSchema.styleSchema -> = { +// TODO +export const multiColumnSchemaTestCases: any = { name: "multi-column-schema", createEditor: () => { return BlockNoteEditor.create({ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 99ff26a4c6..994808d834 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3307,7 +3307,7 @@ importers: version: 2.1.1 lucide-react: specifier: ^0 - version: 0.484.0(react@18.3.1) + version: 0.362.0(react@18.3.1) postcss: specifier: ^8.4.38 version: 8.5.3 @@ -3819,6 +3819,9 @@ importers: '@playwright/test': specifier: 1.51.1 version: 1.51.1 + '@tiptap/pm': + specifier: ^2.11.5 + version: 2.11.5 '@types/node': specifier: ^20.11.18 version: 20.17.28 @@ -3831,6 +3834,9 @@ importers: eslint: specifier: ^8.10.0 version: 8.57.1 + htmlfy: + specifier: ^0.6.7 + version: 0.6.7 react: specifier: ^18.3.1 version: 18.3.1 @@ -3843,6 +3849,15 @@ importers: rimraf: specifier: ^5.0.5 version: 5.0.10 + vite: + specifier: ^5.3.4 + version: 5.4.15(@types/node@20.17.28)(terser@5.39.0) + vite-plugin-eslint: + specifier: ^1.8.1 + version: 1.8.1(eslint@8.57.1)(vite@5.4.15(@types/node@20.17.28)(terser@5.39.0)) + vitest: + specifier: ^2.0.3 + version: 2.1.9(@types/node@20.17.28)(@vitest/ui@2.1.9)(jsdom@25.0.1(canvas@2.11.2(encoding@0.1.13)))(terser@5.39.0) packages: @@ -9659,6 +9674,9 @@ packages: html-whitespace-sensitive-tag-names@3.0.1: resolution: {integrity: sha512-q+310vW8zmymYHALr1da4HyXUQ0zgiIwIicEfotYPWGN0OJVEN/58IJ3A4GBYcEq3LGAZqKb+ugvP0GNB9CEAA==} + htmlfy@0.6.7: + resolution: {integrity: sha512-r8hRd+oIM10lufovN+zr3VKPTYEIvIwqXGucidh2XQufmiw6sbUXFUFjWlfjo3AnefIDTyzykVzQ8IUVuT1peQ==} + http-proxy-agent@5.0.0: resolution: {integrity: sha512-n2hY8YdoRE1i7r6M0w9DIw5GgZN0G25P8zLCRQ8rjXtTU3vsNFBI/vWK/UIeE6g5MUUz6avwAPXmL6Fy9D/90w==} engines: {node: '>= 6'} @@ -10240,10 +10258,10 @@ packages: lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} - lucide-react@0.484.0: - resolution: {integrity: sha512-oZy8coK9kZzvqhSgfbGkPtTgyjpBvs3ukLgDPv14dSOZtBtboryWF5o8i3qen7QbGg7JhiJBz5mK1p8YoMZTLQ==} + lucide-react@0.362.0: + resolution: {integrity: sha512-0S+JudK0AD9vyB0zbu1K0aQsy8k9Wq2l03bio6wxqF2FhK2TSp/y+22HfMyv40EURifgxoSwdU8eIcOv0a8gBA==} peerDependencies: - react: ^16.5.1 || ^17.0.0 || ^18.0.0 || ^19.0.0 + react: ^16.5.1 || ^17.0.0 || ^18.0.0 lz-string@1.5.0: resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==} @@ -17637,6 +17655,14 @@ snapshots: chai: 5.2.0 tinyrainbow: 1.2.0 + '@vitest/mocker@2.1.9(vite@5.4.15(@types/node@20.17.28)(terser@5.39.0))': + dependencies: + '@vitest/spy': 2.1.9 + estree-walker: 3.0.3 + magic-string: 0.30.17 + optionalDependencies: + vite: 5.4.15(@types/node@20.17.28)(terser@5.39.0) + '@vitest/mocker@2.1.9(vite@5.4.15(@types/node@22.13.13)(terser@5.39.0))': dependencies: '@vitest/spy': 2.1.9 @@ -20030,6 +20056,8 @@ snapshots: html-whitespace-sensitive-tag-names@3.0.1: {} + htmlfy@0.6.7: {} + http-proxy-agent@5.0.0: dependencies: '@tootallnate/once': 2.0.0 @@ -20636,7 +20664,7 @@ snapshots: dependencies: yallist: 3.1.1 - lucide-react@0.484.0(react@18.3.1): + lucide-react@0.362.0(react@18.3.1): dependencies: react: 18.3.1 @@ -23836,6 +23864,24 @@ snapshots: string_decoder: 1.3.0 util-deprecate: 1.0.2 + vite-node@2.1.9(@types/node@20.17.28)(terser@5.39.0): + dependencies: + cac: 6.7.14 + debug: 4.4.0 + es-module-lexer: 1.6.0 + pathe: 1.1.2 + vite: 5.4.15(@types/node@20.17.28)(terser@5.39.0) + transitivePeerDependencies: + - '@types/node' + - less + - lightningcss + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + vite-node@2.1.9(@types/node@22.13.13)(terser@5.39.0): dependencies: cac: 6.7.14 @@ -23907,6 +23953,43 @@ snapshots: transitivePeerDependencies: - supports-color + vitest@2.1.9(@types/node@20.17.28)(@vitest/ui@2.1.9)(jsdom@25.0.1(canvas@2.11.2(encoding@0.1.13)))(terser@5.39.0): + dependencies: + '@vitest/expect': 2.1.9 + '@vitest/mocker': 2.1.9(vite@5.4.15(@types/node@20.17.28)(terser@5.39.0)) + '@vitest/pretty-format': 2.1.9 + '@vitest/runner': 2.1.9 + '@vitest/snapshot': 2.1.9 + '@vitest/spy': 2.1.9 + '@vitest/utils': 2.1.9 + chai: 5.2.0 + debug: 4.4.0 + expect-type: 1.2.0 + magic-string: 0.30.17 + pathe: 1.1.2 + std-env: 3.8.1 + tinybench: 2.9.0 + tinyexec: 0.3.2 + tinypool: 1.0.2 + tinyrainbow: 1.2.0 + vite: 5.4.15(@types/node@20.17.28)(terser@5.39.0) + vite-node: 2.1.9(@types/node@20.17.28)(terser@5.39.0) + why-is-node-running: 2.3.0 + optionalDependencies: + '@types/node': 20.17.28 + '@vitest/ui': 2.1.9(vitest@2.1.9) + jsdom: 25.0.1(canvas@2.11.2(encoding@0.1.13)) + transitivePeerDependencies: + - less + - lightningcss + - msw + - sass + - sass-embedded + - stylus + - sugarss + - supports-color + - terser + vitest@2.1.9(@types/node@22.13.13)(@vitest/ui@2.1.9)(jsdom@21.1.2(canvas@2.11.2(encoding@0.1.13)))(terser@5.39.0): dependencies: '@vitest/expect': 2.1.9 diff --git a/shared/formatConversionTestUtil.ts b/shared/formatConversionTestUtil.ts new file mode 100644 index 0000000000..a71cdbda08 --- /dev/null +++ b/shared/formatConversionTestUtil.ts @@ -0,0 +1,197 @@ +import { + Block, + BlockNoteSchema, + BlockSchema, + InlineContent, + InlineContentSchema, + isPartialLinkInlineContent, + isStyledTextInlineContent, + PartialBlock, + PartialInlineContent, + PartialTableCell, + StyledText, + StyleSchema, + TableCell, + TableContent, + UniqueID, +} from "@blocknote/core"; + +function textShorthandToStyledText( + content: string | StyledText[] = "" +): StyledText[] { + if (typeof content === "string") { + return [ + { + type: "text", + text: content, + styles: {}, + }, + ]; + } + return content; +} + +function partialContentToInlineContent( + content: + | PartialInlineContent + | PartialTableCell + | TableContent + | undefined +): + | InlineContent[] + | TableContent + | TableCell + | undefined { + if (typeof content === "string") { + return textShorthandToStyledText(content); + } + + if (Array.isArray(content)) { + return content.flatMap((partialContent) => { + if (typeof partialContent === "string") { + return textShorthandToStyledText(partialContent); + } else if (isPartialLinkInlineContent(partialContent)) { + return { + ...partialContent, + content: textShorthandToStyledText(partialContent.content), + }; + } else if (isStyledTextInlineContent(partialContent)) { + return partialContent; + } else { + // custom inline content + + return { + props: {}, + ...partialContent, + content: partialContentToInlineContent(partialContent.content), + } as any; + } + }); + } else if (content?.type === "tableContent") { + return { + type: "tableContent", + columnWidths: content.columnWidths, + headerRows: content.headerRows, + headerCols: content.headerCols, + rows: content.rows.map((row) => ({ + ...row, + cells: row.cells.map( + (cell) => partialContentToInlineContent(cell) as any + ), + })), + }; + } else if (content?.type === "tableCell") { + return { + type: "tableCell", + content: partialContentToInlineContent(content.content) as any[], + props: { + backgroundColor: content.props?.backgroundColor ?? "default", + textColor: content.props?.textColor ?? "default", + textAlignment: content.props?.textAlignment ?? "left", + colspan: content.props?.colspan ?? 1, + rowspan: content.props?.rowspan ?? 1, + }, + } satisfies TableCell; + } + + return content; +} + +export function partialBlocksToBlocksForTesting< + BSchema extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + schema: BlockNoteSchema, + partialBlocks: Array, NoInfer, NoInfer>> +): Array> { + return partialBlocks.map((partialBlock) => + partialBlockToBlockForTesting(schema.blockSchema, partialBlock) + ); +} + +export function partialBlockToBlockForTesting< + BSchema extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + schema: BSchema, + partialBlock: PartialBlock +): Block { + const contentType: "inline" | "table" | "none" = + schema[partialBlock.type!].content; + + const withDefaults: Block = { + id: "", + type: partialBlock.type!, + props: {} as any, + content: + contentType === "inline" + ? [] + : contentType === "table" + ? { + type: "tableContent", + columnWidths: undefined, + headerRows: undefined, + headerCols: undefined, + rows: [], + } + : (undefined as any), + children: [] as any, + ...partialBlock, + }; + + Object.entries(schema[partialBlock.type!].propSchema).forEach( + ([propKey, propValue]) => { + if ( + withDefaults.props[propKey] === undefined && + propValue.default !== undefined + ) { + (withDefaults.props as any)[propKey] = propValue.default; + } + } + ); + + if (contentType === "inline") { + const content = withDefaults.content as InlineContent[] | undefined; + withDefaults.content = partialContentToInlineContent(content) as any; + } else if (contentType === "table") { + const content = withDefaults.content as TableContent | undefined; + withDefaults.content = { + type: "tableContent", + columnWidths: + content?.columnWidths || + content?.rows[0]?.cells.map(() => undefined) || + [], + headerRows: content?.headerRows || undefined, + headerCols: content?.headerCols || undefined, + rows: + content?.rows.map((row) => ({ + cells: row.cells.map((cell) => partialContentToInlineContent(cell)), + })) || [], + } as any; + } + + return { + ...withDefaults, + content: partialContentToInlineContent(withDefaults.content), + children: withDefaults.children.map((c) => { + return partialBlockToBlockForTesting(schema, c); + }), + } as any; +} + +export function addIdsToBlock(block: PartialBlock) { + if (!block.id) { + block.id = UniqueID.options.generateID(); + } + if (block.children) { + addIdsToBlocks(block.children); + } +} + +export function addIdsToBlocks(blocks: PartialBlock[]) { + for (const block of blocks) { + addIdsToBlock(block); + } +} diff --git a/shared/testDocument.ts b/shared/testDocument.ts index 1e85eb2870..ebeddf7158 100644 --- a/shared/testDocument.ts +++ b/shared/testDocument.ts @@ -1,10 +1,8 @@ -import { - BlockNoteSchema, - defaultBlockSpecs, - PageBreak, - partialBlocksToBlocksForTesting, -} from "@blocknote/core"; +import { BlockNoteSchema, defaultBlockSpecs, PageBreak } from "@blocknote/core"; +import { partialBlocksToBlocksForTesting } from "./formatConversionTestUtil.js"; + +// TODO: Update tests that use this to the new format and remove export const testDocument = partialBlocksToBlocksForTesting( BlockNoteSchema.create({ blockSpecs: { ...defaultBlockSpecs, pageBreak: PageBreak }, diff --git a/tests/package.json b/tests/package.json index e102ac10fc..741cfd447f 100644 --- a/tests/package.json +++ b/tests/package.json @@ -6,6 +6,7 @@ "build": "tsc", "lint": "eslint src --max-warnings 0", "playwright": "playwright test", + "test": "vitest --run", "test:updateSnaps": "docker run --rm -e RUN_IN_DOCKER=true --network host -v $(pwd)/..:/work/ -w /work/tests -it mcr.microsoft.com/playwright:v1.51.1-noble npx playwright test -u", "test-ct": "playwright test -c playwright-ct.config.ts --headed", "test-ct:updateSnaps": "docker run --rm -e RUN_IN_DOCKER=true --network host -v $(pwd)/..:/work/ -w /work/tests -it mcr.microsoft.com/playwright:v1.51.1-noble npx playwright test -c playwright-ct.config.ts -u", @@ -18,15 +19,20 @@ "@blocknote/mantine": "workspace:*", "@blocknote/react": "workspace:*", "@blocknote/shadcn": "workspace:*", + "@tiptap/pm": "^2.11.5", "@types/react": "^18.0.25", "@types/react-dom": "^18.0.9", "@playwright/experimental-ct-react": "1.51.1", "@playwright/test": "1.51.1", "eslint": "^8.10.0", + "htmlfy": "^0.6.7", "react-icons": "^5.2.1", "rimraf": "^5.0.5", "react": "^18.3.1", - "react-dom": "^18.3.1" + "react-dom": "^18.3.1", + "vite": "^5.3.4", + "vite-plugin-eslint": "^1.8.1", + "vitest": "^2.0.3" }, "eslintConfig": { "extends": [ diff --git a/tests/src/unit/core/clipboard/clipboardTestUtil.ts b/tests/src/unit/core/clipboard/clipboardTestUtil.ts new file mode 100644 index 0000000000..6e5ed1cfd0 --- /dev/null +++ b/tests/src/unit/core/clipboard/clipboardTestUtil.ts @@ -0,0 +1,121 @@ +import { + BlockNoteEditor, + BlockSchema, + InlineContentSchema, + PartialBlock, + StyleSchema, +} from "@blocknote/core"; +import { Node, Slice } from "@tiptap/pm/model"; +import { Selection } from "@tiptap/pm/state"; +import { EditorView } from "@tiptap/pm/view"; +import * as pmView from "@tiptap/pm/view"; + +// Helper function to get the position of a text node with given text content. +// By default, returns the position just before the node, but can be just after +// instead if `after` is set to true. +export const getPosOfTextNode = ( + doc: Node, + textContent: string, + after = false +) => { + let ret: number | undefined = undefined; + + doc.descendants((node, pos) => { + if (node.isText && node.textContent === textContent) { + ret = pos + (after ? node.nodeSize : 0); + return false; + } + + return ret === undefined; + }); + + if (ret === undefined) { + throw new Error(`Text node with content "${textContent}" not found.`); + } + + return ret; +}; + +// Helper function to get the position of a table cell node with given text +// content. Returns the position just before the node. +export const getPosOfTableCellNode = (doc: Node, textContent: string) => { + let ret: number | undefined = undefined; + + doc.descendants((node, pos) => { + if (node.type.name === "tableCell" && node.textContent === textContent) { + ret = pos; + return false; + } + + return ret === undefined; + }); + + if (ret === undefined) { + throw new Error(`Table cell node with content "${textContent}" not found.`); + } + + return ret; +}; + +export const setupClipboardTest = < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + document: PartialBlock[], + getSelection: (pmDoc: Node) => Selection +) => { + if (!editor.prosemirrorView) { + throw new Error("Editor view not initialized."); + } + + (window as any).__TEST_OPTIONS.mockID = 0; + + editor.replaceBlocks(editor.document, document); + + editor.transact((tr) => tr.setSelection(getSelection(tr.doc))); +}; + +function sliceSingleNode(slice: Slice) { + return slice.openStart === 0 && + slice.openEnd === 0 && + slice.content.childCount === 1 + ? slice.content.firstChild + : null; +} + +// This function is a copy of the `doPaste` function from `@tiptap/pm/view`, +// but made to work in a JSDOM environment. To do this, the `tr.scrollIntoView` +// call has been removed. +// https://github.com/ProseMirror/prosemirror-view/blob/17b508f618c944c54776f8ddac45edcb49970796/src/input.ts#L624 +export function doPaste( + view: EditorView, + text: string, + html: string | null, + preferPlain: boolean, + event: ClipboardEvent +) { + const slice = (pmView as any).__parseFromClipboard( + view, + text, + html, + preferPlain, + view.state.selection.$from + ); + if ( + view.someProp("handlePaste", (f) => f(view, event, slice || Slice.empty)) + ) { + return true; + } + if (!slice) { + return false; + } + + const singleNode = sliceSingleNode(slice); + const tr = singleNode + ? view.state.tr.replaceSelectionWith(singleNode, preferPlain) + : view.state.tr.replaceSelection(slice); + view.dispatch(tr.setMeta("paste", true).setMeta("uiEvent", "paste")); + return true; +} diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/basicBlocks.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/basicBlocks.html new file mode 100644 index 0000000000..4b0fff5d10 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/basicBlocks.html @@ -0,0 +1,39 @@ +

Paragraph 1

+

Heading 1

+
    +
  1. +

    Numbered List Item 1

    +
  2. +
+
    +
  • +

    Bullet List Item 1

    +
  • +
  • + +

    Check List Item 1

    +
  • +
+
+  console.log("Hello World");
+
+ + + + + + + + + +
+

Table Cell 1

+
+

Table Cell 2

+
+

Table Cell 3

+
+

Table Cell 4

+
+

Add image

+

Paragraph 2

\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/basicBlocksWithProps.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/basicBlocksWithProps.html new file mode 100644 index 0000000000..aa29f7463c --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/basicBlocksWithProps.html @@ -0,0 +1,51 @@ +

Paragraph 1

+

Heading 1

+
    +
  1. +

    Numbered List Item 1

    +
  2. +
+
    +
  • +

    Bullet List Item 1

    +
  • +
  • + +

    Check List Item 1

    +
  • +
+
+  console.log("Hello World");
+
+ + + + + + + + + +
+

Table Cell 1

+
+

Table Cell 2

+
+

Table Cell 3

+
+

Table Cell 4

+
+
+ 1280px-Placeholder_view_vector.svg.png +
Placeholder
+
+

Paragraph 2

\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/childToParent.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/childToParent.html new file mode 100644 index 0000000000..a39b61fc62 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/childToParent.html @@ -0,0 +1,2 @@ +

Paragraph 1

+

Nested Paragraph 1

\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/childrenToNextParent.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/childrenToNextParent.html new file mode 100644 index 0000000000..5482d90cfa --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/childrenToNextParent.html @@ -0,0 +1,4 @@ +

Nested Paragraph 1

+

Nested Paragraph 2

+

Nested Paragraph 3

+

Paragraph 2

\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/childrenToNextParentsChildren.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/childrenToNextParentsChildren.html new file mode 100644 index 0000000000..5f11c91d10 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/childrenToNextParentsChildren.html @@ -0,0 +1,7 @@ +

Nested Paragraph 1

+

Nested Paragraph 2

+

Nested Paragraph 3

+

Paragraph 2

+

Nested Paragraph 4

+

Nested Paragraph 5

+

Nested Paragraph 6

\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/image.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/image.html new file mode 100644 index 0000000000..3d97d675dd --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/image.html @@ -0,0 +1,6 @@ +BlockNote image \ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/multipleChildren.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/multipleChildren.html new file mode 100644 index 0000000000..bad0f9b365 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/multipleChildren.html @@ -0,0 +1,3 @@ +

Nested Paragraph 1

+

Nested Paragraph 2

+

Nested Paragraph 3

\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/multipleStyledText.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/multipleStyledText.html new file mode 100644 index 0000000000..8f6d4fcb54 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/multipleStyledText.html @@ -0,0 +1,3 @@ +Unstyled Text +Italic Text +Bold Text \ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/nestedImage.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/nestedImage.html new file mode 100644 index 0000000000..7983b6974c --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/nestedImage.html @@ -0,0 +1,8 @@ +

Paragraph 1

+BlockNote image +

Nested Paragraph 1

\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/partialChildToParent.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/partialChildToParent.html new file mode 100644 index 0000000000..3599c4a943 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/partialChildToParent.html @@ -0,0 +1,2 @@ +

aragraph 1

+

N

\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/styledText.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/styledText.html new file mode 100644 index 0000000000..3e4402a48e --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/styledText.html @@ -0,0 +1 @@ +Italic Text \ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableAllCells.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableAllCells.html new file mode 100644 index 0000000000..67be1a7c03 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableAllCells.html @@ -0,0 +1,18 @@ + + + + + + + + + +
+

Table Cell 1

+
+

Table Cell 2

+
+

Table Cell 3

+
+

Table Cell 4

+
\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableCell.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableCell.html new file mode 100644 index 0000000000..8493ba34a0 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableCell.html @@ -0,0 +1,7 @@ + + + + +
+

Table Cell 1

+
\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableCellText.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableCellText.html new file mode 100644 index 0000000000..925f07b3fd --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableCellText.html @@ -0,0 +1 @@ +Table Cell 1 \ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableCol.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableCol.html new file mode 100644 index 0000000000..9b3beaa5ce --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableCol.html @@ -0,0 +1,12 @@ + + + + + + + +
+

Table Cell 1

+
+

Table Cell 3

+
\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableRow.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableRow.html new file mode 100644 index 0000000000..f36b6de978 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/tableRow.html @@ -0,0 +1,10 @@ + + + + + +
+

Table Cell 1

+
+

Table Cell 2

+
\ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/unstyledText.html b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/unstyledText.html new file mode 100644 index 0000000000..6147731f88 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/__snapshots__/text/html/unstyledText.html @@ -0,0 +1 @@ +Unstyled Text \ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copy/copyTestInstances.ts b/tests/src/unit/core/clipboard/copy/copyTestInstances.ts new file mode 100644 index 0000000000..5018f0d552 --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/copyTestInstances.ts @@ -0,0 +1,636 @@ +import { NodeSelection, TextSelection } from "@tiptap/pm/state"; +import { CellSelection } from "@tiptap/pm/tables"; + +import { + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema, +} from "../../testSchema.js"; +import { CopyTestCase } from "../../../shared/clipboard/copy/copyTestCase.js"; +import { testCopyHTML } from "../../../shared/clipboard/copy/copyTestExecutors.js"; +import { TestInstance } from "../../../types.js"; +import { + getPosOfTableCellNode, + getPosOfTextNode, +} from "../clipboardTestUtil.js"; + +export const copyTestInstancesHTML: TestInstance< + CopyTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = [ + { + testCase: { + name: "multipleChildren", + document: [ + { + type: "paragraph", + content: "Paragraph 1", + children: [ + { + type: "paragraph", + content: "Nested Paragraph 1", + }, + { + type: "paragraph", + content: "Nested Paragraph 2", + }, + { + type: "paragraph", + content: "Nested Paragraph 3", + }, + ], + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Nested Paragraph 1"); + const endPos = getPosOfTextNode(doc, "Nested Paragraph 3", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "childToParent", + document: [ + { + type: "paragraph", + content: "Paragraph 1", + children: [ + { + type: "paragraph", + content: "Nested Paragraph 1", + }, + { + type: "paragraph", + content: "Nested Paragraph 2", + }, + { + type: "paragraph", + content: "Nested Paragraph 3", + }, + ], + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1"); + const endPos = getPosOfTextNode(doc, "Nested Paragraph 1", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "partialChildToParent", + document: [ + { + type: "paragraph", + content: "Paragraph 1", + children: [ + { + type: "paragraph", + content: "Nested Paragraph 1", + }, + { + type: "paragraph", + content: "Nested Paragraph 2", + }, + { + type: "paragraph", + content: "Nested Paragraph 3", + }, + ], + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1") + 1; + const endPos = getPosOfTextNode(doc, "Nested Paragraph 1") + 1; + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "childrenToNextParent", + document: [ + { + type: "paragraph", + content: "Paragraph 1", + children: [ + { + type: "paragraph", + content: "Nested Paragraph 1", + }, + { + type: "paragraph", + content: "Nested Paragraph 2", + }, + { + type: "paragraph", + content: "Nested Paragraph 3", + }, + ], + }, + { + type: "paragraph", + content: "Paragraph 2", + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Nested Paragraph 1"); + const endPos = getPosOfTextNode(doc, "Paragraph 2", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "childrenToNextParentsChildren", + document: [ + { + type: "paragraph", + content: "Paragraph 1", + children: [ + { + type: "paragraph", + content: "Nested Paragraph 1", + }, + { + type: "paragraph", + content: "Nested Paragraph 2", + }, + { + type: "paragraph", + content: "Nested Paragraph 3", + }, + ], + }, + { + type: "paragraph", + content: "Paragraph 2", + children: [ + { + type: "paragraph", + content: "Nested Paragraph 4", + }, + { + type: "paragraph", + content: "Nested Paragraph 5", + }, + { + type: "paragraph", + content: "Nested Paragraph 6", + }, + ], + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Nested Paragraph 1"); + const endPos = getPosOfTextNode(doc, "Nested Paragraph 6", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "unstyledText", + document: [ + { + type: "heading", + content: "Unstyled Text", + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Unstyled Text"); + const endPos = getPosOfTextNode(doc, "Unstyled Text", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "styledText", + document: [ + { + type: "paragraph", + content: [ + { + type: "text", + text: "Unstyled Text", + styles: {}, + }, + { + type: "text", + text: "Italic Text", + styles: { + italic: true, + }, + }, + ], + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Italic Text"); + const endPos = getPosOfTextNode(doc, "Italic Text", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "multipleStyledText", + document: [ + { + type: "paragraph", + content: [ + { + type: "text", + text: "Unstyled Text", + styles: {}, + }, + { + type: "text", + text: "Italic Text", + styles: { + italic: true, + }, + }, + { + type: "text", + text: "Bold Text", + styles: { + bold: true, + }, + }, + ], + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Unstyled Text"); + const endPos = getPosOfTextNode(doc, "Bold Text", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "image", + document: [ + { + type: "image", + props: { + url: "https://ralfvanveen.com/wp-content/uploads/2021/06/Placeholder-_-Glossary.svg", + }, + }, + ], + getCopySelection: (doc) => { + let startPos: number | undefined = undefined; + + doc.descendants((node, pos) => { + if (node.type.name === "image") { + startPos = pos; + } + }); + + if (startPos === undefined) { + throw new Error("Image node not found."); + } + + return NodeSelection.create(doc, startPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "nestedImage", + document: [ + { + type: "paragraph", + content: "Paragraph 1", + children: [ + { + type: "image", + props: { + url: "https://ralfvanveen.com/wp-content/uploads/2021/06/Placeholder-_-Glossary.svg", + }, + children: [ + { + type: "paragraph", + content: "Nested Paragraph 1", + }, + ], + }, + ], + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1"); + const endPos = getPosOfTextNode(doc, "Nested Paragraph 1", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "tableCellText", + document: [ + { + type: "table", + content: { + type: "tableContent", + rows: [ + { + cells: [["Table Cell 1"], ["Table Cell 2"]], + }, + { + cells: [["Table Cell 3"], ["Table Cell 4"]], + }, + ], + }, + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Table Cell 1"); + const endPos = getPosOfTextNode(doc, "Table Cell 1", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "tableCell", + document: [ + { + type: "table", + content: { + type: "tableContent", + rows: [ + { + cells: [["Table Cell 1"], ["Table Cell 2"]], + }, + { + cells: [["Table Cell 3"], ["Table Cell 4"]], + }, + ], + }, + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTableCellNode(doc, "Table Cell 1"); + + return CellSelection.create(doc, startPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "tableRow", + document: [ + { + type: "table", + content: { + type: "tableContent", + rows: [ + { + cells: [["Table Cell 1"], ["Table Cell 2"]], + }, + { + cells: [["Table Cell 3"], ["Table Cell 4"]], + }, + ], + }, + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTableCellNode(doc, "Table Cell 1"); + const endPos = getPosOfTableCellNode(doc, "Table Cell 2"); + + return CellSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "tableCol", + document: [ + { + type: "table", + content: { + type: "tableContent", + rows: [ + { + cells: [["Table Cell 1"], ["Table Cell 2"]], + }, + { + cells: [["Table Cell 3"], ["Table Cell 4"]], + }, + ], + }, + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTableCellNode(doc, "Table Cell 1"); + const endPos = getPosOfTableCellNode(doc, "Table Cell 3"); + + return CellSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "tableAllCells", + document: [ + { + type: "table", + content: { + type: "tableContent", + rows: [ + { + cells: [["Table Cell 1"], ["Table Cell 2"]], + }, + { + cells: [["Table Cell 3"], ["Table Cell 4"]], + }, + ], + }, + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTableCellNode(doc, "Table Cell 1"); + const endPos = getPosOfTableCellNode(doc, "Table Cell 4"); + + return CellSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + // TODO: 2 tests below necessary? + { + testCase: { + name: "basicBlocks", + document: [ + { + type: "paragraph", + content: "Paragraph 1", + }, + { + type: "heading", + content: "Heading 1", + }, + { + type: "numberedListItem", + content: "Numbered List Item 1", + }, + { + type: "bulletListItem", + content: "Bullet List Item 1", + }, + { + type: "checkListItem", + content: "Check List Item 1", + }, + { + type: "codeBlock", + content: 'console.log("Hello World");', + }, + { + type: "table", + content: { + type: "tableContent", + rows: [ + { + cells: [["Table Cell 1"], ["Table Cell 2"]], + }, + { + cells: [["Table Cell 3"], ["Table Cell 4"]], + }, + ], + }, + }, + { + type: "image", + }, + { + type: "paragraph", + content: "Paragraph 2", + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1"); + const endPos = getPosOfTextNode(doc, "Paragraph 2", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, + { + testCase: { + name: "basicBlocksWithProps", + document: [ + { + type: "paragraph", + props: { + textColor: "red", + }, + content: "Paragraph 1", + }, + { + type: "heading", + props: { + level: 2, + }, + content: "Heading 1", + }, + { + type: "numberedListItem", + props: { + start: 2, + }, + content: "Numbered List Item 1", + }, + { + type: "bulletListItem", + props: { + backgroundColor: "red", + }, + content: "Bullet List Item 1", + }, + { + type: "checkListItem", + props: { + checked: true, + }, + content: "Check List Item 1", + }, + { + type: "codeBlock", + props: { + language: "typescript", + }, + content: 'console.log("Hello World");', + }, + { + type: "table", + content: { + type: "tableContent", + rows: [ + { + cells: [["Table Cell 1"], ["Table Cell 2"]], + }, + { + cells: [["Table Cell 3"], ["Table Cell 4"]], + }, + ], + }, + }, + { + type: "image", + props: { + name: "1280px-Placeholder_view_vector.svg.png", + url: "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Placeholder_view_vector.svg/1280px-Placeholder_view_vector.svg.png", + caption: "Placeholder", + showPreview: true, + previewWidth: 256, + }, + }, + { + type: "paragraph", + content: "Paragraph 2", + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1"); + const endPos = getPosOfTextNode(doc, "Paragraph 2", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyHTML, + }, +]; diff --git a/tests/src/unit/core/clipboard/copy/runTests.test.ts b/tests/src/unit/core/clipboard/copy/runTests.test.ts new file mode 100644 index 0000000000..c1e3d77a0e --- /dev/null +++ b/tests/src/unit/core/clipboard/copy/runTests.test.ts @@ -0,0 +1,18 @@ +import { describe, it } from "vitest"; + +import { setupTestEditor } from "../../setupTestEditor.js"; +import { testSchema } from "../../testSchema.js"; +import { copyTestInstancesHTML } from "./copyTestInstances.js"; + +// Tests for verifying content that gets put on the clipboard when copying +// within the editor. Used for as many cases as possible to ensure each block or +// set of blocks is correctly converted into different types of clipboard data. +describe("Copy tests (HTML)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of copyTestInstancesHTML) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); diff --git a/tests/src/unit/core/clipboard/copyPaste/__snapshots__/paragraphInCustomBlock.json b/tests/src/unit/core/clipboard/copyPaste/__snapshots__/paragraphInCustomBlock.json new file mode 100644 index 0000000000..dae7ce6eed --- /dev/null +++ b/tests/src/unit/core/clipboard/copyPaste/__snapshots__/paragraphInCustomBlock.json @@ -0,0 +1,36 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "customParagraph", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/clipboard/copyPaste/copyPasteTestInstances.ts b/tests/src/unit/core/clipboard/copyPaste/copyPasteTestInstances.ts new file mode 100644 index 0000000000..1174599c2b --- /dev/null +++ b/tests/src/unit/core/clipboard/copyPaste/copyPasteTestInstances.ts @@ -0,0 +1,47 @@ +import { TextSelection } from "@tiptap/pm/state"; + +import { + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema, +} from "../../testSchema.js"; +import { CopyPasteTestCase } from "../../../shared/clipboard/copyPaste/copyPasteTestCase.js"; +import { testCopyPaste } from "../../../shared/clipboard/copyPaste/copyPasteTestExecutors.js"; +import { TestInstance } from "../../../types.js"; +import { getPosOfTextNode } from "../clipboardTestUtil.js"; + +export const copyPasteTestInstances: TestInstance< + CopyPasteTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = [ + { + testCase: { + name: "paragraphInCustomBlock", + document: [ + { + type: "paragraph", + content: "Paragraph 1", + }, + { + type: "customParagraph", + content: "Custom Paragraph 1", + }, + ], + getCopySelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1"); + const endPos = getPosOfTextNode(doc, "Paragraph 1", true); + + return TextSelection.create(doc, startPos, endPos); + }, + getPasteSelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Custom Paragraph 1"); + const endPos = getPosOfTextNode(doc, "Custom Paragraph 1", true); + + return TextSelection.create(doc, startPos, endPos); + }, + }, + executeTest: testCopyPaste, + }, +]; diff --git a/tests/src/unit/core/clipboard/copyPaste/runTests.test.ts b/tests/src/unit/core/clipboard/copyPaste/runTests.test.ts new file mode 100644 index 0000000000..1c55cbaf13 --- /dev/null +++ b/tests/src/unit/core/clipboard/copyPaste/runTests.test.ts @@ -0,0 +1,17 @@ +import { describe, it } from "vitest"; + +import { setupTestEditor } from "../../setupTestEditor.js"; +import { testSchema } from "../../testSchema.js"; +import { copyPasteTestInstances } from "./copyPasteTestInstances.js"; + +// Tests for verifying that copying and pasting content within the editor works +// as expected. Used for specific cases where unexpected behaviour was noticed. +describe("Copy/paste tests", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of copyPasteTestInstances) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); diff --git a/tests/src/unit/core/clipboard/copyPasteEquality/copyPasteEqualityTestInstances.ts b/tests/src/unit/core/clipboard/copyPasteEquality/copyPasteEqualityTestInstances.ts new file mode 100644 index 0000000000..e3bc47da79 --- /dev/null +++ b/tests/src/unit/core/clipboard/copyPasteEquality/copyPasteEqualityTestInstances.ts @@ -0,0 +1,27 @@ +import { + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema, +} from "../../testSchema.js"; +import { CopyPasteEqualityTestCase } from "../../../shared/clipboard/copyPasteEquality/copyPasteEqualityTestCase.js"; +import { testCopyPasteEquality } from "../../../shared/clipboard/copyPasteEquality/copyPasteEqualityTestExecutors.js"; +import { TestInstance } from "../../../types.js"; +import { copyTestInstancesHTML } from "../copy/copyTestInstances.js"; + +export const copyPasteEqualityTestInstances: TestInstance< + CopyPasteEqualityTestCase< + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema + >, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = copyTestInstancesHTML.map(({ testCase }) => ({ + testCase: { + name: testCase.name, + document: testCase.document, + getCopyAndPasteSelection: testCase.getCopySelection, + }, + executeTest: testCopyPasteEquality, +})); diff --git a/tests/src/unit/core/clipboard/copyPasteEquality/runTests.test.ts b/tests/src/unit/core/clipboard/copyPasteEquality/runTests.test.ts new file mode 100644 index 0000000000..27c4c619b0 --- /dev/null +++ b/tests/src/unit/core/clipboard/copyPasteEquality/runTests.test.ts @@ -0,0 +1,19 @@ +import { describe, it } from "vitest"; + +import { setupTestEditor } from "../../setupTestEditor.js"; +import { testSchema } from "../../testSchema.js"; +import { copyPasteEqualityTestInstances } from "./copyPasteEqualityTestInstances.js"; + +// Tests for verifying that copying and pasting content in place within the +// editor results in the same document as the original. Used for as many cases +// as possible to ensure that converting to and from clipboard data does not +// result in any data loss. +describe("Copy/paste equality tests", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of copyPasteEqualityTestInstances) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); diff --git a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-divs.json b/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteEndOfParagraph.json similarity index 60% rename from packages/core/src/api/exporters/html/__snapshots__/paste/parse-divs.json rename to tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteEndOfParagraph.json index 33f2f5010b..97c76edcff 100644 --- a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-divs.json +++ b/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteEndOfParagraph.json @@ -1,19 +1,19 @@ [ { - "id": "1", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { + "styles": {}, + "text": "Paragraph 1Paragraph", "type": "text", - "text": "Single Div", - "styles": {} - } + }, ], - "children": [] - } + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteImage.json b/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteImage.json new file mode 100644 index 0000000000..c0252a327f --- /dev/null +++ b/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteImage.json @@ -0,0 +1,34 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": undefined, + "id": "2", + "props": { + "backgroundColor": "default", + "caption": "", + "name": "", + "previewWidth": 512, + "showPreview": true, + "textAlignment": "left", + "url": "exampleURL", + }, + "type": "image", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteParagraphInCustomBlock.json b/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteParagraphInCustomBlock.json new file mode 100644 index 0000000000..6ebff558bb --- /dev/null +++ b/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteParagraphInCustomBlock.json @@ -0,0 +1,19 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Custom Paragraph 1Paragraph", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "customParagraph", + }, +] \ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html b/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteTable.json similarity index 80% rename from packages/core/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html rename to tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteTable.json index 9c4f9b7629..871e788cbf 100644 --- a/packages/core/src/api/clipboard/__snapshots__/external/pasteParagraphInCustomBlock.html +++ b/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteTable.json @@ -4,11 +4,11 @@ "content": [ { "styles": {}, - "text": "Paragraph", + "text": "Paragraph 1", "type": "text", }, ], - "id": "0", + "id": "1", "props": { "backgroundColor": "default", "textAlignment": "left", @@ -32,7 +32,7 @@ "content": [ { "styles": {}, - "text": "Table Cell", + "text": "Cell 1", "type": "text", }, ], @@ -49,7 +49,7 @@ "content": [ { "styles": {}, - "text": "Table Cell", + "text": "Cell 2", "type": "text", }, ], @@ -70,7 +70,7 @@ "content": [ { "styles": {}, - "text": "Table Cell", + "text": "Cell 3", "type": "text", }, ], @@ -87,7 +87,7 @@ "content": [ { "styles": {}, - "text": "Table Cell", + "text": "Cell 4", "type": "text", }, ], @@ -105,34 +105,10 @@ ], "type": "tableContent", }, - "id": "1", - "props": { - "textColor": "default", - }, - "type": "table", - }, - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph", - "type": "text", - }, - ], "id": "2", - "props": {}, - "type": "customParagraph", - }, - { - "children": [], - "content": [], - "id": "3", "props": { - "backgroundColor": "default", - "textAlignment": "left", "textColor": "default", }, - "type": "paragraph", + "type": "table", }, ] \ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html b/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteTableInExistingTable.json similarity index 83% rename from packages/core/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html rename to tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteTableInExistingTable.json index 034816337e..d968fe9dd4 100644 --- a/packages/core/src/api/clipboard/__snapshots__/external/pasteTableInExistingTable.html +++ b/tests/src/unit/core/clipboard/paste/__snapshots__/text/html/pasteTableInExistingTable.json @@ -1,21 +1,4 @@ [ - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Paragraph", - "type": "text", - }, - ], - "id": "0", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, { "children": [], "content": { @@ -33,7 +16,7 @@ "content": [ { "styles": {}, - "text": "Table Cell", + "text": "Table Cell 1", "type": "text", }, ], @@ -50,7 +33,7 @@ "content": [ { "styles": {}, - "text": "Table Cell", + "text": "Table Cell 2", "type": "text", }, ], @@ -82,7 +65,7 @@ "content": [ { "styles": {}, - "text": "Table Cell", + "text": "Table Cell 3", "type": "text", }, ], @@ -189,28 +172,4 @@ }, "type": "table", }, - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Custom Paragraph", - "type": "text", - }, - ], - "id": "2", - "props": {}, - "type": "customParagraph", - }, - { - "children": [], - "content": [], - "id": "3", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, ] \ No newline at end of file diff --git a/tests/src/unit/core/clipboard/paste/__snapshots__/text/plain/pasteEndOfParagraphText.json b/tests/src/unit/core/clipboard/paste/__snapshots__/text/plain/pasteEndOfParagraphText.json new file mode 100644 index 0000000000..97c76edcff --- /dev/null +++ b/tests/src/unit/core/clipboard/paste/__snapshots__/text/plain/pasteEndOfParagraphText.json @@ -0,0 +1,19 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1Paragraph", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/clipboard/paste/pasteTestInstances.ts b/tests/src/unit/core/clipboard/paste/pasteTestInstances.ts new file mode 100644 index 0000000000..1df662d4f7 --- /dev/null +++ b/tests/src/unit/core/clipboard/paste/pasteTestInstances.ts @@ -0,0 +1,166 @@ +import { TextSelection } from "@tiptap/pm/state"; + +import { + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema, +} from "../../testSchema.js"; +import { PasteTestCase } from "../../../shared/clipboard/paste/pasteTestCase.js"; +import { + testPasteHTML, + testPasteMarkdown, +} from "../../../shared/clipboard/paste/pasteTestExecutors.js"; +import { TestInstance } from "../../../types.js"; +import { getPosOfTextNode } from "../clipboardTestUtil.js"; + +export const pasteTestInstancesHTML: TestInstance< + PasteTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = [ + { + testCase: { + name: "pasteEndOfParagraph", + content: `

Paragraph

`, + document: [ + { + type: "paragraph", + content: "Paragraph 1", + }, + ], + getPasteSelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1", true); + + return TextSelection.create(doc, startPos); + }, + }, + executeTest: testPasteHTML, + }, + { + testCase: { + name: "pasteImage", + content: ``, + document: [ + { + type: "paragraph", + content: "Paragraph 1", + }, + ], + getPasteSelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1", true); + + return TextSelection.create(doc, startPos); + }, + }, + executeTest: testPasteHTML, + }, + { + testCase: { + name: "pasteTable", + content: ` + + + + + + + + +
Cell 1Cell 2
Cell 3Cell 4
`, + document: [ + { + type: "paragraph", + content: "Paragraph 1", + }, + ], + getPasteSelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1", true); + + return TextSelection.create(doc, startPos); + }, + }, + executeTest: testPasteHTML, + }, + { + testCase: { + name: "pasteTableInExistingTable", + content: ` + + + + + + + + +
Cell 1Cell 2
Cell 3Cell 4
`, + document: [ + { + type: "table", + content: { + type: "tableContent", + rows: [ + { + cells: [["Table Cell 1"], ["Table Cell 2"]], + }, + { + cells: [["Table Cell 3"], ["Table Cell 4"]], + }, + ], + }, + }, + ], + getPasteSelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Table Cell 4", true); + + return TextSelection.create(doc, startPos); + }, + }, + executeTest: testPasteHTML, + }, + { + testCase: { + name: "pasteParagraphInCustomBlock", + content: `

Paragraph

`, + document: [ + { + type: "customParagraph", + content: "Custom Paragraph 1", + }, + ], + getPasteSelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Custom Paragraph 1", true); + + return TextSelection.create(doc, startPos); + }, + }, + executeTest: testPasteHTML, + }, +]; + +export const pasteTestInstancesMarkdown: TestInstance< + PasteTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = [ + { + testCase: { + name: "pasteEndOfParagraphText", + content: `Paragraph`, + document: [ + { + type: "paragraph", + content: "Paragraph 1", + }, + ], + getPasteSelection: (doc) => { + const startPos = getPosOfTextNode(doc, "Paragraph 1", true); + + return TextSelection.create(doc, startPos); + }, + }, + executeTest: testPasteMarkdown, + }, +]; diff --git a/tests/src/unit/core/clipboard/paste/runTests.test.ts b/tests/src/unit/core/clipboard/paste/runTests.test.ts new file mode 100644 index 0000000000..92fba65fef --- /dev/null +++ b/tests/src/unit/core/clipboard/paste/runTests.test.ts @@ -0,0 +1,32 @@ +import { describe, it } from "vitest"; + +import { setupTestEditor } from "../../setupTestEditor.js"; +import { testSchema } from "../../testSchema.js"; +import { + pasteTestInstancesHTML, + pasteTestInstancesMarkdown, +} from "./pasteTestInstances.js"; + +// Tests for verifying that clipboard data gets pasted into the editor properly. +// Used for specific cases for when content from outside the editor is pasted +// into it. This includes content from other editors, as well as content from +// the web that has produced bugs in the past. +describe("Paste tests (HTML)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of pasteTestInstancesHTML) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); + +describe("Paste tests (Markdown)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of pasteTestInstancesMarkdown) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/contains-newlines.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/contains-newlines.html new file mode 100644 index 0000000000..32e032f09d --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/contains-newlines.html @@ -0,0 +1,11 @@ +
+
+
+
+
+          const hello ='world';console.log(hello);
+        
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/defaultLanguage.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/defaultLanguage.html new file mode 100644 index 0000000000..a8fb6870f0 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/defaultLanguage.html @@ -0,0 +1,11 @@ +
+
+
+
+
+          console.log('Hello, world!');
+        
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/empty.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/empty.html new file mode 100644 index 0000000000..7df4533925 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/empty.html @@ -0,0 +1,11 @@ +
+
+
+
+
+          
+        
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/python.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/python.html new file mode 100644 index 0000000000..232edd4914 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/python.html @@ -0,0 +1,11 @@ +
+
+
+
+
+          print('Hello, world!')
+        
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/complex/misc.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/complex/misc.html new file mode 100644 index 0000000000..7587f35366 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/complex/misc.html @@ -0,0 +1,59 @@ +
+
+
+
+

+ + Heading + + + 2 + +

+
+
+
+
+
+

Paragraph

+
+
+
+
+
+
+

+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/basic.html new file mode 100644 index 0000000000..9974d8d975 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/basic.html @@ -0,0 +1,28 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/button.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/button.html new file mode 100644 index 0000000000..db235fd792 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/button.html @@ -0,0 +1,20 @@ +
+
+
+
+
+
+
+ + + +
+

Add file

+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/nested.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/nested.html new file mode 100644 index 0000000000..6553a5c4a8 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/nested.html @@ -0,0 +1,56 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/noCaption.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/noCaption.html new file mode 100644 index 0000000000..48340682e8 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/noCaption.html @@ -0,0 +1,26 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/noName.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/noName.html new file mode 100644 index 0000000000..47ae5b3bf9 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/file/noName.html @@ -0,0 +1,27 @@ +
+
+
+
+
+
+
+ + + +
+

+
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/basic.html new file mode 100644 index 0000000000..ca0de5979f --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/basic.html @@ -0,0 +1,13 @@ +
+
+
+
+

+ Text1 +
+ Text2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/between-links.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/between-links.html new file mode 100644 index 0000000000..9e4b427c62 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/between-links.html @@ -0,0 +1,21 @@ +
+
+
+
+

+ Link1 +
+ Link2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/end.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/end.html new file mode 100644 index 0000000000..cc08190f01 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/end.html @@ -0,0 +1,12 @@ +
+
+
+
+

+ Text1 +
+

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/link.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/link.html new file mode 100644 index 0000000000..4cae02d67b --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/link.html @@ -0,0 +1,21 @@ +
+
+
+
+

+ Link1 +
+ Link1 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/multiple.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/multiple.html new file mode 100644 index 0000000000..06a2a6a7e5 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/multiple.html @@ -0,0 +1,15 @@ +
+
+
+
+

+ Text1 +
+ Text2 +
+ Text3 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/only.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/only.html new file mode 100644 index 0000000000..030fa48828 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/only.html @@ -0,0 +1,11 @@ +
+
+
+
+

+
+

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/start.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/start.html new file mode 100644 index 0000000000..29e2b8ece4 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/start.html @@ -0,0 +1,12 @@ +
+
+
+
+

+
+ Text1 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/styles.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/styles.html new file mode 100644 index 0000000000..b6b8eadb30 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/styles.html @@ -0,0 +1,13 @@ +
+
+
+
+

+ Text1 +
+ Text2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/basic.html new file mode 100644 index 0000000000..fe9509a5e3 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/basic.html @@ -0,0 +1,22 @@ +
+
+
+
+
+
+ example +
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/button.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/button.html new file mode 100644 index 0000000000..250700bb22 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/button.html @@ -0,0 +1,20 @@ +
+
+
+
+
+
+
+ + + +
+

Add image

+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/nested.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/nested.html new file mode 100644 index 0000000000..90e46213fe --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/nested.html @@ -0,0 +1,42 @@ +
+
+
+
+
+
+ Caption +
+

Caption

+
+
+
+
+
+
+
+
+ Caption +
+

Caption

+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/noCaption.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/noCaption.html new file mode 100644 index 0000000000..2daf51143b --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/noCaption.html @@ -0,0 +1,20 @@ +
+
+
+
+
+
+ example +
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/noName.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/noName.html new file mode 100644 index 0000000000..05bc98c060 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/noName.html @@ -0,0 +1,21 @@ +
+
+
+
+
+
+ Caption +
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/noPreview.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/noPreview.html new file mode 100644 index 0000000000..84f2dbfc76 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/image/noPreview.html @@ -0,0 +1,30 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/link/adjacent.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/link/adjacent.html new file mode 100644 index 0000000000..2408c611ac --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/link/adjacent.html @@ -0,0 +1,20 @@ +
+
+
+
+

+ Website + Website2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/link/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/link/basic.html new file mode 100644 index 0000000000..3daea90831 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/link/basic.html @@ -0,0 +1,15 @@ +
+
+
+
+

+ Website +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/link/styled.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/link/styled.html new file mode 100644 index 0000000000..2b9d4cb574 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/link/styled.html @@ -0,0 +1,22 @@ +
+
+
+
+

+ + Web + + site +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/lists/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/lists/basic.html new file mode 100644 index 0000000000..3cb5ed5e94 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/lists/basic.html @@ -0,0 +1,58 @@ +
+
+
+
+

Bullet List Item 1

+
+
+
+
+
+
+

Bullet List Item 2

+
+
+
+
+
+
+

Numbered List Item 1

+
+
+
+
+
+
+

Numbered List Item 2

+
+
+
+
+
+
+ +

Check List Item 1

+
+
+
+
+
+
+ +

Check List Item 2

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/lists/nested.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/lists/nested.html new file mode 100644 index 0000000000..f9aaf463f8 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/lists/nested.html @@ -0,0 +1,62 @@ +
+
+
+
+

Bullet List Item 1

+
+
+
+
+
+
+

Bullet List Item 2

+
+
+
+
+
+

Numbered List Item 1

+
+
+
+
+
+
+

Numbered List Item 2

+
+
+
+
+
+ +

Check List Item 1

+
+
+
+
+
+
+ +

Check List Item 2

+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/pageBreak/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/pageBreak/basic.html new file mode 100644 index 0000000000..545ab1bbac --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/pageBreak/basic.html @@ -0,0 +1,9 @@ +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/basic.html new file mode 100644 index 0000000000..326c6a037b --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/basic.html @@ -0,0 +1,9 @@ +
+
+
+
+

Paragraph

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/empty.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/empty.html new file mode 100644 index 0000000000..8c0240ae7c --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/empty.html @@ -0,0 +1,9 @@ +
+
+
+
+

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/lineBreaks.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/lineBreaks.html new file mode 100644 index 0000000000..0aa8dffa67 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/lineBreaks.html @@ -0,0 +1,13 @@ +
+
+
+
+

+ Line 1 +
+ Line 2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/nested.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/nested.html new file mode 100644 index 0000000000..7d99f8188d --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/nested.html @@ -0,0 +1,25 @@ +
+
+
+
+

Paragraph

+
+
+
+
+
+

Nested Paragraph 1

+
+
+
+
+
+
+

Nested Paragraph 2

+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/styled.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/styled.html new file mode 100644 index 0000000000..5ae4c7b95c --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/styled.html @@ -0,0 +1,32 @@ +
+
+
+
+

+ Plain + Red Text + Blue Background + + Mixed Colors + +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/allColWidths.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/allColWidths.html new file mode 100644 index 0000000000..778749b580 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/allColWidths.html @@ -0,0 +1,43 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/basic.html new file mode 100644 index 0000000000..a9e249effe --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/basic.html @@ -0,0 +1,43 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/headerCols.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/headerCols.html new file mode 100644 index 0000000000..6f5dcb8982 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/headerCols.html @@ -0,0 +1,43 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/headerRows.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/headerRows.html new file mode 100644 index 0000000000..2ce617f949 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/headerRows.html @@ -0,0 +1,43 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedCellColors.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedCellColors.html new file mode 100644 index 0000000000..8cafca0c72 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedCellColors.html @@ -0,0 +1,55 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedColWidths.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedColWidths.html new file mode 100644 index 0000000000..a5e5bdf3b4 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedColWidths.html @@ -0,0 +1,43 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedRowspansAndColspans.html b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedRowspansAndColspans.html new file mode 100644 index 0000000000..eb7dd2ce02 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedRowspansAndColspans.html @@ -0,0 +1,46 @@ +
+
+
+
+ + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/contains-newlines.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/contains-newlines.html new file mode 100644 index 0000000000..1b766eb380 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/contains-newlines.html @@ -0,0 +1,8 @@ +
+  
+    const hello ='world';
+    
+ console.log(hello); +
+
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/defaultLanguage.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/defaultLanguage.html new file mode 100644 index 0000000000..c5939c1b5e --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/defaultLanguage.html @@ -0,0 +1,3 @@ +
+  console.log('Hello, world!');
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/empty.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/empty.html new file mode 100644 index 0000000000..9bbe62c374 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/empty.html @@ -0,0 +1,3 @@ +
+  
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/python.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/python.html new file mode 100644 index 0000000000..2d95c0d45d --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/codeBlock/python.html @@ -0,0 +1,3 @@ +
+  print('Hello, world!')
+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/complex/misc.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/complex/misc.html new file mode 100644 index 0000000000..0df8a18343 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/complex/misc.html @@ -0,0 +1,14 @@ +

+ + Heading + + + 2 + +

+

Paragraph

+
    +
  • +

    +
  • +
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/basic.html new file mode 100644 index 0000000000..22fe1c373a --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/basic.html @@ -0,0 +1,4 @@ +
+ example +

Caption

+
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/file/button/external.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/button.html similarity index 100% rename from packages/core/src/api/exporters/html/__snapshots__/file/button/external.html rename to tests/src/unit/core/formatConversion/export/__snapshots__/html/file/button.html diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/nested.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/nested.html new file mode 100644 index 0000000000..226ee83250 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/nested.html @@ -0,0 +1,8 @@ +
+ example +

Caption

+
+
+ example +

Caption

+
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/file/noCaption/external.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/noCaption.html similarity index 100% rename from packages/core/src/api/exporters/html/__snapshots__/file/noCaption/external.html rename to tests/src/unit/core/formatConversion/export/__snapshots__/html/file/noCaption.html diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/noName.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/noName.html new file mode 100644 index 0000000000..f0ac923a66 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/file/noName.html @@ -0,0 +1,4 @@ +
+ exampleURL +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/basic.html new file mode 100644 index 0000000000..d0444869cc --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/basic.html @@ -0,0 +1,5 @@ +

+ Text1 +
+ Text2 +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/between-links.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/between-links.html new file mode 100644 index 0000000000..701b5d4213 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/between-links.html @@ -0,0 +1,13 @@ +

+ Link1 +
+ Link2 +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/end.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/end.html new file mode 100644 index 0000000000..1f7bcf996b --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/end.html @@ -0,0 +1,4 @@ +

+ Text1 +
+

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/link.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/link.html new file mode 100644 index 0000000000..2c762aedc5 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/link.html @@ -0,0 +1,13 @@ +

+ Link1 +
+ Link1 +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/multiple.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/multiple.html new file mode 100644 index 0000000000..5d957daa62 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/multiple.html @@ -0,0 +1,7 @@ +

+ Text1 +
+ Text2 +
+ Text3 +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/only.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/only.html new file mode 100644 index 0000000000..b96f89d7a0 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/only.html @@ -0,0 +1,3 @@ +

+
+

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/start.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/start.html new file mode 100644 index 0000000000..f0370a6c68 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/start.html @@ -0,0 +1,4 @@ +

+
+ Text1 +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/styles.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/styles.html new file mode 100644 index 0000000000..7a49318b49 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/hardbreak/styles.html @@ -0,0 +1,5 @@ +

+ Text1 +
+ Text2 +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/basic.html new file mode 100644 index 0000000000..59f782dbb1 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/basic.html @@ -0,0 +1,9 @@ +
+ example +

Caption

+
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/image/button/external.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/button.html similarity index 100% rename from packages/core/src/api/exporters/html/__snapshots__/image/button/external.html rename to tests/src/unit/core/formatConversion/export/__snapshots__/html/image/button.html diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/nested.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/nested.html new file mode 100644 index 0000000000..8cc825084e --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/nested.html @@ -0,0 +1,8 @@ +
+ exampleURL +

Caption

+
+
+ exampleURL +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/noCaption.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/noCaption.html new file mode 100644 index 0000000000..269bdeca7e --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/noCaption.html @@ -0,0 +1,6 @@ +example \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/noName.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/noName.html new file mode 100644 index 0000000000..decd178fbe --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/noName.html @@ -0,0 +1,4 @@ +
+ exampleURL +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/noPreview.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/noPreview.html new file mode 100644 index 0000000000..21bf2faaf1 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/image/noPreview.html @@ -0,0 +1,10 @@ +
+ example +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/link/adjacent.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/link/adjacent.html new file mode 100644 index 0000000000..db99691d33 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/link/adjacent.html @@ -0,0 +1,12 @@ +

+ Website + Website2 +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/link/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/link/basic.html new file mode 100644 index 0000000000..4b61e8c582 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/link/basic.html @@ -0,0 +1,7 @@ +

+ Website +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/link/styled.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/link/styled.html new file mode 100644 index 0000000000..fb7737f7f8 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/link/styled.html @@ -0,0 +1,14 @@ +

+ + Web + + site +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/lists/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/lists/basic.html new file mode 100644 index 0000000000..aee1048a87 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/lists/basic.html @@ -0,0 +1,26 @@ +
    +
  • +

    Bullet List Item 1

    +
  • +
  • +

    Bullet List Item 2

    +
  • +
+
    +
  1. +

    Numbered List Item 1

    +
  2. +
  3. +

    Numbered List Item 2

    +
  4. +
+
    +
  • + +

    Check List Item 1

    +
  • +
  • + +

    Check List Item 2

    +
  • +
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/lists/nested.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/lists/nested.html new file mode 100644 index 0000000000..b2497ae937 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/lists/nested.html @@ -0,0 +1,26 @@ +
    +
  • +

    Bullet List Item 1

    +
  • +
  • +

    Bullet List Item 2

    +
      +
    1. +

      Numbered List Item 1

      +
    2. +
    3. +

      Numbered List Item 2

      +
        +
      • + +

        Check List Item 1

        +
      • +
      • + +

        Check List Item 2

        +
      • +
      +
    4. +
    +
  • +
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/pageBreak/basic/external.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/pageBreak/basic.html similarity index 100% rename from packages/core/src/api/exporters/html/__snapshots__/pageBreak/basic/external.html rename to tests/src/unit/core/formatConversion/export/__snapshots__/html/pageBreak/basic.html diff --git a/packages/core/src/api/exporters/html/__snapshots__/paragraph/basic/external.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/basic.html similarity index 100% rename from packages/core/src/api/exporters/html/__snapshots__/paragraph/basic/external.html rename to tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/basic.html diff --git a/packages/core/src/api/exporters/html/__snapshots__/paragraph/empty/external.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/empty.html similarity index 100% rename from packages/core/src/api/exporters/html/__snapshots__/paragraph/empty/external.html rename to tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/empty.html diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/lineBreaks.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/lineBreaks.html new file mode 100644 index 0000000000..7dafa23c42 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/lineBreaks.html @@ -0,0 +1,5 @@ +

+ Line 1 +
+ Line 2 +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/nested.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/nested.html new file mode 100644 index 0000000000..5e80eb83e2 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/nested.html @@ -0,0 +1,3 @@ +

Paragraph

+

Nested Paragraph 1

+

Nested Paragraph 2

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/styled.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/styled.html new file mode 100644 index 0000000000..65e55c08bf --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/paragraph/styled.html @@ -0,0 +1,12 @@ +

+ Plain + Red Text + Blue Background + + Mixed Colors + +

\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/allColWidths.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/allColWidths.html new file mode 100644 index 0000000000..9ce9e3e5c6 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/allColWidths.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/basic.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/basic.html new file mode 100644 index 0000000000..00f73d172c --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/basic.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/headerCols.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/headerCols.html new file mode 100644 index 0000000000..eeebae59df --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/headerCols.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/headerRows.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/headerRows.html new file mode 100644 index 0000000000..008f208fdc --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/headerRows.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/mixedCellColors.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/mixedCellColors.html new file mode 100644 index 0000000000..05bcfd2bfc --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/mixedCellColors.html @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/mixedColWidths.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/mixedColWidths.html new file mode 100644 index 0000000000..72d863ebea --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/mixedColWidths.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/mixedRowspansAndColspans.html b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/mixedRowspansAndColspans.html new file mode 100644 index 0000000000..9ec43c73e7 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/html/table/mixedRowspansAndColspans.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/codeBlock/contains-newlines/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/codeBlock/contains-newlines.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/codeBlock/contains-newlines/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/codeBlock/contains-newlines.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/codeBlock/defaultLanguage/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/codeBlock/defaultLanguage.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/codeBlock/defaultLanguage/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/codeBlock/defaultLanguage.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/codeBlock/empty/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/codeBlock/empty.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/codeBlock/empty/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/codeBlock/empty.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/codeBlock/python/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/codeBlock/python.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/codeBlock/python/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/codeBlock/python.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/complex/misc/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/complex/misc.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/complex/misc/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/complex/misc.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/file/basic/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/file/basic.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/file/basic/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/file/basic.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/file/button/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/file/button.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/file/button/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/file/button.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/file/nested/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/file/nested.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/file/nested/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/file/nested.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/file/noCaption/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/file/noCaption.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/file/noCaption/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/file/noCaption.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/file/noName/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/file/noName.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/file/noName/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/file/noName.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/basic/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/basic.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/basic/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/basic.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/between-links/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/between-links.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/between-links/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/between-links.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/end/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/end.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/end/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/end.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/link/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/link.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/link/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/link.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/multiple/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/multiple.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/multiple/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/multiple.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/only/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/only.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/only/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/only.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/start/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/start.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/start/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/start.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/styles/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/styles.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/hardbreak/styles/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/hardbreak/styles.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/image/noPreview/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/basic.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/image/noPreview/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/basic.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/image/button/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/button.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/image/button/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/button.md diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/nested.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/nested.md new file mode 100644 index 0000000000..83c6df00ed --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/nested.md @@ -0,0 +1,7 @@ +[exampleURL](exampleURL) + +Caption + +[exampleURL](exampleURL) + +Caption diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/noCaption.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/noCaption.md new file mode 100644 index 0000000000..f525eb2143 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/noCaption.md @@ -0,0 +1 @@ +[example](exampleURL) diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/noName.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/noName.md new file mode 100644 index 0000000000..c7fefc547f --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/noName.md @@ -0,0 +1,3 @@ +[exampleURL](exampleURL) + +Caption diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/noPreview.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/noPreview.md new file mode 100644 index 0000000000..3acd9e1ad0 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/image/noPreview.md @@ -0,0 +1,3 @@ +[example](exampleURL) + +Caption diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/link/adjacent/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/link/adjacent.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/link/adjacent/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/link/adjacent.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/link/basic/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/link/basic.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/link/basic/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/link/basic.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/link/styled/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/link/styled.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/link/styled/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/link/styled.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/lists/basic/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/lists/basic.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/lists/basic/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/lists/basic.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/lists/nested/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/lists/nested.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/lists/nested/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/lists/nested.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/pageBreak/basic/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/pageBreak/basic.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/pageBreak/basic/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/pageBreak/basic.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/paragraph/basic/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/paragraph/basic.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/paragraph/basic/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/paragraph/basic.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/paragraph/empty/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/paragraph/empty.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/paragraph/empty/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/paragraph/empty.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/paragraph/lineBreaks/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/paragraph/lineBreaks.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/paragraph/lineBreaks/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/paragraph/lineBreaks.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/paragraph/nested/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/paragraph/nested.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/paragraph/nested/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/paragraph/nested.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/paragraph/styled/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/paragraph/styled.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/paragraph/styled/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/paragraph/styled.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/allColWidths/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/allColWidths.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/table/allColWidths/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/allColWidths.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/basic/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/basic.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/table/basic/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/basic.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/headerCols/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/headerCols.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/table/headerCols/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/headerCols.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/headerRows/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/headerRows.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/table/headerRows/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/headerRows.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/mixedCellColors/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/mixedCellColors.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/table/mixedCellColors/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/mixedCellColors.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/mixedColWidths/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/mixedColWidths.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/table/mixedColWidths/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/mixedColWidths.md diff --git a/packages/core/src/api/exporters/markdown/__snapshots__/table/mixedRowspansAndColspans/markdown.md b/tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/mixedRowspansAndColspans.md similarity index 100% rename from packages/core/src/api/exporters/markdown/__snapshots__/table/mixedRowspansAndColspans/markdown.md rename to tests/src/unit/core/formatConversion/export/__snapshots__/markdown/table/mixedRowspansAndColspans.md diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/contains-newlines.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/contains-newlines.json new file mode 100644 index 0000000000..da4c135551 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/contains-newlines.json @@ -0,0 +1,26 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "language": "javascript", + }, + "content": [ + { + "text": "const hello = 'world'; +console.log(hello); +", + "type": "text", + }, + ], + "type": "codeBlock", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/defaultLanguage.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/defaultLanguage.json new file mode 100644 index 0000000000..97b0374bfb --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/defaultLanguage.json @@ -0,0 +1,24 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "language": "text", + }, + "content": [ + { + "text": "console.log('Hello, world!');", + "type": "text", + }, + ], + "type": "codeBlock", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/empty.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/empty.json new file mode 100644 index 0000000000..4fd34ff835 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/empty.json @@ -0,0 +1,18 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "language": "text", + }, + "type": "codeBlock", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/python.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/python.json new file mode 100644 index 0000000000..01b6f86580 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/codeBlock/python.json @@ -0,0 +1,24 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "language": "python", + }, + "content": [ + { + "text": "print('Hello, world!')", + "type": "text", + }, + ], + "type": "codeBlock", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/complex/misc.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/complex/misc.json new file mode 100644 index 0000000000..85f484ec68 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/complex/misc.json @@ -0,0 +1,88 @@ +[ + { + "attrs": { + "backgroundColor": "blue", + "id": "1", + "textColor": "yellow", + }, + "content": [ + { + "attrs": { + "level": 2, + "textAlignment": "right", + }, + "content": [ + { + "marks": [ + { + "type": "bold", + }, + { + "type": "underline", + }, + ], + "text": "Heading ", + "type": "text", + }, + { + "marks": [ + { + "type": "italic", + }, + { + "type": "strike", + }, + ], + "text": "2", + "type": "text", + }, + ], + "type": "heading", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "red", + "id": "2", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Paragraph", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, + { + "attrs": { + "backgroundColor": "default", + "id": "3", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "type": "bulletListItem", + }, + ], + "type": "blockContainer", + }, + ], + "type": "blockGroup", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/basic.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/basic.json new file mode 100644 index 0000000000..0de31316e1 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/basic.json @@ -0,0 +1,20 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "Caption", + "name": "example", + "url": "exampleURL", + }, + "type": "file", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/button.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/button.json new file mode 100644 index 0000000000..42be1c0985 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/button.json @@ -0,0 +1,20 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "", + "name": "", + "url": "", + }, + "type": "file", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/nested.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/nested.json new file mode 100644 index 0000000000..f122b855d8 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/nested.json @@ -0,0 +1,43 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "Caption", + "name": "example", + "url": "exampleURL", + }, + "type": "file", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "id": "2", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "Caption", + "name": "example", + "url": "exampleURL", + }, + "type": "file", + }, + ], + "type": "blockContainer", + }, + ], + "type": "blockGroup", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/noCaption.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/noCaption.json new file mode 100644 index 0000000000..7b9cd6f1c4 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/noCaption.json @@ -0,0 +1,20 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "", + "name": "example", + "url": "exampleURL", + }, + "type": "file", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/noName.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/noName.json new file mode 100644 index 0000000000..393aff6af8 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/file/noName.json @@ -0,0 +1,20 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "Caption", + "name": "", + "url": "exampleURL", + }, + "type": "file", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/basic.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/basic.json new file mode 100644 index 0000000000..8f3e362113 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/basic.json @@ -0,0 +1,31 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Text1", + "type": "text", + }, + { + "type": "hardBreak", + }, + { + "text": "Text2", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/between-links.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/between-links.json new file mode 100644 index 0000000000..93e7571b21 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/between-links.json @@ -0,0 +1,53 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "marks": [ + { + "attrs": { + "class": null, + "href": "https://www.website.com", + "rel": "noopener noreferrer nofollow", + "target": "_blank", + }, + "type": "link", + }, + ], + "text": "Link1", + "type": "text", + }, + { + "type": "hardBreak", + }, + { + "marks": [ + { + "attrs": { + "class": null, + "href": "https://www.website2.com", + "rel": "noopener noreferrer nofollow", + "target": "_blank", + }, + "type": "link", + }, + ], + "text": "Link2", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/end.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/end.json new file mode 100644 index 0000000000..781e539991 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/end.json @@ -0,0 +1,27 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Text1", + "type": "text", + }, + { + "type": "hardBreak", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/link.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/link.json new file mode 100644 index 0000000000..aee93b47d3 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/link.json @@ -0,0 +1,53 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "marks": [ + { + "attrs": { + "class": null, + "href": "https://www.website.com", + "rel": "noopener noreferrer nofollow", + "target": "_blank", + }, + "type": "link", + }, + ], + "text": "Link1", + "type": "text", + }, + { + "type": "hardBreak", + }, + { + "marks": [ + { + "attrs": { + "class": null, + "href": "https://www.website.com", + "rel": "noopener noreferrer nofollow", + "target": "_blank", + }, + "type": "link", + }, + ], + "text": "Link1", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/multiple.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/multiple.json new file mode 100644 index 0000000000..b8cd0f19ec --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/multiple.json @@ -0,0 +1,38 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Text1", + "type": "text", + }, + { + "type": "hardBreak", + }, + { + "text": "Text2", + "type": "text", + }, + { + "type": "hardBreak", + }, + { + "text": "Text3", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/only.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/only.json new file mode 100644 index 0000000000..6a1a4d2554 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/only.json @@ -0,0 +1,23 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "type": "hardBreak", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/start.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/start.json new file mode 100644 index 0000000000..dc2396df1f --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/start.json @@ -0,0 +1,27 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "type": "hardBreak", + }, + { + "text": "Text1", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/styles.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/styles.json new file mode 100644 index 0000000000..034bf8b726 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/hardbreak/styles.json @@ -0,0 +1,36 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Text1", + "type": "text", + }, + { + "type": "hardBreak", + }, + { + "marks": [ + { + "type": "bold", + }, + ], + "text": "Text2", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/basic.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/basic.json new file mode 100644 index 0000000000..ad2d0f7a69 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/basic.json @@ -0,0 +1,23 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "Caption", + "name": "example", + "previewWidth": 256, + "showPreview": true, + "textAlignment": "left", + "url": "exampleURL", + }, + "type": "image", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/button.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/button.json new file mode 100644 index 0000000000..e0aef86d8e --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/button.json @@ -0,0 +1,23 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "", + "name": "", + "previewWidth": 512, + "showPreview": true, + "textAlignment": "left", + "url": "", + }, + "type": "image", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/nested.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/nested.json new file mode 100644 index 0000000000..db8fee4b1d --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/nested.json @@ -0,0 +1,49 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "Caption", + "name": "", + "previewWidth": 256, + "showPreview": true, + "textAlignment": "left", + "url": "exampleURL", + }, + "type": "image", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "id": "2", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "Caption", + "name": "", + "previewWidth": 256, + "showPreview": true, + "textAlignment": "left", + "url": "exampleURL", + }, + "type": "image", + }, + ], + "type": "blockContainer", + }, + ], + "type": "blockGroup", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/noCaption.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/noCaption.json new file mode 100644 index 0000000000..aaa57c857a --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/noCaption.json @@ -0,0 +1,23 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "", + "name": "example", + "previewWidth": 256, + "showPreview": true, + "textAlignment": "left", + "url": "exampleURL", + }, + "type": "image", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/noName.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/noName.json new file mode 100644 index 0000000000..10a9c03a69 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/noName.json @@ -0,0 +1,23 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "Caption", + "name": "", + "previewWidth": 256, + "showPreview": true, + "textAlignment": "left", + "url": "exampleURL", + }, + "type": "image", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/noPreview.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/noPreview.json new file mode 100644 index 0000000000..946ca5f86e --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/image/noPreview.json @@ -0,0 +1,23 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "caption": "Caption", + "name": "example", + "previewWidth": 256, + "showPreview": false, + "textAlignment": "left", + "url": "exampleURL", + }, + "type": "image", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/link/adjacent.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/link/adjacent.json new file mode 100644 index 0000000000..13f609f82e --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/link/adjacent.json @@ -0,0 +1,50 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "marks": [ + { + "attrs": { + "class": null, + "href": "https://www.website.com", + "rel": "noopener noreferrer nofollow", + "target": "_blank", + }, + "type": "link", + }, + ], + "text": "Website", + "type": "text", + }, + { + "marks": [ + { + "attrs": { + "class": null, + "href": "https://www.website2.com", + "rel": "noopener noreferrer nofollow", + "target": "_blank", + }, + "type": "link", + }, + ], + "text": "Website2", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/link/basic.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/link/basic.json new file mode 100644 index 0000000000..a760a4ad4f --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/link/basic.json @@ -0,0 +1,35 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "marks": [ + { + "attrs": { + "class": null, + "href": "https://www.website.com", + "rel": "noopener noreferrer nofollow", + "target": "_blank", + }, + "type": "link", + }, + ], + "text": "Website", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/link/styled.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/link/styled.json new file mode 100644 index 0000000000..2d4dc02bec --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/link/styled.json @@ -0,0 +1,53 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "marks": [ + { + "type": "bold", + }, + { + "attrs": { + "class": null, + "href": "https://www.website.com", + "rel": "noopener noreferrer nofollow", + "target": "_blank", + }, + "type": "link", + }, + ], + "text": "Web", + "type": "text", + }, + { + "marks": [ + { + "attrs": { + "class": null, + "href": "https://www.website.com", + "rel": "noopener noreferrer nofollow", + "target": "_blank", + }, + "type": "link", + }, + ], + "text": "site", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/lists/basic.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/lists/basic.json new file mode 100644 index 0000000000..70a1a0aaa4 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/lists/basic.json @@ -0,0 +1,140 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Bullet List Item 1", + "type": "text", + }, + ], + "type": "bulletListItem", + }, + ], + "type": "blockContainer", + }, + { + "attrs": { + "backgroundColor": "default", + "id": "2", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Bullet List Item 2", + "type": "text", + }, + ], + "type": "bulletListItem", + }, + ], + "type": "blockContainer", + }, + { + "attrs": { + "backgroundColor": "default", + "id": "3", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "index": null, + "start": undefined, + "textAlignment": "left", + }, + "content": [ + { + "text": "Numbered List Item 1", + "type": "text", + }, + ], + "type": "numberedListItem", + }, + ], + "type": "blockContainer", + }, + { + "attrs": { + "backgroundColor": "default", + "id": "4", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "index": null, + "start": undefined, + "textAlignment": "left", + }, + "content": [ + { + "text": "Numbered List Item 2", + "type": "text", + }, + ], + "type": "numberedListItem", + }, + ], + "type": "blockContainer", + }, + { + "attrs": { + "backgroundColor": "default", + "id": "5", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "checked": false, + "textAlignment": "left", + }, + "content": [ + { + "text": "Check List Item 1", + "type": "text", + }, + ], + "type": "checkListItem", + }, + ], + "type": "blockContainer", + }, + { + "attrs": { + "backgroundColor": "default", + "id": "6", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "checked": true, + "textAlignment": "left", + }, + "content": [ + { + "text": "Check List Item 2", + "type": "text", + }, + ], + "type": "checkListItem", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/lists/nested.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/lists/nested.json new file mode 100644 index 0000000000..b0f224fec8 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/lists/nested.json @@ -0,0 +1,150 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Bullet List Item 1", + "type": "text", + }, + ], + "type": "bulletListItem", + }, + ], + "type": "blockContainer", + }, + { + "attrs": { + "backgroundColor": "default", + "id": "2", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Bullet List Item 2", + "type": "text", + }, + ], + "type": "bulletListItem", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "id": "3", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "index": null, + "start": undefined, + "textAlignment": "left", + }, + "content": [ + { + "text": "Numbered List Item 1", + "type": "text", + }, + ], + "type": "numberedListItem", + }, + ], + "type": "blockContainer", + }, + { + "attrs": { + "backgroundColor": "default", + "id": "4", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "index": null, + "start": undefined, + "textAlignment": "left", + }, + "content": [ + { + "text": "Numbered List Item 2", + "type": "text", + }, + ], + "type": "numberedListItem", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "id": "5", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "checked": false, + "textAlignment": "left", + }, + "content": [ + { + "text": "Check List Item 1", + "type": "text", + }, + ], + "type": "checkListItem", + }, + ], + "type": "blockContainer", + }, + { + "attrs": { + "backgroundColor": "default", + "id": "6", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "checked": true, + "textAlignment": "left", + }, + "content": [ + { + "text": "Check List Item 2", + "type": "text", + }, + ], + "type": "checkListItem", + }, + ], + "type": "blockContainer", + }, + ], + "type": "blockGroup", + }, + ], + "type": "blockContainer", + }, + ], + "type": "blockGroup", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/pageBreak/basic.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/pageBreak/basic.json new file mode 100644 index 0000000000..f054006323 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/pageBreak/basic.json @@ -0,0 +1,15 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "type": "pageBreak", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/basic.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/basic.json new file mode 100644 index 0000000000..03c5eb0a1b --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/basic.json @@ -0,0 +1,24 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Paragraph", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/empty.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/empty.json new file mode 100644 index 0000000000..34dcd51ce9 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/empty.json @@ -0,0 +1,18 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/lineBreaks.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/lineBreaks.json new file mode 100644 index 0000000000..14d1230246 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/lineBreaks.json @@ -0,0 +1,31 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Line 1", + "type": "text", + }, + { + "type": "hardBreak", + }, + { + "text": "Line 2", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/nested.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/nested.json new file mode 100644 index 0000000000..8b7532615d --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/nested.json @@ -0,0 +1,73 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Paragraph", + "type": "text", + }, + ], + "type": "paragraph", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "id": "2", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Nested Paragraph 1", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, + { + "attrs": { + "backgroundColor": "default", + "id": "3", + "textColor": "default", + }, + "content": [ + { + "attrs": { + "textAlignment": "left", + }, + "content": [ + { + "text": "Nested Paragraph 2", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, + ], + "type": "blockGroup", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/styled.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/styled.json new file mode 100644 index 0000000000..debf389327 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/paragraph/styled.json @@ -0,0 +1,66 @@ +[ + { + "attrs": { + "backgroundColor": "pink", + "id": "1", + "textColor": "orange", + }, + "content": [ + { + "attrs": { + "textAlignment": "center", + }, + "content": [ + { + "text": "Plain ", + "type": "text", + }, + { + "marks": [ + { + "attrs": { + "stringValue": "red", + }, + "type": "textColor", + }, + ], + "text": "Red Text ", + "type": "text", + }, + { + "marks": [ + { + "attrs": { + "stringValue": "blue", + }, + "type": "backgroundColor", + }, + ], + "text": "Blue Background ", + "type": "text", + }, + { + "marks": [ + { + "attrs": { + "stringValue": "red", + }, + "type": "textColor", + }, + { + "attrs": { + "stringValue": "blue", + }, + "type": "backgroundColor", + }, + ], + "text": "Mixed Colors", + "type": "text", + }, + ], + "type": "paragraph", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/allColWidths.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/allColWidths.json new file mode 100644 index 0000000000..519391c98f --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/allColWidths.json @@ -0,0 +1,248 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 100, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 200, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 100, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 200, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 100, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 200, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + ], + "type": "table", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/basic.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/basic.json new file mode 100644 index 0000000000..8fd5f7f2d3 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/basic.json @@ -0,0 +1,230 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + ], + "type": "table", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/headerCols.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/headerCols.json new file mode 100644 index 0000000000..3933a56ca3 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/headerCols.json @@ -0,0 +1,230 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableHeader", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableHeader", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableHeader", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + ], + "type": "table", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/headerRows.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/headerRows.json new file mode 100644 index 0000000000..dc9ee26a35 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/headerRows.json @@ -0,0 +1,230 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableHeader", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableHeader", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableHeader", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + ], + "type": "table", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/mixedCellColors.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/mixedCellColors.json new file mode 100644 index 0000000000..69b25e9bfa --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/mixedCellColors.json @@ -0,0 +1,242 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "content": [ + { + "attrs": { + "backgroundColor": "red", + "colspan": 1, + "colwidth": [ + 100, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "blue", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "blue", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "yellow", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "red", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 100, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 100, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + ], + "type": "table", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/mixedColWidths.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/mixedColWidths.json new file mode 100644 index 0000000000..60600bb04e --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/mixedColWidths.json @@ -0,0 +1,242 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 100, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 100, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 100, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": null, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + ], + "type": "table", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/mixedRowspansAndColspans.json b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/mixedRowspansAndColspans.json new file mode 100644 index 0000000000..11fb672923 --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/__snapshots__/nodes/table/mixedRowspansAndColspans.json @@ -0,0 +1,178 @@ +[ + { + "attrs": { + "backgroundColor": "default", + "id": "1", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "content": [ + { + "attrs": { + "backgroundColor": "red", + "colspan": 2, + "colwidth": [ + 100, + 200, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "blue", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "yellow", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "red", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 100, + ], + "rowspan": 2, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 2, + "colwidth": [ + 200, + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + { + "content": [ + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 200, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + { + "attrs": { + "backgroundColor": "default", + "colspan": 1, + "colwidth": [ + 300, + ], + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "content": [ + { + "content": [ + { + "text": "Table Cell", + "type": "text", + }, + ], + "type": "tableParagraph", + }, + ], + "type": "tableCell", + }, + ], + "type": "tableRow", + }, + ], + "type": "table", + }, + ], + "type": "blockContainer", + }, +] \ No newline at end of file diff --git a/packages/core/src/api/testUtil/cases/defaultSchema.ts b/tests/src/unit/core/formatConversion/export/exportTestInstances.ts similarity index 88% rename from packages/core/src/api/testUtil/cases/defaultSchema.ts rename to tests/src/unit/core/formatConversion/export/exportTestInstances.ts index 2b1b47e5ec..2e476712af 100644 --- a/packages/core/src/api/testUtil/cases/defaultSchema.ts +++ b/tests/src/unit/core/formatConversion/export/exportTestInstances.ts @@ -1,63 +1,50 @@ -import { EditorTestCases } from "../index.js"; - -import { uploadToTmpFilesDotOrg_DEV_ONLY } from "../../../blocks/FileBlockContent/uploadToTmpFilesDotOrg_DEV_ONLY.js"; +import { ExportTestCase } from "../../../shared/formatConversion/export/exportTestCase.js"; import { - DefaultBlockSchema, - DefaultInlineContentSchema, - DefaultStyleSchema, -} from "../../../blocks/defaultBlocks.js"; + testExportBlockNoteHTML, + testExportHTML, + testExportMarkdown, + testExportNodes, +} from "../../../shared/formatConversion/export/exportTestExecutors.js"; +import { TestInstance } from "../../../types.js"; import { - pageBreakSchema, - withPageBreak, -} from "../../../blocks/PageBreakBlockContent/schema.js"; -import { BlockNoteEditor } from "../../../editor/BlockNoteEditor.js"; -import { BlockNoteSchema } from "../../../editor/BlockNoteSchema.js"; + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema, +} from "../../testSchema.js"; -export const defaultSchemaTestCases: EditorTestCases< - DefaultBlockSchema & typeof pageBreakSchema.blockSchema, - DefaultInlineContentSchema, - DefaultStyleSchema -> = { - name: "default schema", - createEditor: () => { - return BlockNoteEditor.create({ - schema: withPageBreak(BlockNoteSchema.create()), - uploadFile: uploadToTmpFilesDotOrg_DEV_ONLY, - codeBlock: { - supportedLanguages: { - javascript: { - name: "JavaScript", - aliases: ["js"], - }, - python: { - name: "Python", - aliases: ["py"], - }, - }, - }, - }); - }, - documents: [ - { +export const exportTestInstancesBlockNoteHTML: TestInstance< + ExportTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = [ + { + testCase: { name: "paragraph/empty", - blocks: [ + content: [ { type: "paragraph", }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "paragraph/basic", - blocks: [ + content: [ { type: "paragraph", content: "Paragraph", }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "paragraph/styled", - blocks: [ + content: [ { type: "paragraph", props: { @@ -97,9 +84,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "paragraph/nested", - blocks: [ + content: [ { type: "paragraph", content: "Paragraph", @@ -116,18 +106,24 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "paragraph/lineBreaks", - blocks: [ + content: [ { type: "paragraph", content: "Line 1\nLine 2", }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "lists/basic", - blocks: [ + content: [ { type: "bulletListItem", content: "Bullet List Item 1", @@ -157,9 +153,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "lists/nested", - blocks: [ + content: [ { type: "bulletListItem", content: "Bullet List Item 1", @@ -193,26 +192,35 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "codeBlock/empty", - blocks: [ + content: [ { type: "codeBlock", }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "codeBlock/defaultLanguage", - blocks: [ + content: [ { type: "codeBlock", content: "console.log('Hello, world!');", }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "codeBlock/python", - blocks: [ + content: [ { type: "codeBlock", props: { language: "python" }, @@ -220,9 +228,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "codeBlock/contains-newlines", - blocks: [ + content: [ { type: "codeBlock", props: { language: "javascript" }, @@ -230,25 +241,34 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "pageBreak/basic", - blocks: [ + content: [ { type: "pageBreak", }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "file/button", - blocks: [ + content: [ { type: "file", }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "file/basic", - blocks: [ + content: [ { type: "file", props: { @@ -259,9 +279,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "file/noName", - blocks: [ + content: [ { type: "file", props: { @@ -271,9 +294,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "file/noCaption", - blocks: [ + content: [ { type: "file", props: { @@ -283,9 +309,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "file/nested", - blocks: [ + content: [ { type: "file", props: { @@ -306,20 +335,23 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - // Because images need to fetch the download URL async, their internal HTML - // is initially rendered without a `src` attribute, which is reflected in - // the tests. - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "image/button", - blocks: [ + content: [ { type: "image", }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "image/basic", - blocks: [ + content: [ { type: "image", props: { @@ -331,9 +363,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "image/noName", - blocks: [ + content: [ { type: "image", props: { @@ -344,9 +379,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "image/noCaption", - blocks: [ + content: [ { type: "image", props: { @@ -357,9 +395,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "image/noPreview", - blocks: [ + content: [ { type: "image", props: { @@ -372,9 +413,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "image/nested", - blocks: [ + content: [ { type: "image", props: { @@ -395,9 +439,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "table/basic", - blocks: [ + content: [ { type: "table", content: { @@ -519,9 +566,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "table/allColWidths", - blocks: [ + content: [ { type: "table", content: { @@ -644,9 +694,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "table/mixedColWidths", - blocks: [ + content: [ { type: "table", content: { @@ -769,9 +822,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "table/mixedCellColors", - blocks: [ + content: [ { type: "table", content: { @@ -894,9 +950,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "table/mixedRowspansAndColspans", - blocks: [ + content: [ { type: "table", content: { @@ -986,9 +1045,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "table/headerRows", - blocks: [ + content: [ { type: "table", content: { @@ -1111,9 +1173,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "table/headerCols", - blocks: [ + content: [ { type: "table", content: { @@ -1236,9 +1301,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "link/basic", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1252,9 +1320,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "link/styled", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1281,9 +1352,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "link/adjacent", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1302,9 +1376,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "hardbreak/basic", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1318,9 +1395,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "hardbreak/multiple", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1334,9 +1414,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "hardbreak/start", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1350,9 +1433,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "hardbreak/end", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1366,9 +1452,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "hardbreak/only", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1382,9 +1471,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "hardbreak/styles", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1403,9 +1495,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "hardbreak/link", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1419,9 +1514,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "hardbreak/between-links", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "paragraph", @@ -1440,9 +1538,12 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "complex/misc", - blocks: [ + content: [ { // id: UniqueID.options.generateID(), type: "heading", @@ -1489,5 +1590,36 @@ export const defaultSchemaTestCases: EditorTestCases< }, ], }, - ], -}; + executeTest: testExportBlockNoteHTML, + }, +]; + +export const exportTestInstancesHTML: TestInstance< + ExportTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = exportTestInstancesBlockNoteHTML.map(({ testCase }) => ({ + testCase, + executeTest: testExportHTML, +})); + +export const exportTestInstancesMarkdown: TestInstance< + ExportTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = exportTestInstancesBlockNoteHTML.map(({ testCase }) => ({ + testCase, + executeTest: testExportMarkdown, +})); + +export const exportTestInstancesNodes: TestInstance< + ExportTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = exportTestInstancesBlockNoteHTML.map(({ testCase }) => ({ + testCase, + executeTest: testExportNodes, +})); diff --git a/tests/src/unit/core/formatConversion/export/runTests.test.ts b/tests/src/unit/core/formatConversion/export/runTests.test.ts new file mode 100644 index 0000000000..badd6638cb --- /dev/null +++ b/tests/src/unit/core/formatConversion/export/runTests.test.ts @@ -0,0 +1,53 @@ +import { describe, it } from "vitest"; + +import { setupTestEditor } from "../../setupTestEditor.js"; +import { testSchema } from "../../testSchema.js"; +import { + exportTestInstancesBlockNoteHTML, + exportTestInstancesHTML, + exportTestInstancesMarkdown, + exportTestInstancesNodes, +} from "./exportTestInstances.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("Export tests (BlockNote HTML)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of exportTestInstancesBlockNoteHTML) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); + +describe("Export tests (HTML)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of exportTestInstancesHTML) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); + +describe("Export tests (Markdown)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of exportTestInstancesMarkdown) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); + +describe("Export tests (TipTap nodes)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of exportTestInstancesNodes) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); diff --git a/tests/src/unit/core/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts b/tests/src/unit/core/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts new file mode 100644 index 0000000000..63d3552df0 --- /dev/null +++ b/tests/src/unit/core/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts @@ -0,0 +1,23 @@ +import { ExportParseEqualityTestCase } from "../../../shared/formatConversion/exportParseEquality/exportParseEqualityTestCase.js"; +import { testExportParseEqualityBlockNoteHTML } from "../../../shared/formatConversion/exportParseEquality/exportParseEqualityTestExecutors.js"; +import { TestInstance } from "../../../types.js"; +import { + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema, +} from "../../testSchema.js"; +import { exportTestInstancesBlockNoteHTML } from "../export/exportTestInstances.js"; + +export const exportParseEqualityTestInstancesBlockNoteHTML: TestInstance< + ExportParseEqualityTestCase< + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema + >, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = exportTestInstancesBlockNoteHTML.map(({ testCase }) => ({ + testCase, + executeTest: testExportParseEqualityBlockNoteHTML, +})); diff --git a/tests/src/unit/core/formatConversion/exportParseEquality/runTests.test.ts b/tests/src/unit/core/formatConversion/exportParseEquality/runTests.test.ts new file mode 100644 index 0000000000..3970bb02d8 --- /dev/null +++ b/tests/src/unit/core/formatConversion/exportParseEquality/runTests.test.ts @@ -0,0 +1,22 @@ +import { describe, it } from "vitest"; + +import { setupTestEditor } from "../../setupTestEditor.js"; +import { testSchema } from "../../testSchema.js"; +import { exportParseEqualityTestInstancesBlockNoteHTML } from "./exportParseEqualityTestInstances.js"; + +// Tests for verifying that exporting blocks to another format, then importing +// them back results in the same blocks as the original. Used for as many cases +// as possible to ensure that exporting and importing blocks does not result in +// any data loss. +describe("Export/parse equality tests (BlockNote HTML)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { + testCase, + executeTest, + } of exportParseEqualityTestInstancesBlockNoteHTML) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); diff --git a/tests/src/unit/core/formatConversion/formatConversionTestUtil.ts b/tests/src/unit/core/formatConversion/formatConversionTestUtil.ts new file mode 100644 index 0000000000..a71cdbda08 --- /dev/null +++ b/tests/src/unit/core/formatConversion/formatConversionTestUtil.ts @@ -0,0 +1,197 @@ +import { + Block, + BlockNoteSchema, + BlockSchema, + InlineContent, + InlineContentSchema, + isPartialLinkInlineContent, + isStyledTextInlineContent, + PartialBlock, + PartialInlineContent, + PartialTableCell, + StyledText, + StyleSchema, + TableCell, + TableContent, + UniqueID, +} from "@blocknote/core"; + +function textShorthandToStyledText( + content: string | StyledText[] = "" +): StyledText[] { + if (typeof content === "string") { + return [ + { + type: "text", + text: content, + styles: {}, + }, + ]; + } + return content; +} + +function partialContentToInlineContent( + content: + | PartialInlineContent + | PartialTableCell + | TableContent + | undefined +): + | InlineContent[] + | TableContent + | TableCell + | undefined { + if (typeof content === "string") { + return textShorthandToStyledText(content); + } + + if (Array.isArray(content)) { + return content.flatMap((partialContent) => { + if (typeof partialContent === "string") { + return textShorthandToStyledText(partialContent); + } else if (isPartialLinkInlineContent(partialContent)) { + return { + ...partialContent, + content: textShorthandToStyledText(partialContent.content), + }; + } else if (isStyledTextInlineContent(partialContent)) { + return partialContent; + } else { + // custom inline content + + return { + props: {}, + ...partialContent, + content: partialContentToInlineContent(partialContent.content), + } as any; + } + }); + } else if (content?.type === "tableContent") { + return { + type: "tableContent", + columnWidths: content.columnWidths, + headerRows: content.headerRows, + headerCols: content.headerCols, + rows: content.rows.map((row) => ({ + ...row, + cells: row.cells.map( + (cell) => partialContentToInlineContent(cell) as any + ), + })), + }; + } else if (content?.type === "tableCell") { + return { + type: "tableCell", + content: partialContentToInlineContent(content.content) as any[], + props: { + backgroundColor: content.props?.backgroundColor ?? "default", + textColor: content.props?.textColor ?? "default", + textAlignment: content.props?.textAlignment ?? "left", + colspan: content.props?.colspan ?? 1, + rowspan: content.props?.rowspan ?? 1, + }, + } satisfies TableCell; + } + + return content; +} + +export function partialBlocksToBlocksForTesting< + BSchema extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + schema: BlockNoteSchema, + partialBlocks: Array, NoInfer, NoInfer>> +): Array> { + return partialBlocks.map((partialBlock) => + partialBlockToBlockForTesting(schema.blockSchema, partialBlock) + ); +} + +export function partialBlockToBlockForTesting< + BSchema extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + schema: BSchema, + partialBlock: PartialBlock +): Block { + const contentType: "inline" | "table" | "none" = + schema[partialBlock.type!].content; + + const withDefaults: Block = { + id: "", + type: partialBlock.type!, + props: {} as any, + content: + contentType === "inline" + ? [] + : contentType === "table" + ? { + type: "tableContent", + columnWidths: undefined, + headerRows: undefined, + headerCols: undefined, + rows: [], + } + : (undefined as any), + children: [] as any, + ...partialBlock, + }; + + Object.entries(schema[partialBlock.type!].propSchema).forEach( + ([propKey, propValue]) => { + if ( + withDefaults.props[propKey] === undefined && + propValue.default !== undefined + ) { + (withDefaults.props as any)[propKey] = propValue.default; + } + } + ); + + if (contentType === "inline") { + const content = withDefaults.content as InlineContent[] | undefined; + withDefaults.content = partialContentToInlineContent(content) as any; + } else if (contentType === "table") { + const content = withDefaults.content as TableContent | undefined; + withDefaults.content = { + type: "tableContent", + columnWidths: + content?.columnWidths || + content?.rows[0]?.cells.map(() => undefined) || + [], + headerRows: content?.headerRows || undefined, + headerCols: content?.headerCols || undefined, + rows: + content?.rows.map((row) => ({ + cells: row.cells.map((cell) => partialContentToInlineContent(cell)), + })) || [], + } as any; + } + + return { + ...withDefaults, + content: partialContentToInlineContent(withDefaults.content), + children: withDefaults.children.map((c) => { + return partialBlockToBlockForTesting(schema, c); + }), + } as any; +} + +export function addIdsToBlock(block: PartialBlock) { + if (!block.id) { + block.id = UniqueID.options.generateID(); + } + if (block.children) { + addIdsToBlocks(block.children); + } +} + +export function addIdsToBlocks(blocks: PartialBlock[]) { + for (const block of blocks) { + addIdsToBlock(block); + } +} diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-basic-block-types.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/basicBlockTypes.json similarity index 75% rename from packages/core/src/api/parsers/html/__snapshots__/parse-basic-block-types.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/basicBlockTypes.json index 66c01ba90c..1a9bd562f2 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-basic-block-types.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/basicBlockTypes.json @@ -1,142 +1,143 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 1", + "type": "text", + }, + ], "id": "1", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 1, "textAlignment": "left", - "level": 1 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 2", "type": "text", - "text": "Heading 1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 2, "textAlignment": "left", - "level": 2 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 3", "type": "text", - "text": "Heading 2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "3", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 3, "textAlignment": "left", - "level": 3 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Paragraph", "type": "text", - "text": "Heading 3", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "4", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Paragraph", - "styles": {} - } - ], - "children": [] + "type": "paragraph", }, { + "children": [], + "content": undefined, "id": "5", - "type": "image", "props": { "backgroundColor": "default", - "textAlignment": "left", - "name": "", - "url": "exampleURL", "caption": "Image Caption", + "name": "", + "previewWidth": 512, "showPreview": true, - "previewWidth": 512 + "textAlignment": "left", + "url": "exampleURL", }, - "children": [] + "type": "image", }, { - "id": "6", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "None ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Bold ", "styles": { - "bold": true - } + "bold": true, + }, + "text": "Bold ", + "type": "text", }, { - "type": "text", - "text": "Italic ", "styles": { - "italic": true - } + "italic": true, + }, + "text": "Italic ", + "type": "text", }, { - "type": "text", - "text": "Underline ", "styles": { - "underline": true - } + "underline": true, + }, + "text": "Underline ", + "type": "text", }, { - "type": "text", - "text": "Strikethrough ", "styles": { - "strike": true - } + "strike": true, + }, + "text": "Strikethrough ", + "type": "text", }, { - "type": "text", - "text": "All", "styles": { "bold": true, "italic": true, + "strike": true, "underline": true, - "strike": true - } - } + }, + "text": "All", + "type": "text", + }, ], - "children": [] - } + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/parse/__snapshots__/html/codeBlocks.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/codeBlocks.json new file mode 100644 index 0000000000..f9bd791440 --- /dev/null +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/codeBlocks.json @@ -0,0 +1,62 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "console.log("Should default to JS")", + "type": "text", + }, + ], + "id": "1", + "props": { + "language": "text", + }, + "type": "codeBlock", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "console.log("Should parse TS from data-language")", + "type": "text", + }, + ], + "id": "2", + "props": { + "language": "typescript", + }, + "type": "codeBlock", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "print("Should parse Python from language- class")", + "type": "text", + }, + ], + "id": "3", + "props": { + "language": "python", + }, + "type": "codeBlock", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "console.log("Should prioritize TS from data-language over language- class")", + "type": "text", + }, + ], + "id": "4", + "props": { + "language": "typescript", + }, + "type": "codeBlock", + }, +] \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-deep-nested-content.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/deepNestedContent.json similarity index 74% rename from packages/core/src/api/exporters/html/__snapshots__/paste/parse-deep-nested-content.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/deepNestedContent.json index ae11e36cb7..959dbbcd5a 100644 --- a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-deep-nested-content.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/deepNestedContent.json @@ -1,240 +1,243 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Outer 1 Div Before", + "type": "text", + }, + ], "id": "1", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": " Outer 2 Div Before", "type": "text", - "text": "Outer 1 Div Before", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": " Outer 3 Div Before", "type": "text", - "text": " Outer 2 Div Before", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "3", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": " Outer 4 Div Before", "type": "text", - "text": " Outer 3 Div Before", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "4", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 1", "type": "text", - "text": " Outer 4 Div Before", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "5", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 1, "textAlignment": "left", - "level": 1 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 2", "type": "text", - "text": "Heading 1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "6", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 2, "textAlignment": "left", - "level": 2 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 3", "type": "text", - "text": "Heading 2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "7", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 3, "textAlignment": "left", - "level": 3 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Paragraph", "type": "text", - "text": "Heading 3", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "8", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Paragraph", - "styles": {} - } - ], - "children": [] + "type": "paragraph", }, { + "children": [], + "content": undefined, "id": "9", - "type": "image", "props": { "backgroundColor": "default", + "caption": "Image Caption", + "name": "", + "previewWidth": 512, + "showPreview": true, "textAlignment": "left", "url": "exampleURL", - "caption": "Image Caption", - "width": 512 }, - "children": [] + "type": "image", }, { - "id": "10", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", - "text": "Bold", "styles": { - "bold": true - } + "bold": true, + }, + "text": "Bold", + "type": "text", }, { - "type": "text", + "styles": {}, "text": " ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Italic", "styles": { - "italic": true - } + "italic": true, + }, + "text": "Italic", + "type": "text", }, { - "type": "text", + "styles": {}, "text": " ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Underline", "styles": { - "underline": true - } + "underline": true, + }, + "text": "Underline", + "type": "text", }, { - "type": "text", + "styles": {}, "text": " ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Strikethrough", "styles": { - "strike": true - } + "strike": true, + }, + "text": "Strikethrough", + "type": "text", }, { - "type": "text", + "styles": {}, "text": " ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "All", "styles": { "bold": true, "italic": true, + "strike": true, "underline": true, - "strike": true - } - } + }, + "text": "All", + "type": "text", + }, ], - "children": [] - }, - { - "id": "11", - "type": "paragraph", + "id": "10", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": " Outer 4 Div After Outer 3 Div After Outer 2 Div After Outer 1 Div After", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "11", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-divs.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/divs.json similarity index 72% rename from packages/core/src/api/parsers/html/__snapshots__/parse-divs.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/divs.json index 764afd66ac..1e08669f16 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-divs.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/divs.json @@ -1,121 +1,121 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Single Div", + "type": "text", + }, + ], "id": "1", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": " Div", "type": "text", - "text": "Single Div", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Nested Div", "type": "text", - "text": " Div", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "3", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Div", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { "id": "4", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Single Div 2", "type": "text", - "text": "Nested Div", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "5", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Nested Div", "type": "text", - "text": "Single Div 2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "6", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Div", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { "id": "7", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Div", - "styles": {} - } - ], - "children": [] - } + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-fake-image-caption.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/fakeImageCaption.json similarity index 73% rename from packages/core/src/api/parsers/html/__snapshots__/parse-fake-image-caption.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/fakeImageCaption.json index 319d16a003..3964251638 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-fake-image-caption.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/fakeImageCaption.json @@ -1,33 +1,34 @@ [ { + "children": [], + "content": undefined, "id": "1", - "type": "image", "props": { "backgroundColor": "default", - "textAlignment": "left", - "name": "", - "url": "exampleURL", "caption": "", + "name": "", + "previewWidth": 512, "showPreview": true, - "previewWidth": 512 + "textAlignment": "left", + "url": "exampleURL", }, - "children": [] + "type": "image", }, { - "id": "2", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Image Caption", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/parse/__snapshots__/html/googleDocs.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/googleDocs.json new file mode 100644 index 0000000000..5a7912dcd1 --- /dev/null +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/googleDocs.json @@ -0,0 +1,579 @@ +[ + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Heading 1", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "level": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Heading 2", + "type": "text", + }, + ], + "id": "2", + "props": { + "backgroundColor": "default", + "level": 2, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Heading 3", + "type": "text", + }, + ], + "id": "3", + "props": { + "backgroundColor": "default", + "level": 3, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 2", + "type": "text", + }, + ], + "id": "5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 3", + "type": "text", + }, + ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph With +Hard Break", + "type": "text", + }, + ], + "id": "7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Bold", + "type": "text", + }, + { + "styles": {}, + "text": " ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "Italic", + "type": "text", + }, + { + "styles": {}, + "text": " Underline ", + "type": "text", + }, + { + "styles": { + "strike": true, + }, + "text": "Strikethrough", + "type": "text", + }, + { + "styles": {}, + "text": " ", + "type": "text", + }, + { + "styles": { + "bold": true, + "italic": true, + "strike": true, + }, + "text": "All", + "type": "text", + }, + ], + "id": "8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [ + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Nested Numbered List Item 1", + "type": "text", + }, + ], + "id": "11", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Nested Numbered List Item 2", + "type": "text", + }, + ], + "id": "12", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": " Nested Bullet List Item 1", + "type": "text", + }, + ], + "id": "10", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Nested Bullet List Item 2", + "type": "text", + }, + ], + "id": "13", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": " Bullet List Item 1", + "type": "text", + }, + ], + "id": "9", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Bullet List Item 2", + "type": "text", + }, + ], + "id": "14", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Numbered List Item 1", + "type": "text", + }, + ], + "id": "15", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Numbered List Item 2", + "type": "text", + }, + ], + "id": "16", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": undefined, + "id": "17", + "props": { + "backgroundColor": "default", + "caption": "", + "name": "", + "previewWidth": 447, + "showPreview": true, + "textAlignment": "left", + "url": "https://lh7-us.googleusercontent.com/SGyYp6hfLvNkli62NKFJB6NQz-fNa2Sjy8QxfUuqipW--qCCXmCz-dJmeZUGaDXIF9TEZHzbhNJsw4_w-B09eaFOn0oUChKsrSt3cwAIFu6d4SoSjHTR_DRTPr415_P7an7Lue-EwlUcVBk1WCzcoVQ", + }, + "type": "image", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " +", + "type": "text", + }, + ], + "id": "18", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": { + "columnWidths": [ + undefined, + undefined, + undefined, + ], + "headerCols": undefined, + "headerRows": undefined, + "rows": [ + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 1", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 2", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 3", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 4", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 5", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 6", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 7", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 8", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 9", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + ], + "type": "tableContent", + }, + "id": "19", + "props": { + "textColor": "default", + }, + "type": "table", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph", + "type": "text", + }, + ], + "id": "20", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " +", + "type": "text", + }, + ], + "id": "21", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-image-in-paragraph.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/imageInParagraph.json similarity index 74% rename from packages/core/src/api/parsers/html/__snapshots__/parse-image-in-paragraph.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/imageInParagraph.json index 1a581a00c3..28369c981f 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-image-in-paragraph.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/imageInParagraph.json @@ -1,16 +1,17 @@ [ { + "children": [], + "content": undefined, "id": "1", - "type": "image", "props": { "backgroundColor": "default", - "textAlignment": "left", - "name": "", - "url": "exampleURL", "caption": "", + "name": "", + "previewWidth": 512, "showPreview": true, - "previewWidth": 512 + "textAlignment": "left", + "url": "exampleURL", }, - "children": [] - } + "type": "image", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-div-with-inline-content.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/inlineContentAndNestedBlocks.json similarity index 73% rename from packages/core/src/api/exporters/html/__snapshots__/paste/parse-div-with-inline-content.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/inlineContentAndNestedBlocks.json index d06969a05f..b21c97408c 100644 --- a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-div-with-inline-content.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/inlineContentAndNestedBlocks.json @@ -1,91 +1,91 @@ [ { - "id": "1", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "None ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Bold ", "styles": { - "bold": true - } + "bold": true, + }, + "text": "Bold ", + "type": "text", }, { - "type": "text", - "text": "Italic ", "styles": { - "italic": true - } + "italic": true, + }, + "text": "Italic ", + "type": "text", }, { - "type": "text", - "text": "Underline ", "styles": { - "underline": true - } + "underline": true, + }, + "text": "Underline ", + "type": "text", }, { - "type": "text", - "text": "Strikethrough ", "styles": { - "strike": true - } + "strike": true, + }, + "text": "Strikethrough ", + "type": "text", }, { - "type": "text", - "text": "All", "styles": { "bold": true, "italic": true, + "strike": true, "underline": true, - "strike": true - } - } + }, + "text": "All", + "type": "text", + }, ], - "children": [] - }, - { - "id": "2", - "type": "paragraph", + "id": "1", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Div", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "3", - "type": "paragraph", + "id": "2", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Paragraph", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/list-test.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/lists.json similarity index 75% rename from packages/core/src/api/parsers/html/__snapshots__/list-test.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/lists.json index 67e64c4521..cdd50b6d47 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/list-test.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/lists.json @@ -1,177 +1,177 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "First", + "type": "text", + }, + ], "id": "1", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Second", "type": "text", - "text": "First", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Third", "type": "text", - "text": "Second", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "3", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Fourth", "type": "text", - "text": "Third", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "4", - "type": "checkListItem", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": false, "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "checkListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Fifth", "type": "text", - "text": "Fourth", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "5", - "type": "checkListItem", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": false, "textAlignment": "left", - "checked": false + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Fifth", - "styles": {} - } - ], - "children": [] + "type": "checkListItem", }, { - "id": "6", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Five Parent", - "styles": {} - } - ], "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Child 1", + "type": "text", + }, + ], "id": "7", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Child 2", "type": "text", - "text": "Child 1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "8", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Child 3", "type": "text", - "text": "Child 2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "9", - "type": "checkListItem", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": false, "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "checkListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Child 4", "type": "text", - "text": "Child 3", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "10", - "type": "checkListItem", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": false, "textAlignment": "left", - "checked": false + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Child 4", - "styles": {} - } - ], - "children": [] - } - ] - } + "type": "checkListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Five Parent", + "type": "text", + }, + ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-mixed-nested-lists.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/mixedNestedLists.json similarity index 76% rename from packages/core/src/api/parsers/html/__snapshots__/parse-mixed-nested-lists.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/mixedNestedLists.json index 26371dc417..5b79ba865f 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-mixed-nested-lists.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/mixedNestedLists.json @@ -1,265 +1,265 @@ [ { - "id": "1", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "2", - "type": "bulletListItem", + "id": "1", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], + "type": "bulletListItem", + }, + { "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item", + "type": "text", + }, + ], "id": "3", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Numbered List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { "id": "4", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Numbered List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "5", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "type": "numberedListItem", + }, + ], "content": [ { - "type": "text", + "styles": {}, "text": "Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "6", - "type": "numberedListItem", + "id": "2", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Bullet List Item", "type": "text", - "text": "Numbered List Item", - "styles": {} - } + }, ], - "children": [] - }, - { - "id": "7", - "type": "numberedListItem", + "id": "5", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Numbered List Item", - "styles": {} - } + "type": "text", + }, ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Check List Item", + "type": "text", + }, + ], "id": "8", - "type": "checkListItem", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": true, "textAlignment": "left", - "checked": true + "textColor": "default", }, + "type": "checkListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Check List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { "id": "9", - "type": "checkListItem", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": false, "textAlignment": "left", - "checked": false + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Check List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "10", - "type": "numberedListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "type": "checkListItem", + }, + ], "content": [ { - "type": "text", + "styles": {}, "text": "Numbered List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "11", - "type": "checkListItem", + "id": "7", "props": { - "textColor": "default", "backgroundColor": "default", "textAlignment": "left", - "checked": true + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Numbered List Item", "type": "text", - "text": "Check List Item", - "styles": {} - } + }, ], - "children": [] - }, - { - "id": "12", - "type": "checkListItem", + "id": "10", "props": { - "textColor": "default", "backgroundColor": "default", "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Check List Item", - "styles": {} - } + "type": "text", + }, ], + "id": "11", + "props": { + "backgroundColor": "default", + "checked": true, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item", + "type": "text", + }, + ], "id": "13", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { "id": "14", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Bullet List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "15", - "type": "checkListItem", + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Check List Item", + "type": "text", + }, + ], + "id": "12", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": false, "textAlignment": "left", - "checked": true + "textColor": "default", }, + "type": "checkListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Check List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "15", + "props": { + "backgroundColor": "default", + "checked": true, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, ] \ No newline at end of file diff --git a/tests/src/unit/core/formatConversion/parse/__snapshots__/html/nestedLists.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/nestedLists.json new file mode 100644 index 0000000000..061ca1c5bc --- /dev/null +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/nestedLists.json @@ -0,0 +1,265 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item", + "type": "text", + }, + ], + "id": "3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item", + "type": "text", + }, + ], + "id": "4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item", + "type": "text", + }, + ], + "id": "8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item", + "type": "text", + }, + ], + "id": "9", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], + "id": "7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], + "id": "10", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Check List Item", + "type": "text", + }, + ], + "id": "11", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Check List Item", + "type": "text", + }, + ], + "id": "13", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Check List Item", + "type": "text", + }, + ], + "id": "14", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Check List Item", + "type": "text", + }, + ], + "id": "12", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Check List Item", + "type": "text", + }, + ], + "id": "15", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, +] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-nested-lists-with-paragraphs.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/nestedListsWithParagraphs.json similarity index 76% rename from packages/core/src/api/parsers/html/__snapshots__/parse-nested-lists-with-paragraphs.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/nestedListsWithParagraphs.json index 0d3b65965d..055d8f7d31 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-nested-lists-with-paragraphs.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/nestedListsWithParagraphs.json @@ -1,265 +1,265 @@ [ { - "id": "1", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "2", - "type": "bulletListItem", + "id": "1", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], + "type": "bulletListItem", + }, + { "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item", + "type": "text", + }, + ], "id": "3", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { "id": "4", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Bullet List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "5", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "type": "bulletListItem", + }, + ], "content": [ { - "type": "text", + "styles": {}, "text": "Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "6", - "type": "numberedListItem", + "id": "2", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Bullet List Item", "type": "text", - "text": "Numbered List Item", - "styles": {} - } + }, ], - "children": [] - }, - { - "id": "7", - "type": "numberedListItem", + "id": "5", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Numbered List Item", - "styles": {} - } + "type": "text", + }, ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item", + "type": "text", + }, + ], "id": "8", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Numbered List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { "id": "9", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Numbered List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "10", - "type": "numberedListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "type": "numberedListItem", + }, + ], "content": [ { - "type": "text", + "styles": {}, "text": "Numbered List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "11", - "type": "checkListItem", + "id": "7", "props": { - "textColor": "default", "backgroundColor": "default", "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Numbered List Item", "type": "text", - "text": "Checked List Item", - "styles": {} - } + }, ], - "children": [] - }, - { - "id": "12", - "type": "checkListItem", + "id": "10", "props": { - "textColor": "default", "backgroundColor": "default", "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Checked List Item", - "styles": {} - } + "type": "text", + }, ], + "id": "11", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Checked List Item", + "type": "text", + }, + ], "id": "13", - "type": "checkListItem", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": false, "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "checkListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Checked List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { "id": "14", - "type": "checkListItem", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": false, "textAlignment": "left", - "checked": false + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Checked List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "15", - "type": "checkListItem", + "type": "checkListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Checked List Item", + "type": "text", + }, + ], + "id": "12", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": false, "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "checkListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Checked List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "15", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-notion-html.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/notion.json similarity index 75% rename from packages/core/src/api/parsers/html/__snapshots__/parse-notion-html.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/notion.json index b1ebb03e09..b1eb97dd2d 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-notion-html.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/notion.json @@ -1,565 +1,566 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 1", + "type": "text", + }, + ], "id": "1", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 1, "textAlignment": "left", - "level": 1 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 2", "type": "text", - "text": "Heading 1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 2, "textAlignment": "left", - "level": 2 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 3", "type": "text", - "text": "Heading 2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "3", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 3, "textAlignment": "left", - "level": 3 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Paragraph 1", "type": "text", - "text": "Heading 3", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "4", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Nested Paragraph 1", "type": "text", - "text": "Paragraph 1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "5", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Nested Paragraph 2", "type": "text", - "text": "Nested Paragraph 1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "6", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Paragraph With Hard Break", "type": "text", - "text": "Nested Paragraph 2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "7", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Paragraph With Hard Break", - "styles": {} - } - ], - "children": [] + "type": "paragraph", }, { - "id": "8", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", - "text": "Bold", "styles": { - "bold": true - } + "bold": true, + }, + "text": "Bold", + "type": "text", }, { - "type": "text", + "styles": {}, "text": " ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Italic", "styles": { - "italic": true - } + "italic": true, + }, + "text": "Italic", + "type": "text", }, { - "type": "text", + "styles": {}, "text": " Underline ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Strikethrough", "styles": { - "strike": true - } + "strike": true, + }, + "text": "Strikethrough", + "type": "text", }, { - "type": "text", + "styles": {}, "text": " ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "All", "styles": { "bold": true, "italic": true, - "strike": true - } - } + "strike": true, + }, + "text": "All", + "type": "text", + }, ], - "children": [] - }, - { - "id": "9", - "type": "bulletListItem", + "id": "8", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Bullet List Item 1", - "styles": {} - } - ], + "type": "paragraph", + }, + { "children": [ { - "id": "10", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Nested Bullet List Item 1", - "styles": {} - } - ], "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item 1", + "type": "text", + }, + ], "id": "11", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Nested Numbered List Item 2", "type": "text", - "text": "Nested Numbered List Item 1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "12", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Numbered List Item 2", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "13", - "type": "bulletListItem", + "type": "numberedListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item 1", + "type": "text", + }, + ], + "id": "10", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Bullet List Item 2", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } - ] + "id": "13", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Bullet List Item 1", + "type": "text", + }, + ], + "id": "9", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", }, { + "children": [], + "content": [ + { + "styles": {}, + "text": "Bullet List Item 2", + "type": "text", + }, + ], "id": "14", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Numbered List Item 1", "type": "text", - "text": "Bullet List Item 2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "15", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Numbered List Item 2", "type": "text", - "text": "Numbered List Item 1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "16", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Background Color Paragraph", "type": "text", - "text": "Numbered List Item 2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "17", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Background Color Paragraph", - "styles": {} - } - ], - "children": [] + "type": "paragraph", }, { - "id": "18", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "!", - "styles": {} + "type": "text", }, { - "type": "link", - "href": "https://www.pulsecarshalton.co.uk/wp-content/uploads/2016/08/jk-placeholder-image.jpg", "content": [ { - "type": "text", + "styles": {}, "text": "https://www.pulsecarshalton.co.uk/wp-content/uploads/2016/08/jk-placeholder-image.jpg", - "styles": {} - } - ] - } + "type": "text", + }, + ], + "href": "https://www.pulsecarshalton.co.uk/wp-content/uploads/2016/08/jk-placeholder-image.jpg", + "type": "link", + }, ], - "children": [] - }, - { - "id": "19", - "type": "table", + "id": "18", "props": { - "textColor": "default" + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": { - "type": "tableContent", "columnWidths": [ - null, - null, - null + undefined, + undefined, + undefined, ], + "headerCols": undefined, "headerRows": 1, "rows": [ { "cells": [ { - "type": "tableCell", "content": [ { - "type": "text", + "styles": {}, "text": "Cell 1", - "styles": {} - } + "type": "text", + }, ], "props": { + "backgroundColor": "default", "colspan": 1, "rowspan": 1, - "backgroundColor": "default", + "textAlignment": "left", "textColor": "default", - "textAlignment": "left" - } + }, + "type": "tableCell", }, { - "type": "tableCell", "content": [ { - "type": "text", + "styles": {}, "text": "Cell 2", - "styles": {} - } + "type": "text", + }, ], "props": { + "backgroundColor": "default", "colspan": 1, "rowspan": 1, - "backgroundColor": "default", + "textAlignment": "left", "textColor": "default", - "textAlignment": "left" - } + }, + "type": "tableCell", }, { - "type": "tableCell", "content": [ { - "type": "text", + "styles": {}, "text": "Cell 3", - "styles": {} - } + "type": "text", + }, ], "props": { + "backgroundColor": "default", "colspan": 1, "rowspan": 1, - "backgroundColor": "default", + "textAlignment": "left", "textColor": "default", - "textAlignment": "left" - } - } - ] + }, + "type": "tableCell", + }, + ], }, { "cells": [ { - "type": "tableCell", "content": [ { - "type": "text", + "styles": {}, "text": "Cell 4", - "styles": {} - } + "type": "text", + }, ], "props": { + "backgroundColor": "default", "colspan": 1, "rowspan": 1, - "backgroundColor": "default", + "textAlignment": "left", "textColor": "default", - "textAlignment": "left" - } + }, + "type": "tableCell", }, { - "type": "tableCell", "content": [ { - "type": "text", + "styles": {}, "text": "Cell 5", - "styles": {} - } + "type": "text", + }, ], "props": { + "backgroundColor": "default", "colspan": 1, "rowspan": 1, - "backgroundColor": "default", + "textAlignment": "left", "textColor": "default", - "textAlignment": "left" - } + }, + "type": "tableCell", }, { - "type": "tableCell", "content": [ { - "type": "text", + "styles": {}, "text": "Cell 6", - "styles": {} - } + "type": "text", + }, ], "props": { + "backgroundColor": "default", "colspan": 1, "rowspan": 1, - "backgroundColor": "default", + "textAlignment": "left", "textColor": "default", - "textAlignment": "left" - } - } - ] + }, + "type": "tableCell", + }, + ], }, { "cells": [ { - "type": "tableCell", "content": [ { - "type": "text", + "styles": {}, "text": "Cell 7", - "styles": {} - } + "type": "text", + }, ], "props": { + "backgroundColor": "default", "colspan": 1, "rowspan": 1, - "backgroundColor": "default", + "textAlignment": "left", "textColor": "default", - "textAlignment": "left" - } + }, + "type": "tableCell", }, { - "type": "tableCell", "content": [ { - "type": "text", + "styles": {}, "text": "Cell 8", - "styles": {} - } + "type": "text", + }, ], "props": { + "backgroundColor": "default", "colspan": 1, "rowspan": 1, - "backgroundColor": "default", + "textAlignment": "left", "textColor": "default", - "textAlignment": "left" - } + }, + "type": "tableCell", }, { - "type": "tableCell", "content": [ { - "type": "text", + "styles": {}, "text": "Cell 9", - "styles": {} - } + "type": "text", + }, ], "props": { + "backgroundColor": "default", "colspan": 1, "rowspan": 1, - "backgroundColor": "default", + "textAlignment": "left", "textColor": "default", - "textAlignment": "left" - } - } - ] - } - ] + }, + "type": "tableCell", + }, + ], + }, + ], + "type": "tableContent", }, - "children": [] - }, - { - "id": "20", - "type": "paragraph", + "id": "19", "props": { "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" }, + "type": "table", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Paragraph", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "20", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-two-divs.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/twoDivs.json similarity index 72% rename from packages/core/src/api/parsers/html/__snapshots__/parse-two-divs.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/twoDivs.json index aa21de34f0..e91570e36b 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-two-divs.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/twoDivs.json @@ -1,36 +1,36 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Single Div", + "type": "text", + }, + ], "id": "1", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "second Div", "type": "text", - "text": "Single Div", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "second Div", - "styles": {} - } - ], - "children": [] - } + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/twoTables.json similarity index 71% rename from packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html rename to tests/src/unit/core/formatConversion/parse/__snapshots__/html/twoTables.json index 0a607ca98c..3ffbb3ead1 100644 --- a/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraph.html +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/html/twoTables.json @@ -1,27 +1,9 @@ [ - { - "children": [], - "content": [ - { - "styles": {}, - "text": "ParagraphParagraph", - "type": "text", - }, - ], - "id": "0", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, { "children": [], "content": { "columnWidths": [ undefined, - undefined, ], "headerCols": undefined, "headerRows": undefined, @@ -31,8 +13,10 @@ { "content": [ { - "styles": {}, - "text": "Table Cell", + "styles": { + "underline": true, + }, + "text": "Company", "type": "text", }, ], @@ -45,11 +29,25 @@ }, "type": "tableCell", }, + ], + }, + { + "cells": [ { "content": [ + { + "styles": { + "bold": true, + }, + "text": "Example Company Inc.", + "type": "text", + }, { "styles": {}, - "text": "Table Cell", + "text": " + +Name: [Company Representative] +Title: Chief Executive Officer", "type": "text", }, ], @@ -64,13 +62,33 @@ }, ], }, + ], + "type": "tableContent", + }, + "id": "1", + "props": { + "textColor": "default", + }, + "type": "table", + }, + { + "children": [], + "content": { + "columnWidths": [ + undefined, + ], + "headerCols": undefined, + "headerRows": undefined, + "rows": [ { "cells": [ { "content": [ { - "styles": {}, - "text": "Table Cell", + "styles": { + "underline": true, + }, + "text": "Advisor", "type": "text", }, ], @@ -83,11 +101,15 @@ }, "type": "tableCell", }, + ], + }, + { + "cells": [ { "content": [ { "styles": {}, - "text": "Table Cell", + "text": "[Advisor Name]", "type": "text", }, ], @@ -105,34 +127,10 @@ ], "type": "tableContent", }, - "id": "1", - "props": { - "textColor": "default", - }, - "type": "table", - }, - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Custom Paragraph", - "type": "text", - }, - ], "id": "2", - "props": {}, - "type": "customParagraph", - }, - { - "children": [], - "content": [], - "id": "3", "props": { - "backgroundColor": "default", - "textAlignment": "left", "textColor": "default", }, - "type": "paragraph", + "type": "table", }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/non-nested.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/basic.json similarity index 74% rename from packages/core/src/api/parsers/markdown/__snapshots__/non-nested.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/basic.json index 05911c4983..632e74dcb7 100644 --- a/packages/core/src/api/parsers/markdown/__snapshots__/non-nested.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/basic.json @@ -1,71 +1,71 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading", + "type": "text", + }, + ], "id": "1", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 1, "textAlignment": "left", - "level": 1 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Paragraph", "type": "text", - "text": "Heading", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Bullet List Item", "type": "text", - "text": "Paragraph", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "3", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Numbered List Item", "type": "text", - "text": "Bullet List Item", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "4", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Numbered List Item", - "styles": {} - } - ], - "children": [] - } + "type": "numberedListItem", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/whitespace bold.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/boldWithWhitespace.json similarity index 73% rename from packages/core/src/api/parsers/markdown/__snapshots__/whitespace bold.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/boldWithWhitespace.json index 0fafd59cb1..3331f6218a 100644 --- a/packages/core/src/api/parsers/markdown/__snapshots__/whitespace bold.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/boldWithWhitespace.json @@ -1,19 +1,19 @@ [ { - "id": "1", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "hello **beautiful ** world", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/complex.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/complex.json similarity index 74% rename from packages/core/src/api/parsers/markdown/__snapshots__/complex.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/complex.json index 37036e205d..81ac21d79a 100644 --- a/packages/core/src/api/parsers/markdown/__snapshots__/complex.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/complex.json @@ -1,353 +1,353 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 1", + "type": "text", + }, + ], "id": "1", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 1, "textAlignment": "left", - "level": 1 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 2", "type": "text", - "text": "Heading 1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 2, "textAlignment": "left", - "level": 2 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 3", "type": "text", - "text": "Heading 2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "3", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 3, "textAlignment": "left", - "level": 3 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Paragraph", "type": "text", - "text": "Heading 3", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "4", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Paragraph", - "styles": {} - } - ], - "children": [] + "type": "paragraph", }, { - "id": "5", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "P", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "ara", "styles": { - "bold": true - } + "bold": true, + }, + "text": "ara", + "type": "text", }, { - "type": "text", - "text": "grap", "styles": { - "italic": true - } + "italic": true, + }, + "text": "grap", + "type": "text", }, { - "type": "text", + "styles": {}, "text": "h", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "6", - "type": "paragraph", + "id": "5", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "P", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "ara", "styles": { - "italic": true - } + "italic": true, + }, + "text": "ara", + "type": "text", }, { - "type": "text", - "text": "grap", "styles": { - "strike": true - } + "strike": true, + }, + "text": "grap", + "type": "text", }, { - "type": "text", + "styles": {}, "text": "h", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "7", - "type": "bulletListItem", + "id": "6", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "8", - "type": "bulletListItem", + "id": "7", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], + "type": "bulletListItem", + }, + { "children": [ { - "id": "9", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], "children": [ { - "id": "10", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } - ] - }, - { - "id": "11", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "id": "10", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + ], "content": [ { + "styles": {}, + "text": "Bullet List Item", "type": "text", - "text": "Paragraph", - "styles": {} - } + }, ], + "id": "9", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], "id": "12", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Numbered List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { "id": "13", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], + "id": "15", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + ], "content": [ { - "type": "text", + "styles": {}, "text": "Numbered List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { "id": "14", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Bullet List Item", "type": "text", - "text": "Numbered List Item", - "styles": {} - } + }, ], - "children": [ - { - "id": "15", - "type": "numberedListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Numbered List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { "id": "16", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "17", - "type": "bulletListItem", + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Paragraph", + "type": "text", + }, + ], + "id": "11", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } - ] - }, - { - "id": "18", - "type": "bulletListItem", + "id": "17", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "8", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "18", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/issue-226-1.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/issue226case1.json similarity index 74% rename from packages/core/src/api/parsers/markdown/__snapshots__/issue-226-1.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/issue226case1.json index 9c186d37b0..8ca8b088a3 100644 --- a/packages/core/src/api/parsers/markdown/__snapshots__/issue-226-1.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/issue226case1.json @@ -1,71 +1,71 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "📝 item1", + "type": "text", + }, + ], "id": "1", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "⚙️ item2", "type": "text", - "text": "📝 item1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "🔗 item3", "type": "text", - "text": "⚙️ item2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "3", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "h1", "type": "text", - "text": "🔗 item3", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "4", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 1, "textAlignment": "left", - "level": 1 + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "h1", - "styles": {} - } - ], - "children": [] - } + "type": "heading", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/issue-226-2.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/issue226case2.json similarity index 73% rename from packages/core/src/api/parsers/markdown/__snapshots__/issue-226-2.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/issue226case2.json index fc1b9f3de9..e0939c1645 100644 --- a/packages/core/src/api/parsers/markdown/__snapshots__/issue-226-2.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/issue226case2.json @@ -1,144 +1,144 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "a", + "type": "text", + }, + ], "id": "1", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "b", "type": "text", - "text": "a", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "c", "type": "text", - "text": "b", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "3", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "d", "type": "text", - "text": "c", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "4", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "anything", "type": "text", - "text": "d", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "5", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "anything", - "styles": {} - } - ], - "children": [] + "type": "paragraph", }, { - "id": "6", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "link", - "href": "http://example.com", "content": [ { - "type": "text", + "styles": {}, "text": "a link", - "styles": {} - } - ] - } + "type": "text", + }, + ], + "href": "http://example.com", + "type": "link", + }, ], - "children": [] - }, - { - "id": "7", - "type": "bulletListItem", + "id": "6", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "another", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "8", - "type": "bulletListItem", + "id": "7", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "list", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/nested.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/nested.json similarity index 75% rename from packages/core/src/api/parsers/markdown/__snapshots__/nested.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/nested.json index 627349f4f8..df04f955b6 100644 --- a/packages/core/src/api/parsers/markdown/__snapshots__/nested.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/nested.json @@ -1,72 +1,72 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading", + "type": "text", + }, + ], "id": "1", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 1, "textAlignment": "left", - "level": 1 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Paragraph", "type": "text", - "text": "Heading", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Paragraph", - "styles": {} - } - ], - "children": [] + "type": "paragraph", }, { - "id": "3", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], "children": [ { - "id": "4", - "type": "numberedListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Numbered List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } - ] - } + "id": "4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/styled.json b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/styled.json similarity index 72% rename from packages/core/src/api/parsers/markdown/__snapshots__/styled.json rename to tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/styled.json index 43a1efe52d..a2c32954d5 100644 --- a/packages/core/src/api/parsers/markdown/__snapshots__/styled.json +++ b/tests/src/unit/core/formatConversion/parse/__snapshots__/markdown/styled.json @@ -1,58 +1,58 @@ [ { - "id": "1", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", - "text": "Bold", "styles": { - "bold": true - } + "bold": true, + }, + "text": "Bold", + "type": "text", }, { - "type": "text", + "styles": {}, "text": " ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Italic", "styles": { - "italic": true - } + "italic": true, + }, + "text": "Italic", + "type": "text", }, { - "type": "text", + "styles": {}, "text": " ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Strikethrough", "styles": { - "strike": true - } + "strike": true, + }, + "text": "Strikethrough", + "type": "text", }, { - "type": "text", + "styles": {}, "text": " ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Multiple", "styles": { "bold": true, - "italic": true - } - } + "italic": true, + }, + "text": "Multiple", + "type": "text", + }, ], - "children": [] - } + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/parseHTML.test.ts b/tests/src/unit/core/formatConversion/parse/parseTestInstances.ts similarity index 64% rename from packages/core/src/api/parsers/html/parseHTML.test.ts rename to tests/src/unit/core/formatConversion/parse/parseTestInstances.ts index 0f5699b4aa..1953d1ca75 100644 --- a/packages/core/src/api/parsers/html/parseHTML.test.ts +++ b/tests/src/unit/core/formatConversion/parse/parseTestInstances.ts @@ -1,356 +1,320 @@ -import * as pmView from "prosemirror-view"; -import { describe, expect, it } from "vitest"; -import { BlockNoteEditor } from "../../../index.js"; -import { nestedListsToBlockNoteStructure } from "./util/nestedLists.js"; - -async function parseHTMLAndCompareSnapshots( - html: string, - snapshotName: string -) { - const editor = BlockNoteEditor.create(); - const div = document.createElement("div"); - editor.mount(div); - const blocks = await editor.tryParseHTMLToBlocks(html); - - const snapshotPath = "./__snapshots__/" + snapshotName + ".json"; - await expect(JSON.stringify(blocks, undefined, 2)).toMatchFileSnapshot( - snapshotPath - ); - - // Now, we also want to test actually pasting in the editor, and not just calling - // tryParseHTMLToBlocks directly. - // The reason is that the prosemirror logic for pasting can be a bit different, because - // it's related to the context of where the user is pasting exactly (selection) - // - // The internal difference come that in tryParseHTMLToBlocks, we use DOMParser.parse, - // while when pasting, Prosemirror uses DOMParser.parseSlice, and then tries to fit the - // slice in the document. This fitting might change the structure / interpretation of the pasted blocks - - // Simulate a paste event (this uses DOMParser.parseSlice internally) - - (window as any).__TEST_OPTIONS.mockID = 0; // reset id counter - const htmlNode = nestedListsToBlockNoteStructure(html); - - editor.transact((tr) => { - const slice = (pmView as any).__parseFromClipboard( - editor.prosemirrorView, - "", - htmlNode.innerHTML, - false, - tr.selection.$from - ); - tr.replaceSelection(slice); - }); - - // alternative paste simulation doesn't work in a non-browser vitest env - // editor._tiptapEditor.view.pasteHTML(html, { - // preventDefault: () => { - // // noop - // }, - // clipboardData: { - // types: ["text/html"], - // getData: () => html, - // }, - // } as any); - - const pastedBlocks = editor.document; - pastedBlocks.pop(); // trailing paragraph - expect(pastedBlocks).toStrictEqual(blocks); - - editor.mount(undefined); -} - -describe("Parse HTML", () => { - it("Parse basic block types", async () => { - const html = `

Heading 1

-

Heading 2

-

Heading 3

-

Paragraph

-
Image Caption
-

None Bold Italic Underline Strikethrough All

`; - - await parseHTMLAndCompareSnapshots(html, "parse-basic-block-types"); - }); - - it("list test", async () => { - const html = `
    -
  • First
  • -
  • Second
  • -
  • Third
  • -
  • - - Fourth -
  • -
  • - - Fifth -
  • -
  • Five Parent -
      -
    • Child 1
    • -
    • Child 2
    • -
    • - - Child 3 -
    • -
    • - - Child 4 -
    • -
    -
  • -
`; - await parseHTMLAndCompareSnapshots(html, "list-test"); - }); - - it("Parse nested lists", async () => { - const html = `
    -
  • Bullet List Item
  • -
  • Bullet List Item -
      -
    • Nested Bullet List Item
    • -
    • Nested Bullet List Item
    • -
    -
  • -
  • Bullet List Item
  • -
-
    -
  1. Numbered List Item
  2. -
  3. Numbered List Item -
      -
    1. Nested Numbered List Item
    2. -
    3. Nested Numbered List Item
    4. -
    -
  4. -
  5. Numbered List Item
  6. -
-
    -
  • - - Check List Item -
  • -
  • - - Check List Item -
      -
    • - - Nested Check List Item -
    • -
    • - - Nested Check List Item -
    • -
    -
  • -
  • - - Nested Check List Item -
  • -
`; - - await parseHTMLAndCompareSnapshots(html, "parse-nested-lists"); - }); - - it("Parse nested lists with paragraphs", async () => { - const html = `
    -
  • -

    Bullet List Item

    -
  • -
  • -

    Bullet List Item

    -
      -
    • -

      Nested Bullet List Item

      -
    • -
    • -

      Nested Bullet List Item

      -
    • -
    -
  • -
  • -

    Bullet List Item

    -
  • -
-
    -
  1. -

    Numbered List Item

    -
  2. -
  3. -

    Numbered List Item

    -
      -
    1. -

      Nested Numbered List Item

      -
    2. -
    3. -

      Nested Numbered List Item

      -
    4. -
    -
  4. -
  5. -

    Numbered List Item

    -
  6. -
+import { ParseTestCase } from "../../../shared/formatConversion/parse/parseTestCase.js"; +import { + testParseHTML, + testParseMarkdown, +} from "../../../shared/formatConversion/parse/parseTestExecutors.js"; +import { TestInstance } from "../../../types.js"; +import { + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema, +} from "../../testSchema.js"; + +export const parseTestInstancesHTML: TestInstance< + ParseTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = [ + { + testCase: { + name: "basicBlockTypes", + content: `

Heading 1

+

Heading 2

+

Heading 3

+

Paragraph

+
Image Caption
+

None Bold Italic Underline Strikethrough All

`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "lists", + content: `
    +
  • First
  • +
  • Second
  • +
  • Third
  • +
  • + + Fourth +
  • +
  • + + Fifth +
  • +
  • Five Parent
      +
    • Child 1
    • +
    • Child 2
    • -

      Checked List Item

      -
    • -
    • - -

      Checked List Item

      -
        -
      • - -

        Nested Checked List Item

        -
      • -
      • - -

        Nested Checked List Item

        -
      • -
      + Child 3
    • -

      Checked List Item

      + Child 4
    • -
    `; - - await parseHTMLAndCompareSnapshots( - html, - "parse-nested-lists-with-paragraphs" - ); - }); - - it("Parse mixed nested lists", async () => { - const html = `
      -
    • Bullet List Item
    • -
    • Bullet List Item -
        -
      1. Nested Numbered List Item
      2. -
      3. Nested Numbered List Item
      4. -
      -
    • -
    • Bullet List Item
    -
      -
    1. Numbered List Item
    2. -
    3. Numbered List Item -
        -
      • - - Nested Check List Item -
      • -
      • - - Nested Check List Item -
      • -
      -
    4. -
    5. Numbered List Item
    6. -
    -
      -
    • - - Check List Item -
    • -
    • - - Check List Item -
        -
      • Nested Bullet List Item
      • -
      • Nested Bullet List Item
      • -
      -
    • -
    • - - Nested Check List Item -
    • -
    `; - - await parseHTMLAndCompareSnapshots(html, "parse-mixed-nested-lists"); - }); - - it("Parse divs", async () => { - const html = `
    Single Div
    -
    - Div -
    Nested Div
    -
    Nested Div
    -
    -
    Single Div 2
    +
  • +
`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "nestedLists", + content: `
    +
  • Bullet List Item
  • +
  • Bullet List Item +
      +
    • Nested Bullet List Item
    • +
    • Nested Bullet List Item
    • +
    +
  • +
  • Bullet List Item
  • +
+
    +
  1. Numbered List Item
  2. +
  3. Numbered List Item +
      +
    1. Nested Numbered List Item
    2. +
    3. Nested Numbered List Item
    4. +
    +
  4. +
  5. Numbered List Item
  6. +
+
    +
  • + + Check List Item +
  • +
  • + + Check List Item +
      +
    • + + Nested Check List Item +
    • +
    • + + Nested Check List Item +
    • +
    +
  • +
  • + + Nested Check List Item +
  • +
`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "nestedListsWithParagraphs", + content: `
    +
  • +

    Bullet List Item

    +
  • +
  • +

    Bullet List Item

    +
      +
    • +

      Nested Bullet List Item

      +
    • +
    • +

      Nested Bullet List Item

      +
    • +
    +
  • +
  • +

    Bullet List Item

    +
  • +
+
    +
  1. +

    Numbered List Item

    +
  2. +
  3. +

    Numbered List Item

    +
      +
    1. +

      Nested Numbered List Item

      +
    2. +
    3. +

      Nested Numbered List Item

      +
    4. +
    +
  4. +
  5. +

    Numbered List Item

    +
  6. +
+
    +
  • + +

    Checked List Item

    +
  • +
  • + +

    Checked List Item

    +
      +
    • + +

      Nested Checked List Item

      +
    • +
    • + +

      Nested Checked List Item

      +
    • +
    +
  • +
  • + +

    Checked List Item

    +
  • +
`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "mixedNestedLists", + content: `
    +
  • Bullet List Item
  • +
  • Bullet List Item +
      +
    1. Nested Numbered List Item
    2. +
    3. Nested Numbered List Item
    4. +
    +
  • +
  • Bullet List Item
  • +
+
    +
  1. Numbered List Item
  2. +
  3. Numbered List Item +
      +
    • + + Nested Check List Item +
    • +
    • + + Nested Check List Item +
    • +
    +
  4. +
  5. Numbered List Item
  6. +
+
    +
  • + + Check List Item +
  • +
  • + + Check List Item +
      +
    • Nested Bullet List Item
    • +
    • Nested Bullet List Item
    • +
    +
  • +
  • + + Nested Check List Item +
  • +
`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "divs", + content: `
Single Div
+
+ Div +
Nested Div
+
Nested Div
+
+
Single Div 2
+
+
Nested Div
+
Nested Div
+
`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "twoDivs", + content: `
Single Div
second Div
`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "imageInParagraph", + content: `

+ +

`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "fakeImageCaption", + content: `
+ +

Image Caption

+
`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "deepNestedContent", + content: `
+ Outer 1 Div Before
-
Nested Div
-
Nested Div
-
`; - - await parseHTMLAndCompareSnapshots(html, "parse-divs"); - }); - - it("Parse two divs", async () => { - const html = `
Single Div
second Div
`; - - await parseHTMLAndCompareSnapshots(html, "parse-two-divs"); - }); - - it("Parse image in paragraph", async () => { - const html = `

- -

`; - - await parseHTMLAndCompareSnapshots(html, "parse-image-in-paragraph"); - }); - - it("Parse fake image caption", async () => { - const html = `
- -

Image Caption

-
`; - - await parseHTMLAndCompareSnapshots(html, "parse-fake-image-caption"); - }); - - // TODO: this one fails - it.skip("Parse deep nested content", async () => { - const html = `
- Outer 1 Div Before + Outer 2 Div Before
- Outer 2 Div Before + Outer 3 Div Before
- Outer 3 Div Before -
- Outer 4 Div Before -

Heading 1

-

Heading 2

-

Heading 3

-

Paragraph

-
Image Caption
-

Bold Italic Underline Strikethrough All

- Outer 4 Div After -
- Outer 3 Div After + Outer 4 Div Before +

Heading 1

+

Heading 2

+

Heading 3

+

Paragraph

+
Image Caption
+

Bold Italic Underline Strikethrough All

+ Outer 4 Div After
- Outer 2 Div After + Outer 3 Div After
- Outer 1 Div After -
`; - - await parseHTMLAndCompareSnapshots(html, "parse-deep-nested-content"); - }); - - it("Parse div with inline content and nested blocks", async () => { - const html = `
- None Bold Italic Underline Strikethrough All -
Nested Div
-

Nested Paragraph

-
`; - - await parseHTMLAndCompareSnapshots(html, "parse-div-with-inline-content"); - }); - - it("Parses 2 tables", async () => { - const html = ` - + Outer 2 Div After + + Outer 1 Div After +`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "inlineContentAndNestedBlocks", + content: `
+ None Bold Italic Underline Strikethrough All +
Nested Div
+

Nested Paragraph

+
`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "twoTables", + content: `
-

Company

@@ -378,21 +342,14 @@ describe("Parse HTML", () => {

[Advisor Name]

`; - - await parseHTMLAndCompareSnapshots(html, "parse-2-tables"); - }); - - it("Parse Notion HTML", async () => { - // A few notes on Notion output HTML: - // - Does not preserve text/background colors - // - Does not preserve non-list-item block nesting - // - Hard breaks are represented using white space, not `
` elements - // - Images are converted to links with a "!" at the start - // - Cells in first row of a table are converted to `th` elements, regardless - // of if the row is set as a header row - - const html = `

Heading 1

+`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "notion", + content: `

Heading 1

Heading 2

Heading 3

Paragraph 1

@@ -443,22 +400,14 @@ With Hard Break

Paragraph

-`; - - await parseHTMLAndCompareSnapshots(html, "parse-notion-html"); - }); - - // Currently breaking, seems related to parsing `
` elements - it.skip("Parse Google Docs HTML", async () => { - // A few notes on Google Docs output HTML: - // - All inline markup is represented as `` elements with inline - // styles (bold, italic, etc.) - // - The nested list structure is not valid, i.e. `
    ` elements are not - // placed within `
  • ` elements - // - Images are wrapped in two spans and a paragraph - // - Everything is nested within a `` element - - const html = ` +`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "googleDocs", + content: `

    Heading 1

    @@ -549,17 +498,139 @@ With Hard Break

Paragraph

-
`; - - await parseHTMLAndCompareSnapshots(html, "parse-google-docs-html"); - }); - - it("Parse codeblocks", async () => { - const html = `
console.log("Should default to JS")
-
console.log("Should parse TS from data-language")
-
print("Should parse Python from language- class")
-
console.log("Should prioritize TS from data-language over language- class")
`; - - await parseHTMLAndCompareSnapshots(html, "parse-codeblocks"); - }); -}); +
`, + }, + executeTest: testParseHTML, + }, + { + testCase: { + name: "codeBlocks", + content: `
console.log("Should default to JS")
+
console.log("Should parse TS from data-language")
+
print("Should parse Python from language- class")
+
console.log("Should prioritize TS from data-language over language- class")
`, + }, + executeTest: testParseHTML, + }, +]; + +export const parseTestInstancesMarkdown: TestInstance< + ParseTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = [ + { + testCase: { + name: "basic", + content: `# Heading + +Paragraph + +* Bullet List Item + +1. Numbered List Item +`, + }, + executeTest: testParseMarkdown, + }, + { + testCase: { + name: "nested", + content: `# Heading + +Paragraph + +* Bullet List Item + + 1. Numbered List Item +`, + }, + executeTest: testParseMarkdown, + }, + { + testCase: { + name: "styled", + content: `**Bold** *Italic* ~~Strikethrough~~ ***Multiple***`, + }, + executeTest: testParseMarkdown, + }, + { + testCase: { + name: "complex", + content: `# Heading 1 + +## Heading 2 + +### Heading 3 + +Paragraph + +P**ara***grap*h + +P*ara*~~grap~~h + +* Bullet List Item + +* Bullet List Item + + * Bullet List Item + + * Bullet List Item + + Paragraph + + 1. Numbered List Item + + 2. Numbered List Item + + 3. Numbered List Item + + 1. Numbered List Item + + * Bullet List Item + + * Bullet List Item + +* Bullet List Item`, + }, + executeTest: testParseMarkdown, + }, + { + testCase: { + name: "boldWithWhitespace", + content: `hello **beautiful ** world`, + }, + executeTest: testParseMarkdown, + }, + { + testCase: { + name: "issue226case1", + content: ` +- 📝 item1 +- ⚙️ item2 +- 🔗 item3 + +# h1 +`, + }, + executeTest: testParseMarkdown, + }, + { + testCase: { + name: "issue226case2", + content: `* a +* b +* c +* d + +anything + +[a link](http://example.com) + +* another +* list`, + }, + executeTest: testParseMarkdown, + }, +]; diff --git a/tests/src/unit/core/formatConversion/parse/runTests.test.ts b/tests/src/unit/core/formatConversion/parse/runTests.test.ts new file mode 100644 index 0000000000..dd87c5fa03 --- /dev/null +++ b/tests/src/unit/core/formatConversion/parse/runTests.test.ts @@ -0,0 +1,32 @@ +import { describe, it } from "vitest"; + +import { setupTestEditor } from "../../setupTestEditor.js"; +import { testSchema } from "../../testSchema.js"; +import { + parseTestInstancesHTML, + parseTestInstancesMarkdown, +} from "./parseTestInstances.js"; + +// Tests for verifying that importing blocks from other formats works as +// expected. Used for specific cases for when content from outside the editor is +// imported as blocks. This includes content from other editors, as well as +// content from the web that has produced bugs in the past. +describe("Parse tests (HTML)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of parseTestInstancesHTML) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); + +describe("Parse tests (Markdown)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of parseTestInstancesMarkdown) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); diff --git a/tests/src/unit/core/setupTestEditor.ts b/tests/src/unit/core/setupTestEditor.ts new file mode 100644 index 0000000000..5df422680a --- /dev/null +++ b/tests/src/unit/core/setupTestEditor.ts @@ -0,0 +1,56 @@ +import { + BlockNoteEditor, + BlockNoteSchema, + BlockSchema, + initializeESMDependencies, + InlineContentSchema, + StyleSchema, + uploadToTmpFilesDotOrg_DEV_ONLY, +} from "@blocknote/core"; +import { afterAll, beforeAll } from "vitest"; + +export const setupTestEditor = < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + schema: BlockNoteSchema +): (() => BlockNoteEditor) => { + let editor: BlockNoteEditor; + const div = document.createElement("div"); + + beforeAll(async () => { + (window as any).__TEST_OPTIONS = (window as any).__TEST_OPTIONS || {}; + + editor = BlockNoteEditor.create({ + codeBlock: { + supportedLanguages: { + javascript: { + name: "JavaScript", + aliases: ["js"], + }, + python: { + name: "Python", + aliases: ["py"], + }, + }, + }, + schema, + trailingBlock: false, + uploadFile: uploadToTmpFilesDotOrg_DEV_ONLY, + }); + editor.mount(div); + + await initializeESMDependencies(); + }); + + afterAll(() => { + editor.mount(undefined); + editor._tiptapEditor.destroy(); + editor = undefined as any; + + delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS; + }); + + return () => editor; +}; diff --git a/tests/src/unit/core/testSchema.ts b/tests/src/unit/core/testSchema.ts new file mode 100644 index 0000000000..e6a566f630 --- /dev/null +++ b/tests/src/unit/core/testSchema.ts @@ -0,0 +1,183 @@ +import { + BlockNoteSchema, + createBlockSpec, + createInlineContentSpec, + createStyleSpec, + defaultBlockSpecs, + defaultInlineContentSpecs, + defaultProps, + defaultStyleSpecs, + imagePropSchema, + imageRender, + PageBreak, +} from "@blocknote/core"; + +// BLOCKS ---------------------------------------------------------------------- + +// This is a modified version of the default image block that does not implement +// a `toExternalHTML` function. It's used to test if the custom serializer by +// default serializes custom blocks using their `render` function. +const SimpleImage = createBlockSpec( + { + type: "simpleImage", + propSchema: imagePropSchema, + content: "none", + }, + { + render: (block, editor) => imageRender(block as any, editor as any), + } +); + +const CustomParagraph = createBlockSpec( + { + type: "customParagraph", + propSchema: defaultProps, + content: "inline", + }, + { + render: () => { + const paragraph = document.createElement("p"); + paragraph.className = "custom-paragraph"; + + return { + dom: paragraph, + contentDOM: paragraph, + }; + }, + toExternalHTML: () => { + const paragraph = document.createElement("p"); + paragraph.className = "custom-paragraph"; + paragraph.innerHTML = "Hello World"; + + return { + dom: paragraph, + }; + }, + } +); + +const SimpleCustomParagraph = createBlockSpec( + { + type: "simpleCustomParagraph", + propSchema: defaultProps, + content: "inline", + }, + { + render: () => { + const paragraph = document.createElement("p"); + paragraph.className = "simple-custom-paragraph"; + + return { + dom: paragraph, + contentDOM: paragraph, + }; + }, + } +); + +// INLINE CONTENT -------------------------------------------------------------- + +const Mention = createInlineContentSpec( + { + type: "mention", + propSchema: { + user: { + default: "", + }, + }, + content: "none", + }, + { + render: (ic) => { + const dom = document.createElement("span"); + dom.appendChild(document.createTextNode("@" + ic.props.user)); + + return { + dom, + }; + }, + } +); + +const Tag = createInlineContentSpec( + { + type: "tag" as const, + propSchema: {}, + content: "styled", + }, + { + render: () => { + const dom = document.createElement("span"); + dom.textContent = "#"; + + const contentDOM = document.createElement("span"); + dom.appendChild(contentDOM); + + return { + dom, + contentDOM, + }; + }, + } +); + +// STYLES ---------------------------------------------------------------------- + +const Small = createStyleSpec( + { + type: "small", + propSchema: "boolean", + }, + { + render: () => { + const dom = document.createElement("small"); + return { + dom, + contentDOM: dom, + }; + }, + } +); + +const FontSize = createStyleSpec( + { + type: "fontSize", + propSchema: "string", + }, + { + render: (value) => { + const dom = document.createElement("span"); + dom.setAttribute("style", "font-size: " + value); + return { + dom, + contentDOM: dom, + }; + }, + } +); + +// SCHEMA ---------------------------------------------------------------------- + +export const testSchema = BlockNoteSchema.create({ + blockSpecs: { + ...defaultBlockSpecs, + pageBreak: PageBreak, + customParagraph: CustomParagraph, + simpleCustomParagraph: SimpleCustomParagraph, + simpleImage: SimpleImage, + }, + inlineContentSpecs: { + ...defaultInlineContentSpecs, + mention: Mention, + tag: Tag, + }, + styleSpecs: { + ...defaultStyleSpecs, + small: Small, + fontSize: FontSize, + }, +}); + +export type TestBlockSchema = typeof testSchema.blockSchema; +export type TestInlineContentSchema = typeof testSchema.inlineContentSchema; +export type TestStyleSchema = typeof testSchema.styleSchema; diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/contains-newlines.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/contains-newlines.html new file mode 100644 index 0000000000..32e032f09d --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/contains-newlines.html @@ -0,0 +1,11 @@ +
+
+
+
+
+          const hello ='world';console.log(hello);
+        
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/defaultLanguage.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/defaultLanguage.html new file mode 100644 index 0000000000..a8fb6870f0 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/defaultLanguage.html @@ -0,0 +1,11 @@ +
+
+
+
+
+          console.log('Hello, world!');
+        
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/empty.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/empty.html new file mode 100644 index 0000000000..7df4533925 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/empty.html @@ -0,0 +1,11 @@ +
+
+
+
+
+          
+        
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/python.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/python.html new file mode 100644 index 0000000000..232edd4914 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/codeBlock/python.html @@ -0,0 +1,11 @@ +
+
+
+
+
+          print('Hello, world!')
+        
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/complex/misc.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/complex/misc.html new file mode 100644 index 0000000000..7587f35366 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/complex/misc.html @@ -0,0 +1,59 @@ +
+
+
+
+

+ + Heading + + + 2 + +

+
+
+
+
+
+

Paragraph

+
+
+
+
+
+
+

+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/contextParagraph/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/contextParagraph/basic.html new file mode 100644 index 0000000000..be4542743b --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/contextParagraph/basic.html @@ -0,0 +1,14 @@ +
+
+
+
+
React Context Paragraph
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/basic.html new file mode 100644 index 0000000000..150ceb1216 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/basic.html @@ -0,0 +1,14 @@ +
+
+
+
+

React Custom Paragraph

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/lineBreaks.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/lineBreaks.html new file mode 100644 index 0000000000..52a1aa140a --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/lineBreaks.html @@ -0,0 +1,18 @@ +
+
+
+
+

+ Line 1 +
+ Line 2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/nested.html new file mode 100644 index 0000000000..d839341713 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/nested.html @@ -0,0 +1,40 @@ +
+
+
+
+

React Custom Paragraph

+
+
+
+
+
+

Nested React Custom Paragraph 1

+
+
+
+
+
+
+

Nested React Custom Paragraph 2

+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/styled.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/styled.html new file mode 100644 index 0000000000..29d66a7d8e --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/customParagraph/styled.html @@ -0,0 +1,34 @@ +
+
+
+
+

+ Plain + Red Text + Blue Background + + Mixed Colors + +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/basic.html new file mode 100644 index 0000000000..9974d8d975 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/basic.html @@ -0,0 +1,28 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/button.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/button.html new file mode 100644 index 0000000000..db235fd792 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/button.html @@ -0,0 +1,20 @@ +
+
+
+
+
+
+
+ + + +
+

Add file

+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/nested.html new file mode 100644 index 0000000000..6553a5c4a8 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/nested.html @@ -0,0 +1,56 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/noCaption.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/noCaption.html new file mode 100644 index 0000000000..48340682e8 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/noCaption.html @@ -0,0 +1,26 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/noName.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/noName.html new file mode 100644 index 0000000000..47ae5b3bf9 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/file/noName.html @@ -0,0 +1,27 @@ +
+
+
+
+
+
+
+ + + +
+

+
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/fontSize/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/fontSize/basic.html new file mode 100644 index 0000000000..601e2af9c0 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/fontSize/basic.html @@ -0,0 +1,16 @@ +
+
+
+
+

+ This is text with a custom fontSize +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/basic.html new file mode 100644 index 0000000000..ca0de5979f --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/basic.html @@ -0,0 +1,13 @@ +
+
+
+
+

+ Text1 +
+ Text2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/between-links.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/between-links.html new file mode 100644 index 0000000000..9e4b427c62 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/between-links.html @@ -0,0 +1,21 @@ +
+
+
+
+

+ Link1 +
+ Link2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/end.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/end.html new file mode 100644 index 0000000000..cc08190f01 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/end.html @@ -0,0 +1,12 @@ +
+
+
+
+

+ Text1 +
+

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/link.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/link.html new file mode 100644 index 0000000000..4cae02d67b --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/link.html @@ -0,0 +1,21 @@ +
+
+
+
+

+ Link1 +
+ Link1 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/multiple.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/multiple.html new file mode 100644 index 0000000000..06a2a6a7e5 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/multiple.html @@ -0,0 +1,15 @@ +
+
+
+
+

+ Text1 +
+ Text2 +
+ Text3 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/only.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/only.html new file mode 100644 index 0000000000..030fa48828 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/only.html @@ -0,0 +1,11 @@ +
+
+
+
+

+
+

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/start.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/start.html new file mode 100644 index 0000000000..29e2b8ece4 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/start.html @@ -0,0 +1,12 @@ +
+
+
+
+

+
+ Text1 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/styles.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/styles.html new file mode 100644 index 0000000000..b6b8eadb30 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/hardbreak/styles.html @@ -0,0 +1,13 @@ +
+
+
+
+

+ Text1 +
+ Text2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/basic.html new file mode 100644 index 0000000000..fe9509a5e3 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/basic.html @@ -0,0 +1,22 @@ +
+
+
+
+
+
+ example +
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/button.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/button.html new file mode 100644 index 0000000000..250700bb22 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/button.html @@ -0,0 +1,20 @@ +
+
+
+
+
+
+
+ + + +
+

Add image

+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/nested.html new file mode 100644 index 0000000000..90e46213fe --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/nested.html @@ -0,0 +1,42 @@ +
+
+
+
+
+
+ Caption +
+

Caption

+
+
+
+
+
+
+
+
+ Caption +
+

Caption

+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/noCaption.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/noCaption.html new file mode 100644 index 0000000000..2daf51143b --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/noCaption.html @@ -0,0 +1,20 @@ +
+
+
+
+
+
+ example +
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/noName.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/noName.html new file mode 100644 index 0000000000..05bc98c060 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/noName.html @@ -0,0 +1,21 @@ +
+
+
+
+
+
+ Caption +
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/noPreview.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/noPreview.html new file mode 100644 index 0000000000..84f2dbfc76 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/image/noPreview.html @@ -0,0 +1,30 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/link/adjacent.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/link/adjacent.html new file mode 100644 index 0000000000..2408c611ac --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/link/adjacent.html @@ -0,0 +1,20 @@ +
+
+
+
+

+ Website + Website2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/link/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/link/basic.html new file mode 100644 index 0000000000..3daea90831 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/link/basic.html @@ -0,0 +1,15 @@ +
+
+
+
+

+ Website +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/link/styled.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/link/styled.html new file mode 100644 index 0000000000..2b9d4cb574 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/link/styled.html @@ -0,0 +1,22 @@ +
+
+
+
+

+ + Web + + site +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/lists/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/lists/basic.html new file mode 100644 index 0000000000..3cb5ed5e94 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/lists/basic.html @@ -0,0 +1,58 @@ +
+
+
+
+

Bullet List Item 1

+
+
+
+
+
+
+

Bullet List Item 2

+
+
+
+
+
+
+

Numbered List Item 1

+
+
+
+
+
+
+

Numbered List Item 2

+
+
+
+
+
+
+ +

Check List Item 1

+
+
+
+
+
+
+ +

Check List Item 2

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/lists/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/lists/nested.html new file mode 100644 index 0000000000..f9aaf463f8 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/lists/nested.html @@ -0,0 +1,62 @@ +
+
+
+
+

Bullet List Item 1

+
+
+
+
+
+
+

Bullet List Item 2

+
+
+
+
+
+

Numbered List Item 1

+
+
+
+
+
+
+

Numbered List Item 2

+
+
+
+
+
+ +

Check List Item 1

+
+
+
+
+
+
+ +

Check List Item 2

+
+
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/mention/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/mention/basic.html new file mode 100644 index 0000000000..a4b3e6a87e --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/mention/basic.html @@ -0,0 +1,12 @@ +
+
+
+
+

+ I enjoy working with + @Matthew +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/pageBreak/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/pageBreak/basic.html new file mode 100644 index 0000000000..545ab1bbac --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/pageBreak/basic.html @@ -0,0 +1,9 @@ +
+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/basic.html new file mode 100644 index 0000000000..326c6a037b --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/basic.html @@ -0,0 +1,9 @@ +
+
+
+
+

Paragraph

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/empty.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/empty.html new file mode 100644 index 0000000000..8c0240ae7c --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/empty.html @@ -0,0 +1,9 @@ +
+
+
+
+

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/lineBreaks.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/lineBreaks.html new file mode 100644 index 0000000000..0aa8dffa67 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/lineBreaks.html @@ -0,0 +1,13 @@ +
+
+
+
+

+ Line 1 +
+ Line 2 +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/nested.html new file mode 100644 index 0000000000..7d99f8188d --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/nested.html @@ -0,0 +1,25 @@ +
+
+
+
+

Paragraph

+
+
+
+
+
+

Nested Paragraph 1

+
+
+
+
+
+
+

Nested Paragraph 2

+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/styled.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/styled.html new file mode 100644 index 0000000000..5ae4c7b95c --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/paragraph/styled.html @@ -0,0 +1,32 @@ +
+
+
+
+

+ Plain + Red Text + Blue Background + + Mixed Colors + +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/basic.html new file mode 100644 index 0000000000..9974d8d975 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/basic.html @@ -0,0 +1,28 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/button.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/button.html new file mode 100644 index 0000000000..db235fd792 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/button.html @@ -0,0 +1,20 @@ +
+
+
+
+
+
+
+ + + +
+

Add file

+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/nested.html new file mode 100644 index 0000000000..6553a5c4a8 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/nested.html @@ -0,0 +1,56 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/noCaption.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/noCaption.html new file mode 100644 index 0000000000..48340682e8 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/noCaption.html @@ -0,0 +1,26 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/noName.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/noName.html new file mode 100644 index 0000000000..47ae5b3bf9 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactFile/noName.html @@ -0,0 +1,27 @@ +
+
+
+
+
+
+
+ + + +
+

+
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/basic.html new file mode 100644 index 0000000000..fe9509a5e3 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/basic.html @@ -0,0 +1,22 @@ +
+
+
+
+
+
+ example +
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/button.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/button.html new file mode 100644 index 0000000000..250700bb22 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/button.html @@ -0,0 +1,20 @@ +
+
+
+
+
+
+
+ + + +
+

Add image

+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/nested.html new file mode 100644 index 0000000000..59718524c9 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/nested.html @@ -0,0 +1,44 @@ +
+
+
+
+
+
+ example +
+

Caption

+
+
+
+
+
+
+
+
+ example +
+

Caption

+
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/noCaption.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/noCaption.html new file mode 100644 index 0000000000..2daf51143b --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/noCaption.html @@ -0,0 +1,20 @@ +
+
+
+
+
+
+ example +
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/noName.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/noName.html new file mode 100644 index 0000000000..05bc98c060 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/noName.html @@ -0,0 +1,21 @@ +
+
+
+
+
+
+ Caption +
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/noPreview.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/noPreview.html new file mode 100644 index 0000000000..84f2dbfc76 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/reactImage/noPreview.html @@ -0,0 +1,30 @@ +
+
+
+
+
+
+
+ + + +
+

example

+
+

Caption

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/simpleCustomParagraph/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/simpleCustomParagraph/basic.html new file mode 100644 index 0000000000..1b1d65bad0 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/simpleCustomParagraph/basic.html @@ -0,0 +1,14 @@ +
+
+
+
+

React Custom Paragraph

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/simpleCustomParagraph/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/simpleCustomParagraph/nested.html new file mode 100644 index 0000000000..a393455366 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/simpleCustomParagraph/nested.html @@ -0,0 +1,40 @@ +
+
+
+
+

Custom React Paragraph

+
+
+
+
+
+

Nested React Custom Paragraph 1

+
+
+
+
+
+
+

Nested React Custom Paragraph 2

+
+
+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/simpleCustomParagraph/styled.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/simpleCustomParagraph/styled.html new file mode 100644 index 0000000000..077d8d0898 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/simpleCustomParagraph/styled.html @@ -0,0 +1,34 @@ +
+
+
+
+

+ Plain + Red Text + Blue Background + + Mixed Colors + +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/small/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/small/basic.html new file mode 100644 index 0000000000..33dcb60c92 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/small/basic.html @@ -0,0 +1,11 @@ +
+
+
+
+

+ This is a small text +

+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/allColWidths.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/allColWidths.html new file mode 100644 index 0000000000..778749b580 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/allColWidths.html @@ -0,0 +1,43 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/basic.html new file mode 100644 index 0000000000..a9e249effe --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/basic.html @@ -0,0 +1,43 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/headerCols.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/headerCols.html new file mode 100644 index 0000000000..6f5dcb8982 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/headerCols.html @@ -0,0 +1,43 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/headerRows.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/headerRows.html new file mode 100644 index 0000000000..2ce617f949 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/headerRows.html @@ -0,0 +1,43 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedCellColors.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedCellColors.html new file mode 100644 index 0000000000..8cafca0c72 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedCellColors.html @@ -0,0 +1,55 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedColWidths.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedColWidths.html new file mode 100644 index 0000000000..a5e5bdf3b4 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedColWidths.html @@ -0,0 +1,43 @@ +
+
+
+
+ + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedRowspansAndColspans.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedRowspansAndColspans.html new file mode 100644 index 0000000000..eb7dd2ce02 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/table/mixedRowspansAndColspans.html @@ -0,0 +1,46 @@ +
+
+
+
+ + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+
+
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/tag/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/tag/basic.html new file mode 100644 index 0000000000..f17714232a --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/blocknoteHTML/tag/basic.html @@ -0,0 +1,15 @@ +
+
+
+
+

+ I love + + # + BlockNote + +

+
+
+
+
\ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-basic-block-types.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/basicBlockTypes.json similarity index 73% rename from packages/core/src/api/exporters/html/__snapshots__/paste/parse-basic-block-types.json rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/basicBlockTypes.json index 2d11e081f6..1a9bd562f2 100644 --- a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-basic-block-types.json +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/basicBlockTypes.json @@ -1,140 +1,143 @@ [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 1", + "type": "text", + }, + ], "id": "1", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 1, "textAlignment": "left", - "level": 1 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 2", "type": "text", - "text": "Heading 1", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "2", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 2, "textAlignment": "left", - "level": 2 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Heading 3", "type": "text", - "text": "Heading 2", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "3", - "type": "heading", "props": { - "textColor": "default", "backgroundColor": "default", + "level": 3, "textAlignment": "left", - "level": 3 + "textColor": "default", }, + "type": "heading", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Paragraph", "type": "text", - "text": "Heading 3", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "4", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Paragraph", - "styles": {} - } - ], - "children": [] + "type": "paragraph", }, { + "children": [], + "content": undefined, "id": "5", - "type": "image", "props": { "backgroundColor": "default", + "caption": "Image Caption", + "name": "", + "previewWidth": 512, + "showPreview": true, "textAlignment": "left", "url": "exampleURL", - "caption": "Image Caption", - "width": 512 }, - "children": [] + "type": "image", }, { - "id": "6", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "None ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Bold ", "styles": { - "bold": true - } + "bold": true, + }, + "text": "Bold ", + "type": "text", }, { - "type": "text", - "text": "Italic ", "styles": { - "italic": true - } + "italic": true, + }, + "text": "Italic ", + "type": "text", }, { - "type": "text", - "text": "Underline ", "styles": { - "underline": true - } + "underline": true, + }, + "text": "Underline ", + "type": "text", }, { - "type": "text", - "text": "Strikethrough ", "styles": { - "strike": true - } + "strike": true, + }, + "text": "Strikethrough ", + "type": "text", }, { - "type": "text", - "text": "All", "styles": { "bold": true, "italic": true, + "strike": true, "underline": true, - "strike": true - } - } + }, + "text": "All", + "type": "text", + }, ], - "children": [] - } + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/contains-newlines.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/contains-newlines.html new file mode 100644 index 0000000000..1b766eb380 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/contains-newlines.html @@ -0,0 +1,8 @@ +
+  
+    const hello ='world';
+    
+ console.log(hello); +
+
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/defaultLanguage.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/defaultLanguage.html new file mode 100644 index 0000000000..c5939c1b5e --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/defaultLanguage.html @@ -0,0 +1,3 @@ +
+  console.log('Hello, world!');
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/empty.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/empty.html new file mode 100644 index 0000000000..9bbe62c374 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/empty.html @@ -0,0 +1,3 @@ +
+  
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/python.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/python.html new file mode 100644 index 0000000000..2d95c0d45d --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlock/python.html @@ -0,0 +1,3 @@ +
+  print('Hello, world!')
+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlocks.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlocks.json new file mode 100644 index 0000000000..f9bd791440 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/codeBlocks.json @@ -0,0 +1,62 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "console.log("Should default to JS")", + "type": "text", + }, + ], + "id": "1", + "props": { + "language": "text", + }, + "type": "codeBlock", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "console.log("Should parse TS from data-language")", + "type": "text", + }, + ], + "id": "2", + "props": { + "language": "typescript", + }, + "type": "codeBlock", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "print("Should parse Python from language- class")", + "type": "text", + }, + ], + "id": "3", + "props": { + "language": "python", + }, + "type": "codeBlock", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "console.log("Should prioritize TS from data-language over language- class")", + "type": "text", + }, + ], + "id": "4", + "props": { + "language": "typescript", + }, + "type": "codeBlock", + }, +] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/complex/misc.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/complex/misc.html new file mode 100644 index 0000000000..0df8a18343 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/complex/misc.html @@ -0,0 +1,14 @@ +

+ + Heading + + + 2 + +

+

Paragraph

+
    +
  • +

    +
  • +
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactContextParagraph/basic/external.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/contextParagraph/basic.html similarity index 100% rename from packages/react/src/test/__snapshots__/reactContextParagraph/basic/external.html rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/contextParagraph/basic.html diff --git a/packages/react/src/test/__snapshots__/reactCustomParagraph/basic/external.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/customParagraph/basic.html similarity index 100% rename from packages/react/src/test/__snapshots__/reactCustomParagraph/basic/external.html rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/customParagraph/basic.html diff --git a/packages/react/src/test/__snapshots__/reactCustomParagraph/lineBreaks/external.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/customParagraph/lineBreaks.html similarity index 100% rename from packages/react/src/test/__snapshots__/reactCustomParagraph/lineBreaks/external.html rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/customParagraph/lineBreaks.html diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/customParagraph/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/customParagraph/nested.html new file mode 100644 index 0000000000..6b2e1554cf --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/customParagraph/nested.html @@ -0,0 +1,3 @@ +

Hello World

+

Hello World

+

Hello World

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/customParagraph/styled.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/customParagraph/styled.html new file mode 100644 index 0000000000..77e2409a54 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/customParagraph/styled.html @@ -0,0 +1,6 @@ +

Hello World

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/deepNestedContent.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/deepNestedContent.json new file mode 100644 index 0000000000..959dbbcd5a --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/deepNestedContent.json @@ -0,0 +1,243 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Outer 1 Div Before", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Outer 2 Div Before", + "type": "text", + }, + ], + "id": "2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Outer 3 Div Before", + "type": "text", + }, + ], + "id": "3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Outer 4 Div Before", + "type": "text", + }, + ], + "id": "4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 1", + "type": "text", + }, + ], + "id": "5", + "props": { + "backgroundColor": "default", + "level": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 2", + "type": "text", + }, + ], + "id": "6", + "props": { + "backgroundColor": "default", + "level": 2, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 3", + "type": "text", + }, + ], + "id": "7", + "props": { + "backgroundColor": "default", + "level": 3, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph", + "type": "text", + }, + ], + "id": "8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": undefined, + "id": "9", + "props": { + "backgroundColor": "default", + "caption": "Image Caption", + "name": "", + "previewWidth": 512, + "showPreview": true, + "textAlignment": "left", + "url": "exampleURL", + }, + "type": "image", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Bold", + "type": "text", + }, + { + "styles": {}, + "text": " ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "Italic", + "type": "text", + }, + { + "styles": {}, + "text": " ", + "type": "text", + }, + { + "styles": { + "underline": true, + }, + "text": "Underline", + "type": "text", + }, + { + "styles": {}, + "text": " ", + "type": "text", + }, + { + "styles": { + "strike": true, + }, + "text": "Strikethrough", + "type": "text", + }, + { + "styles": {}, + "text": " ", + "type": "text", + }, + { + "styles": { + "bold": true, + "italic": true, + "strike": true, + "underline": true, + }, + "text": "All", + "type": "text", + }, + ], + "id": "10", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Outer 4 Div After Outer 3 Div After Outer 2 Div After Outer 1 Div After", + "type": "text", + }, + ], + "id": "11", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/divs.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/divs.json new file mode 100644 index 0000000000..1e08669f16 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/divs.json @@ -0,0 +1,121 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Single Div", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Div", + "type": "text", + }, + ], + "id": "2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Div", + "type": "text", + }, + ], + "id": "3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Div", + "type": "text", + }, + ], + "id": "4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Single Div 2", + "type": "text", + }, + ], + "id": "5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Div", + "type": "text", + }, + ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Div", + "type": "text", + }, + ], + "id": "7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] \ No newline at end of file diff --git a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-fake-image-caption.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/fakeImageCaption.json similarity index 66% rename from packages/core/src/api/exporters/html/__snapshots__/paste/parse-fake-image-caption.json rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/fakeImageCaption.json index 86a0cb8168..3964251638 100644 --- a/packages/core/src/api/exporters/html/__snapshots__/paste/parse-fake-image-caption.json +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/fakeImageCaption.json @@ -1,31 +1,34 @@ [ { + "children": [], + "content": undefined, "id": "1", - "type": "image", "props": { "backgroundColor": "default", + "caption": "", + "name": "", + "previewWidth": 512, + "showPreview": true, "textAlignment": "left", "url": "exampleURL", - "caption": "", - "width": 512 }, - "children": [] + "type": "image", }, { - "id": "2", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Image Caption", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/basic.html new file mode 100644 index 0000000000..22fe1c373a --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/basic.html @@ -0,0 +1,4 @@ +
+ example +

Caption

+
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactFile/button/external.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/button.html similarity index 100% rename from packages/react/src/test/__snapshots__/reactFile/button/external.html rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/file/button.html diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/nested.html new file mode 100644 index 0000000000..226ee83250 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/nested.html @@ -0,0 +1,8 @@ +
+ example +

Caption

+
+
+ example +

Caption

+
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactFile/noCaption/external.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/noCaption.html similarity index 100% rename from packages/react/src/test/__snapshots__/reactFile/noCaption/external.html rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/file/noCaption.html diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/noName.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/noName.html new file mode 100644 index 0000000000..f0ac923a66 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/file/noName.html @@ -0,0 +1,4 @@ +
+ exampleURL +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/fontSize/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/fontSize/basic.html new file mode 100644 index 0000000000..b8842df250 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/fontSize/basic.html @@ -0,0 +1,8 @@ +

+ This is text with a custom fontSize +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/googleDocs.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/googleDocs.json new file mode 100644 index 0000000000..5a7912dcd1 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/googleDocs.json @@ -0,0 +1,579 @@ +[ + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Heading 1", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "level": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Heading 2", + "type": "text", + }, + ], + "id": "2", + "props": { + "backgroundColor": "default", + "level": 2, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Heading 3", + "type": "text", + }, + ], + "id": "3", + "props": { + "backgroundColor": "default", + "level": 3, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 2", + "type": "text", + }, + ], + "id": "5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 3", + "type": "text", + }, + ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph With +Hard Break", + "type": "text", + }, + ], + "id": "7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Bold", + "type": "text", + }, + { + "styles": {}, + "text": " ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "Italic", + "type": "text", + }, + { + "styles": {}, + "text": " Underline ", + "type": "text", + }, + { + "styles": { + "strike": true, + }, + "text": "Strikethrough", + "type": "text", + }, + { + "styles": {}, + "text": " ", + "type": "text", + }, + { + "styles": { + "bold": true, + "italic": true, + "strike": true, + }, + "text": "All", + "type": "text", + }, + ], + "id": "8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [ + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Nested Numbered List Item 1", + "type": "text", + }, + ], + "id": "11", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Nested Numbered List Item 2", + "type": "text", + }, + ], + "id": "12", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": " Nested Bullet List Item 1", + "type": "text", + }, + ], + "id": "10", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Nested Bullet List Item 2", + "type": "text", + }, + ], + "id": "13", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": " Bullet List Item 1", + "type": "text", + }, + ], + "id": "9", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Bullet List Item 2", + "type": "text", + }, + ], + "id": "14", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Numbered List Item 1", + "type": "text", + }, + ], + "id": "15", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " Numbered List Item 2", + "type": "text", + }, + ], + "id": "16", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": undefined, + "id": "17", + "props": { + "backgroundColor": "default", + "caption": "", + "name": "", + "previewWidth": 447, + "showPreview": true, + "textAlignment": "left", + "url": "https://lh7-us.googleusercontent.com/SGyYp6hfLvNkli62NKFJB6NQz-fNa2Sjy8QxfUuqipW--qCCXmCz-dJmeZUGaDXIF9TEZHzbhNJsw4_w-B09eaFOn0oUChKsrSt3cwAIFu6d4SoSjHTR_DRTPr415_P7an7Lue-EwlUcVBk1WCzcoVQ", + }, + "type": "image", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " +", + "type": "text", + }, + ], + "id": "18", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": { + "columnWidths": [ + undefined, + undefined, + undefined, + ], + "headerCols": undefined, + "headerRows": undefined, + "rows": [ + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 1", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 2", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 3", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 4", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 5", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 6", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 7", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 8", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 9", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + ], + "type": "tableContent", + }, + "id": "19", + "props": { + "textColor": "default", + }, + "type": "table", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph", + "type": "text", + }, + ], + "id": "20", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": " +", + "type": "text", + }, + ], + "id": "21", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/basic.html new file mode 100644 index 0000000000..d0444869cc --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/basic.html @@ -0,0 +1,5 @@ +

+ Text1 +
+ Text2 +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/between-links.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/between-links.html new file mode 100644 index 0000000000..701b5d4213 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/between-links.html @@ -0,0 +1,13 @@ +

+ Link1 +
+ Link2 +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/end.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/end.html new file mode 100644 index 0000000000..1f7bcf996b --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/end.html @@ -0,0 +1,4 @@ +

+ Text1 +
+

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/link.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/link.html new file mode 100644 index 0000000000..2c762aedc5 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/link.html @@ -0,0 +1,13 @@ +

+ Link1 +
+ Link1 +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/multiple.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/multiple.html new file mode 100644 index 0000000000..5d957daa62 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/multiple.html @@ -0,0 +1,7 @@ +

+ Text1 +
+ Text2 +
+ Text3 +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/only.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/only.html new file mode 100644 index 0000000000..b96f89d7a0 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/only.html @@ -0,0 +1,3 @@ +

+
+

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/start.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/start.html new file mode 100644 index 0000000000..f0370a6c68 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/start.html @@ -0,0 +1,4 @@ +

+
+ Text1 +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/styles.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/styles.html new file mode 100644 index 0000000000..7a49318b49 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/hardbreak/styles.html @@ -0,0 +1,5 @@ +

+ Text1 +
+ Text2 +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/basic.html new file mode 100644 index 0000000000..59f782dbb1 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/basic.html @@ -0,0 +1,9 @@ +
+ example +

Caption

+
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/reactImage/button/external.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/button.html similarity index 100% rename from packages/react/src/test/__snapshots__/reactImage/button/external.html rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/image/button.html diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/nested.html new file mode 100644 index 0000000000..8cc825084e --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/nested.html @@ -0,0 +1,8 @@ +
+ exampleURL +

Caption

+
+
+ exampleURL +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/noCaption.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/noCaption.html new file mode 100644 index 0000000000..269bdeca7e --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/noCaption.html @@ -0,0 +1,6 @@ +example \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/noName.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/noName.html new file mode 100644 index 0000000000..decd178fbe --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/noName.html @@ -0,0 +1,4 @@ +
+ exampleURL +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/noPreview.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/noPreview.html new file mode 100644 index 0000000000..21bf2faaf1 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/image/noPreview.html @@ -0,0 +1,10 @@ +
+ example +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/imageInParagraph.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/imageInParagraph.json new file mode 100644 index 0000000000..28369c981f --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/imageInParagraph.json @@ -0,0 +1,17 @@ +[ + { + "children": [], + "content": undefined, + "id": "1", + "props": { + "backgroundColor": "default", + "caption": "", + "name": "", + "previewWidth": 512, + "showPreview": true, + "textAlignment": "left", + "url": "exampleURL", + }, + "type": "image", + }, +] \ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-div-with-inline-content.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/inlineContentAndNestedBlocks.json similarity index 73% rename from packages/core/src/api/parsers/html/__snapshots__/parse-div-with-inline-content.json rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/inlineContentAndNestedBlocks.json index d06969a05f..b21c97408c 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-div-with-inline-content.json +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/inlineContentAndNestedBlocks.json @@ -1,91 +1,91 @@ [ { - "id": "1", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "None ", - "styles": {} + "type": "text", }, { - "type": "text", - "text": "Bold ", "styles": { - "bold": true - } + "bold": true, + }, + "text": "Bold ", + "type": "text", }, { - "type": "text", - "text": "Italic ", "styles": { - "italic": true - } + "italic": true, + }, + "text": "Italic ", + "type": "text", }, { - "type": "text", - "text": "Underline ", "styles": { - "underline": true - } + "underline": true, + }, + "text": "Underline ", + "type": "text", }, { - "type": "text", - "text": "Strikethrough ", "styles": { - "strike": true - } + "strike": true, + }, + "text": "Strikethrough ", + "type": "text", }, { - "type": "text", - "text": "All", "styles": { "bold": true, "italic": true, + "strike": true, "underline": true, - "strike": true - } - } + }, + "text": "All", + "type": "text", + }, ], - "children": [] - }, - { - "id": "2", - "type": "paragraph", + "id": "1", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Div", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "3", - "type": "paragraph", + "id": "2", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "paragraph", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Paragraph", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/link/adjacent.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/link/adjacent.html new file mode 100644 index 0000000000..db99691d33 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/link/adjacent.html @@ -0,0 +1,12 @@ +

+ Website + Website2 +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/link/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/link/basic.html new file mode 100644 index 0000000000..4b61e8c582 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/link/basic.html @@ -0,0 +1,7 @@ +

+ Website +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/link/styled.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/link/styled.html new file mode 100644 index 0000000000..fb7737f7f8 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/link/styled.html @@ -0,0 +1,14 @@ +

+ + Web + + site +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/lists.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/lists.json new file mode 100644 index 0000000000..cdd50b6d47 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/lists.json @@ -0,0 +1,177 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "First", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Second", + "type": "text", + }, + ], + "id": "2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Third", + "type": "text", + }, + ], + "id": "3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Fourth", + "type": "text", + }, + ], + "id": "4", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Fifth", + "type": "text", + }, + ], + "id": "5", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Child 1", + "type": "text", + }, + ], + "id": "7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Child 2", + "type": "text", + }, + ], + "id": "8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Child 3", + "type": "text", + }, + ], + "id": "9", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Child 4", + "type": "text", + }, + ], + "id": "10", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Five Parent", + "type": "text", + }, + ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, +] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/lists/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/lists/basic.html new file mode 100644 index 0000000000..aee1048a87 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/lists/basic.html @@ -0,0 +1,26 @@ +
    +
  • +

    Bullet List Item 1

    +
  • +
  • +

    Bullet List Item 2

    +
  • +
+
    +
  1. +

    Numbered List Item 1

    +
  2. +
  3. +

    Numbered List Item 2

    +
  4. +
+
    +
  • + +

    Check List Item 1

    +
  • +
  • + +

    Check List Item 2

    +
  • +
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/lists/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/lists/nested.html new file mode 100644 index 0000000000..b2497ae937 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/lists/nested.html @@ -0,0 +1,26 @@ +
    +
  • +

    Bullet List Item 1

    +
  • +
  • +

    Bullet List Item 2

    +
      +
    1. +

      Numbered List Item 1

      +
    2. +
    3. +

      Numbered List Item 2

      +
        +
      • + +

        Check List Item 1

        +
      • +
      • + +

        Check List Item 2

        +
      • +
      +
    4. +
    +
  • +
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/mention/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/mention/basic.html new file mode 100644 index 0000000000..dba0d5cf95 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/mention/basic.html @@ -0,0 +1,4 @@ +

+ I enjoy working with + @Matthew +

\ No newline at end of file diff --git a/packages/core/src/api/parsers/html/__snapshots__/parse-nested-lists.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/mixedNestedLists.json similarity index 76% rename from packages/core/src/api/parsers/html/__snapshots__/parse-nested-lists.json rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/mixedNestedLists.json index f617673f05..5b79ba865f 100644 --- a/packages/core/src/api/parsers/html/__snapshots__/parse-nested-lists.json +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/mixedNestedLists.json @@ -1,265 +1,265 @@ [ { - "id": "1", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "2", - "type": "bulletListItem", + "id": "1", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Bullet List Item", - "styles": {} - } - ], + "type": "bulletListItem", + }, + { "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item", + "type": "text", + }, + ], "id": "3", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Nested Numbered List Item", "type": "text", - "text": "Nested Bullet List Item", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "4", - "type": "bulletListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Bullet List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "5", - "type": "bulletListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "type": "numberedListItem", + }, + ], "content": [ { - "type": "text", + "styles": {}, "text": "Bullet List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "6", - "type": "numberedListItem", + "id": "2", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Bullet List Item", "type": "text", - "text": "Numbered List Item", - "styles": {} - } + }, ], - "children": [] - }, - { - "id": "7", - "type": "numberedListItem", + "id": "5", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Numbered List Item", - "styles": {} - } + "type": "text", + }, ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Check List Item", + "type": "text", + }, + ], "id": "8", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "checked": true, + "textAlignment": "left", + "textColor": "default", }, + "type": "checkListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Nested Check List Item", "type": "text", - "text": "Nested Numbered List Item", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "9", - "type": "numberedListItem", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "checked": false, + "textAlignment": "left", + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Numbered List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "10", - "type": "numberedListItem", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "type": "checkListItem", + }, + ], "content": [ { - "type": "text", + "styles": {}, "text": "Numbered List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - }, - { - "id": "11", - "type": "checkListItem", + "id": "7", "props": { - "textColor": "default", "backgroundColor": "default", "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Numbered List Item", "type": "text", - "text": "Check List Item", - "styles": {} - } + }, ], - "children": [] - }, - { - "id": "12", - "type": "checkListItem", + "id": "10", "props": { - "textColor": "default", "backgroundColor": "default", "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "numberedListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Check List Item", - "styles": {} - } + "type": "text", + }, ], + "id": "11", + "props": { + "backgroundColor": "default", + "checked": true, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { "children": [ { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item", + "type": "text", + }, + ], "id": "13", - "type": "checkListItem", "props": { - "textColor": "default", "backgroundColor": "default", "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "bulletListItem", + }, + { + "children": [], "content": [ { + "styles": {}, + "text": "Nested Bullet List Item", "type": "text", - "text": "Nested Check List Item", - "styles": {} - } + }, ], - "children": [] - }, - { "id": "14", - "type": "checkListItem", "props": { - "textColor": "default", "backgroundColor": "default", "textAlignment": "left", - "checked": false + "textColor": "default", }, - "content": [ - { - "type": "text", - "text": "Nested Check List Item", - "styles": {} - } - ], - "children": [] - } - ] - }, - { - "id": "15", - "type": "checkListItem", + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Check List Item", + "type": "text", + }, + ], + "id": "12", "props": { - "textColor": "default", "backgroundColor": "default", + "checked": false, "textAlignment": "left", - "checked": false + "textColor": "default", }, + "type": "checkListItem", + }, + { + "children": [], "content": [ { - "type": "text", + "styles": {}, "text": "Nested Check List Item", - "styles": {} - } + "type": "text", + }, ], - "children": [] - } + "id": "15", + "props": { + "backgroundColor": "default", + "checked": true, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, ] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/nestedLists.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/nestedLists.json new file mode 100644 index 0000000000..061ca1c5bc --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/nestedLists.json @@ -0,0 +1,265 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item", + "type": "text", + }, + ], + "id": "3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item", + "type": "text", + }, + ], + "id": "4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item", + "type": "text", + }, + ], + "id": "8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item", + "type": "text", + }, + ], + "id": "9", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], + "id": "7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], + "id": "10", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Check List Item", + "type": "text", + }, + ], + "id": "11", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Check List Item", + "type": "text", + }, + ], + "id": "13", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Check List Item", + "type": "text", + }, + ], + "id": "14", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Check List Item", + "type": "text", + }, + ], + "id": "12", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Check List Item", + "type": "text", + }, + ], + "id": "15", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, +] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/nestedListsWithParagraphs.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/nestedListsWithParagraphs.json new file mode 100644 index 0000000000..055d8f7d31 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/nestedListsWithParagraphs.json @@ -0,0 +1,265 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item", + "type": "text", + }, + ], + "id": "3", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item", + "type": "text", + }, + ], + "id": "4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "2", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Bullet List Item", + "type": "text", + }, + ], + "id": "5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item", + "type": "text", + }, + ], + "id": "8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item", + "type": "text", + }, + ], + "id": "9", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], + "id": "7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Numbered List Item", + "type": "text", + }, + ], + "id": "10", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Checked List Item", + "type": "text", + }, + ], + "id": "11", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Checked List Item", + "type": "text", + }, + ], + "id": "13", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Checked List Item", + "type": "text", + }, + ], + "id": "14", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Checked List Item", + "type": "text", + }, + ], + "id": "12", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Checked List Item", + "type": "text", + }, + ], + "id": "15", + "props": { + "backgroundColor": "default", + "checked": false, + "textAlignment": "left", + "textColor": "default", + }, + "type": "checkListItem", + }, +] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/notion.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/notion.json new file mode 100644 index 0000000000..b1eb97dd2d --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/notion.json @@ -0,0 +1,566 @@ +[ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 1", + "type": "text", + }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "level": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 2", + "type": "text", + }, + ], + "id": "2", + "props": { + "backgroundColor": "default", + "level": 2, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Heading 3", + "type": "text", + }, + ], + "id": "3", + "props": { + "backgroundColor": "default", + "level": 3, + "textAlignment": "left", + "textColor": "default", + }, + "type": "heading", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph 1", + "type": "text", + }, + ], + "id": "4", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 1", + "type": "text", + }, + ], + "id": "5", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Paragraph 2", + "type": "text", + }, + ], + "id": "6", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph With Hard Break", + "type": "text", + }, + ], + "id": "7", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": { + "bold": true, + }, + "text": "Bold", + "type": "text", + }, + { + "styles": {}, + "text": " ", + "type": "text", + }, + { + "styles": { + "italic": true, + }, + "text": "Italic", + "type": "text", + }, + { + "styles": {}, + "text": " Underline ", + "type": "text", + }, + { + "styles": { + "strike": true, + }, + "text": "Strikethrough", + "type": "text", + }, + { + "styles": {}, + "text": " ", + "type": "text", + }, + { + "styles": { + "bold": true, + "italic": true, + "strike": true, + }, + "text": "All", + "type": "text", + }, + ], + "id": "8", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [ + { + "children": [ + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item 1", + "type": "text", + }, + ], + "id": "11", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Numbered List Item 2", + "type": "text", + }, + ], + "id": "12", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item 1", + "type": "text", + }, + ], + "id": "10", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Nested Bullet List Item 2", + "type": "text", + }, + ], + "id": "13", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + ], + "content": [ + { + "styles": {}, + "text": "Bullet List Item 1", + "type": "text", + }, + ], + "id": "9", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Bullet List Item 2", + "type": "text", + }, + ], + "id": "14", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "bulletListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Numbered List Item 1", + "type": "text", + }, + ], + "id": "15", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Numbered List Item 2", + "type": "text", + }, + ], + "id": "16", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "numberedListItem", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Background Color Paragraph", + "type": "text", + }, + ], + "id": "17", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "!", + "type": "text", + }, + { + "content": [ + { + "styles": {}, + "text": "https://www.pulsecarshalton.co.uk/wp-content/uploads/2016/08/jk-placeholder-image.jpg", + "type": "text", + }, + ], + "href": "https://www.pulsecarshalton.co.uk/wp-content/uploads/2016/08/jk-placeholder-image.jpg", + "type": "link", + }, + ], + "id": "18", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": { + "columnWidths": [ + undefined, + undefined, + undefined, + ], + "headerCols": undefined, + "headerRows": 1, + "rows": [ + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 1", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 2", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 3", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 4", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 5", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 6", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + { + "cells": [ + { + "content": [ + { + "styles": {}, + "text": "Cell 7", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 8", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + { + "content": [ + { + "styles": {}, + "text": "Cell 9", + "type": "text", + }, + ], + "props": { + "backgroundColor": "default", + "colspan": 1, + "rowspan": 1, + "textAlignment": "left", + "textColor": "default", + }, + "type": "tableCell", + }, + ], + }, + ], + "type": "tableContent", + }, + "id": "19", + "props": { + "textColor": "default", + }, + "type": "table", + }, + { + "children": [], + "content": [ + { + "styles": {}, + "text": "Paragraph", + "type": "text", + }, + ], + "id": "20", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, +] \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/pageBreak/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/pageBreak/basic.html new file mode 100644 index 0000000000..ba65bb0620 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/pageBreak/basic.html @@ -0,0 +1 @@ +
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/basic.html new file mode 100644 index 0000000000..38addeaada --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/basic.html @@ -0,0 +1 @@ +

Paragraph

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/empty.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/empty.html new file mode 100644 index 0000000000..540135ad6a --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/empty.html @@ -0,0 +1 @@ +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/lineBreaks.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/lineBreaks.html new file mode 100644 index 0000000000..7dafa23c42 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/lineBreaks.html @@ -0,0 +1,5 @@ +

+ Line 1 +
+ Line 2 +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/nested.html new file mode 100644 index 0000000000..5e80eb83e2 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/nested.html @@ -0,0 +1,3 @@ +

Paragraph

+

Nested Paragraph 1

+

Nested Paragraph 2

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/styled.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/styled.html new file mode 100644 index 0000000000..65e55c08bf --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/paragraph/styled.html @@ -0,0 +1,12 @@ +

+ Plain + Red Text + Blue Background + + Mixed Colors + +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/basic.html new file mode 100644 index 0000000000..22fe1c373a --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/basic.html @@ -0,0 +1,4 @@ +
+ example +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/button.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/button.html new file mode 100644 index 0000000000..cc675c57a7 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/button.html @@ -0,0 +1 @@ +

Add file

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/nested.html new file mode 100644 index 0000000000..226ee83250 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/nested.html @@ -0,0 +1,8 @@ +
+ example +

Caption

+
+
+ example +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/noCaption.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/noCaption.html new file mode 100644 index 0000000000..e1c8211b39 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/noCaption.html @@ -0,0 +1 @@ +example \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/noName.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/noName.html new file mode 100644 index 0000000000..f0ac923a66 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactFile/noName.html @@ -0,0 +1,4 @@ +
+ exampleURL +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/basic.html new file mode 100644 index 0000000000..59f782dbb1 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/basic.html @@ -0,0 +1,9 @@ +
+ example +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/button.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/button.html new file mode 100644 index 0000000000..8553433aff --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/button.html @@ -0,0 +1 @@ +

Add image

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/nested.html new file mode 100644 index 0000000000..39c365984d --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/nested.html @@ -0,0 +1,18 @@ +
+ example +

Caption

+
+
+ example +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/noCaption.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/noCaption.html new file mode 100644 index 0000000000..269bdeca7e --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/noCaption.html @@ -0,0 +1,6 @@ +example \ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/noName.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/noName.html new file mode 100644 index 0000000000..decd178fbe --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/noName.html @@ -0,0 +1,4 @@ +
+ exampleURL +

Caption

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/noPreview.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/noPreview.html new file mode 100644 index 0000000000..21bf2faaf1 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/reactImage/noPreview.html @@ -0,0 +1,10 @@ +
+ example +

Caption

+
\ No newline at end of file diff --git a/packages/react/src/test/__snapshots__/simpleReactCustomParagraph/basic/external.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/simpleCustomParagraph/basic.html similarity index 100% rename from packages/react/src/test/__snapshots__/simpleReactCustomParagraph/basic/external.html rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/simpleCustomParagraph/basic.html diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/simpleCustomParagraph/nested.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/simpleCustomParagraph/nested.html new file mode 100644 index 0000000000..68e209191a --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/simpleCustomParagraph/nested.html @@ -0,0 +1,3 @@ +

Custom React Paragraph

+

Nested React Custom Paragraph 1

+

Nested React Custom Paragraph 2

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/simpleCustomParagraph/styled.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/simpleCustomParagraph/styled.html new file mode 100644 index 0000000000..d50c890bfb --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/simpleCustomParagraph/styled.html @@ -0,0 +1,14 @@ +

+ Plain + Red Text + Blue Background + + Mixed Colors + +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/small/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/small/basic.html new file mode 100644 index 0000000000..91b799b7b0 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/small/basic.html @@ -0,0 +1,3 @@ +

+ This is a small text +

\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/allColWidths.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/allColWidths.html new file mode 100644 index 0000000000..9ce9e3e5c6 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/allColWidths.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/basic.html new file mode 100644 index 0000000000..00f73d172c --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/basic.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/headerCols.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/headerCols.html new file mode 100644 index 0000000000..eeebae59df --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/headerCols.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/headerRows.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/headerRows.html new file mode 100644 index 0000000000..008f208fdc --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/headerRows.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/mixedCellColors.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/mixedCellColors.html new file mode 100644 index 0000000000..05bcfd2bfc --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/mixedCellColors.html @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/mixedColWidths.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/mixedColWidths.html new file mode 100644 index 0000000000..72d863ebea --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/mixedColWidths.html @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/mixedRowspansAndColspans.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/mixedRowspansAndColspans.html new file mode 100644 index 0000000000..9ec43c73e7 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/table/mixedRowspansAndColspans.html @@ -0,0 +1,38 @@ + + + + + + + + + + + + + +
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
+

Table Cell

+
\ No newline at end of file diff --git a/tests/src/unit/react/formatConversion/export/__snapshots__/html/tag/basic.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/tag/basic.html new file mode 100644 index 0000000000..28d8392094 --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/tag/basic.html @@ -0,0 +1,7 @@ +

+ I love + + # + BlockNote + +

\ No newline at end of file diff --git a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/whitespace bold.json b/tests/src/unit/react/formatConversion/export/__snapshots__/html/twoDivs.json similarity index 50% rename from packages/core/src/api/parsers/markdown/__snapshots__/pasted/whitespace bold.json rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/twoDivs.json index 91798b8de7..e91570e36b 100644 --- a/packages/core/src/api/parsers/markdown/__snapshots__/pasted/whitespace bold.json +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/twoDivs.json @@ -1,42 +1,36 @@ [ { - "id": "0", - "type": "paragraph", - "props": { - "textColor": "default", - "backgroundColor": "default", - "textAlignment": "left" - }, + "children": [], "content": [ { + "styles": {}, + "text": "Single Div", "type": "text", - "text": "hello ", - "styles": {} }, + ], + "id": "1", + "props": { + "backgroundColor": "default", + "textAlignment": "left", + "textColor": "default", + }, + "type": "paragraph", + }, + { + "children": [], + "content": [ { + "styles": {}, + "text": "second Div", "type": "text", - "text": "beautiful ", - "styles": { - "bold": true - } }, - { - "type": "text", - "text": " world", - "styles": {} - } ], - "children": [] - }, - { "id": "2", - "type": "paragraph", "props": { - "textColor": "default", "backgroundColor": "default", - "textAlignment": "left" + "textAlignment": "left", + "textColor": "default", }, - "content": [], - "children": [] - } + "type": "paragraph", + }, ] \ No newline at end of file diff --git a/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html b/tests/src/unit/react/formatConversion/export/__snapshots__/html/twoTables.json similarity index 71% rename from packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html rename to tests/src/unit/react/formatConversion/export/__snapshots__/html/twoTables.json index 0a607ca98c..3ffbb3ead1 100644 --- a/packages/core/src/api/clipboard/__snapshots__/external/pasteEndOfParagraphText.html +++ b/tests/src/unit/react/formatConversion/export/__snapshots__/html/twoTables.json @@ -1,27 +1,9 @@ [ - { - "children": [], - "content": [ - { - "styles": {}, - "text": "ParagraphParagraph", - "type": "text", - }, - ], - "id": "0", - "props": { - "backgroundColor": "default", - "textAlignment": "left", - "textColor": "default", - }, - "type": "paragraph", - }, { "children": [], "content": { "columnWidths": [ undefined, - undefined, ], "headerCols": undefined, "headerRows": undefined, @@ -31,8 +13,10 @@ { "content": [ { - "styles": {}, - "text": "Table Cell", + "styles": { + "underline": true, + }, + "text": "Company", "type": "text", }, ], @@ -45,11 +29,25 @@ }, "type": "tableCell", }, + ], + }, + { + "cells": [ { "content": [ + { + "styles": { + "bold": true, + }, + "text": "Example Company Inc.", + "type": "text", + }, { "styles": {}, - "text": "Table Cell", + "text": " + +Name: [Company Representative] +Title: Chief Executive Officer", "type": "text", }, ], @@ -64,13 +62,33 @@ }, ], }, + ], + "type": "tableContent", + }, + "id": "1", + "props": { + "textColor": "default", + }, + "type": "table", + }, + { + "children": [], + "content": { + "columnWidths": [ + undefined, + ], + "headerCols": undefined, + "headerRows": undefined, + "rows": [ { "cells": [ { "content": [ { - "styles": {}, - "text": "Table Cell", + "styles": { + "underline": true, + }, + "text": "Advisor", "type": "text", }, ], @@ -83,11 +101,15 @@ }, "type": "tableCell", }, + ], + }, + { + "cells": [ { "content": [ { "styles": {}, - "text": "Table Cell", + "text": "[Advisor Name]", "type": "text", }, ], @@ -105,34 +127,10 @@ ], "type": "tableContent", }, - "id": "1", - "props": { - "textColor": "default", - }, - "type": "table", - }, - { - "children": [], - "content": [ - { - "styles": {}, - "text": "Custom Paragraph", - "type": "text", - }, - ], "id": "2", - "props": {}, - "type": "customParagraph", - }, - { - "children": [], - "content": [], - "id": "3", "props": { - "backgroundColor": "default", - "textAlignment": "left", "textColor": "default", }, - "type": "paragraph", + "type": "table", }, ] \ No newline at end of file diff --git a/packages/react/src/test/testCases/customReactBlocks.tsx b/tests/src/unit/react/formatConversion/export/exportTestInstances.ts similarity index 52% rename from packages/react/src/test/testCases/customReactBlocks.tsx rename to tests/src/unit/react/formatConversion/export/exportTestInstances.ts index b1dc6ce448..d822928fb6 100644 --- a/packages/react/src/test/testCases/customReactBlocks.tsx +++ b/tests/src/unit/react/formatConversion/export/exportTestInstances.ts @@ -1,105 +1,36 @@ +import { ExportTestCase } from "../../../shared/formatConversion/export/exportTestCase.js"; import { - BlockNoteEditor, - BlockNoteSchema, - DefaultInlineContentSchema, - DefaultStyleSchema, - EditorTestCases, - defaultBlockSpecs, - defaultProps, - uploadToTmpFilesDotOrg_DEV_ONLY, -} from "@blocknote/core"; -import { createContext, useContext } from "react"; - -import { ReactFileBlock } from "../../blocks/FileBlockContent/FileBlockContent.js"; -import { ReactImageBlock } from "../../blocks/ImageBlockContent/ImageBlockContent.js"; -import { createReactBlockSpec } from "../../schema/ReactBlockSpec.js"; - -const ReactCustomParagraph = createReactBlockSpec( - { - type: "reactCustomParagraph", - propSchema: defaultProps, - content: "inline", - }, - { - render: (props) => ( -

- ), - toExternalHTML: () => ( -

Hello World

- ), - } -); - -const SimpleReactCustomParagraph = createReactBlockSpec( - { - type: "simpleReactCustomParagraph", - propSchema: defaultProps, - content: "inline", - }, - { - render: (props) => ( -

- ), - } -); - -export const TestContext = createContext(undefined); - -const ReactContextParagraphComponent = (props: any) => { - const testData = useContext(TestContext); - if (testData === undefined) { - throw Error(); - } - - return

; -}; + testExportBlockNoteHTML, + testExportHTML, +} from "../../../shared/formatConversion/export/exportTestExecutors.js"; +import { TestInstance } from "../../../types.js"; +import { + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema, +} from "../../testSchema.js"; -const ReactContextParagraph = createReactBlockSpec( +export const exportTestInstancesBlockNoteHTML: TestInstance< + ExportTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = [ { - type: "reactContextParagraph", - propSchema: defaultProps, - content: "inline", - }, - { - render: ReactContextParagraphComponent, - } -); - -const schema = BlockNoteSchema.create({ - blockSpecs: { - ...defaultBlockSpecs, - file: ReactFileBlock, - image: ReactImageBlock, - reactCustomParagraph: ReactCustomParagraph, - simpleReactCustomParagraph: SimpleReactCustomParagraph, - reactContextParagraph: ReactContextParagraph, - }, -}); - -export const customReactBlockSchemaTestCases: EditorTestCases< - typeof schema.blockSchema, - DefaultInlineContentSchema, - DefaultStyleSchema -> = { - name: "custom react block schema", - createEditor: () => { - return BlockNoteEditor.create({ - schema, - uploadFile: uploadToTmpFilesDotOrg_DEV_ONLY, - }); - }, - documents: [ - { + testCase: { name: "reactFile/button", - blocks: [ + content: [ { type: "file", }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "reactFile/basic", - blocks: [ + content: [ { type: "file", props: { @@ -110,9 +41,12 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "reactFile/noName", - blocks: [ + content: [ { type: "file", props: { @@ -122,9 +56,12 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "reactFile/noCaption", - blocks: [ + content: [ { type: "file", props: { @@ -134,9 +71,12 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "reactFile/nested", - blocks: [ + content: [ { type: "file", props: { @@ -157,20 +97,26 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - // Because images need to fetch the download URL async, their internal HTML - // is initially rendered without a `src` attribute, which is reflected in - // the tests. - { + executeTest: testExportBlockNoteHTML, + }, + // Because images need to fetch the download URL async, their internal HTML + // is initially rendered without a `src` attribute, which is reflected in + // the tests. + { + testCase: { name: "reactImage/button", - blocks: [ + content: [ { type: "image", }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "reactImage/basic", - blocks: [ + content: [ { type: "image", props: { @@ -182,9 +128,12 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "reactImage/noName", - blocks: [ + content: [ { type: "image", props: { @@ -195,9 +144,12 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "reactImage/noCaption", - blocks: [ + content: [ { type: "image", props: { @@ -208,9 +160,12 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "reactImage/noPreview", - blocks: [ + content: [ { type: "image", props: { @@ -223,9 +178,12 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - { + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { name: "reactImage/nested", - blocks: [ + content: [ { type: "image", props: { @@ -248,20 +206,26 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - { - name: "reactCustomParagraph/basic", - blocks: [ + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "customParagraph/basic", + content: [ { - type: "reactCustomParagraph", + type: "customParagraph", content: "React Custom Paragraph", }, ], }, - { - name: "reactCustomParagraph/styled", - blocks: [ + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "customParagraph/styled", + content: [ { - type: "reactCustomParagraph", + type: "customParagraph", props: { textAlignment: "center", textColor: "orange", @@ -299,48 +263,60 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - { - name: "reactCustomParagraph/nested", - blocks: [ + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "customParagraph/nested", + content: [ { - type: "reactCustomParagraph", + type: "customParagraph", content: "React Custom Paragraph", children: [ { - type: "reactCustomParagraph", + type: "customParagraph", content: "Nested React Custom Paragraph 1", }, { - type: "reactCustomParagraph", + type: "customParagraph", content: "Nested React Custom Paragraph 2", }, ], }, ], }, - { - name: "reactCustomParagraph/lineBreaks", - blocks: [ + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "customParagraph/lineBreaks", + content: [ { - type: "reactCustomParagraph", + type: "customParagraph", content: "Line 1\nLine 2", }, ], }, - { - name: "simpleReactCustomParagraph/basic", - blocks: [ + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "simpleCustomParagraph/basic", + content: [ { - type: "simpleReactCustomParagraph", + type: "simpleCustomParagraph", content: "React Custom Paragraph", }, ], }, - { - name: "simpleReactCustomParagraph/styled", - blocks: [ + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "simpleCustomParagraph/styled", + content: [ { - type: "simpleReactCustomParagraph", + type: "simpleCustomParagraph", props: { textAlignment: "center", textColor: "orange", @@ -378,33 +354,130 @@ export const customReactBlockSchemaTestCases: EditorTestCases< }, ], }, - { - name: "simpleReactCustomParagraph/nested", - blocks: [ + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "simpleCustomParagraph/nested", + content: [ { - type: "simpleReactCustomParagraph", + type: "simpleCustomParagraph", content: "Custom React Paragraph", children: [ { - type: "simpleReactCustomParagraph", + type: "simpleCustomParagraph", content: "Nested React Custom Paragraph 1", }, { - type: "simpleReactCustomParagraph", + type: "simpleCustomParagraph", content: "Nested React Custom Paragraph 2", }, ], }, ], }, - { - name: "reactContextParagraph/basic", - blocks: [ + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "contextParagraph/basic", + content: [ { - type: "reactContextParagraph", + type: "contextParagraph", content: "React Context Paragraph", }, ], }, - ], -}; + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "mention/basic", + content: [ + { + type: "paragraph", + content: [ + "I enjoy working with ", + { + type: "mention", + props: { + user: "Matthew", + }, + content: undefined, + } as const, + ], + }, + ], + }, + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "tag/basic", + content: [ + { + type: "paragraph", + content: [ + "I love ", + { + type: "tag", + // props: {}, + content: "BlockNote", + } as const, + ], + }, + ], + }, + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "small/basic", + content: [ + { + type: "paragraph", + content: [ + { + type: "text", + text: "This is a small text", + styles: { + small: true, + }, + }, + ], + }, + ], + }, + executeTest: testExportBlockNoteHTML, + }, + { + testCase: { + name: "fontSize/basic", + content: [ + { + type: "paragraph", + content: [ + { + type: "text", + text: "This is text with a custom fontSize", + styles: { + fontSize: "18px", + }, + }, + ], + }, + ], + }, + executeTest: testExportBlockNoteHTML, + }, +]; + +export const exportTestInstancesHTML: TestInstance< + ExportTestCase, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = exportTestInstancesBlockNoteHTML.map(({ testCase }) => ({ + testCase, + executeTest: testExportHTML, +})); diff --git a/tests/src/unit/react/formatConversion/export/runTests.test.ts b/tests/src/unit/react/formatConversion/export/runTests.test.ts new file mode 100644 index 0000000000..92395d74ff --- /dev/null +++ b/tests/src/unit/react/formatConversion/export/runTests.test.ts @@ -0,0 +1,28 @@ +import { describe, it } from "vitest"; + +import { setupTestEditor } from "../../setupTestEditor.js"; +import { testSchema } from "../../testSchema.js"; +import { + exportTestInstancesBlockNoteHTML, + exportTestInstancesHTML, +} from "./exportTestInstances.js"; + +describe("React export tests (BlockNote HTML)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of exportTestInstancesBlockNoteHTML) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); + +describe("React export tests (HTML)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { testCase, executeTest } of exportTestInstancesHTML) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); diff --git a/tests/src/unit/react/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts b/tests/src/unit/react/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts new file mode 100644 index 0000000000..2deca013d9 --- /dev/null +++ b/tests/src/unit/react/formatConversion/exportParseEquality/exportParseEqualityTestInstances.ts @@ -0,0 +1,40 @@ +import { ExportParseEqualityTestCase } from "../../../shared/formatConversion/exportParseEquality/exportParseEqualityTestCase.js"; +import { + testExportParseEqualityBlockNoteHTML, + testExportParseEqualityNodes, +} from "../../../shared/formatConversion/exportParseEquality/exportParseEqualityTestExecutors.js"; +import { TestInstance } from "../../../types.js"; +import { + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema, +} from "../../testSchema.js"; +import { exportTestInstancesBlockNoteHTML } from "../export/exportTestInstances.js"; + +export const exportParseEqualityTestInstancesBlockNoteHTML: TestInstance< + ExportParseEqualityTestCase< + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema + >, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = exportTestInstancesBlockNoteHTML.map(({ testCase }) => ({ + testCase, + executeTest: testExportParseEqualityBlockNoteHTML, +})); + +export const exportParseEqualityTestInstancesNodes: TestInstance< + ExportParseEqualityTestCase< + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema + >, + TestBlockSchema, + TestInlineContentSchema, + TestStyleSchema +>[] = exportParseEqualityTestInstancesBlockNoteHTML.map(({ testCase }) => ({ + testCase, + executeTest: testExportParseEqualityNodes, +})); diff --git a/tests/src/unit/react/formatConversion/exportParseEquality/runTests.test.ts b/tests/src/unit/react/formatConversion/exportParseEquality/runTests.test.ts new file mode 100644 index 0000000000..75bfe85897 --- /dev/null +++ b/tests/src/unit/react/formatConversion/exportParseEquality/runTests.test.ts @@ -0,0 +1,34 @@ +import { describe, it } from "vitest"; + +import { setupTestEditor } from "../../setupTestEditor.js"; +import { testSchema } from "../../testSchema.js"; +import { + exportParseEqualityTestInstancesBlockNoteHTML, + exportParseEqualityTestInstancesNodes, +} from "./exportParseEqualityTestInstances.js"; + +describe("Export/parse equality tests (BlockNote HTML)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { + testCase, + executeTest, + } of exportParseEqualityTestInstancesBlockNoteHTML) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); + +describe("Export/parse equality tests (TipTap nodes)", () => { + const getEditor = setupTestEditor(testSchema); + + for (const { + testCase, + executeTest, + } of exportParseEqualityTestInstancesNodes) { + it(`${testCase.name}`, async () => { + await executeTest(getEditor(), testCase); + }); + } +}); diff --git a/tests/src/unit/react/setupTestEditor.tsx b/tests/src/unit/react/setupTestEditor.tsx new file mode 100644 index 0000000000..428a9d73b2 --- /dev/null +++ b/tests/src/unit/react/setupTestEditor.tsx @@ -0,0 +1,66 @@ +import { + BlockNoteEditor, + BlockNoteSchema, + BlockSchema, + initializeESMDependencies, + InlineContentSchema, + StyleSchema, +} from "@blocknote/core"; +import { BlockNoteViewRaw } from "@blocknote/react"; +import { flushSync } from "react-dom"; +import { createRoot, Root } from "react-dom/client"; +import { afterAll, beforeAll } from "vitest"; + +import { TestContext } from "./testSchema.js"; + +export const setupTestEditor = < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + schema: BlockNoteSchema +): (() => BlockNoteEditor) => { + let editor: BlockNoteEditor; + const div = document.createElement("div"); + + // Note that we don't necessarily need to mount a root (unless we need a React Context) + // Currently, we do mount to a root so that it reflects the "production" use-case more closely. + + // However, it would be nice to increased converage and share the same set of tests for these cases: + // - does render to a root + // - does not render to a root + // - runs in server (jsdom) environment using server-util + let root: Root; + + beforeAll(async () => { + (window as any).__TEST_OPTIONS = (window as any).__TEST_OPTIONS || {}; + + editor = BlockNoteEditor.create({ + schema, + trailingBlock: false, + }); + + const el = ( + + + + ); + root = createRoot(div); + flushSync(() => { + // eslint-disable-next-line testing-library/no-render-in-setup + root.render(el); + }); + + await initializeESMDependencies(); + }); + + afterAll(() => { + root.unmount(); + editor._tiptapEditor.destroy(); + editor = undefined as any; + + delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS; + }); + + return () => editor; +}; diff --git a/tests/src/unit/react/testSchema.tsx b/tests/src/unit/react/testSchema.tsx new file mode 100644 index 0000000000..e08151c1ca --- /dev/null +++ b/tests/src/unit/react/testSchema.tsx @@ -0,0 +1,157 @@ +import { + BlockNoteSchema, + defaultBlockSpecs, + defaultInlineContentSpecs, + defaultProps, + defaultStyleSpecs, + PageBreak, +} from "@blocknote/core"; +import { + createReactBlockSpec, + createReactInlineContentSpec, + createReactStyleSpec, +} from "@blocknote/react"; +import { createContext, useContext } from "react"; + +// BLOCKS ---------------------------------------------------------------------- + +const CustomParagraph = createReactBlockSpec( + { + type: "customParagraph", + propSchema: defaultProps, + content: "inline", + }, + { + render: (props) => ( +

+ ), + toExternalHTML: () => ( +

Hello World

+ ), + } +); + +const SimpleCustomParagraph = createReactBlockSpec( + { + type: "simpleCustomParagraph", + propSchema: defaultProps, + content: "inline", + }, + { + render: (props) => ( +

+ ), + } +); + +export const TestContext = createContext(undefined); + +const ContextParagraphComponent = (props: any) => { + const testData = useContext(TestContext); + if (testData === undefined) { + throw Error(); + } + + return

; +}; + +const ContextParagraph = createReactBlockSpec( + { + type: "contextParagraph", + propSchema: defaultProps, + content: "inline", + }, + { + render: ContextParagraphComponent, + } +); + +// INLINE CONTENT -------------------------------------------------------------- + +const Mention = createReactInlineContentSpec( + { + type: "mention", + propSchema: { + user: { + default: "", + }, + }, + content: "none", + }, + { + render: (props) => { + return @{props.inlineContent.props.user}; + }, + } +); + +const Tag = createReactInlineContentSpec( + { + type: "tag", + propSchema: {}, + content: "styled", + }, + { + render: (props) => { + return ( + + # + + ); + }, + } +); + +// STYLES ---------------------------------------------------------------------- + +const Small = createReactStyleSpec( + { + type: "small", + propSchema: "boolean", + }, + { + render: (props) => { + return ; + }, + } +); + +const FontSize = createReactStyleSpec( + { + type: "fontSize", + propSchema: "string", + }, + { + render: (props) => { + return ( + + ); + }, + } +); + +// SCHEMA ---------------------------------------------------------------------- + +export const testSchema = BlockNoteSchema.create({ + blockSpecs: { + ...defaultBlockSpecs, + pageBreak: PageBreak, + customParagraph: CustomParagraph, + simpleCustomParagraph: SimpleCustomParagraph, + contextParagraph: ContextParagraph, + }, + inlineContentSpecs: { + ...defaultInlineContentSpecs, + mention: Mention, + tag: Tag, + }, + styleSpecs: { + ...defaultStyleSpecs, + small: Small, + fontSize: FontSize, + }, +}); + +export type TestBlockSchema = typeof testSchema.blockSchema; +export type TestInlineContentSchema = typeof testSchema.inlineContentSchema; +export type TestStyleSchema = typeof testSchema.styleSchema; diff --git a/tests/src/unit/shared/clipboard/copy/copyTestCase.ts b/tests/src/unit/shared/clipboard/copy/copyTestCase.ts new file mode 100644 index 0000000000..fdc3eeeedb --- /dev/null +++ b/tests/src/unit/shared/clipboard/copy/copyTestCase.ts @@ -0,0 +1,18 @@ +import { + BlockSchema, + InlineContentSchema, + PartialBlock, + StyleSchema, +} from "@blocknote/core"; +import { Node } from "@tiptap/pm/model"; +import { Selection } from "@tiptap/pm/state"; + +export type CopyTestCase< + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +> = { + name: string; + document: PartialBlock[]; + getCopySelection: (pmDoc: Node) => Selection; +}; diff --git a/tests/src/unit/shared/clipboard/copy/copyTestExecutors.ts b/tests/src/unit/shared/clipboard/copy/copyTestExecutors.ts new file mode 100644 index 0000000000..90ac812fc6 --- /dev/null +++ b/tests/src/unit/shared/clipboard/copy/copyTestExecutors.ts @@ -0,0 +1,69 @@ +import { prettify } from "htmlfy"; +import { expect } from "vitest"; +import { + BlockNoteEditor, + BlockSchema, + InlineContentSchema, + selectedFragmentToHTML, + StyleSchema, +} from "@blocknote/core"; + +import { setupClipboardTest } from "../../../core/clipboard/clipboardTestUtil.js"; +import { CopyTestCase } from "./copyTestCase.js"; + +export const testCopyBlockNoteHTML = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: CopyTestCase +) => { + setupClipboardTest(editor, testCase.document, testCase.getCopySelection); + + const { clipboardHTML } = selectedFragmentToHTML( + editor.prosemirrorView!, + editor + ); + + await expect(prettify(clipboardHTML, { tag_wrap: true })).toMatchFileSnapshot( + `./__snapshots__/blocknote/html/${testCase.name}.html` + ); +}; + +export const testCopyHTML = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: CopyTestCase +) => { + setupClipboardTest(editor, testCase.document, testCase.getCopySelection); + + const { externalHTML } = selectedFragmentToHTML( + editor.prosemirrorView!, + editor + ); + + await expect(prettify(externalHTML, { tag_wrap: true })).toMatchFileSnapshot( + `./__snapshots__/text/html/${testCase.name}.html` + ); +}; + +export const testCopyMarkdown = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: CopyTestCase +) => { + setupClipboardTest(editor, testCase.document, testCase.getCopySelection); + + const { markdown } = selectedFragmentToHTML(editor.prosemirrorView!, editor); + + await expect(markdown).toMatchFileSnapshot( + `./__snapshots__/text/plain/${testCase.name}.md` + ); +}; diff --git a/tests/src/unit/shared/clipboard/copyPaste/copyPasteTestCase.ts b/tests/src/unit/shared/clipboard/copyPaste/copyPasteTestCase.ts new file mode 100644 index 0000000000..9eb7c350c7 --- /dev/null +++ b/tests/src/unit/shared/clipboard/copyPaste/copyPasteTestCase.ts @@ -0,0 +1,19 @@ +import { + BlockSchema, + InlineContentSchema, + PartialBlock, + StyleSchema, +} from "@blocknote/core"; +import { Node } from "@tiptap/pm/model"; +import { Selection } from "@tiptap/pm/state"; + +export type CopyPasteTestCase< + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +> = { + name: string; + document: PartialBlock[]; + getCopySelection: (pmDoc: Node) => Selection; + getPasteSelection: (pmDoc: Node) => Selection; +}; diff --git a/tests/src/unit/shared/clipboard/copyPaste/copyPasteTestExecutors.ts b/tests/src/unit/shared/clipboard/copyPaste/copyPasteTestExecutors.ts new file mode 100644 index 0000000000..c1864e2ded --- /dev/null +++ b/tests/src/unit/shared/clipboard/copyPaste/copyPasteTestExecutors.ts @@ -0,0 +1,44 @@ +import { + BlockNoteEditor, + BlockSchema, + InlineContentSchema, + selectedFragmentToHTML, + StyleSchema, +} from "@blocknote/core"; +import { expect } from "vitest"; + +import { + doPaste, + setupClipboardTest, +} from "../../../core/clipboard/clipboardTestUtil.js"; +import { CopyPasteTestCase } from "./copyPasteTestCase.js"; + +export const testCopyPaste = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: CopyPasteTestCase +) => { + setupClipboardTest(editor, testCase.document, testCase.getCopySelection); + + const { clipboardHTML } = selectedFragmentToHTML( + editor.prosemirrorView!, + editor + ); + + editor.transact((tr) => tr.setSelection(testCase.getPasteSelection(tr.doc))); + + doPaste( + editor.prosemirrorView!, + "text", + clipboardHTML, + false, + new ClipboardEvent("paste") + ); + + await expect(editor.document).toMatchFileSnapshot( + `./__snapshots__/${testCase.name}.json` + ); +}; diff --git a/tests/src/unit/shared/clipboard/copyPasteEquality/copyPasteEqualityTestCase.ts b/tests/src/unit/shared/clipboard/copyPasteEquality/copyPasteEqualityTestCase.ts new file mode 100644 index 0000000000..378a8cc275 --- /dev/null +++ b/tests/src/unit/shared/clipboard/copyPasteEquality/copyPasteEqualityTestCase.ts @@ -0,0 +1,18 @@ +import { + BlockSchema, + InlineContentSchema, + PartialBlock, + StyleSchema, +} from "@blocknote/core"; +import { Node } from "@tiptap/pm/model"; +import { Selection } from "@tiptap/pm/state"; + +export type CopyPasteEqualityTestCase< + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +> = { + name: string; + document: PartialBlock[]; + getCopyAndPasteSelection: (pmDoc: Node) => Selection; +}; diff --git a/tests/src/unit/shared/clipboard/copyPasteEquality/copyPasteEqualityTestExecutors.ts b/tests/src/unit/shared/clipboard/copyPasteEquality/copyPasteEqualityTestExecutors.ts new file mode 100644 index 0000000000..1406739f55 --- /dev/null +++ b/tests/src/unit/shared/clipboard/copyPasteEquality/copyPasteEqualityTestExecutors.ts @@ -0,0 +1,46 @@ +import { + BlockNoteEditor, + BlockSchema, + InlineContentSchema, + selectedFragmentToHTML, + StyleSchema, +} from "@blocknote/core"; +import { expect } from "vitest"; + +import { + doPaste, + setupClipboardTest, +} from "../../../core/clipboard/clipboardTestUtil.js"; +import { CopyPasteEqualityTestCase } from "./copyPasteEqualityTestCase.js"; + +export const testCopyPasteEquality = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: CopyPasteEqualityTestCase +) => { + setupClipboardTest( + editor, + testCase.document, + testCase.getCopyAndPasteSelection + ); + + const { clipboardHTML } = selectedFragmentToHTML( + editor.prosemirrorView!, + editor + ); + + const originalDocument = editor.document; + doPaste( + editor.prosemirrorView!, + "text", + clipboardHTML, + false, + new ClipboardEvent("paste") + ); + const newDocument = editor.document; + + expect(newDocument).toStrictEqual(originalDocument); +}; diff --git a/tests/src/unit/shared/clipboard/paste/pasteTestCase.ts b/tests/src/unit/shared/clipboard/paste/pasteTestCase.ts new file mode 100644 index 0000000000..2aaf323428 --- /dev/null +++ b/tests/src/unit/shared/clipboard/paste/pasteTestCase.ts @@ -0,0 +1,19 @@ +import { + BlockSchema, + InlineContentSchema, + PartialBlock, + StyleSchema, +} from "@blocknote/core"; +import { Node } from "@tiptap/pm/model"; +import { Selection } from "@tiptap/pm/state"; + +export type PasteTestCase< + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +> = { + name: string; + content: string; + document: PartialBlock[]; + getPasteSelection: (pmDoc: Node) => Selection; +}; diff --git a/tests/src/unit/shared/clipboard/paste/pasteTestExecutors.ts b/tests/src/unit/shared/clipboard/paste/pasteTestExecutors.ts new file mode 100644 index 0000000000..8cd46e81bc --- /dev/null +++ b/tests/src/unit/shared/clipboard/paste/pasteTestExecutors.ts @@ -0,0 +1,59 @@ +import { + BlockNoteEditor, + BlockSchema, + InlineContentSchema, + StyleSchema, +} from "@blocknote/core"; +import { expect } from "vitest"; + +import { + doPaste, + setupClipboardTest, +} from "../../../core/clipboard/clipboardTestUtil.js"; +import { PasteTestCase } from "./pasteTestCase.js"; + +export const testPasteHTML = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: PasteTestCase +) => { + setupClipboardTest(editor, testCase.document, testCase.getPasteSelection); + + doPaste( + editor.prosemirrorView!, + "", + testCase.content, + false, + new ClipboardEvent("paste") + ); + + await expect(editor.document).toMatchFileSnapshot( + `./__snapshots__/text/html/${testCase.name}.json` + ); +}; + +export const testPasteMarkdown = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: PasteTestCase +) => { + setupClipboardTest(editor, testCase.document, testCase.getPasteSelection); + + doPaste( + editor.prosemirrorView!, + testCase.content, + "", + true, + new ClipboardEvent("paste") + ); + + await expect(editor.document).toMatchFileSnapshot( + `./__snapshots__/text/plain/${testCase.name}.json` + ); +}; diff --git a/tests/src/unit/shared/formatConversion/export/exportTestCase.ts b/tests/src/unit/shared/formatConversion/export/exportTestCase.ts new file mode 100644 index 0000000000..5375dc00d3 --- /dev/null +++ b/tests/src/unit/shared/formatConversion/export/exportTestCase.ts @@ -0,0 +1,15 @@ +import { + BlockSchema, + InlineContentSchema, + PartialBlock, + StyleSchema, +} from "@blocknote/core"; + +export type ExportTestCase< + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +> = { + name: string; + content: PartialBlock[]; +}; diff --git a/tests/src/unit/shared/formatConversion/export/exportTestExecutors.ts b/tests/src/unit/shared/formatConversion/export/exportTestExecutors.ts new file mode 100644 index 0000000000..3bcfebbdb4 --- /dev/null +++ b/tests/src/unit/shared/formatConversion/export/exportTestExecutors.ts @@ -0,0 +1,86 @@ +import { + BlockNoteEditor, + BlockSchema, + blockToNode, + InlineContentSchema, + StyleSchema, +} from "@blocknote/core"; +import { prettify } from "htmlfy"; +import { expect } from "vitest"; + +import { addIdsToBlocks } from "../../../core/formatConversion/formatConversionTestUtil.js"; +import { ExportTestCase } from "./exportTestCase.js"; + +export const testExportBlockNoteHTML = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: ExportTestCase +) => { + (window as any).__TEST_OPTIONS.mockID = 0; + + addIdsToBlocks(testCase.content); + + await expect( + prettify(await editor.blocksToFullHTML(testCase.content), { + tag_wrap: true, + }) + ).toMatchFileSnapshot(`./__snapshots__/blocknoteHTML/${testCase.name}.html`); +}; + +export const testExportHTML = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: ExportTestCase +) => { + (window as any).__TEST_OPTIONS.mockID = 0; + + addIdsToBlocks(testCase.content); + + await expect( + prettify(await editor.blocksToHTMLLossy(testCase.content), { + tag_wrap: true, + }) + ).toMatchFileSnapshot(`./__snapshots__/html/${testCase.name}.html`); +}; + +export const testExportMarkdown = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: ExportTestCase +) => { + (window as any).__TEST_OPTIONS.mockID = 0; + + addIdsToBlocks(testCase.content); + + await expect( + await editor.blocksToMarkdownLossy(testCase.content) + ).toMatchFileSnapshot(`./__snapshots__/markdown/${testCase.name}.md`); +}; + +export const testExportNodes = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: ExportTestCase +) => { + (window as any).__TEST_OPTIONS.mockID = 0; + + addIdsToBlocks(testCase.content); + + await expect( + testCase.content.map((block) => + blockToNode(block, editor.pmSchema, editor.schema.styleSchema) + ) + ).toMatchFileSnapshot(`./__snapshots__/nodes/${testCase.name}.json`); +}; diff --git a/tests/src/unit/shared/formatConversion/exportParseEquality/exportParseEqualityTestCase.ts b/tests/src/unit/shared/formatConversion/exportParseEquality/exportParseEqualityTestCase.ts new file mode 100644 index 0000000000..069f902669 --- /dev/null +++ b/tests/src/unit/shared/formatConversion/exportParseEquality/exportParseEqualityTestCase.ts @@ -0,0 +1,15 @@ +import { + BlockSchema, + InlineContentSchema, + PartialBlock, + StyleSchema, +} from "@blocknote/core"; + +export type ExportParseEqualityTestCase< + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +> = { + name: string; + content: PartialBlock[]; +}; diff --git a/tests/src/unit/shared/formatConversion/exportParseEquality/exportParseEqualityTestExecutors.ts b/tests/src/unit/shared/formatConversion/exportParseEquality/exportParseEqualityTestExecutors.ts new file mode 100644 index 0000000000..42a75f61c1 --- /dev/null +++ b/tests/src/unit/shared/formatConversion/exportParseEquality/exportParseEqualityTestExecutors.ts @@ -0,0 +1,57 @@ +import { + BlockNoteEditor, + BlockSchema, + blockToNode, + InlineContentSchema, + nodeToBlock, + StyleSchema, +} from "@blocknote/core"; +import { expect } from "vitest"; + +import { + addIdsToBlocks, + partialBlocksToBlocksForTesting, +} from "../../../core/formatConversion/formatConversionTestUtil.js"; +import { ExportParseEqualityTestCase } from "./exportParseEqualityTestCase.js"; + +export const testExportParseEqualityBlockNoteHTML = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: ExportParseEqualityTestCase +) => { + (window as any).__TEST_OPTIONS.mockID = 0; + + addIdsToBlocks(testCase.content); + + const exported = await editor.blocksToFullHTML(testCase.content); + + expect(await editor.tryParseHTMLToBlocks(exported)).toStrictEqual( + partialBlocksToBlocksForTesting(editor.schema, testCase.content) + ); +}; + +export const testExportParseEqualityNodes = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: ExportParseEqualityTestCase +) => { + (window as any).__TEST_OPTIONS.mockID = 0; + + addIdsToBlocks(testCase.content); + + const exported = testCase.content.map((block) => + blockToNode(block, editor.pmSchema) + ); + + expect( + exported.map((node) => nodeToBlock(node, editor.pmSchema)) + ).toStrictEqual( + partialBlocksToBlocksForTesting(editor.schema, testCase.content) + ); +}; diff --git a/tests/src/unit/shared/formatConversion/parse/parseTestCase.ts b/tests/src/unit/shared/formatConversion/parse/parseTestCase.ts new file mode 100644 index 0000000000..da457e3bc0 --- /dev/null +++ b/tests/src/unit/shared/formatConversion/parse/parseTestCase.ts @@ -0,0 +1,4 @@ +export type ParseTestCase = { + name: string; + content: string; +}; diff --git a/tests/src/unit/shared/formatConversion/parse/parseTestExecutors.ts b/tests/src/unit/shared/formatConversion/parse/parseTestExecutors.ts new file mode 100644 index 0000000000..5f10fffaf1 --- /dev/null +++ b/tests/src/unit/shared/formatConversion/parse/parseTestExecutors.ts @@ -0,0 +1,39 @@ +import { + BlockNoteEditor, + BlockSchema, + InlineContentSchema, + StyleSchema, +} from "@blocknote/core"; +import { expect } from "vitest"; + +import { ParseTestCase } from "./parseTestCase.js"; + +export const testParseHTML = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: ParseTestCase +) => { + (window as any).__TEST_OPTIONS.mockID = 0; + + await expect( + await editor.tryParseHTMLToBlocks(testCase.content) + ).toMatchFileSnapshot(`./__snapshots__/html/${testCase.name}.json`); +}; + +export const testParseMarkdown = async < + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +>( + editor: BlockNoteEditor, + testCase: ParseTestCase +) => { + (window as any).__TEST_OPTIONS.mockID = 0; + + await expect( + await editor.tryParseMarkdownToBlocks(testCase.content) + ).toMatchFileSnapshot(`./__snapshots__/markdown/${testCase.name}.json`); +}; diff --git a/tests/src/unit/types.ts b/tests/src/unit/types.ts new file mode 100644 index 0000000000..766d5e2528 --- /dev/null +++ b/tests/src/unit/types.ts @@ -0,0 +1,23 @@ +import { + BlockNoteEditor, + BlockSchema, + InlineContentSchema, + StyleSchema, +} from "@blocknote/core"; + +export type TestExecutor< + TestCase, + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +> = (editor: BlockNoteEditor, testCase: TestCase) => Promise; + +export type TestInstance< + TestCase, + B extends BlockSchema, + I extends InlineContentSchema, + S extends StyleSchema +> = { + testCase: TestCase; + executeTest: TestExecutor; +}; diff --git a/tests/vite.config.ts b/tests/vite.config.ts new file mode 100644 index 0000000000..4aa2e6d97c --- /dev/null +++ b/tests/vite.config.ts @@ -0,0 +1,25 @@ +import * as path from "path"; +import { defineConfig } from "vite"; +import eslintPlugin from "vite-plugin-eslint"; + +// https://vitejs.dev/config/ +export default defineConfig((conf) => ({ + test: { + environment: "jsdom", + setupFiles: ["./vitestSetup.ts"], + include: ["./src/unit/**/*.test.ts"], + }, + resolve: { + alias: + conf.command === "build" + ? ({} as Record) + : ({ + // load live from sources with live reload working + "@blocknote/core": path.resolve(__dirname, "../packages/core/src/"), + "@blocknote/react": path.resolve( + __dirname, + "../packages/react/src/" + ), + } as Record), + }, +})); diff --git a/tests/vitestSetup.ts b/tests/vitestSetup.ts new file mode 100644 index 0000000000..9a869521e0 --- /dev/null +++ b/tests/vitestSetup.ts @@ -0,0 +1,35 @@ +import { afterEach, beforeEach } from "vitest"; + +beforeEach(() => { + (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS = {}; +}); + +afterEach(() => { + delete (window as Window & { __TEST_OPTIONS?: any }).__TEST_OPTIONS; +}); + +// Mock ClipboardEvent +class ClipboardEventMock extends Event { + public clipboardData = { + getData: () => { + // + }, + setData: () => { + // + }, + }; +} +(global as any).ClipboardEvent = ClipboardEventMock; + +// Mock DragEvent +class DragEventMock extends Event { + public dataTransfer = { + getData: () => { + // + }, + setData: () => { + // + }, + }; +} +(global as any).DragEvent = DragEventMock;