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
@@ -3699,6 +3699,19 @@ const {
3699
3699
  areElsCollRight: TinyHtml_areElsCollRight,
3700
3700
  } = collision_namespaceObject;
3701
3701
 
3702
+ /**
3703
+ * Callback invoked on each animation frame with the current scroll position,
3704
+ * normalized animation time (`0` to `1`), and a completion flag.
3705
+ *
3706
+ * @typedef {(progress: { x: number, y: number, isComplete: boolean, time: number }) => void} OnScrollAnimation
3707
+ */
3708
+
3709
+ /**
3710
+ * A list of supported easing function names for smooth animations.
3711
+ *
3712
+ * @typedef {'linear' | 'easeInQuad' | 'easeOutQuad' | 'easeInOutQuad' | 'easeInCubic' | 'easeOutCubic' | 'easeInOutCubic'} Easings
3713
+ */
3714
+
3702
3715
  /**
3703
3716
  * Represents a raw Node element or an instance of TinyHtml.
3704
3717
  * This type is used to abstract interactions with both plain elements
@@ -3769,6 +3782,21 @@ const {
3769
3782
  * @typedef {Element|Window|Document} ElementAndWinAndDoc
3770
3783
  */
3771
3784
 
3785
+ /**
3786
+ * Represents a raw DOM element with document or an instance of TinyHtml.
3787
+ * This type is used to abstract interactions with both plain elements
3788
+ * and wrapped elements via the TinyHtml class.
3789
+ *
3790
+ * @typedef {ElementWithDoc|TinyHtml} TinyElementWithDoc
3791
+ */
3792
+
3793
+ /**
3794
+ * Represents a value that can be either a DOM Element, or the document object.
3795
+ * Useful for functions that operate generically on measurable targets.
3796
+ *
3797
+ * @typedef {Element|Document} ElementWithDoc
3798
+ */
3799
+
3772
3800
  /**
3773
3801
  * A parameter type used for filtering or matching elements.
3774
3802
  * It can be:
@@ -3788,12 +3816,6 @@ const {
3788
3816
  * @typedef {Window|Element|Document|Text} ConstructorElValues
3789
3817
  */
3790
3818
 
3791
- /**
3792
- * The handler function used in event listeners.
3793
- *
3794
- * @typedef {(e: Event) => any} EventRegistryHandle
3795
- */
3796
-
3797
3819
  /**
3798
3820
  * Options passed to `addEventListener` or `removeEventListener`.
3799
3821
  * Can be a boolean or an object of type `AddEventListenerOptions`.
@@ -3805,7 +3827,7 @@ const {
3805
3827
  * Structure describing a registered event callback and its options.
3806
3828
  *
3807
3829
  * @typedef {Object} EventRegistryItem
3808
- * @property {EventRegistryHandle} handler - The function to be executed when the event is triggered.
3830
+ * @property {EventListenerOrEventListenerObject|null} handler - The function to be executed when the event is triggered.
3809
3831
  * @property {EventRegistryOptions} [options] - Optional configuration passed to the listener.
3810
3832
  */
3811
3833
 
