mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-21 07:18:05 +08:00
bdc51d12b5
# Conflicts: # CHANGELOG.md # demos/CHANGELOG.md # demos/package-lock.json # demos/package.json # demos/src/Examples/CollaborativeEditing/React/index.jsx # lerna.json # package-lock.json # packages/core/CHANGELOG.md # packages/core/package.json # packages/extension-blockquote/CHANGELOG.md # packages/extension-blockquote/package.json # packages/extension-bold/CHANGELOG.md # packages/extension-bold/package.json # packages/extension-bubble-menu/CHANGELOG.md # packages/extension-bubble-menu/package.json # packages/extension-bullet-list/CHANGELOG.md # packages/extension-bullet-list/package.json # packages/extension-character-count/CHANGELOG.md # packages/extension-character-count/package.json # packages/extension-code-block-lowlight/CHANGELOG.md # packages/extension-code-block-lowlight/package.json # packages/extension-code-block/CHANGELOG.md # packages/extension-code-block/package.json # packages/extension-code/CHANGELOG.md # packages/extension-code/package.json # packages/extension-collaboration-cursor/CHANGELOG.md # packages/extension-collaboration-cursor/package.json # packages/extension-collaboration/CHANGELOG.md # packages/extension-collaboration/package.json # packages/extension-color/CHANGELOG.md # packages/extension-color/package.json # packages/extension-document/CHANGELOG.md # packages/extension-document/package.json # packages/extension-dropcursor/CHANGELOG.md # packages/extension-dropcursor/package.json # packages/extension-floating-menu/CHANGELOG.md # packages/extension-floating-menu/package.json # packages/extension-focus/CHANGELOG.md # packages/extension-focus/package.json # packages/extension-font-family/CHANGELOG.md # packages/extension-font-family/package.json # packages/extension-gapcursor/CHANGELOG.md # packages/extension-gapcursor/package.json # packages/extension-hard-break/CHANGELOG.md # packages/extension-hard-break/package.json # packages/extension-heading/CHANGELOG.md # packages/extension-heading/package.json # packages/extension-highlight/CHANGELOG.md # packages/extension-highlight/package.json # packages/extension-history/CHANGELOG.md # packages/extension-history/package.json # packages/extension-horizontal-rule/CHANGELOG.md # packages/extension-horizontal-rule/package.json # packages/extension-image/CHANGELOG.md # packages/extension-image/package.json # packages/extension-italic/CHANGELOG.md # packages/extension-italic/package.json # packages/extension-link/CHANGELOG.md # packages/extension-link/package.json # packages/extension-list-item/CHANGELOG.md # packages/extension-list-item/package.json # packages/extension-mention/CHANGELOG.md # packages/extension-mention/package.json # packages/extension-ordered-list/CHANGELOG.md # packages/extension-ordered-list/package.json # packages/extension-paragraph/CHANGELOG.md # packages/extension-paragraph/package.json # packages/extension-placeholder/CHANGELOG.md # packages/extension-placeholder/package.json # packages/extension-strike/CHANGELOG.md # packages/extension-strike/package.json # packages/extension-subscript/CHANGELOG.md # packages/extension-subscript/package.json # packages/extension-superscript/CHANGELOG.md # packages/extension-superscript/package.json # packages/extension-table-cell/CHANGELOG.md # packages/extension-table-cell/package.json # packages/extension-table-header/CHANGELOG.md # packages/extension-table-header/package.json # packages/extension-table-row/CHANGELOG.md # packages/extension-table-row/package.json # packages/extension-table/CHANGELOG.md # packages/extension-table/package.json # packages/extension-task-item/CHANGELOG.md # packages/extension-task-item/package.json # packages/extension-task-list/CHANGELOG.md # packages/extension-task-list/package.json # packages/extension-text-align/CHANGELOG.md # packages/extension-text-align/package.json # packages/extension-text-style/CHANGELOG.md # packages/extension-text-style/package.json # packages/extension-text/CHANGELOG.md # packages/extension-text/package.json # packages/extension-typography/CHANGELOG.md # packages/extension-typography/package.json # packages/extension-underline/CHANGELOG.md # packages/extension-underline/package.json # packages/extension-youtube/CHANGELOG.md # packages/extension-youtube/package.json # packages/html/CHANGELOG.md # packages/html/package.json # packages/pm/CHANGELOG.md # packages/pm/package.json # packages/react/CHANGELOG.md # packages/react/package.json # packages/starter-kit/CHANGELOG.md # packages/starter-kit/package.json # packages/suggestion/CHANGELOG.md # packages/suggestion/package.json # packages/vue-2/CHANGELOG.md # packages/vue-2/package.json # packages/vue-3/CHANGELOG.md # packages/vue-3/package.json
39 lines
906 B
TypeScript
39 lines
906 B
TypeScript
const waitUntilElementExists = (selector: any, callback: (element: Element) => void) => {
|
|
const element = document.querySelector(selector)
|
|
|
|
if (element) {
|
|
return callback(element)
|
|
}
|
|
|
|
setTimeout(() => waitUntilElementExists(selector, callback), 500)
|
|
}
|
|
|
|
const sendData = (eventName: string, data: any) => {
|
|
const event = new CustomEvent(eventName, { detail: data })
|
|
|
|
window.parent.document.dispatchEvent(event)
|
|
}
|
|
|
|
export function splitName(name: string) {
|
|
const parts = name.split('/')
|
|
|
|
if (parts.length !== 3) {
|
|
throw Error('Demos must always be within exactly one category. Nested categories are not supported.')
|
|
}
|
|
|
|
return parts
|
|
}
|
|
|
|
export function debug() {
|
|
sendData('editor', null)
|
|
// @ts-ignore
|
|
sendData('source', window.source)
|
|
|
|
waitUntilElementExists('.tiptap', element => {
|
|
// @ts-ignore
|
|
const editor = element.editor
|
|
|
|
sendData('editor', editor)
|
|
})
|
|
}
|