@kyro-cms/admin 0.9.9 → 0.10.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/dist/index.cjs +94 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +95 -34
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/fields/RichTextField.tsx +45 -27
- package/src/hooks/examples/sample-hook-2.ts +0 -2
- package/src/integration.ts +27 -2
- package/src/plugins/examples/sample-plugin-2.ts +0 -1
- package/src/plugins/examples/sample-plugin.ts +0 -2
package/dist/index.cjs
CHANGED
|
@@ -3861,33 +3861,63 @@ function RichTextField({
|
|
|
3861
3861
|
error,
|
|
3862
3862
|
disabled
|
|
3863
3863
|
}) {
|
|
3864
|
-
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
3865
|
-
const [panelWidth, setPanelWidth] = React.useState(0);
|
|
3866
|
-
const [isMediaPickerOpen, setIsMediaPickerOpen] = React.useState(false);
|
|
3867
3864
|
const [isMounted, setIsMounted] = React.useState(false);
|
|
3868
3865
|
React.useEffect(() => {
|
|
3869
3866
|
setIsMounted(true);
|
|
3870
3867
|
}, []);
|
|
3868
|
+
if (!isMounted) {
|
|
3869
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FieldLayout, { field: field3, error, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3870
|
+
"div",
|
|
3871
|
+
{
|
|
3872
|
+
className: `border rounded-lg bg-[var(--kyro-bg)] overflow-hidden border-[var(--kyro-border)] flex flex-col shadow-sm transition-all duration-200
|
|
3873
|
+
${error ? "border-[var(--kyro-error)] shadow-[0_0_0_1px_var(--kyro-error)]" : "border-[var(--kyro-border)]"}
|
|
3874
|
+
${disabled ? "opacity-60 cursor-not-allowed" : ""}`,
|
|
3875
|
+
children: [
|
|
3876
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg h-[40px]" }),
|
|
3877
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto min-h-[160px] max-h-[400px] p-4" })
|
|
3878
|
+
]
|
|
3879
|
+
}
|
|
3880
|
+
) });
|
|
3881
|
+
}
|
|
3882
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3883
|
+
RichTextEditor,
|
|
3884
|
+
{
|
|
3885
|
+
field: field3,
|
|
3886
|
+
value,
|
|
3887
|
+
onChange,
|
|
3888
|
+
error,
|
|
3889
|
+
disabled
|
|
3890
|
+
}
|
|
3891
|
+
);
|
|
3892
|
+
}
|
|
3893
|
+
function RichTextEditor({
|
|
3894
|
+
field: field3,
|
|
3895
|
+
value,
|
|
3896
|
+
onChange,
|
|
3897
|
+
error,
|
|
3898
|
+
disabled
|
|
3899
|
+
}) {
|
|
3900
|
+
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
3901
|
+
const [panelWidth, setPanelWidth] = React.useState(0);
|
|
3902
|
+
const [isMediaPickerOpen, setIsMediaPickerOpen] = React.useState(false);
|
|
3871
3903
|
React.useEffect(() => {
|
|
3872
3904
|
if (!isExpanded) {
|
|
3873
3905
|
setPanelWidth(0);
|
|
3874
3906
|
return;
|
|
3875
3907
|
}
|
|
3908
|
+
const panel = document.querySelector('[data-kyro-slide-panel="true"]');
|
|
3876
3909
|
const updateWidth = () => {
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
setPanelWidth(panel2.getBoundingClientRect().width);
|
|
3910
|
+
if (panel) {
|
|
3911
|
+
setPanelWidth(panel.getBoundingClientRect().width);
|
|
3880
3912
|
} else {
|
|
3881
3913
|
setPanelWidth(0);
|
|
3882
3914
|
}
|
|
3883
3915
|
};
|
|
3884
3916
|
updateWidth();
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
updateWidth();
|
|
3890
|
-
});
|
|
3917
|
+
const observer = new MutationObserver(() => {
|
|
3918
|
+
updateWidth();
|
|
3919
|
+
});
|
|
3920
|
+
if (panel) {
|
|
3891
3921
|
observer.observe(panel);
|
|
3892
3922
|
}
|
|
3893
3923
|
window.addEventListener("resize", updateWidth);
|
|
@@ -3925,7 +3955,7 @@ function RichTextField({
|
|
|
3925
3955
|
extensionTextStyle.TextStyle,
|
|
3926
3956
|
Color__default.default
|
|
3927
3957
|
],
|
|
3928
|
-
content: value || { type: "doc", content: [] },
|
|
3958
|
+
content: Array.isArray(value) ? { type: "doc", content: value } : value || { type: "doc", content: [] },
|
|
3929
3959
|
editable: !disabled,
|
|
3930
3960
|
onUpdate: ({ editor: editor2 }) => {
|
|
3931
3961
|
onChange(editor2.getJSON());
|
|
@@ -3938,23 +3968,9 @@ function RichTextField({
|
|
|
3938
3968
|
});
|
|
3939
3969
|
React.useEffect(() => {
|
|
3940
3970
|
if (editor && value && JSON.stringify(value) !== JSON.stringify(editor.getJSON())) {
|
|
3941
|
-
editor.commands.setContent(value);
|
|
3971
|
+
editor.commands.setContent(Array.isArray(value) ? { type: "doc", content: value } : value);
|
|
3942
3972
|
}
|
|
3943
3973
|
}, [value, editor]);
|
|
3944
|
-
if (!isMounted) {
|
|
3945
|
-
return /* @__PURE__ */ jsxRuntime.jsx(FieldLayout, { field: field3, error, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3946
|
-
"div",
|
|
3947
|
-
{
|
|
3948
|
-
className: `border rounded-lg bg-[var(--kyro-bg)] overflow-hidden border-[var(--kyro-border)] flex flex-col shadow-sm transition-all duration-200
|
|
3949
|
-
${error ? "border-[var(--kyro-error)] shadow-[0_0_0_1px_var(--kyro-error)]" : "border-[var(--kyro-border)]"}
|
|
3950
|
-
${disabled ? "opacity-60 cursor-not-allowed" : ""}`,
|
|
3951
|
-
children: [
|
|
3952
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-1.5 p-1.5 border-b border-[var(--kyro-border)] bg-[var(--kyro-bg-secondary)] rounded-t-lg h-[40px]" }),
|
|
3953
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto min-h-[160px] max-h-[400px] p-4" })
|
|
3954
|
-
]
|
|
3955
|
-
}
|
|
3956
|
-
) });
|
|
3957
|
-
}
|
|
3958
3974
|
return /* @__PURE__ */ jsxRuntime.jsxs(FieldLayout, { field: field3, error, children: [
|
|
3959
3975
|
isExpanded ? (
|
|
3960
3976
|
// Maximize mode placeholder inside form
|
|
@@ -14703,7 +14719,6 @@ var samplePlugin = {
|
|
|
14703
14719
|
description: "A tiny sample plugin to demonstrate the extensibility surface",
|
|
14704
14720
|
hooks: {
|
|
14705
14721
|
onAdminReady: () => {
|
|
14706
|
-
console.log("[ Kyro Admin ] sample-plugin: onAdminReady executed");
|
|
14707
14722
|
return;
|
|
14708
14723
|
}
|
|
14709
14724
|
}
|
|
@@ -14717,7 +14732,6 @@ var samplePlugin2 = {
|
|
|
14717
14732
|
description: "Second MVP plugin demonstrating beforeDeploy hook",
|
|
14718
14733
|
hooks: {
|
|
14719
14734
|
beforeDeploy: (ctx) => {
|
|
14720
|
-
console.log("[Kyro Admin] sample-plugin-2 beforeDeploy");
|
|
14721
14735
|
return { success: true };
|
|
14722
14736
|
}
|
|
14723
14737
|
}
|
|
@@ -15008,7 +15022,6 @@ export function c(size) {
|
|
|
15008
15022
|
function debug(namespace) {
|
|
15009
15023
|
function d(...args) {
|
|
15010
15024
|
if (typeof localStorage !== "undefined" && localStorage.getItem("DEBUG")) {
|
|
15011
|
-
console.log(namespace, ...args);
|
|
15012
15025
|
}
|
|
15013
15026
|
}
|
|
15014
15027
|
d.enabled = false;
|
|
@@ -15028,9 +15041,33 @@ export default debug;
|
|
|
15028
15041
|
"kyro:config": resolvedConfig
|
|
15029
15042
|
}
|
|
15030
15043
|
},
|
|
15044
|
+
build: {
|
|
15045
|
+
rollupOptions: {
|
|
15046
|
+
output: {
|
|
15047
|
+
manualChunks(id) {
|
|
15048
|
+
if (id.includes("@tiptap") || id.includes("prosemirror")) {
|
|
15049
|
+
return "vendor-tiptap";
|
|
15050
|
+
}
|
|
15051
|
+
}
|
|
15052
|
+
}
|
|
15053
|
+
}
|
|
15054
|
+
},
|
|
15031
15055
|
optimizeDeps: {
|
|
15032
15056
|
include: [
|
|
15033
|
-
"use-sync-external-store"
|
|
15057
|
+
"use-sync-external-store",
|
|
15058
|
+
"@tiptap/core",
|
|
15059
|
+
"@tiptap/react",
|
|
15060
|
+
"@tiptap/pm",
|
|
15061
|
+
"@tiptap/starter-kit",
|
|
15062
|
+
"@tiptap/extension-link",
|
|
15063
|
+
"@tiptap/extension-image",
|
|
15064
|
+
"@tiptap/extension-text-align",
|
|
15065
|
+
"@tiptap/extension-underline",
|
|
15066
|
+
"@tiptap/extension-highlight",
|
|
15067
|
+
"@tiptap/extension-task-list",
|
|
15068
|
+
"@tiptap/extension-task-item",
|
|
15069
|
+
"@tiptap/extension-text-style",
|
|
15070
|
+
"@tiptap/extension-color"
|
|
15034
15071
|
],
|
|
15035
15072
|
exclude: ["debug", "react/compiler-runtime"]
|
|
15036
15073
|
},
|
|
@@ -15040,7 +15077,31 @@ export default debug;
|
|
|
15040
15077
|
__KYRO_ADMIN_CONFIG_FILE__: JSON.stringify(configFile)
|
|
15041
15078
|
},
|
|
15042
15079
|
ssr: {
|
|
15043
|
-
noExternal: [
|
|
15080
|
+
noExternal: [
|
|
15081
|
+
"@kyro-cms/admin",
|
|
15082
|
+
"@kyro-cms/core",
|
|
15083
|
+
"@tiptap/core",
|
|
15084
|
+
"@tiptap/react",
|
|
15085
|
+
"@tiptap/pm",
|
|
15086
|
+
"@tiptap/starter-kit",
|
|
15087
|
+
"@tiptap/extension-link",
|
|
15088
|
+
"@tiptap/extension-image",
|
|
15089
|
+
"@tiptap/extension-text-align",
|
|
15090
|
+
"@tiptap/extension-underline",
|
|
15091
|
+
"@tiptap/extension-highlight",
|
|
15092
|
+
"@tiptap/extension-task-list",
|
|
15093
|
+
"@tiptap/extension-task-item",
|
|
15094
|
+
"@tiptap/extension-text-style",
|
|
15095
|
+
"@tiptap/extension-color",
|
|
15096
|
+
"prosemirror-model",
|
|
15097
|
+
"prosemirror-state",
|
|
15098
|
+
"prosemirror-view",
|
|
15099
|
+
"prosemirror-schema-list",
|
|
15100
|
+
"prosemirror-commands",
|
|
15101
|
+
"prosemirror-keymap",
|
|
15102
|
+
"prosemirror-transform",
|
|
15103
|
+
"prosemirror-inputrules"
|
|
15104
|
+
]
|
|
15044
15105
|
}
|
|
15045
15106
|
}
|
|
15046
15107
|
});
|