1- import type { Parchment } from 'quill'
21import type Toolbar from 'quill/modules/toolbar'
32import type BaseTheme from 'quill/themes/base'
43import type Picker from 'quill/ui/picker'
54import type { Constructor } from '../../config/types'
65import type FluentEditor from '../../core/fluent-editor'
76import { CHANGE_LANGUAGE_EVENT } from '../../config'
7+ import { isFunction } from '../../utils/is'
88
99interface QuillTheme extends BaseTheme {
1010 pickers : QuillThemePicker [ ]
1111}
1212type QuillThemePicker = ( Picker & { options : HTMLElement } )
13- interface InternalModule {
14- show : ( ) => void
15- hide : ( ) => void
16- update : ( ) => void
17- destroy : ( ) => void
18- }
19- export interface InternalTableSelectionModule extends InternalModule {
20- dragging : boolean
21- boundary : {
22- x : number
23- y : number
24- x1 : number
25- y1 : number
26- width : number
27- height : number
28- } | null
29- selectedTds : Parchment . Blot [ ]
30- cellSelect : HTMLElement
31- tableMenu ?: InternalModule
32- computeSelectedTds : (
33- startPoint : {
34- x : number
35- y : number
36- } ,
37- endPoint : {
38- x : number
39- y : number
40- }
41- ) => Parchment . Blot [ ]
42- updateWithSelectedTds : ( ) => void
43- }
13+
4414export function generateTableUp ( QuillTableUp : Constructor ) {
4515 return class extends QuillTableUp {
46- tableSelection ?: InternalTableSelectionModule
4716 constructor ( public quill : FluentEditor , options : Partial < any > ) {
4817 super ( quill , options )
4918
19+ if ( ! this . quill . options [ 'format-painter' ] ) this . quill . options [ 'format-painter' ] = { }
20+ const currentIgnoreFormat = this . quill . options [ 'format-painter' ] . ignoreFormat || [ ]
21+ this . quill . options [ 'format-painter' ] . ignoreFormat = Array . from (
22+ new Set ( [
23+ ...currentIgnoreFormat ,
24+ 'table-up-cell-inner' ,
25+ ] ) ,
26+ )
27+
5028 this . quill . emitter . on ( CHANGE_LANGUAGE_EVENT , ( ) => {
5129 this . options . texts = this . resolveTexts ( options . texts )
5230 const toolbar = this . quill . getModule ( 'toolbar' ) as Toolbar
@@ -59,13 +37,14 @@ export function generateTableUp(QuillTableUp: Constructor) {
5937 }
6038 }
6139 }
62- if ( this . tableSelection ) {
63- this . tableSelection . destroy ( )
64- }
65- if ( this . options . selection ) {
66- // eslint-disable-next-line new-cap
67- this . tableSelection = new this . options . selection ( this , this . quill , this . options . selectionOptions )
68- }
40+
41+ Object . keys ( this . modules ) . forEach ( ( key ) => {
42+ if ( isFunction ( this . modules [ key ] . destroy ) ) {
43+ this . modules [ key ] . destroy ( )
44+ }
45+ } )
46+ this . modules = { }
47+ this . initModules ( )
6948 } )
7049 }
7150
0 commit comments