@@ -12,6 +12,9 @@ import { onMounted, ref } from 'vue'
1212import ' highlight.js/styles/atom-one-dark.css'
1313import ' katex/dist/katex.min.css'
1414
15+ import ' quill-table-up/index.css'
16+ import ' quill-table-up/table-creator.css'
17+
1518window .hljs = hljs
1619window .katex = katex
1720window .Html2Canvas = Html2Canvas
@@ -33,56 +36,54 @@ const mentionList = [
3336 },
3437]
3538
36- const TOOLBAR_CONFIG = [
37- [' undo' , ' redo' , ' clean' , ' format-painter' ],
38- [{ header: [1 , 2 , 3 , 4 , 5 , 6 , false ] }, { font: [] }, { size: [' 12px' , ' 14px' , ' 16px' , ' 18px' , ' 20px' , ' 24px' , ' 32px' , ' 36px' , ' 48px' , ' 72px' ] }],
39- [' bold' , ' italic' , ' strike' , ' underline' ],
40- [{ color: [] }, { background: [] }],
41- [{ align: [] }, { list: ' ordered' }, { list: ' bullet' }, { list: ' check' }],
42- [{ script: ' sub' }, { script: ' super' }],
43- [{ indent: ' -1' }, { indent: ' +1' }],
44- [{ direction: ' rtl' }],
45- [' link' , ' blockquote' , ' code' , ' code-block' ],
46- [' image' , ' file' ],
47- [' emoji' , ' video' , ' formula' , ' screenshot' ],
48- ]
49-
5039const articleRef = ref <HTMLElement >()
5140function updateDeltaStr(deltaStr : string ) {
5241 if (articleRef .value ) {
5342 articleRef .value .innerHTML = deltaStr
5443 }
5544}
5645
57- onMounted (() => {
46+ onMounted (async () => {
5847 // ssr compat, reference: https://vitepress.dev/guide/ssr-compat#importing-in-mounted-hook
59- import (' @opentiny/fluent-editor' ).then ((module ) => {
60- const FluentEditor = module .default
48+ const [
49+ { default : FluentEditor, generateTableUp, FULL_TOOLBAR },
50+ { defaultCustomSelect, TableMenuContextmenu, TableSelection, TableUp },
51+ ] = await Promise .all ([
52+ import (' @opentiny/fluent-editor' ),
53+ import (' quill-table-up' ),
54+ ])
6155
62- editor = new FluentEditor ( ' #editor-get-content-delta ' , {
63- theme: ' snow ' ,
64- modules: {
65- toolbar: TOOLBAR_CONFIG ,
66- syntax: { hljs } ,
67- emoji: true ,
68- file : true ,
69- mention: {
70- itemKey: ' cn ' ,
71- searchKey ,
72- search( term ) {
73- return mentionList . filter (( item ) => {
74- return item [ searchKey ] && String ( item [ searchKey ]). includes ( term )
75- } )
76- },
56+ FluentEditor . register ({ ' modules/table-up ' : generateTableUp ( TableUp ) }, true )
57+ editor = new FluentEditor ( ' #editor-get-content-delta ' , {
58+ theme: ' snow ' ,
59+ modules: {
60+ toolbar: FULL_TOOLBAR ,
61+ syntax: { hljs } ,
62+ emoji : true ,
63+ file: true ,
64+ mention: {
65+ itemKey: ' cn ' ,
66+ searchKey ,
67+ search( term ) {
68+ return mentionList . filter (( item ) => {
69+ return item [ searchKey ] && String ( item [ searchKey ]). includes ( term )
70+ })
7771 },
7872 },
79- })
73+ ' table-up' : {
74+ customSelect: defaultCustomSelect ,
75+ modules: [
76+ { module: TableSelection },
77+ { module: TableMenuContextmenu },
78+ ],
79+ },
80+ },
81+ })
8082
81- updateDeltaStr (JSON .stringify (editor .getContents ()))
83+ updateDeltaStr (JSON .stringify (editor .getContents ()))
8284
83- editor .on (' text-change' , () => {
84- updateDeltaStr (JSON .stringify (editor .getContents ()))
85- })
85+ editor .on (' text-change' , () => {
86+ updateDeltaStr (JSON .stringify (editor .getContents ()))
8687 })
8788})
8889 </script >
0 commit comments