@tiptap/extension-strike
Advanced tools
+113
| "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, { | ||
| Strike: () => Strike, | ||
| default: () => index_default, | ||
| inputRegex: () => inputRegex, | ||
| pasteRegex: () => pasteRegex | ||
| }); | ||
| module.exports = __toCommonJS(index_exports); | ||
| // src/strike.ts | ||
| var import_core = require("@tiptap/core"); | ||
| var inputRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/; | ||
| var pasteRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g; | ||
| var Strike = import_core.Mark.create({ | ||
| name: "strike", | ||
| addOptions() { | ||
| return { | ||
| HTMLAttributes: {} | ||
| }; | ||
| }, | ||
| parseHTML() { | ||
| return [ | ||
| { | ||
| tag: "s" | ||
| }, | ||
| { | ||
| tag: "del" | ||
| }, | ||
| { | ||
| tag: "strike" | ||
| }, | ||
| { | ||
| style: "text-decoration", | ||
| consuming: false, | ||
| getAttrs: (style) => style.includes("line-through") ? {} : false | ||
| } | ||
| ]; | ||
| }, | ||
| renderHTML({ HTMLAttributes }) { | ||
| return ["s", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0]; | ||
| }, | ||
| markdownTokenName: "del", | ||
| parseMarkdown: (token, helpers) => { | ||
| return helpers.applyMark("strike", helpers.parseInline(token.tokens || [])); | ||
| }, | ||
| renderMarkdown: (node, h) => { | ||
| return `~~${h.renderChildren(node)}~~`; | ||
| }, | ||
| addCommands() { | ||
| return { | ||
| setStrike: () => ({ commands }) => { | ||
| return commands.setMark(this.name); | ||
| }, | ||
| toggleStrike: () => ({ commands }) => { | ||
| return commands.toggleMark(this.name); | ||
| }, | ||
| unsetStrike: () => ({ commands }) => { | ||
| return commands.unsetMark(this.name); | ||
| } | ||
| }; | ||
| }, | ||
| addKeyboardShortcuts() { | ||
| return { | ||
| "Mod-Shift-s": () => this.editor.commands.toggleStrike() | ||
| }; | ||
| }, | ||
| addInputRules() { | ||
| return [ | ||
| (0, import_core.markInputRule)({ | ||
| find: inputRegex, | ||
| type: this.type | ||
| }) | ||
| ]; | ||
| }, | ||
| addPasteRules() { | ||
| return [ | ||
| (0, import_core.markPasteRule)({ | ||
| find: pasteRegex, | ||
| type: this.type | ||
| }) | ||
| ]; | ||
| } | ||
| }); | ||
| // src/index.ts | ||
| var index_default = Strike; | ||
| // Annotate the CommonJS export names for ESM import in node: | ||
| 0 && (module.exports = { | ||
| Strike, | ||
| inputRegex, | ||
| pasteRegex | ||
| }); | ||
| //# sourceMappingURL=index.cjs.map |
| {"version":3,"sources":["../src/index.ts","../src/strike.ts"],"sourcesContent":["import { Strike } from './strike.js'\n\nexport * from './strike.js'\n\nexport default Strike\n","import { Mark, markInputRule, markPasteRule, mergeAttributes } from '@tiptap/core'\n\nexport interface StrikeOptions {\n /**\n * HTML attributes to add to the strike element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n strike: {\n /**\n * Set a strike mark\n * @example editor.commands.setStrike()\n */\n setStrike: () => ReturnType\n /**\n * Toggle a strike mark\n * @example editor.commands.toggleStrike()\n */\n toggleStrike: () => ReturnType\n /**\n * Unset a strike mark\n * @example editor.commands.unsetStrike()\n */\n unsetStrike: () => ReturnType\n }\n }\n}\n\n/**\n * Matches a strike to a ~~strike~~ on input.\n */\nexport const inputRegex = /(?:^|\\s)(~~(?!\\s+~~)((?:[^~]+))~~(?!\\s+~~))$/\n\n/**\n * Matches a strike to a ~~strike~~ on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(~~(?!\\s+~~)((?:[^~]+))~~(?!\\s+~~))/g\n\n/**\n * This extension allows you to create strike text.\n * @see https://www.tiptap.dev/api/marks/strike\n */\nexport const Strike = Mark.create<StrikeOptions>({\n name: 'strike',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 's',\n },\n {\n tag: 'del',\n },\n {\n tag: 'strike',\n },\n {\n style: 'text-decoration',\n consuming: false,\n getAttrs: style => ((style as string).includes('line-through') ? {} : false),\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['s', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n markdownTokenName: 'del',\n\n parseMarkdown: (token, helpers) => {\n // Convert 'del' token to strike mark\n return helpers.applyMark('strike', helpers.parseInline(token.tokens || []))\n },\n\n renderMarkdown: (node, h) => {\n return `~~${h.renderChildren(node)}~~`\n },\n\n addCommands() {\n return {\n setStrike:\n () =>\n ({ commands }) => {\n return commands.setMark(this.name)\n },\n toggleStrike:\n () =>\n ({ commands }) => {\n return commands.toggleMark(this.name)\n },\n unsetStrike:\n () =>\n ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-s': () => this.editor.commands.toggleStrike(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },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A,IACJ;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,eAAe,MAAM,KAAK,OAAO,SAAS,aAAa;AAAA,IACzD;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,UACL,2BAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,UACL,2BAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;ADjID,IAAO,gBAAQ;","names":[]} |
| import { Mark } from '@tiptap/core'; | ||
| interface StrikeOptions { | ||
| /** | ||
| * HTML attributes to add to the strike element. | ||
| * @default {} | ||
| * @example { class: 'foo' } | ||
| */ | ||
| HTMLAttributes: Record<string, any>; | ||
| } | ||
| declare module '@tiptap/core' { | ||
| interface Commands<ReturnType> { | ||
| strike: { | ||
| /** | ||
| * Set a strike mark | ||
| * @example editor.commands.setStrike() | ||
| */ | ||
| setStrike: () => ReturnType; | ||
| /** | ||
| * Toggle a strike mark | ||
| * @example editor.commands.toggleStrike() | ||
| */ | ||
| toggleStrike: () => ReturnType; | ||
| /** | ||
| * Unset a strike mark | ||
| * @example editor.commands.unsetStrike() | ||
| */ | ||
| unsetStrike: () => ReturnType; | ||
| }; | ||
| } | ||
| } | ||
| /** | ||
| * Matches a strike to a ~~strike~~ on input. | ||
| */ | ||
| declare const inputRegex: RegExp; | ||
| /** | ||
| * Matches a strike to a ~~strike~~ on paste. | ||
| */ | ||
| declare const pasteRegex: RegExp; | ||
| /** | ||
| * This extension allows you to create strike text. | ||
| * @see https://www.tiptap.dev/api/marks/strike | ||
| */ | ||
| declare const Strike: Mark<StrikeOptions, any>; | ||
| export { Strike, type StrikeOptions, Strike as default, inputRegex, pasteRegex }; |
| import { Mark } from '@tiptap/core'; | ||
| interface StrikeOptions { | ||
| /** | ||
| * HTML attributes to add to the strike element. | ||
| * @default {} | ||
| * @example { class: 'foo' } | ||
| */ | ||
| HTMLAttributes: Record<string, any>; | ||
| } | ||
| declare module '@tiptap/core' { | ||
| interface Commands<ReturnType> { | ||
| strike: { | ||
| /** | ||
| * Set a strike mark | ||
| * @example editor.commands.setStrike() | ||
| */ | ||
| setStrike: () => ReturnType; | ||
| /** | ||
| * Toggle a strike mark | ||
| * @example editor.commands.toggleStrike() | ||
| */ | ||
| toggleStrike: () => ReturnType; | ||
| /** | ||
| * Unset a strike mark | ||
| * @example editor.commands.unsetStrike() | ||
| */ | ||
| unsetStrike: () => ReturnType; | ||
| }; | ||
| } | ||
| } | ||
| /** | ||
| * Matches a strike to a ~~strike~~ on input. | ||
| */ | ||
| declare const inputRegex: RegExp; | ||
| /** | ||
| * Matches a strike to a ~~strike~~ on paste. | ||
| */ | ||
| declare const pasteRegex: RegExp; | ||
| /** | ||
| * This extension allows you to create strike text. | ||
| * @see https://www.tiptap.dev/api/marks/strike | ||
| */ | ||
| declare const Strike: Mark<StrikeOptions, any>; | ||
| export { Strike, type StrikeOptions, Strike as default, inputRegex, pasteRegex }; |
| // src/strike.ts | ||
| import { Mark, markInputRule, markPasteRule, mergeAttributes } from "@tiptap/core"; | ||
| var inputRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/; | ||
| var pasteRegex = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g; | ||
| var Strike = Mark.create({ | ||
| name: "strike", | ||
| addOptions() { | ||
| return { | ||
| HTMLAttributes: {} | ||
| }; | ||
| }, | ||
| parseHTML() { | ||
| return [ | ||
| { | ||
| tag: "s" | ||
| }, | ||
| { | ||
| tag: "del" | ||
| }, | ||
| { | ||
| tag: "strike" | ||
| }, | ||
| { | ||
| style: "text-decoration", | ||
| consuming: false, | ||
| getAttrs: (style) => style.includes("line-through") ? {} : false | ||
| } | ||
| ]; | ||
| }, | ||
| renderHTML({ HTMLAttributes }) { | ||
| return ["s", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]; | ||
| }, | ||
| markdownTokenName: "del", | ||
| parseMarkdown: (token, helpers) => { | ||
| return helpers.applyMark("strike", helpers.parseInline(token.tokens || [])); | ||
| }, | ||
| renderMarkdown: (node, h) => { | ||
| return `~~${h.renderChildren(node)}~~`; | ||
| }, | ||
| addCommands() { | ||
| return { | ||
| setStrike: () => ({ commands }) => { | ||
| return commands.setMark(this.name); | ||
| }, | ||
| toggleStrike: () => ({ commands }) => { | ||
| return commands.toggleMark(this.name); | ||
| }, | ||
| unsetStrike: () => ({ commands }) => { | ||
| return commands.unsetMark(this.name); | ||
| } | ||
| }; | ||
| }, | ||
| addKeyboardShortcuts() { | ||
| return { | ||
| "Mod-Shift-s": () => this.editor.commands.toggleStrike() | ||
| }; | ||
| }, | ||
| addInputRules() { | ||
| return [ | ||
| markInputRule({ | ||
| find: inputRegex, | ||
| type: this.type | ||
| }) | ||
| ]; | ||
| }, | ||
| addPasteRules() { | ||
| return [ | ||
| markPasteRule({ | ||
| find: pasteRegex, | ||
| type: this.type | ||
| }) | ||
| ]; | ||
| } | ||
| }); | ||
| // src/index.ts | ||
| var index_default = Strike; | ||
| export { | ||
| Strike, | ||
| index_default as default, | ||
| inputRegex, | ||
| pasteRegex | ||
| }; | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"sources":["../src/strike.ts","../src/index.ts"],"sourcesContent":["import { Mark, markInputRule, markPasteRule, mergeAttributes } from '@tiptap/core'\n\nexport interface StrikeOptions {\n /**\n * HTML attributes to add to the strike element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n strike: {\n /**\n * Set a strike mark\n * @example editor.commands.setStrike()\n */\n setStrike: () => ReturnType\n /**\n * Toggle a strike mark\n * @example editor.commands.toggleStrike()\n */\n toggleStrike: () => ReturnType\n /**\n * Unset a strike mark\n * @example editor.commands.unsetStrike()\n */\n unsetStrike: () => ReturnType\n }\n }\n}\n\n/**\n * Matches a strike to a ~~strike~~ on input.\n */\nexport const inputRegex = /(?:^|\\s)(~~(?!\\s+~~)((?:[^~]+))~~(?!\\s+~~))$/\n\n/**\n * Matches a strike to a ~~strike~~ on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(~~(?!\\s+~~)((?:[^~]+))~~(?!\\s+~~))/g\n\n/**\n * This extension allows you to create strike text.\n * @see https://www.tiptap.dev/api/marks/strike\n */\nexport const Strike = Mark.create<StrikeOptions>({\n name: 'strike',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 's',\n },\n {\n tag: 'del',\n },\n {\n tag: 'strike',\n },\n {\n style: 'text-decoration',\n consuming: false,\n getAttrs: style => ((style as string).includes('line-through') ? {} : false),\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['s', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n markdownTokenName: 'del',\n\n parseMarkdown: (token, helpers) => {\n // Convert 'del' token to strike mark\n return helpers.applyMark('strike', helpers.parseInline(token.tokens || []))\n },\n\n renderMarkdown: (node, h) => {\n return `~~${h.renderChildren(node)}~~`\n },\n\n addCommands() {\n return {\n setStrike:\n () =>\n ({ commands }) => {\n return commands.setMark(this.name)\n },\n toggleStrike:\n () =>\n ({ commands }) => {\n return commands.toggleMark(this.name)\n },\n unsetStrike:\n () =>\n ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-s': () => this.editor.commands.toggleStrike(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n","import { Strike } from './strike.js'\n\nexport * from './strike.js'\n\nexport default Strike\n"],"mappings":";A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,MAAM,KAAK,OAAO,SAAS,aAAa;AAAA,IACzD;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,MACL,cAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,MACL,cAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;ACjID,IAAO,gBAAQ;","names":[]} |
+3
-3
| { | ||
| "name": "@tiptap/extension-strike", | ||
| "description": "strike extension for tiptap", | ||
| "version": "3.20.3", | ||
| "version": "3.20.4", | ||
| "homepage": "https://tiptap.dev", | ||
@@ -34,6 +34,6 @@ "keywords": [ | ||
| "devDependencies": { | ||
| "@tiptap/core": "^3.20.3" | ||
| "@tiptap/core": "^3.20.4" | ||
| }, | ||
| "peerDependencies": { | ||
| "@tiptap/core": "^3.20.3" | ||
| "@tiptap/core": "^3.20.4" | ||
| }, | ||
@@ -40,0 +40,0 @@ "repository": { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22312
269.65%11
120%357
192.62%