mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-23 14:06:00 +03:00
Add isEmpty extension to remove on:content event from collaborator editor (#3774)
* Add validation extension to remove on content event from collaborator editor Signed-off-by: Anna No <anna.no@xored.com> * Add validation extension to remove on content event from collaborator editor Signed-off-by: Anna No <anna.no@xored.com> * Add validation extension to remove on content event from collaborator editor Signed-off-by: Anna No <anna.no@xored.com> * Add isEmpty extension to remove on:content event from collaborator editor Signed-off-by: Anna No <anna.no@xored.com> * Add isEmpty extension to remove on:content event from collaborator editor Signed-off-by: Anna No <anna.no@xored.com> * Add isEmpty extension to remove on:content event from collaborator editor Signed-off-by: Anna No <anna.no@xored.com> * Add isEmpty extension to remove on:content event from collaborator editor Signed-off-by: Anna No <anna.no@xored.com> --------- Signed-off-by: Anna No <anna.no@xored.com>
This commit is contained in:
parent
56f0dc573d
commit
152c858c1d
@ -0,0 +1,34 @@
|
|||||||
|
import { Extension } from '@tiptap/core'
|
||||||
|
|
||||||
|
export interface IsEmptyContentOptions {
|
||||||
|
onChange: (isEmpty: boolean) => void
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface IsEmptyContentStorage {
|
||||||
|
isEmpty: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export const IsEmptyContentExtension: Extension<IsEmptyContentOptions, IsEmptyContentStorage> =
|
||||||
|
Extension.create<IsEmptyContentOptions>({
|
||||||
|
name: 'is-empty-content-extension',
|
||||||
|
addStorage () {
|
||||||
|
return {
|
||||||
|
isEmpty: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onCreate () {
|
||||||
|
this.parent?.()
|
||||||
|
|
||||||
|
this.storage.isEmpty = this.editor.isEmpty
|
||||||
|
this.options.onChange(this.storage.isEmpty)
|
||||||
|
},
|
||||||
|
onUpdate () {
|
||||||
|
this.parent?.()
|
||||||
|
|
||||||
|
if (this.storage.isEmpty !== this.editor.isEmpty) {
|
||||||
|
this.storage.isEmpty = this.editor.isEmpty
|
||||||
|
|
||||||
|
this.options.onChange(this.storage.isEmpty)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
@ -31,6 +31,11 @@ export * from './types'
|
|||||||
export { default as Collaboration } from './components/Collaboration.svelte'
|
export { default as Collaboration } from './components/Collaboration.svelte'
|
||||||
export { default as StyleButton } from './components/StyleButton.svelte'
|
export { default as StyleButton } from './components/StyleButton.svelte'
|
||||||
|
|
||||||
|
export {
|
||||||
|
IsEmptyContentExtension,
|
||||||
|
IsEmptyContentOptions,
|
||||||
|
IsEmptyContentStorage
|
||||||
|
} from './components/extension/isEmptyContent'
|
||||||
export {
|
export {
|
||||||
NodeHighlightExtension,
|
NodeHighlightExtension,
|
||||||
NodeHighlightExtensionOptions,
|
NodeHighlightExtensionOptions,
|
||||||
|
Loading…
Reference in New Issue
Block a user