tiny-essentials 1.17.0 โ 1.18.0
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/TinyBasicsEs.js +336 -45
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyClipboard.js +459 -0
- package/dist/v1/TinyClipboard.min.js +1 -0
- package/dist/v1/TinyDragger.js +336 -45
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyEssentials.js +1218 -45
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyHtml.js +336 -45
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinySmartScroller.js +336 -45
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyTextRangeEditor.js +497 -0
- package/dist/v1/TinyTextRangeEditor.min.js +1 -0
- package/dist/v1/TinyUploadClicker.js +338 -45
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/build/TinyClipboard.cjs +7 -0
- package/dist/v1/build/TinyClipboard.d.mts +3 -0
- package/dist/v1/build/TinyClipboard.mjs +2 -0
- package/dist/v1/build/TinyTextRangeEditor.cjs +7 -0
- package/dist/v1/build/TinyTextRangeEditor.d.mts +3 -0
- package/dist/v1/build/TinyTextRangeEditor.mjs +2 -0
- package/dist/v1/index.cjs +4 -0
- package/dist/v1/index.d.mts +3 -1
- package/dist/v1/index.mjs +3 -1
- package/dist/v1/libs/TinyClipboard.cjs +420 -0
- package/dist/v1/libs/TinyClipboard.d.mts +155 -0
- package/dist/v1/libs/TinyClipboard.mjs +398 -0
- package/dist/v1/libs/TinyHtml.cjs +336 -45
- package/dist/v1/libs/TinyHtml.d.mts +238 -27
- package/dist/v1/libs/TinyHtml.mjs +320 -47
- package/dist/v1/libs/TinyTextRangeEditor.cjs +458 -0
- package/dist/v1/libs/TinyTextRangeEditor.d.mts +200 -0
- package/dist/v1/libs/TinyTextRangeEditor.mjs +424 -0
- package/docs/v1/README.md +2 -0
- package/docs/v1/libs/TinyClipboard.md +213 -0
- package/docs/v1/libs/TinyHtml.md +211 -15
- package/docs/v1/libs/TinyTextRangeEditor.md +208 -0
- package/package.json +1 -1
package/docs/v1/libs/TinyHtml.md
CHANGED
|
@@ -90,8 +90,32 @@ ElementAndWinAndDoc | TinyHtml
|
|
|
90
90
|
|
|
91
91
|
---
|
|
92
92
|
|
|
93
|
+
#### `TinyElementWithDoc`
|
|
94
|
+
|
|
95
|
+
Accepts both raw DOM elements, the `document` object, or a `TinyHtml` wrapper.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
ElementWithDoc | TinyHtml
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Used to abstract interactions with either native elements or enhanced wrappers.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
93
105
|
### ๐ Union Types
|
|
94
106
|
|
|
107
|
+
#### `ElementWithDoc`
|
|
108
|
+
|
|
109
|
+
A raw DOM `Element` or the `document` object.
|
|
110
|
+
|
|
111
|
+
```ts
|
|
112
|
+
Element | Document
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Commonly used when the target might be either a single HTML element or the whole document, particularly in layout and measurement utilities.
|
|
116
|
+
|
|
117
|
+
---
|
|
118
|
+
|
|
95
119
|
#### `ElementAndWinAndDoc`
|
|
96
120
|
|
|
97
121
|
Used for scrollable or measurable targets.
|
|
@@ -133,18 +157,6 @@ Window | Element | Document | Text
|
|
|
133
157
|
|
|
134
158
|
---
|
|
135
159
|
|
|
136
|
-
### ๐ฏ Event System Types
|
|
137
|
-
|
|
138
|
-
#### `EventRegistryHandle`
|
|
139
|
-
|
|
140
|
-
A basic event listener handler function.
|
|
141
|
-
|
|
142
|
-
```ts
|
|
143
|
-
(e: Event) => any
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
---
|
|
147
|
-
|
|
148
160
|
#### `EventRegistryOptions`
|
|
149
161
|
|
|
150
162
|
Options for `addEventListener` and `removeEventListener`.
|
|
@@ -161,7 +173,7 @@ Describes an individual event registration.
|
|
|
161
173
|
|
|
162
174
|
```ts
|
|
163
175
|
{
|
|
164
|
-
handler:
|
|
176
|
+
handler: EventListenerOrEventListenerObject | null,
|
|
165
177
|
options?: EventRegistryOptions
|
|
166
178
|
}
|
|
167
179
|
```
|
|
@@ -446,8 +458,10 @@ Each method below ensures type and returns raw DOM objects:
|
|
|
446
458
|
| `_preEventTargetElem(...)` | `EventTarget` | `EventTarget` |
|
|
447
459
|
| `_preElemsAndWindow(...)` | `Element\|Window` | `ElementAndWindow[]` |
|
|
448
460
|
| `_preElemAndWindow(...)` | `Element\|Window` | `ElementAndWindow` |
|
|
449
|
-
| `_preElemsAndWinAndDoc(...)`
|
|
450
|
-
| `_preElemAndWinAndDoc(...)`
|
|
461
|
+
| `_preElemsAndWinAndDoc(...)` | `Element\|Window\|Document` | `ElementAndWindow[]` |
|
|
462
|
+
| `_preElemAndWinAndDoc(...)` | `Element\|Window\|Document` | `ElementAndWindow` |
|
|
463
|
+
| `_preElemsWithDoc(...)` | `Element\|Document` | `ElementWithDoc[]` |
|
|
464
|
+
| `_preElemWithDoc(...)` | `Element\|Document` | `ElementWithDoc` |
|
|
451
465
|
|
|
452
466
|
---
|
|
453
467
|
|
|
@@ -747,6 +761,102 @@ Normalizes and converts input (elements, arrays, or strings) into appendable DOM
|
|
|
747
761
|
|
|
748
762
|
---
|
|
749
763
|
|
|
764
|
+
## ๐งฎ Easing Functions
|
|
765
|
+
|
|
766
|
+
### `TinyHtml.easings`
|
|
767
|
+
|
|
768
|
+
A collection of predefined easing functions used for scroll and animation calculations.
|
|
769
|
+
Each easing function takes a normalized time (`t` from 0 to 1) and returns a transformed progress value.
|
|
770
|
+
|
|
771
|
+
| Name | Description |
|
|
772
|
+
| ---------------- | ------------------------------------- |
|
|
773
|
+
| `linear` | Constant speed, no easing. |
|
|
774
|
+
| `easeInQuad` | Accelerates from zero velocity. |
|
|
775
|
+
| `easeOutQuad` | Decelerates to zero velocity. |
|
|
776
|
+
| `easeInOutQuad` | Accelerates, then decelerates. |
|
|
777
|
+
| `easeInCubic` | Starts slow, speeds up sharply. |
|
|
778
|
+
| `easeOutCubic` | Starts fast, slows down gradually. |
|
|
779
|
+
| `easeInOutCubic` | Smooth acceleration and deceleration. |
|
|
780
|
+
|
|
781
|
+
```ts
|
|
782
|
+
type Easings =
|
|
783
|
+
| 'linear'
|
|
784
|
+
| 'easeInQuad'
|
|
785
|
+
| 'easeOutQuad'
|
|
786
|
+
| 'easeInOutQuad'
|
|
787
|
+
| 'easeInCubic'
|
|
788
|
+
| 'easeOutCubic'
|
|
789
|
+
| 'easeInOutCubic';
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
```ts
|
|
793
|
+
TinyHtml.easings = {
|
|
794
|
+
linear: (t) => t,
|
|
795
|
+
easeInQuad: (t) => t * t,
|
|
796
|
+
easeOutQuad: (t) => t * (2 - t),
|
|
797
|
+
easeInOutQuad: (t) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t),
|
|
798
|
+
easeInCubic: (t) => t * t * t,
|
|
799
|
+
easeOutCubic: (t) => --t * t * t + 1,
|
|
800
|
+
easeInOutCubic: (t) => (t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1),
|
|
801
|
+
};
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
---
|
|
805
|
+
|
|
806
|
+
## ๐งญ Smooth Scrolling
|
|
807
|
+
|
|
808
|
+
### `TinyHtml.scrollToXY(el, settings)`
|
|
809
|
+
|
|
810
|
+
Smoothly scrolls one or more elements (or `window`) to a target position using a custom duration and easing.
|
|
811
|
+
|
|
812
|
+
If no `duration` or invalid `easing` is provided, the scroll happens instantly.
|
|
813
|
+
|
|
814
|
+
```ts
|
|
815
|
+
TinyHtml.scrollToXY(el, {
|
|
816
|
+
targetX?: number,
|
|
817
|
+
targetY?: number,
|
|
818
|
+
duration?: number,
|
|
819
|
+
easing?: Easings,
|
|
820
|
+
});
|
|
821
|
+
```
|
|
822
|
+
|
|
823
|
+
| Parameter | Type | Description |
|
|
824
|
+
| -------------------- | ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
825
|
+
| `el` | `TinyElementAndWindow \| TinyElementAndWindow[]` | One or more elements or the `window` to scroll. |
|
|
826
|
+
| `settings` | `Object` | Scroll configuration. |
|
|
827
|
+
| `targetX` | `number` *(optional)* | Final horizontal scroll position. |
|
|
828
|
+
| `targetY` | `number` *(optional)* | Final vertical scroll position. |
|
|
829
|
+
| `duration` | `number` *(optional)* | Duration of the scroll animation in milliseconds. |
|
|
830
|
+
| `easing` | `Easings` *(optional)* | Name of easing function to control animation curve. |
|
|
831
|
+
| `onAnimation` | `OnScrollAnimation` *(optional)* | Optional callback invoked on each animation frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag. |
|
|
832
|
+
|
|
833
|
+
---
|
|
834
|
+
|
|
835
|
+
## โ๏ธ Internal Scroll Mechanism
|
|
836
|
+
|
|
837
|
+
When called, `scrollToXY()` performs:
|
|
838
|
+
|
|
839
|
+
1. **Start Position Detection** โ Gets current scroll positions.
|
|
840
|
+
2. **Delta Calculation** โ Calculates the distance to scroll.
|
|
841
|
+
3. **Easing Evaluation** โ Determines the easing curve to use.
|
|
842
|
+
4. **Scroll Loop** โ Uses `requestAnimationFrame` to animate over time.
|
|
843
|
+
5. **Instant Scroll Fallback** โ If no easing/duration is defined, scrolls instantly.
|
|
844
|
+
|
|
845
|
+
```ts
|
|
846
|
+
function executeScroll(elem, newX, newY) {
|
|
847
|
+
if (elem instanceof Window) {
|
|
848
|
+
window.scrollTo(newX, newY);
|
|
849
|
+
} else if (elem.nodeType === 9) {
|
|
850
|
+
elem.defaultView.scrollTo(newX, newY); // For documents
|
|
851
|
+
} else {
|
|
852
|
+
if (elem.scrollLeft !== newX) elem.scrollLeft = newX;
|
|
853
|
+
if (elem.scrollTop !== newY) elem.scrollTop = newY;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
---
|
|
859
|
+
|
|
750
860
|
## ๐ Dimensions (Size API)
|
|
751
861
|
|
|
752
862
|
TinyHtml provides methods to **read** and **set** an element's dimensions, similar to jQueryโs width/height API, with support for box models: `content`, `padding`, `border`, and `margin`.
|
|
@@ -823,6 +933,9 @@ This API set focuses on **measuring element offsets**, **scroll positions**, and
|
|
|
823
933
|
|
|
824
934
|
### ๐ Element Positioning
|
|
825
935
|
|
|
936
|
+
#### `.animate(keyframes, ops?)` / `TinyHtml.animate(el, keyframes, ops?)`
|
|
937
|
+
Applies an animation to one or more TinyElement instances using the Web Animations API.
|
|
938
|
+
|
|
826
939
|
#### `.offset()` / `TinyHtml.offset(el)`
|
|
827
940
|
Returns the coordinates `{ top, left }` of the element **relative to the document**.
|
|
828
941
|
|
|
@@ -1137,6 +1250,89 @@ All event listeners are tracked in a private registry for full control.
|
|
|
1137
1250
|
|
|
1138
1251
|
---
|
|
1139
1252
|
|
|
1253
|
+
### ๐ `listenForPaste()`
|
|
1254
|
+
|
|
1255
|
+
Handling Pasted Files and Text
|
|
1256
|
+
|
|
1257
|
+
```js
|
|
1258
|
+
element.listenForPaste({
|
|
1259
|
+
onFilePaste(item, file) {
|
|
1260
|
+
console.log("Pasted file:", file.name);
|
|
1261
|
+
},
|
|
1262
|
+
onTextPaste(item, text) {
|
|
1263
|
+
console.log("Pasted text:", text);
|
|
1264
|
+
},
|
|
1265
|
+
});
|
|
1266
|
+
```
|
|
1267
|
+
|
|
1268
|
+
Registers a listener for the `"paste"` event to extract files or plain text directly from the clipboard.
|
|
1269
|
+
|
|
1270
|
+
* `onFilePaste(item, file)` โ Triggered once for each file pasted (e.g., images or documents).
|
|
1271
|
+
* `onTextPaste(item, text)` โ Triggered when plain text is pasted.
|
|
1272
|
+
|
|
1273
|
+
Use this to build file dropzones, rich editors, or custom paste behavior.
|
|
1274
|
+
You can also use the static version for multiple elements:
|
|
1275
|
+
|
|
1276
|
+
```js
|
|
1277
|
+
TinyHtml.listenForPaste([el1, el2], {
|
|
1278
|
+
onFilePaste(item, file) {
|
|
1279
|
+
console.log("Pasted a file into multiple elements!");
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
```
|
|
1283
|
+
|
|
1284
|
+
Returns the internal paste handler function.
|
|
1285
|
+
|
|
1286
|
+
---
|
|
1287
|
+
|
|
1288
|
+
### ๐ก `hasEventListener()`
|
|
1289
|
+
|
|
1290
|
+
Checking for Event Presence
|
|
1291
|
+
|
|
1292
|
+
```js
|
|
1293
|
+
if (element.hasEventListener("click")) {
|
|
1294
|
+
console.log("Click handler already registered.");
|
|
1295
|
+
}
|
|
1296
|
+
```
|
|
1297
|
+
|
|
1298
|
+
Checks whether any handler is currently registered on `__eventRegistry` for the given event name on an element.
|
|
1299
|
+
|
|
1300
|
+
* Returns `true` if any listener exists for the event, otherwise `false`.
|
|
1301
|
+
|
|
1302
|
+
Also available as a static version:
|
|
1303
|
+
|
|
1304
|
+
```js
|
|
1305
|
+
TinyHtml.hasEventListener(el, "paste");
|
|
1306
|
+
```
|
|
1307
|
+
|
|
1308
|
+
---
|
|
1309
|
+
|
|
1310
|
+
### ๐ฏ `hasExactEventListener()`
|
|
1311
|
+
|
|
1312
|
+
Checking for a Specific Handler
|
|
1313
|
+
|
|
1314
|
+
```js
|
|
1315
|
+
function onClick() {}
|
|
1316
|
+
element.on("click", onClick);
|
|
1317
|
+
|
|
1318
|
+
if (element.hasExactEventListener("click", onClick)) {
|
|
1319
|
+
console.log("The exact click handler is registered.");
|
|
1320
|
+
}
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
Checks whether an element has **that exact function** registered on `__eventRegistry` for the given event.
|
|
1324
|
+
|
|
1325
|
+
* Returns `true` only if the same reference to the function is found.
|
|
1326
|
+
* Helps prevent duplicate listeners or for conditional removal logic.
|
|
1327
|
+
|
|
1328
|
+
Also available as a static version:
|
|
1329
|
+
|
|
1330
|
+
```js
|
|
1331
|
+
TinyHtml.hasExactEventListener(el, "click", onClick);
|
|
1332
|
+
```
|
|
1333
|
+
|
|
1334
|
+
---
|
|
1335
|
+
|
|
1140
1336
|
### ๐ฅ `on()` / `once()`
|
|
1141
1337
|
|
|
1142
1338
|
Registering Events
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# ๐ฆ `TinyTextRangeEditor` Documentation
|
|
2
|
+
|
|
3
|
+
A lightweight but powerful text range utility class for `<input>` and `<textarea>` elements, ideal for building BBCode or other tag-based markup editors.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## ๐ Constructor
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
new TinyTextRangeEditor(element, options?)
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Parameters:
|
|
14
|
+
|
|
15
|
+
* `element` **(HTMLInputElement | HTMLTextAreaElement)** โ Target editable element.
|
|
16
|
+
* `options` **(Object)** *(optional)* โ Customize tag delimiters.
|
|
17
|
+
|
|
18
|
+
* `openTag` **(string)** โ Default: `'['`
|
|
19
|
+
* `closeTag` **(string)** โ Default: `']'`
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ๐ง Core Methods
|
|
24
|
+
|
|
25
|
+
### `getOpenTag()` โ `string`
|
|
26
|
+
|
|
27
|
+
Returns the current **opening tag symbol**.
|
|
28
|
+
|
|
29
|
+
### `getCloseTag()` โ `string`
|
|
30
|
+
|
|
31
|
+
Returns the current **closing tag symbol**.
|
|
32
|
+
|
|
33
|
+
### `setOpenTag(tag: string)`
|
|
34
|
+
|
|
35
|
+
Changes the **opening tag symbol**.
|
|
36
|
+
|
|
37
|
+
### `setCloseTag(tag: string)`
|
|
38
|
+
|
|
39
|
+
Changes the **closing tag symbol**.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## ๐ฏ Selection & Focus
|
|
44
|
+
|
|
45
|
+
### `focus()` โ `this`
|
|
46
|
+
|
|
47
|
+
Focuses the target element.
|
|
48
|
+
|
|
49
|
+
### `ensureFocus()` โ `this`
|
|
50
|
+
|
|
51
|
+
Focuses the element only if not already focused.
|
|
52
|
+
|
|
53
|
+
### `getSelectionRange()` โ `{ start: number, end: number }`
|
|
54
|
+
|
|
55
|
+
Returns the current **text selection range**.
|
|
56
|
+
|
|
57
|
+
### `setSelectionRange(start, end, preserveScroll = true)` โ `this`
|
|
58
|
+
|
|
59
|
+
Sets the selection range.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## ๐ Value Access
|
|
64
|
+
|
|
65
|
+
### `getValue()` โ `string`
|
|
66
|
+
|
|
67
|
+
Returns the entire value of the field.
|
|
68
|
+
|
|
69
|
+
### `setValue(value: string)` โ `this`
|
|
70
|
+
|
|
71
|
+
Sets the entire content.
|
|
72
|
+
|
|
73
|
+
### `getSelectedText()` โ `string`
|
|
74
|
+
|
|
75
|
+
Returns the currently selected text.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
## โ๏ธ Text Manipulation
|
|
80
|
+
|
|
81
|
+
### `insertText(text, options?)` โ `this`
|
|
82
|
+
|
|
83
|
+
Inserts (and replaces) text at selection.
|
|
84
|
+
|
|
85
|
+
#### Options:
|
|
86
|
+
|
|
87
|
+
* `newCursor`: `"start" | "end" | "preserve"` *(default: `'end'`)*
|
|
88
|
+
* `autoSpacing`: *(boolean)* Add space if needed on both sides.
|
|
89
|
+
* `autoSpaceLeft` / `autoSpaceRight`: *(boolean)* Fine-grained spacing control.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
### `deleteSelection()` โ `this`
|
|
94
|
+
|
|
95
|
+
Deletes selected text.
|
|
96
|
+
|
|
97
|
+
### `transformSelection(fn)` โ `this`
|
|
98
|
+
|
|
99
|
+
Applies a transformation function to the selected text.
|
|
100
|
+
|
|
101
|
+
### `surroundSelection(prefix, suffix)` โ `this`
|
|
102
|
+
|
|
103
|
+
Wraps selected text with custom strings.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## ๐ช Tag Operations
|
|
108
|
+
|
|
109
|
+
### `wrapWithTag(tagName, attributes?)` โ `this`
|
|
110
|
+
|
|
111
|
+
Wraps the selection in a custom tag.
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
editor.wrapWithTag("b");
|
|
115
|
+
editor.wrapWithTag("color", { value: "red" });
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `insertTag(tagName, content?, attributes?)` โ `this`
|
|
119
|
+
|
|
120
|
+
Inserts an opening and closing tag with optional content.
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
editor.insertTag("quote", "Hello!", { user: "Yasmin" });
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### `insertSelfClosingTag(tagName, attributes?)` โ `this`
|
|
127
|
+
|
|
128
|
+
Inserts a self-closing tag.
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
editor.insertSelfClosingTag("br");
|
|
132
|
+
editor.insertSelfClosingTag("img", { src: "link.jpg", alt: "image" });
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### `toggleTag(tagName, attributes?)` โ `this`
|
|
136
|
+
|
|
137
|
+
Wraps or **unwraps** the selection with a tag.
|
|
138
|
+
|
|
139
|
+
```js
|
|
140
|
+
editor.toggleTag("b");
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `toggleCode(codeName)` โ `this`
|
|
144
|
+
|
|
145
|
+
Wraps or **unwraps** the selection with a code.
|
|
146
|
+
|
|
147
|
+
```js
|
|
148
|
+
editor.toggleTag("**");
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## ๐ง Utility
|
|
154
|
+
|
|
155
|
+
### `moveCaret(offset: number)` โ `this`
|
|
156
|
+
|
|
157
|
+
Moves the caret by an offset.
|
|
158
|
+
|
|
159
|
+
### `selectAll()` โ `this`
|
|
160
|
+
|
|
161
|
+
Selects all the content.
|
|
162
|
+
|
|
163
|
+
### `expandSelection(before, after)` โ `this`
|
|
164
|
+
|
|
165
|
+
Expands the selection range by the given number of characters.
|
|
166
|
+
|
|
167
|
+
### `replaceAll(regex, replacerFn)` โ `this`
|
|
168
|
+
|
|
169
|
+
Performs regex replacement over the full text.
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
### `replaceInSelection(regex, replacerFn)`
|
|
174
|
+
|
|
175
|
+
Replaces all matches of a regular expression **only within the currently selected text** in the editor.
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## ๐งฉ Internal Attribute Helper
|
|
180
|
+
|
|
181
|
+
### `_insertAttr(attributes)` โ `string`
|
|
182
|
+
|
|
183
|
+
Serializes tag attributes to string format. Supports:
|
|
184
|
+
|
|
185
|
+
* โ
Object: `{ color: "red" } โ color="red"`
|
|
186
|
+
* โ
Array: `["checked", "readonly"] โ checked readonly`
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## ๐งช Example Use
|
|
191
|
+
|
|
192
|
+
```js
|
|
193
|
+
const textarea = document.querySelector('textarea');
|
|
194
|
+
const editor = new TinyTextRangeEditor(textarea);
|
|
195
|
+
|
|
196
|
+
editor.wrapWithTag("b");
|
|
197
|
+
editor.insertTag("color", "red text", { color: "red" });
|
|
198
|
+
editor.insertSelfClosingTag("br");
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## ๐ Notes
|
|
204
|
+
|
|
205
|
+
* All methods are **chainable** (`return this`)
|
|
206
|
+
* Throws detailed **TypeErrors** if used incorrectly
|
|
207
|
+
* Does **not** depend on any external library
|
|
208
|
+
* Useful for BBCode editors, markdown-like syntax, or custom in-text macros
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "npm run test:mjs && npm run test:cjs && npm run test:js",
|