106 lines
2.9 KiB
JavaScript
106 lines
2.9 KiB
JavaScript
"use strict";
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
// src/index.ts
|
|
var index_exports = {};
|
|
__export(index_exports, {
|
|
Underline: () => Underline,
|
|
default: () => index_default
|
|
});
|
|
module.exports = __toCommonJS(index_exports);
|
|
|
|
// src/underline.ts
|
|
var import_core = require("@tiptap/core");
|
|
var Underline = import_core.Mark.create({
|
|
name: "underline",
|
|
addOptions() {
|
|
return {
|
|
HTMLAttributes: {}
|
|
};
|
|
},
|
|
parseHTML() {
|
|
return [
|
|
{
|
|
tag: "u"
|
|
},
|
|
{
|
|
style: "text-decoration",
|
|
consuming: false,
|
|
getAttrs: (style) => style.includes("underline") ? {} : false
|
|
}
|
|
];
|
|
},
|
|
renderHTML({ HTMLAttributes }) {
|
|
return ["u", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
|
|
},
|
|
parseMarkdown(token, helpers) {
|
|
return helpers.applyMark(this.name || "underline", helpers.parseInline(token.tokens || []));
|
|
},
|
|
renderMarkdown(node, helpers) {
|
|
return `++${helpers.renderChildren(node)}++`;
|
|
},
|
|
markdownTokenizer: {
|
|
name: "underline",
|
|
level: "inline",
|
|
start(src) {
|
|
return src.indexOf("++");
|
|
},
|
|
tokenize(src, _tokens, lexer) {
|
|
const rule = /^(\+\+)([\s\S]+?)(\+\+)/;
|
|
const match = rule.exec(src);
|
|
if (!match) {
|
|
return void 0;
|
|
}
|
|
const innerContent = match[2].trim();
|
|
return {
|
|
type: "underline",
|
|
raw: match[0],
|
|
text: innerContent,
|
|
tokens: lexer.inlineTokens(innerContent)
|
|
};
|
|
}
|
|
},
|
|
addCommands() {
|
|
return {
|
|
setUnderline: () => ({ commands }) => {
|
|
return commands.setMark(this.name);
|
|
},
|
|
toggleUnderline: () => ({ commands }) => {
|
|
return commands.toggleMark(this.name);
|
|
},
|
|
unsetUnderline: () => ({ commands }) => {
|
|
return commands.unsetMark(this.name);
|
|
}
|
|
};
|
|
},
|
|
addKeyboardShortcuts() {
|
|
return {
|
|
"Mod-u": () => this.editor.commands.toggleUnderline(),
|
|
"Mod-U": () => this.editor.commands.toggleUnderline()
|
|
};
|
|
}
|
|
});
|
|
|
|
// src/index.ts
|
|
var index_default = Underline;
|
|
// Annotate the CommonJS export names for ESM import in node:
|
|
0 && (module.exports = {
|
|
Underline
|
|
});
|
|
//# sourceMappingURL=index.cjs.map
|