mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-08 01:53:04 +08:00
fix: use editorView
for isDestroyed
check for SSR (#6233)
* fix: use `editorView` for `isDestroyed` check for SSR * chore: update import of `fast-deep-equal` to include extension * chore: fix unrelated issue * chore: add changeset --------- Co-authored-by: bdbch <6538827+bdbch@users.noreply.github.com>
This commit is contained in:
parent
dca2852f25
commit
5e957e5373
5
.changeset/cool-singers-call.md
Normal file
5
.changeset/cool-singers-call.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
'@tiptap/core': major
|
||||
---
|
||||
|
||||
This resolves in issue with SSR where the isDestroyed property could not be read while in SSR
|
@ -1,6 +1,5 @@
|
||||
import { Extension } from '@tiptap/core'
|
||||
import { NodeSelection, Plugin } from '@tiptap/pm/state'
|
||||
import { EditorView } from '@tiptap/pm/view'
|
||||
|
||||
function removeNode(node) {
|
||||
node.parentNode.removeChild(node)
|
||||
@ -63,7 +62,7 @@ export default Extension.create({
|
||||
// from: view.nodeDOM(view.state.selection.from),
|
||||
// to: view.nodeDOM(view.state.selection.to),
|
||||
// })
|
||||
const { dom, text } = EditorView.serializeForClipboard(view, slice)
|
||||
const { dom, text } = view.serializeForClipboard(slice)
|
||||
|
||||
e.dataTransfer.clearData()
|
||||
e.dataTransfer.setData('text/html', dom.innerHTML)
|
||||
|
@ -287,6 +287,7 @@ export class Editor extends EventEmitter<EditorEvents> {
|
||||
composing: false,
|
||||
dragging: null,
|
||||
editable: true,
|
||||
isDestroyed: false,
|
||||
} as EditorView,
|
||||
{
|
||||
get: (obj, key) => {
|
||||
@ -717,8 +718,7 @@ export class Editor extends EventEmitter<EditorEvents> {
|
||||
* Check if the editor is already destroyed.
|
||||
*/
|
||||
public get isDestroyed(): boolean {
|
||||
// @ts-ignore
|
||||
return !this.view?.docView
|
||||
return !this.editorView?.isDestroyed
|
||||
}
|
||||
|
||||
public $node(selector: string, attributes?: { [key: string]: any }): NodePos | null {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import type { Editor } from '@tiptap/core'
|
||||
import deepEqual from 'fast-deep-equal/es6/react'
|
||||
import deepEqual from 'fast-deep-equal/es6/react.js'
|
||||
import { useDebugValue, useEffect, useLayoutEffect, useState } from 'react'
|
||||
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user