@tarekeldeeb/quran-madina-react 1.0.1 → 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 +12 -7
- package/dist/index.cjs +10 -4
- package/dist/index.d.ts +16 -7
- package/dist/index.mjs +10 -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" />
|
|
@@ -35,6 +35,9 @@ export default function App() {
|
|
|
35
35
|
{/* a word subsequence (1-based, inclusive) */}
|
|
36
36
|
<QuranMadinaHtml sura={1} aya={1} words="1:2" />
|
|
37
37
|
|
|
38
|
+
{/* highlight an error range */}
|
|
39
|
+
<QuranMadinaHtml sura={1} aya={1} words="1-14" error="10-13" />
|
|
40
|
+
|
|
38
41
|
{/* no header / copy chrome */}
|
|
39
42
|
<QuranMadinaHtml sura={2} aya="13-14" headless />
|
|
40
43
|
|
|
@@ -52,20 +55,22 @@ export default function App() {
|
|
|
52
55
|
|
|
53
56
|
| Prop | Type | Notes |
|
|
54
57
|
|-------------|---------------------|-------|
|
|
55
|
-
| `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). |
|
|
56
59
|
| `sura` | number \| string | Sura 1–114, with `aya`. |
|
|
57
60
|
| `aya` | number \| string | Aya or range, e.g. `"8-10"`. |
|
|
58
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"`. |
|
|
63
|
+
| `error` | string | 1-based word range to mark with built-in "error" highlight styling, e.g. `"10-13"`. |
|
|
59
64
|
| `headless` | boolean | Drop the header/copy chrome. |
|
|
60
65
|
| `quotes` | string | `"no"` (or `"false"`) drops the quote marks shown around inline (single-line) renders. |
|
|
61
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. |
|
|
62
|
-
| `
|
|
63
|
-
| `name`
|
|
64
|
-
| `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. |
|
|
65
70
|
| `src` | string | Library script URL. Default: unpkg latest. |
|
|
66
71
|
| `cdn` | string | Base URL for CSS + JSON assets. Default: unpkg package root. |
|
|
67
72
|
|
|
68
|
-
> **Global config caveat:** `
|
|
73
|
+
> **Global config caveat:** `layout`, `fontSize`, `src` and `cdn` configure the single
|
|
69
74
|
> library instance for the whole page. Only the **first** mounted `<QuranMadinaHtml>` sets them;
|
|
70
75
|
> later values are ignored. Put your config on the first instance you render.
|
|
71
76
|
|
|
@@ -109,7 +114,7 @@ Notes for mobile:
|
|
|
109
114
|
- Capacitor serves the app from `localhost`, so keep the default `cdn` (unpkg) **or** self-host the
|
|
110
115
|
assets and point `cdn` at them — see above. Do not rely on the library's `../` default.
|
|
111
116
|
- **Offline support:** bundle the library `dist/quran-madina-html.min.js`, `dist/*.min.css`, the
|
|
112
|
-
`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
|
|
113
118
|
the bundled JS and `cdn` to the base path that contains `dist/` and `assets/`. Everything —
|
|
114
119
|
including the font — resolves from `cdn`, so no network is needed (requires library >= 0.6,
|
|
115
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,8 @@ function QuranMadinaHtml({
|
|
|
72
73
|
sura,
|
|
73
74
|
aya,
|
|
74
75
|
words,
|
|
76
|
+
highlight,
|
|
77
|
+
error,
|
|
75
78
|
headless,
|
|
76
79
|
quotes,
|
|
77
80
|
inline,
|
|
@@ -79,6 +82,7 @@ function QuranMadinaHtml({
|
|
|
79
82
|
// loader config (only honored on first mount, see loadQuranMadinaHtml)
|
|
80
83
|
src,
|
|
81
84
|
cdn,
|
|
85
|
+
layout,
|
|
82
86
|
font,
|
|
83
87
|
name,
|
|
84
88
|
fontSize,
|
|
@@ -92,11 +96,11 @@ function QuranMadinaHtml({
|
|
|
92
96
|
);
|
|
93
97
|
(0, import_react.useEffect)(() => {
|
|
94
98
|
let active = true;
|
|
95
|
-
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));
|
|
96
100
|
return () => {
|
|
97
101
|
active = false;
|
|
98
102
|
};
|
|
99
|
-
}, [src, cdn, font, name, fontSize]);
|
|
103
|
+
}, [src, cdn, layout, font, name, fontSize]);
|
|
100
104
|
(0, import_react.useEffect)(() => {
|
|
101
105
|
const el = ref.current;
|
|
102
106
|
if (!el) return;
|
|
@@ -117,10 +121,12 @@ function QuranMadinaHtml({
|
|
|
117
121
|
set("aya", aya);
|
|
118
122
|
}
|
|
119
123
|
set("words", words);
|
|
124
|
+
set("highlight", highlight);
|
|
125
|
+
set("error", error);
|
|
120
126
|
set("headless", headless);
|
|
121
127
|
set("quotes", quotes);
|
|
122
128
|
set("inline", inline);
|
|
123
129
|
set("notitle", notitle);
|
|
124
|
-
}, [ready, page, sura, aya, words, headless, quotes, inline, notitle]);
|
|
130
|
+
}, [ready, page, sura, aya, words, highlight, error, headless, quotes, inline, notitle]);
|
|
125
131
|
return import_react.default.createElement(TAG, { ref, class: className, style, ...rest });
|
|
126
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,13 @@ 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;
|
|
34
|
+
/**
|
|
35
|
+
* 1-based inclusive word range (same syntax as `words`) marking a sub-range that should
|
|
36
|
+
* render with the library's built-in "error" highlight styling.
|
|
37
|
+
*/
|
|
38
|
+
error?: string;
|
|
30
39
|
/** Drop the header / copy chrome and render only the Quran text. */
|
|
31
40
|
headless?: boolean;
|
|
32
41
|
/**
|
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,8 @@ function QuranMadinaHtml({
|
|
|
36
37
|
sura,
|
|
37
38
|
aya,
|
|
38
39
|
words,
|
|
40
|
+
highlight,
|
|
41
|
+
error,
|
|
39
42
|
headless,
|
|
40
43
|
quotes,
|
|
41
44
|
inline,
|
|
@@ -43,6 +46,7 @@ function QuranMadinaHtml({
|
|
|
43
46
|
// loader config (only honored on first mount, see loadQuranMadinaHtml)
|
|
44
47
|
src,
|
|
45
48
|
cdn,
|
|
49
|
+
layout,
|
|
46
50
|
font,
|
|
47
51
|
name,
|
|
48
52
|
fontSize,
|
|
@@ -56,11 +60,11 @@ function QuranMadinaHtml({
|
|
|
56
60
|
);
|
|
57
61
|
useEffect(() => {
|
|
58
62
|
let active = true;
|
|
59
|
-
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));
|
|
60
64
|
return () => {
|
|
61
65
|
active = false;
|
|
62
66
|
};
|
|
63
|
-
}, [src, cdn, font, name, fontSize]);
|
|
67
|
+
}, [src, cdn, layout, font, name, fontSize]);
|
|
64
68
|
useEffect(() => {
|
|
65
69
|
const el = ref.current;
|
|
66
70
|
if (!el) return;
|
|
@@ -81,11 +85,13 @@ function QuranMadinaHtml({
|
|
|
81
85
|
set("aya", aya);
|
|
82
86
|
}
|
|
83
87
|
set("words", words);
|
|
88
|
+
set("highlight", highlight);
|
|
89
|
+
set("error", error);
|
|
84
90
|
set("headless", headless);
|
|
85
91
|
set("quotes", quotes);
|
|
86
92
|
set("inline", inline);
|
|
87
93
|
set("notitle", notitle);
|
|
88
|
-
}, [ready, page, sura, aya, words, headless, quotes, inline, notitle]);
|
|
94
|
+
}, [ready, page, sura, aya, words, highlight, error, headless, quotes, inline, notitle]);
|
|
89
95
|
return React.createElement(TAG, { ref, class: className, style, ...rest });
|
|
90
96
|
}
|
|
91
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",
|