@tarekeldeeb/quran-madina-react 1.0.2 → 2.0.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 +8 -7
- package/dist/index.cjs +8 -4
- package/dist/index.d.ts +11 -7
- package/dist/index.mjs +8 -4
- package/package.json +1 -1
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}
|
|
30
|
+
<QuranMadinaHtml page={106} layout="1441H" />
|
|
31
31
|
|
|
32
32
|
{/* aya range */}
|
|
33
33
|
<QuranMadinaHtml sura={2} aya="8-10" />
|
|
@@ -55,21 +55,22 @@ 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"`. |
|
|
63
64
|
| `headless` | boolean | Drop the header/copy chrome. |
|
|
64
65
|
| `quotes` | string | `"no"` (or `"false"`) drops the quote marks shown around inline (single-line) renders. |
|
|
65
66
|
| `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
|
-
| `
|
|
67
|
-
| `name`
|
|
68
|
-
| `fontSize` | number \| string | px, default 16. Any size
|
|
67
|
+
| `layout` | string | `1441H` (default), `1405H` or `IndoPak`. Letters are stretched like the print; any `fontSize` works. |
|
|
68
|
+
| `font`, `name` | string | Deprecated: ignored since 2.0 (the library logs a warning). |
|
|
69
|
+
| `fontSize` | number \| string | px, default 16. Any size works. |
|
|
69
70
|
| `src` | string | Library script URL. Default: unpkg latest. |
|
|
70
71
|
| `cdn` | string | Base URL for CSS + JSON assets. Default: unpkg package root. |
|
|
71
72
|
|
|
72
|
-
> **Global config caveat:** `
|
|
73
|
+
> **Global config caveat:** `layout`, `fontSize`, `src` and `cdn` configure the single
|
|
73
74
|
> library instance for the whole page. Only the **first** mounted `<QuranMadinaHtml>` sets them;
|
|
74
75
|
> later values are ignored. Put your config on the first instance you render.
|
|
75
76
|
|
|
@@ -113,7 +114,7 @@ Notes for mobile:
|
|
|
113
114
|
- Capacitor serves the app from `localhost`, so keep the default `cdn` (unpkg) **or** self-host the
|
|
114
115
|
assets and point `cdn` at them — see above. Do not rely on the library's `../` default.
|
|
115
116
|
- **Offline support:** bundle the library `dist/quran-madina-html.min.js`, `dist/*.min.css`, the
|
|
116
|
-
`assets/db
|
|
117
|
+
`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
118
|
the bundled JS and `cdn` to the base path that contains `dist/` and `assets/`. Everything —
|
|
118
119
|
including the font — resolves from `cdn`, so no network is needed (requires library >= 0.6,
|
|
119
120
|
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,6 +73,7 @@ function QuranMadinaHtml({
|
|
|
72
73
|
sura,
|
|
73
74
|
aya,
|
|
74
75
|
words,
|
|
76
|
+
highlight,
|
|
75
77
|
error,
|
|
76
78
|
headless,
|
|
77
79
|
quotes,
|
|
@@ -80,6 +82,7 @@ function QuranMadinaHtml({
|
|
|
80
82
|
// loader config (only honored on first mount, see loadQuranMadinaHtml)
|
|
81
83
|
src,
|
|
82
84
|
cdn,
|
|
85
|
+
layout,
|
|
83
86
|
font,
|
|
84
87
|
name,
|
|
85
88
|
fontSize,
|
|
@@ -93,11 +96,11 @@ function QuranMadinaHtml({
|
|
|
93
96
|
);
|
|
94
97
|
(0, import_react.useEffect)(() => {
|
|
95
98
|
let active = true;
|
|
96
|
-
loadQuranMadinaHtml({ src, cdn, font, name, fontSize }).then(() => active && setReady(true)).catch((err) => console.error("[quran-madina-html]", err));
|
|
99
|
+
loadQuranMadinaHtml({ src, cdn, layout, font, name, fontSize }).then(() => active && setReady(true)).catch((err) => console.error("[quran-madina-html]", err));
|
|
97
100
|
return () => {
|
|
98
101
|
active = false;
|
|
99
102
|
};
|
|
100
|
-
}, [src, cdn, font, name, fontSize]);
|
|
103
|
+
}, [src, cdn, layout, font, name, fontSize]);
|
|
101
104
|
(0, import_react.useEffect)(() => {
|
|
102
105
|
const el = ref.current;
|
|
103
106
|
if (!el) return;
|
|
@@ -118,11 +121,12 @@ function QuranMadinaHtml({
|
|
|
118
121
|
set("aya", aya);
|
|
119
122
|
}
|
|
120
123
|
set("words", words);
|
|
124
|
+
set("highlight", highlight);
|
|
121
125
|
set("error", error);
|
|
122
126
|
set("headless", headless);
|
|
123
127
|
set("quotes", quotes);
|
|
124
128
|
set("inline", inline);
|
|
125
129
|
set("notitle", notitle);
|
|
126
|
-
}, [ready, page, sura, aya, words, error, headless, quotes, inline, notitle]);
|
|
130
|
+
}, [ready, page, sura, aya, words, highlight, error, headless, quotes, inline, notitle]);
|
|
127
131
|
return import_react.default.createElement(TAG, { ref, class: className, style, ...rest });
|
|
128
132
|
}
|
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-
|
|
14
|
-
*
|
|
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
|
|
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,6 +29,8 @@ 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.
|
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,6 +37,7 @@ function QuranMadinaHtml({
|
|
|
36
37
|
sura,
|
|
37
38
|
aya,
|
|
38
39
|
words,
|
|
40
|
+
highlight,
|
|
39
41
|
error,
|
|
40
42
|
headless,
|
|
41
43
|
quotes,
|
|
@@ -44,6 +46,7 @@ function QuranMadinaHtml({
|
|
|
44
46
|
// loader config (only honored on first mount, see loadQuranMadinaHtml)
|
|
45
47
|
src,
|
|
46
48
|
cdn,
|
|
49
|
+
layout,
|
|
47
50
|
font,
|
|
48
51
|
name,
|
|
49
52
|
fontSize,
|
|
@@ -57,11 +60,11 @@ function QuranMadinaHtml({
|
|
|
57
60
|
);
|
|
58
61
|
useEffect(() => {
|
|
59
62
|
let active = true;
|
|
60
|
-
loadQuranMadinaHtml({ src, cdn, font, name, fontSize }).then(() => active && setReady(true)).catch((err) => console.error("[quran-madina-html]", err));
|
|
63
|
+
loadQuranMadinaHtml({ src, cdn, layout, font, name, fontSize }).then(() => active && setReady(true)).catch((err) => console.error("[quran-madina-html]", err));
|
|
61
64
|
return () => {
|
|
62
65
|
active = false;
|
|
63
66
|
};
|
|
64
|
-
}, [src, cdn, font, name, fontSize]);
|
|
67
|
+
}, [src, cdn, layout, font, name, fontSize]);
|
|
65
68
|
useEffect(() => {
|
|
66
69
|
const el = ref.current;
|
|
67
70
|
if (!el) return;
|
|
@@ -82,12 +85,13 @@ function QuranMadinaHtml({
|
|
|
82
85
|
set("aya", aya);
|
|
83
86
|
}
|
|
84
87
|
set("words", words);
|
|
88
|
+
set("highlight", highlight);
|
|
85
89
|
set("error", error);
|
|
86
90
|
set("headless", headless);
|
|
87
91
|
set("quotes", quotes);
|
|
88
92
|
set("inline", inline);
|
|
89
93
|
set("notitle", notitle);
|
|
90
|
-
}, [ready, page, sura, aya, words, error, headless, quotes, inline, notitle]);
|
|
94
|
+
}, [ready, page, sura, aya, words, highlight, error, headless, quotes, inline, notitle]);
|
|
91
95
|
return React.createElement(TAG, { ref, class: className, style, ...rest });
|
|
92
96
|
}
|
|
93
97
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarekeldeeb/quran-madina-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.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",
|