UNPKG

reactjs-tiptap-editor

Version:

A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React

117 lines (116 loc) 2.91 kB
import { M as m, m as p } from "./clsx-DaPvp9ji.js"; import { jsx as d, Fragment as g } from "react/jsx-runtime"; import { u as f, d as h, A as k } from "./index-RcSPeQHn.js"; import "react"; import "./theme.js"; var M = m.create({ name: "underline", addOptions() { return { HTMLAttributes: {} }; }, parseHTML() { return [ { tag: "u" }, { style: "text-decoration", consuming: !1, getAttrs: (e) => e.includes("underline") ? {} : !1 } ]; }, renderHTML({ HTMLAttributes: e }) { return ["u", p(this.options.HTMLAttributes, e), 0]; }, parseMarkdown(e, t) { return t.applyMark(this.name || "underline", t.parseInline(e.tokens || [])); }, renderMarkdown(e, t) { return `++${t.renderChildren(e)}++`; }, markdownTokenizer: { name: "underline", level: "inline", start(e) { return e.indexOf("++"); }, tokenize(e, t, n) { const r = /^(\+\+)([\s\S]+?)(\+\+)/.exec(e); if (!r) return; const o = r[2].trim(); return { type: "underline", raw: r[0], text: o, tokens: n.inlineTokens(o) }; } }, addCommands() { return { setUnderline: () => ({ commands: e }) => e.setMark(this.name), toggleUnderline: () => ({ commands: e }) => e.toggleMark(this.name), unsetUnderline: () => ({ commands: e }) => e.unsetMark(this.name) }; }, addKeyboardShortcuts() { return { "Mod-u": () => this.editor.commands.toggleUnderline(), "Mod-U": () => this.editor.commands.toggleUnderline() }; } }), v = M; function w() { const e = f(U.name), { icon: t = void 0, tooltip: n = void 0, shortcutKeys: i = void 0, tooltipOptions: r = {}, action: o = void 0, isActive: a = void 0 } = (e == null ? void 0 : e.componentProps) ?? {}, { dataState: u, disabled: s, update: l } = h(a), c = () => { s || o && (o(), l()); }; return e ? /* @__PURE__ */ d( k, { action: c, dataState: u, disabled: s, icon: t, shortcutKeys: i, tooltip: n, tooltipOptions: r } ) : /* @__PURE__ */ d(g, {}); } const U = /* @__PURE__ */ v.extend({ // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-expect-error addOptions() { var e; return { ...(e = this.parent) == null ? void 0 : e.call(this), button({ editor: t, t: n, extension: i }) { return { componentProps: { action: () => t.commands.toggleUnderline(), isActive: () => t.isActive("underline") || !1, disabled: !1, icon: "Underline", shortcutKeys: i.options.shortcutKeys ?? ["mod", "U"], tooltip: n("editor.underline.tooltip") } }; } }; } }); export { w as RichTextUnderline, U as TextUnderline };