@@ -4364,9 +4386,9 @@ class TinyHtml_TinyHtml {
4364
4386
  * Ensures the input is returned as an array.
4365
4387
  * Useful to normalize operations across multiple or single element/window/document elements.
4366
4388
  *
4367
- * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/window element or array of html elements.
4389
+ * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/document/window element or array of html elements.
4368
4390
  * @param {string} where - The method or context name where validation is being called.
4369
- * @returns {ElementAndWindow[]} - Always returns an array of element/window elements.
4391
+ * @returns {ElementAndWindow[]} - Always returns an array of element/document/window elements.
4370
4392
  * @readonly
4371
4393
  */
4372
4394
  static _preElemsAndWinAndDoc(elems, where) {
@@ -4383,9 +4405,9 @@ class TinyHtml_TinyHtml {
4383
4405
  * Ensures the input is returned as an single element/window/document element.
4384
4406
  * Useful to normalize operations across multiple or single element/window/document elements.
4385
4407
  *
4386
- * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/window element or array of html elements.
4408
+ * @param {TinyElementAndWinAndDoc|TinyElementAndWinAndDoc[]} elems - A single element/document/window element or array of html elements.
4387
4409
  * @param {string} where - The method or context name where validation is being called.
4388
- * @returns {ElementAndWindow} - Always returns an single element/window element.
4410
+ * @returns {ElementAndWindow} - Always returns an single element/document/window element.
4389
4411
  * @readonly
4390
4412
  */
4391
4413
  static _preElemAndWinAndDoc(elems, where) {
@@ -4399,6 +4421,32 @@ class TinyHtml_TinyHtml {
4399
4421
  return result;
4400
4422
  }
4401
4423
 
4424
+ /**
4425
+ * Ensures the input is returned as an array.
4426
+ * Useful to normalize operations across multiple or single element with document elements.
4427
+ *
4428
+ * @param {TinyElementWithDoc|TinyElementWithDoc[]} elems - A single element with document element or array of html elements.
4429
+ * @param {string} where - The method or context name where validation is being called.
4430
+ * @returns {ElementWithDoc[]} - Always returns an array of element with document elements.
4431
+ * @readonly
4432
+ */
4433
+ static _preElemsWithDoc(elems, where) {
4434
+ return TinyHtml_TinyHtml._preElemsTemplate(elems, where, [Element, Document], ['Element', 'Document']);
4435
+ }
4436
+
4437
+ /**
4438
+ * Ensures the input is returned as an single element with document element.
4439
+ * Useful to normalize operations across multiple or single element with document elements.
4440
+ *
4441
+ * @param {TinyElementWithDoc|TinyElementWithDoc[]} elems - A single element/window element or array of html elements.
4442
+ * @param {string} where - The method or context name where validation is being called.
4443
+ * @returns {ElementWithDoc} - Always returns an single element/window element.
4444
+ * @readonly
4445
+ */
4446
+ static _preElemWithDoc(elems, where) {
4447
+ return TinyHtml_TinyHtml._preElemTemplate(elems, where, [Element, Document], ['Element', 'Document']);
4448
+ }
4449
+
4402
4450
  /**
4403
4451
  * Normalizes and converts one or more DOM elements (or TinyHtml instances)
4404
4452
  * into an array of `TinyHtml` instances.
@@ -6107,7 +6155,7 @@ class TinyHtml_TinyHtml {
6107
6155
  */
6108
6156
  static setWinScrollTop(value) {
6109
6157
  if (typeof value !== 'number') throw new TypeError('The value must be a number.');
6110
- window.scrollTo({ top: value });
6158
+ TinyHtml_TinyHtml.setScrollTop(window, value);
6111
6159
  }
6112
6160
 
6113
6161
  /**
@@ -6116,7 +6164,7 @@ class TinyHtml_TinyHtml {
6116
6164
  */
6117
6165
  static setWinScrollLeft(value) {
6118
6166
  if (typeof value !== 'number') throw new TypeError('The value must be a number.');
6119
- window.scrollTo({ left: value });
6167
+ TinyHtml_TinyHtml.setScrollLeft(window, value);
6120
6168
  }
6121
6169
 
6122
6170
  /**
@@ -6433,6 +6481,30 @@ class TinyHtml_TinyHtml {
6433
6481
 
6434
6482
  //////////////////////////////////////////////////
6435
6483
 
6484
+ /**
6485
+ * Applies an animation to one or multiple TinyElement instances.
6486
+ *
6487
+ * @param {TinyElement|TinyElement[]} el - A single TinyElement or an array of TinyElements to animate.
6488
+ * @param {Keyframe[] | PropertyIndexedKeyframes | null} keyframes - The keyframes used to define the animation.
6489
+ * @param {number | KeyframeAnimationOptions} [ops] - Timing or configuration options for the animation.
6490
+ * @returns {TinyElement|TinyElement[]}
6491
+ */
6492
+ static animate(el, keyframes, ops) {
6493
+ TinyHtml_TinyHtml._preElems(el, 'animate').forEach((elem) => elem.animate(keyframes, ops));
6494
+ return el;
6495
+ }
6496
+
6497
+ /**
6498
+ * Applies an animation to one or multiple TinyElement instances.
6499
+ *
6500
+ * @param {Keyframe[] | PropertyIndexedKeyframes | null} keyframes - The keyframes used to define the animation.
6501
+ * @param {number | KeyframeAnimationOptions} [ops] - Timing or configuration options for the animation.
6502
+ * @returns {TinyElement|TinyElement[]}
6503
+ */
6504
+ animate(keyframes, ops) {
6505
+ return TinyHtml_TinyHtml.animate(this, keyframes, ops);
6506
+ }
6507
+
6436
6508
  /**
6437
6509
  * Gets the offset of the element relative to the document.
6438
6510
  * @param {TinyElement} el - Target element.
@@ -6588,26 +6660,147 @@ class TinyHtml_TinyHtml {
6588
6660
  }
6589
6661
 
6590
6662
  /**
6591
- * Sets the vertical scroll position.
6592
- * @param {TinyElementAndWindow|TinyElementAndWindow[]} el - Element or window.
6593
- * @param {number} value - Scroll top value.
6594
- * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
6663
+ * Collection of easing functions used for scroll and animation calculations.
6664
+ * Each function receives a normalized time value (`t` from 0 to 1) and returns the eased progress.
6665
+ *
6666
+ * @type {Record<string, (t: number) => number>}
6595
6667
  */
6596
- static setScrollTop(el, value) {
6597
- if (typeof value !== 'number') throw new TypeError('ScrollTop value must be a number.');
6598
- TinyHtml_TinyHtml._preElemsAndWindow(el, 'setScrollTop').forEach((elem) => {
6599
- if (TinyHtml_TinyHtml.isWindow(elem)) {
6600
- elem.scrollTo(elem.pageXOffset, value);
6668
+ static easings = {
6669
+ linear: (t) => t,
6670
+ easeInQuad: (t) => t * t,
6671
+ easeOutQuad: (t) => t * (2 - t),
6672
+ easeInOutQuad: (t) => (t < 0.5 ? 2 * t * t : -1 + (4 - 2 * t) * t),
6673
+ easeInCubic: (t) => t * t * t,
6674
+ easeOutCubic: (t) => --t * t * t + 1,
6675
+ easeInOutCubic: (t) => (t < 0.5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1),
6676
+ };
6677
+
6678
+ /**
6679
+ * Smoothly scrolls one or more elements (or the window) to the specified X and Y coordinates
6680
+ * using a custom duration and easing function.
6681
+ *
6682
+ * If `duration` or a valid `easing` is not provided, the scroll will be performed immediately.
6683
+ *
6684
+ * @param {TinyElementAndWindow | TinyElementAndWindow[]} el - A single element, array of elements, or the window to scroll.
6685
+ * @param {Object} [settings={}] - Configuration object for the scroll animation.
6686
+ * @param {number} [settings.targetX] - The horizontal scroll target in pixels.
6687
+ * @param {number} [settings.targetY] - The vertical scroll target in pixels.
6688
+ * @param {number} [settings.duration] - The duration of the animation in milliseconds.
6689
+ * @param {Easings} [settings.easing] - The easing function name to use for the scroll animation.
6690
+ * @param {OnScrollAnimation} [settings.onAnimation] - Optional callback invoked on each animation
6691
+ * frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag.
6692
+ * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
6693
+ * @throws {TypeError} If `el` is not a valid element, array, or window.
6694
+ * @throws {TypeError} If `targetX` or `targetY` is defined but not a number.
6695
+ * @throws {TypeError} If `duration` is defined but not a number.
6696
+ * @throws {TypeError} If `easing` is defined but not a valid easing function name.
6697
+ * @throws {TypeError} If `onAnimation` is defined but not a function.
6698
+ */
6699
+ static scrollToXY(el, { targetX, targetY, duration, easing, onAnimation } = {}) {
6700
+ if (targetX !== undefined && typeof targetX !== 'number')
6701
+ throw new TypeError('`targetX` must be a number if provided.');
6702
+ if (targetY !== undefined && typeof targetY !== 'number')
6703
+ throw new TypeError('`targetY` must be a number if provided.');
6704
+ if (duration !== undefined && typeof duration !== 'number')
6705
+ throw new TypeError('`duration` must be a number if provided.');
6706
+ if (easing !== undefined && typeof easing !== 'string')
6707
+ throw new TypeError('`easing` must be a string if provided.');
6708
+ if (easing !== undefined && typeof TinyHtml_TinyHtml.easings[easing] !== 'function')
6709
+ throw new TypeError(`Unknown easing function: "${easing}".`);
6710
+ if (onAnimation !== undefined && typeof onAnimation !== 'function')
6711
+ throw new TypeError('`onAnimation` must be a function if provided.');
6712
+
6713
+ /**
6714
+ * Performs an instant scroll to the given coordinates.
6715
+ *
6716
+ * @param {ElementAndWindow} elem - The element or window to scroll.
6717
+ * @param {number} newX - The final horizontal scroll position.
6718
+ * @param {number} newY - The final vertical scroll position.
6719
+ * @param {number} time - Normalized progress value.
6720
+ */
6721
+ const executeScroll = (elem, newX, newY, time) => {
6722
+ if (elem instanceof Window) {
6723
+ window.scrollTo(newX, newY);
6601
6724
  } else if (elem.nodeType === 9) {
6602
6725
  // @ts-ignore
6603
- elem.defaultView.scrollTo(elem.defaultView.pageXOffset, value);
6726
+ elem.defaultView.scrollTo(newX, newY);
6604
6727
  } else {
6605
- elem.scrollTop = value;
6728
+ const startX = elem instanceof Window ? window.scrollX : elem.scrollLeft;
6729
+ const startY = elem instanceof Window ? window.scrollY : elem.scrollTop;
6730
+ if (startX !== newX) elem.scrollLeft = newX;
6731
+ if (startY !== newY) elem.scrollTop = newY;
6606
6732
  }
6733
+ if (typeof onAnimation === 'function')
6734
+ onAnimation({ x: newX, y: newY, isComplete: time >= 1, time });
6735
+ };
6736
+
6737
+ TinyHtml_TinyHtml._preElemsAndWindow(el, 'scrollToXY').forEach((elem) => {
6738
+ const startX = elem instanceof Window ? window.scrollX : elem.scrollLeft;
6739
+ const startY = elem instanceof Window ? window.scrollY : elem.scrollTop;
6740
+ const targX = targetX ?? startX;
6741
+ const targY = targetY ?? startY;
6742
+
6743
+ const changeX = targX - startX;
6744
+ const changeY = targY - startY;
6745
+
6746
+ const ease = (typeof easing === 'string' && TinyHtml_TinyHtml.easings[easing]) || null;
6747
+ if (typeof duration !== 'number' || typeof ease !== 'function')
6748
+ return executeScroll(elem, targX, targY, 1);
6749
+ const startTime = performance.now();
6750
+ const dur = duration ?? 0;
6751
+
6752
+ /**
6753
+ * Animates the scroll position based on easing and time.
6754
+ *
6755
+ * @param {number} currentTime - Timestamp provided by requestAnimationFrame.
6756
+ */
6757
+ function animateScroll(currentTime) {
6758
+ if (typeof ease !== 'function') return;
6759
+ const time = Math.min(1, (currentTime - startTime) / dur);
6760
+ const easedTime = ease(time);
6761
+
6762
+ const newX = startX + changeX * easedTime;
6763
+ const newY = startY + changeY * easedTime;
6764
+ executeScroll(elem, newX, newY, time);
6765
+
6766
+ if (time < 1) requestAnimationFrame(animateScroll);
6767
+ }
6768
+
6769
+ requestAnimationFrame(animateScroll);
6607
6770
  });
6608
6771
  return el;
6609
6772
  }
6610
6773
 
6774
+ /**
6775
+ * Smoothly scrolls one or more elements (or the window) to the specified X and Y coordinates
6776
+ * using a custom duration and easing function.
6777
+ *
6778
+ * If `duration` or a valid `easing` is not provided, the scroll will be performed immediately.
6779
+ *
6780
+ * @param {Object} [settings={}] - Configuration object for the scroll animation.
6781
+ * @param {number} [settings.targetX] - The horizontal scroll target in pixels.
6782
+ * @param {number} [settings.targetY] - The vertical scroll target in pixels.
6783
+ * @param {number} [settings.duration] - The duration of the animation in milliseconds.
6784
+ * @param {Easings} [settings.easing] - The easing function name to use for the scroll animation.
6785
+ * @param {OnScrollAnimation} [settings.onAnimation] - Optional callback invoked on each animation
6786
+ * frame with the current scroll position, normalized animation time (`0` to `1`), and a completion flag.
6787
+ * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
6788
+ */
6789
+ scrollToXY({ targetX, targetY, duration, easing, onAnimation } = {}) {
6790
+ return TinyHtml_TinyHtml.scrollToXY(this, { targetX, targetY, duration, easing, onAnimation });
6791
+ }
6792
+
6793
+ /**
6794
+ * Sets the vertical scroll position.
6795
+ * @param {TinyElementAndWindow|TinyElementAndWindow[]} el - Element or window.
6796
+ * @param {number} value - Scroll top value.
6797
+ * @returns {TinyElementAndWindow|TinyElementAndWindow[]}
6798
+ */
6799
+ static setScrollTop(el, value) {
6800
+ if (typeof value !== 'number') throw new TypeError('ScrollTop value must be a number.');
6801
+ return TinyHtml_TinyHtml.scrollToXY(el, { targetY: value });
6802
+ }
6803
+
6611
6804
  /**
6612
6805
  * Sets the vertical scroll position.
6613
6806
  * @param {number} value - Scroll top value.
@@ -6625,17 +6818,7 @@ class TinyHtml_TinyHtml {
6625
6818
  */
6626
6819
  static setScrollLeft(el, value) {
6627
6820
  if (typeof value !== 'number') throw new TypeError('ScrollLeft value must be a number.');
6628
- TinyHtml_TinyHtml._preElemsAndWindow(el, 'setScrollLeft').forEach((elem) => {
6629
- if (TinyHtml_TinyHtml.isWindow(elem)) {
6630
- elem.scrollTo(value, elem.pageYOffset);
6631
- } else if (elem.nodeType === 9) {
6632
- // @ts-ignore
6633
- elem.defaultView.scrollTo(value, elem.defaultView.pageYOffset);
6634
- } else {
6635
- elem.scrollLeft = value;
6636
- }
6637
- });
6638
- return el;
6821
+ return TinyHtml_TinyHtml.scrollToXY(el, { targetX: value });
6639
6822
  }
6640
6823
 
6641
6824
  /**
@@ -7523,12 +7706,120 @@ class TinyHtml_TinyHtml {
7523
7706
 
7524
7707
  ////////////////////////////////////////////
7525
7708
 
7709
+ /**
7710
+ * Registers a listener for the "paste" event to extract files and text from the clipboard (e.g., when the user presses Ctrl+V).
7711
+ *
7712
+ * This method allows reacting to pasted content by providing separate callbacks for files and plain text.
7713
+ * Useful for building file upload areas, rich-text editors, or input enhancements.
7714
+ *
7715
+ * @param {TinyElementWithDoc|TinyElementWithDoc[]} el - The target element(s) where the "paste" event will be listened.
7716
+ * @param {Object} [settings={}] - Optional callbacks to handle clipboard content.
7717
+ * @param {(data: DataTransferItem, file: File) => void} [settings.onFilePaste] - Called for each file pasted from the clipboard (e.g., images).
7718
+ * @param {(data: DataTransferItem, text: string) => void} [settings.onTextPaste] - Called when plain text is pasted from the clipboard.
7719
+ * @returns {EventListenerOrEventListenerObject} The internal "paste" event handler used.
7720
+ */
7721
+ static listenForPaste(el, { onFilePaste, onTextPaste } = {}) {
7722
+ if (typeof onFilePaste !== 'undefined' && typeof onFilePaste !== 'function')
7723
+ throw new TypeError('onFilePaste must be a function.');
7724
+ if (typeof onTextPaste !== 'undefined' && typeof onTextPaste !== 'function')
7725
+ throw new TypeError('onTextPaste must be a function.');
7726
+
7727
+ /** @type {EventListenerOrEventListenerObject} */
7728
+ const pasteEvent = (event) => {
7729
+ if (!(event instanceof ClipboardEvent)) return;
7730
+ const items = event.clipboardData?.items || [];
7731
+ for (const item of items) {
7732
+ if (item.kind === 'file') {
7733
+ if (typeof onFilePaste === 'function') {
7734
+ const file = item.getAsFile();
7735
+ if (file) onFilePaste(item, file);
7736
+ }
7737
+ } else if (item.kind === 'string') {
7738
+ if (typeof onTextPaste === 'function')
7739
+ item.getAsString((text) => onTextPaste(item, text));
7740
+ }
7741
+ }
7742
+ };
7743
+
7744
+ TinyHtml_TinyHtml._preElemsWithDoc(el, 'listenForPaste').forEach((elem) =>
7745
+ TinyHtml_TinyHtml.on(elem, 'paste', pasteEvent),
7746
+ );
7747
+ return pasteEvent;
7748
+ }
7749
+
7750
+ /**
7751
+ * Registers a listener for the "paste" event to extract files and text from the clipboard (e.g., when the user presses Ctrl+V).
7752
+ *
7753
+ * This method allows reacting to pasted content by providing separate callbacks for files and plain text.
7754
+ * Useful for building file upload areas, rich-text editors, or input enhancements.
7755
+ *
7756
+ * @param {Object} [settings={}] - Optional callbacks to handle clipboard content.
7757
+ * @param {(data: DataTransferItem, file: File) => void} [settings.onFilePaste] - Called for each file pasted from the clipboard (e.g., images).
7758
+ * @param {(data: DataTransferItem, text: string) => void} [settings.onTextPaste] - Called when plain text is pasted from the clipboard.
7759
+ * @returns {EventListenerOrEventListenerObject} The internal "paste" event handler used.
7760
+ */
7761
+ listenForPaste({ onFilePaste, onTextPaste } = {}) {
7762
+ return TinyHtml_TinyHtml.listenForPaste(this, { onFilePaste, onTextPaste });
7763
+ }
7764
+
7765
+ /**
7766
+ * Checks if the element has a listener for a specific event.
7767
+ *
7768
+ * @param {TinyEventTarget} el - The element to check.
7769
+ * @param {string} event - The event name to check.
7770
+ * @returns {boolean}
7771
+ */
7772
+ static hasEventListener(el, event) {
7773
+ const elem = TinyHtml_TinyHtml._preEventTargetElem(el, 'hasEventListener');
7774
+ if (!__eventRegistry.has(elem)) return false;
7775
+ const events = __eventRegistry.get(elem);
7776
+ return !!(events && Array.isArray(events[event]) && events[event].length > 0);
7777
+ }
7778
+
7779
+ /**
7780
+ * Checks if the element has a listener for a specific event.
7781
+ *
7782
+ * @param {string} event - The event name to check.
7783
+ * @returns {boolean}
7784
+ */
7785
+ hasEventListener(event) {
7786
+ return TinyHtml_TinyHtml.hasEventListener(this, event);
7787
+ }
7788
+
7789
+ /**
7790
+ * Checks if the element has the exact handler registered for a specific event.
7791
+ *
7792
+ * @param {TinyEventTarget} el - The element to check.
7793
+ * @param {string} event - The event name to check.
7794
+ * @param {EventListenerOrEventListenerObject} handler - The handler function to check.
7795
+ * @returns {boolean}
7796
+ */
7797
+ static hasExactEventListener(el, event, handler) {
7798
+ const elem = TinyHtml_TinyHtml._preEventTargetElem(el, 'hasExactEventListener');
7799
+ if (typeof handler !== 'function') throw new TypeError('The "handler" must be a function.');
7800
+ if (!__eventRegistry.has(elem)) return false;
7801
+ const events = __eventRegistry.get(elem);
7802
+ if (!events || !Array.isArray(events[event])) return false;
7803
+ return events[event].some((item) => item.handler === handler);
7804
+ }
7805
+
7806
+ /**
7807
+ * Checks if the element has the exact handler registered for a specific event.
7808
+ *
7809
+ * @param {string} event - The event name to check.
7810
+ * @param {EventListenerOrEventListenerObject} handler - The handler function to check.
7811
+ * @returns {boolean}
7812
+ */
7813
+ hasExactEventListener(event, handler) {
7814
+ return TinyHtml_TinyHtml.hasExactEventListener(this, event, handler);
7815
+ }
7816
+
7526
7817
  /**
7527
7818
  * Registers an event listener on the specified element.
7528
7819
  *
7529
7820
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target to listen on.
7530
7821
  * @param {string} event - The event type (e.g. 'click', 'keydown').
7531
- * @param {EventRegistryHandle} handler - The callback function to run on event.
7822
+ * @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
7532
7823
  * @param {EventRegistryOptions} [options] - Optional event listener options.
7533
7824
  * @returns {TinyEventTarget|TinyEventTarget[]}
7534
7825
  */
@@ -7550,7 +7841,7 @@ class TinyHtml_TinyHtml {
7550
7841
  * Registers an event listener on the specified element.
7551
7842
  *
7552
7843
  * @param {string} event - The event type (e.g. 'click', 'keydown').
7553
- * @param {EventRegistryHandle} handler - The callback function to run on event.
7844
+ * @param {EventListenerOrEventListenerObject|null} handler - The callback function to run on event.
7554
7845
  * @param {EventRegistryOptions} [options] - Optional event listener options.
7555
7846
  * @returns {TinyEventTarget|TinyEventTarget[]}
7556
7847
  */
@@ -7563,17 +7854,17 @@ class TinyHtml_TinyHtml {
7563
7854
  *
7564
7855
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target to listen on.
7565
7856
  * @param {string} event - The event type (e.g. 'click', 'keydown').
7566
- * @param {EventRegistryHandle} handler - The callback function to run on event.
7857
+ * @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
7567
7858
  * @param {EventRegistryOptions} [options={}] - Optional event listener options.
7568
7859
  * @returns {TinyEventTarget|TinyEventTarget[]}
7569
7860
  */
7570
7861
  static once(el, event, handler, options = {}) {
7571
7862
  if (typeof event !== 'string') throw new TypeError('The event name must be a string.');
7572
7863
  TinyHtml_TinyHtml._preEventTargetElems(el, 'once').forEach((elem) => {
7573
- /** @type {EventRegistryHandle} e */
7864
+ /** @type {EventListenerOrEventListenerObject} */
7574
7865
  const wrapped = (e) => {
7575
7866
  TinyHtml_TinyHtml.off(elem, event, wrapped);
7576
- handler(e);
7867
+ if (typeof handler === 'function') handler(e);
7577
7868
  };
7578
7869
 
7579
7870
  TinyHtml_TinyHtml.on(
@@ -7590,7 +7881,7 @@ class TinyHtml_TinyHtml {
7590
7881
  * Registers an event listener that runs only once, then is removed.
7591
7882
  *
7592
7883
  * @param {string} event - The event type (e.g. 'click', 'keydown').
7593
- * @param {EventRegistryHandle} handler - The callback function to run on event.
7884
+ * @param {EventListenerOrEventListenerObject} handler - The callback function to run on event.
7594
7885
  * @param {EventRegistryOptions} [options={}] - Optional event listener options.
7595
7886
  * @returns {TinyEventTarget|TinyEventTarget[]}
7596
7887
  */
@@ -7603,7 +7894,7 @@ class TinyHtml_TinyHtml {
7603
7894
  *
7604
7895
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
7605
7896
  * @param {string} event - The event type.
7606
- * @param {EventRegistryHandle} handler - The function originally bound to the event.
7897
+ * @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
7607
7898
  * @param {boolean|EventListenerOptions} [options] - Optional listener options.
7608
7899
  * @returns {TinyEventTarget|TinyEventTarget[]}
7609
7900
  */
@@ -7625,7 +7916,7 @@ class TinyHtml_TinyHtml {
7625
7916
  * Removes a specific event listener from an element.
7626
7917
  *
7627
7918
  * @param {string} event - The event type.
7628
- * @param {EventRegistryHandle} handler - The function originally bound to the event.
7919
+ * @param {EventListenerOrEventListenerObject|null} handler - The function originally bound to the event.
7629
7920
  * @param {boolean|EventListenerOptions} [options] - Optional listener options.
7630
7921
  * @returns {TinyEventTarget|TinyEventTarget[]}
7631
7922
  */
@@ -7668,7 +7959,7 @@ class TinyHtml_TinyHtml {
7668
7959
  * Removes all event listeners of all types from the element.
7669
7960
  *
7670
7961
  * @param {TinyEventTarget|TinyEventTarget[]} el - The target element.
7671
- * @param {((handler: EventListenerOrEventListenerObject, event: string) => boolean)|null} [filterFn=null] -
7962
+ * @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
7672
7963
  * Optional filter function to selectively remove specific handlers.
7673
7964
  * @returns {TinyEventTarget|TinyEventTarget[]}
7674
7965
  */
@@ -7695,7 +7986,7 @@ class TinyHtml_TinyHtml {
7695
7986
  /**
7696
7987
  * Removes all event listeners of all types from the element.
7697
7988
  *
7698
- * @param {((handler: EventListenerOrEventListenerObject, event: string) => boolean)|null} [filterFn=null] -
7989
+ * @param {((handler: EventListenerOrEventListenerObject|null, event: string) => boolean)|null} [filterFn=null] -
7699
7990
  * Optional filter function to selectively remove specific handlers.
7700
7991
  * @returns {TinyEventTarget|TinyEventTarget[]}
7701
7992
  */