Skip to content

Commit ee8d5ba

Browse files
authored
refactor: patch ts type (#252)
* chore: build bundle with one vite config * fix: ts type patch and export * fix: patch docs missing ts type * fix: typo
1 parent 8e398bc commit ee8d5ba

File tree

128 files changed

+786
-1037
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

128 files changed

+786
-1037
lines changed

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"tiny-editor"
2626
],
2727
"scripts": {
28-
"dev": "pnpm -F docs dev",
28+
"dev": "pnpm -F @opentiny/fluent-editor dev",
29+
"dev:docs": "pnpm -F docs dev",
2930
"dev:projects": "pnpm -F projects dev",
3031
"build": "pnpm -F docs build",
3132
"build:v3": "pnpm -F docs build:v3",

packages/docs/fluent-editor/demos/add-toolbar-item.vue

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted } from 'vue'
34
4-
let editor
5+
let editor: FluentEditor
56
67
const TOOLBAR_CONFIG = [
78
[{ header: [] }],
@@ -21,7 +22,7 @@ onMounted(() => {
2122
// 增加工具栏图标
2223
const goodIcon = `<svg t="1734490908682" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5918" width="200" height="200"><path d="M881.066667 394.666667c-21.333333-23.466667-51.2-36.266667-81.066667-36.266667H618.666667v-117.333333c0-44.8-29.866667-85.333333-87.466667-117.333334-17.066667-10.666667-38.4-12.8-57.6-8.533333-19.2 4.266667-36.266667 17.066667-46.933333 34.133333-2.133333 2.133333-2.133333 4.266667-4.266667 6.4l-125.866667 281.6H204.8c-59.733333 0-108.8 46.933333-108.8 106.666667v258.133333c0 57.6 49.066667 106.666667 108.8 106.666667h544c53.333333 0 98.133333-38.4 106.666667-89.6l51.2-337.066667c4.266667-34.133333-6.4-64-25.6-87.466666z m-593.066667 448H204.8c-25.6 0-44.8-19.2-44.8-42.666667v-256c0-23.466667 19.2-42.666667 44.8-42.666667h83.2v341.333334z m554.666667-373.333334L789.333333 806.4c-4.266667 21.333333-21.333333 36.266667-42.666666 36.266667H352V471.466667l130.133333-290.133334c2.133333-4.266667 4.266667-4.266667 6.4-4.266666 2.133333 0 4.266667 0 8.533334 2.133333 25.6 14.933333 55.466667 38.4 55.466666 64v149.333333c0 17.066667 14.933333 32 32 32h213.333334c12.8 0 25.6 4.266667 34.133333 14.933334 8.533333 6.4 12.8 19.2 10.666667 29.866666z" fill="#666666" p-id="5919"></path></svg>`
2324
const badIcon = `<svg t="1734491308472" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3380" width="200" height="200"><path d="M904.533333 522.666667L853.333333 185.6c-8.533333-51.2-55.466667-89.6-106.666666-89.6H204.8c-59.733333 0-108.8 46.933333-108.8 106.666667v258.133333c0 57.6 49.066667 106.666667 108.8 106.666667h91.733333l125.866667 281.6c2.133333 2.133333 2.133333 4.266667 4.266667 6.4 14.933333 23.466667 38.4 36.266667 64 36.266666 12.8 0 25.6-4.266667 38.4-10.666666 57.6-34.133333 87.466667-72.533333 87.466666-117.333334v-117.333333h183.466667c32 0 59.733333-12.8 81.066667-36.266667 19.2-25.6 29.866667-55.466667 23.466666-87.466666z m-616.533333-21.333334H204.8c-25.6 0-44.8-19.2-44.8-42.666666v-256c0-23.466667 19.2-42.666667 44.8-42.666667h83.2v341.333333zM832 567.466667c-8.533333 8.533333-21.333333 14.933333-34.133333 14.933333h-213.333334c-17.066667 0-32 14.933333-32 32v149.333333c0 25.6-29.866667 49.066667-55.466666 64-4.266667 2.133333-10.666667 2.133333-14.933334-4.266666L352 533.333333V160H746.666667c21.333333 0 40.533333 14.933333 42.666666 36.266667L842.666667 533.333333c2.133333 10.666667-2.133333 23.466667-10.666667 34.133334z" fill="#666666" p-id="3381"></path></svg>`
24-
const icons = FluentEditor.import('ui/icons')
25+
const icons = FluentEditor.import('ui/icons') as Record<string, string>
2526
icons.good = goodIcon
2627
icons.bad = badIcon
2728
@@ -38,16 +39,15 @@ onMounted(() => {
3839
3940
editor = new FluentEditor('#editor-add-toolbar-item', {
4041
theme: 'snow',
41-
lang: 'zh-CN',
4242
modules: {
4343
toolbar: {
4444
container: TOOLBAR_CONFIG,
4545
handlers: {
46-
good(value) {
46+
good(value: boolean) {
4747
// 给选中的内容设置格式
4848
this.quill.format('good', value ? '#5cb300' : '')
4949
},
50-
bad(value) {
50+
bad(value: boolean) {
5151
this.quill.format('bad', value ? '#f23030' : '')
5252
},
5353
},

packages/docs/fluent-editor/demos/basic-usage.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted } from 'vue'
34
4-
let editor
5+
let editor: FluentEditor
56
67
onMounted(() => {
78
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook

packages/docs/fluent-editor/demos/code-block-highlight.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import hljs from 'highlight.js'
34
// config extra languages
45
import go from 'highlight.js/lib/languages/go'
@@ -8,7 +9,7 @@ import 'highlight.js/styles/atom-one-dark.css'
89
910
hljs.registerLanguage('go', go)
1011
11-
let editor
12+
let editor: FluentEditor
1213
1314
const TOOLBAR_CONFIG = [
1415
[{ header: [] }],

packages/docs/fluent-editor/demos/counter-count.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted } from 'vue'
34
4-
let editor
5+
let editor: FluentEditor
56
67
onMounted(() => {
78
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook

packages/docs/fluent-editor/demos/counter.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted } from 'vue'
34
4-
let editor
5+
let editor: FluentEditor
56
67
onMounted(() => {
78
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook

packages/docs/fluent-editor/demos/custom-toolbar.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
// 代码块高亮
34
import hljs from 'highlight.js'
45
// 截屏
@@ -13,7 +14,7 @@ window.hljs = hljs
1314
window.katex = katex
1415
window.Html2Canvas = Html2Canvas
1516
16-
let editor
17+
let editor: FluentEditor
1718
const editorRef = ref<HTMLElement>()
1819
1920
const TOOLBAR_CONFIG = [

packages/docs/fluent-editor/demos/emoji.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted } from 'vue'
34
4-
let editor
5+
let editor: FluentEditor
56
67
const TOOLBAR_CONFIG = [
78
[{ header: [] }],

packages/docs/fluent-editor/demos/file-upload-handle.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
<script setup lang="ts">
22
import type { Range } from '@opentiny/fluent-editor'
3+
import type FluentEditor from '@opentiny/fluent-editor'
34
import { onMounted, ref } from 'vue'
45
5-
let editor
6-
const editorRef = ref()
6+
let editor: FluentEditor
7+
const editorRef = ref<HTMLElement>()
78
89
const TOOLBAR_CONFIG = [
910
[{ header: [] }],

packages/docs/fluent-editor/demos/file-upload.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted, ref } from 'vue'
34
4-
let editor
5-
const editorRef = ref()
5+
let editor: FluentEditor
6+
const editorRef = ref<HTMLElement>()
67
78
const TOOLBAR_CONFIG = [
89
[{ header: [] }],

packages/docs/fluent-editor/demos/format-painter.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted } from 'vue'
34
4-
let editor
5+
let editor: FluentEditor
56
67
const TOOLBAR_CONFIG = [
78
[{ header: [] }],
@@ -23,7 +24,7 @@ onMounted(() => {
2324
},
2425
})
2526
})
26-
})
27+
})
2728
</script>
2829

2930
<template>

packages/docs/fluent-editor/demos/formula-mathlive.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<script setup lang="ts">
2+
import type { MathliveModule } from '@opentiny/fluent-editor'
3+
import type FluentEditor from '@opentiny/fluent-editor'
24
import { onMounted } from 'vue'
35
46
import 'mathlive'
57
import 'mathlive/static.css'
68
import 'mathlive/fonts.css'
79
8-
let mathliveEditor
10+
let mathliveEditor: FluentEditor
911
1012
const TOOLBAR_CONFIG = [
1113
[{ header: [] }],
@@ -27,7 +29,7 @@ onMounted(() => {
2729
container: TOOLBAR_CONFIG,
2830
handlers: {
2931
formula() {
30-
const mathlive = this.quill.getModule('mathlive')
32+
const mathlive = this.quill.getModule('mathlive') as MathliveModule
3133
mathlive.createDialog('e=mc^2')
3234
},
3335
},

packages/docs/fluent-editor/demos/formula.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import katex from 'katex'
34
import { onMounted } from 'vue'
45
import 'katex/dist/katex.min.css'
56
67
window.katex = katex
78
8-
let editor
9+
let editor: FluentEditor
910
1011
const TOOLBAR_CONFIG = [
1112
[{ header: [] }],

packages/docs/fluent-editor/demos/get-content-delta.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
// 代码块高亮
34
import hljs from 'highlight.js'
4-
55
// 截屏
66
import Html2Canvas from 'html2canvas'
7+
78
// 插入公式
89
import katex from 'katex'
9-
1010
import { onMounted, ref } from 'vue'
11-
import 'highlight.js/styles/atom-one-dark.css'
1211
12+
import 'highlight.js/styles/atom-one-dark.css'
1313
import 'katex/dist/katex.min.css'
1414
1515
window.hljs = hljs
1616
window.katex = katex
1717
window.Html2Canvas = Html2Canvas
1818
19-
let editor
19+
let editor: FluentEditor
2020
2121
// @提醒
2222
const searchKey = 'name'

packages/docs/fluent-editor/demos/get-content-html.vue

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
// 代码块高亮
34
import hljs from 'highlight.js'
4-
55
// 截屏
66
import Html2Canvas from 'html2canvas'
77
// 插入公式
88
import katex from 'katex'
9-
109
import { onMounted, ref } from 'vue'
11-
import 'highlight.js/styles/atom-one-dark.css'
1210
11+
import 'highlight.js/styles/atom-one-dark.css'
1312
import 'katex/dist/katex.min.css'
1413
1514
window.hljs = hljs
1615
window.katex = katex
1716
window.Html2Canvas = Html2Canvas
1817
19-
let editor
18+
let editor: FluentEditor
2019
2120
// @提醒
2221
const searchKey = 'name'

packages/docs/fluent-editor/demos/header-list-container.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted, ref } from 'vue'
34
import 'quill-header-list/dist/index.css'
45
5-
let editor
6-
const editorRef = ref()
7-
const headerListRef = ref()
6+
let editor: FluentEditor
7+
const editorRef = ref<HTMLElement>()
8+
const headerListRef = ref<HTMLElement>()
89
910
onMounted(() => {
1011
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook
@@ -13,6 +14,7 @@ onMounted(() => {
1314
import('quill-header-list'),
1415
])
1516
.then(([{ default: FluentEditor }, { default: HeaderList }]) => {
17+
if (!editorRef.value) return
1618
FluentEditor.register({ 'modules/header-list': HeaderList }, true)
1719
1820
editor = new FluentEditor(editorRef.value, {

packages/docs/fluent-editor/demos/header-list.vue

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted, ref } from 'vue'
34
import 'quill-header-list/dist/index.css'
45
5-
let editor
6-
const editorRef = ref()
7-
const headerListRef = ref()
6+
let editor: FluentEditor
7+
const editorRef = ref<HTMLElement>()
8+
const headerListRef = ref<HTMLElement>()
89
910
onMounted(() => {
1011
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook
@@ -13,6 +14,7 @@ onMounted(() => {
1314
import('quill-header-list'),
1415
])
1516
.then(([{ default: FluentEditor }, { default: HeaderList }]) => {
17+
if (!editorRef.value) return
1618
FluentEditor.register({ 'modules/header-list': HeaderList }, true)
1719
1820
editor = new FluentEditor(editorRef.value, {

packages/docs/fluent-editor/demos/i18n-custom.vue

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
3+
import type { I18N } from '@opentiny/fluent-editor'
4+
25
import QuillToolbarTip from 'quill-toolbar-tip'
36
import { onMounted, ref } from 'vue'
4-
57
import 'quill-toolbar-tip/dist/index.css'
68
7-
let editor
8-
const editorRef = ref()
9+
let editor: FluentEditor
10+
const editorRef = ref<HTMLElement>()
911
const lang = ref('zh-CN')
1012
1113
onMounted(() => {
1214
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook
1315
import('@opentiny/fluent-editor').then(({ default: FluentEditor, I18N, generateToolbarTip }) => {
16+
if (!editorRef.value) return
1417
FluentEditor.register({ 'modules/toolbar-tip': generateToolbarTip(QuillToolbarTip) }, true)
1518
I18N.register(
1619
{
@@ -52,8 +55,8 @@ onMounted(() => {
5255
})
5356
})
5457
function switchLanguage() {
55-
lang.value = lang.value === 'zh-CN' ? 'en-US' : 'zh-CN'
56-
editor.getModule('i18n').changeLanguage({ lang: lang.value })
58+
lang.value = lang.value === 'zh-CN' ? 'en-US' : 'zh-CN';
59+
(editor.getModule('i18n') as I18N).changeLanguage({ lang: lang.value })
5760
}
5861
</script>
5962

packages/docs/fluent-editor/demos/i18n.vue

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
3+
import type { I18N } from '@opentiny/fluent-editor'
24
import { onMounted, ref } from 'vue'
35
4-
let editor
5-
const editorRef = ref()
6+
let editor: FluentEditor
7+
const editorRef = ref<HTMLElement>()
68
const lang = ref('en-US')
79
810
onMounted(() => {
911
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook
10-
import('@opentiny/fluent-editor').then(({ default: FluentEditor, generateToolbarTip }) => {
12+
import('@opentiny/fluent-editor').then(({ default: FluentEditor }) => {
13+
if (!editorRef.value) return
1114
editor = new FluentEditor(editorRef.value, {
1215
theme: 'snow',
1316
modules: {
@@ -25,8 +28,8 @@ onMounted(() => {
2528
})
2629
})
2730
function switchLanguage() {
28-
lang.value = lang.value === 'zh-CN' ? 'en-US' : 'zh-CN'
29-
editor.getModule('i18n').changeLanguage({ lang: lang.value })
31+
lang.value = lang.value === 'zh-CN' ? 'en-US' : 'zh-CN';
32+
(editor.getModule('i18n') as I18N).changeLanguage({ lang: lang.value })
3033
}
3134
</script>
3235

packages/docs/fluent-editor/demos/markdown.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted } from 'vue'
34
4-
let editor
5+
let editor: FluentEditor
56
67
onMounted(() => {
78
// ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook

packages/docs/fluent-editor/demos/mention-custom-list.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<script setup lang="ts">
2+
import type FluentEditor from '@opentiny/fluent-editor'
23
import { onMounted } from 'vue'
34
4-
let editor
5+
let editor: FluentEditor
56
67
// @提醒
78
const searchKey = 'name'

0 commit comments

Comments
 (0)