@sethumadhavan004/ink-editor 0.0.4 → 0.0.5
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/index.d.mts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +68 -50
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +68 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2419,7 +2419,7 @@ var COLOR_LABELS = {
|
|
|
2419
2419
|
accentColor: "Accent"
|
|
2420
2420
|
};
|
|
2421
2421
|
var COLOR_KEYS = Object.keys(SWATCHES);
|
|
2422
|
-
function ColorPanel({ colors, onChange, open, onToggle, onClose }) {
|
|
2422
|
+
function ColorPanel({ colors, onChange, open, onToggle, onClose, hiddenKeys = [] }) {
|
|
2423
2423
|
const ref = useRef2(null);
|
|
2424
2424
|
useEffect2(() => {
|
|
2425
2425
|
if (!open) return;
|
|
@@ -2444,7 +2444,7 @@ function ColorPanel({ colors, onChange, open, onToggle, onClose }) {
|
|
|
2444
2444
|
children: /* @__PURE__ */ jsx2(Palette, { size: 16 })
|
|
2445
2445
|
}
|
|
2446
2446
|
),
|
|
2447
|
-
open && /* @__PURE__ */ jsx2("div", { className: "ink-popover ink-popover--right ink-color-panel", role: "dialog", "aria-label": "Color customization", children: COLOR_KEYS.map((key) => /* @__PURE__ */ jsxs2("div", { className: "ink-color-row", children: [
|
|
2447
|
+
open && /* @__PURE__ */ jsx2("div", { className: "ink-popover ink-popover--right ink-color-panel", role: "dialog", "aria-label": "Color customization", children: COLOR_KEYS.filter((k) => !hiddenKeys.includes(k)).map((key) => /* @__PURE__ */ jsxs2("div", { className: "ink-color-row", children: [
|
|
2448
2448
|
/* @__PURE__ */ jsx2("span", { className: "ink-color-label", children: COLOR_LABELS[key] }),
|
|
2449
2449
|
/* @__PURE__ */ jsxs2("div", { className: "ink-swatches", children: [
|
|
2450
2450
|
SWATCHES[key].map((swatch) => /* @__PURE__ */ jsx2(
|
|
@@ -2488,7 +2488,8 @@ function FloatingToolbar({
|
|
|
2488
2488
|
colors,
|
|
2489
2489
|
onColorsChange,
|
|
2490
2490
|
toolbarStart,
|
|
2491
|
-
toolbarEnd
|
|
2491
|
+
toolbarEnd,
|
|
2492
|
+
hiddenColorKeys
|
|
2492
2493
|
}) {
|
|
2493
2494
|
const [openPanel, setOpenPanel] = useState(null);
|
|
2494
2495
|
useEffect3(() => {
|
|
@@ -2632,7 +2633,8 @@ function FloatingToolbar({
|
|
|
2632
2633
|
onChange: onColorsChange,
|
|
2633
2634
|
open: openPanel === "color",
|
|
2634
2635
|
onToggle: () => togglePanel("color"),
|
|
2635
|
-
onClose: () => setOpenPanel(null)
|
|
2636
|
+
onClose: () => setOpenPanel(null),
|
|
2637
|
+
hiddenKeys: hiddenColorKeys
|
|
2636
2638
|
}
|
|
2637
2639
|
),
|
|
2638
2640
|
toolbarEnd && toolbarEnd.length > 0 && /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
@@ -2657,7 +2659,8 @@ function PagedEditorContent({
|
|
|
2657
2659
|
onColorsChange,
|
|
2658
2660
|
toolbarStart,
|
|
2659
2661
|
toolbarEnd,
|
|
2660
|
-
singlePage = false
|
|
2662
|
+
singlePage = false,
|
|
2663
|
+
hiddenColorKeys
|
|
2661
2664
|
}) {
|
|
2662
2665
|
const widthPx = getPageWidthPx(pageSize);
|
|
2663
2666
|
const bodyWidthPx = getBodyWidthPx(pageSize);
|
|
@@ -2665,53 +2668,62 @@ function PagedEditorContent({
|
|
|
2665
2668
|
const pageHeightPx = Math.round(dims.heightMm * 3.7795);
|
|
2666
2669
|
const hasToolbar = toolbar.length > 0;
|
|
2667
2670
|
const bodyHeightPx = getBodyHeightPx(pageSize);
|
|
2668
|
-
|
|
2671
|
+
const cssVars = {
|
|
2672
|
+
"--ink-bg": colors.canvasBg,
|
|
2673
|
+
"--ink-page": colors.paperColor,
|
|
2674
|
+
"--ink-text": colors.textColor,
|
|
2675
|
+
"--ink-border-line": colors.lineColor,
|
|
2676
|
+
"--ink-accent": colors.accentColor,
|
|
2677
|
+
"--ink-font-body": FONTS[font].family
|
|
2678
|
+
};
|
|
2679
|
+
const toolbar_el = editor && hasToolbar ? /* @__PURE__ */ jsx4(
|
|
2680
|
+
FloatingToolbar,
|
|
2681
|
+
{
|
|
2682
|
+
editor,
|
|
2683
|
+
buttons: toolbar,
|
|
2684
|
+
ruled,
|
|
2685
|
+
onToggleRuled,
|
|
2686
|
+
font,
|
|
2687
|
+
onFontChange,
|
|
2688
|
+
colors,
|
|
2689
|
+
onColorsChange,
|
|
2690
|
+
toolbarStart,
|
|
2691
|
+
toolbarEnd,
|
|
2692
|
+
hiddenColorKeys
|
|
2693
|
+
}
|
|
2694
|
+
) : null;
|
|
2695
|
+
const card_el = /* @__PURE__ */ jsx4(
|
|
2669
2696
|
"div",
|
|
2670
2697
|
{
|
|
2671
|
-
className: `ink-page-
|
|
2672
|
-
"data-theme": theme,
|
|
2698
|
+
className: `ink-page-card${ruled ? " ink-ruled" : ""}`,
|
|
2673
2699
|
style: {
|
|
2674
|
-
|
|
2675
|
-
"
|
|
2676
|
-
|
|
2677
|
-
"--ink-
|
|
2678
|
-
"--ink-
|
|
2679
|
-
"--ink-
|
|
2700
|
+
width: widthPx,
|
|
2701
|
+
...singlePage ? { height: pageHeightPx, overflow: "hidden" } : { minHeight: pageHeightPx },
|
|
2702
|
+
padding: `${dims.paddingTopMm}mm ${dims.paddingRightMm}mm ${dims.paddingBottomMm}mm ${dims.paddingLeftMm}mm`,
|
|
2703
|
+
["--ink-padding-top"]: `${dims.paddingTopMm}mm`,
|
|
2704
|
+
["--ink-padding-right"]: `${dims.paddingRightMm}mm`,
|
|
2705
|
+
["--ink-padding-left"]: `${dims.paddingLeftMm}mm`,
|
|
2706
|
+
["--ink-body-width"]: `${bodyWidthPx}px`,
|
|
2707
|
+
["--ink-body-height"]: `${bodyHeightPx}px`
|
|
2680
2708
|
},
|
|
2709
|
+
children: /* @__PURE__ */ jsx4(EditorContent, { editor })
|
|
2710
|
+
}
|
|
2711
|
+
);
|
|
2712
|
+
if (singlePage) {
|
|
2713
|
+
return /* @__PURE__ */ jsxs4("div", { "data-theme": theme, style: cssVars, children: [
|
|
2714
|
+
toolbar_el,
|
|
2715
|
+
card_el
|
|
2716
|
+
] });
|
|
2717
|
+
}
|
|
2718
|
+
return /* @__PURE__ */ jsxs4(
|
|
2719
|
+
"div",
|
|
2720
|
+
{
|
|
2721
|
+
className: "ink-page-wrap",
|
|
2722
|
+
"data-theme": theme,
|
|
2723
|
+
style: cssVars,
|
|
2681
2724
|
children: [
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
{
|
|
2685
|
-
editor,
|
|
2686
|
-
buttons: toolbar,
|
|
2687
|
-
ruled,
|
|
2688
|
-
onToggleRuled,
|
|
2689
|
-
font,
|
|
2690
|
-
onFontChange,
|
|
2691
|
-
colors,
|
|
2692
|
-
onColorsChange,
|
|
2693
|
-
toolbarStart,
|
|
2694
|
-
toolbarEnd
|
|
2695
|
-
}
|
|
2696
|
-
),
|
|
2697
|
-
/* @__PURE__ */ jsx4(
|
|
2698
|
-
"div",
|
|
2699
|
-
{
|
|
2700
|
-
className: `ink-page-card${ruled ? " ink-ruled" : ""}`,
|
|
2701
|
-
style: {
|
|
2702
|
-
width: widthPx,
|
|
2703
|
-
// In singlePage mode: fixed height + overflow hidden so content never visually spills
|
|
2704
|
-
...singlePage ? { height: pageHeightPx, overflow: "hidden" } : { minHeight: pageHeightPx },
|
|
2705
|
-
padding: `${dims.paddingTopMm}mm ${dims.paddingRightMm}mm ${dims.paddingBottomMm}mm ${dims.paddingLeftMm}mm`,
|
|
2706
|
-
["--ink-padding-top"]: `${dims.paddingTopMm}mm`,
|
|
2707
|
-
["--ink-padding-right"]: `${dims.paddingRightMm}mm`,
|
|
2708
|
-
["--ink-padding-left"]: `${dims.paddingLeftMm}mm`,
|
|
2709
|
-
["--ink-body-width"]: `${bodyWidthPx}px`,
|
|
2710
|
-
["--ink-body-height"]: `${bodyHeightPx}px`
|
|
2711
|
-
},
|
|
2712
|
-
children: /* @__PURE__ */ jsx4(EditorContent, { editor })
|
|
2713
|
-
}
|
|
2714
|
-
)
|
|
2725
|
+
toolbar_el,
|
|
2726
|
+
card_el
|
|
2715
2727
|
]
|
|
2716
2728
|
}
|
|
2717
2729
|
);
|
|
@@ -2731,7 +2743,9 @@ function InkEditor({
|
|
|
2731
2743
|
toolbarEnd,
|
|
2732
2744
|
singlePage = false,
|
|
2733
2745
|
onOverflow,
|
|
2734
|
-
initialContent
|
|
2746
|
+
initialContent,
|
|
2747
|
+
onColorsChange,
|
|
2748
|
+
hiddenColorKeys
|
|
2735
2749
|
}) {
|
|
2736
2750
|
const [ruled, setRuled] = useState2(false);
|
|
2737
2751
|
const [font, setFont] = useState2(initialFont);
|
|
@@ -2771,10 +2785,14 @@ function InkEditor({
|
|
|
2771
2785
|
font,
|
|
2772
2786
|
onFontChange: setFont,
|
|
2773
2787
|
colors,
|
|
2774
|
-
onColorsChange:
|
|
2788
|
+
onColorsChange: (c) => {
|
|
2789
|
+
setColors(c);
|
|
2790
|
+
onColorsChange?.(c);
|
|
2791
|
+
},
|
|
2775
2792
|
toolbarStart,
|
|
2776
2793
|
toolbarEnd,
|
|
2777
|
-
singlePage
|
|
2794
|
+
singlePage,
|
|
2795
|
+
hiddenColorKeys
|
|
2778
2796
|
}
|
|
2779
2797
|
);
|
|
2780
2798
|
}
|