@siladev/qalam 0.2.0 → 0.2.1

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.
@@ -1,10 +1,10 @@
1
- import { jsx as r, jsxs as q, Fragment as A } from "react/jsx-runtime";
2
- import { useRef as O, useCallback as Q, useEffect as G, useState as F, useLayoutEffect as J } from "react";
3
- const T = "ـ", K = new Set("سشصض"), U = new Set("ةهد"), V = new Set("طلكگ"), z = new Set("عقف"), M = new Set(
1
+ import { jsx as r, jsxs as g, Fragment as A } from "react/jsx-runtime";
2
+ import { useRef as O, useCallback as G, useEffect as J, useState as F, useLayoutEffect as K } from "react";
3
+ const v = "ـ", U = new Set("سشصض"), V = new Set("ةهد"), z = new Set("طلكگ"), X = new Set("عقف"), M = new Set(
4
4
  "بتثجحخسشصضطظعغفقكلمنهيئپچژگ"
5
5
  );
6
6
  new Set("ادذرزوأإآؤ");
7
- const X = new Set("اأإآ");
7
+ const Y = new Set("اأإآ");
8
8
  function B(e) {
9
9
  const t = e.charCodeAt(0);
10
10
  return t >= 1569 && t <= 1610 || t >= 1646 && t <= 1747 || t >= 64336 && t <= 65023;
@@ -21,7 +21,7 @@ function D(e, t) {
21
21
  return B(e[a]);
22
22
  return !1;
23
23
  }
24
- function Y(e, t) {
24
+ function Z(e, t) {
25
25
  for (let n = t + 1; n < e.length; n++)
26
26
  if (!S(e[n])) {
27
27
  if (B(e[n])) return !1;
@@ -29,42 +29,42 @@ function Y(e, t) {
29
29
  }
30
30
  return !0;
31
31
  }
32
- function Z(e, t) {
32
+ function ee(e, t) {
33
33
  for (let n = t - 1; n >= 0; n--)
34
34
  if (!S(e[n]))
35
35
  return M.has(e[n]);
36
36
  return !1;
37
37
  }
38
- function j(e, t) {
38
+ function H(e, t) {
39
39
  if (e[t] !== "ل") return !1;
40
40
  for (let n = t + 1; n < e.length; n++)
41
41
  if (!S(e[n]))
42
- return X.has(e[n]);
42
+ return Y.has(e[n]);
43
43
  return !1;
44
44
  }
45
- function ee(e) {
45
+ function te(e) {
46
46
  const t = [];
47
47
  for (let n = 0; n < e.length; n++) {
48
48
  const a = e[n];
49
- if (a.includes(T)) continue;
49
+ if (a.includes(v)) continue;
50
50
  let s = null;
51
51
  for (let i = 0; i < a.length; i++) {
52
52
  if (S(a[i])) continue;
53
53
  const c = a[i];
54
- if (K.has(c) && D(a, i) && !j(a, i)) {
54
+ if (U.has(c) && D(a, i) && !H(a, i)) {
55
55
  const l = { wordIndex: n, charIndex: i + 1, priority: 1 };
56
56
  (!s || l.priority < s.priority) && (s = l);
57
57
  continue;
58
58
  }
59
- if (Y(a, i) && Z(a, i)) {
59
+ if (Z(a, i) && ee(a, i)) {
60
60
  let l = 0;
61
- if (U.has(c) ? l = 2 : V.has(c) ? l = 3 : z.has(c) && (l = 4), l > 0) {
62
- const o = { wordIndex: n, charIndex: i, priority: l };
63
- (!s || o.priority < s.priority) && (s = o);
61
+ if (V.has(c) ? l = 2 : z.has(c) ? l = 3 : X.has(c) && (l = 4), l > 0) {
62
+ const d = { wordIndex: n, charIndex: i, priority: l };
63
+ (!s || d.priority < s.priority) && (s = d);
64
64
  continue;
65
65
  }
66
66
  }
67
- if (M.has(c) && D(a, i) && !j(a, i)) {
67
+ if (M.has(c) && D(a, i) && !H(a, i)) {
68
68
  const l = { wordIndex: n, charIndex: i + 1, priority: 5 };
69
69
  (!s || l.priority < s.priority) && (s = l);
70
70
  }
@@ -73,42 +73,52 @@ function ee(e) {
73
73
  }
74
74
  return t;
75
75
  }
76
- function te(e, t) {
76
+ function P(e, t) {
77
77
  for (; t < e.length && S(e[t]); ) t++;
78
78
  return t;
79
79
  }
80
- function H(e, t, n = 1) {
81
- const a = te(e, t);
82
- return e.slice(0, a) + T.repeat(n) + e.slice(a);
80
+ function j(e, t, n = 1) {
81
+ const a = P(e, t);
82
+ return e.slice(0, a) + v.repeat(n) + e.slice(a);
83
83
  }
84
84
  function ne(e, t, n, a = 50) {
85
85
  let s = e, i = t(s);
86
86
  if (i >= n) return s;
87
87
  for (let c = 0; c < a; c++) {
88
- const l = s.split(" "), o = ee(l);
89
- if (o.length === 0) {
90
- const u = l.map((p, m) => ({ word: p, index: m })).filter(({ word: p }) => p.includes(T));
91
- if (u.length === 0) break;
92
- for (const { word: p, index: m } of u) {
93
- const N = p.indexOf(T);
94
- if (l[m] = H(p, N, 1), s = l.join(" "), i = t(s), i >= n) return s;
88
+ const l = s.split(" "), d = te(l);
89
+ if (d.length === 0) {
90
+ const m = l.map((o, h) => ({ word: o, index: h })).filter(({ word: o }) => o.includes(v));
91
+ if (m.length === 0) break;
92
+ for (const { word: o, index: h } of m) {
93
+ const f = o.indexOf(v), k = o.split(v).length - 1;
94
+ if (k === 2) {
95
+ const b = P(o, f + k);
96
+ if (b < o.length && o[b] === "ا") {
97
+ const q = j(o, f, 2), y = [...l];
98
+ y[h] = q;
99
+ const R = t(y.join(" "));
100
+ R <= n && (l[h] = q, s = y.join(" "), i = R);
101
+ continue;
102
+ }
103
+ }
104
+ if (l[h] = j(o, f, 1), s = l.join(" "), i = t(s), i >= n) return s;
95
105
  }
96
106
  continue;
97
107
  }
98
- o.sort((u, p) => u.priority - p.priority);
99
- const d = o[0];
100
- if (l[d.wordIndex] = H(l[d.wordIndex], d.charIndex), s = l.join(" "), i = t(s), i >= n) return s;
108
+ d.sort((m, o) => m.priority - o.priority);
109
+ const p = d[0];
110
+ if (l[p.wordIndex] = j(l[p.wordIndex], p.charIndex), s = l.join(" "), i = t(s), i >= n) return s;
101
111
  }
102
112
  return s;
103
113
  }
104
- function E(e) {
114
+ function C(e) {
105
115
  if (e === 2) return "(مرتان)";
106
116
  const t = e.toString().replace(/\d/g, (n) => "٠١٢٣٤٥٦٧٨٩"[parseInt(n)]);
107
117
  return e > 10 ? `(${t} مرة)` : `(${t} مرات)`;
108
118
  }
109
- function P(e, t, n) {
119
+ function Q(e, t, n) {
110
120
  if (n >= t.length) return /* @__PURE__ */ r(A, { children: e });
111
- const a = t[n], s = P(e, t, n + 1);
121
+ const a = t[n], s = Q(e, t, n + 1);
112
122
  switch (a.type) {
113
123
  case "bold":
114
124
  return /* @__PURE__ */ r("strong", { children: s });
@@ -117,9 +127,9 @@ function P(e, t, n) {
117
127
  case "link":
118
128
  return /* @__PURE__ */ r("a", { href: a.attrs.href, target: a.attrs.target ?? "_blank", rel: "noopener noreferrer", children: s });
119
129
  case "repeat":
120
- return /* @__PURE__ */ q("span", { className: "qalam-render-inline-repeat", children: [
130
+ return /* @__PURE__ */ g("span", { className: "qalam-render-inline-repeat", children: [
121
131
  s,
122
- /* @__PURE__ */ r("span", { className: "qalam-render-inline-repeat-badge", children: E(a.attrs.count) })
132
+ /* @__PURE__ */ r("span", { className: "qalam-render-inline-repeat-badge", children: C(a.attrs.count) })
123
133
  ] });
124
134
  case "propheticSpeech":
125
135
  return /* @__PURE__ */ r("span", { className: "qalam-render-prophetic-speech", children: s });
@@ -128,26 +138,26 @@ function P(e, t, n) {
128
138
  }
129
139
  }
130
140
  function ae({ node: e }) {
131
- return e.marks?.length ? P(e.text, e.marks, 0) : /* @__PURE__ */ r(A, { children: e.text });
141
+ return e.marks?.length ? Q(e.text, e.marks, 0) : /* @__PURE__ */ r(A, { children: e.text });
132
142
  }
133
143
  function re({ seg: e, index: t }) {
134
144
  const n = /* @__PURE__ */ r("span", { className: "qalam-render-verse", children: e.textHafsSmart });
135
- return e.repeat > 1 ? /* @__PURE__ */ q(A, { children: [
145
+ return e.repeat > 1 ? /* @__PURE__ */ g(A, { children: [
136
146
  /* @__PURE__ */ r("span", { className: "qalam-render-repeat", children: n }),
137
- /* @__PURE__ */ r("span", { className: "qalam-render-repeat-badge", children: E(e.repeat) })
147
+ /* @__PURE__ */ r("span", { className: "qalam-render-repeat-badge", children: C(e.repeat) })
138
148
  ] }) : n;
139
149
  }
140
150
  function se({ node: e }) {
141
151
  const { resolved: t } = e, n = t.segments.map((s) => s.textCopy).join(" "), a = t.basmalah ? `بِسْمِ اللَّهِ الرَّحْمَـٰنِ الرَّحِيمِ ${n}` : n;
142
- return /* @__PURE__ */ q("span", { className: "qalam-render-quran", "data-copy": a, "data-citation": t.citation, children: [
152
+ return /* @__PURE__ */ g("span", { className: "qalam-render-quran", "data-copy": a, "data-citation": t.citation, children: [
143
153
  /* @__PURE__ */ r("span", { className: "qalam-render-seo", "aria-hidden": "false", children: a }),
144
- /* @__PURE__ */ q("span", { "aria-hidden": "true", children: [
154
+ /* @__PURE__ */ g("span", { "aria-hidden": "true", children: [
145
155
  /* @__PURE__ */ r("span", { className: "qalam-render-bracket", children: "﴿" }),
146
- t.basmalah && /* @__PURE__ */ q(A, { children: [
156
+ t.basmalah && /* @__PURE__ */ g(A, { children: [
147
157
  /* @__PURE__ */ r("span", { className: "qalam-render-basmalah", children: "" }),
148
158
  " "
149
159
  ] }),
150
- t.segments.map((s, i) => /* @__PURE__ */ q("span", { children: [
160
+ t.segments.map((s, i) => /* @__PURE__ */ g("span", { children: [
151
161
  i > 0 && " ",
152
162
  /* @__PURE__ */ r(re, { seg: s, index: i })
153
163
  ] }, i)),
@@ -172,13 +182,13 @@ function ie({ node: e }) {
172
182
  }
173
183
  const i = [];
174
184
  for (let c = 0; c < n.length; c++)
175
- a[c] && (c === 0 || !a[c - 1]) && i.push(/* @__PURE__ */ r("span", { className: "qalam-render-prophetic-quote", children: "”" }, `q-open-${c}`)), i.push(/* @__PURE__ */ r(C, { node: n[c] }, c)), a[c] && (c === n.length - 1 || !a[c + 1]) && i.push(/* @__PURE__ */ r("span", { className: "qalam-render-prophetic-quote", children: "“" }, `q-close-${c}`));
176
- return /* @__PURE__ */ q("span", { className: "qalam-render-hadith", children: [
185
+ a[c] && (c === 0 || !a[c - 1]) && i.push(/* @__PURE__ */ r("span", { className: "qalam-render-prophetic-quote", children: "”" }, `q-open-${c}`)), i.push(/* @__PURE__ */ r(_, { node: n[c] }, c)), a[c] && (c === n.length - 1 || !a[c + 1]) && i.push(/* @__PURE__ */ r("span", { className: "qalam-render-prophetic-quote", children: "“" }, `q-close-${c}`));
186
+ return /* @__PURE__ */ g("span", { className: "qalam-render-hadith", children: [
177
187
  /* @__PURE__ */ r("span", { className: "qalam-render-hadith-bracket", children: "«" }),
178
188
  i,
179
189
  /* @__PURE__ */ r("span", { className: "qalam-render-hadith-bracket", children: "»" }),
180
190
  t.citation && /* @__PURE__ */ r("span", { className: "qalam-render-hadith-citation", children: `[${t.citation}]` }),
181
- t.grade && /* @__PURE__ */ q("span", { className: "qalam-render-hadith-grade", children: [
191
+ t.grade && /* @__PURE__ */ g("span", { className: "qalam-render-hadith-grade", children: [
182
192
  "(",
183
193
  t.grade,
184
194
  ")"
@@ -186,15 +196,15 @@ function ie({ node: e }) {
186
196
  ] });
187
197
  }
188
198
  function le({ node: e }) {
189
- const { citation: t } = e.attrs;
190
- return /* @__PURE__ */ q("span", { className: "qalam-render-quote", children: [
199
+ const t = e.attrs?.citation;
200
+ return /* @__PURE__ */ g("span", { className: "qalam-render-quote", children: [
191
201
  /* @__PURE__ */ r("span", { className: "qalam-render-quote-bracket", children: "”" }),
192
- e.content?.map((n, a) => /* @__PURE__ */ r(C, { node: n }, a)),
202
+ e.content?.map((n, a) => /* @__PURE__ */ r(_, { node: n }, a)),
193
203
  /* @__PURE__ */ r("span", { className: "qalam-render-quote-bracket", children: "“" }),
194
204
  t && /* @__PURE__ */ r("cite", { className: "qalam-render-quote-citation", children: ` [${t}]` })
195
205
  ] });
196
206
  }
197
- function C({ node: e }) {
207
+ function _({ node: e }) {
198
208
  switch (e.type) {
199
209
  case "text":
200
210
  return /* @__PURE__ */ r(ae, { node: e });
@@ -212,84 +222,84 @@ function C({ node: e }) {
212
222
  }
213
223
  function oe({ node: e }) {
214
224
  const t = O(null), [n, a] = F(null), [s, i] = F(!1), [c, l] = F(void 0);
215
- return J(() => {
216
- const o = t.current;
217
- if (!o) return;
218
- const d = document.createElement("span");
219
- d.className = "qalam-render-poem__shatr", d.style.position = "absolute", d.style.visibility = "hidden", d.style.whiteSpace = "nowrap", d.style.width = "auto", o.appendChild(d);
220
- const u = (h) => (d.textContent = h, d.scrollWidth), p = o.parentElement?.clientWidth ?? o.clientWidth, m = 32;
221
- let N = 1;
222
- for (const h of e.content)
223
- !h.attrs.separator && h.attrs.parts.length > N && (N = h.attrs.parts.length);
224
- const w = p / N, y = w - m;
225
- let g = !1, k = 0;
226
- const v = [];
227
- for (let h = 0; h < e.content.length; h++) {
228
- const b = e.content[h];
229
- if (!b.attrs.separator)
230
- for (let R = 0; R < b.attrs.parts.length; R++) {
231
- const L = b.attrs.parts[R], $ = L ? u(L) : 0;
232
- v.push({ key: `${h}-${R}`, text: L, naturalWidth: $ }), L && ($ > k && (k = $), b.attrs.parts.length > 1 && $ > y && (g = !0));
225
+ return K(() => {
226
+ const d = t.current;
227
+ if (!d) return;
228
+ const p = document.createElement("span");
229
+ p.className = "qalam-render-poem__shatr", p.style.position = "absolute", p.style.visibility = "hidden", p.style.whiteSpace = "nowrap", p.style.width = "auto", d.appendChild(p);
230
+ const m = (u) => (p.textContent = u, p.scrollWidth), o = d.parentElement?.clientWidth ?? d.clientWidth, h = 32;
231
+ let f = 1;
232
+ for (const u of e.content)
233
+ !u.attrs.separator && u.attrs.parts.length > f && (f = u.attrs.parts.length);
234
+ const k = o / f, b = k - h;
235
+ let q = !1, y = 0;
236
+ const R = [];
237
+ for (let u = 0; u < e.content.length; u++) {
238
+ const x = e.content[u];
239
+ if (!x.attrs.separator)
240
+ for (let w = 0; w < x.attrs.parts.length; w++) {
241
+ const W = x.attrs.parts[w], $ = W ? m(W) : 0;
242
+ R.push({ key: `${u}-${w}`, text: W, naturalWidth: $ }), W && ($ > y && (y = $), x.attrs.parts.length > 1 && $ > b && (q = !0));
233
243
  }
234
244
  }
235
- i(g);
236
- const f = k * 1.3 + m, _ = Math.min(f, w), I = g ? k : _ - m;
237
- l(g ? p : Math.min(_ * N, p));
238
- const x = /* @__PURE__ */ new Map();
239
- for (const { key: h, text: b, naturalWidth: R } of v) {
240
- if (!b) {
241
- x.set(h, b);
245
+ i(q);
246
+ const N = y * 1.3 + h, I = Math.min(N, k), L = q ? y : I - h;
247
+ l(q ? o : Math.min(I * f, o));
248
+ const E = /* @__PURE__ */ new Map();
249
+ for (const { key: u, text: x, naturalWidth: w } of R) {
250
+ if (!x) {
251
+ E.set(u, x);
242
252
  continue;
243
253
  }
244
- R >= I ? x.set(h, b) : x.set(h, ne(b, u, I));
254
+ w >= L ? E.set(u, x) : E.set(u, ne(x, m, L));
245
255
  }
246
- o.removeChild(d), a(x);
247
- }, [e]), /* @__PURE__ */ q("div", { ref: t, className: `qalam-render-poem${s ? " qalam-render-poem--stacked" : ""}`, style: c ? { maxWidth: c } : void 0, children: [
256
+ d.removeChild(p), a(E);
257
+ }, [e]), /* @__PURE__ */ g("div", { ref: t, className: `qalam-render-poem${s ? " qalam-render-poem--stacked" : ""}`, style: c ? { maxWidth: c } : void 0, children: [
248
258
  e.content.map(
249
- (o, d) => o.attrs.separator ? /* @__PURE__ */ r("div", { className: "qalam-render-poem__separator", children: "* * *" }, d) : /* @__PURE__ */ q("div", { className: "qalam-render-poem__bayt", children: [
250
- o.attrs.parts.map((u, p) => {
251
- const m = `${d}-${p}`, N = n?.get(m) ?? u;
259
+ (d, p) => d.attrs.separator ? /* @__PURE__ */ r("div", { className: "qalam-render-poem__separator", children: "* * *" }, p) : /* @__PURE__ */ g("div", { className: "qalam-render-poem__bayt", children: [
260
+ d.attrs.parts.map((m, o) => {
261
+ const h = `${p}-${o}`, f = n?.get(h) ?? m;
252
262
  return /* @__PURE__ */ r(
253
263
  "span",
254
264
  {
255
265
  className: "qalam-render-poem__shatr",
256
- "data-shatr-key": m,
257
- "data-shatr-text": u,
258
- children: N
266
+ "data-shatr-key": h,
267
+ "data-shatr-text": m,
268
+ children: f
259
269
  },
260
- p
270
+ o
261
271
  );
262
272
  }),
263
- (o.attrs.repeat ?? 1) > 1 && /* @__PURE__ */ r("span", { className: "qalam-render-poem__repeat-badge", children: E(o.attrs.repeat) })
264
- ] }, d)
273
+ (d.attrs.repeat ?? 1) > 1 && /* @__PURE__ */ r("span", { className: "qalam-render-poem__repeat-badge", children: C(d.attrs.repeat) })
274
+ ] }, p)
265
275
  ),
266
276
  e.attrs?.citation && /* @__PURE__ */ r("cite", { className: "qalam-render-poem-citation", children: `[${e.attrs.citation}]` })
267
277
  ] });
268
278
  }
269
- function W({ node: e }) {
279
+ function T({ node: e }) {
270
280
  switch (e.type) {
271
281
  case "paragraph": {
272
282
  const t = e.attrs?.repeat ?? 1;
273
- return t > 1 ? /* @__PURE__ */ q("p", { className: "qalam-render-block-repeat", children: [
274
- e.content?.map((n, a) => /* @__PURE__ */ r(C, { node: n }, a)),
275
- /* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-ghost", children: E(t) }),
276
- /* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-badge", children: E(t) })
277
- ] }) : /* @__PURE__ */ r("p", { children: e.content?.map((n, a) => /* @__PURE__ */ r(C, { node: n }, a)) });
283
+ return t > 1 ? /* @__PURE__ */ g("p", { className: "qalam-render-block-repeat", children: [
284
+ e.content?.map((n, a) => /* @__PURE__ */ r(_, { node: n }, a)),
285
+ /* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-ghost", children: C(t) }),
286
+ /* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-badge", children: C(t) })
287
+ ] }) : /* @__PURE__ */ r("p", { children: e.content?.map((n, a) => /* @__PURE__ */ r(_, { node: n }, a)) });
278
288
  }
279
289
  case "heading": {
280
290
  const t = `h${e.attrs.level}`;
281
- return /* @__PURE__ */ r(t, { children: e.content?.map((n, a) => /* @__PURE__ */ r(C, { node: n }, a)) });
291
+ return /* @__PURE__ */ r(t, { children: e.content?.map((n, a) => /* @__PURE__ */ r(_, { node: n }, a)) });
282
292
  }
283
293
  case "bulletList":
284
- return /* @__PURE__ */ r("ul", { children: e.content.map((t, n) => /* @__PURE__ */ r("li", { children: t.content.map((a, s) => /* @__PURE__ */ r(W, { node: a }, s)) }, n)) });
294
+ return /* @__PURE__ */ r("ul", { children: e.content.map((t, n) => /* @__PURE__ */ r("li", { children: t.content.map((a, s) => /* @__PURE__ */ r(T, { node: a }, s)) }, n)) });
285
295
  case "orderedList":
286
- return /* @__PURE__ */ r("ol", { ...e.attrs?.listType === "abjad" ? { "data-list-type": "abjad", style: { "--qalam-ol-style": "abjad" } } : {}, children: e.content.map((t, n) => /* @__PURE__ */ r("li", { children: t.content.map((a, s) => /* @__PURE__ */ r(W, { node: a }, s)) }, n)) });
296
+ return /* @__PURE__ */ r("ol", { ...e.attrs?.listType === "abjad" ? { "data-list-type": "abjad", style: { "--qalam-ol-style": "abjad" } } : {}, children: e.content.map((t, n) => /* @__PURE__ */ r("li", { children: t.content.map((a, s) => /* @__PURE__ */ r(T, { node: a }, s)) }, n)) });
287
297
  case "blockquote": {
288
298
  const t = e.attrs?.repeat ?? 1, n = e.attrs?.citation;
289
- return /* @__PURE__ */ q("blockquote", { className: t > 1 ? "qalam-render-block-repeat" : void 0, ...n ? { "data-citation": n } : {}, children: [
290
- e.content.map((a, s) => /* @__PURE__ */ r(W, { node: a }, s)),
299
+ return /* @__PURE__ */ g("blockquote", { className: t > 1 ? "qalam-render-block-repeat" : void 0, ...n ? { "data-citation": n } : {}, children: [
300
+ e.content.map((a, s) => /* @__PURE__ */ r(T, { node: a }, s)),
291
301
  n && /* @__PURE__ */ r("cite", { className: "qalam-render-blockquote-citation", children: `[${n}]` }),
292
- t > 1 && /* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-badge", children: E(t) })
302
+ t > 1 && /* @__PURE__ */ r("span", { className: "qalam-render-block-repeat-badge", children: C(t) })
293
303
  ] });
294
304
  }
295
305
  case "poem":
@@ -299,41 +309,41 @@ function W({ node: e }) {
299
309
  }
300
310
  }
301
311
  function he({ doc: e, className: t, dir: n = "rtl" }) {
302
- const a = O(null), s = Q((i) => {
312
+ const a = O(null), s = G((i) => {
303
313
  const c = window.getSelection();
304
314
  if (!c || c.isCollapsed) return;
305
315
  const l = a.current;
306
316
  if (!l) return;
307
- const o = c.getRangeAt(0), d = l.querySelectorAll(".qalam-render-quran");
308
- let u = !1;
309
- for (const f of d)
310
- if (o.intersectsNode(f)) {
311
- u = !0;
317
+ const d = c.getRangeAt(0), p = l.querySelectorAll(".qalam-render-quran");
318
+ let m = !1;
319
+ for (const N of p)
320
+ if (d.intersectsNode(N)) {
321
+ m = !0;
312
322
  break;
313
323
  }
314
- if (!u) return;
324
+ if (!m) return;
315
325
  i.preventDefault();
316
- const p = o.cloneRange();
317
- for (const f of d)
318
- o.intersectsNode(f) && (f.contains(o.startContainer) && p.setStartBefore(f), f.contains(o.endContainer) && p.setEndAfter(f));
319
- const m = p.cloneContents(), N = document.createTreeWalker(m, NodeFilter.SHOW_ELEMENT), w = [];
320
- let y = N.currentNode;
321
- for (; y; )
322
- y instanceof HTMLElement && y.classList.contains("qalam-render-quran") && w.push(y), y = N.nextNode();
323
- for (const f of w) {
324
- const _ = f.dataset.copy || "", I = f.dataset.citation || "", x = document.createElement("span");
325
- x.textContent = `﴿${_}﴾ [${I}]`, f.replaceWith(x);
326
+ const o = d.cloneRange();
327
+ for (const N of p)
328
+ d.intersectsNode(N) && (N.contains(d.startContainer) && o.setStartBefore(N), N.contains(d.endContainer) && o.setEndAfter(N));
329
+ const h = o.cloneContents(), f = document.createTreeWalker(h, NodeFilter.SHOW_ELEMENT), k = [];
330
+ let b = f.currentNode;
331
+ for (; b; )
332
+ b instanceof HTMLElement && b.classList.contains("qalam-render-quran") && k.push(b), b = f.nextNode();
333
+ for (const N of k) {
334
+ const I = N.dataset.copy || "", L = N.dataset.citation || "", E = document.createElement("span");
335
+ E.textContent = `﴿${I}﴾ [${L}]`, N.replaceWith(E);
326
336
  }
327
- const g = document.createElement("div");
328
- g.appendChild(m), document.body.appendChild(g);
329
- const k = g.innerText, v = g.innerHTML;
330
- document.body.removeChild(g), i.clipboardData?.setData("text/plain", k), i.clipboardData?.setData("text/html", v);
337
+ const q = document.createElement("div");
338
+ q.appendChild(h), document.body.appendChild(q);
339
+ const y = q.innerText, R = q.innerHTML;
340
+ document.body.removeChild(q), i.clipboardData?.setData("text/plain", y), i.clipboardData?.setData("text/html", R);
331
341
  }, []);
332
- return G(() => {
342
+ return J(() => {
333
343
  const i = a.current;
334
344
  if (i)
335
345
  return i.addEventListener("copy", s), () => i.removeEventListener("copy", s);
336
- }, [s]), /* @__PURE__ */ r("div", { ref: a, className: `qalam-renderer ${t ?? ""}`, dir: n, children: e.content.map((i, c) => /* @__PURE__ */ r(W, { node: i }, c)) });
346
+ }, [s]), /* @__PURE__ */ r("div", { ref: a, className: `qalam-renderer ${t ?? ""}`, dir: n, children: e.content.map((i, c) => /* @__PURE__ */ r(T, { node: i }, c)) });
337
347
  }
338
348
  export {
339
349
  he as Q
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { validateAST as e } from "./schema/index.js";
2
2
  import { Q as s, a as t } from "./QalamEditor-sYrI0Izl.js";
3
- import { Q as f } from "./QalamRenderer-CQRQmyKZ.js";
3
+ import { Q as f } from "./QalamRenderer-CbbJYMLn.js";
4
4
  import { resolveAST as d } from "./resolver/index.js";
5
5
  import { g as Q, a as p, b as u, i as S, l as g, r as i } from "./lookup-CFbcujyG.js";
6
6
  export {
@@ -1,4 +1,4 @@
1
- import { Q as a } from "../QalamRenderer-CQRQmyKZ.js";
1
+ import { Q as a } from "../QalamRenderer-CbbJYMLn.js";
2
2
  export {
3
3
  a as QalamRenderer
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"file":"tatweel.d.ts","sourceRoot":"","sources":["../../src/renderer/tatweel.ts"],"names":[],"mappings":"AA2IA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EACnC,WAAW,EAAE,MAAM,EACnB,aAAa,GAAE,MAAW,GACzB,MAAM,CA0CR"}
1
+ {"version":3,"file":"tatweel.d.ts","sourceRoot":"","sources":["../../src/renderer/tatweel.ts"],"names":[],"mappings":"AA2IA;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,EACnC,WAAW,EAAE,MAAM,EACnB,aAAa,GAAE,MAAW,GACzB,MAAM,CA6DR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siladev/qalam",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Islamic content editor with Quran verse references",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",