@tarekeldeeb/quran-madina-react 1.0.2 → 2.1.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/README.md CHANGED
@@ -27,7 +27,7 @@ export default function App() {
27
27
  return (
28
28
  <div dir="rtl">
29
29
  {/* full page */}
30
- <QuranMadinaHtml page={106} font="Hafs" />
30
+ <QuranMadinaHtml page={106} layout="1441H" />
31
31
 
32
32
  {/* aya range */}
33
33
  <QuranMadinaHtml sura={2} aya="8-10" />
@@ -55,21 +55,23 @@ export default function App() {
55
55
 
56
56
  | Prop | Type | Notes |
57
57
  |-------------|---------------------|-------|
58
- | `page` | number \| string | Full page 1–604. Mutually exclusive with `sura`/`aya` (page wins). |
58
+ | `page` | number \| string | Full page 1–604 (IndoPak 1–610). Mutually exclusive with `sura`/`aya` (page wins). |
59
59
  | `sura` | number \| string | Sura 1–114, with `aya`. |
60
60
  | `aya` | number \| string | Aya or range, e.g. `"8-10"`. |
61
61
  | `words` | string | 1-based word range: `"1:2"`, `"3-10"`, or a single index. |
62
+ | `highlight` | string | 1-based word range to mark soft yellow, e.g. `"5-8"`. |
62
63
  | `error` | string | 1-based word range to mark with built-in "error" highlight styling, e.g. `"10-13"`. |
64
+ | `letters` | string | Letters to emphasise inside words: `"1:3 crimson, 4:3-5 emerald"` (word:letters, optional colour — crimson by default — and optional `blink`). |
63
65
  | `headless` | boolean | Drop the header/copy chrome. |
64
66
  | `quotes` | string | `"no"` (or `"false"`) drops the quote marks shown around inline (single-line) renders. |
65
67
  | `inline` | string | `"no"` forces the multiline/header layout even for a selection that fits one line. `"auto"` (default) is fit-based. `"yes"` (force a single line for an overflowing selection) is not implemented yet. |
66
- | `font` | string | `Hafs`, `Uthman`, `Amiri Quran`, `Amiri Quran Colored`, `me_quran`. |
67
- | `name` | string | DB name, default `Madina05`. |
68
- | `fontSize` | number \| string | px, default 16. Any size 6–100: 16 and 24 have pre-built DBs, every other size is interpolated between them at load time. |
68
+ | `layout` | string | `1441H` (default), `1405H` or `IndoPak`. Letters are stretched like the print; any `fontSize` works. |
69
+ | `font`, `name` | string | Deprecated: ignored since 2.0 (the library logs a warning). |
70
+ | `fontSize` | number \| string | px, default 16. Any size works. |
69
71
  | `src` | string | Library script URL. Default: unpkg latest. |
70
72
  | `cdn` | string | Base URL for CSS + JSON assets. Default: unpkg package root. |
71
73
 
72
- > **Global config caveat:** `font`, `name`, `fontSize`, `src` and `cdn` configure the single
74
+ > **Global config caveat:** `layout`, `fontSize`, `src` and `cdn` configure the single
73
75
  > library instance for the whole page. Only the **first** mounted `<QuranMadinaHtml>` sets them;
74
76
  > later values are ignored. Put your config on the first instance you render.
75
77
 
@@ -113,7 +115,7 @@ Notes for mobile:
113
115
  - Capacitor serves the app from `localhost`, so keep the default `cdn` (unpkg) **or** self-host the
114
116
  assets and point `cdn` at them — see above. Do not rely on the library's `../` default.
115
117
  - **Offline support:** bundle the library `dist/quran-madina-html.min.js`, `dist/*.min.css`, the
116
- `assets/db/*.json` you use and the `assets/fonts/*.woff2` into your web build, then set `src` to
118
+ `assets/db/v2/` files of the layout you use (its `.json` or shard folder and its `-qmh.woff2` font) into your web build, then set `src` to
117
119
  the bundled JS and `cdn` to the base path that contains `dist/` and `assets/`. Everything —
118
120
  including the font — resolves from `cdn`, so no network is needed (requires library >= 0.6,
119
121
  which stores font paths relative).
package/dist/index.cjs CHANGED
@@ -41,7 +41,7 @@ var DEFAULT_SRC = "https://unpkg.com/quran-madina-html";
41
41
  var DEFAULT_CDN = "https://unpkg.com/quran-madina-html/";
42
42
  var loaderPromise = null;
43
43
  function loadQuranMadinaHtml(opts = {}) {
44
- const { src = DEFAULT_SRC, cdn = DEFAULT_CDN, font, name, fontSize } = opts;
44
+ const { src = DEFAULT_SRC, cdn = DEFAULT_CDN, layout, font, name, fontSize } = opts;
45
45
  if (typeof window === "undefined" || typeof document === "undefined") {
46
46
  return Promise.resolve();
47
47
  }
@@ -55,6 +55,7 @@ function loadQuranMadinaHtml(opts = {}) {
55
55
  script.src = src;
56
56
  script.async = true;
57
57
  if (cdn) script.setAttribute("data-cdn", cdn);
58
+ if (layout) script.setAttribute("data-layout", layout);
58
59
  if (font) script.setAttribute("data-font", font);
59
60
  if (name) script.setAttribute("data-name", name);
60
61
  if (fontSize != null) script.setAttribute("data-font-size", String(fontSize));
@@ -72,7 +73,9 @@ function QuranMadinaHtml({
72
73
  sura,
73
74
  aya,
74
75
  words,
76
+ highlight,
75
77
  error,
78
+ letters,
76
79
  headless,
77
80
  quotes,
78
81
  inline,
@@ -80,6 +83,7 @@ function QuranMadinaHtml({
80
83
  // loader config (only honored on first mount, see loadQuranMadinaHtml)
81
84
  src,
82
85
  cdn,
86
+ layout,
83
87
  font,
84
88
  name,
85
89
  fontSize,
@@ -93,11 +97,11 @@ function QuranMadinaHtml({
93
97
  );
94
98
  (0, import_react.useEffect)(() => {
95
99
  let active = true;
96
- loadQuranMadinaHtml({ src, cdn, font, name, fontSize }).then(() => active && setReady(true)).catch((err) => console.error("[quran-madina-html]", err));
100
+ loadQuranMadinaHtml({ src, cdn, layout, font, name, fontSize }).then(() => active && setReady(true)).catch((err) => console.error("[quran-madina-html]", err));
97
101
  return () => {
98
102
  active = false;
99
103
  };
100
- }, [src, cdn, font, name, fontSize]);
104
+ }, [src, cdn, layout, font, name, fontSize]);
101
105
  (0, import_react.useEffect)(() => {
102
106
  const el = ref.current;
103
107
  if (!el) return;
@@ -118,11 +122,13 @@ function QuranMadinaHtml({
118
122
  set("aya", aya);
119
123
  }
120
124
  set("words", words);
125
+ set("highlight", highlight);
121
126
  set("error", error);
127
+ set("letters", letters);
122
128
  set("headless", headless);
123
129
  set("quotes", quotes);
124
130
  set("inline", inline);
125
131
  set("notitle", notitle);
126
- }, [ready, page, sura, aya, words, error, headless, quotes, inline, notitle]);
132
+ }, [ready, page, sura, aya, words, highlight, error, letters, headless, quotes, inline, notitle]);
127
133
  return import_react.default.createElement(TAG, { ref, class: className, style, ...rest });
128
134
  }
package/dist/index.d.ts CHANGED
@@ -5,21 +5,23 @@ export interface QuranMadinaHtmlLoaderOptions {
5
5
  src?: string;
6
6
  /** Base URL for the CSS + JSON assets (default: https://unpkg.com/quran-madina-html/). */
7
7
  cdn?: string;
8
- /** data-font: "Hafs" | "Uthman" | "Amiri Quran" | "Amiri Quran Colored" | "me_quran". */
9
- font?: string;
10
- /** data-name (default "Madina05"). */
11
- name?: string;
12
8
  /**
13
- * data-font-size in px (default 16). Any size from 6 to 100 works: 16 and 24 have pre-built
14
- * databases, every other size is fitted at load time by linear interpolation between them.
9
+ * data-layout: "1441H" (default) | "1405H" | "IndoPak". Letters are stretched like the
10
+ * print and any font size works with one DB per layout.
15
11
  */
12
+ layout?: "1441H" | "1405H" | "IndoPak" | string;
13
+ /** @deprecated Ignored since 2.0 (every tag uses the v2 fonts; a warning is logged). */
14
+ font?: string;
15
+ /** @deprecated Ignored since 2.0 (a warning is logged). */
16
+ name?: string;
17
+ /** data-font-size in px (default 16). Any size works. */
16
18
  fontSize?: number | string;
17
19
  }
18
20
 
19
21
  export interface QuranMadinaHtmlProps
20
22
  extends QuranMadinaHtmlLoaderOptions,
21
23
  React.HTMLAttributes<HTMLElement> {
22
- /** Render a full Madina page (1-604). Mutually exclusive with sura/aya. */
24
+ /** Render a full page (1-604; IndoPak 1-610). Mutually exclusive with sura/aya. */
23
25
  page?: number | string;
24
26
  /** Sura number (1-114). Use together with `aya`. */
25
27
  sura?: number | string;
@@ -27,11 +29,21 @@ export interface QuranMadinaHtmlProps
27
29
  aya?: number | string;
28
30
  /** Restrict to a 1-based word range, e.g. "1:2", "3-10", or a single index. */
29
31
  words?: string;
32
+ /** 1-based inclusive word range (same syntax as `words`) to mark soft yellow. */
33
+ highlight?: string;
30
34
  /**
31
35
  * 1-based inclusive word range (same syntax as `words`) marking a sub-range that should
32
36
  * render with the library's built-in "error" highlight styling.
33
37
  */
34
38
  error?: string;
39
+ /**
40
+ * Letters to emphasise inside words: comma-separated groups "word:letters [colour] [blink]",
41
+ * e.g. "1:3 crimson, 4:3-5 emerald blink, 6:2+4". Word numbers count like highlight/error;
42
+ * letters are n, n-m or n+m; the colour is optional (crimson by default): crimson, emerald,
43
+ * lapis, gold, violet or any CSS colour; "blink" makes the letter's halo pulse (no animation
44
+ * by default). Nothing moves.
45
+ */
46
+ letters?: string;
35
47
  /** Drop the header / copy chrome and render only the Quran text. */
36
48
  headless?: boolean;
37
49
  /**
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ var DEFAULT_SRC = "https://unpkg.com/quran-madina-html";
5
5
  var DEFAULT_CDN = "https://unpkg.com/quran-madina-html/";
6
6
  var loaderPromise = null;
7
7
  function loadQuranMadinaHtml(opts = {}) {
8
- const { src = DEFAULT_SRC, cdn = DEFAULT_CDN, font, name, fontSize } = opts;
8
+ const { src = DEFAULT_SRC, cdn = DEFAULT_CDN, layout, font, name, fontSize } = opts;
9
9
  if (typeof window === "undefined" || typeof document === "undefined") {
10
10
  return Promise.resolve();
11
11
  }
@@ -19,6 +19,7 @@ function loadQuranMadinaHtml(opts = {}) {
19
19
  script.src = src;
20
20
  script.async = true;
21
21
  if (cdn) script.setAttribute("data-cdn", cdn);
22
+ if (layout) script.setAttribute("data-layout", layout);
22
23
  if (font) script.setAttribute("data-font", font);
23
24
  if (name) script.setAttribute("data-name", name);
24
25
  if (fontSize != null) script.setAttribute("data-font-size", String(fontSize));
@@ -36,7 +37,9 @@ function QuranMadinaHtml({
36
37
  sura,
37
38
  aya,
38
39
  words,
40
+ highlight,
39
41
  error,
42
+ letters,
40
43
  headless,
41
44
  quotes,
42
45
  inline,
@@ -44,6 +47,7 @@ function QuranMadinaHtml({
44
47
  // loader config (only honored on first mount, see loadQuranMadinaHtml)
45
48
  src,
46
49
  cdn,
50
+ layout,
47
51
  font,
48
52
  name,
49
53
  fontSize,
@@ -57,11 +61,11 @@ function QuranMadinaHtml({
57
61
  );
58
62
  useEffect(() => {
59
63
  let active = true;
60
- loadQuranMadinaHtml({ src, cdn, font, name, fontSize }).then(() => active && setReady(true)).catch((err) => console.error("[quran-madina-html]", err));
64
+ loadQuranMadinaHtml({ src, cdn, layout, font, name, fontSize }).then(() => active && setReady(true)).catch((err) => console.error("[quran-madina-html]", err));
61
65
  return () => {
62
66
  active = false;
63
67
  };
64
- }, [src, cdn, font, name, fontSize]);
68
+ }, [src, cdn, layout, font, name, fontSize]);
65
69
  useEffect(() => {
66
70
  const el = ref.current;
67
71
  if (!el) return;
@@ -82,12 +86,14 @@ function QuranMadinaHtml({
82
86
  set("aya", aya);
83
87
  }
84
88
  set("words", words);
89
+ set("highlight", highlight);
85
90
  set("error", error);
91
+ set("letters", letters);
86
92
  set("headless", headless);
87
93
  set("quotes", quotes);
88
94
  set("inline", inline);
89
95
  set("notitle", notitle);
90
- }, [ready, page, sura, aya, words, error, headless, quotes, inline, notitle]);
96
+ }, [ready, page, sura, aya, words, highlight, error, letters, headless, quotes, inline, notitle]);
91
97
  return React.createElement(TAG, { ref, class: className, style, ...rest });
92
98
  }
93
99
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tarekeldeeb/quran-madina-react",
3
- "version": "1.0.2",
3
+ "version": "2.1.0",
4
4
  "description": "React wrapper for the quran-madina-html custom element — render Madina-style Quran pages (no images) in React on web and mobile (via a Capacitor WebView).",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",