Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid saving without changes #2686

Merged
merged 4 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/EditorFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const createEditor = ({ content, onCreate, onUpdate, extensions, enableRichEditi
}
extensions = extensions || []
return new Editor({
content,
content: content + '<p/>',
max-nextcloud marked this conversation as resolved.
Show resolved Hide resolved
onCreate,
onUpdate,
editorProps: {
Expand Down
2 changes: 2 additions & 0 deletions src/tests/fixtures/tables/basic.out.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@
<td colspan="1" rowspan="1">other cell</td>
</tr>
</table>
<p>
</p>
2 changes: 2 additions & 0 deletions src/tests/fixtures/tables/handbook.out.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@
<td colspan="1" rowspan="1">16</td>
</tr>
</table>
<p>
</p>
24 changes: 24 additions & 0 deletions src/tests/markdown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,27 @@ describe('Markdown serializer from html', () => {
expect(markdownThroughEditorHtml('<pre id="frontmatter"><code>---</code></pre><h1>Heading</h1>')).toBe('----\n---\n----\n\n# Heading')
})
})

describe('Trailing nodes', () => {
test('No extra transaction is added after loading', () => {
const source = "# My heading\n\n* test\n* test2"
const tiptap = createEditor({
content: markdownit.render(source),
enableRichEditing: true,
})

const jsonBefore = tiptap.getJSON()

// Focus triggers a transaction which is adding the trailing node
// this pushes a step through the collaboration plugin
// Resulting markdown will not contain the trailing paragraph so everytime the tiptap instance is created from the html, this transaction gets dispatched
tiptap.commands.focus()

const jsonAfter = tiptap.getJSON()
expect(jsonAfter).toStrictEqual(jsonBefore)

const serializer = createMarkdownSerializer(tiptap.schema)
const md = serializer.serialize(tiptap.state.doc)
expect(md).toBe(source)
})
})