analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
95 lines (92 loc) • 5.54 kB
JavaScript
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }// src/components/RichEditor/RichEditor.tsx
var _react = require('react');
var _jsxruntime = require('react/jsx-runtime');
var RichEditorCore = _react.lazy.call(void 0,
() => Promise.resolve().then(() => _interopRequireWildcard(require("./RichEditorCore-Q7FQAPEE.js"))).then((module) => ({
default: module.RichEditor
}))
);
var RichEditorErrorBoundary = class extends _react.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__ */ _jsxruntime.jsx.call(void 0, "div", { className: "border border-red-200 rounded-xl overflow-hidden bg-red-50 p-6", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex items-start gap-3", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "shrink-0 w-10 h-10 bg-red-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"svg",
{
className: "w-5 h-5 text-red-600",
fill: "none",
viewBox: "0 0 24 24",
stroke: "currentColor",
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
"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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "flex-1", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "space-y-3", children: [
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-red-600 font-medium mb-1", children: "Usando Yarn:" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "code", { className: "block bg-red-100 text-red-800 px-3 py-2 rounded text-xs font-mono overflow-x-auto", children: installCommand })
] }),
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "text-xs text-red-600 font-medium mb-1", children: "Usando NPM:" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "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__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "border border-border-200 rounded-xl overflow-hidden bg-background-0 animate-pulse", children: [
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-10 bg-background-100 border-b border-border-200" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-32 bg-background-50" }),
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "h-8 bg-background-100 border-t border-border-200" })
] });
}
function RichEditor(props) {
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RichEditorErrorBoundary, { fallback: MissingDependenciesErrorFallback, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, LoadingFallback, {}), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RichEditorCore, { ...props }) }) });
}
function MissingDependenciesErrorFallback(error) {
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MissingDependenciesError, { error });
}
exports.RichEditor = RichEditor;
//# sourceMappingURL=chunk-KYUUQXB7.js.map