tiny-essentials 1.21.8 → 1.21.9
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/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/UltraRandomMsgGen.min.js +1 -1
- package/dist/v1/libs/TinyDragger.cjs +1 -1
- package/dist/v1/libs/TinyDragger.d.mts +2 -2
- package/dist/v1/libs/TinyDragger.mjs +1 -1
- package/dist/v1/libs/TinyGamepad.d.mts +1 -1
- package/dist/v1/libs/TinyHtml.cjs +235 -170
- package/dist/v1/libs/TinyHtml.d.mts +364 -339
- package/dist/v1/libs/TinyHtml.mjs +234 -170
- package/dist/v1/libs/TinyInventory.d.mts +1 -1
- package/dist/v1/libs/TinyTextRangeEditor.cjs +18 -18
- package/dist/v1/libs/TinyTextRangeEditor.d.mts +36 -36
- package/dist/v1/libs/TinyTextRangeEditor.mjs +18 -18
- package/dist/v1/libs/UltraRandomMsgGen.cjs +103 -31
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +74 -44
- package/dist/v1/libs/UltraRandomMsgGen.mjs +98 -31
- package/package.json +1 -1
|
@@ -328,7 +328,7 @@ declare class TinyInventory {
|
|
|
328
328
|
* Keys are item IDs, values are configuration objects created with {@link TinyInventory.defineItem}.
|
|
329
329
|
* @type {Map<string, ItemDef>}
|
|
330
330
|
*/
|
|
331
|
-
static "__#
|
|
331
|
+
static "__#27@#ItemRegistry": Map<string, ItemDef>;
|
|
332
332
|
/**
|
|
333
333
|
* Returns a deep-cloned snapshot of all registered items.
|
|
334
334
|
* Ensures the caller cannot mutate the internal registry.
|
|
@@ -54,7 +54,7 @@ class TinyTextRangeEditor {
|
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* Ensures the element has focus.
|
|
57
|
-
* @returns {
|
|
57
|
+
* @returns {this}
|
|
58
58
|
*/
|
|
59
59
|
ensureFocus() {
|
|
60
60
|
if (document.activeElement !== this.#el) this.#el.focus();
|
|
@@ -63,7 +63,7 @@ class TinyTextRangeEditor {
|
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Focus the element.
|
|
66
|
-
* @returns {
|
|
66
|
+
* @returns {this}
|
|
67
67
|
*/
|
|
68
68
|
focus() {
|
|
69
69
|
this.#el.focus();
|
|
@@ -83,7 +83,7 @@ class TinyTextRangeEditor {
|
|
|
83
83
|
* @param {number} start - Start index.
|
|
84
84
|
* @param {number} end - End index.
|
|
85
85
|
* @param {boolean} [preserveScroll=true] - Whether to preserve scroll position.
|
|
86
|
-
* @returns {
|
|
86
|
+
* @returns {this}
|
|
87
87
|
*/
|
|
88
88
|
setSelectionRange(start, end, preserveScroll = true) {
|
|
89
89
|
if (typeof start !== 'number' || typeof end !== 'number')
|
|
@@ -108,7 +108,7 @@ class TinyTextRangeEditor {
|
|
|
108
108
|
/**
|
|
109
109
|
* Sets the full value of the element.
|
|
110
110
|
* @param {string} value - The new value to assign.
|
|
111
|
-
* @returns {
|
|
111
|
+
* @returns {this}
|
|
112
112
|
*/
|
|
113
113
|
setValue(value) {
|
|
114
114
|
if (typeof value !== 'string') throw new TypeError('Value must be a string.');
|
|
@@ -130,7 +130,7 @@ class TinyTextRangeEditor {
|
|
|
130
130
|
* @param {boolean} [settings.autoSpacing=false]
|
|
131
131
|
* @param {boolean} [settings.autoSpaceLeft=false]
|
|
132
132
|
* @param {boolean} [settings.autoSpaceRight=false]
|
|
133
|
-
* @returns {
|
|
133
|
+
* @returns {this}
|
|
134
134
|
*/
|
|
135
135
|
insertText(
|
|
136
136
|
text,
|
|
@@ -173,7 +173,7 @@ class TinyTextRangeEditor {
|
|
|
173
173
|
|
|
174
174
|
/**
|
|
175
175
|
* Deletes the currently selected text.
|
|
176
|
-
* @returns {
|
|
176
|
+
* @returns {this}
|
|
177
177
|
*/
|
|
178
178
|
deleteSelection() {
|
|
179
179
|
this.insertText('');
|
|
@@ -183,7 +183,7 @@ class TinyTextRangeEditor {
|
|
|
183
183
|
/**
|
|
184
184
|
* Replaces the selection using a transformation function.
|
|
185
185
|
* @param {(selected: string) => string} transformer - Function that modifies the selected text.
|
|
186
|
-
* @returns {
|
|
186
|
+
* @returns {this}
|
|
187
187
|
*/
|
|
188
188
|
transformSelection(transformer) {
|
|
189
189
|
if (typeof transformer !== 'function') throw new TypeError('transformer must be a function.');
|
|
@@ -199,7 +199,7 @@ class TinyTextRangeEditor {
|
|
|
199
199
|
* Surrounds current selection with prefix and suffix.
|
|
200
200
|
* @param {string} prefix - Text to insert before.
|
|
201
201
|
* @param {string} suffix - Text to insert after.
|
|
202
|
-
* @returns {
|
|
202
|
+
* @returns {this}
|
|
203
203
|
*/
|
|
204
204
|
surroundSelection(prefix, suffix) {
|
|
205
205
|
if (typeof prefix !== 'string' || typeof suffix !== 'string')
|
|
@@ -212,7 +212,7 @@ class TinyTextRangeEditor {
|
|
|
212
212
|
/**
|
|
213
213
|
* Moves the caret by a given offset.
|
|
214
214
|
* @param {number} offset - Characters to move.
|
|
215
|
-
* @returns {
|
|
215
|
+
* @returns {this}
|
|
216
216
|
*/
|
|
217
217
|
moveCaret(offset) {
|
|
218
218
|
if (typeof offset !== 'number') throw new TypeError('offset must be a number.');
|
|
@@ -224,7 +224,7 @@ class TinyTextRangeEditor {
|
|
|
224
224
|
|
|
225
225
|
/**
|
|
226
226
|
* Selects all content in the field.
|
|
227
|
-
* @returns {
|
|
227
|
+
* @returns {this}
|
|
228
228
|
*/
|
|
229
229
|
selectAll() {
|
|
230
230
|
this.setSelectionRange(0, this.#el.value.length);
|
|
@@ -235,7 +235,7 @@ class TinyTextRangeEditor {
|
|
|
235
235
|
* Expands the current selection by character amounts.
|
|
236
236
|
* @param {number} before - Characters to expand to the left.
|
|
237
237
|
* @param {number} after - Characters to expand to the right.
|
|
238
|
-
* @returns {
|
|
238
|
+
* @returns {this}
|
|
239
239
|
*/
|
|
240
240
|
expandSelection(before, after) {
|
|
241
241
|
if (typeof before !== 'number' || typeof after !== 'number')
|
|
@@ -251,7 +251,7 @@ class TinyTextRangeEditor {
|
|
|
251
251
|
* Replaces all regex matches in the content.
|
|
252
252
|
* @param {RegExp} regex - Regex to match.
|
|
253
253
|
* @param {(match: string) => string} replacer - Replacement function.
|
|
254
|
-
* @returns {
|
|
254
|
+
* @returns {this}
|
|
255
255
|
*/
|
|
256
256
|
replaceAll(regex, replacer) {
|
|
257
257
|
if (!(regex instanceof RegExp)) throw new TypeError('regex must be a RegExp.');
|
|
@@ -266,7 +266,7 @@ class TinyTextRangeEditor {
|
|
|
266
266
|
*
|
|
267
267
|
* @param {RegExp} regex - Regular expression to match inside selection.
|
|
268
268
|
* @param {(match: string) => string} replacer - Function to replace each match.
|
|
269
|
-
* @returns {
|
|
269
|
+
* @returns {this}
|
|
270
270
|
*/
|
|
271
271
|
replaceInSelection(regex, replacer) {
|
|
272
272
|
if (!(regex instanceof RegExp)) throw new TypeError('regex must be a RegExp.');
|
|
@@ -289,7 +289,7 @@ class TinyTextRangeEditor {
|
|
|
289
289
|
* Toggles a code around the current selection.
|
|
290
290
|
* If it's already wrapped, unwraps it.
|
|
291
291
|
* @param {string} codeName - The code to toggle.
|
|
292
|
-
* @returns {
|
|
292
|
+
* @returns {this}
|
|
293
293
|
*/
|
|
294
294
|
toggleCode(codeName) {
|
|
295
295
|
if (typeof codeName !== 'string') throw new TypeError('codeName must be a string.');
|
|
@@ -367,7 +367,7 @@ class TinyTextRangeEditor {
|
|
|
367
367
|
* - If an object: key-value pairs (e.g., `{ color: "red" }` → `color="red"`).
|
|
368
368
|
* - If an array: boolean attributes (e.g., `["disabled", "readonly"]`).
|
|
369
369
|
*
|
|
370
|
-
* @returns {
|
|
370
|
+
* @returns {this}
|
|
371
371
|
*/
|
|
372
372
|
wrapWithTag(tagName, attributes = {}) {
|
|
373
373
|
if (typeof tagName !== 'string') throw new TypeError('tagName must be a string.');
|
|
@@ -385,7 +385,7 @@ class TinyTextRangeEditor {
|
|
|
385
385
|
* @param {string} tagName - The tag to insert.
|
|
386
386
|
* @param {string} [content=''] - Optional content between tags.
|
|
387
387
|
* @param {Record<string,string> | string[]} [attributes={}] - Optional attributes or list of empty attributes.
|
|
388
|
-
* @returns {
|
|
388
|
+
* @returns {this}
|
|
389
389
|
*/
|
|
390
390
|
insertTag(tagName, content = '', attributes = {}) {
|
|
391
391
|
if (typeof tagName !== 'string') throw new TypeError('tagName must be a string.');
|
|
@@ -405,7 +405,7 @@ class TinyTextRangeEditor {
|
|
|
405
405
|
* Inserts a self-closing tag.
|
|
406
406
|
* @param {string} tagName - The tag name.
|
|
407
407
|
* @param {Record<string,string> | string[]} [attributes={}] - Optional attributes or list of empty attributes.
|
|
408
|
-
* @returns {
|
|
408
|
+
* @returns {this}
|
|
409
409
|
*/
|
|
410
410
|
insertSelfClosingTag(tagName, attributes = {}) {
|
|
411
411
|
if (typeof tagName !== 'string') throw new TypeError('tagName must be a string.');
|
|
@@ -424,7 +424,7 @@ class TinyTextRangeEditor {
|
|
|
424
424
|
* Supports tags with attributes. If already wrapped, it unwraps.
|
|
425
425
|
* @param {string} tagName - The tag to toggle.
|
|
426
426
|
* @param {Record<string,string> | string[]} [attributes={}] - Optional attributes to apply when wrapping.
|
|
427
|
-
* @returns {
|
|
427
|
+
* @returns {this}
|
|
428
428
|
*/
|
|
429
429
|
toggleTag(tagName, attributes = {}) {
|
|
430
430
|
if (typeof tagName !== 'string') throw new TypeError('tagName must be a string.');
|
|
@@ -24,14 +24,14 @@ declare class TinyTextRangeEditor {
|
|
|
24
24
|
setCloseTag(tag: string): void;
|
|
25
25
|
/**
|
|
26
26
|
* Ensures the element has focus.
|
|
27
|
-
* @returns {
|
|
27
|
+
* @returns {this}
|
|
28
28
|
*/
|
|
29
|
-
ensureFocus():
|
|
29
|
+
ensureFocus(): this;
|
|
30
30
|
/**
|
|
31
31
|
* Focus the element.
|
|
32
|
-
* @returns {
|
|
32
|
+
* @returns {this}
|
|
33
33
|
*/
|
|
34
|
-
focus():
|
|
34
|
+
focus(): this;
|
|
35
35
|
/** @returns {{ start: number, end: number }} The current selection range. */
|
|
36
36
|
getSelectionRange(): {
|
|
37
37
|
start: number;
|
|
@@ -42,17 +42,17 @@ declare class TinyTextRangeEditor {
|
|
|
42
42
|
* @param {number} start - Start index.
|
|
43
43
|
* @param {number} end - End index.
|
|
44
44
|
* @param {boolean} [preserveScroll=true] - Whether to preserve scroll position.
|
|
45
|
-
* @returns {
|
|
45
|
+
* @returns {this}
|
|
46
46
|
*/
|
|
47
|
-
setSelectionRange(start: number, end: number, preserveScroll?: boolean):
|
|
47
|
+
setSelectionRange(start: number, end: number, preserveScroll?: boolean): this;
|
|
48
48
|
/** @returns {string} The full current text value. */
|
|
49
49
|
getValue(): string;
|
|
50
50
|
/**
|
|
51
51
|
* Sets the full value of the element.
|
|
52
52
|
* @param {string} value - The new value to assign.
|
|
53
|
-
* @returns {
|
|
53
|
+
* @returns {this}
|
|
54
54
|
*/
|
|
55
|
-
setValue(value: string):
|
|
55
|
+
setValue(value: string): this;
|
|
56
56
|
/** @returns {string} The currently selected text. */
|
|
57
57
|
getSelectedText(): string;
|
|
58
58
|
/**
|
|
@@ -63,72 +63,72 @@ declare class TinyTextRangeEditor {
|
|
|
63
63
|
* @param {boolean} [settings.autoSpacing=false]
|
|
64
64
|
* @param {boolean} [settings.autoSpaceLeft=false]
|
|
65
65
|
* @param {boolean} [settings.autoSpaceRight=false]
|
|
66
|
-
* @returns {
|
|
66
|
+
* @returns {this}
|
|
67
67
|
*/
|
|
68
68
|
insertText(text: string, { newCursor, autoSpacing, autoSpaceLeft, autoSpaceRight, }?: {
|
|
69
69
|
newCursor?: "end" | "start" | "preserve" | undefined;
|
|
70
70
|
autoSpacing?: boolean | undefined;
|
|
71
71
|
autoSpaceLeft?: boolean | undefined;
|
|
72
72
|
autoSpaceRight?: boolean | undefined;
|
|
73
|
-
}):
|
|
73
|
+
}): this;
|
|
74
74
|
/**
|
|
75
75
|
* Deletes the currently selected text.
|
|
76
|
-
* @returns {
|
|
76
|
+
* @returns {this}
|
|
77
77
|
*/
|
|
78
|
-
deleteSelection():
|
|
78
|
+
deleteSelection(): this;
|
|
79
79
|
/**
|
|
80
80
|
* Replaces the selection using a transformation function.
|
|
81
81
|
* @param {(selected: string) => string} transformer - Function that modifies the selected text.
|
|
82
|
-
* @returns {
|
|
82
|
+
* @returns {this}
|
|
83
83
|
*/
|
|
84
|
-
transformSelection(transformer: (selected: string) => string):
|
|
84
|
+
transformSelection(transformer: (selected: string) => string): this;
|
|
85
85
|
/**
|
|
86
86
|
* Surrounds current selection with prefix and suffix.
|
|
87
87
|
* @param {string} prefix - Text to insert before.
|
|
88
88
|
* @param {string} suffix - Text to insert after.
|
|
89
|
-
* @returns {
|
|
89
|
+
* @returns {this}
|
|
90
90
|
*/
|
|
91
|
-
surroundSelection(prefix: string, suffix: string):
|
|
91
|
+
surroundSelection(prefix: string, suffix: string): this;
|
|
92
92
|
/**
|
|
93
93
|
* Moves the caret by a given offset.
|
|
94
94
|
* @param {number} offset - Characters to move.
|
|
95
|
-
* @returns {
|
|
95
|
+
* @returns {this}
|
|
96
96
|
*/
|
|
97
|
-
moveCaret(offset: number):
|
|
97
|
+
moveCaret(offset: number): this;
|
|
98
98
|
/**
|
|
99
99
|
* Selects all content in the field.
|
|
100
|
-
* @returns {
|
|
100
|
+
* @returns {this}
|
|
101
101
|
*/
|
|
102
|
-
selectAll():
|
|
102
|
+
selectAll(): this;
|
|
103
103
|
/**
|
|
104
104
|
* Expands the current selection by character amounts.
|
|
105
105
|
* @param {number} before - Characters to expand to the left.
|
|
106
106
|
* @param {number} after - Characters to expand to the right.
|
|
107
|
-
* @returns {
|
|
107
|
+
* @returns {this}
|
|
108
108
|
*/
|
|
109
|
-
expandSelection(before: number, after: number):
|
|
109
|
+
expandSelection(before: number, after: number): this;
|
|
110
110
|
/**
|
|
111
111
|
* Replaces all regex matches in the content.
|
|
112
112
|
* @param {RegExp} regex - Regex to match.
|
|
113
113
|
* @param {(match: string) => string} replacer - Replacement function.
|
|
114
|
-
* @returns {
|
|
114
|
+
* @returns {this}
|
|
115
115
|
*/
|
|
116
|
-
replaceAll(regex: RegExp, replacer: (match: string) => string):
|
|
116
|
+
replaceAll(regex: RegExp, replacer: (match: string) => string): this;
|
|
117
117
|
/**
|
|
118
118
|
* Replaces all regex matches within the currently selected text.
|
|
119
119
|
*
|
|
120
120
|
* @param {RegExp} regex - Regular expression to match inside selection.
|
|
121
121
|
* @param {(match: string) => string} replacer - Function to replace each match.
|
|
122
|
-
* @returns {
|
|
122
|
+
* @returns {this}
|
|
123
123
|
*/
|
|
124
|
-
replaceInSelection(regex: RegExp, replacer: (match: string) => string):
|
|
124
|
+
replaceInSelection(regex: RegExp, replacer: (match: string) => string): this;
|
|
125
125
|
/**
|
|
126
126
|
* Toggles a code around the current selection.
|
|
127
127
|
* If it's already wrapped, unwraps it.
|
|
128
128
|
* @param {string} codeName - The code to toggle.
|
|
129
|
-
* @returns {
|
|
129
|
+
* @returns {this}
|
|
130
130
|
*/
|
|
131
|
-
toggleCode(codeName: string):
|
|
131
|
+
toggleCode(codeName: string): this;
|
|
132
132
|
/**
|
|
133
133
|
* Converts a list of attributes into a string suitable for tag insertion.
|
|
134
134
|
*
|
|
@@ -169,32 +169,32 @@ declare class TinyTextRangeEditor {
|
|
|
169
169
|
* - If an object: key-value pairs (e.g., `{ color: "red" }` → `color="red"`).
|
|
170
170
|
* - If an array: boolean attributes (e.g., `["disabled", "readonly"]`).
|
|
171
171
|
*
|
|
172
|
-
* @returns {
|
|
172
|
+
* @returns {this}
|
|
173
173
|
*/
|
|
174
|
-
wrapWithTag(tagName: string, attributes?: Record<string, string> | string[]):
|
|
174
|
+
wrapWithTag(tagName: string, attributes?: Record<string, string> | string[]): this;
|
|
175
175
|
/**
|
|
176
176
|
* Inserts a tag with optional inner content.
|
|
177
177
|
* @param {string} tagName - The tag to insert.
|
|
178
178
|
* @param {string} [content=''] - Optional content between tags.
|
|
179
179
|
* @param {Record<string,string> | string[]} [attributes={}] - Optional attributes or list of empty attributes.
|
|
180
|
-
* @returns {
|
|
180
|
+
* @returns {this}
|
|
181
181
|
*/
|
|
182
|
-
insertTag(tagName: string, content?: string, attributes?: Record<string, string> | string[]):
|
|
182
|
+
insertTag(tagName: string, content?: string, attributes?: Record<string, string> | string[]): this;
|
|
183
183
|
/**
|
|
184
184
|
* Inserts a self-closing tag.
|
|
185
185
|
* @param {string} tagName - The tag name.
|
|
186
186
|
* @param {Record<string,string> | string[]} [attributes={}] - Optional attributes or list of empty attributes.
|
|
187
|
-
* @returns {
|
|
187
|
+
* @returns {this}
|
|
188
188
|
*/
|
|
189
|
-
insertSelfClosingTag(tagName: string, attributes?: Record<string, string> | string[]):
|
|
189
|
+
insertSelfClosingTag(tagName: string, attributes?: Record<string, string> | string[]): this;
|
|
190
190
|
/**
|
|
191
191
|
* Toggles a tag around the current selection.
|
|
192
192
|
* Supports tags with attributes. If already wrapped, it unwraps.
|
|
193
193
|
* @param {string} tagName - The tag to toggle.
|
|
194
194
|
* @param {Record<string,string> | string[]} [attributes={}] - Optional attributes to apply when wrapping.
|
|
195
|
-
* @returns {
|
|
195
|
+
* @returns {this}
|
|
196
196
|
*/
|
|
197
|
-
toggleTag(tagName: string, attributes?: Record<string, string> | string[]):
|
|
197
|
+
toggleTag(tagName: string, attributes?: Record<string, string> | string[]): this;
|
|
198
198
|
#private;
|
|
199
199
|
}
|
|
200
200
|
//# sourceMappingURL=TinyTextRangeEditor.d.mts.map
|
|
@@ -48,7 +48,7 @@ class TinyTextRangeEditor {
|
|
|
48
48
|
}
|
|
49
49
|
/**
|
|
50
50
|
* Ensures the element has focus.
|
|
51
|
-
* @returns {
|
|
51
|
+
* @returns {this}
|
|
52
52
|
*/
|
|
53
53
|
ensureFocus() {
|
|
54
54
|
if (document.activeElement !== this.#el)
|
|
@@ -57,7 +57,7 @@ class TinyTextRangeEditor {
|
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Focus the element.
|
|
60
|
-
* @returns {
|
|
60
|
+
* @returns {this}
|
|
61
61
|
*/
|
|
62
62
|
focus() {
|
|
63
63
|
this.#el.focus();
|
|
@@ -75,7 +75,7 @@ class TinyTextRangeEditor {
|
|
|
75
75
|
* @param {number} start - Start index.
|
|
76
76
|
* @param {number} end - End index.
|
|
77
77
|
* @param {boolean} [preserveScroll=true] - Whether to preserve scroll position.
|
|
78
|
-
* @returns {
|
|
78
|
+
* @returns {this}
|
|
79
79
|
*/
|
|
80
80
|
setSelectionRange(start, end, preserveScroll = true) {
|
|
81
81
|
if (typeof start !== 'number' || typeof end !== 'number')
|
|
@@ -98,7 +98,7 @@ class TinyTextRangeEditor {
|
|
|
98
98
|
/**
|
|
99
99
|
* Sets the full value of the element.
|
|
100
100
|
* @param {string} value - The new value to assign.
|
|
101
|
-
* @returns {
|
|
101
|
+
* @returns {this}
|
|
102
102
|
*/
|
|
103
103
|
setValue(value) {
|
|
104
104
|
if (typeof value !== 'string')
|
|
@@ -119,7 +119,7 @@ class TinyTextRangeEditor {
|
|
|
119
119
|
* @param {boolean} [settings.autoSpacing=false]
|
|
120
120
|
* @param {boolean} [settings.autoSpaceLeft=false]
|
|
121
121
|
* @param {boolean} [settings.autoSpaceRight=false]
|
|
122
|
-
* @returns {
|
|
122
|
+
* @returns {this}
|
|
123
123
|
*/
|
|
124
124
|
insertText(text, { newCursor = 'end', autoSpacing = false, autoSpaceLeft = autoSpacing, autoSpaceRight = autoSpacing, } = {}) {
|
|
125
125
|
if (typeof text !== 'string')
|
|
@@ -151,7 +151,7 @@ class TinyTextRangeEditor {
|
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* Deletes the currently selected text.
|
|
154
|
-
* @returns {
|
|
154
|
+
* @returns {this}
|
|
155
155
|
*/
|
|
156
156
|
deleteSelection() {
|
|
157
157
|
this.insertText('');
|
|
@@ -160,7 +160,7 @@ class TinyTextRangeEditor {
|
|
|
160
160
|
/**
|
|
161
161
|
* Replaces the selection using a transformation function.
|
|
162
162
|
* @param {(selected: string) => string} transformer - Function that modifies the selected text.
|
|
163
|
-
* @returns {
|
|
163
|
+
* @returns {this}
|
|
164
164
|
*/
|
|
165
165
|
transformSelection(transformer) {
|
|
166
166
|
if (typeof transformer !== 'function')
|
|
@@ -176,7 +176,7 @@ class TinyTextRangeEditor {
|
|
|
176
176
|
* Surrounds current selection with prefix and suffix.
|
|
177
177
|
* @param {string} prefix - Text to insert before.
|
|
178
178
|
* @param {string} suffix - Text to insert after.
|
|
179
|
-
* @returns {
|
|
179
|
+
* @returns {this}
|
|
180
180
|
*/
|
|
181
181
|
surroundSelection(prefix, suffix) {
|
|
182
182
|
if (typeof prefix !== 'string' || typeof suffix !== 'string')
|
|
@@ -188,7 +188,7 @@ class TinyTextRangeEditor {
|
|
|
188
188
|
/**
|
|
189
189
|
* Moves the caret by a given offset.
|
|
190
190
|
* @param {number} offset - Characters to move.
|
|
191
|
-
* @returns {
|
|
191
|
+
* @returns {this}
|
|
192
192
|
*/
|
|
193
193
|
moveCaret(offset) {
|
|
194
194
|
if (typeof offset !== 'number')
|
|
@@ -200,7 +200,7 @@ class TinyTextRangeEditor {
|
|
|
200
200
|
}
|
|
201
201
|
/**
|
|
202
202
|
* Selects all content in the field.
|
|
203
|
-
* @returns {
|
|
203
|
+
* @returns {this}
|
|
204
204
|
*/
|
|
205
205
|
selectAll() {
|
|
206
206
|
this.setSelectionRange(0, this.#el.value.length);
|
|
@@ -210,7 +210,7 @@ class TinyTextRangeEditor {
|
|
|
210
210
|
* Expands the current selection by character amounts.
|
|
211
211
|
* @param {number} before - Characters to expand to the left.
|
|
212
212
|
* @param {number} after - Characters to expand to the right.
|
|
213
|
-
* @returns {
|
|
213
|
+
* @returns {this}
|
|
214
214
|
*/
|
|
215
215
|
expandSelection(before, after) {
|
|
216
216
|
if (typeof before !== 'number' || typeof after !== 'number')
|
|
@@ -225,7 +225,7 @@ class TinyTextRangeEditor {
|
|
|
225
225
|
* Replaces all regex matches in the content.
|
|
226
226
|
* @param {RegExp} regex - Regex to match.
|
|
227
227
|
* @param {(match: string) => string} replacer - Replacement function.
|
|
228
|
-
* @returns {
|
|
228
|
+
* @returns {this}
|
|
229
229
|
*/
|
|
230
230
|
replaceAll(regex, replacer) {
|
|
231
231
|
if (!(regex instanceof RegExp))
|
|
@@ -241,7 +241,7 @@ class TinyTextRangeEditor {
|
|
|
241
241
|
*
|
|
242
242
|
* @param {RegExp} regex - Regular expression to match inside selection.
|
|
243
243
|
* @param {(match: string) => string} replacer - Function to replace each match.
|
|
244
|
-
* @returns {
|
|
244
|
+
* @returns {this}
|
|
245
245
|
*/
|
|
246
246
|
replaceInSelection(regex, replacer) {
|
|
247
247
|
if (!(regex instanceof RegExp))
|
|
@@ -261,7 +261,7 @@ class TinyTextRangeEditor {
|
|
|
261
261
|
* Toggles a code around the current selection.
|
|
262
262
|
* If it's already wrapped, unwraps it.
|
|
263
263
|
* @param {string} codeName - The code to toggle.
|
|
264
|
-
* @returns {
|
|
264
|
+
* @returns {this}
|
|
265
265
|
*/
|
|
266
266
|
toggleCode(codeName) {
|
|
267
267
|
if (typeof codeName !== 'string')
|
|
@@ -339,7 +339,7 @@ class TinyTextRangeEditor {
|
|
|
339
339
|
* - If an object: key-value pairs (e.g., `{ color: "red" }` → `color="red"`).
|
|
340
340
|
* - If an array: boolean attributes (e.g., `["disabled", "readonly"]`).
|
|
341
341
|
*
|
|
342
|
-
* @returns {
|
|
342
|
+
* @returns {this}
|
|
343
343
|
*/
|
|
344
344
|
wrapWithTag(tagName, attributes = {}) {
|
|
345
345
|
if (typeof tagName !== 'string')
|
|
@@ -357,7 +357,7 @@ class TinyTextRangeEditor {
|
|
|
357
357
|
* @param {string} tagName - The tag to insert.
|
|
358
358
|
* @param {string} [content=''] - Optional content between tags.
|
|
359
359
|
* @param {Record<string,string> | string[]} [attributes={}] - Optional attributes or list of empty attributes.
|
|
360
|
-
* @returns {
|
|
360
|
+
* @returns {this}
|
|
361
361
|
*/
|
|
362
362
|
insertTag(tagName, content = '', attributes = {}) {
|
|
363
363
|
if (typeof tagName !== 'string')
|
|
@@ -376,7 +376,7 @@ class TinyTextRangeEditor {
|
|
|
376
376
|
* Inserts a self-closing tag.
|
|
377
377
|
* @param {string} tagName - The tag name.
|
|
378
378
|
* @param {Record<string,string> | string[]} [attributes={}] - Optional attributes or list of empty attributes.
|
|
379
|
-
* @returns {
|
|
379
|
+
* @returns {this}
|
|
380
380
|
*/
|
|
381
381
|
insertSelfClosingTag(tagName, attributes = {}) {
|
|
382
382
|
if (typeof tagName !== 'string')
|
|
@@ -393,7 +393,7 @@ class TinyTextRangeEditor {
|
|
|
393
393
|
* Supports tags with attributes. If already wrapped, it unwraps.
|
|
394
394
|
* @param {string} tagName - The tag to toggle.
|
|
395
395
|
* @param {Record<string,string> | string[]} [attributes={}] - Optional attributes to apply when wrapping.
|
|
396
|
-
* @returns {
|
|
396
|
+
* @returns {this}
|
|
397
397
|
*/
|
|
398
398
|
toggleTag(tagName, attributes = {}) {
|
|
399
399
|
if (typeof tagName !== 'string')
|