analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
95 lines (94 loc) • 4.51 kB
JavaScript
// src/components/RichEditor/RichEditor.tsx
import { lazy, Suspense, Component } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
var RichEditorCore = lazy(
() => import("./RichEditorCore-ZGHPGZXZ.mjs").then((module) => ({
default: module.RichEditor
}))
);
var RichEditorErrorBoundary = class extends Component {
constructor(props) {
super(props);
this.state = { hasError: false, error: null };
}
static getDerivedStateFromError(error) {
return { hasError: true, error };
}
render() {
if (this.state.hasError && this.state.error) {
return this.props.fallback(this.state.error);
}
return this.props.children;
}
};
var TIPTAP_DEPENDENCIES = [
"@tiptap/react",
"@tiptap/core",
"@tiptap/starter-kit",
"@tiptap/extension-underline",
"@tiptap/extension-text-align",
"@tiptap/extension-color",
"@tiptap/extension-text-style",
"@tiptap/extension-highlight",
"@tiptap/extension-subscript",
"@tiptap/extension-superscript",
"@tiptap/extension-link",
"@tiptap/extension-placeholder",
"@tiptap/extension-image"
];
function MissingDependenciesError({ error }) {
const isTiptapError = error.message.includes("@tiptap") || error.message.includes("Cannot find module '@tiptap");
const installCommand = `yarn add ${TIPTAP_DEPENDENCIES.join(" ")}`;
const npmCommand = `npm install ${TIPTAP_DEPENDENCIES.join(" ")}`;
return /* @__PURE__ */ jsx("div", { className: "border border-red-200 rounded-xl overflow-hidden bg-red-50 p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
/* @__PURE__ */ jsx("div", { className: "shrink-0 w-10 h-10 bg-red-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsx(
"svg",
{
className: "w-5 h-5 text-red-600",
fill: "none",
viewBox: "0 0 24 24",
stroke: "currentColor",
children: /* @__PURE__ */ jsx(
"path",
{
strokeLinecap: "round",
strokeLinejoin: "round",
strokeWidth: 2,
d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
}
)
}
) }),
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
/* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-red-800 mb-2", children: isTiptapError ? "Depend\xEAncias do TipTap n\xE3o encontradas" : "Erro ao carregar o RichEditor" }),
/* @__PURE__ */ jsx("p", { className: "text-red-700 text-sm mb-4", children: isTiptapError ? "O componente RichEditor requer as depend\xEAncias do TipTap para funcionar. Instale-as executando um dos comandos abaixo:" : error.message }),
isTiptapError && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
/* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("p", { className: "text-xs text-red-600 font-medium mb-1", children: "Usando Yarn:" }),
/* @__PURE__ */ jsx("code", { className: "block bg-red-100 text-red-800 px-3 py-2 rounded text-xs font-mono overflow-x-auto", children: installCommand })
] }),
/* @__PURE__ */ jsxs("div", { children: [
/* @__PURE__ */ jsx("p", { className: "text-xs text-red-600 font-medium mb-1", children: "Usando NPM:" }),
/* @__PURE__ */ jsx("code", { className: "block bg-red-100 text-red-800 px-3 py-2 rounded text-xs font-mono overflow-x-auto", children: npmCommand })
] })
] })
] })
] }) });
}
function LoadingFallback() {
return /* @__PURE__ */ jsxs("div", { className: "border border-border-200 rounded-xl overflow-hidden bg-background-0 animate-pulse", children: [
/* @__PURE__ */ jsx("div", { className: "h-10 bg-background-100 border-b border-border-200" }),
/* @__PURE__ */ jsx("div", { className: "h-32 bg-background-50" }),
/* @__PURE__ */ jsx("div", { className: "h-8 bg-background-100 border-t border-border-200" })
] });
}
function RichEditor(props) {
return /* @__PURE__ */ jsx(RichEditorErrorBoundary, { fallback: MissingDependenciesErrorFallback, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingFallback, {}), children: /* @__PURE__ */ jsx(RichEditorCore, { ...props }) }) });
}
function MissingDependenciesErrorFallback(error) {
return /* @__PURE__ */ jsx(MissingDependenciesError, { error });
}
export {
RichEditor
};
//# sourceMappingURL=chunk-73DEBAQ6.mjs.map