tiptap/demos/setup/react.ts
svenadlung bdc51d12b5 Merge branch 'main' into develop
# 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
2023-07-17 13:03:44 +02:00

39 lines
1002 B
TypeScript

import 'iframe-resizer/js/iframeResizer.contentWindow'
import './style.scss'
import React from 'react'
import { createRoot } from 'react-dom/client'
import { debug, splitName } from './helper.js'
export default function init(name: string, source: any) {
// @ts-ignore
window.source = source
document.title = name
const [demoCategory, demoName, frameworkName] = splitName(name)
import(`../src/${demoCategory}/${demoName}/${frameworkName}/index.tsx`)
.then(module => {
const root = document.getElementById('app')
if (root) {
createRoot(root)
.render(React.createElement(module.default))
}
debug()
})
.catch(() => {
import(`../src/${demoCategory}/${demoName}/${frameworkName}/index.jsx`)
.then(module => {
const root = document.getElementById('app')
if (root) {
createRoot(root)
.render(React.createElement(module.default))
}
debug()
})
})
}