suneditor 3.0.0-beta.3 → 3.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +8 -8
- package/README.md +44 -49
- package/dist/suneditor.min.css +1 -1
- package/dist/suneditor.min.js +1 -1
- package/package.json +95 -53
- package/src/assets/design/color.css +2 -2
- package/src/assets/design/size.css +2 -0
- package/src/assets/icons/defaultIcons.js +16 -1
- package/src/assets/suneditor-contents.css +9 -8
- package/src/assets/suneditor.css +29 -26
- package/src/core/{section → base}/actives.js +20 -12
- package/src/core/base/history.js +4 -4
- package/src/core/class/char.js +10 -10
- package/src/core/class/component.js +146 -57
- package/src/core/class/format.js +94 -2458
- package/src/core/class/html.js +187 -129
- package/src/core/class/inline.js +1853 -0
- package/src/core/class/listFormat.js +582 -0
- package/src/core/class/menu.js +14 -3
- package/src/core/class/nodeTransform.js +9 -14
- package/src/core/class/offset.js +162 -197
- package/src/core/class/selection.js +137 -34
- package/src/core/class/toolbar.js +73 -52
- package/src/core/class/ui.js +11 -11
- package/src/core/class/viewer.js +56 -55
- package/src/core/config/context.js +122 -0
- package/src/core/config/frameContext.js +204 -0
- package/src/core/config/options.js +639 -0
- package/src/core/editor.js +181 -108
- package/src/core/event/actions/index.js +229 -0
- package/src/core/event/effects/common.registry.js +60 -0
- package/src/core/event/effects/keydown.registry.js +551 -0
- package/src/core/event/effects/ruleHelpers.js +145 -0
- package/src/core/{base → event}/eventManager.js +119 -201
- package/src/core/event/executor.js +21 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_toolbar.js +4 -4
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.js +2 -2
- package/src/core/event/handlers/handler_ww_input.js +77 -0
- package/src/core/event/handlers/handler_ww_key.js +228 -0
- package/src/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.js +3 -3
- package/src/core/event/ports.js +211 -0
- package/src/core/event/reducers/keydown.reducer.js +89 -0
- package/src/core/event/rules/keydown.rule.arrow.js +54 -0
- package/src/core/event/rules/keydown.rule.backspace.js +202 -0
- package/src/core/event/rules/keydown.rule.delete.js +126 -0
- package/src/core/event/rules/keydown.rule.enter.js +144 -0
- package/src/core/event/rules/keydown.rule.tab.js +29 -0
- package/src/core/section/constructor.js +79 -388
- package/src/core/section/documentType.js +47 -26
- package/src/core/util/instanceCheck.js +59 -0
- package/src/editorInjector/_classes.js +4 -0
- package/src/editorInjector/_core.js +17 -7
- package/src/editorInjector/index.js +10 -2
- package/src/events.js +6 -0
- package/src/helper/clipboard.js +24 -10
- package/src/helper/converter.js +17 -12
- package/src/helper/dom/domCheck.js +22 -3
- package/src/helper/dom/domQuery.js +91 -45
- package/src/helper/dom/domUtils.js +93 -19
- package/src/helper/dom/index.js +4 -0
- package/src/helper/env.js +11 -7
- package/src/helper/keyCodeMap.js +4 -3
- package/src/langs/ckb.js +1 -1
- package/src/langs/cs.js +1 -1
- package/src/langs/da.js +1 -1
- package/src/langs/de.js +1 -1
- package/src/langs/en.js +1 -1
- package/src/langs/es.js +1 -1
- package/src/langs/fa.js +1 -1
- package/src/langs/fr.js +1 -1
- package/src/langs/he.js +1 -1
- package/src/langs/hu.js +1 -1
- package/src/langs/it.js +1 -1
- package/src/langs/ja.js +1 -1
- package/src/langs/km.js +1 -1
- package/src/langs/ko.js +1 -1
- package/src/langs/lv.js +1 -1
- package/src/langs/nl.js +1 -1
- package/src/langs/pl.js +1 -1
- package/src/langs/pt_br.js +10 -10
- package/src/langs/ro.js +1 -1
- package/src/langs/ru.js +1 -1
- package/src/langs/se.js +1 -1
- package/src/langs/tr.js +1 -1
- package/src/langs/uk.js +1 -1
- package/src/langs/ur.js +1 -1
- package/src/langs/zh_cn.js +1 -1
- package/src/modules/ApiManager.js +25 -18
- package/src/modules/Browser.js +52 -61
- package/src/modules/ColorPicker.js +37 -38
- package/src/modules/Controller.js +85 -79
- package/src/modules/Figure.js +275 -187
- package/src/modules/FileManager.js +86 -92
- package/src/modules/HueSlider.js +67 -35
- package/src/modules/Modal.js +84 -77
- package/src/modules/ModalAnchorEditor.js +62 -79
- package/src/modules/SelectMenu.js +89 -86
- package/src/plugins/browser/audioGallery.js +9 -5
- package/src/plugins/browser/fileBrowser.js +10 -6
- package/src/plugins/browser/fileGallery.js +9 -5
- package/src/plugins/browser/imageGallery.js +9 -5
- package/src/plugins/browser/videoGallery.js +11 -6
- package/src/plugins/command/blockquote.js +1 -0
- package/src/plugins/command/exportPDF.js +11 -8
- package/src/plugins/command/fileUpload.js +41 -29
- package/src/plugins/command/list_bulleted.js +2 -1
- package/src/plugins/command/list_numbered.js +2 -1
- package/src/plugins/dropdown/align.js +8 -2
- package/src/plugins/dropdown/backgroundColor.js +19 -11
- package/src/plugins/dropdown/font.js +15 -9
- package/src/plugins/dropdown/fontColor.js +19 -11
- package/src/plugins/dropdown/formatBlock.js +7 -2
- package/src/plugins/dropdown/hr.js +7 -3
- package/src/plugins/dropdown/layout.js +6 -2
- package/src/plugins/dropdown/lineHeight.js +8 -3
- package/src/plugins/dropdown/list.js +2 -1
- package/src/plugins/dropdown/paragraphStyle.js +15 -11
- package/src/plugins/dropdown/{table.js → table/index.js} +514 -362
- package/src/plugins/dropdown/template.js +6 -2
- package/src/plugins/dropdown/textStyle.js +7 -3
- package/src/plugins/field/mention.js +33 -27
- package/src/plugins/input/fontSize.js +44 -37
- package/src/plugins/input/pageNavigator.js +3 -2
- package/src/plugins/modal/audio.js +90 -85
- package/src/plugins/modal/drawing.js +58 -66
- package/src/plugins/modal/embed.js +193 -180
- package/src/plugins/modal/image.js +441 -439
- package/src/plugins/modal/link.js +31 -8
- package/src/plugins/modal/math.js +23 -22
- package/src/plugins/modal/video.js +233 -230
- package/src/plugins/popup/anchor.js +24 -18
- package/src/suneditor.js +69 -24
- package/src/typedef.js +42 -19
- package/types/assets/icons/defaultIcons.d.ts +8 -0
- package/types/core/class/char.d.ts +1 -1
- package/types/core/class/component.d.ts +29 -7
- package/types/core/class/format.d.ts +4 -354
- package/types/core/class/html.d.ts +13 -4
- package/types/core/class/inline.d.ts +263 -0
- package/types/core/class/listFormat.d.ts +135 -0
- package/types/core/class/menu.d.ts +10 -2
- package/types/core/class/offset.d.ts +24 -26
- package/types/core/class/selection.d.ts +2 -0
- package/types/core/class/toolbar.d.ts +24 -11
- package/types/core/class/ui.d.ts +1 -1
- package/types/core/class/viewer.d.ts +1 -1
- package/types/core/config/context.d.ts +157 -0
- package/types/core/config/frameContext.d.ts +367 -0
- package/types/core/config/options.d.ts +1119 -0
- package/types/core/editor.d.ts +101 -66
- package/types/core/event/actions/index.d.ts +47 -0
- package/types/core/event/effects/common.registry.d.ts +50 -0
- package/types/core/event/effects/keydown.registry.d.ts +73 -0
- package/types/core/event/effects/ruleHelpers.d.ts +31 -0
- package/types/core/{base → event}/eventManager.d.ts +15 -46
- package/types/core/event/executor.d.ts +6 -0
- package/types/core/event/handlers/handler_ww_input.d.ts +41 -0
- package/types/core/{base/eventHandlers/handler_ww_key_input.d.ts → event/handlers/handler_ww_key.d.ts} +4 -6
- package/types/core/event/ports.d.ts +255 -0
- package/types/core/event/reducers/keydown.reducer.d.ts +75 -0
- package/types/core/event/rules/keydown.rule.arrow.d.ts +8 -0
- package/types/core/event/rules/keydown.rule.backspace.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.delete.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.enter.d.ts +9 -0
- package/types/core/event/rules/keydown.rule.tab.d.ts +9 -0
- package/types/core/section/constructor.d.ts +101 -631
- package/types/core/section/documentType.d.ts +14 -4
- package/types/core/util/instanceCheck.d.ts +50 -0
- package/types/editorInjector/_classes.d.ts +4 -0
- package/types/editorInjector/_core.d.ts +17 -7
- package/types/editorInjector/index.d.ts +10 -2
- package/types/events.d.ts +1 -0
- package/types/helper/clipboard.d.ts +2 -2
- package/types/helper/converter.d.ts +6 -9
- package/types/helper/dom/domCheck.d.ts +7 -0
- package/types/helper/dom/domQuery.d.ts +19 -8
- package/types/helper/dom/domUtils.d.ts +24 -2
- package/types/helper/dom/index.d.ts +86 -1
- package/types/helper/env.d.ts +6 -1
- package/types/helper/index.d.ts +7 -1
- package/types/helper/keyCodeMap.d.ts +3 -3
- package/types/index.d.ts +23 -117
- package/types/langs/index.d.ts +2 -2
- package/types/modules/ApiManager.d.ts +1 -8
- package/types/modules/Browser.d.ts +4 -62
- package/types/modules/ColorPicker.d.ts +4 -21
- package/types/modules/Controller.d.ts +8 -64
- package/types/modules/Figure.d.ts +54 -50
- package/types/modules/FileManager.d.ts +1 -13
- package/types/modules/HueSlider.d.ts +13 -3
- package/types/modules/Modal.d.ts +0 -43
- package/types/modules/ModalAnchorEditor.d.ts +0 -73
- package/types/modules/SelectMenu.d.ts +0 -85
- package/types/modules/index.d.ts +3 -3
- package/types/plugins/browser/audioGallery.d.ts +29 -18
- package/types/plugins/browser/fileBrowser.d.ts +38 -27
- package/types/plugins/browser/fileGallery.d.ts +29 -18
- package/types/plugins/browser/imageGallery.d.ts +24 -16
- package/types/plugins/browser/videoGallery.d.ts +29 -18
- package/types/plugins/command/blockquote.d.ts +1 -0
- package/types/plugins/command/exportPDF.d.ts +18 -18
- package/types/plugins/command/fileUpload.d.ts +65 -45
- package/types/plugins/command/list_bulleted.d.ts +1 -0
- package/types/plugins/command/list_numbered.d.ts +1 -0
- package/types/plugins/dropdown/align.d.ts +13 -8
- package/types/plugins/dropdown/backgroundColor.d.ts +30 -19
- package/types/plugins/dropdown/font.d.ts +13 -12
- package/types/plugins/dropdown/fontColor.d.ts +30 -19
- package/types/plugins/dropdown/formatBlock.d.ts +13 -8
- package/types/plugins/dropdown/hr.d.ts +15 -11
- package/types/plugins/dropdown/layout.d.ts +15 -11
- package/types/plugins/dropdown/lineHeight.d.ts +16 -11
- package/types/plugins/dropdown/list.d.ts +1 -0
- package/types/plugins/dropdown/paragraphStyle.d.ts +31 -27
- package/types/plugins/dropdown/table/index.d.ts +582 -0
- package/types/plugins/dropdown/table.d.ts +41 -86
- package/types/plugins/dropdown/template.d.ts +15 -11
- package/types/plugins/dropdown/textStyle.d.ts +19 -11
- package/types/plugins/field/mention.d.ts +58 -56
- package/types/plugins/index.d.ts +38 -38
- package/types/plugins/input/fontSize.d.ts +46 -50
- package/types/plugins/modal/audio.d.ts +26 -56
- package/types/plugins/modal/drawing.d.ts +0 -85
- package/types/plugins/modal/embed.d.ts +15 -79
- package/types/plugins/modal/image.d.ts +24 -136
- package/types/plugins/modal/link.d.ts +34 -15
- package/types/plugins/modal/math.d.ts +0 -16
- package/types/plugins/modal/video.d.ts +17 -86
- package/types/plugins/popup/anchor.d.ts +1 -8
- package/types/suneditor.d.ts +70 -19
- package/types/typedef.d.ts +60 -46
- package/src/core/base/eventHandlers/handler_ww_key_input.js +0 -1200
- package/src/core/section/context.js +0 -102
- package/types/core/section/context.d.ts +0 -45
- package/types/langs/_Lang.d.ts +0 -194
- /package/src/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.js +0 -0
- /package/types/core/{section → base}/actives.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_toolbar.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_clipboard.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_dragDrop.d.ts +0 -0
- /package/types/core/{base/eventHandlers → event/handlers}/handler_ww_mouse.d.ts +0 -0
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{ t: string, p?: * }} Action
|
|
3
|
+
* @typedef {Object} __se__ComponentInfo
|
|
4
|
+
* @property {Element} target
|
|
5
|
+
* @property {string} pluginName
|
|
6
|
+
* @property {Object} [options]
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const A = {
|
|
10
|
+
/**
|
|
11
|
+
* @category [[ common.registry ]]
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// === event, cache ===
|
|
15
|
+
/** @returns {Action} */
|
|
16
|
+
prevent: () => ({ t: 'event.prevent' }),
|
|
17
|
+
/** @returns {Action} */
|
|
18
|
+
stop: () => ({ t: 'event.stop' }),
|
|
19
|
+
/** @returns {Action} */
|
|
20
|
+
preventStop: () => ({ t: 'event.prevent.stop' }),
|
|
21
|
+
/** @returns {Action} */
|
|
22
|
+
cacheStyleNode: () => ({ t: 'cache.styleNode' }),
|
|
23
|
+
/**
|
|
24
|
+
* @param {NamedNodeMap} attrs
|
|
25
|
+
* @returns {Action}
|
|
26
|
+
*/
|
|
27
|
+
cacheFormatAttrsTemp: (attrs) => ({ t: 'cache.formatAttrsTemp', p: { attrs } }),
|
|
28
|
+
|
|
29
|
+
// === commands ===
|
|
30
|
+
/** @returns {Action} */
|
|
31
|
+
componentDeselect: () => ({ t: 'component.deselect' }),
|
|
32
|
+
/** @returns {Action} */
|
|
33
|
+
editorNativeFocus: () => ({ t: 'editor._nativeFocus' }),
|
|
34
|
+
/**
|
|
35
|
+
* @param {boolean} hard
|
|
36
|
+
* @returns {Action}
|
|
37
|
+
*/
|
|
38
|
+
historyPush: (hard) => ({ t: 'history.push', p: hard }),
|
|
39
|
+
/** @returns {Action} */
|
|
40
|
+
documentTypeRefreshHeader: () => ({ t: 'documentType.refreshHeader' }),
|
|
41
|
+
|
|
42
|
+
// === class ===
|
|
43
|
+
/**
|
|
44
|
+
* @param {Node} sc - Start container
|
|
45
|
+
* @param {number} so - Start offset
|
|
46
|
+
* @param {Node} ec - End container
|
|
47
|
+
* @param {number} eo - End offset
|
|
48
|
+
* @returns {Action}
|
|
49
|
+
*/
|
|
50
|
+
selectionSetRange: (sc, so, ec, eo) => ({ t: 'selection.setRange', p: { sc, so, ec, eo } }),
|
|
51
|
+
/**
|
|
52
|
+
* @param {Element} rangeEl
|
|
53
|
+
* @param {Element[]|null} selectedFormats
|
|
54
|
+
* @param {Element|null} newBlockElement
|
|
55
|
+
* @param {boolean} shouldDelete
|
|
56
|
+
* @param {boolean} skipHistory
|
|
57
|
+
* @returns {Action}
|
|
58
|
+
*/
|
|
59
|
+
formatRemoveBlock: (rangeEl, selectedFormats, newBlockElement, shouldDelete, skipHistory) => ({
|
|
60
|
+
t: 'format.removeBlock',
|
|
61
|
+
p: { rangeEl, selectedFormats, newBlockElement, shouldDelete, skipHistory }
|
|
62
|
+
}),
|
|
63
|
+
/**
|
|
64
|
+
* @param {Node} item
|
|
65
|
+
* @returns {Action}
|
|
66
|
+
*/
|
|
67
|
+
domUtilsRemoveItem: (item) => ({ t: 'dom.utils.removeItem', p: { item } }),
|
|
68
|
+
|
|
69
|
+
// === utils ===
|
|
70
|
+
/**
|
|
71
|
+
* @param {__se__ComponentInfo} cmponentInfo
|
|
72
|
+
* @returns {Action}
|
|
73
|
+
*/
|
|
74
|
+
selectComponentFallback: (cmponentInfo) => ({ t: 'select.component.fallback', p: { cmponentInfo } }),
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* @category [[ keydown.registry ]]
|
|
78
|
+
*/
|
|
79
|
+
|
|
80
|
+
// === backspace and delete ===
|
|
81
|
+
/**
|
|
82
|
+
* @param {Node} container
|
|
83
|
+
* @param {Element} formatEl
|
|
84
|
+
* @returns {Action}
|
|
85
|
+
*/
|
|
86
|
+
delFormatRemoveAndMove: (container, formatEl) => ({ t: 'del.format.removeAndMove', p: { container, formatEl } }),
|
|
87
|
+
|
|
88
|
+
// === backspace ===
|
|
89
|
+
/**
|
|
90
|
+
* @param {Element} formatEl
|
|
91
|
+
* @returns {Action}
|
|
92
|
+
*/
|
|
93
|
+
backspaceFormatMaintain: (formatEl) => ({ t: 'backspace.format.maintain', p: { formatEl } }),
|
|
94
|
+
/**
|
|
95
|
+
* @param {Node} selectionNode
|
|
96
|
+
* @param {Range} range
|
|
97
|
+
* @param {__se__ComponentInfo} fileComponentInfo
|
|
98
|
+
* @returns {Action}
|
|
99
|
+
*/
|
|
100
|
+
backspaceComponentSelect: (selectionNode, range, fileComponentInfo) => ({ t: 'backspace.component.select', p: { selectionNode, range, fileComponentInfo } }),
|
|
101
|
+
/**
|
|
102
|
+
* @param {boolean} isList
|
|
103
|
+
* @param {Node} sel
|
|
104
|
+
* @param {Element} formatEl
|
|
105
|
+
* @param {__se__ComponentInfo} fileComponentInfo
|
|
106
|
+
* @returns {Action}
|
|
107
|
+
*/
|
|
108
|
+
backspaceComponentRemove: (isList, sel, formatEl, fileComponentInfo) => ({ t: 'backspace.component.remove', p: { isList, sel, formatEl, fileComponentInfo } }),
|
|
109
|
+
/**
|
|
110
|
+
* @param {Element} prev
|
|
111
|
+
* @param {Element} formatEl
|
|
112
|
+
* @param {Element} rangeEl
|
|
113
|
+
* @returns {Action}
|
|
114
|
+
*/
|
|
115
|
+
backspaceListMergePrev: (prev, formatEl, rangeEl) => ({ t: 'backspace.list.mergePrev', p: { prev, formatEl, rangeEl } }),
|
|
116
|
+
/**
|
|
117
|
+
* @param {Range} range
|
|
118
|
+
* @returns {Action}
|
|
119
|
+
*/
|
|
120
|
+
backspaceListRemoveNested: (range) => ({ t: 'backspace.list.removeNested', p: { range } }),
|
|
121
|
+
|
|
122
|
+
// === delete ===
|
|
123
|
+
/**
|
|
124
|
+
* @param {Element} formatEl
|
|
125
|
+
* @param {__se__ComponentInfo} fileComponentInfo
|
|
126
|
+
* @returns {Action}
|
|
127
|
+
*/
|
|
128
|
+
deleteComponentSelect: (formatEl, fileComponentInfo) => ({ t: 'delete.component.select', p: { formatEl, fileComponentInfo } }),
|
|
129
|
+
/**
|
|
130
|
+
* @param {Element} nextEl
|
|
131
|
+
* @returns {Action}
|
|
132
|
+
*/
|
|
133
|
+
deleteComponentSelectNext: (formatEl, nextEl) => ({ t: 'delete.component.selectNext', p: { formatEl, nextEl } }),
|
|
134
|
+
/**
|
|
135
|
+
* @param {Range} range
|
|
136
|
+
* @param {Element} formatEl
|
|
137
|
+
* @param {Element} rangeEl
|
|
138
|
+
* @returns {Action}
|
|
139
|
+
*/
|
|
140
|
+
deleteListRemoveNested: (range, formatEl, rangeEl) => ({ t: 'delete.list.removeNested', p: { range, formatEl, rangeEl } }),
|
|
141
|
+
|
|
142
|
+
// === tab ===
|
|
143
|
+
/**
|
|
144
|
+
* @param {Range} range
|
|
145
|
+
* @param {Element} formatEl
|
|
146
|
+
* @param {boolean} shift
|
|
147
|
+
* @returns {Action}
|
|
148
|
+
*/
|
|
149
|
+
tabFormatIndent: (range, formatEl, shift) => ({ t: 'tab.format.indent', p: { range, formatEl, shift } }),
|
|
150
|
+
|
|
151
|
+
// === enter ===
|
|
152
|
+
/**
|
|
153
|
+
* @param {Range} range Range object
|
|
154
|
+
* @returns {Action}
|
|
155
|
+
*/
|
|
156
|
+
enterScrollTo: (range) => ({ t: 'enter.scrollTo', p: { range } }),
|
|
157
|
+
/**
|
|
158
|
+
* @param {Element} formatEl
|
|
159
|
+
* @returns {Action}
|
|
160
|
+
*/
|
|
161
|
+
enterLineAddDefault: (formatEl) => ({ t: 'enter.line.addDefault', p: { formatEl } }),
|
|
162
|
+
/**
|
|
163
|
+
* @param {Element} formatEl
|
|
164
|
+
* @param {Node} selectionNode
|
|
165
|
+
* @returns {Action}
|
|
166
|
+
*/
|
|
167
|
+
enterListAddItem: (formatEl, selectionNode) => ({ t: 'enter.list.addItem', p: { formatEl, selectionNode } }),
|
|
168
|
+
/**
|
|
169
|
+
* @param {Element} formatEl
|
|
170
|
+
* @param {Element} rangeEl
|
|
171
|
+
* @returns {Action}
|
|
172
|
+
*/
|
|
173
|
+
enterFormatExitEmpty: (formatEl, rangeEl) => ({ t: 'enter.format.exitEmpty', p: { formatEl, rangeEl } }),
|
|
174
|
+
/**
|
|
175
|
+
* @param {Node} selectionNode
|
|
176
|
+
* @param {boolean} selectionFormat
|
|
177
|
+
* @param {Element} brBlock
|
|
178
|
+
* @param {NodeList} children
|
|
179
|
+
* @param {number} offset
|
|
180
|
+
* @returns {Action}
|
|
181
|
+
*/
|
|
182
|
+
enterFormatCleanBrAndZWS: (selectionNode, selectionFormat, brBlock, children, offset) => ({ t: 'enter.format.cleanBrAndZWS', p: { selectionNode, selectionFormat, brBlock, children, offset } }),
|
|
183
|
+
/**
|
|
184
|
+
* @param {Element} brBlock
|
|
185
|
+
* @param {Range} range
|
|
186
|
+
* @param {Selection} wSelection
|
|
187
|
+
* @param {number} offset
|
|
188
|
+
* @returns {Action}
|
|
189
|
+
*/
|
|
190
|
+
enterFormatInsertBrHtml: (brBlock, range, wSelection, offset) => ({ t: 'enter.format.insertBrHtml', p: { brBlock, range, wSelection, offset } }),
|
|
191
|
+
/**
|
|
192
|
+
* @param {Selection} wSelection
|
|
193
|
+
* @returns {Action}
|
|
194
|
+
*/
|
|
195
|
+
enterFormatInsertBrNode: (wSelection) => ({ t: 'enter.format.insertBrNode', p: { wSelection } }),
|
|
196
|
+
/**
|
|
197
|
+
* @param {Element} formatEl
|
|
198
|
+
* @param {Node} selectionNode
|
|
199
|
+
* @param {boolean} formatStartEdge
|
|
200
|
+
* @param {boolean} formatEndEdge
|
|
201
|
+
* @returns {Action}
|
|
202
|
+
*/
|
|
203
|
+
enterFormatBreakAtEdge: (formatEl, selectionNode, formatStartEdge, formatEndEdge) => ({ t: 'enter.format.breakAtEdge', p: { formatEl, selectionNode, formatStartEdge, formatEndEdge } }),
|
|
204
|
+
/**
|
|
205
|
+
* @param {Element} formatEl
|
|
206
|
+
* @param {Range} range
|
|
207
|
+
* @param {boolean} formatStartEdge
|
|
208
|
+
* @param {boolean} formatEndEdge
|
|
209
|
+
* @returns {Action}
|
|
210
|
+
*/
|
|
211
|
+
enterFormatBreakWithSelection: (formatEl, range, formatStartEdge, formatEndEdge) => ({ t: 'enter.format.breakWithSelection', p: { formatEl, range, formatStartEdge, formatEndEdge } }),
|
|
212
|
+
/**
|
|
213
|
+
* @param {Element} formatEl
|
|
214
|
+
* @param {Range} range
|
|
215
|
+
* @returns {Action}
|
|
216
|
+
*/
|
|
217
|
+
enterFormatBreakAtCursor: (formatEl, range) => ({ t: 'enter.format.breakAtCursor', p: { formatEl, range } }),
|
|
218
|
+
/**
|
|
219
|
+
* @param {Element} formatEl
|
|
220
|
+
* @returns {Action}
|
|
221
|
+
*/
|
|
222
|
+
enterFigcaptionExitInList: (formatEl) => ({ t: 'enter.figcaption.exitInList', p: { formatEl } }),
|
|
223
|
+
|
|
224
|
+
// === keydown reducer ===
|
|
225
|
+
/** @returns {Action} */
|
|
226
|
+
keydownInputInsertNbsp: () => ({ t: 'keydown.input.insertNbsp' }),
|
|
227
|
+
/** @returns {Action} */
|
|
228
|
+
keydownInputInsertZWS: () => ({ t: 'keydown.input.insertZWS' })
|
|
229
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { dom } from '../../../helper';
|
|
2
|
+
import { _w } from '../../../helper/env';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {Object} EffectContext
|
|
6
|
+
* @property {__se__EventPorts} ports - Ports for interacting with editor
|
|
7
|
+
* @property {__se__EventKeydownCtx} ctx - Reducer context
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {(ctx: EffectContext, payload?: *) => *} Effect
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** @type {Record<string, Effect>} */
|
|
15
|
+
export default {
|
|
16
|
+
// event, cache
|
|
17
|
+
/** @action prevent */
|
|
18
|
+
'event.prevent': ({ ctx }) => ctx.e.preventDefault(),
|
|
19
|
+
/** @action stop */
|
|
20
|
+
'event.stop': ({ ctx }) => ctx.e.stopPropagation(),
|
|
21
|
+
/** @action preventStop */
|
|
22
|
+
'event.prevent.stop': ({ ctx }) => {
|
|
23
|
+
ctx.e.preventDefault();
|
|
24
|
+
ctx.e.stopPropagation();
|
|
25
|
+
},
|
|
26
|
+
/** @action cacheStyleNode */
|
|
27
|
+
'cache.styleNode': ({ ports }) => ports.styleNodeCache(),
|
|
28
|
+
/** @action cacheFormatAttrsTemp */
|
|
29
|
+
'cache.formatAttrsTemp': ({ ports }, { attrs }) => ports.formatAttrsTempCache(attrs),
|
|
30
|
+
|
|
31
|
+
// commands
|
|
32
|
+
/** @action editorNativeFocus */
|
|
33
|
+
'editor._nativeFocus': ({ ports }) => ports.editor._nativeFocus(),
|
|
34
|
+
/** @action historyPush */
|
|
35
|
+
'history.push': ({ ports }, hard) => ports.history.push(hard),
|
|
36
|
+
/** @action documentTypeRefreshHeader */
|
|
37
|
+
'documentType.refreshHeader': ({ ctx }) => {
|
|
38
|
+
_w.setTimeout(() => {
|
|
39
|
+
ctx.fc.get('documentType').reHeader();
|
|
40
|
+
}, 0);
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
// class
|
|
44
|
+
/** @action componentDeselect */
|
|
45
|
+
'component.deselect': ({ ports }) => ports.component.deselect(),
|
|
46
|
+
/** @action selectionSetRange */
|
|
47
|
+
'selection.setRange': ({ ports }, { sc, so, ec, eo }) => ports.selection.setRange(sc, so, ec, eo),
|
|
48
|
+
/** @action formatRemoveBlock */
|
|
49
|
+
'format.removeBlock': ({ ports }, { rangeEl, selectedFormats, newBlockElement, shouldDelete, skipHistory }) => ports.format.removeBlock(rangeEl, { selectedFormats, newBlockElement, shouldDelete, skipHistory }),
|
|
50
|
+
|
|
51
|
+
// helper
|
|
52
|
+
/** @action domUtilsRemoveItem */
|
|
53
|
+
'dom.utils.removeItem': (_, { item }) => dom.utils.removeItem(item),
|
|
54
|
+
|
|
55
|
+
// utils
|
|
56
|
+
/** @action selectComponentFallback */
|
|
57
|
+
'select.component.fallback': ({ ports }, { cmponentInfo }) => {
|
|
58
|
+
if (ports.component.select(cmponentInfo.target, cmponentInfo.pluginName) === false) ports.editor.blur();
|
|
59
|
+
}
|
|
60
|
+
};
|