Skip to content
Open
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
18 changes: 1 addition & 17 deletions lib/components/Tapwrite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import { TableCell } from './tiptap/table/table-cell'
import { Box, IconButton, Stack } from '@mui/material'
import Hardbreak from '@tiptap/extension-hard-break'
import Placeholder from '@tiptap/extension-placeholder'
import { EditorState } from '@tiptap/pm/state'
import { useAppState } from '../context/useAppState'
import { AttachmentIcon } from '../icons'
import { NotionLikeProps } from '../main'
Expand Down Expand Up @@ -258,22 +257,7 @@ export const Editor = ({

useEffect(() => {
if (editor && content !== editor.getHTML()) {
editor.commands.setContent(content)

setTimeout(() => {
const { state, view } = editor

// Create a new EditorState without undo/redo history
// This is necessary because a history is set after setContent command is run. So when cmd+z is operated,
// it ends up in an empty state.
const newState = EditorState.create({
doc: state.doc,
plugins: state.plugins, // Preserve the plugins
})

// Replace the editor state with the new state (without history)
view.updateState(newState)
}, 0)
editor.commands.setContent(content, false) // no history entry
}
}, [content, editor])

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tapwrite",
"private": false,
"version": "1.1.93",
"version": "1.1.94",
"type": "module",
"main": "dist/main.js",
"types": "dist/main.d.ts",
Expand Down