@wordpress/format-library
Version:
Format library for the WordPress editor.
53 lines (52 loc) • 1.13 kB
JavaScript
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
import { __ } from "@wordpress/i18n";
import { toggleFormat } from "@wordpress/rich-text";
import {
RichTextShortcut,
__unstableRichTextInputEvent
} from "@wordpress/block-editor";
const name = "core/underline";
const title = __("Underline");
const underline = {
name,
title,
tagName: "span",
className: null,
attributes: {
style: "style"
},
edit({ value, onChange }) {
const onToggle = () => {
onChange(
toggleFormat(value, {
type: name,
attributes: {
style: "text-decoration: underline;"
},
title
})
);
};
return /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(
RichTextShortcut,
{
type: "primary",
character: "u",
onUse: onToggle
}
),
/* @__PURE__ */ jsx(
__unstableRichTextInputEvent,
{
inputType: "formatUnderline",
onInput: onToggle
}
)
] });
}
};
export {
underline
};
//# sourceMappingURL=index.js.map