@inshapardaz/likhari-react 0.1.6-dev.68 → 0.1.6
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/EditorRoot.d.ts +1 -25
- package/dist/EditorRoot.d.ts.map +1 -1
- package/dist/EditorRoot.js +5 -24
- package/dist/components/LinkDialog.d.ts.map +1 -1
- package/dist/components/LinkDialog.js +3 -7
- package/dist/components/Toolbar.d.ts +1 -4
- package/dist/components/Toolbar.d.ts.map +1 -1
- package/dist/components/Toolbar.js +31 -215
- package/dist/index.d.ts +0 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/nodes.d.ts.map +1 -1
- package/dist/nodes.js +0 -2
- package/dist/theme/EditorThemeProvider.d.ts +1 -17
- package/dist/theme/EditorThemeProvider.d.ts.map +1 -1
- package/dist/theme/EditorThemeProvider.js +2 -24
- package/dist/theme/editor.css +0 -125
- package/dist/theme/editorTheme.d.ts.map +1 -1
- package/dist/theme/editorTheme.js +0 -1
- package/package.json +1 -2
- package/dist/PortalTargetContext.d.ts +0 -16
- package/dist/PortalTargetContext.d.ts.map +0 -1
- package/dist/PortalTargetContext.js +0 -18
- package/dist/i18n/index.d.ts +0 -4
- package/dist/i18n/index.d.ts.map +0 -1
- package/dist/i18n/index.js +0 -2
- package/dist/i18n/strings.d.ts +0 -158
- package/dist/i18n/strings.d.ts.map +0 -1
- package/dist/i18n/strings.js +0 -425
- package/dist/i18n/useStrings.d.ts +0 -10
- package/dist/i18n/useStrings.d.ts.map +0 -1
- package/dist/i18n/useStrings.js +0 -14
- package/dist/image/ImageComponent.d.ts +0 -23
- package/dist/image/ImageComponent.d.ts.map +0 -1
- package/dist/image/ImageComponent.js +0 -171
- package/dist/image/ImageCropDialog.d.ts +0 -22
- package/dist/image/ImageCropDialog.d.ts.map +0 -1
- package/dist/image/ImageCropDialog.js +0 -120
- package/dist/image/ImageCropper.d.ts +0 -15
- package/dist/image/ImageCropper.d.ts.map +0 -1
- package/dist/image/ImageCropper.js +0 -120
- package/dist/image/ImageDialog.d.ts +0 -37
- package/dist/image/ImageDialog.d.ts.map +0 -1
- package/dist/image/ImageDialog.js +0 -176
- package/dist/image/ImageNode.d.ts +0 -64
- package/dist/image/ImageNode.d.ts.map +0 -1
- package/dist/image/ImageNode.js +0 -133
- package/dist/image/ImageOptionsContext.d.ts +0 -24
- package/dist/image/ImageOptionsContext.d.ts.map +0 -1
- package/dist/image/ImageOptionsContext.js +0 -10
- package/dist/image/cropMath.d.ts +0 -35
- package/dist/image/cropMath.d.ts.map +0 -1
- package/dist/image/cropMath.js +0 -92
- package/dist/image/imageEdit.d.ts +0 -49
- package/dist/image/imageEdit.d.ts.map +0 -1
- package/dist/image/imageEdit.js +0 -132
- package/dist/image/imageUrl.d.ts +0 -14
- package/dist/image/imageUrl.d.ts.map +0 -1
- package/dist/image/imageUrl.js +0 -27
- package/dist/theme/accentColor.d.ts +0 -43
- package/dist/theme/accentColor.d.ts.map +0 -1
- package/dist/theme/accentColor.js +0 -84
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Derives Mantine's 10-shade color array and the editor's own
|
|
3
|
-
* `--editor-accent` / `--editor-accent-soft` pair from a single
|
|
4
|
-
* host-supplied accent color (EditorRootProps.accentColor). No color
|
|
5
|
-
* library needed — a few lines of hex parsing plus RGB lerp is enough for a
|
|
6
|
-
* usable (not professionally calibrated) ramp.
|
|
7
|
-
*/
|
|
8
|
-
/** Parses a `#rgb` or `#rrggbb` hex color. Returns null for anything else —
|
|
9
|
-
* callers fall back to the static default tokens rather than throwing on a
|
|
10
|
-
* bad host-supplied value. */
|
|
11
|
-
export function hexToRgb(hex) {
|
|
12
|
-
const cleaned = hex.trim().replace(/^#/, '');
|
|
13
|
-
const full = cleaned.length === 3
|
|
14
|
-
? cleaned
|
|
15
|
-
.split('')
|
|
16
|
-
.map((c) => c + c)
|
|
17
|
-
.join('')
|
|
18
|
-
: cleaned;
|
|
19
|
-
if (!/^[0-9a-fA-F]{6}$/.test(full))
|
|
20
|
-
return null;
|
|
21
|
-
return {
|
|
22
|
-
r: parseInt(full.slice(0, 2), 16),
|
|
23
|
-
g: parseInt(full.slice(2, 4), 16),
|
|
24
|
-
b: parseInt(full.slice(4, 6), 16),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
function toHex(n) {
|
|
28
|
-
return Math.round(Math.min(255, Math.max(0, n)))
|
|
29
|
-
.toString(16)
|
|
30
|
-
.padStart(2, '0');
|
|
31
|
-
}
|
|
32
|
-
export function rgbToHex({ r, g, b }) {
|
|
33
|
-
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
34
|
-
}
|
|
35
|
-
/** Linear-interpolates two colors; t=0 -> a, t=1 -> b. */
|
|
36
|
-
export function mix(a, b, t) {
|
|
37
|
-
return {
|
|
38
|
-
r: a.r + (b.r - a.r) * t,
|
|
39
|
-
g: a.g + (b.g - a.g) * t,
|
|
40
|
-
b: a.b + (b.b - a.b) * t,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
const WHITE = { r: 255, g: 255, b: 255 };
|
|
44
|
-
const BLACK = { r: 0, g: 0, b: 0 };
|
|
45
|
-
/**
|
|
46
|
-
* A 10-shade Mantine color array for `theme.colors.likhariAccent`, mixing
|
|
47
|
-
* the base color towards white for the lighter shades (0-4ish) and towards
|
|
48
|
-
* black for the darker ones (6-9ish) — shade 6 (Mantine's default "filled"
|
|
49
|
-
* shade) is the exact input color, matching what the static
|
|
50
|
-
* `likhariAccent` ramp already did for the default tokens.
|
|
51
|
-
*/
|
|
52
|
-
export function generateAccentShades(hex) {
|
|
53
|
-
const base = hexToRgb(hex);
|
|
54
|
-
if (!base)
|
|
55
|
-
return null;
|
|
56
|
-
// How far to mix towards white (positive) or black (negative) per shade,
|
|
57
|
-
// relative to shade 6 = the exact input color.
|
|
58
|
-
const mixAmount = [0.88, 0.72, 0.56, 0.4, 0.22, 0.1, 0, -0.14, -0.28, -0.42];
|
|
59
|
-
const shades = mixAmount.map((t) => rgbToHex(mix(base, t >= 0 ? WHITE : BLACK, Math.abs(t))));
|
|
60
|
-
return shades;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* The editor canvas/toolbar's own `--editor-accent` / `--editor-accent-soft`
|
|
64
|
-
* pair for a host-supplied accent color, mirroring the relationship between
|
|
65
|
-
* `LIGHT_TOKENS`/`DARK_TOKENS`'s `accent`/`accentSoft` (packages/core/src/theme/tokens.ts):
|
|
66
|
-
* light mode keeps the accent as given and derives a light tint for "soft";
|
|
67
|
-
* dark mode lightens the accent itself (for contrast against a dark canvas)
|
|
68
|
-
* and derives a dark tint for "soft".
|
|
69
|
-
*/
|
|
70
|
-
export function generateAccentCssVars(hex, mode) {
|
|
71
|
-
const base = hexToRgb(hex);
|
|
72
|
-
if (!base)
|
|
73
|
-
return null;
|
|
74
|
-
if (mode === 'dark') {
|
|
75
|
-
return {
|
|
76
|
-
accent: rgbToHex(mix(base, WHITE, 0.45)),
|
|
77
|
-
accentSoft: rgbToHex(mix(base, BLACK, 0.75)),
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
return {
|
|
81
|
-
accent: hex,
|
|
82
|
-
accentSoft: rgbToHex(mix(base, WHITE, 0.88)),
|
|
83
|
-
};
|
|
84
|
-
}
|