feat(demo): build a static editor preview for GitHub Pages
This commit is contained in:
1 parent
12d13327a6
commit
4645d3d11c
10 files changed
+57
-5
No files matched your search
@@ -1,14 +1,26 @@
|
||||
import { watchFontLoading } from '@@/appearance/font-loading'
|
||||
import { t } from '@@/i18n/runtime'
|
||||
// Unauthenticated editor demo for automated performance and interaction tests.
|
||||
import { createEditorState, createEditorView } from '../editor'
|
||||
import sample from './sample.md?raw'
|
||||
import '@/i18n'
|
||||
import '@@/appearance/base.css'
|
||||
import './demo.css'
|
||||
|
||||
// ?repeat=N repeats the sample N times for large-document performance testing.
|
||||
const repeat = Number(new URLSearchParams(location.search).get('repeat') ?? 1)
|
||||
const doc = Array.from({ length: Math.max(1, repeat) }).fill(sample).join('\n')
|
||||
|
||||
watchFontLoading()
|
||||
const header = document.createElement('header')
|
||||
const title = document.createElement('strong')
|
||||
title.textContent = `RawMark ${__RAWMARK_RELEASE__}`
|
||||
const notice = document.createElement('span')
|
||||
notice.textContent = t('common.demo_notice')
|
||||
const github = document.createElement('a')
|
||||
github.href = 'https://github.com/eezd/RawMark'
|
||||
github.textContent = 'GitHub'
|
||||
header.append(title, notice, github)
|
||||
document.body.prepend(header)
|
||||
const view = createEditorView(document.getElementById('app')!, createEditorState({ doc }))
|
||||
;(window as unknown as { rawmarkView: typeof view }).rawmarkView = view
|
||||
Reference in new issue
Block a user