tiptap/docs/src/main.js

55 lines
1.4 KiB
JavaScript
Raw Normal View History

2020-03-05 16:18:17 +08:00
import Prism from 'prismjs'
2020-04-17 03:12:31 +08:00
import 'prismjs/components/prism-jsx.js'
2020-11-18 21:37:35 +08:00
import 'prismjs/components/prism-typescript.js'
2020-04-18 05:35:07 +08:00
import 'prismjs/components/prism-scss.js'
2020-10-13 00:42:47 +08:00
import PortalVue from 'portal-vue'
2021-01-30 03:56:53 +08:00
import iframeResize from 'iframe-resizer/js/iframeResizer'
2020-04-17 23:06:55 +08:00
import App from '~/layouts/App'
2019-12-08 04:02:22 +08:00
2020-11-19 00:52:23 +08:00
Prism.manual = true
2021-02-04 07:10:03 +08:00
export default function (Vue) {
2020-12-01 17:25:00 +08:00
// fix docsearch
2020-12-02 00:33:20 +08:00
if (typeof window === 'object' && !window.process) {
2020-12-01 17:25:00 +08:00
window.process = {
env: {
NODE_ENV: 'production',
},
}
}
2020-10-13 00:42:47 +08:00
Vue.use(PortalVue)
2021-01-30 03:56:53 +08:00
Vue.directive('resize', {
2021-02-02 18:37:24 +08:00
bind: (el, { value = {} }) => {
el.addEventListener('load', () => {
iframeResize({
...value,
messageCallback(messageData) {
2021-02-03 05:20:16 +08:00
if (messageData.message.type !== 'resize') {
return
2021-02-02 18:37:24 +08:00
}
2021-02-03 05:20:16 +08:00
const style = window.getComputedStyle(el.parentElement)
const maxHeight = parseInt(style.getPropertyValue('max-height'), 10)
if (messageData.message.height > maxHeight) {
el.setAttribute('scrolling', 'auto')
} else {
el.setAttribute('scrolling', 'no')
}
el.iFrameResizer.resize()
2021-02-02 18:37:24 +08:00
},
}, el)
})
2021-01-30 03:56:53 +08:00
},
unbind(el) {
el.iFrameResizer.removeListeners()
},
})
2020-04-17 23:06:55 +08:00
Vue.component('Layout', App)
2020-10-02 16:55:55 +08:00
Vue.component('Demo', () => import(/* webpackChunkName: "demo" */ '~/components/Demo'))
2019-12-08 04:02:22 +08:00
}