reactjs-tiptap-editor
Version:
A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React
98 lines (97 loc) • 3.15 kB
JavaScript
import { L as d } from "./index-BDYJ8Ph2.js";
import { h as f } from "./index-C07N8gA1.js";
import { jsx as i, Fragment as p, jsxs as h } from "react/jsx-runtime";
import { Fragment as g } from "react";
import { u as m, e as D, A as v, I as x } from "./index-RcSPeQHn.js";
import "./theme.js";
import { D as H, a as A, b as L, c as w, d as b } from "./dropdown-menu-q6RL_fkA.js";
function _() {
const t = m(C.name), {
tooltip: o = void 0,
items: n,
icon: s,
isActive: l = void 0
} = (t == null ? void 0 : t.componentProps) ?? {}, { editorDisabled: a, dataState: r } = D(l);
return t ? /* @__PURE__ */ h(H, { children: [
/* @__PURE__ */ i(
A,
{
asChild: !0,
disabled: a,
children: /* @__PURE__ */ i(
v,
{
customClass: "!richtext-w-12 richtext-h-12",
disabled: a,
icon: s,
tooltip: o,
children: /* @__PURE__ */ i(
x,
{
className: "richtext-ml-1 richtext-size-3 richtext-text-zinc-500",
name: "MenuDown"
}
)
}
)
}
),
/* @__PURE__ */ i(L, { className: "richtext-min-w-24", children: n == null ? void 0 : n.map((e, c) => /* @__PURE__ */ h(g, { children: [
/* @__PURE__ */ i(
w,
{
checked: e.value === (r == null ? void 0 : r.value),
onClick: () => e == null ? void 0 : e.action(),
children: e.label
}
),
e.value === "Default" && /* @__PURE__ */ i(b, {})
] }, `line-height-${c}`)) })
] }) : /* @__PURE__ */ i(p, {});
}
const C = /* @__PURE__ */ d.extend({
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-expect-error
addOptions() {
var t;
return {
...(t = this.parent) == null ? void 0 : t.call(this),
lineHeights: f,
button({ editor: o, extension: n, t: s }) {
var a, r;
const l = (r = (a = n == null ? void 0 : n.options) == null ? void 0 : a.lineHeights) == null ? void 0 : r.map((e) => ({
label: e === "Default" ? s("editor.default") : String(e),
value: e,
isActive: () => e === "Default" ? !0 : o.isActive("textStyle", { lineHeight: e }) || !1,
action: () => {
if (e === "Default") {
o.chain().focus().unsetLineHeight().run();
return;
}
o.chain().focus().toggleTextStyle({ lineHeight: e }).run();
},
// disabled: !editor.can().setFontSize(String(k.value)),
default: e === "Default" || !1
}));
return {
componentProps: {
tooltip: s("editor.lineheight.tooltip"),
items: l,
icon: "LineHeight",
isActive: () => {
const e = (l || []).find((u) => u.isActive() && !u.default);
return e && !e.default ? e : {
value: "Default",
isActive: () => !1
};
}
}
};
}
};
}
});
export {
C as LineHeight,
_ as RichTextLineHeight
};