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.
Files changed (39) hide show
  1. package/dist/v1/TinyBasicsEs.js +336 -45
  2. package/dist/v1/TinyBasicsEs.min.js +1 -1
  3. package/dist/v1/TinyClipboard.js +459 -0
  4. package/dist/v1/TinyClipboard.min.js +1 -0
  5. package/dist/v1/TinyDragger.js +336 -45
  6. package/dist/v1/TinyDragger.min.js +1 -1
  7. package/dist/v1/TinyEssentials.js +1218 -45
  8. package/dist/v1/TinyEssentials.min.js +1 -1
  9. package/dist/v1/TinyHtml.js +336 -45
  10. package/dist/v1/TinyHtml.min.js +1 -1
  11. package/dist/v1/TinySmartScroller.js +336 -45
  12. package/dist/v1/TinySmartScroller.min.js +1 -1
  13. package/dist/v1/TinyTextRangeEditor.js +497 -0
  14. package/dist/v1/TinyTextRangeEditor.min.js +1 -0
  15. package/dist/v1/TinyUploadClicker.js +338 -45
  16. package/dist/v1/TinyUploadClicker.min.js +1 -1
  17. package/dist/v1/build/TinyClipboard.cjs +7 -0
  18. package/dist/v1/build/TinyClipboard.d.mts +3 -0
  19. package/dist/v1/build/TinyClipboard.mjs +2 -0
  20. package/dist/v1/build/TinyTextRangeEditor.cjs +7 -0
  21. package/dist/v1/build/TinyTextRangeEditor.d.mts +3 -0
  22. package/dist/v1/build/TinyTextRangeEditor.mjs +2 -0
  23. package/dist/v1/index.cjs +4 -0
  24. package/dist/v1/index.d.mts +3 -1
  25. package/dist/v1/index.mjs +3 -1
  26. package/dist/v1/libs/TinyClipboard.cjs +420 -0
  27. package/dist/v1/libs/TinyClipboard.d.mts +155 -0
  28. package/dist/v1/libs/TinyClipboard.mjs +398 -0
  29. package/dist/v1/libs/TinyHtml.cjs +336 -45
  30. package/dist/v1/libs/TinyHtml.d.mts +238 -27
  31. package/dist/v1/libs/TinyHtml.mjs +320 -47
  32. package/dist/v1/libs/TinyTextRangeEditor.cjs +458 -0
  33. package/dist/v1/libs/TinyTextRangeEditor.d.mts +200 -0
  34. package/dist/v1/libs/TinyTextRangeEditor.mjs +424 -0
  35. package/docs/v1/README.md +2 -0
  36. package/docs/v1/libs/TinyClipboard.md +213 -0
  37. package/docs/v1/libs/TinyHtml.md +211 -15
  38. package/docs/v1/libs/TinyTextRangeEditor.md +208 -0
  39. package/package.json +1 -1
@@ -4275,6 +4275,19 @@ const {
4275
4275
  areElsCollRight: TinyHtml_areElsCollRight,
4276
4276
  } = collision_namespaceObject;
4277
4277
 
4278
+ /**
4279
+ * Callback invoked on each animation frame with the current scroll position,
4280
+ * normalized animation time (`0` to `1`), and a completion flag.
4281
+ *
4282
+ * @typedef {(progress: { x: number, y: number, isComplete: boolean, time: number }) => void} OnScrollAnimation
4283
+ */
4284
+
4285
+ /**
4286
+ * A list of supported easing function names for smooth animations.
4287
+ *
4288
+ * @typedef {'linear' | 'easeInQuad' | 'easeOutQuad' | 'easeInOutQuad' | 'easeInCubic' | 'easeOutCubic' | 'easeInOutCubic'} Easings
4289
+ */
4290
+
4278
4291
  /**
4279
4292
  * Represents a raw Node element or an instance of TinyHtml.
4280
4293
  * This type is used to abstract interactions with both plain elements
@@ -4345,6 +4358,21 @@ const {
4345
4358
  * @typedef {Element|Window|Document} ElementAndWinAndDoc
4346
4359
  */
4347
4360
 
