jodit 4.2.50 → 4.3.1
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/CHANGELOG.md +27 -0
- package/es2015/jodit.css +1 -1
- package/es2015/jodit.fat.min.js +2 -2
- package/es2015/jodit.js +238 -108
- package/es2015/jodit.min.js +2 -2
- package/es2015/plugins/debug/debug.css +1 -1
- package/es2015/plugins/debug/debug.js +1 -1
- package/es2015/plugins/debug/debug.min.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2015/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2018/jodit.css +1 -1
- package/es2018/jodit.fat.min.js +2 -2
- package/es2018/jodit.js +239 -108
- package/es2018/jodit.min.js +2 -2
- package/es2018/plugins/debug/debug.css +1 -1
- package/es2018/plugins/debug/debug.js +1 -1
- package/es2018/plugins/debug/debug.min.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2018/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021/jodit.css +1 -1
- package/es2021/jodit.fat.min.js +2 -2
- package/es2021/jodit.js +237 -107
- package/es2021/jodit.min.js +2 -2
- package/es2021/plugins/debug/debug.css +1 -1
- package/es2021/plugins/debug/debug.js +1 -1
- package/es2021/plugins/debug/debug.min.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2021/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es2021.en/jodit.css +1 -1
- package/es2021.en/jodit.fat.min.js +2 -2
- package/es2021.en/jodit.js +237 -107
- package/es2021.en/jodit.min.js +2 -2
- package/es2021.en/plugins/debug/debug.css +1 -1
- package/es2021.en/plugins/debug/debug.js +1 -1
- package/es2021.en/plugins/debug/debug.min.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es2021.en/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/es5/164.fat.min.js +1 -1
- package/es5/164.min.js +1 -1
- package/es5/5.fat.min.js +1 -1
- package/es5/5.min.js +1 -1
- package/es5/jodit.css +2 -2
- package/es5/jodit.fat.min.js +2 -2
- package/es5/jodit.js +241 -109
- package/es5/jodit.min.css +2 -2
- package/es5/jodit.min.js +2 -2
- package/es5/plugins/debug/debug.css +1 -1
- package/es5/plugins/debug/debug.js +1 -1
- package/es5/plugins/debug/debug.min.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.css +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.js +1 -1
- package/es5/plugins/speech-recognize/speech-recognize.min.js +1 -1
- package/esm/config.d.ts +4 -0
- package/esm/config.js +4 -0
- package/esm/core/constants.js +1 -1
- package/esm/core/decorators/cache/cache.d.ts +100 -0
- package/esm/core/decorators/cache/cache.js +106 -0
- package/esm/core/global.d.ts +6 -1
- package/esm/core/global.js +15 -13
- package/esm/core/helpers/utils/selector.d.ts +5 -1
- package/esm/core/helpers/utils/selector.js +3 -0
- package/esm/core/traits/dlgs.js +3 -0
- package/esm/core/view/view.js +4 -6
- package/esm/jodit.js +5 -5
- package/esm/modules/dialog/dialog.d.ts +8 -8
- package/esm/modules/dialog/dialog.js +37 -30
- package/esm/modules/file-browser/file-browser.js +2 -2
- package/esm/plugins/clipboard/clipboard.js +2 -1
- package/esm/plugins/image-processor/image-processor.js +5 -4
- package/esm/plugins/search/search.js +2 -2
- package/esm/types/view.d.ts +1 -0
- package/package.json +1 -1
- package/types/config.d.ts +4 -0
- package/types/core/decorators/cache/cache.d.ts +100 -0
- package/types/core/global.d.ts +6 -1
- package/types/core/helpers/utils/selector.d.ts +5 -1
- package/types/modules/dialog/dialog.d.ts +8 -8
- package/types/types/view.d.ts +1 -0
|
@@ -60,7 +60,14 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
60
60
|
return 'Dialog';
|
|
61
61
|
}
|
|
62
62
|
get destination() {
|
|
63
|
-
|
|
63
|
+
const { popupRoot, shadowRoot } = this.o;
|
|
64
|
+
if (popupRoot) {
|
|
65
|
+
return popupRoot;
|
|
66
|
+
}
|
|
67
|
+
if (shadowRoot) {
|
|
68
|
+
return shadowRoot;
|
|
69
|
+
}
|
|
70
|
+
return this.od.body;
|
|
64
71
|
}
|
|
65
72
|
setElements(root, elements) {
|
|
66
73
|
const elements_list = [];
|
|
@@ -89,14 +96,14 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
89
96
|
}
|
|
90
97
|
});
|
|
91
98
|
}
|
|
92
|
-
|
|
99
|
+
__onMouseUp() {
|
|
93
100
|
if (this.draggable || this.resizable) {
|
|
94
|
-
this.
|
|
101
|
+
this.__removeGlobalResizeListeners();
|
|
95
102
|
this.draggable = false;
|
|
96
103
|
this.resizable = false;
|
|
97
104
|
this.unlockSelect();
|
|
98
105
|
if (this.e) {
|
|
99
|
-
this.
|
|
106
|
+
this.__removeGlobalResizeListeners();
|
|
100
107
|
/**
|
|
101
108
|
* Fired when the dialog box is finished to resizing
|
|
102
109
|
*/
|
|
@@ -107,7 +114,7 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
107
114
|
/**
|
|
108
115
|
*
|
|
109
116
|
*/
|
|
110
|
-
|
|
117
|
+
__onHeaderMouseDown(e) {
|
|
111
118
|
const target = e.target;
|
|
112
119
|
if (!this.o.draggable ||
|
|
113
120
|
(target && target.nodeName.match(/^(INPUT|SELECT)$/))) {
|
|
@@ -123,7 +130,7 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
123
130
|
e.preventDefault();
|
|
124
131
|
}
|
|
125
132
|
this.lockSelect();
|
|
126
|
-
this.
|
|
133
|
+
this.__addGlobalResizeListeners();
|
|
127
134
|
if (this.e) {
|
|
128
135
|
/**
|
|
129
136
|
* Fired when dialog box is started moving
|
|
@@ -132,7 +139,7 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
132
139
|
this.e.fire('closeAllPopups');
|
|
133
140
|
}
|
|
134
141
|
}
|
|
135
|
-
|
|
142
|
+
__onMouseMove(e) {
|
|
136
143
|
if (this.draggable && this.o.draggable) {
|
|
137
144
|
this.setPosition(this.startPoint.x + e.clientX - this.startX, this.startPoint.y + e.clientY - this.startY);
|
|
138
145
|
if (this.e) {
|
|
@@ -153,7 +160,7 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
153
160
|
}
|
|
154
161
|
}
|
|
155
162
|
}
|
|
156
|
-
|
|
163
|
+
__onEsc(e) {
|
|
157
164
|
if (!this.o.closeOnEsc) {
|
|
158
165
|
return;
|
|
159
166
|
}
|
|
@@ -170,14 +177,14 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
170
177
|
e.stopImmediatePropagation();
|
|
171
178
|
}
|
|
172
179
|
}
|
|
173
|
-
|
|
180
|
+
__onResizerMouseDown(e) {
|
|
174
181
|
this.resizable = true;
|
|
175
182
|
this.startX = e.clientX;
|
|
176
183
|
this.startY = e.clientY;
|
|
177
184
|
this.startPoint.w = this.dialog.offsetWidth;
|
|
178
185
|
this.startPoint.h = this.dialog.offsetHeight;
|
|
179
186
|
this.lockSelect();
|
|
180
|
-
this.
|
|
187
|
+
this.__addGlobalResizeListeners();
|
|
181
188
|
if (this.e) {
|
|
182
189
|
/**
|
|
183
190
|
* Fired when dialog box is started resizing
|
|
@@ -185,17 +192,17 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
185
192
|
this.e.fire(this, 'startResize');
|
|
186
193
|
}
|
|
187
194
|
}
|
|
188
|
-
|
|
195
|
+
__addGlobalResizeListeners() {
|
|
189
196
|
const self = this;
|
|
190
197
|
self.e
|
|
191
|
-
.on(self.ow, 'pointermove touchmove', self.
|
|
192
|
-
.on(self.ow, 'pointerup touchend', self.
|
|
198
|
+
.on(self.ow, 'pointermove touchmove', self.__onMouseMove)
|
|
199
|
+
.on(self.ow, 'pointerup touchend', self.__onMouseUp);
|
|
193
200
|
}
|
|
194
|
-
|
|
201
|
+
__removeGlobalResizeListeners() {
|
|
195
202
|
const self = this;
|
|
196
203
|
self.e
|
|
197
|
-
.off(self.ow, 'mousemove pointermove', self.
|
|
198
|
-
.off(self.ow, 'mouseup pointerup', self.
|
|
204
|
+
.off(self.ow, 'mousemove pointermove', self.__onMouseMove)
|
|
205
|
+
.off(self.ow, 'mouseup pointerup', self.__onMouseUp);
|
|
199
206
|
}
|
|
200
207
|
/**
|
|
201
208
|
* Specifies the size of the window
|
|
@@ -451,7 +458,7 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
451
458
|
this.toggleFullSize(false);
|
|
452
459
|
}
|
|
453
460
|
Dom.safeRemove(this.container);
|
|
454
|
-
this.
|
|
461
|
+
this.__removeGlobalResizeListeners();
|
|
455
462
|
/**
|
|
456
463
|
* It called after the window is closed
|
|
457
464
|
*/
|
|
@@ -477,7 +484,7 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
477
484
|
this.unlockSelect = () => {
|
|
478
485
|
this.setMod('moved', false);
|
|
479
486
|
};
|
|
480
|
-
this.
|
|
487
|
+
this.__onResize = () => {
|
|
481
488
|
if (this.options &&
|
|
482
489
|
this.o.resizable &&
|
|
483
490
|
!this.moved &&
|
|
@@ -545,14 +552,14 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
545
552
|
});
|
|
546
553
|
const headerBox = self.getElm('header');
|
|
547
554
|
headerBox &&
|
|
548
|
-
self.e.on(headerBox, 'pointerdown touchstart', self.
|
|
549
|
-
self.e.on(self.resizer, 'mousedown touchstart', self.
|
|
555
|
+
self.e.on(headerBox, 'pointerdown touchstart', self.__onHeaderMouseDown);
|
|
556
|
+
self.e.on(self.resizer, 'mousedown touchstart', self.__onResizerMouseDown);
|
|
550
557
|
const fullSize = pluginSystem.get('fullsize');
|
|
551
558
|
isFunction(fullSize) && fullSize(self);
|
|
552
559
|
this.e
|
|
553
560
|
.on(self.container, 'close_dialog', self.close)
|
|
554
|
-
.on(this.ow, 'keydown', this.
|
|
555
|
-
.on(this.ow, 'resize', this.
|
|
561
|
+
.on(this.ow, 'keydown', this.__onEsc)
|
|
562
|
+
.on(this.ow, 'resize', this.__onResize);
|
|
556
563
|
if (this.o.closeOnClickOverlay) {
|
|
557
564
|
const overlay = self.getElm('overlay');
|
|
558
565
|
assert(overlay != null, 'Overlay element does not exist');
|
|
@@ -581,30 +588,30 @@ let Dialog = Dialog_1 = class Dialog extends ViewWithToolbar {
|
|
|
581
588
|
this.close();
|
|
582
589
|
}
|
|
583
590
|
if (this.events) {
|
|
584
|
-
this.
|
|
591
|
+
this.__removeGlobalResizeListeners();
|
|
585
592
|
this.events
|
|
586
593
|
.off(this.container, 'close_dialog', self.close)
|
|
587
|
-
.off(this.ow, 'keydown', this.
|
|
588
|
-
.off(this.ow, 'resize', this.
|
|
594
|
+
.off(this.ow, 'keydown', this.__onEsc)
|
|
595
|
+
.off(this.ow, 'resize', this.__onResize);
|
|
589
596
|
}
|
|
590
597
|
super.destruct();
|
|
591
598
|
}
|
|
592
599
|
};
|
|
593
600
|
__decorate([
|
|
594
601
|
autobind
|
|
595
|
-
], Dialog.prototype, "
|
|
602
|
+
], Dialog.prototype, "__onMouseUp", null);
|
|
596
603
|
__decorate([
|
|
597
604
|
autobind
|
|
598
|
-
], Dialog.prototype, "
|
|
605
|
+
], Dialog.prototype, "__onHeaderMouseDown", null);
|
|
599
606
|
__decorate([
|
|
600
607
|
autobind
|
|
601
|
-
], Dialog.prototype, "
|
|
608
|
+
], Dialog.prototype, "__onMouseMove", null);
|
|
602
609
|
__decorate([
|
|
603
610
|
autobind
|
|
604
|
-
], Dialog.prototype, "
|
|
611
|
+
], Dialog.prototype, "__onEsc", null);
|
|
605
612
|
__decorate([
|
|
606
613
|
autobind
|
|
607
|
-
], Dialog.prototype, "
|
|
614
|
+
], Dialog.prototype, "__onResizerMouseDown", null);
|
|
608
615
|
__decorate([
|
|
609
616
|
autobind
|
|
610
617
|
], Dialog.prototype, "close", null);
|
|
@@ -16,7 +16,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
16
16
|
import { STATUSES } from "../../core/component/index.js";
|
|
17
17
|
import * as consts from "../../core/constants.js";
|
|
18
18
|
import { IS_PROD } from "../../core/constants.js";
|
|
19
|
-
import { autobind, cache, derive } from "../../core/decorators/index.js";
|
|
19
|
+
import { autobind, cache, cached, derive } from "../../core/decorators/index.js";
|
|
20
20
|
import { watch } from "../../core/decorators/watch/watch.js";
|
|
21
21
|
import { observable } from "../../core/event-emitter/index.js";
|
|
22
22
|
import { ConfigProto, error, isAbortError, isFunction, isString, trim } from "../../core/helpers/index.js";
|
|
@@ -307,8 +307,8 @@ let FileBrowser = class FileBrowser extends ViewWithToolbar {
|
|
|
307
307
|
if (this.isInDestruct) {
|
|
308
308
|
return;
|
|
309
309
|
}
|
|
310
|
+
cached(this, '_dialog')?.destruct();
|
|
310
311
|
super.destruct();
|
|
311
|
-
this._dialog.destruct();
|
|
312
312
|
this.events && this.e.off('.filebrowser');
|
|
313
313
|
this.uploader && this.uploader.destruct();
|
|
314
314
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Copyright (c) 2013-2025 Valeriy Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
5
|
*/
|
|
6
6
|
import { CLIPBOARD_ID, INSERT_AS_HTML, TEXT_HTML, TEXT_PLAIN } from "../../core/constants.js";
|
|
7
|
+
import { cached } from "../../core/decorators/cache/cache.js";
|
|
7
8
|
import { pluginSystem } from "../../core/global.js";
|
|
8
9
|
import { getDataTransfer, stripTags } from "../../core/helpers/index.js";
|
|
9
10
|
import "./config.js";
|
|
@@ -61,7 +62,7 @@ export class clipboard {
|
|
|
61
62
|
}
|
|
62
63
|
/** @override */
|
|
63
64
|
destruct(editor) {
|
|
64
|
-
editor
|
|
65
|
+
cached(editor, 'buffer')?.set(CLIPBOARD_ID, '');
|
|
65
66
|
editor?.events?.off('.' + CLIPBOARD_ID);
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -14,7 +14,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
14
14
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
15
|
};
|
|
16
16
|
import { SOURCE_CONSUMER } from "../../core/constants.js";
|
|
17
|
-
import { debounce, watch } from "../../core/decorators/index.js";
|
|
17
|
+
import { cached, debounce, watch } from "../../core/decorators/index.js";
|
|
18
18
|
import { pluginSystem } from "../../core/global.js";
|
|
19
19
|
import { $$, dataBind } from "../../core/helpers/index.js";
|
|
20
20
|
import { Plugin } from "../../core/plugin/index.js";
|
|
@@ -27,13 +27,14 @@ const JODIT_IMAGE_BLOB_ID = JODIT_IMAGE_PROCESSOR_BINDED + 'blob-id';
|
|
|
27
27
|
export class imageProcessor extends Plugin {
|
|
28
28
|
afterInit(jodit) { }
|
|
29
29
|
beforeDestruct(jodit) {
|
|
30
|
-
const
|
|
31
|
-
|
|
30
|
+
const buffer = cached(jodit, 'buffer');
|
|
31
|
+
const list = buffer?.get(JODIT_IMAGE_BLOB_ID);
|
|
32
|
+
if (buffer && list) {
|
|
32
33
|
const keys = Object.keys(list);
|
|
33
34
|
for (const uri of keys) {
|
|
34
35
|
URL.revokeObjectURL(uri);
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
buffer.delete(JODIT_IMAGE_BLOB_ID);
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
onAfterGetValueFromEditor(data, consumer) {
|
|
@@ -14,7 +14,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
14
14
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
15
15
|
};
|
|
16
16
|
import { IS_PROD } from "../../core/constants.js";
|
|
17
|
-
import { autobind, cache, watch } from "../../core/decorators/index.js";
|
|
17
|
+
import { autobind, cache, cached, watch } from "../../core/decorators/index.js";
|
|
18
18
|
import { Dom, LazyWalker } from "../../core/dom/index.js";
|
|
19
19
|
import { pluginSystem } from "../../core/global.js";
|
|
20
20
|
import { scrollIntoViewIfNeeded } from "../../core/helpers/index.js";
|
|
@@ -319,7 +319,7 @@ export class search extends Plugin {
|
|
|
319
319
|
}
|
|
320
320
|
/** @override */
|
|
321
321
|
beforeDestruct(jodit) {
|
|
322
|
-
this
|
|
322
|
+
cached(this, 'ui')?.destruct();
|
|
323
323
|
jodit.e.off('.search');
|
|
324
324
|
}
|
|
325
325
|
}
|
package/esm/types/view.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ interface IViewOptions extends ILanguageOptions, IToolbarOptions {
|
|
|
59
59
|
createAttributes?: IDictionary<Attributes | NodeFunction>;
|
|
60
60
|
events?: IDictionary<(...args: any[]) => any>;
|
|
61
61
|
shadowRoot?: Nullable<ShadowRoot>;
|
|
62
|
+
popupRoot?: Nullable<HTMLElement>;
|
|
62
63
|
ownerWindow?: Window;
|
|
63
64
|
language?: string;
|
|
64
65
|
}
|
package/package.json
CHANGED
package/types/config.d.ts
CHANGED
|
@@ -686,6 +686,10 @@ declare class Config implements IViewOptions {
|
|
|
686
686
|
* Buttons in toolbat without SVG - only texts
|
|
687
687
|
*/
|
|
688
688
|
textIcons: boolean;
|
|
689
|
+
/**
|
|
690
|
+
* Element for dialog container
|
|
691
|
+
*/
|
|
692
|
+
popupRoot: Nullable<HTMLElement>;
|
|
689
693
|
/**
|
|
690
694
|
* shows a INPUT[type=color] to open the browser color picker, on the right bottom of widget color picker
|
|
691
695
|
*/
|
|
@@ -12,6 +12,106 @@ import type { IDictionary, Nullable } from "../../../types";
|
|
|
12
12
|
export interface CachePropertyDescriptor<T, R> extends PropertyDescriptor {
|
|
13
13
|
get?: (this: T) => R;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves a cached property value from an object if it exists; otherwise, returns `null`.
|
|
17
|
+
*
|
|
18
|
+
* This utility is particularly useful when working with properties that are lazily initialized
|
|
19
|
+
* or dynamically created, such as getters or cached computations. It ensures you can safely
|
|
20
|
+
* access the value without triggering initialization or creating a new instance.
|
|
21
|
+
*
|
|
22
|
+
* ### Usage Example:
|
|
23
|
+
* ```typescript
|
|
24
|
+
* import type { IUIElement } from "jodit";
|
|
25
|
+
*
|
|
26
|
+
* const { component, cache, cached } = Jodit.decorators;
|
|
27
|
+
* const { UIElement } = Jodit.modules;
|
|
28
|
+
*
|
|
29
|
+
* @component
|
|
30
|
+
* class SomeComponent extends UIElement {
|
|
31
|
+
* @cache
|
|
32
|
+
* get someElement(): IUIElement {
|
|
33
|
+
* return new UIElement(this.jodit);
|
|
34
|
+
* }
|
|
35
|
+
*
|
|
36
|
+
* destruct() {
|
|
37
|
+
* // Use the cached utility to clean up only if the property is initialized
|
|
38
|
+
* cached(this, 'someElement')?.destruct();
|
|
39
|
+
* super.destruct();
|
|
40
|
+
* }
|
|
41
|
+
* }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param object - The object containing the property to check.
|
|
45
|
+
* @param property - The name of the property to retrieve from the cache.
|
|
46
|
+
* @returns The cached value of the property if it exists; otherwise, `null`.
|
|
47
|
+
*
|
|
48
|
+
* ### Notes:
|
|
49
|
+
* - If the property is defined as a getter, the function will return `null`
|
|
50
|
+
* instead of invoking the getter.
|
|
51
|
+
* - This function is non-destructive and does not alter the object's state.
|
|
52
|
+
*/
|
|
15
53
|
export declare function cached<T>(object: object, property: string): Nullable<T>;
|
|
54
|
+
/**
|
|
55
|
+
* A decorator that caches the result of a getter method. Once the getter is accessed for the first time,
|
|
56
|
+
* its computed value is stored as a property of the object. Subsequent accesses return the cached value
|
|
57
|
+
* without recalculating it, improving performance and avoiding redundant computations.
|
|
58
|
+
*
|
|
59
|
+
* ### Key Features:
|
|
60
|
+
* - **Lazy Initialization**: The original getter is invoked only once, the first time the property is accessed.
|
|
61
|
+
* - **Immutability**: After caching, the value is stored as a non-writable, non-configurable property, preventing accidental modifications.
|
|
62
|
+
* - **Conditional Caching**: If the returned value has a property `noCache` set to `true`, the caching mechanism is bypassed, and the getter is invoked each time.
|
|
63
|
+
*
|
|
64
|
+
* ### Usage Example 1: Basic Caching
|
|
65
|
+
* ```typescript
|
|
66
|
+
* import { cache } from './decorators';
|
|
67
|
+
*
|
|
68
|
+
* class Example {
|
|
69
|
+
* private counter = 0;
|
|
70
|
+
*
|
|
71
|
+
* @cache
|
|
72
|
+
* get expensiveComputation(): number {
|
|
73
|
+
* console.log('Calculating...');
|
|
74
|
+
* return ++this.counter;
|
|
75
|
+
* }
|
|
76
|
+
* }
|
|
77
|
+
*
|
|
78
|
+
* const instance = new Example();
|
|
79
|
+
* console.log(instance.expensiveComputation); // Logs "Calculating..." and returns 1
|
|
80
|
+
* console.log(instance.expensiveComputation); // Returns 1 (cached value, no calculation)
|
|
81
|
+
* ```
|
|
82
|
+
*
|
|
83
|
+
* ### Usage Example 2: Integration with Cached Utilities
|
|
84
|
+
* ```typescript
|
|
85
|
+
* import { cache, cached } from './decorators';
|
|
86
|
+
* import type { IUIElement } from "jodit";
|
|
87
|
+
*
|
|
88
|
+
* const { component } = Jodit.decorators;
|
|
89
|
+
* const { UIElement } = Jodit.modules;
|
|
90
|
+
*
|
|
91
|
+
* @component
|
|
92
|
+
* class SomeComponent extends UIElement {
|
|
93
|
+
* @cache
|
|
94
|
+
* get someElement(): IUIElement {
|
|
95
|
+
* return new UIElement(this.jodit);
|
|
96
|
+
* }
|
|
97
|
+
*
|
|
98
|
+
* destruct() {
|
|
99
|
+
* // Use the cached utility to clean up only if the property is initialized
|
|
100
|
+
* cached(this, 'someElement')?.destruct();
|
|
101
|
+
* super.destruct();
|
|
102
|
+
* }
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*
|
|
106
|
+
* @param _ - The target object (not used directly).
|
|
107
|
+
* @param name - The name of the property to decorate.
|
|
108
|
+
* @param descriptor - The property descriptor, which must include a getter method.
|
|
109
|
+
* @throws Will throw an error if the descriptor does not include a getter.
|
|
110
|
+
*
|
|
111
|
+
* ### Notes:
|
|
112
|
+
* - **Performance**: Ideal for properties that are computationally expensive and do not change after the initial computation.
|
|
113
|
+
* - **Flexibility**: Supports conditional caching via the `noCache` property in the returned value.
|
|
114
|
+
* - **Compatibility**: Designed to work seamlessly with objects and classes in TypeScript or JavaScript.
|
|
115
|
+
*/
|
|
16
116
|
export declare function cache<T, R>(_: object, name: PropertyKey, descriptor: CachePropertyDescriptor<T, R>): void;
|
|
17
117
|
export declare function cacheHTML<T extends Function, R>(target: IDictionary, _: string, descriptor: CachePropertyDescriptor<T, R>): void;
|
package/types/core/global.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
/**
|
|
7
7
|
* @module global
|
|
8
8
|
*/
|
|
9
|
-
import type { HTMLTagNames, IDictionary, IJodit, IViewBased, IViewComponent } from "../types";
|
|
9
|
+
import type { HTMLTagNames, IDictionary, IJodit, IViewBased, IViewComponent, IViewOptions } from "../types";
|
|
10
10
|
import { PluginSystem } from "./plugin/plugin-system";
|
|
11
11
|
import { EventEmitter } from "./event-emitter";
|
|
12
12
|
export declare const instances: IDictionary<IJodit>;
|
|
@@ -21,6 +21,11 @@ export declare const extendLang: (langs: IDictionary) => void;
|
|
|
21
21
|
* Create unique box(HTMLCotainer) and remove it after destroy
|
|
22
22
|
*/
|
|
23
23
|
export declare function getContainer<T extends HTMLTagNames = HTMLTagNames>(jodit: IViewBased | IViewComponent, classFunc?: Function | string, tag?: T, createInsideEditor?: boolean): HTMLElementTagNameMap[T];
|
|
24
|
+
/**
|
|
25
|
+
* Get root element for view
|
|
26
|
+
* @internal
|
|
27
|
+
*/
|
|
28
|
+
export declare function getPopupViewRoot(o: IViewOptions, container: HTMLElement, defaultRoot: HTMLElement): HTMLElement;
|
|
24
29
|
/**
|
|
25
30
|
* Global event emitter
|
|
26
31
|
*/
|
|
@@ -15,14 +15,18 @@ import type { HTMLTagNames, IDictionary, Nullable } from "../../../types";
|
|
|
15
15
|
* ```javascript
|
|
16
16
|
* Jodit.modules.Helpers.$$('.someselector').forEach(function (elm) {
|
|
17
17
|
* elm.addEventListener('click', function () {
|
|
18
|
-
* alert('
|
|
18
|
+
* alert('Clicked');
|
|
19
19
|
* });
|
|
20
20
|
* })
|
|
21
21
|
* ```
|
|
22
22
|
* @param selector - CSS like selector
|
|
23
23
|
* @param root - where to search
|
|
24
|
+
* @deprecated Do not use it in new code
|
|
24
25
|
*/
|
|
25
26
|
export declare function $$<K extends HTMLTagNames>(selector: K, root: HTMLElement | DocumentFragment): Array<HTMLElementTagNameMap[K]>;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Do not use it in new code
|
|
29
|
+
*/
|
|
26
30
|
export declare function $$<T extends HTMLElement>(selector: string, root: HTMLElement | DocumentFragment): T[];
|
|
27
31
|
/**
|
|
28
32
|
* Calculate XPath selector
|
|
@@ -35,17 +35,17 @@ export declare class Dialog extends ViewWithToolbar implements IDialog {
|
|
|
35
35
|
private lockSelect;
|
|
36
36
|
private unlockSelect;
|
|
37
37
|
private setElements;
|
|
38
|
-
private
|
|
38
|
+
private __onMouseUp;
|
|
39
39
|
/**
|
|
40
40
|
*
|
|
41
41
|
*/
|
|
42
|
-
private
|
|
43
|
-
private
|
|
44
|
-
private
|
|
45
|
-
private
|
|
46
|
-
private
|
|
47
|
-
private
|
|
48
|
-
private
|
|
42
|
+
private __onHeaderMouseDown;
|
|
43
|
+
private __onMouseMove;
|
|
44
|
+
private __onEsc;
|
|
45
|
+
private __onResize;
|
|
46
|
+
private __onResizerMouseDown;
|
|
47
|
+
private __addGlobalResizeListeners;
|
|
48
|
+
private __removeGlobalResizeListeners;
|
|
49
49
|
OPTIONS: IDialogOptions;
|
|
50
50
|
readonly dialog: HTMLElement;
|
|
51
51
|
workplace: HTMLDivElement;
|
package/types/types/view.d.ts
CHANGED
|
@@ -59,6 +59,7 @@ interface IViewOptions extends ILanguageOptions, IToolbarOptions {
|
|
|
59
59
|
createAttributes?: IDictionary<Attributes | NodeFunction>;
|
|
60
60
|
events?: IDictionary<(...args: any[]) => any>;
|
|
61
61
|
shadowRoot?: Nullable<ShadowRoot>;
|
|
62
|
+
popupRoot?: Nullable<HTMLElement>;
|
|
62
63
|
ownerWindow?: Window;
|
|
63
64
|
language?: string;
|
|
64
65
|
}
|