text-slicer 1.4.1 → 1.5.0-dev.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/index.cjs.js +1 -1
- package/dist/index.d.ts +5 -14
- package/dist/index.es.js +69 -114
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m={splitMode:"both",cssVariables:!1,dataAttributes:!1,keepWhitespaceNodes:!0,iosSafariTransformFix:!1,extraCharWrapper:!1},n=Object.freeze({word:"ts-word",char:"ts-char",charWrap:"ts-char-wrap",whitespace:"ts-whitespace"}),a=" ",c="--char-index",d=()=>typeof window<"u"&&typeof document<"u",p=t=>{const e=Intl.Segmenter;if(typeof e=="function"){const s=new e("en",{granularity:"grapheme"});return Array.from(s.segment(t),r=>r.segment)}return Array.from(t)},l=t=>t.split(a),h=t=>{const e={};return Object.keys(t).forEach(s=>{const r=t[s];r!==void 0&&(e[s]=r)}),e};exports.CLASSNAMES=n,exports.TextSlicer=class{el;original;opts;callbacks;charIndex;mounted;constructor(t={},e){const s=(r=t.container,d()&&r?typeof r=="string"?document.querySelector(r):r:null);var r;this.el=s,this.original=(i=>!!i&&typeof HTMLElement<"u"&&i instanceof HTMLElement)(s)?s.textContent?.toString()??"":"",this.opts={...m,...h(t)},this.callbacks=e,this.charIndex=0,this.mounted=!1}get metrics(){const t=this.original;return{wordTotal:t.length?l(t).length:0,charTotal:t.length,renderedAt:Date.now()}}init(){this.el&&(this.mounted=!0,this.split())}reinit(t,e){this.el&&(typeof t=="string"&&(this.original=t),e&&(this.opts={...this.opts,...h(e)}),this.split())}clear(){this.el&&(this.el.style.minHeight="",this.el.replaceChildren())}split(){if(!this.el)return;this.clear(),this.charIndex=0;const t=this.original,e=document.createDocumentFragment(),s=l(t);this.opts.splitMode==="chars"?this.appendChars(e,t):this.appendWords(e,s),this.el.appendChild(e),this.opts.cssVariables&&(this.el.style.setProperty("--word-total",String(s.length)),this.el.style.setProperty("--char-total",String(t.length))),this.opts.iosSafariTransformFix&&(()=>{if(!d())return!1;const r=navigator.userAgent||"",i=/iP(hone|ad|od)/.test(r),o=/WebKit/.test(r)&&!/Chrome|CriOS|FxiOS|EdgiOS/.test(r);return i&&o})()&&this.applyIOSContainerSizeFix(),this.callbacks?.onAfterRender?.(this.metrics)}destroy(){this.el&&(this.clear(),this.mounted=!1)}updateOptions(t){this.opts={...this.opts,...h(t)},this.mounted&&this.split()}appendWords(t,e){e.forEach((s,r)=>{if(this.opts.splitMode==="both"){const i=this.createWordSpan(r,s);for(const o of p(s)){const u=this.createCharNode(o);i.append(u)}t.append(i)}else{const i=this.createWordSpan(r);i.append(document.createTextNode(s)),t.append(i)}r<e.length-1&&t.append(this.createSpaceSpan())})}appendChars(t,e){for(const s of p(e)){const r=this.createCharNode(s);t.append(r)}}createWordSpan(t,e=""){const s=document.createElement("span");return s.classList.add(n.word),this.opts.dataAttributes&&e&&s.setAttribute("data-word",e),this.opts.cssVariables&&s.style.setProperty("--word-index",String(t)),s}createCharNode(t){if(t===a){const s=document.createElement("span");return s.classList.add(n.whitespace),s.textContent=a,s}if(this.opts.extraCharWrapper){const s=document.createElement("span");s.classList.add(n.charWrap);const r=document.createElement("span");return r.classList.add(n.char),r.textContent=t,this.opts.dataAttributes&&r.setAttribute("data-char",t),this.opts.cssVariables&&r.style.setProperty(c,String(this.charIndex)),this.charIndex+=1,s.appendChild(r),s}const e=document.createElement("span");return e.classList.add(n.char),e.textContent=t,this.opts.dataAttributes&&e.setAttribute("data-char",t),this.opts.cssVariables&&e.style.setProperty(c,String(this.charIndex)),this.charIndex+=1,e}createSpaceSpan(){const t=document.createElement("span");return t.classList.add(n.whitespace),t.textContent=a,t}applyIOSContainerSizeFix(){if(!this.el)return;this.el.style.minHeight="",this.el.offsetHeight;const t=this.el.getBoundingClientRect(),e=Math.ceil(t.height);e>0&&(this.el.style.minHeight=`${e}px`)}};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export interface TextSlicerOptions {
|
|
|
5
5
|
cssVariables?: boolean;
|
|
6
6
|
dataAttributes?: boolean;
|
|
7
7
|
keepWhitespaceNodes?: boolean;
|
|
8
|
-
|
|
8
|
+
iosSafariTransformFix?: boolean;
|
|
9
|
+
extraCharWrapper?: boolean;
|
|
9
10
|
}
|
|
10
11
|
export interface TextSlicerMetrics {
|
|
11
12
|
wordTotal: number;
|
|
@@ -18,6 +19,7 @@ export interface TextSlicerCallbacks {
|
|
|
18
19
|
export declare const CLASSNAMES: Readonly<{
|
|
19
20
|
word: "ts-word";
|
|
20
21
|
char: "ts-char";
|
|
22
|
+
charWrap: "ts-char-wrap";
|
|
21
23
|
whitespace: "ts-whitespace";
|
|
22
24
|
}>;
|
|
23
25
|
export declare class TextSlicer {
|
|
@@ -27,10 +29,6 @@ export declare class TextSlicer {
|
|
|
27
29
|
private callbacks;
|
|
28
30
|
private charIndex;
|
|
29
31
|
private mounted;
|
|
30
|
-
private ro;
|
|
31
|
-
private frozen;
|
|
32
|
-
private freezeScheduled;
|
|
33
|
-
private freezeWordWidthsBound;
|
|
34
32
|
constructor(options?: TextSlicerOptions, callbacks?: TextSlicerCallbacks);
|
|
35
33
|
get metrics(): TextSlicerMetrics;
|
|
36
34
|
init(): void;
|
|
@@ -42,14 +40,7 @@ export declare class TextSlicer {
|
|
|
42
40
|
private appendWords;
|
|
43
41
|
private appendChars;
|
|
44
42
|
private createWordSpan;
|
|
45
|
-
private
|
|
43
|
+
private createCharNode;
|
|
46
44
|
private createSpaceSpan;
|
|
47
|
-
private
|
|
48
|
-
private scheduleFreezeWordWidths;
|
|
49
|
-
private measureWordWidths;
|
|
50
|
-
private applyWordWidths;
|
|
51
|
-
private freezeWordWidths;
|
|
52
|
-
private unfreezeWordWidths;
|
|
53
|
-
private attachResizeObserver;
|
|
54
|
-
private detachResizeObserver;
|
|
45
|
+
private applyIOSContainerSizeFix;
|
|
55
46
|
}
|
package/dist/index.es.js
CHANGED
|
@@ -1,155 +1,110 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
if (typeof
|
|
4
|
-
const
|
|
5
|
-
return Array.from(
|
|
6
|
-
}
|
|
7
|
-
return Array.from(
|
|
8
|
-
},
|
|
9
|
-
const
|
|
10
|
-
return Object.keys(
|
|
11
|
-
const s =
|
|
12
|
-
s !== void 0 && (e
|
|
13
|
-
}),
|
|
1
|
+
const g = { splitMode: "both", cssVariables: !1, dataAttributes: !1, keepWhitespaceNodes: !0, iosSafariTransformFix: !1, extraCharWrapper: !1 }, a = Object.freeze({ word: "ts-word", char: "ts-char", charWrap: "ts-char-wrap", whitespace: "ts-whitespace" }), o = " ", p = "--char-index", d = () => typeof window < "u" && typeof document < "u", l = (n) => {
|
|
2
|
+
const t = Intl.Segmenter;
|
|
3
|
+
if (typeof t == "function") {
|
|
4
|
+
const e = new t("en", { granularity: "grapheme" });
|
|
5
|
+
return Array.from(e.segment(n), (s) => s.segment);
|
|
6
|
+
}
|
|
7
|
+
return Array.from(n);
|
|
8
|
+
}, u = (n) => n.split(o), c = (n) => {
|
|
9
|
+
const t = {};
|
|
10
|
+
return Object.keys(n).forEach((e) => {
|
|
11
|
+
const s = n[e];
|
|
12
|
+
s !== void 0 && (t[e] = s);
|
|
13
|
+
}), t;
|
|
14
14
|
};
|
|
15
|
-
class
|
|
15
|
+
class f {
|
|
16
16
|
el;
|
|
17
17
|
original;
|
|
18
18
|
opts;
|
|
19
19
|
callbacks;
|
|
20
20
|
charIndex;
|
|
21
21
|
mounted;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.scheduleFreezeNow();
|
|
27
|
-
};
|
|
28
|
-
constructor(e = {}, t) {
|
|
29
|
-
const s = f(e.container);
|
|
30
|
-
this.el = s, this.original = ((i) => !!i && typeof HTMLElement < "u" && i instanceof HTMLElement)(s) ? s.textContent?.toString() ?? "" : "", this.opts = { ...u, ...a(e) }, this.callbacks = t, this.charIndex = 0, this.mounted = !1;
|
|
22
|
+
constructor(t = {}, e) {
|
|
23
|
+
const s = (r = t.container, d() && r ? typeof r == "string" ? document.querySelector(r) : r : null);
|
|
24
|
+
var r;
|
|
25
|
+
this.el = s, this.original = ((i) => !!i && typeof HTMLElement < "u" && i instanceof HTMLElement)(s) ? s.textContent?.toString() ?? "" : "", this.opts = { ...g, ...c(t) }, this.callbacks = e, this.charIndex = 0, this.mounted = !1;
|
|
31
26
|
}
|
|
32
27
|
get metrics() {
|
|
33
|
-
const
|
|
34
|
-
return { wordTotal:
|
|
28
|
+
const t = this.original;
|
|
29
|
+
return { wordTotal: t.length ? u(t).length : 0, charTotal: t.length, renderedAt: Date.now() };
|
|
35
30
|
}
|
|
36
31
|
init() {
|
|
37
32
|
this.el && (this.mounted = !0, this.split());
|
|
38
33
|
}
|
|
39
|
-
reinit(
|
|
40
|
-
this.el && (typeof
|
|
34
|
+
reinit(t, e) {
|
|
35
|
+
this.el && (typeof t == "string" && (this.original = t), e && (this.opts = { ...this.opts, ...c(e) }), this.split());
|
|
41
36
|
}
|
|
42
37
|
clear() {
|
|
43
|
-
this.el && (this.
|
|
38
|
+
this.el && (this.el.style.minHeight = "", this.el.replaceChildren());
|
|
44
39
|
}
|
|
45
40
|
split() {
|
|
46
41
|
if (!this.el) return;
|
|
47
42
|
this.clear(), this.charIndex = 0;
|
|
48
|
-
const
|
|
49
|
-
this.opts.splitMode === "chars" ? this.appendChars(
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
43
|
+
const t = this.original, e = document.createDocumentFragment(), s = u(t);
|
|
44
|
+
this.opts.splitMode === "chars" ? this.appendChars(e, t) : this.appendWords(e, s), this.el.appendChild(e), this.opts.cssVariables && (this.el.style.setProperty("--word-total", String(s.length)), this.el.style.setProperty("--char-total", String(t.length))), this.opts.iosSafariTransformFix && (() => {
|
|
45
|
+
if (!d()) return !1;
|
|
46
|
+
const r = navigator.userAgent || "", i = /iP(hone|ad|od)/.test(r), h = /WebKit/.test(r) && !/Chrome|CriOS|FxiOS|EdgiOS/.test(r);
|
|
47
|
+
return i && h;
|
|
48
|
+
})() && this.applyIOSContainerSizeFix(), this.callbacks?.onAfterRender?.(this.metrics);
|
|
53
49
|
}
|
|
54
50
|
destroy() {
|
|
55
|
-
this.el && (this.
|
|
51
|
+
this.el && (this.clear(), this.mounted = !1);
|
|
56
52
|
}
|
|
57
|
-
updateOptions(
|
|
58
|
-
this.opts = { ...this.opts, ...
|
|
53
|
+
updateOptions(t) {
|
|
54
|
+
this.opts = { ...this.opts, ...c(t) }, this.mounted && this.split();
|
|
59
55
|
}
|
|
60
|
-
appendWords(
|
|
61
|
-
|
|
56
|
+
appendWords(t, e) {
|
|
57
|
+
e.forEach((s, r) => {
|
|
62
58
|
if (this.opts.splitMode === "both") {
|
|
63
|
-
const
|
|
64
|
-
for (const
|
|
65
|
-
const
|
|
66
|
-
|
|
59
|
+
const i = this.createWordSpan(r, s);
|
|
60
|
+
for (const h of l(s)) {
|
|
61
|
+
const m = this.createCharNode(h);
|
|
62
|
+
i.append(m);
|
|
67
63
|
}
|
|
68
|
-
|
|
64
|
+
t.append(i);
|
|
69
65
|
} else {
|
|
70
|
-
const
|
|
71
|
-
|
|
66
|
+
const i = this.createWordSpan(r);
|
|
67
|
+
i.append(document.createTextNode(s)), t.append(i);
|
|
72
68
|
}
|
|
73
|
-
|
|
69
|
+
r < e.length - 1 && t.append(this.createSpaceSpan());
|
|
74
70
|
});
|
|
75
71
|
}
|
|
76
|
-
appendChars(
|
|
77
|
-
for (const s of
|
|
78
|
-
const
|
|
79
|
-
|
|
72
|
+
appendChars(t, e) {
|
|
73
|
+
for (const s of l(e)) {
|
|
74
|
+
const r = this.createCharNode(s);
|
|
75
|
+
t.append(r);
|
|
80
76
|
}
|
|
81
77
|
}
|
|
82
|
-
createWordSpan(
|
|
78
|
+
createWordSpan(t, e = "") {
|
|
83
79
|
const s = document.createElement("span");
|
|
84
|
-
return s.classList.add(
|
|
85
|
-
}
|
|
86
|
-
createCharSpan(e) {
|
|
87
|
-
const t = document.createElement("span");
|
|
88
|
-
return t.textContent = e, this.opts.dataAttributes && t.setAttribute("data-char", e), e === h ? (t.classList.add(o.whitespace), this.opts.keepWhitespaceNodes || (t.textContent = h)) : (t.classList.add(o.char), this.opts.cssVariables && t.style.setProperty("--char-index", String(this.charIndex)), this.charIndex += 1), t;
|
|
80
|
+
return s.classList.add(a.word), this.opts.dataAttributes && e && s.setAttribute("data-word", e), this.opts.cssVariables && s.style.setProperty("--word-index", String(t)), s;
|
|
89
81
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
scheduleFreezeNow() {
|
|
95
|
-
this.el && this.opts.freezeWordWidths && (this.freezeScheduled || (this.freezeScheduled = !0, requestAnimationFrame(() => {
|
|
96
|
-
this.freezeScheduled = !1, this.freezeWordWidths();
|
|
97
|
-
})));
|
|
98
|
-
}
|
|
99
|
-
async scheduleFreezeWordWidths() {
|
|
100
|
-
if (this.el && this.opts.freezeWordWidths) {
|
|
101
|
-
try {
|
|
102
|
-
await document.fonts?.ready;
|
|
103
|
-
} catch {
|
|
104
|
-
}
|
|
105
|
-
await new Promise((e) => requestAnimationFrame(() => e())), this.scheduleFreezeNow(), this.attachResizeObserver();
|
|
82
|
+
createCharNode(t) {
|
|
83
|
+
if (t === o) {
|
|
84
|
+
const s = document.createElement("span");
|
|
85
|
+
return s.classList.add(a.whitespace), s.textContent = o, s;
|
|
106
86
|
}
|
|
87
|
+
if (this.opts.extraCharWrapper) {
|
|
88
|
+
const s = document.createElement("span");
|
|
89
|
+
s.classList.add(a.charWrap);
|
|
90
|
+
const r = document.createElement("span");
|
|
91
|
+
return r.classList.add(a.char), r.textContent = t, this.opts.dataAttributes && r.setAttribute("data-char", t), this.opts.cssVariables && r.style.setProperty(p, String(this.charIndex)), this.charIndex += 1, s.appendChild(r), s;
|
|
92
|
+
}
|
|
93
|
+
const e = document.createElement("span");
|
|
94
|
+
return e.classList.add(a.char), e.textContent = t, this.opts.dataAttributes && e.setAttribute("data-char", t), this.opts.cssVariables && e.style.setProperty(p, String(this.charIndex)), this.charIndex += 1, e;
|
|
107
95
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return Array.from(e, (t) => {
|
|
112
|
-
t.style.width = "", t.style.flex = "";
|
|
113
|
-
const { width: s } = t.getBoundingClientRect();
|
|
114
|
-
return Math.ceil(s);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
applyWordWidths(e) {
|
|
118
|
-
this.el && this.el.querySelectorAll(`.${o.word}`).forEach((t, s) => {
|
|
119
|
-
const i = e[s] ?? 0;
|
|
120
|
-
t.style.width = `${i}px`, t.style.flex = "0 0 auto";
|
|
121
|
-
});
|
|
96
|
+
createSpaceSpan() {
|
|
97
|
+
const t = document.createElement("span");
|
|
98
|
+
return t.classList.add(a.whitespace), t.textContent = o, t;
|
|
122
99
|
}
|
|
123
|
-
|
|
100
|
+
applyIOSContainerSizeFix() {
|
|
124
101
|
if (!this.el) return;
|
|
125
|
-
|
|
126
|
-
this.
|
|
127
|
-
|
|
128
|
-
unfreezeWordWidths() {
|
|
129
|
-
!this.el || !this.frozen || (this.el.querySelectorAll(`.${o.word}`).forEach((e) => {
|
|
130
|
-
e.style.width = "", e.style.flex = "";
|
|
131
|
-
}), this.frozen = !1);
|
|
132
|
-
}
|
|
133
|
-
attachResizeObserver() {
|
|
134
|
-
if (this.el && this.opts.freezeWordWidths) {
|
|
135
|
-
if (!this.ro) {
|
|
136
|
-
this.ro = new ResizeObserver(() => {
|
|
137
|
-
this.scheduleFreezeNow();
|
|
138
|
-
});
|
|
139
|
-
try {
|
|
140
|
-
this.ro.observe(this.el, { box: "border-box" });
|
|
141
|
-
} catch {
|
|
142
|
-
this.ro.observe(this.el);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
window.addEventListener("resize", this.freezeWordWidthsBound, { passive: !0 });
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
detachResizeObserver() {
|
|
149
|
-
this.ro && (this.ro.disconnect(), this.ro = null), window.removeEventListener("resize", this.freezeWordWidthsBound);
|
|
102
|
+
this.el.style.minHeight = "", this.el.offsetHeight;
|
|
103
|
+
const t = this.el.getBoundingClientRect(), e = Math.ceil(t.height);
|
|
104
|
+
e > 0 && (this.el.style.minHeight = `${e}px`);
|
|
150
105
|
}
|
|
151
106
|
}
|
|
152
107
|
export {
|
|
153
|
-
|
|
154
|
-
|
|
108
|
+
a as CLASSNAMES,
|
|
109
|
+
f as TextSlicer
|
|
155
110
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(o
|
|
1
|
+
(function(a,o){typeof exports=="object"&&typeof module<"u"?o(exports):typeof define=="function"&&define.amd?define(["exports"],o):o((a=typeof globalThis<"u"?globalThis:a||self).TextSlicer={})})(this,function(a){"use strict";const o={splitMode:"both",cssVariables:!1,dataAttributes:!1,keepWhitespaceNodes:!0,iosSafariTransformFix:!1,extraCharWrapper:!1},r=Object.freeze({word:"ts-word",char:"ts-char",charWrap:"ts-char-wrap",whitespace:"ts-whitespace"}),c=" ",p="--char-index",l=()=>typeof window<"u"&&typeof document<"u",u=t=>{const e=Intl.Segmenter;if(typeof e=="function"){const s=new e("en",{granularity:"grapheme"});return Array.from(s.segment(t),i=>i.segment)}return Array.from(t)},f=t=>t.split(c),h=t=>{const e={};return Object.keys(t).forEach(s=>{const i=t[s];i!==void 0&&(e[s]=i)}),e};a.CLASSNAMES=r,a.TextSlicer=class{el;original;opts;callbacks;charIndex;mounted;constructor(t={},e){const s=(i=t.container,l()&&i?typeof i=="string"?document.querySelector(i):i:null);var i;this.el=s,this.original=(n=>!!n&&typeof HTMLElement<"u"&&n instanceof HTMLElement)(s)?s.textContent?.toString()??"":"",this.opts={...o,...h(t)},this.callbacks=e,this.charIndex=0,this.mounted=!1}get metrics(){const t=this.original;return{wordTotal:t.length?f(t).length:0,charTotal:t.length,renderedAt:Date.now()}}init(){this.el&&(this.mounted=!0,this.split())}reinit(t,e){this.el&&(typeof t=="string"&&(this.original=t),e&&(this.opts={...this.opts,...h(e)}),this.split())}clear(){this.el&&(this.el.style.minHeight="",this.el.replaceChildren())}split(){if(!this.el)return;this.clear(),this.charIndex=0;const t=this.original,e=document.createDocumentFragment(),s=f(t);this.opts.splitMode==="chars"?this.appendChars(e,t):this.appendWords(e,s),this.el.appendChild(e),this.opts.cssVariables&&(this.el.style.setProperty("--word-total",String(s.length)),this.el.style.setProperty("--char-total",String(t.length))),this.opts.iosSafariTransformFix&&(()=>{if(!l())return!1;const i=navigator.userAgent||"",n=/iP(hone|ad|od)/.test(i),d=/WebKit/.test(i)&&!/Chrome|CriOS|FxiOS|EdgiOS/.test(i);return n&&d})()&&this.applyIOSContainerSizeFix(),this.callbacks?.onAfterRender?.(this.metrics)}destroy(){this.el&&(this.clear(),this.mounted=!1)}updateOptions(t){this.opts={...this.opts,...h(t)},this.mounted&&this.split()}appendWords(t,e){e.forEach((s,i)=>{if(this.opts.splitMode==="both"){const n=this.createWordSpan(i,s);for(const d of u(s)){const m=this.createCharNode(d);n.append(m)}t.append(n)}else{const n=this.createWordSpan(i);n.append(document.createTextNode(s)),t.append(n)}i<e.length-1&&t.append(this.createSpaceSpan())})}appendChars(t,e){for(const s of u(e)){const i=this.createCharNode(s);t.append(i)}}createWordSpan(t,e=""){const s=document.createElement("span");return s.classList.add(r.word),this.opts.dataAttributes&&e&&s.setAttribute("data-word",e),this.opts.cssVariables&&s.style.setProperty("--word-index",String(t)),s}createCharNode(t){if(t===c){const s=document.createElement("span");return s.classList.add(r.whitespace),s.textContent=c,s}if(this.opts.extraCharWrapper){const s=document.createElement("span");s.classList.add(r.charWrap);const i=document.createElement("span");return i.classList.add(r.char),i.textContent=t,this.opts.dataAttributes&&i.setAttribute("data-char",t),this.opts.cssVariables&&i.style.setProperty(p,String(this.charIndex)),this.charIndex+=1,s.appendChild(i),s}const e=document.createElement("span");return e.classList.add(r.char),e.textContent=t,this.opts.dataAttributes&&e.setAttribute("data-char",t),this.opts.cssVariables&&e.style.setProperty(p,String(this.charIndex)),this.charIndex+=1,e}createSpaceSpan(){const t=document.createElement("span");return t.classList.add(r.whitespace),t.textContent=c,t}applyIOSContainerSizeFix(){if(!this.el)return;this.el.style.minHeight="",this.el.offsetHeight;const t=this.el.getBoundingClientRect(),e=Math.ceil(t.height);e>0&&(this.el.style.minHeight=`${e}px`)}},Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "text-slicer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0-dev.0",
|
|
4
4
|
"description": "TextSlicer is designed to split text within an HTML element into separate words and/or characters, wrapping each word and/or character in separate span elements.",
|
|
5
5
|
"author": "ux-ui.pro",
|
|
6
6
|
"license": "MIT",
|