jodit 3.15.2 → 3.16.2
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/.idea/workspace.xml +301 -299
- package/CHANGELOG.MD +88 -7
- package/CONTRIBUTING.md +97 -0
- package/README.md +7 -7
- package/build/jodit.css +38 -32
- package/build/jodit.es2018.css +37 -31
- package/build/jodit.es2018.en.css +37 -31
- package/build/jodit.es2018.en.js +1981 -1393
- package/build/jodit.es2018.en.min.css +1 -1
- package/build/jodit.es2018.en.min.js +1 -1
- package/build/jodit.es2018.js +2053 -1447
- package/build/jodit.es2018.min.css +1 -1
- package/build/jodit.es2018.min.js +1 -1
- package/build/jodit.js +3475 -2625
- package/build/jodit.min.css +2 -2
- package/build/jodit.min.js +1 -1
- package/build/vdom.css +1 -1
- package/build/vdom.js +32 -20
- package/package.json +13 -13
- package/src/README.md +1 -1
- package/src/config.ts +69 -36
- package/src/core/async/async.ts +46 -24
- package/src/core/constants.ts +1 -0
- package/src/core/decorators/README.md +35 -0
- package/src/core/decorators/cache/cache.ts +1 -1
- package/src/core/decorators/debounce/debounce.ts +20 -9
- package/src/core/decorators/idle/README.md +14 -0
- package/src/core/decorators/idle/idle.ts +1 -1
- package/src/core/decorators/watch/watch.ts +8 -7
- package/src/core/dom/README.md +42 -0
- package/src/core/dom/dom.ts +37 -23
- package/src/core/dom/index.ts +1 -0
- package/src/core/dom/lazy-walker.ts +133 -0
- package/src/core/event-emitter/event-emitter.ts +8 -8
- package/src/core/event-emitter/eventify.ts +73 -0
- package/src/core/event-emitter/index.ts +1 -0
- package/src/core/helpers/html/apply-styles.ts +1 -1
- package/src/core/helpers/html/strip-tags.ts +3 -2
- package/src/core/helpers/string/fuzzy-search-index.ts +58 -0
- package/src/core/helpers/string/i18n.ts +1 -1
- package/src/core/helpers/string/index.ts +3 -2
- package/src/core/helpers/utils/append-script.ts +1 -1
- package/src/core/helpers/utils/css.ts +1 -1
- package/src/core/helpers/utils/selector.ts +1 -1
- package/src/core/helpers/utils/utils.ts +3 -3
- package/src/core/plugin/plugin-system.ts +14 -8
- package/src/core/request/ajax.ts +3 -3
- package/src/core/selection/select.ts +10 -10
- package/src/core/selection/style/api/toggle/toggle-css.ts +5 -2
- package/src/core/selection/style/api/wrap-unwrapped-text.ts +1 -1
- package/src/core/selection/style/apply-style.ts +4 -4
- package/src/core/storage/engines/local-storage-provider.ts +20 -19
- package/src/core/ui/button/button/button.ts +5 -5
- package/src/core/ui/element.ts +2 -2
- package/src/core/ui/form/inputs/input/input.ts +1 -1
- package/src/core/ui/form/inputs/select/select.ts +1 -1
- package/src/core/ui/group/list.ts +2 -2
- package/src/core/vdom/render/index.ts +12 -8
- package/src/core/vdom/v-dom-jodit.ts +1 -1
- package/src/core/view/view.ts +1 -1
- package/src/index.ts +3 -3
- package/src/jodit.ts +72 -55
- package/src/langs/README.md +1 -1
- package/src/langs/ar.js +2 -1
- package/src/langs/cs_cz.js +2 -1
- package/src/langs/de.js +2 -1
- package/src/langs/es.js +2 -1
- package/src/langs/fa.js +2 -1
- package/src/langs/fr.js +2 -1
- package/src/langs/he.js +2 -1
- package/src/langs/hu.js +2 -1
- package/src/langs/id.js +2 -1
- package/src/langs/index.ts +1 -1
- package/src/langs/it.js +2 -1
- package/src/langs/ja.js +2 -1
- package/src/langs/ko.js +2 -1
- package/src/langs/nl.js +2 -1
- package/src/langs/pl.js +2 -1
- package/src/langs/pt_br.js +2 -1
- package/src/langs/ru.js +2 -1
- package/src/langs/tr.js +2 -1
- package/src/langs/zh_cn.js +2 -1
- package/src/langs/zh_tw.js +2 -1
- package/src/modules/dialog/dialog.ts +6 -6
- package/src/modules/dialog/prompt.ts +1 -1
- package/src/modules/file-browser/README.md +2 -2
- package/src/modules/file-browser/builders/context-menu.ts +12 -13
- package/src/modules/file-browser/fetch/load-tree.ts +1 -1
- package/src/modules/file-browser/file-browser.ts +10 -7
- package/src/modules/history/README.md +5 -0
- package/src/modules/{observer → history}/command.ts +5 -5
- package/src/modules/{observer/observer.ts → history/history.ts} +97 -55
- package/src/modules/{observer → history}/snapshot.ts +3 -4
- package/src/modules/{observer → history}/stack.ts +4 -4
- package/src/modules/image-editor/image-editor.ts +8 -8
- package/src/modules/image-editor/templates/form.ts +2 -2
- package/src/modules/index.ts +3 -3
- package/src/modules/status-bar/status-bar.ts +4 -0
- package/src/modules/table/table.ts +2 -2
- package/src/modules/toolbar/button/button.ts +2 -2
- package/src/modules/toolbar/collection/collection.ts +1 -1
- package/src/modules/uploader/helpers/process-old-browser-drag.ts +1 -1
- package/src/modules/uploader/helpers/send-files.ts +1 -1
- package/src/modules/uploader/helpers/send.ts +1 -1
- package/src/modules/uploader/uploader.ts +3 -3
- package/src/modules/widget/color-picker/color-picker.ts +2 -3
- package/src/modules/widget/tabs/tabs.ts +17 -12
- package/src/plugins/add-new-line/add-new-line.ts +8 -8
- package/src/plugins/class-span/class-span.ts +1 -1
- package/src/plugins/clipboard/copy-format.ts +1 -1
- package/src/plugins/clipboard/drag-and-drop-element.ts +4 -2
- package/src/plugins/clipboard/paste/config.ts +19 -3
- package/src/plugins/clipboard/paste/helpers.ts +17 -50
- package/src/plugins/clipboard/paste/interface.ts +6 -0
- package/src/plugins/clipboard/paste/paste.ts +22 -8
- package/src/plugins/clipboard/paste-from-word/config.ts +17 -0
- package/src/plugins/clipboard/paste-from-word/paste-from-word.ts +15 -6
- package/src/plugins/clipboard/paste-storage/paste-storage.ts +6 -6
- package/src/plugins/color/color.ts +2 -2
- package/src/plugins/error-messages/error-messages.ts +2 -2
- package/src/plugins/fix/clean-html/README.md +26 -0
- package/src/plugins/fix/{clean-html.ts → clean-html/clean-html.ts} +59 -142
- package/src/plugins/fix/clean-html/config.ts +106 -0
- package/src/plugins/fix/index.ts +12 -0
- package/src/plugins/fix/wrap-nodes/README.md +27 -0
- package/src/plugins/fix/wrap-nodes/config.ts +24 -0
- package/src/plugins/fix/{wrap-text-nodes.ts → wrap-nodes/wrap-nodes.ts} +9 -4
- package/src/plugins/focus/focus.ts +1 -1
- package/src/plugins/format-block/format-block.ts +1 -1
- package/src/plugins/fullsize/fullsize.ts +4 -4
- package/src/plugins/iframe/iframe.ts +3 -3
- package/src/plugins/image/image-properties/image-properties.ts +12 -13
- package/src/plugins/indent/indent.ts +1 -1
- package/src/plugins/index.ts +2 -2
- package/src/plugins/inline-popup/config/items/a.ts +2 -2
- package/src/plugins/inline-popup/config/items/cells.ts +11 -11
- package/src/plugins/inline-popup/config/items/iframe.ts +1 -1
- package/src/plugins/inline-popup/config/items/img.ts +7 -7
- package/src/plugins/inline-popup/inline-popup.ts +5 -5
- package/src/plugins/keyboard/backspace/backspace.ts +1 -1
- package/src/plugins/keyboard/backspace/cases/check-join-neighbors.ts +1 -1
- package/src/plugins/keyboard/helpers.ts +1 -1
- package/src/plugins/keyboard/hotkeys.ts +1 -1
- package/src/plugins/limit/limit.ts +3 -3
- package/src/plugins/line-height/line-height.ts +1 -1
- package/src/plugins/link/link.ts +8 -8
- package/src/plugins/link/template.ts +2 -2
- package/src/plugins/media/file.ts +1 -1
- package/src/plugins/media/media.ts +1 -1
- package/src/plugins/media/video/config.ts +1 -1
- package/src/plugins/mobile/config.ts +1 -1
- package/src/plugins/mobile/mobile.ts +1 -1
- package/src/plugins/ordered-list/config.ts +61 -0
- package/src/plugins/ordered-list/ordered-list.ts +3 -153
- package/src/plugins/placeholder/placeholder.ts +3 -3
- package/src/plugins/print/helpers.ts +14 -7
- package/src/plugins/print/index.ts +1 -1
- package/src/plugins/print/{preview.less → preview/preview.less} +1 -1
- package/src/plugins/print/{preview.ts → preview/preview.ts} +9 -8
- package/src/plugins/print/print.ts +19 -10
- package/src/plugins/redo-undo/redo-undo.ts +3 -3
- package/src/plugins/resizer/resizer.ts +11 -11
- package/src/plugins/search/README.md +38 -0
- package/src/plugins/search/config.ts +82 -0
- package/src/plugins/search/helpers/index.ts +12 -0
- package/src/plugins/search/helpers/sentence-finder.ts +103 -0
- package/src/plugins/search/helpers/wrap-ranges-texts-in-tmp-span.ts +120 -0
- package/src/plugins/search/search.ts +269 -615
- package/src/plugins/search/ui/search.less +159 -0
- package/src/plugins/search/ui/search.ts +256 -0
- package/src/plugins/select/select.ts +1 -1
- package/src/plugins/size/config.ts +8 -8
- package/src/plugins/size/resize-handler.ts +3 -3
- package/src/plugins/size/size.ts +4 -4
- package/src/plugins/source/editor/engines/ace.ts +9 -9
- package/src/plugins/source/editor/engines/area.ts +3 -3
- package/src/plugins/source/source.ts +6 -6
- package/src/plugins/spellcheck/README.md +1 -0
- package/src/plugins/spellcheck/config.ts +34 -0
- package/src/plugins/spellcheck/spellcheck.svg +4 -0
- package/src/plugins/spellcheck/spellcheck.ts +48 -0
- package/src/plugins/sticky/sticky.ts +3 -3
- package/src/plugins/table/resize-cells.ts +11 -11
- package/src/plugins/table/select-cells.ts +2 -2
- package/src/plugins/tooltip/tooltip.ts +1 -1
- package/src/plugins/xpath/xpath.ts +8 -8
- package/src/polyfills.ts +5 -4
- package/src/styles/icons/README.md +2 -2
- package/src/types/async.d.ts +12 -2
- package/src/types/core.ts +1 -1
- package/src/types/events.d.ts +6 -2
- package/src/types/file-browser.d.ts +1 -2
- package/{types/types/observer.d.ts → src/types/history.d.ts} +11 -7
- package/src/types/index.d.ts +1 -1
- package/src/types/jodit.d.ts +12 -4
- package/src/types/toolbar.d.ts +5 -5
- package/src/types/types.d.ts +11 -4
- package/types/config.d.ts +68 -35
- package/types/core/async/async.d.ts +11 -4
- package/types/core/constants.d.ts +1 -0
- package/types/core/dom/dom.d.ts +3 -5
- package/types/core/dom/index.d.ts +1 -0
- package/types/core/dom/lazy-walker.d.ts +37 -0
- package/types/core/event-emitter/eventify.d.ts +39 -0
- package/types/core/event-emitter/index.d.ts +1 -0
- package/types/core/helpers/string/fuzzy-search-index.d.ts +10 -0
- package/types/core/helpers/string/i18n.d.ts +1 -1
- package/types/core/helpers/string/index.d.ts +3 -2
- package/types/core/helpers/utils/utils.d.ts +1 -1
- package/types/core/selection/select.d.ts +1 -1
- package/types/core/ui/button/button/button.d.ts +4 -4
- package/types/core/view/view.d.ts +1 -1
- package/types/jodit.d.ts +19 -6
- package/types/modules/{observer → history}/command.d.ts +4 -4
- package/types/modules/{observer/observer.d.ts → history/history.d.ts} +17 -9
- package/types/modules/{observer → history}/snapshot.d.ts +1 -1
- package/types/modules/{observer → history}/stack.d.ts +3 -3
- package/types/modules/image-editor/image-editor.d.ts +1 -1
- package/types/modules/index.d.ts +3 -3
- package/types/modules/toolbar/button/button.d.ts +2 -5
- package/types/modules/widget/tabs/tabs.d.ts +1 -1
- package/types/plugins/class-span/class-span.d.ts +1 -1
- package/types/plugins/clipboard/paste/config.d.ts +8 -0
- package/types/plugins/clipboard/paste/helpers.d.ts +2 -2
- package/types/plugins/clipboard/paste/interface.d.ts +5 -0
- package/types/plugins/clipboard/paste-from-word/config.d.ts +5 -0
- package/types/plugins/clipboard/paste-from-word/paste-from-word.d.ts +3 -2
- package/types/plugins/fix/clean-html/clean-html.d.ts +70 -0
- package/types/plugins/fix/{clean-html.d.ts → clean-html/config.d.ts} +2 -57
- package/types/plugins/fix/index.d.ts +10 -0
- package/types/plugins/fix/wrap-nodes/config.d.ts +16 -0
- package/types/plugins/fix/{wrap-text-nodes.d.ts → wrap-nodes/wrap-nodes.d.ts} +5 -2
- package/types/plugins/fullsize/fullsize.d.ts +2 -2
- package/types/plugins/index.d.ts +2 -2
- package/types/plugins/ordered-list/config.d.ts +6 -0
- package/types/plugins/ordered-list/ordered-list.d.ts +1 -1
- package/types/plugins/print/helpers.d.ts +2 -2
- package/types/plugins/print/index.d.ts +1 -1
- package/types/plugins/print/{preview.d.ts → preview/preview.d.ts} +1 -1
- package/types/plugins/search/config.d.ts +36 -0
- package/types/plugins/search/helpers/index.d.ts +10 -0
- package/types/plugins/search/helpers/sentence-finder.d.ts +21 -0
- package/types/plugins/search/helpers/wrap-ranges-texts-in-tmp-span.d.ts +14 -0
- package/types/plugins/search/search.d.ts +25 -39
- package/types/plugins/search/ui/search.d.ts +37 -0
- package/types/plugins/spellcheck/config.d.ts +15 -0
- package/types/plugins/spellcheck/spellcheck.d.ts +19 -0
- package/types/plugins/sticky/sticky.d.ts +2 -2
- package/types/types/async.d.ts +12 -2
- package/types/types/core.d.ts +1 -1
- package/types/types/core.ts +1 -1
- package/types/types/events.d.ts +6 -2
- package/types/types/file-browser.d.ts +1 -2
- package/{src/types/observer.d.ts → types/types/history.d.ts} +11 -7
- package/types/types/index.d.ts +1 -1
- package/types/types/jodit.d.ts +12 -4
- package/types/types/toolbar.d.ts +5 -5
- package/types/types/types.d.ts +11 -4
- package/src/modules/observer/README.md +0 -0
- package/src/plugins/search/search.less +0 -152
|
@@ -51,7 +51,7 @@ export function attr(elm: Element, key: string): null | string;
|
|
|
51
51
|
/**
|
|
52
52
|
* Remove attribute
|
|
53
53
|
*/
|
|
54
|
-
export function attr(elm: Element, key: string, value: null):
|
|
54
|
+
export function attr(elm: Element, key: string, value: null): void;
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Set attribute
|
|
@@ -200,11 +200,11 @@ export const loadImage = (
|
|
|
200
200
|
): RejectablePromise<HTMLImageElement> =>
|
|
201
201
|
jodit.async.promise<HTMLImageElement>((res, rej) => {
|
|
202
202
|
const image = new Image(),
|
|
203
|
-
onError = () => {
|
|
203
|
+
onError = (): void => {
|
|
204
204
|
jodit.e.off(image);
|
|
205
205
|
rej?.();
|
|
206
206
|
},
|
|
207
|
-
onSuccess = () => {
|
|
207
|
+
onSuccess = (): void => {
|
|
208
208
|
jodit.e.off(image);
|
|
209
209
|
res(image);
|
|
210
210
|
};
|
|
@@ -91,14 +91,20 @@ export class PluginSystem implements IPluginSystem {
|
|
|
91
91
|
const extrasList: IExtraPlugin[] = jodit.o.extraPlugins.map(s =>
|
|
92
92
|
isString(s) ? { name: s } : s
|
|
93
93
|
),
|
|
94
|
-
disableList = splitArray(jodit.o.disablePlugins).map(s =>
|
|
95
|
-
this.normalizeName(s)
|
|
96
|
-
|
|
94
|
+
disableList = splitArray(jodit.o.disablePlugins).map(s => {
|
|
95
|
+
const name = this.normalizeName(s);
|
|
96
|
+
|
|
97
|
+
if (!isProd && !this._items.has(name)) {
|
|
98
|
+
console.error(TypeError(`Unknown plugin disabled:${name}`));
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return name;
|
|
102
|
+
}),
|
|
97
103
|
doneList: string[] = [],
|
|
98
104
|
promiseList: IDictionary<PluginInstance | undefined> = {},
|
|
99
105
|
plugins: PluginInstance[] = [],
|
|
100
106
|
pluginsMap: IDictionary<PluginInstance> = {},
|
|
101
|
-
makeAndInit = ([name, plugin]: [string, PluginType]) => {
|
|
107
|
+
makeAndInit = ([name, plugin]: [string, PluginType]): void => {
|
|
102
108
|
if (
|
|
103
109
|
disableList.includes(name) ||
|
|
104
110
|
doneList.includes(name) ||
|
|
@@ -197,7 +203,7 @@ export class PluginSystem implements IPluginSystem {
|
|
|
197
203
|
instance: PluginInstance,
|
|
198
204
|
doneList: string[],
|
|
199
205
|
promiseList: IDictionary<PluginInstance | undefined>
|
|
200
|
-
) {
|
|
206
|
+
): void {
|
|
201
207
|
const initPlugin = (name: string, plugin: PluginInstance): boolean => {
|
|
202
208
|
if (isInitable(plugin)) {
|
|
203
209
|
const req = (plugin as IPlugin).requires;
|
|
@@ -218,7 +224,7 @@ export class PluginSystem implements IPluginSystem {
|
|
|
218
224
|
|
|
219
225
|
doneList.push(name);
|
|
220
226
|
} else {
|
|
221
|
-
if (!isProd) {
|
|
227
|
+
if (!isProd && !promiseList[name]) {
|
|
222
228
|
console.log('Await plugin: ', name);
|
|
223
229
|
}
|
|
224
230
|
|
|
@@ -258,7 +264,7 @@ export class PluginSystem implements IPluginSystem {
|
|
|
258
264
|
private addListenerOnBeforeDestruct(
|
|
259
265
|
jodit: IJodit,
|
|
260
266
|
plugins: PluginInstance[]
|
|
261
|
-
) {
|
|
267
|
+
): void {
|
|
262
268
|
jodit.e.on('beforeDestruct', () => {
|
|
263
269
|
plugins.forEach(instance => {
|
|
264
270
|
if (isDestructable(instance)) {
|
|
@@ -276,7 +282,7 @@ export class PluginSystem implements IPluginSystem {
|
|
|
276
282
|
* Download plugins
|
|
277
283
|
*/
|
|
278
284
|
private load(jodit: IJodit, pluginList: IExtraPlugin[]): Promise<any> {
|
|
279
|
-
const reflect = (p: Promise<any>) =>
|
|
285
|
+
const reflect = (p: Promise<any>): Promise<any> =>
|
|
280
286
|
p.then(
|
|
281
287
|
(v: any) => ({ v, status: 'fulfilled' }),
|
|
282
288
|
(e: any) => ({ e, status: 'rejected' })
|
package/src/core/request/ajax.ts
CHANGED
|
@@ -102,11 +102,11 @@ export class Ajax<T extends object = any> implements IAjax<T> {
|
|
|
102
102
|
const request = this.prepareRequest();
|
|
103
103
|
|
|
104
104
|
return this.j.async.promise((resolve, reject) => {
|
|
105
|
-
const onReject = () => {
|
|
105
|
+
const onReject = (): void => {
|
|
106
106
|
reject(error('Connection error'));
|
|
107
107
|
};
|
|
108
108
|
|
|
109
|
-
const onResolve = () => {
|
|
109
|
+
const onResolve = (): void => {
|
|
110
110
|
this.resolved = true;
|
|
111
111
|
|
|
112
112
|
resolve(
|
|
@@ -138,7 +138,7 @@ export class Ajax<T extends object = any> implements IAjax<T> {
|
|
|
138
138
|
this.options.onProgress?.(percentComplete);
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
-
xhr.onreadystatechange = () => {
|
|
141
|
+
xhr.onreadystatechange = (): void => {
|
|
142
142
|
this.options.onProgress?.(10);
|
|
143
143
|
|
|
144
144
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
@@ -179,7 +179,7 @@ export class Select implements ISelect {
|
|
|
179
179
|
try {
|
|
180
180
|
const rng = this.createRange();
|
|
181
181
|
|
|
182
|
-
(() => {
|
|
182
|
+
((): void => {
|
|
183
183
|
if (this.doc.caretPositionFromPoint) {
|
|
184
184
|
const caret = this.doc.caretPositionFromPoint(x, y);
|
|
185
185
|
|
|
@@ -286,7 +286,7 @@ export class Select implements ISelect {
|
|
|
286
286
|
restore(): void {
|
|
287
287
|
let range: Range | false = false;
|
|
288
288
|
|
|
289
|
-
const markAttr = (start: boolean) =>
|
|
289
|
+
const markAttr = (start: boolean): string =>
|
|
290
290
|
`span[data-${consts.MARKER_CLASS}=${start ? 'start' : 'end'}]`;
|
|
291
291
|
|
|
292
292
|
const start = this.area.querySelector(markAttr(true)),
|
|
@@ -725,7 +725,7 @@ export class Select implements ISelect {
|
|
|
725
725
|
css(image, styles);
|
|
726
726
|
}
|
|
727
727
|
|
|
728
|
-
const onload = () => {
|
|
728
|
+
const onload = (): void => {
|
|
729
729
|
if (
|
|
730
730
|
image.naturalHeight < image.offsetHeight ||
|
|
731
731
|
image.naturalWidth < image.offsetWidth
|
|
@@ -750,7 +750,7 @@ export class Select implements ISelect {
|
|
|
750
750
|
* {@link FileBrowser|FileBrowser} or {@link Uploader|Uploader}
|
|
751
751
|
* @example
|
|
752
752
|
* ```javascript
|
|
753
|
-
* var editor =
|
|
753
|
+
* var editor = Jodit.make("#redactor");
|
|
754
754
|
* editor.e.on('afterInsertImage', function (image) {
|
|
755
755
|
* image.className = 'bloghead4';
|
|
756
756
|
* });
|
|
@@ -806,7 +806,7 @@ export class Select implements ISelect {
|
|
|
806
806
|
end = end.previousSibling;
|
|
807
807
|
}
|
|
808
808
|
|
|
809
|
-
const checkElm = (node: Nullable<Node>) => {
|
|
809
|
+
const checkElm = (node: Nullable<Node>): void => {
|
|
810
810
|
if (
|
|
811
811
|
node &&
|
|
812
812
|
node !== root &&
|
|
@@ -900,8 +900,8 @@ export class Select implements ISelect {
|
|
|
900
900
|
const container = start ? range.startContainer : range.endContainer;
|
|
901
901
|
const offset = start ? range.startOffset : range.endOffset;
|
|
902
902
|
|
|
903
|
-
const check = (elm: Node | null) =>
|
|
904
|
-
elm && !Dom.isTag(elm, 'br') && !Dom.isEmptyTextNode(elm);
|
|
903
|
+
const check = (elm: Node | null): boolean =>
|
|
904
|
+
Boolean(elm && !Dom.isTag(elm, 'br') && !Dom.isEmptyTextNode(elm));
|
|
905
905
|
|
|
906
906
|
// check right offset
|
|
907
907
|
if (Dom.isText(container)) {
|
|
@@ -1117,7 +1117,7 @@ export class Select implements ISelect {
|
|
|
1117
1117
|
* Return current selected HTML
|
|
1118
1118
|
* @example
|
|
1119
1119
|
* ```javascript
|
|
1120
|
-
* const editor =
|
|
1120
|
+
* const editor = Jodit.make();
|
|
1121
1121
|
* console.log(editor.s.html); // html
|
|
1122
1122
|
* console.log(Jodit.modules.Helpers.stripTags(editor.s.html)); // plain text
|
|
1123
1123
|
* ```
|
|
@@ -1318,7 +1318,7 @@ export class Select implements ISelect {
|
|
|
1318
1318
|
const clearBR = (
|
|
1319
1319
|
start: Node,
|
|
1320
1320
|
getNext: (node: Node) => Node | null
|
|
1321
|
-
) => {
|
|
1321
|
+
): void => {
|
|
1322
1322
|
let next = getNext(start);
|
|
1323
1323
|
|
|
1324
1324
|
while (next) {
|
|
@@ -1373,7 +1373,7 @@ export class Select implements ISelect {
|
|
|
1373
1373
|
}
|
|
1374
1374
|
|
|
1375
1375
|
// After splitting some part can be empty
|
|
1376
|
-
const fillFakeParent = (fake: Node) => {
|
|
1376
|
+
const fillFakeParent = (fake: Node): void => {
|
|
1377
1377
|
if (
|
|
1378
1378
|
fake?.parentNode?.firstChild === fake?.parentNode?.lastChild
|
|
1379
1379
|
) {
|
|
@@ -45,12 +45,15 @@ export function toggleCSS(
|
|
|
45
45
|
) {
|
|
46
46
|
!dry && css(elm, rule, null);
|
|
47
47
|
mode = UNSET;
|
|
48
|
-
mode =
|
|
48
|
+
mode = removeExtraStyleAttribute(commitStyle, elm, mode);
|
|
49
49
|
return;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
mode = CHANGE;
|
|
53
53
|
!dry && css(elm, rule, style[rule]);
|
|
54
|
+
if (!dry) {
|
|
55
|
+
mode = removeExtraStyleAttribute(commitStyle, elm, mode);
|
|
56
|
+
}
|
|
54
57
|
});
|
|
55
58
|
}
|
|
56
59
|
|
|
@@ -71,7 +74,7 @@ export function toggleCSS(
|
|
|
71
74
|
* If the element has an empty style attribute, it removes the attribute,
|
|
72
75
|
* and if it is default, it removes the element itself
|
|
73
76
|
*/
|
|
74
|
-
function
|
|
77
|
+
function removeExtraStyleAttribute(
|
|
75
78
|
commitStyle: CommitStyle,
|
|
76
79
|
elm: HTMLElement,
|
|
77
80
|
mode: CommitMode
|
|
@@ -20,7 +20,7 @@ export function wrapUnwrappedText(
|
|
|
20
20
|
): HTMLElement {
|
|
21
21
|
const root = jodit.editor,
|
|
22
22
|
ci = jodit.createInside,
|
|
23
|
-
edge = (n: Node, key: keyof Node = 'previousSibling') => {
|
|
23
|
+
edge = (n: Node, key: keyof Node = 'previousSibling'): Node => {
|
|
24
24
|
let edgeNode: Node = n,
|
|
25
25
|
node: Nullable<Node> = n;
|
|
26
26
|
|
|
@@ -34,7 +34,7 @@ export function ApplyStyle(jodit: IJodit, cs: CommitStyle): void {
|
|
|
34
34
|
|
|
35
35
|
const fsm = new FiniteStateMachine('start', {
|
|
36
36
|
start: {
|
|
37
|
-
start() {
|
|
37
|
+
start(): void {
|
|
38
38
|
sel.save();
|
|
39
39
|
normalizeNode(editor.firstChild); // FF fix for test "commandsTest - Exec command "bold"
|
|
40
40
|
this.setState('generator');
|
|
@@ -42,7 +42,7 @@ export function ApplyStyle(jodit: IJodit, cs: CommitStyle): void {
|
|
|
42
42
|
},
|
|
43
43
|
|
|
44
44
|
generator: {
|
|
45
|
-
initGenerator() {
|
|
45
|
+
initGenerator(): Generator {
|
|
46
46
|
return jodit.s.wrapInTagGen();
|
|
47
47
|
},
|
|
48
48
|
|
|
@@ -174,13 +174,13 @@ export function ApplyStyle(jodit: IJodit, cs: CommitStyle): void {
|
|
|
174
174
|
},
|
|
175
175
|
|
|
176
176
|
endProcess: {
|
|
177
|
-
toggleStyles() {
|
|
177
|
+
toggleStyles(): void {
|
|
178
178
|
this.setState('generator');
|
|
179
179
|
}
|
|
180
180
|
},
|
|
181
181
|
|
|
182
182
|
end: {
|
|
183
|
-
finalize() {
|
|
183
|
+
finalize(): void {
|
|
184
184
|
sel.restore();
|
|
185
185
|
}
|
|
186
186
|
}
|
|
@@ -13,31 +13,32 @@ import type { BooleanFunction, IStorage, StorageValueType } from 'jodit/types';
|
|
|
13
13
|
/**
|
|
14
14
|
* Check if user disable local storages/cookie etc.
|
|
15
15
|
*/
|
|
16
|
-
export const canUsePersistentStorage: BooleanFunction =
|
|
17
|
-
|
|
18
|
-
const
|
|
16
|
+
export const canUsePersistentStorage: BooleanFunction =
|
|
17
|
+
((): BooleanFunction => {
|
|
18
|
+
const canUse = (): boolean => {
|
|
19
|
+
const tmpKey = '___Jodit___' + Math.random().toString();
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
try {
|
|
22
|
+
localStorage.setItem(tmpKey, '1');
|
|
23
|
+
const result = localStorage.getItem(tmpKey) === '1';
|
|
24
|
+
localStorage.removeItem(tmpKey);
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
return result;
|
|
27
|
+
} catch {}
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
return false;
|
|
30
|
+
};
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
let result: boolean | undefined;
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
return () => {
|
|
35
|
+
if (result === undefined) {
|
|
36
|
+
result = canUse();
|
|
37
|
+
}
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
})();
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Persistent storage in localStorage
|
|
@@ -49,16 +49,16 @@ export const UIButtonState = (): IUIButtonState => ({
|
|
|
49
49
|
@component
|
|
50
50
|
export class UIButton extends UIElement implements IUIButton {
|
|
51
51
|
/** @override */
|
|
52
|
-
className(): string {
|
|
52
|
+
override className(): string {
|
|
53
53
|
return 'UIButton';
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
/**
|
|
57
57
|
* Marker for buttons
|
|
58
58
|
*/
|
|
59
|
-
isButton: true = true;
|
|
59
|
+
readonly isButton: true = true;
|
|
60
60
|
|
|
61
|
-
state = UIButtonState();
|
|
61
|
+
readonly state = UIButtonState();
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Set state
|
|
@@ -148,7 +148,7 @@ export class UIButton extends UIElement implements IUIButton {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
@watch('state.tabIndex')
|
|
151
|
-
onChangeTabIndex(): void {
|
|
151
|
+
protected onChangeTabIndex(): void {
|
|
152
152
|
attr(this.container, 'tabindex', this.state.tabIndex);
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -228,7 +228,7 @@ export class UIButton extends UIElement implements IUIButton {
|
|
|
228
228
|
return super.destruct();
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
private actionHandlers: Function[] = [];
|
|
231
|
+
private readonly actionHandlers: Function[] = [];
|
|
232
232
|
|
|
233
233
|
/**
|
|
234
234
|
* Add action handler
|
package/src/core/ui/element.ts
CHANGED
|
@@ -71,8 +71,8 @@ export abstract class UIElement<T extends IViewBased = IViewBased>
|
|
|
71
71
|
closest<T extends IUIElement>(type: Function | T): Nullable<T> {
|
|
72
72
|
const c =
|
|
73
73
|
typeof type === 'object'
|
|
74
|
-
? (pe: IUIElement) => pe === type
|
|
75
|
-
: (pe: IUIElement) => pe instanceof type;
|
|
74
|
+
? (pe: IUIElement): boolean => pe === type
|
|
75
|
+
: (pe: IUIElement): boolean => pe instanceof type;
|
|
76
76
|
|
|
77
77
|
let pe = this.__parentElement;
|
|
78
78
|
|
|
@@ -49,7 +49,7 @@ export class UISelect extends UIInput implements IUISelect {
|
|
|
49
49
|
const { j } = this,
|
|
50
50
|
{ nativeInput } = this;
|
|
51
51
|
|
|
52
|
-
const opt = () => j.create.element('option');
|
|
52
|
+
const opt = (): HTMLOptionElement => j.create.element('option');
|
|
53
53
|
|
|
54
54
|
if (state.placeholder !== undefined) {
|
|
55
55
|
const option = opt();
|
|
@@ -99,7 +99,7 @@ export class UIList<T extends IViewBased = IViewBased>
|
|
|
99
99
|
|
|
100
100
|
let group: IUIGroup;
|
|
101
101
|
|
|
102
|
-
const addButton = (control: IControlTypeStrong) => {
|
|
102
|
+
const addButton = (control: IControlTypeStrong): void => {
|
|
103
103
|
let elm: Nullable<IUIElement> = null;
|
|
104
104
|
|
|
105
105
|
switch (control.name) {
|
|
@@ -146,7 +146,7 @@ export class UIList<T extends IViewBased = IViewBased>
|
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
const isNotRemoved = (b: IControlTypeStrong) =>
|
|
149
|
+
const isNotRemoved = (b: IControlTypeStrong): boolean =>
|
|
150
150
|
!this.removeButtons.includes(b.name);
|
|
151
151
|
|
|
152
152
|
items.forEach(item => {
|
|
@@ -14,13 +14,17 @@ import { domToVDom } from '../helpers';
|
|
|
14
14
|
import { Async } from 'jodit/core/async';
|
|
15
15
|
import autobind from 'autobind-decorator';
|
|
16
16
|
|
|
17
|
-
const isProperty = (key: string) => key !== 'children';
|
|
17
|
+
const isProperty = (key: string): boolean => key !== 'children';
|
|
18
18
|
|
|
19
|
-
const isNew =
|
|
20
|
-
prev
|
|
19
|
+
const isNew =
|
|
20
|
+
(prev: IDictionary, next: IDictionary) =>
|
|
21
|
+
(key: string): boolean =>
|
|
22
|
+
prev[key] !== next[key];
|
|
21
23
|
|
|
22
|
-
const isGone =
|
|
23
|
-
|
|
24
|
+
const isGone =
|
|
25
|
+
(prev: IDictionary, next: IDictionary) =>
|
|
26
|
+
(key: string): boolean =>
|
|
27
|
+
!(key in next);
|
|
24
28
|
|
|
25
29
|
const updateDom = (
|
|
26
30
|
dom: Node,
|
|
@@ -59,7 +63,7 @@ const createDom = (fiber: IFiber): Node => {
|
|
|
59
63
|
export class VDomRender {
|
|
60
64
|
private async: Async = new Async();
|
|
61
65
|
|
|
62
|
-
private commitRoot() {
|
|
66
|
+
private commitRoot(): void {
|
|
63
67
|
this.deletions.forEach(this.commitWork);
|
|
64
68
|
this.deletions.length = 0;
|
|
65
69
|
this.commitWork(this.wipRoot?.child);
|
|
@@ -67,7 +71,7 @@ export class VDomRender {
|
|
|
67
71
|
this.wipRoot = undefined;
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
private commitWork(fiber: CanUndef<IFiber>) {
|
|
74
|
+
private commitWork(fiber: CanUndef<IFiber>): void {
|
|
71
75
|
if (!fiber) {
|
|
72
76
|
return;
|
|
73
77
|
}
|
|
@@ -92,7 +96,7 @@ export class VDomRender {
|
|
|
92
96
|
this.commitWork(fiber?.sibling);
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
private commitDeletion(fiber: CanUndef<IFiber>, domParent: Node) {
|
|
99
|
+
private commitDeletion(fiber: CanUndef<IFiber>, domParent: Node): void {
|
|
96
100
|
if (fiber?.dom) {
|
|
97
101
|
domParent.removeChild(fiber.dom);
|
|
98
102
|
} else {
|
package/src/core/view/view.ts
CHANGED
|
@@ -98,7 +98,7 @@ export abstract class View extends Component implements IViewBased, Mods, Elms {
|
|
|
98
98
|
|
|
99
99
|
/**
|
|
100
100
|
* Return default timeout period in milliseconds for some debounce or throttle functions.
|
|
101
|
-
* By default
|
|
101
|
+
* By default, `{history.timeout}` options
|
|
102
102
|
*/
|
|
103
103
|
get defaultTimeout(): number {
|
|
104
104
|
return isVoid(this.o.defaultTimeout) ? 100 : this.o.defaultTimeout;
|
package/src/index.ts
CHANGED
|
@@ -23,14 +23,14 @@ import { Jodit as DefaultJodit } from './jodit';
|
|
|
23
23
|
import Languages from './langs/';
|
|
24
24
|
|
|
25
25
|
import * as decorators from './core/decorators';
|
|
26
|
-
import * as
|
|
26
|
+
import * as constants from './core/constants';
|
|
27
27
|
import * as Modules from './modules/';
|
|
28
28
|
import * as Plugins from './plugins/';
|
|
29
29
|
import * as Icons from './styles/icons/';
|
|
30
30
|
|
|
31
31
|
// copy constants in Jodit
|
|
32
|
-
Object.keys(
|
|
33
|
-
(DefaultJodit as any)[key] = (
|
|
32
|
+
Object.keys(constants).forEach((key: string) => {
|
|
33
|
+
(DefaultJodit as any)[key] = (constants as any)[key];
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
const esFilter = (key: string): boolean => key !== '__esModule';
|