tiptap/demos/setup/react.ts

26 lines
626 B
TypeScript
Raw Normal View History

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