4361
+ /**
4362
+ * Represents a raw DOM element with document or an instance of TinyHtml.
4363
+ * This type is used to abstract interactions with both plain elements
4364
+ * and wrapped elements via the TinyHtml class.
4365
+ *
4366
+ * @typedef {ElementWithDoc|TinyHtml} TinyElementWithDoc
4367
+ */
4368
+
4369
+ /**
4370
+ * Represents a value that can be either a DOM Element, or the document object.
4371
+ * Useful for functions that operate generically on measurable targets.
4372
+ *
4373
+ * @typedef {Element|Document} ElementWithDoc
4374
+ */
4375
+
4348
4376
  /**
4349
4377
  * A parameter type used for filtering or matching elements.
4350
4378
  * It can be:
@@ -4364,12 +4392,6 @@ const {
4364
4392
  * @typedef {Window|Element|Document|Text} ConstructorElValues
4365
4393
  */
4366
4394
 
4367
- /**
4368
- * The handler function used in event listeners.
4369
- *
4370
- * @typedef {(e: Event) => any} EventRegistryHandle
4371
- */
4372
-
4373
4395
  /**
4374
4396
  * Options passed to `addEventListener` or `removeEventListener`.
4375
4397
  * Can be a boolean or an object of type `AddEventListenerOptions`.
@@ -4381,7 +4403,7 @@ const {
4381
4403
  * Structure describing a registered event callback and its options.
4382
4404
  *
4383
4405
  * @typedef {Object} EventRegistryItem
4384
- * @property {EventRegistryHandle} handler - The function to be executed when the event is triggered.
4406
+ * @property {EventListenerOrEventListenerObject|null} handler - The function to be executed when the event is triggered.
4385
4407
  * @property {EventRegistryOptions} [options] - Optional configuration passed to the listener.
4386
4408
  */
4387
4409
 
@@ -4940,9 +4962,9 @@ class TinyHtml_TinyHtml {
4940
4962
  * Ensures the input is returned as an array.
4941
4963
  * Useful to normalize operations across multiple or single element/window/document elements.
4942
4964
  *
4943
- * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/window element or array of html elements.
4965
+ * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/document/window element or array of html elements.
4944
4966
  * @param {string} where - The method or context name where validation is being called.
4945
- * @returns {ElementAndWindow[]} - Always returns an array of element/window elements.
4967
+ * @returns {ElementAndWindow[]} - Always returns an array of element/document/window elements.
4946
4968
  * @readonly
4947
4969
  */
4948
4970
  static _preElemsAndWinAndDoc(elems, where) {
@@ -4959,9 +4981,9 @@ class TinyHtml_TinyHtml {
4959
4981
  * Ensures the input is returned as an single element/window/document element.
4960
4982
  * Useful to normalize operations across multiple or single element/window/document elements.
4961
4983
  *
4962
- * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/window element or array of html elements.
4984
+ * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/document/window element or array of html elements.
4963
4985
  * @param {string} where - The method or context name where validation is being called.
4964
- * @returns {ElementAndWindow} - Always returns an single element/window element.
4986
+ * @returns {ElementAndWindow} - Always returns an single element/document/window element.
4965
4987
  * @readonly
4966
4988
  */
4967
4989
  static _preElemAndWinAndDoc(elems, where) {
@@ -4975,6 +4997,32 @@ class TinyHtml_TinyHtml {
4975
4997
  return result;
4976
4998
  }
4977
4999
 
5000
+ /**
5001
+ * Ensures the input is returned as an array.
5002
+ * Useful to normalize operations across multiple or single element with document elements.
5003
+ *
5004
+ * @param {TinyElementWithDoc|TinyElementWithDoc[]} elems - A single element with document element or array of html elements.
5005
+ * @param {string} where - The method or context name where validation is being called.
5006
+ * @returns {ElementWithDoc[]} - Always returns an array of element with document elements.
5007
+ * @readonly
5008
+ */
5009
+ static _preElemsWithDoc(elems, where) {
5010
+ return TinyHtml_TinyHtml._preElemsTemplate(elems, where, [Element, Document], ['Element', 'Document']);
5011
+ }
5012
+
5013
+ /**
5014
+ * Ensures the input is returned as an single element with document element.
5015
+ * Useful to normalize operations across multiple or single element with document elements.
5016
+ *
5017
+ * @param {TinyElementWithDoc|TinyElementWithDoc[]} elems - A single element/window element or array of html elements.
5018
+ * @param {string} where - The method or context name where validation is being called.
5019
+ * @returns {ElementWithDoc} - Always returns an single element/window element.
5020
+ * @readonly
5021
+ */
5022
+ static _preElemWithDoc(elems, where) {
5023
+ return TinyHtml_TinyHtml._preElemTemplate(elems, where, [Element, Document], ['Element', 'Document']);
5024
+ }
5025
+
4978
5026
  /**
4979
5027
  * Normalizes and converts one or more DOM elements (or TinyHtml instances)
4980
5028
  * into an array of `TinyHtml` instances.
@@ -6683,7 +6731,7 @@ class TinyHtml_TinyHtml {
6683
6731
  */
6684
6732
  static setWinScrollTop(value) {
6685
6733
  if (typeof value !== 'number') throw new TypeError('The value must be a number.');
6686
- window.scrollTo({ top: value });
6734
+ TinyHtml_TinyHtml.setScrollTop(window, value);
6687
6735
  }
6688
6736
 
6689
6737
  /**
@@ -6692,7 +6740,7 @@ class TinyHtml_TinyHtml {
6692
6740
  */
6693
6741
  static setWinScrollLeft(value) {
6694
6742
  if (typeof value !== 'number') throw new TypeError('The value must be a number.');
6695
- window.scrollTo({ left: value });
6743
+ TinyHtml_TinyHtml.setScrollLeft(window, value);
6696
6744
  }
6697
6745
 
6698
6746
  /**
@@ -7009,6 +7057,30 @@ class TinyHtml_TinyHtml {
7009
7057
 
7010
7058
  //////////////////////////////////////////////////
7011
7059
 
7060
+ /**
7061
+ * Applies an animation to one or multiple TinyElement instances.
7062
+ *
7063
+ * @param {TinyElement|TinyElement[]} el - A single TinyElement or an array of TinyElements to animate.
7064
+ * @param {Keyframe[] | PropertyIndexedKeyframes | null} keyframes - The keyframes used to define the animation.
7065
+ * @param {number | KeyframeAnimationOptions} [ops] - Timing or configuration options for the animation.
7066
+ * @returns {TinyElement|TinyElement[]}
7067
+ */
7068
+ static animate(el, keyframes, ops) {
7069
+ TinyHtml_TinyHtml._preElems(el, 'animate').forEach((elem) => elem.animate(keyframes, ops));
7070
+ return el;
7071
+ }
7072
+
7073
+ /**
7074
+ * Applies an animation to one or multiple TinyElement instances.
7075
+ *
7076
+ * @param {Keyframe[] | PropertyIndexedKeyframes | null} keyframes - The keyframes used to define the animation.
7077
+ * @param {number | KeyframeAnimationOptions} [ops] - Timing or configuration options for the animation.
7078
+ * @returns {TinyElement|TinyElement[]}
7079
+ */
7080
+ animate(keyframes, ops) {
7081
+ return TinyHtml_TinyHtml.animate(this, keyframes, ops);
7082
+ }
7083
+
7012
7084
  /**
7013
7085
  * Gets the offset of the element relative to the document.
7014
7086
  * @param {TinyElement} el - Target element.
@@ -7164,26 +7236,147 @@ class TinyHtml_TinyHtml {
7164
7236
  }
7165
7237
 
7166
7238
  /**
7167
- * Sets the vertical scroll position.
7168
- * @param {TinyElementAndWindow|TinyElementAndWindow[]} el - Element or window.
7169
- * @param {number} value - Scroll top value.
7170
- * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
7239
+ * Collection of easing functions used for scroll and animation calculations.
7240
+ * Each function receives a normalized time value (`t` from 0 to 1) and returns the eased progress.
7241
+ *
7242
+ * @type {Record<string, (t: number) => number>}
7171
7243
  */
7172
- static setScrollTop(el, value) {
7173
- if (typeof value !== 'number') throw new TypeError('ScrollTop value must be a number.');
7174
- TinyHtml_TinyHtml._preElemsAndWindow(el, 'setScrollTop').forEach((elem) => {
7175
- if (TinyHtml_TinyHtml.isWindow(elem)) {
7176
- elem.scrollTo(elem.pageXOffset, value);
7244
+ static easings = {
7245
+ linear: (t) => t,
7246
+ easeInQuad: (t) => t * t,
7247
+ easeOutQuad: (t) => t * (2 - t),
7248
+ easeInOutQuad: (t) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t),
7249
+ easeInCubic: (t) => t * t * t,
7250
+ easeOutCubic: (t) => --t * t * t + 1,
7251
+ easeInOutCubic: (t) => (t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1),
7252
+ };
7253
+
7254
+ /**
7255
+ * Smoothly scrolls one or more elements (or the window) to the specified X and Y coordinates
7256
+ * using a custom duration and easing function.
7257
+ *
7258
+ * If `duration` or a valid `easing` is not provided, the scroll will be performed immediately.
7259
+ *
7260
+ * @param {TinyElementAndWindow | TinyElementAndWindow[]} el - A single element, array of elements, or the window to scroll.
7261
+ * @param {Object} [settings={}] - Configuration object for the scroll animation.
7262
+ * @param {number} [settings.targetX] - The horizontal scroll target in pixels.
7263
+ * @param {number} [settings.targetY] - The vertical scroll target in pixels.
7264
+ * @param {number} [settings.duration] - The duration of the animation in milliseconds.
7265
+ * @param {Easings} [settings.easing] - The easing function name to use for the scroll animation.
7266
+ * @param {OnScrollAnimation} [settings.onAnimation] - Optional callback invoked on each animation
7267
+ * frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag.
7268
+ * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
7269
+ * @throws {TypeError} If `el` is not a valid element, array, or window.
7270
+ * @throws {TypeError} If `targetX` or `targetY` is defined but not a number.
7271
+ * @throws {TypeError} If `duration` is defined but not a number.
7272
+ * @throws {TypeError} If `easing` is defined but not a valid easing function name.
7273
+ * @throws {TypeError} If `onAnimation` is defined but not a function.
7274
+ */
7275
+ static scrollToXY(el, { targetX, targetY, duration, easing, onAnimation } = {}) {
7276
+ if (targetX !== undefined && typeof targetX !== 'number')
7277
+ throw new TypeError('`targetX` must be a number if provided.');
7278
+ if (targetY !== undefined && typeof targetY !== 'number')
7279
+ throw new TypeError('`targetY` must be a number if provided.');
7280
+ if (duration !== undefined && typeof duration !== 'number')
7281
+ throw new TypeError('`duration` must be a number if provided.');
7282
+ if (easing !== undefined && typeof easing !== 'string')
7283
+ throw new TypeError('`easing` must be a string if provided.');
7284
+ if (easing !== undefined && typeof TinyHtml_TinyHtml.easings[easing] !== 'function')
7285
+ throw new TypeError(`Unknown easing function: "${easing}".`);
7286
+ if (onAnimation !== undefined && typeof onAnimation !== 'function')
7287
+ throw new TypeError('`onAnimation` must be a function if provided.');
7288
+
7289
+ /**
7290
+ * Performs an instant scroll to the given coordinates.
7291
+ *
7292
+ * @param {ElementAndWindow} elem - The element or window to scroll.
7293
+ * @param {number} newX - The final horizontal scroll position.
7294
+ * @param {number} newY - The final vertical scroll position.
7295
+ * @param {number} time - Normalized progress value.
7296
+ */
7297
+ const executeScroll = (elem, newX, newY, time) => {
7298
+ if (elem instanceof Window) {
7299
+ window.scrollTo(newX, newY);
7177
7300
  } else if (elem.nodeType === 9) {
7178
7301
  // @ts-ignore
7179
- elem.defaultView.scrollTo(elem.defaultView.pageXOffset, value);
7302
+ elem.defaultView.scrollTo(newX, newY);
7180
7303
  } else {
7181
- elem.scrollTop = value;
7304
+ const startX = elem instanceof Window ? window.scrollX : elem.scrollLeft;
7305
+ const startY = elem instanceof Window ? window.scrollY : elem.scrollTop;
7306
+ if (startX !== newX) elem.scrollLeft = newX;
7307
+ if (startY !== newY) elem.scrollTop = newY;
7182
7308
  }
7309
+ if (typeof onAnimation === 'function')
7310
+ onAnimation({ x: newX, y: newY, isComplete: time >= 1, time });
7311
+ };
7312
+
7313
+ TinyHtml_TinyHtml._preElemsAndWindow(el, 'scrollToXY').forEach((elem) => {
7314
+ const startX = elem instanceof Window ? window.scrollX : elem.scrollLeft;
7315
+ const startY = elem instanceof Window ? window.scrollY : elem.scrollTop;
7316
+ const targX = targetX ?? startX;
7317
+ const targY = targetY ?? startY;
7318
+
7319
+ const changeX = targX - startX;
7320
+ const changeY = targY - startY;
7321
+
7322
+ const ease = (typeof easing === 'string' && TinyHtml_TinyHtml.easings[easing]) || null;
7323
+ if (typeof duration !== 'number' || typeof ease !== 'function')
7324
+ return executeScroll(elem, targX, targY, 1);
7325
+ const startTime = performance.now();
7326
+ const dur = duration ?? 0;
7327
+
7328
+ /**
7329
+ * Animates the scroll position based on easing and time.
7330
+ *
7331
+ * @param {number} currentTime - Timestamp provided by requestAnimationFrame.
7332
+ */
7333
+ function animateScroll(currentTime) {
7334
+ if (typeof ease !== 'function') return;
7335
+ const time = Math.min(1, (currentTime - startTime) / dur);
7336
+ const easedTime = ease(time);
7337
+
7338
+ const newX = startX + changeX * easedTime;
7339
+ const newY = startY + changeY * easedTime;
7340
+ executeScroll(elem, newX, newY, time);
7341
+
7342
+ if (time < 1) requestAnimationFrame(animateScroll);
7343
+ }
7344
+
7345
+ requestAnimationFrame(animateScroll);
7183
7346
  });
7184
7347
  return el;
7185
7348
  }
7186
7349
 
7350
+ /**
7351
+ * Smoothly scrolls one or more elements (or the window) to the specified X and Y coordinates
7352
+ * using a custom duration and easing function.
7353
+ *
7354
+ * If `duration` or a valid `easing` is not provided, the scroll will be performed immediately.
7355
+ *
7356
+ * @param {Object} [settings={}] - Configuration object for the scroll animation.
7357
+ * @param {number} [settings.targetX] - The horizontal scroll target in pixels.
7358
+ * @param {number} [settings.targetY] - The vertical scroll target in pixels.
7359
+ * @param {number} [settings.duration] - The duration of the animation in milliseconds.
7360
+ * @param {Easings} [settings.easing] - The easing function name to use for the scroll animation.
7361
+ * @param {OnScrollAnimation} [settings.onAnimation] - Optional callback invoked on each animation
7362
+ * frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag.
7363
+ * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
7364
+ */
7365
+ scrollToXY({ targetX, targetY, duration, easing, onAnimation } = {}) {
7366
+ return TinyHtml_TinyHtml.scrollToXY(this, { targetX, targetY, duration, easing, onAnimation });
7367
+ }
7368
+
7369
+ /**
7370
+ * Sets the vertical scroll position.
7371
+ * @param {TinyElementAndWindow|TinyElementAndWindow[]} el - Element or window.
7372
+ * @param {number} value - Scroll top value.
7373
+ * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
7374
+ */
7375
+ static setScrollTop(el, value) {
7376
+ if (typeof value !== 'number') throw new TypeError('ScrollTop value must be a number.');
7377
+ return TinyHtml_TinyHtml.scrollToXY(el, { targetY: value });
7378
+ }
7379
+
7187
7380
  /**
7188
7381
  * Sets the vertical scroll position.
7189
7382
  * @param {number} value - Scroll top value.
@@ -7201,17 +7394,7 @@ class TinyHtml_TinyHtml {
7201
7394
  */
7202
7395
  static setScrollLeft(el, value) {
7203
7396
  if (typeof value !== 'number') throw new TypeError('ScrollLeft value must be a number.');
7204
- TinyHtml_TinyHtml._preElemsAndWindow(el, 'setScrollLeft').forEach((elem) => {
7205
- if (TinyHtml_TinyHtml.isWindow(elem)) {
7206
- elem.scrollTo(value, elem.pageYOffset);
7207
- } else if (elem.nodeType === 9) {
7208
- // @ts-ignore
7209
- elem.defaultView.scrollTo(value, elem.defaultView.pageYOffset);
7210
- } else {
7211
- elem.scrollLeft = value;
7212
- }
7213
- });
7214
- return el;
7397
+ return TinyHtml_TinyHtml.scrollToXY(el, { targetX: value });
7215
7398
  }
7216
7399
 
7217
7400
  /**
@@ -8099,12 +8282,120 @@ class TinyHtml_TinyHtml {
8099
8282
 
8100
8283
  ////////////////////////////////////////////
8101
8284
 
8285
+ /**
8286
+ * Registers a listener for the "paste" event to extract files and text from the clipboard (e.g., when the user presses Ctrl+V).
8287
+ *
8288
+ * This method allows reacting to pasted content by providing separate callbacks for files and plain text.
8289
+ * Useful for building file upload areas, rich-text editors, or input enhancements.
8290
+ *
8291
+ * @param {TinyElementWithDoc|TinyElementWithDoc[]} el - The target element(s) where the "paste" event will be listened.
8292
+ * @param {Object} [settings={}] - Optional callbacks to handle clipboard content.
8293
+ * @param {(data: DataTransferItem, file: File) => void} [settings.onFilePaste] - Called for each file pasted from the clipboard (e.g., images).
8294
+ * @param {(data: DataTransferItem, text: string) => void} [settings.onTextPaste] - Called when plain text is pasted from the clipboard.
8295
+ * @returns {EventListenerOrEventListenerObject} The internal "paste" event handler used.
8296
+ */
8297
+ static listenForPaste(el, { onFilePaste, onTextPaste } = {}) {
8298
+ if (typeof onFilePaste !== 'undefined' && typeof onFilePaste !== 'function')
8299
+ throw new TypeError('onFilePaste must be a function.');
8300
+ if (typeof onTextPaste !== 'undefined' && typeof onTextPaste !== 'function')
8301
+ throw new TypeError('onTextPaste must be a function.');
8302
+
8303
+ /** @type {EventListenerOrEventListenerObject} */
8304
+ const pasteEvent = (event) => {
8305
+ if (!(event instanceof ClipboardEvent)) return;
8306
+ const items = event.clipboardData?.items || [];
8307
+ for (const item of items) {
8308
+ if (item.kind === 'file') {
8309
+ if (typeof onFilePaste === 'function') {
8310
+ const file = item.getAsFile();
8311
+ if (file) onFilePaste(item, file);
8312
+ }
8313
+ } else if (item.kind === 'string') {
8314
+ if (typeof onTextPaste === 'function')
8315
+ item.getAsString((text) => onTextPaste(item, text));
8316
+ }
8317
+ }
8318
+ };
8319
+
8320
+ TinyHtml_TinyHtml._preElemsWithDoc(el, 'listenForPaste').forEach((elem) =>
8321
+ TinyHtml_TinyHtml.on(elem, 'paste', pasteEvent),
8322
+ );
8323
+ return pasteEvent;
8324
+ }
8325
+
8326
+ /**
8327
+ * Registers a listener for the "paste" event to extract files and text from the clipboard (e.g., when the user presses Ctrl+V).
8328
+ *
8329
+ * This method allows reacting to pasted content by providing separate callbacks for files and plain text.
8330
+ * Useful for building file upload areas, rich-text editors, or input enhancements.
8331
+ *
8332
+ * @param {Object} [settings={}] - Optional callbacks to handle clipboard content.
8333
+ * @param {(data: DataTransferItem, file: File) => void} [settings.onFilePaste] - Called for each file pasted from the clipboard (e.g., images).
8334
+ * @param {(data: DataTransferItem, text: string) => void} [settings.onTextPaste] - Called when plain text is pasted from the clipboard.
8335
+ * @returns {EventListenerOrEventListenerObject} The internal "paste" event handler used.
8336
+ */
8337
+ listenForPaste({ onFilePaste, onTextPaste } = {}) {
8338
+ return TinyHtml_TinyHtml.listenForPaste(this, { onFilePaste, onTextPaste });
8339
+ }
8340
+
8341
+ /**
8342
+ * Checks if the element has a listener for a specific event.
8343
+ *
8344
+ * @param {TinyEventTarget} el - The element to check.
8345
+ * @param {string} event - The event name to check.
8346
+ * @returns {boolean}
8347
+ */
8348
+ static hasEventListener(el, event) {
8349
+ const elem = TinyHtml_TinyHtml._preEventTargetElem(el, 'hasEventListener');
8350
+ if (!__eventRegistry.has(elem)) return false;
8351
+ const events = __eventRegistry.get(elem);
8352
+ return !!(events && Array.isArray(events[event]) && events[event].length > 0);
8353
+ }
8354
+
8355
+ /**
8356
+ * Checks if the element has a listener for a specific event.
8357
+ *
8358
+ * @param {string} event - The event name to check.
8359
+ * @returns {boolean}
8360
+ */
8361
+ hasEventListener(event) {
8362
+ return TinyHtml_TinyHtml.hasEventListener(this, event);
8363
+ }
8364
+
8365
+ /**
8366
+ * Checks if the element has the exact handler registered for a specific event.
8367
+ *
8368
+ * @param {TinyEventTarget} el - The element to check.
8369
+ * @param {string} event - The event name to check.
8370
+ * @param {EventListenerOrEventListenerObject} handler - The handler function to check.
8371
+ * @returns {boolean}
8372
+ */
8373
+ static hasExactEventListener(el, event, handler) {
8374
+ const elem = TinyHtml_TinyHtml._preEventTargetElem(el, 'hasExactEventListener');
8375
+ if (typeof handler !== 'function') throw new TypeError('The "handler" must be a function.');
8376
+ if (!__eventRegistry.has(elem)) return false;
8377
+ const events = __eventRegistry.get(elem);
8378
+ if (!events || !Array.isArray(events[event])) return false;
8379
+ return events[event].some((item) => item.handler === handler);
8380
+ }
8381
+
8382
+ /**
8383
+ * Checks if the element has the exact handler registered for a specific event.
8384
+ *
8385
+ * @param {string} event - The event name to check.
8386
+ * @param {EventListenerOrEventListenerObject} handler - The handler function to check.
8387
+ * @returns {boolean}
8388
+ */
8389
+ hasExactEventListener(event, handler) {
8390
+ return TinyHtml_TinyHtml.hasExactEventListener(this, event, handler);
8391
+ }
8392
+
8102
8393
  /**
8103
8394
  * Registers an event listener on the specified element.
8104
8395
  *
8105
8396
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target to listen on.
8106
8397
  * @param {string} event - The event type (e.g. 'click', 'keydown').
8107
- * @param {EventRegistryHandle} handler - The callback function to run on event.
8398
+ * @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
8108
8399
  * @param {EventRegistryOptions} [options] - Optional event listener options.
8109
8400
  * @returns {TinyEventTarget|TinyEventTarget[]}
8110
8401
  */
@@ -8126,7 +8417,7 @@ class TinyHtml_TinyHtml {
8126
8417
  * Registers an event listener on the specified element.
8127
8418
  *
8128
8419
  * @param {string} event - The event type (e.g. 'click', 'keydown').
8129
- * @param {EventRegistryHandle} handler - The callback function to run on event.
8420
+ * @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
8130
8421
  * @param {EventRegistryOptions} [options] - Optional event listener options.
8131
8422
  * @returns {TinyEventTarget|TinyEventTarget[]}
8132
8423
  */
@@ -8139,17 +8430,17 @@ class TinyHtml_TinyHtml {
8139
8430
  *
8140
8431
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target to listen on.
8141
8432
  * @param {string} event - The event type (e.g. 'click', 'keydown').
8142
- * @param {EventRegistryHandle} handler - The callback function to run on event.
8433
+ * @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
8143
8434
  * @param {EventRegistryOptions} [options={}] - Optional event listener options.
8144
8435
  * @returns {TinyEventTarget|TinyEventTarget[]}
8145
8436
  */
8146
8437
  static once(el, event, handler, options = {}) {
8147
8438
  if (typeof event !== 'string') throw new TypeError('The event name must be a string.');
8148
8439
  TinyHtml_TinyHtml._preEventTargetElems(el, 'once').forEach((elem) => {
8149
- /** @type {EventRegistryHandle} e */
8440
+ /** @type {EventListenerOrEventListenerObject} */
8150
8441
  const wrapped = (e) => {
8151
8442
  TinyHtml_TinyHtml.off(elem, event, wrapped);
8152
- handler(e);
8443
+ if (typeof handler === 'function') handler(e);
8153
8444
  };
8154
8445
 
8155
8446
  TinyHtml_TinyHtml.on(
@@ -8166,7 +8457,7 @@ class TinyHtml_TinyHtml {
8166
8457
  * Registers an event listener that runs only once, then is removed.
8167
8458
  *
8168
8459
  * @param {string} event - The event type (e.g. 'click', 'keydown').
8169
- * @param {EventRegistryHandle} handler - The callback function to run on event.
8460
+ * @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
8170
8461
  * @param {EventRegistryOptions} [options={}] - Optional event listener options.
8171
8462
  * @returns {TinyEventTarget|TinyEventTarget[]}
8172
8463
  */
@@ -8179,7 +8470,7 @@ class TinyHtml_TinyHtml {
8179
8470
  *
8180
8471
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
8181
8472
  * @param {string} event - The event type.
8182
- * @param {EventRegistryHandle} handler - The function originally bound to the event.
8473
+ * @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
8183
8474
  * @param {boolean|EventListenerOptions} [options] - Optional listener options.
8184
8475
  * @returns {TinyEventTarget|TinyEventTarget[]}
8185
8476
  */
@@ -8201,7 +8492,7 @@ class TinyHtml_TinyHtml {
8201
8492
  * Removes a specific event listener from an element.
8202
8493
  *
8203
8494
  * @param {string} event - The event type.
8204
- * @param {EventRegistryHandle} handler - The function originally bound to the event.
8495
+ * @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
8205
8496
  * @param {boolean|EventListenerOptions} [options] - Optional listener options.
8206
8497
  * @returns {TinyEventTarget|TinyEventTarget[]}
8207
8498
  */
@@ -8244,7 +8535,7 @@ class TinyHtml_TinyHtml {
8244
8535
  * Removes all event listeners of all types from the element.
8245
8536
  *
8246
8537
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
8247
- * @param {((handler: EventListenerOrEventListenerObject, event: string) => boolean)|null} [filterFn=null] -
8538
+ * @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
8248
8539
  * Optional filter function to selectively remove specific handlers.
8249
8540
  * @returns {TinyEventTarget|TinyEventTarget[]}
8250
8541
  */
@@ -8271,7 +8562,7 @@ class TinyHtml_TinyHtml {
8271
8562
  /**
8272
8563
  * Removes all event listeners of all types from the element.
8273
8564
  *
8274
- * @param {((handler: EventListenerOrEventListenerObject, event: string) => boolean)|null} [filterFn=null] -
8565
+ * @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
8275
8566
  * Optional filter function to selectively remove specific handlers.
8276
8567
  * @returns {TinyEventTarget|TinyEventTarget[]}
8277
8568
  */
@@ -11822,6 +12113,8 @@ class TinySmartScroller {
11822
12113
 
11823
12114
 
11824
12115
 
12116
+
12117
+
11825
12118
 
11826
12119
 
11827
12120