@bikdotai/bik-component-library 0.0.838-beta.4 → 0.0.838-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/editor/extensions/buildExtensions.js +2 -2
- package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
- package/dist/cjs/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js +1 -1
- package/dist/cjs/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js.map +1 -1
- package/dist/esm/editor/extensions/buildExtensions.js +12 -10
- package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
- package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.d.ts +5 -7
- package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js +53 -21
- package/dist/esm/editor/extensions/htmlTagStrip/HtmlTagStripExtension.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@tiptap/extension-character-count"),_=require("@tiptap/extension-color"),k=require("@tiptap/extension-font-family"),b=require("@tiptap/extension-hard-break"),C=require("@tiptap/extension-highlight"),M=require("@tiptap/extension-image"),y=require("@tiptap/extension-link"),T=require("../../node_modules/@tiptap/extension-paragraph/dist/index.js"),g=require("@tiptap/extension-placeholder"),P=require("@tiptap/extension-subscript"),L=require("@tiptap/extension-superscript"),H=require("@tiptap/extension-text-align"),D=require("@tiptap/extension-text-style"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const E=require("@tiptap/extension-character-count"),_=require("@tiptap/extension-color"),k=require("@tiptap/extension-font-family"),b=require("@tiptap/extension-hard-break"),C=require("@tiptap/extension-highlight"),M=require("@tiptap/extension-image"),y=require("@tiptap/extension-link"),T=require("../../node_modules/@tiptap/extension-paragraph/dist/index.js"),g=require("@tiptap/extension-placeholder"),P=require("@tiptap/extension-subscript"),L=require("@tiptap/extension-superscript"),H=require("@tiptap/extension-text-align"),D=require("@tiptap/extension-text-style"),A=require("@tiptap/extension-underline"),w=require("@tiptap/starter-kit"),z=require("../../helpers/sanitize.js"),B=require("./characterLimit/CharacterLimitExtension.js"),F=require("./FontSizeExtension.js"),I=require("./htmlTagStrip/HtmlTagStripExtension.js"),O=require("./jsonHighlight/JsonHighlightExtension.js"),i=require("./mention/MentionExtension.js"),R=require("./paste/PasteExtension.js"),N=require("./plainClipboard/PasteNormalizationExtension.js"),U=require("./sectionDivider/SectionDividerNode.js"),l=require("./sendShortcut/SendShortcutExtension.js"),j=require("./slashCommand/SlashCommandExtension.js"),v=require("./variable/VariableDecorationExtension.js"),n=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},u=n(E),d=n(_),K=n(k),J=n(b),V=n(C),W=n(M),Z=n(y),c=n(g),G=n(P),Q=n(L),X=n(H),Y=n(A),h=n(w);function $(e){if(e.features?.jsonMode)return[h.default.configure({link:!1,underline:!1,bold:!1,italic:!1,strike:!1,code:!1,heading:!1,bulletList:!1,orderedList:!1,blockquote:!1,horizontalRule:!1}),c.default.configure({placeholder:e.placeholder??`{
|
|
2
2
|
|
|
3
|
-
}`}),O.JsonHighlightExtension,l.SendShortcutExtension.configure({onSend:e.onSend,sendShortcut:e.sendShortcut,extraShortcuts:e.shortcuts??[]}),...e.maxCharacters?[u.default.configure({limit:e.maxCharacters})]:[]];const s=e.features?.richPaste??!1,m=e.features?.richTypography??!1,a=e.features?.allowedMarks,r=t=>!a||a.includes(t),f=J.default.extend({addKeyboardShortcuts(){return{"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),o=t=>t==="0"||t==="0px"||t==="0pt"||t==="0em",x=T.default.extend({addAttributes(){return{...this.parent?.()??{},margin:{default:null,parseHTML:t=>o(t.style.marginTop)&&o(t.style.marginBottom)?"0":null,renderHTML:t=>t.margin==="0"?{style:"margin: 0px"}:{}}}}}),
|
|
3
|
+
}`}),O.JsonHighlightExtension,l.SendShortcutExtension.configure({onSend:e.onSend,sendShortcut:e.sendShortcut,extraShortcuts:e.shortcuts??[]}),...e.maxCharacters?[u.default.configure({limit:e.maxCharacters})]:[]];const s=e.features?.richPaste??!1,m=e.features?.richTypography??!1,a=e.features?.allowedMarks,r=t=>!a||a.includes(t),f=J.default.extend({addKeyboardShortcuts(){return{"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),o=t=>t==="0"||t==="0px"||t==="0pt"||t==="0em",x=T.default.extend({addAttributes(){return{...this.parent?.()??{},margin:{default:null,parseHTML:t=>o(t.style.marginTop)&&o(t.style.marginBottom)?"0":null,renderHTML:t=>t.margin==="0"?{style:"margin: 0px"}:{}}}}}),p=[h.default.configure({link:!1,underline:!1,hardBreak:!1,paragraph:!1,bold:r("bold")?{}:!1,italic:r("italic")?{}:!1,strike:r("strike")?{}:!1,code:r("code")?{}:!1}),x,f,...r("underline")?[Y.default]:[],Z.default.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,isAllowedUri:t=>z.isAllowedLinkUrl(t),HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),D.TextStyle,c.default.configure({placeholder:e.placeholder??"Type a message..."}),...e.onPaste?[R.PasteExtension.configure({onPaste:e.onPaste})]:[],N.PasteNormalizationExtension.configure({preserveMarks:s,plainOnly:!s}),l.SendShortcutExtension.configure({onSend:e.onSend,sendShortcut:e.sendShortcut,extraShortcuts:e.shortcuts??[]}),v.VariableDecorationExtension,I.HtmlTagStripExtension.configure({stripAll:!s}),...e.maxCharacters?[u.default.configure({limit:e.maxCharacters})]:[],...e.characterLimit?[B.CharacterLimitExtension.configure({limit:e.characterLimit})]:[],U.SectionDividerNode],S=[...e.mentions?.agents?[i.buildAgentMentionExtension(e.mentions.agents,e.onMentionSelected,e.renderMentionItem,e.renderMentionDropdown,e.removeMentionTriggerOnDismiss)]:[],...e.mentions?.teams?[i.buildTeamMentionExtension(e.mentions.teams,e.onMentionSelected,e.renderMentionItem,e.renderMentionDropdown,e.removeMentionTriggerOnDismiss)]:[],...e.slashCommands?[j.buildSlashCommandExtension(e.slashCommands,e.onSlashCommandSelected,e.renderSlashCommandItem,e.renderSlashCommandDropdown)]:[]],q=m?[d.default,V.default.configure({multicolor:!0}),K.default,F.FontSizeExtension,X.default.configure({types:["heading","paragraph"]}),G.default,Q.default,W.default]:[d.default];return[...p,...S,...q]}exports.buildExtensions=$;
|
|
4
4
|
//# sourceMappingURL=buildExtensions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildExtensions.js","sources":["../../../../src/editor/extensions/buildExtensions.ts"],"sourcesContent":["import CharacterCount from '@tiptap/extension-character-count';\nimport Color from '@tiptap/extension-color';\nimport FontFamily from '@tiptap/extension-font-family';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Highlight from '@tiptap/extension-highlight';\nimport Image from '@tiptap/extension-image';\nimport Link from '@tiptap/extension-link';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Subscript from '@tiptap/extension-subscript';\nimport Superscript from '@tiptap/extension-superscript';\nimport TextAlign from '@tiptap/extension-text-align';\nimport { TextStyle } from '@tiptap/extension-text-style';\nimport Underline from '@tiptap/extension-underline';\nimport StarterKit from '@tiptap/starter-kit';\nimport type { ReactNode } from 'react';\nimport { isAllowedLinkUrl } from '../../helpers/sanitize';\nimport type {\n\tEditorFeatures,\n\tEditorSnapshot,\n\tKeyboardShortcut,\n\tMentionDropdownRenderProps,\n\tMentionItem,\n\tPasteData,\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../BikEditor.types';\nimport { CharacterLimitExtension } from './characterLimit/CharacterLimitExtension';\nimport { FontSizeExtension } from './FontSizeExtension';\nimport { HtmlTagStripExtension } from './htmlTagStrip/HtmlTagStripExtension';\nimport { JsonHighlightExtension } from './jsonHighlight/JsonHighlightExtension';\nimport {\n\tbuildAgentMentionExtension,\n\tbuildTeamMentionExtension,\n} from './mention/MentionExtension';\nimport { PasteExtension } from './paste/PasteExtension';\nimport { PasteNormalizationExtension } from './plainClipboard/PasteNormalizationExtension';\nimport { SectionDividerNode } from './sectionDivider/SectionDividerNode';\nimport { SendShortcutExtension } from './sendShortcut/SendShortcutExtension';\nimport { buildSlashCommandExtension } from './slashCommand/SlashCommandExtension';\nimport { VariableDecorationExtension } from './variable/VariableDecorationExtension';\n\ninterface ExtensionConfig {\n\tfeatures?: EditorFeatures;\n\tplaceholder?: string;\n\tmaxCharacters?: number;\n\t/**\n\t * Soft character limit. Unlike `maxCharacters` (which hard-blocks all input),\n\t * this blocks typing past the limit but ALLOWS paste to overflow, rendering\n\t * the excess characters greyed (`.bik-editor-overflow`). Purely visual +\n\t * typing-guard; the consumer shows the count/error and gates send itself.\n\t */\n\tcharacterLimit?: number;\n\thasSections?: boolean;\n\tmentions?: {\n\t\tagents?: { current: MentionItem[] };\n\t\tteams?: { current: MentionItem[] };\n\t};\n\tslashCommands?: { current: SlashCommandItem[] };\n\tonPaste?: (data: PasteData) => boolean | void;\n\tonSend?: (content: EditorSnapshot) => void;\n\tsendShortcut?:\n\t\t| { key: string; modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'> }\n\t\t| Array<{\n\t\t\t\tkey: string;\n\t\t\t\tmodifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;\n\t\t }>;\n\tshortcuts?: KeyboardShortcut[];\n\tonMentionSelected?: (item: MentionItem, char: '@' | '#') => void;\n\tonSlashCommandSelected?: (command: SlashCommandItem) => void;\n\trenderMentionItem?: (item: MentionItem, isActive: boolean) => ReactNode;\n\trenderMentionDropdown?: (props: MentionDropdownRenderProps) => ReactNode;\n\tremoveMentionTriggerOnDismiss?: boolean;\n\trenderSlashCommandItem?: (\n\t\titem: SlashCommandItem,\n\t\tisActive: boolean,\n\t) => ReactNode;\n\trenderSlashCommandDropdown?: (\n\t\tprops: SlashCommandDropdownRenderProps,\n\t) => ReactNode;\n}\n\nexport function buildExtensions(config: ExtensionConfig) {\n\t// JSON body mode is a dedicated code editor — it deliberately skips the rich\n\t// text stack (mentions, typography, rich paste, sections) and turns the whole\n\t// document into one syntax-highlighted JSON code block, Postman-style.\n\tif (config.features?.jsonMode) {\n\t\treturn [\n\t\t\tStarterKit.configure({\n\t\t\t\tlink: false,\n\t\t\t\tunderline: false,\n\t\t\t\t// Keep codeBlock (the JSON container) and history; drop everything\n\t\t\t\t// that has no meaning inside raw JSON.\n\t\t\t\tbold: false,\n\t\t\t\titalic: false,\n\t\t\t\tstrike: false,\n\t\t\t\tcode: false,\n\t\t\t\theading: false,\n\t\t\t\tbulletList: false,\n\t\t\t\torderedList: false,\n\t\t\t\tblockquote: false,\n\t\t\t\thorizontalRule: false,\n\t\t\t}),\n\t\t\tPlaceholder.configure({\n\t\t\t\tplaceholder: config.placeholder ?? '{\\n \\n}',\n\t\t\t}),\n\t\t\tJsonHighlightExtension,\n\t\t\tSendShortcutExtension.configure({\n\t\t\t\tonSend: config.onSend,\n\t\t\t\tsendShortcut: config.sendShortcut,\n\t\t\t\textraShortcuts: config.shortcuts ?? [],\n\t\t\t}),\n\t\t\t...(config.maxCharacters\n\t\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\n\t\t\t\t: []),\n\t\t];\n\t}\n\n\tconst hasRichPaste = config.features?.richPaste ?? false;\n\tconst hasRichTypography = config.features?.richTypography ?? false;\n\n\t// When allowedMarks is specified only those marks are registered in the schema.\n\t// This disables rendering, keyboard shortcuts AND paste-preservation for the\n\t// excluded marks — all three come for free when the extension is absent.\n\tconst allowedMarks = config.features?.allowedMarks;\n\tconst isMark = (m: 'bold' | 'italic' | 'strike' | 'underline' | 'code') =>\n\t\t!allowedMarks || allowedMarks.includes(m);\n\n\t// Soft line break. Shift-Enter inserts a <br> inside the current block\n\t// (matches Gmail); plain Enter still splits the block into a new paragraph\n\t// via StarterKit's default. HardBreak is registered standalone — like Link\n\t// and Underline above — instead of through StarterKit, so we can bind ONLY\n\t// Shift-Enter here and leave Mod-Enter free for the send shortcut.\n\tconst softBreak = HardBreak.extend({\n\t\taddKeyboardShortcuts() {\n\t\t\treturn {\n\t\t\t\t'Shift-Enter': () => this.editor.commands.setHardBreak(),\n\t\t\t};\n\t\t},\n\t});\n\n\t// Paragraph that preserves a zero block-margin from the source (Gmail-style).\n\t// Most sources (ChatGPT, typed text) use plain <p> → no margin attr → the\n\t// editor/viewer default 1em margin provides the gap. Google-Docs-style\n\t// content uses margin:0 paragraphs and a separate blank-line paragraph for\n\t// spacing; we keep that margin:0 so the blank line — not stacked margins —\n\t// provides a single-line gap, exactly like Gmail. The paste pipeline also\n\t// sets margin:'0' on every paragraph when a paste contains blank-line\n\t// paragraphs (see applyParagraphSpacing), so spacing comes from EITHER the\n\t// margin OR the blank line, never both (no double gap).\n\tconst isZeroLen = (v: string) =>\n\t\tv === '0' || v === '0px' || v === '0pt' || v === '0em';\n\tconst ParagraphWithMargin = Paragraph.extend({\n\t\taddAttributes() {\n\t\t\treturn {\n\t\t\t\t...(this.parent?.() ?? {}),\n\t\t\t\tmargin: {\n\t\t\t\t\tdefault: null,\n\t\t\t\t\tparseHTML: (el: HTMLElement) =>\n\t\t\t\t\t\tisZeroLen(el.style.marginTop) && isZeroLen(el.style.marginBottom)\n\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\trenderHTML: (attrs: { margin?: string | null }) =>\n\t\t\t\t\t\tattrs.margin === '0' ? { style: 'margin: 0px' } : {},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t});\n\n\tconst base = [\n\t\t// Exclude Link and Underline from StarterKit — TipTap v3 bundles both.\n\t\t// Without this, two copies of each are registered and the StarterKit copy's\n\t\t// click handler calls window.open even when openOnClick: false is set.\n\t\tStarterKit.configure({\n\t\t\tlink: false,\n\t\t\tunderline: false,\n\t\t\thardBreak: false,\n\t\t\tparagraph: false,\n\t\t\tbold: isMark('bold') ? {} : false,\n\t\t\titalic: isMark('italic') ? {} : false,\n\t\t\tstrike: isMark('strike') ? {} : false,\n\t\t\tcode: isMark('code') ? {} : false,\n\t\t}),\n\t\tParagraphWithMargin,\n\t\tsoftBreak,\n\t\t...(isMark('underline') ? [Underline] : []),\n\t\t// Extend Link to strip addPasteRules() and addInputRules() so pasting a\n\t\t// URL never creates a hyperlink regardless of autolink/linkOnPaste values.\n\t\tLink.extend({\n\t\t\taddPasteRules: () => [],\n\t\t\taddInputRules: () => [],\n\t\t}).configure({\n\t\t\topenOnClick: false,\n\t\t\tautolink: false,\n\t\t\tlinkOnPaste: false,\n\t\t\t// Block javascript:/data:/vbscript: hrefs. TipTap keeps the href\n\t\t\t// attribute verbatim, so scheme validation must live here.\n\t\t\tisAllowedUri: (url) => isAllowedLinkUrl(url),\n\t\t\tHTMLAttributes: {\n\t\t\t\trel: 'noopener noreferrer',\n\t\t\t\tclass: 'bik-link',\n\t\t\t},\n\t\t}),\n\t\tTextStyle,\n\t\tPlaceholder.configure({\n\t\t\tplaceholder: config.placeholder ?? 'Type a message...',\n\t\t}),\n\t\t// Consumer paste callback runs first. If it returns true the event is\n\t\t// consumed and neither PlainClipboardExtension nor the editor's default\n\t\t// paste handling will run for that event.\n\t\t...(config.onPaste\n\t\t\t? [PasteExtension.configure({ onPaste: config.onPaste })]\n\t\t\t: []),\n\t\tPasteNormalizationExtension.configure({\n\t\t\tpreserveMarks: hasRichPaste,\n\t\t\t// Only email + signature (richPaste) keep the rich HTML paste pipeline.\n\t\t\t// Every other channel (WhatsApp, IG, FB, comments) forces plain-text\n\t\t\t// paste for BOTH Cmd/Ctrl+V and Cmd/Ctrl+Shift+V — no formatting.\n\t\t\tplainOnly: !hasRichPaste,\n\t\t}),\n\t\tSendShortcutExtension.configure({\n\t\t\tonSend: config.onSend,\n\t\t\tsendShortcut: config.sendShortcut,\n\t\t\textraShortcuts: config.shortcuts ?? [],\n\t\t}),\n\t\tVariableDecorationExtension,\n\t\t// Strip complete HTML tags from typed text in non-email channels.\n\t\t// Email (richPaste) keeps tags because the editor legitimately renders HTML.\n\t\t...(!hasRichPaste ? [HtmlTagStripExtension] : []),\n\t\t...(config.maxCharacters\n\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\n\t\t\t: []),\n\t\t...(config.characterLimit\n\t\t\t? [CharacterLimitExtension.configure({ limit: config.characterLimit })]\n\t\t\t: []),\n\t\t// Always register SectionDividerNode so the custom <div data-section-divider>\n\t\t// node is part of the schema in every editor instance. This means imperative\n\t\t// callers (setBodyAndSections / setSectionContent) work even when no\n\t\t// `sections` prop was provided at mount time.\n\t\tSectionDividerNode,\n\t];\n\n\tconst mentionExtensions = [\n\t\t...(config.mentions?.agents\n\t\t\t? [\n\t\t\t\t\tbuildAgentMentionExtension(\n\t\t\t\t\t\tconfig.mentions.agents,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t\tconfig.removeMentionTriggerOnDismiss,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.mentions?.teams\n\t\t\t? [\n\t\t\t\t\tbuildTeamMentionExtension(\n\t\t\t\t\t\tconfig.mentions.teams,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t\tconfig.removeMentionTriggerOnDismiss,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.slashCommands\n\t\t\t? [\n\t\t\t\t\tbuildSlashCommandExtension(\n\t\t\t\t\t\tconfig.slashCommands,\n\t\t\t\t\t\tconfig.onSlashCommandSelected,\n\t\t\t\t\t\tconfig.renderSlashCommandItem,\n\t\t\t\t\t\tconfig.renderSlashCommandDropdown,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t];\n\n\tconst richExtensions = hasRichTypography\n\t\t? [\n\t\t\t\tColor,\n\t\t\t\tHighlight.configure({ multicolor: true }),\n\t\t\t\tFontFamily,\n\t\t\t\tFontSizeExtension,\n\t\t\t\tTextAlign.configure({ types: ['heading', 'paragraph'] }),\n\t\t\t\tSubscript,\n\t\t\t\tSuperscript,\n\t\t\t\tImage,\n\t\t ]\n\t\t: [Color];\n\n\treturn [...base, ...mentionExtensions, ...richExtensions];\n}\n"],"names":["buildExtensions","config","StarterKit","Placeholder","JsonHighlightExtension","SendShortcutExtension","CharacterCount","hasRichPaste","hasRichTypography","allowedMarks","isMark","m","softBreak","HardBreak","isZeroLen","v","ParagraphWithMargin","Paragraph","el","attrs","base","Underline","Link","url","isAllowedLinkUrl","TextStyle","PasteExtension","PasteNormalizationExtension","VariableDecorationExtension","HtmlTagStripExtension","CharacterLimitExtension","SectionDividerNode","mentionExtensions","buildAgentMentionExtension","buildTeamMentionExtension","buildSlashCommandExtension","richExtensions","Color","Highlight","FontFamily","FontSizeExtension","TextAlign","Subscript","Superscript","Image"],"mappings":"+7CAkFO,SAASA,EAAgBC,EAAyB,CAIxD,GAAIA,EAAO,UAAU,SACpB,MAAO,CACNC,EAAAA,QAAW,UAAU,CACpB,KAAM,GACN,UAAW,GAGX,KAAM,GACN,OAAQ,GACR,OAAQ,GACR,KAAM,GACN,QAAS,GACT,WAAY,GACZ,YAAa,GACb,WAAY,GACZ,eAAgB,EAAA,CAChB,EACDC,EAAAA,QAAY,UAAU,CACrB,YAAaF,EAAO,aAAe;AAAA;AAAA,EAAA,CACnC,EACDG,EAAAA,uBACAC,EAAAA,sBAAsB,UAAU,CAC/B,OAAQJ,EAAO,OACf,aAAcA,EAAO,aACrB,eAAgBA,EAAO,WAAa,CAAA,CAAC,CACrC,EACD,GAAIA,EAAO,cACR,CAACK,UAAe,UAAU,CAAE,MAAOL,EAAO,aAAA,CAAe,CAAC,EAC1D,CAAA,CAAC,EAIN,MAAMM,EAAeN,EAAO,UAAU,WAAa,GAC7CO,EAAoBP,EAAO,UAAU,gB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ET,MAAO,CAAC,GAAGjB,EAAM,GAAGY,EAAmB,GAAGI,CAAc,CACzD"}
|
|
1
|
+
{"version":3,"file":"buildExtensions.js","sources":["../../../../src/editor/extensions/buildExtensions.ts"],"sourcesContent":["import CharacterCount from '@tiptap/extension-character-count';\nimport Color from '@tiptap/extension-color';\nimport FontFamily from '@tiptap/extension-font-family';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Highlight from '@tiptap/extension-highlight';\nimport Image from '@tiptap/extension-image';\nimport Link from '@tiptap/extension-link';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Subscript from '@tiptap/extension-subscript';\nimport Superscript from '@tiptap/extension-superscript';\nimport TextAlign from '@tiptap/extension-text-align';\nimport { TextStyle } from '@tiptap/extension-text-style';\nimport Underline from '@tiptap/extension-underline';\nimport StarterKit from '@tiptap/starter-kit';\nimport type { ReactNode } from 'react';\nimport { isAllowedLinkUrl } from '../../helpers/sanitize';\nimport type {\n\tEditorFeatures,\n\tEditorSnapshot,\n\tKeyboardShortcut,\n\tMentionDropdownRenderProps,\n\tMentionItem,\n\tPasteData,\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../BikEditor.types';\nimport { CharacterLimitExtension } from './characterLimit/CharacterLimitExtension';\nimport { FontSizeExtension } from './FontSizeExtension';\nimport { HtmlTagStripExtension } from './htmlTagStrip/HtmlTagStripExtension';\nimport { JsonHighlightExtension } from './jsonHighlight/JsonHighlightExtension';\nimport {\n\tbuildAgentMentionExtension,\n\tbuildTeamMentionExtension,\n} from './mention/MentionExtension';\nimport { PasteExtension } from './paste/PasteExtension';\nimport { PasteNormalizationExtension } from './plainClipboard/PasteNormalizationExtension';\nimport { SectionDividerNode } from './sectionDivider/SectionDividerNode';\nimport { SendShortcutExtension } from './sendShortcut/SendShortcutExtension';\nimport { buildSlashCommandExtension } from './slashCommand/SlashCommandExtension';\nimport { VariableDecorationExtension } from './variable/VariableDecorationExtension';\n\ninterface ExtensionConfig {\n\tfeatures?: EditorFeatures;\n\tplaceholder?: string;\n\tmaxCharacters?: number;\n\t/**\n\t * Soft character limit. Unlike `maxCharacters` (which hard-blocks all input),\n\t * this blocks typing past the limit but ALLOWS paste to overflow, rendering\n\t * the excess characters greyed (`.bik-editor-overflow`). Purely visual +\n\t * typing-guard; the consumer shows the count/error and gates send itself.\n\t */\n\tcharacterLimit?: number;\n\thasSections?: boolean;\n\tmentions?: {\n\t\tagents?: { current: MentionItem[] };\n\t\tteams?: { current: MentionItem[] };\n\t};\n\tslashCommands?: { current: SlashCommandItem[] };\n\tonPaste?: (data: PasteData) => boolean | void;\n\tonSend?: (content: EditorSnapshot) => void;\n\tsendShortcut?:\n\t\t| { key: string; modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'> }\n\t\t| Array<{\n\t\t\t\tkey: string;\n\t\t\t\tmodifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;\n\t\t }>;\n\tshortcuts?: KeyboardShortcut[];\n\tonMentionSelected?: (item: MentionItem, char: '@' | '#') => void;\n\tonSlashCommandSelected?: (command: SlashCommandItem) => void;\n\trenderMentionItem?: (item: MentionItem, isActive: boolean) => ReactNode;\n\trenderMentionDropdown?: (props: MentionDropdownRenderProps) => ReactNode;\n\tremoveMentionTriggerOnDismiss?: boolean;\n\trenderSlashCommandItem?: (\n\t\titem: SlashCommandItem,\n\t\tisActive: boolean,\n\t) => ReactNode;\n\trenderSlashCommandDropdown?: (\n\t\tprops: SlashCommandDropdownRenderProps,\n\t) => ReactNode;\n}\n\nexport function buildExtensions(config: ExtensionConfig) {\n\t// JSON body mode is a dedicated code editor — it deliberately skips the rich\n\t// text stack (mentions, typography, rich paste, sections) and turns the whole\n\t// document into one syntax-highlighted JSON code block, Postman-style.\n\tif (config.features?.jsonMode) {\n\t\treturn [\n\t\t\tStarterKit.configure({\n\t\t\t\tlink: false,\n\t\t\t\tunderline: false,\n\t\t\t\t// Keep codeBlock (the JSON container) and history; drop everything\n\t\t\t\t// that has no meaning inside raw JSON.\n\t\t\t\tbold: false,\n\t\t\t\titalic: false,\n\t\t\t\tstrike: false,\n\t\t\t\tcode: false,\n\t\t\t\theading: false,\n\t\t\t\tbulletList: false,\n\t\t\t\torderedList: false,\n\t\t\t\tblockquote: false,\n\t\t\t\thorizontalRule: false,\n\t\t\t}),\n\t\t\tPlaceholder.configure({\n\t\t\t\tplaceholder: config.placeholder ?? '{\\n \\n}',\n\t\t\t}),\n\t\t\tJsonHighlightExtension,\n\t\t\tSendShortcutExtension.configure({\n\t\t\t\tonSend: config.onSend,\n\t\t\t\tsendShortcut: config.sendShortcut,\n\t\t\t\textraShortcuts: config.shortcuts ?? [],\n\t\t\t}),\n\t\t\t...(config.maxCharacters\n\t\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\n\t\t\t\t: []),\n\t\t];\n\t}\n\n\tconst hasRichPaste = config.features?.richPaste ?? false;\n\tconst hasRichTypography = config.features?.richTypography ?? false;\n\n\t// When allowedMarks is specified only those marks are registered in the schema.\n\t// This disables rendering, keyboard shortcuts AND paste-preservation for the\n\t// excluded marks — all three come for free when the extension is absent.\n\tconst allowedMarks = config.features?.allowedMarks;\n\tconst isMark = (m: 'bold' | 'italic' | 'strike' | 'underline' | 'code') =>\n\t\t!allowedMarks || allowedMarks.includes(m);\n\n\t// Soft line break. Shift-Enter inserts a <br> inside the current block\n\t// (matches Gmail); plain Enter still splits the block into a new paragraph\n\t// via StarterKit's default. HardBreak is registered standalone — like Link\n\t// and Underline above — instead of through StarterKit, so we can bind ONLY\n\t// Shift-Enter here and leave Mod-Enter free for the send shortcut.\n\tconst softBreak = HardBreak.extend({\n\t\taddKeyboardShortcuts() {\n\t\t\treturn {\n\t\t\t\t'Shift-Enter': () => this.editor.commands.setHardBreak(),\n\t\t\t};\n\t\t},\n\t});\n\n\t// Paragraph that preserves a zero block-margin from the source (Gmail-style).\n\t// Most sources (ChatGPT, typed text) use plain <p> → no margin attr → the\n\t// editor/viewer default 1em margin provides the gap. Google-Docs-style\n\t// content uses margin:0 paragraphs and a separate blank-line paragraph for\n\t// spacing; we keep that margin:0 so the blank line — not stacked margins —\n\t// provides a single-line gap, exactly like Gmail. The paste pipeline also\n\t// sets margin:'0' on every paragraph when a paste contains blank-line\n\t// paragraphs (see applyParagraphSpacing), so spacing comes from EITHER the\n\t// margin OR the blank line, never both (no double gap).\n\tconst isZeroLen = (v: string) =>\n\t\tv === '0' || v === '0px' || v === '0pt' || v === '0em';\n\tconst ParagraphWithMargin = Paragraph.extend({\n\t\taddAttributes() {\n\t\t\treturn {\n\t\t\t\t...(this.parent?.() ?? {}),\n\t\t\t\tmargin: {\n\t\t\t\t\tdefault: null,\n\t\t\t\t\tparseHTML: (el: HTMLElement) =>\n\t\t\t\t\t\tisZeroLen(el.style.marginTop) && isZeroLen(el.style.marginBottom)\n\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\trenderHTML: (attrs: { margin?: string | null }) =>\n\t\t\t\t\t\tattrs.margin === '0' ? { style: 'margin: 0px' } : {},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t});\n\n\tconst base = [\n\t\t// Exclude Link and Underline from StarterKit — TipTap v3 bundles both.\n\t\t// Without this, two copies of each are registered and the StarterKit copy's\n\t\t// click handler calls window.open even when openOnClick: false is set.\n\t\tStarterKit.configure({\n\t\t\tlink: false,\n\t\t\tunderline: false,\n\t\t\thardBreak: false,\n\t\t\tparagraph: false,\n\t\t\tbold: isMark('bold') ? {} : false,\n\t\t\titalic: isMark('italic') ? {} : false,\n\t\t\tstrike: isMark('strike') ? {} : false,\n\t\t\tcode: isMark('code') ? {} : false,\n\t\t}),\n\t\tParagraphWithMargin,\n\t\tsoftBreak,\n\t\t...(isMark('underline') ? [Underline] : []),\n\t\t// Extend Link to strip addPasteRules() and addInputRules() so pasting a\n\t\t// URL never creates a hyperlink regardless of autolink/linkOnPaste values.\n\t\tLink.extend({\n\t\t\taddPasteRules: () => [],\n\t\t\taddInputRules: () => [],\n\t\t}).configure({\n\t\t\topenOnClick: false,\n\t\t\tautolink: false,\n\t\t\tlinkOnPaste: false,\n\t\t\t// Block javascript:/data:/vbscript: hrefs. TipTap keeps the href\n\t\t\t// attribute verbatim, so scheme validation must live here.\n\t\t\tisAllowedUri: (url) => isAllowedLinkUrl(url),\n\t\t\tHTMLAttributes: {\n\t\t\t\trel: 'noopener noreferrer',\n\t\t\t\tclass: 'bik-link',\n\t\t\t},\n\t\t}),\n\t\tTextStyle,\n\t\tPlaceholder.configure({\n\t\t\tplaceholder: config.placeholder ?? 'Type a message...',\n\t\t}),\n\t\t// Consumer paste callback runs first. If it returns true the event is\n\t\t// consumed and neither PlainClipboardExtension nor the editor's default\n\t\t// paste handling will run for that event.\n\t\t...(config.onPaste\n\t\t\t? [PasteExtension.configure({ onPaste: config.onPaste })]\n\t\t\t: []),\n\t\tPasteNormalizationExtension.configure({\n\t\t\tpreserveMarks: hasRichPaste,\n\t\t\t// Only email + signature (richPaste) keep the rich HTML paste pipeline.\n\t\t\t// Every other channel (WhatsApp, IG, FB, comments) forces plain-text\n\t\t\t// paste for BOTH Cmd/Ctrl+V and Cmd/Ctrl+Shift+V — no formatting.\n\t\t\tplainOnly: !hasRichPaste,\n\t\t}),\n\t\tSendShortcutExtension.configure({\n\t\t\tonSend: config.onSend,\n\t\t\tsendShortcut: config.sendShortcut,\n\t\t\textraShortcuts: config.shortcuts ?? [],\n\t\t}),\n\t\tVariableDecorationExtension,\n\t\t// Strip HTML tags from typed text.\n\t\t// Non-email (WhatsApp, IG, private note): strip ALL tags.\n\t\t// Email (richPaste): strip only dangerous tags (script, iframe, form, etc.)\n\t\t// while preserving legitimate email tags (h1, table, div, etc.).\n\t\tHtmlTagStripExtension.configure({ stripAll: !hasRichPaste }),\n\t\t...(config.maxCharacters\n\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\n\t\t\t: []),\n\t\t...(config.characterLimit\n\t\t\t? [CharacterLimitExtension.configure({ limit: config.characterLimit })]\n\t\t\t: []),\n\t\t// Always register SectionDividerNode so the custom <div data-section-divider>\n\t\t// node is part of the schema in every editor instance. This means imperative\n\t\t// callers (setBodyAndSections / setSectionContent) work even when no\n\t\t// `sections` prop was provided at mount time.\n\t\tSectionDividerNode,\n\t];\n\n\tconst mentionExtensions = [\n\t\t...(config.mentions?.agents\n\t\t\t? [\n\t\t\t\t\tbuildAgentMentionExtension(\n\t\t\t\t\t\tconfig.mentions.agents,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t\tconfig.removeMentionTriggerOnDismiss,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.mentions?.teams\n\t\t\t? [\n\t\t\t\t\tbuildTeamMentionExtension(\n\t\t\t\t\t\tconfig.mentions.teams,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t\tconfig.removeMentionTriggerOnDismiss,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.slashCommands\n\t\t\t? [\n\t\t\t\t\tbuildSlashCommandExtension(\n\t\t\t\t\t\tconfig.slashCommands,\n\t\t\t\t\t\tconfig.onSlashCommandSelected,\n\t\t\t\t\t\tconfig.renderSlashCommandItem,\n\t\t\t\t\t\tconfig.renderSlashCommandDropdown,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t];\n\n\tconst richExtensions = hasRichTypography\n\t\t? [\n\t\t\t\tColor,\n\t\t\t\tHighlight.configure({ multicolor: true }),\n\t\t\t\tFontFamily,\n\t\t\t\tFontSizeExtension,\n\t\t\t\tTextAlign.configure({ types: ['heading', 'paragraph'] }),\n\t\t\t\tSubscript,\n\t\t\t\tSuperscript,\n\t\t\t\tImage,\n\t\t ]\n\t\t: [Color];\n\n\treturn [...base, ...mentionExtensions, ...richExtensions];\n}\n"],"names":["buildExtensions","config","StarterKit","Placeholder","JsonHighlightExtension","SendShortcutExtension","CharacterCount","hasRichPaste","hasRichTypography","allowedMarks","isMark","m","softBreak","HardBreak","isZeroLen","v","ParagraphWithMargin","Paragraph","el","attrs","base","Underline","Link","url","isAllowedLinkUrl","TextStyle","PasteExtension","PasteNormalizationExtension","VariableDecorationExtension","HtmlTagStripExtension","CharacterLimitExtension","SectionDividerNode","mentionExtensions","buildAgentMentionExtension","buildTeamMentionExtension","buildSlashCommandExtension","richExtensions","Color","Highlight","FontFamily","FontSizeExtension","TextAlign","Subscript","Superscript","Image"],"mappings":"+7CAkFO,SAASA,EAAgBC,EAAyB,CAIxD,GAAIA,EAAO,UAAU,SACpB,MAAO,CACNC,EAAAA,QAAW,UAAU,CACpB,KAAM,GACN,UAAW,GAGX,KAAM,GACN,OAAQ,GACR,OAAQ,GACR,KAAM,GACN,QAAS,GACT,WAAY,GACZ,YAAa,GACb,WAAY,GACZ,eAAgB,EAAA,CAChB,EACDC,EAAAA,QAAY,UAAU,CACrB,YAAaF,EAAO,aAAe;AAAA;AAAA,EAAA,CACnC,EACDG,EAAAA,uBACAC,EAAAA,sBAAsB,UAAU,CAC/B,OAAQJ,EAAO,OACf,aAAcA,EAAO,aACrB,eAAgBA,EAAO,WAAa,CAAA,CAAC,CACrC,EACD,GAAIA,EAAO,cACR,CAACK,UAAe,UAAU,CAAE,MAAOL,EAAO,aAAA,CAAe,CAAC,EAC1D,CAAA,CAAC,EAIN,MAAMM,EAAeN,EAAO,UAAU,WAAa,GAC7CO,EAAoBP,EAAO,UAAU,gBAAkB,GAKvDQ,EAAeR,EAAO,UAAU,aAChCS,EAAUC,GACf,CAACF,GAAgBA,EAAa,SAASE,CAAC,EAOnCC,EAAYC,EAAAA,QAAU,OAAO,CAClC,sBAAuB,CACtB,MAAO,CACN,cAAe,IAAM,KAAK,OAAO,SAAS,aAAA,CAAa,CAEzD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AQJ,EAAO,OACf,aAAcA,EAAO,aACrB,eAAgBA,EAAO,WAAa,CAAA,CAAC,CACrC,EACD2B,EAAAA,4BAKAC,EAAAA,sBAAsB,UAAU,CAAE,SAAU,CAACtB,EAAc,EAC3D,GAAIN,EAAO,cACR,CAACK,EAAAA,QAAe,UAAU,CAAE,MAAOL,EAAO,cAAe,CAAC,EAC1D,CAAA,EACH,GAAIA,EAAO,eACR,CAAC6B,EAAAA,wBAAwB,UAAU,CAAE,MAAO7B,EAAO,eAAgB,CAAC,EACpE,CAAA,EAKH8B,EAAAA,kBAAA,EAGKC,EAAoB,CACzB,GAAI/B,EAAO,UAAU,OAClB,CACAgC,EAAAA,2BACChC,EAAO,SAAS,OAChBA,EAAO,kBACPA,EAAO,kBACPA,EAAO,sBACPA,EAAO,6BAAA,CACR,EAEA,CAAA,EACH,GAAIA,EAAO,UAAU,MAClB,CACAiC,EAAAA,0BACCjC,EAAO,SAAS,MAChBA,EAAO,kBACPA,EAAO,kBACPA,EAAO,sBACPA,EAAO,6BAAA,CACR,EAEA,CAAA,EACH,GAAIA,EAAO,cACR,CACAkC,EAAAA,2BACClC,EAAO,cACPA,EAAO,uBACPA,EAAO,uBACPA,EAAO,0BAAA,CACR,EAEA,CAAA,CAAC,EAGCmC,EAAiB5B,EACpB,CACA6B,EAAAA,QACAC,EAAAA,QAAU,UAAU,CAAE,WAAY,GAAM,EACxCC,EAAAA,QACAC,EAAAA,kBACAC,EAAAA,QAAU,UAAU,CAAE,MAAO,CAAC,UAAW,WAAW,EAAG,EACvDC,EAAAA,QACAC,EAAAA,QACAC,EAAAA,OAAA,EAEA,CAACP,EAAAA,OAAK,EAET,MAAO,CAAC,GAAGjB,EAAM,GAAGY,EAAmB,GAAGI,CAAc,CACzD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("../../../node_modules/@tiptap/core/dist/index.js"),d=require("@tiptap/pm/state"),r=/<\/?[a-zA-Z][a-zA-Z0-9]*(?:\s[^>]*)?\/?>/g,g=new Set(["script","iframe","object","embed","applet","form","input","button","select","option","textarea","style","link","meta","base","svg","math","noscript","template"]),f=/<\/?([a-zA-Z][a-zA-Z0-9]*)/;function x(s){const n=s.match(f);return n?g.has(n[1].toLowerCase()):!1}const A=m.Extension.create({name:"htmlTagStrip",addOptions(){return{stripAll:!0}},addProseMirrorPlugins(){const{stripAll:s}=this.options,n=s?()=>!0:a=>x(a);return[new d.Plugin({appendTransaction(a,T,i){if(!a.some(t=>t.docChanged))return null;const{tr:e}=i;let p=!1;return i.doc.descendants((t,o)=>{if(!t.isText||!t.text||(r.lastIndex=0,!r.test(t.text)))return;r.lastIndex=0;const l=t.text.replace(r,u=>n(u)?"":u);if(l===t.text)return;const c=o+t.nodeSize;l?e.replaceWith(e.mapping.map(o),e.mapping.map(c),i.schema.text(l,t.marks)):e.delete(e.mapping.map(o),e.mapping.map(c)),p=!0}),p?(e.setMeta("addToHistory",!1),e):null}})]}});exports.HtmlTagStripExtension=A;
|
|
2
2
|
//# sourceMappingURL=HtmlTagStripExtension.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlTagStripExtension.js","sources":["../../../../../src/editor/extensions/htmlTagStrip/HtmlTagStripExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { Plugin } from '@tiptap/pm/state';\n\nconst COMPLETE_TAG = /<\\/?[a-zA-Z][a-zA-Z0-9]*(?:\\s[^>]*)?\\/?>/g;\n\n/**\n * Strips
|
|
1
|
+
{"version":3,"file":"HtmlTagStripExtension.js","sources":["../../../../../src/editor/extensions/htmlTagStrip/HtmlTagStripExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { Plugin } from '@tiptap/pm/state';\n\nconst COMPLETE_TAG = /<\\/?[a-zA-Z][a-zA-Z0-9]*(?:\\s[^>]*)?\\/?>/g;\n\n// Tags that have no business in an email — stripped even in rich-paste mode.\nconst DANGEROUS_TAG_NAMES = new Set([\n\t'script',\n\t'iframe',\n\t'object',\n\t'embed',\n\t'applet',\n\t'form',\n\t'input',\n\t'button',\n\t'select',\n\t'option',\n\t'textarea',\n\t'style',\n\t'link',\n\t'meta',\n\t'base',\n\t'svg',\n\t'math',\n\t'noscript',\n\t'template',\n]);\n\nconst TAG_NAME_RE = /<\\/?([a-zA-Z][a-zA-Z0-9]*)/;\n\nfunction isDangerousTag(tag: string): boolean {\n\tconst m = tag.match(TAG_NAME_RE);\n\treturn m ? DANGEROUS_TAG_NAMES.has(m[1].toLowerCase()) : false;\n}\n\n/**\n * Strips HTML tags from typed text in real time.\n *\n * Two modes controlled by `stripAll`:\n * - `true` (non-email): strip ALL complete tags — `<h1>Hello</h1>` → `Hello`\n * - `false` (email): strip only DANGEROUS tags — `<script>`, `<iframe>`,\n * `<form>`, etc. — while preserving legitimate email tags like `<h1>`, `<table>`\n *\n * Incomplete tags like `<h` are preserved (the regex requires a closing `>`).\n * Non-tag angle brackets like `2 < 3` are also preserved.\n */\nexport const HtmlTagStripExtension = Extension.create({\n\tname: 'htmlTagStrip',\n\taddOptions() {\n\t\treturn { stripAll: true };\n\t},\n\taddProseMirrorPlugins() {\n\t\tconst { stripAll } = this.options;\n\t\tconst shouldStrip = stripAll\n\t\t\t? () => true\n\t\t\t: (tag: string) => isDangerousTag(tag);\n\n\t\treturn [\n\t\t\tnew Plugin({\n\t\t\t\tappendTransaction(transactions, _oldState, newState) {\n\t\t\t\t\tif (!transactions.some((t) => t.docChanged)) return null;\n\n\t\t\t\t\tconst { tr } = newState;\n\t\t\t\t\tlet changed = false;\n\n\t\t\t\t\tnewState.doc.descendants((node, pos) => {\n\t\t\t\t\t\tif (!node.isText || !node.text) return;\n\t\t\t\t\t\tCOMPLETE_TAG.lastIndex = 0;\n\t\t\t\t\t\tif (!COMPLETE_TAG.test(node.text)) return;\n\n\t\t\t\t\t\tCOMPLETE_TAG.lastIndex = 0;\n\t\t\t\t\t\tconst stripped = node.text.replace(COMPLETE_TAG, (match) =>\n\t\t\t\t\t\t\tshouldStrip(match) ? '' : match,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (stripped === node.text) return;\n\n\t\t\t\t\t\tconst end = pos + node.nodeSize;\n\t\t\t\t\t\tif (stripped) {\n\t\t\t\t\t\t\ttr.replaceWith(\n\t\t\t\t\t\t\t\ttr.mapping.map(pos),\n\t\t\t\t\t\t\t\ttr.mapping.map(end),\n\t\t\t\t\t\t\t\tnewState.schema.text(stripped, node.marks),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttr.delete(tr.mapping.map(pos), tr.mapping.map(end));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchanged = true;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!changed) return null;\n\t\t\t\t\ttr.setMeta('addToHistory', false);\n\t\t\t\t\treturn tr;\n\t\t\t\t},\n\t\t\t}),\n\t\t];\n\t},\n});\n"],"names":["COMPLETE_TAG","DANGEROUS_TAG_NAMES","TAG_NAME_RE","isDangerousTag","tag","m","HtmlTagStripExtension","Extension","stripAll","shouldStrip","Plugin","transactions","_oldState","newState","tr","changed","node","pos","stripped","match","end"],"mappings":"kLAGMA,EAAe,4CAGfC,MAA0B,IAAI,CACnC,SACA,SACA,SACA,QACA,SACA,OACA,QACA,SACA,SACA,SACA,WACA,QACA,OACA,OACA,OACA,MACA,OACA,WACA,UACD,CAAC,EAEKC,EAAc,6BAEpB,SAASC,EAAeC,EAAsB,CAC7C,MAAMC,EAAID,EAAI,MAAMF,CAAW,EAC/B,OAAOG,EAAIJ,EAAoB,IAAII,EAAE,CAAC,EAAE,YAAA,CAAa,EAAI,EAC1D,CAaO,MAAMC,EAAwBC,EAAAA,UAAU,OAAO,CACrD,KAAM,eACN,YAAa,CACZ,MAAO,CAAE,SAAU,EAAA,CACpB,EACA,uBAAwB,CACvB,KAAM,CAAE,SAAAC,GAAa,KAAK,QACpBC,EAAcD,EACjB,IAAM,GACLJ,GAAgBD,EAAeC,CAAG,EAEtC,MAAO,CACN,IAAIM,SAAO,CACV,kBAAkBC,EAAcC,EAAWC,EAAU,CACpD,GAAI,CAACF,EAAa,KAAM,GAAM,EAAE,UAAU,EAAG,OAAO,KAEpD,KAAM,CAAE,GAAAG,GAAOD,EACf,IAAIE,EAAU,GA0Bd,OAxBAF,EAAS,IAAI,YAAY,CAACG,EAAMC,IAAQ,CAGvC,GAFI,CAACD,EAAK,QAAU,CAACA,EAAK,OAC1BhB,EAAa,UAAY,EACrB,CAACA,EAAa,KAAKgB,EAAK,IAAI,GAAG,OAEnChB,EAAa,UAAY,EACzB,MAAMkB,EAAWF,EAAK,KAAK,QAAQhB,EAAemB,GACjDV,EAAYU,CAAK,EAAI,GAAKA,CAAA,EAE3B,GAAID,IAAaF,EAAK,KAAM,OAE5B,MAAMI,EAAMH,EAAMD,EAAK,SACnBE,EACHJ,EAAG,YACFA,EAAG,QAAQ,IAAIG,CAAG,EAClBH,EAAG,QAAQ,IAAIM,CAAG,EAClBP,EAAS,OAAO,KAAKK,EAAUF,EAAK,KAAK,CAAA,EAG1CF,EAAG,OAAOA,EAAG,QAAQ,IAAIG,CAAG,EAAGH,EAAG,QAAQ,IAAIM,CAAG,CAAC,EAEnDL,EAAU,EACX,CAAC,EAEIA,GACLD,EAAG,QAAQ,eAAgB,EAAK,EACzBA,GAFc,IAGtB,CAAA,CACA,CAAA,CAEH,CACD,CAAC"}
|
|
@@ -13,10 +13,10 @@ import L from "@tiptap/extension-text-align";
|
|
|
13
13
|
import { TextStyle as P } from "@tiptap/extension-text-style";
|
|
14
14
|
import H from "@tiptap/extension-underline";
|
|
15
15
|
import m from "@tiptap/starter-kit";
|
|
16
|
-
import { isAllowedLinkUrl as
|
|
17
|
-
import { CharacterLimitExtension as
|
|
18
|
-
import { FontSizeExtension as
|
|
19
|
-
import { HtmlTagStripExtension as
|
|
16
|
+
import { isAllowedLinkUrl as g } from "../../helpers/sanitize.js";
|
|
17
|
+
import { CharacterLimitExtension as w } from "./characterLimit/CharacterLimitExtension.js";
|
|
18
|
+
import { FontSizeExtension as A } from "./FontSizeExtension.js";
|
|
19
|
+
import { HtmlTagStripExtension as D } from "./htmlTagStrip/HtmlTagStripExtension.js";
|
|
20
20
|
import { JsonHighlightExtension as B } from "./jsonHighlight/JsonHighlightExtension.js";
|
|
21
21
|
import { buildAgentMentionExtension as I, buildTeamMentionExtension as O } from "./mention/MentionExtension.js";
|
|
22
22
|
import { PasteExtension as R } from "./paste/PasteExtension.js";
|
|
@@ -101,7 +101,7 @@ function he(e) {
|
|
|
101
101
|
linkOnPaste: !1,
|
|
102
102
|
// Block javascript:/data:/vbscript: hrefs. TipTap keeps the href
|
|
103
103
|
// attribute verbatim, so scheme validation must live here.
|
|
104
|
-
isAllowedUri: (r) =>
|
|
104
|
+
isAllowedUri: (r) => g(r),
|
|
105
105
|
HTMLAttributes: {
|
|
106
106
|
rel: "noopener noreferrer",
|
|
107
107
|
class: "bik-link"
|
|
@@ -128,11 +128,13 @@ function he(e) {
|
|
|
128
128
|
extraShortcuts: e.shortcuts ?? []
|
|
129
129
|
}),
|
|
130
130
|
K,
|
|
131
|
-
// Strip
|
|
132
|
-
//
|
|
133
|
-
|
|
131
|
+
// Strip HTML tags from typed text.
|
|
132
|
+
// Non-email (WhatsApp, IG, private note): strip ALL tags.
|
|
133
|
+
// Email (richPaste): strip only dangerous tags (script, iframe, form, etc.)
|
|
134
|
+
// while preserving legitimate email tags (h1, table, div, etc.).
|
|
135
|
+
D.configure({ stripAll: !o }),
|
|
134
136
|
...e.maxCharacters ? [s.configure({ limit: e.maxCharacters })] : [],
|
|
135
|
-
...e.characterLimit ? [
|
|
137
|
+
...e.characterLimit ? [w.configure({ limit: e.characterLimit })] : [],
|
|
136
138
|
// Always register SectionDividerNode so the custom <div data-section-divider>
|
|
137
139
|
// node is part of the schema in every editor instance. This means imperative
|
|
138
140
|
// callers (setBodyAndSections / setSectionContent) work even when no
|
|
@@ -169,7 +171,7 @@ function he(e) {
|
|
|
169
171
|
i,
|
|
170
172
|
M.configure({ multicolor: !0 }),
|
|
171
173
|
S,
|
|
172
|
-
|
|
174
|
+
A,
|
|
173
175
|
L.configure({ types: ["heading", "paragraph"] }),
|
|
174
176
|
y,
|
|
175
177
|
T,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildExtensions.js","sources":["../../../../src/editor/extensions/buildExtensions.ts"],"sourcesContent":["import CharacterCount from '@tiptap/extension-character-count';\nimport Color from '@tiptap/extension-color';\nimport FontFamily from '@tiptap/extension-font-family';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Highlight from '@tiptap/extension-highlight';\nimport Image from '@tiptap/extension-image';\nimport Link from '@tiptap/extension-link';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Subscript from '@tiptap/extension-subscript';\nimport Superscript from '@tiptap/extension-superscript';\nimport TextAlign from '@tiptap/extension-text-align';\nimport { TextStyle } from '@tiptap/extension-text-style';\nimport Underline from '@tiptap/extension-underline';\nimport StarterKit from '@tiptap/starter-kit';\nimport type { ReactNode } from 'react';\nimport { isAllowedLinkUrl } from '../../helpers/sanitize';\nimport type {\n\tEditorFeatures,\n\tEditorSnapshot,\n\tKeyboardShortcut,\n\tMentionDropdownRenderProps,\n\tMentionItem,\n\tPasteData,\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../BikEditor.types';\nimport { CharacterLimitExtension } from './characterLimit/CharacterLimitExtension';\nimport { FontSizeExtension } from './FontSizeExtension';\nimport { HtmlTagStripExtension } from './htmlTagStrip/HtmlTagStripExtension';\nimport { JsonHighlightExtension } from './jsonHighlight/JsonHighlightExtension';\nimport {\n\tbuildAgentMentionExtension,\n\tbuildTeamMentionExtension,\n} from './mention/MentionExtension';\nimport { PasteExtension } from './paste/PasteExtension';\nimport { PasteNormalizationExtension } from './plainClipboard/PasteNormalizationExtension';\nimport { SectionDividerNode } from './sectionDivider/SectionDividerNode';\nimport { SendShortcutExtension } from './sendShortcut/SendShortcutExtension';\nimport { buildSlashCommandExtension } from './slashCommand/SlashCommandExtension';\nimport { VariableDecorationExtension } from './variable/VariableDecorationExtension';\n\ninterface ExtensionConfig {\n\tfeatures?: EditorFeatures;\n\tplaceholder?: string;\n\tmaxCharacters?: number;\n\t/**\n\t * Soft character limit. Unlike `maxCharacters` (which hard-blocks all input),\n\t * this blocks typing past the limit but ALLOWS paste to overflow, rendering\n\t * the excess characters greyed (`.bik-editor-overflow`). Purely visual +\n\t * typing-guard; the consumer shows the count/error and gates send itself.\n\t */\n\tcharacterLimit?: number;\n\thasSections?: boolean;\n\tmentions?: {\n\t\tagents?: { current: MentionItem[] };\n\t\tteams?: { current: MentionItem[] };\n\t};\n\tslashCommands?: { current: SlashCommandItem[] };\n\tonPaste?: (data: PasteData) => boolean | void;\n\tonSend?: (content: EditorSnapshot) => void;\n\tsendShortcut?:\n\t\t| { key: string; modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'> }\n\t\t| Array<{\n\t\t\t\tkey: string;\n\t\t\t\tmodifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;\n\t\t }>;\n\tshortcuts?: KeyboardShortcut[];\n\tonMentionSelected?: (item: MentionItem, char: '@' | '#') => void;\n\tonSlashCommandSelected?: (command: SlashCommandItem) => void;\n\trenderMentionItem?: (item: MentionItem, isActive: boolean) => ReactNode;\n\trenderMentionDropdown?: (props: MentionDropdownRenderProps) => ReactNode;\n\tremoveMentionTriggerOnDismiss?: boolean;\n\trenderSlashCommandItem?: (\n\t\titem: SlashCommandItem,\n\t\tisActive: boolean,\n\t) => ReactNode;\n\trenderSlashCommandDropdown?: (\n\t\tprops: SlashCommandDropdownRenderProps,\n\t) => ReactNode;\n}\n\nexport function buildExtensions(config: ExtensionConfig) {\n\t// JSON body mode is a dedicated code editor — it deliberately skips the rich\n\t// text stack (mentions, typography, rich paste, sections) and turns the whole\n\t// document into one syntax-highlighted JSON code block, Postman-style.\n\tif (config.features?.jsonMode) {\n\t\treturn [\n\t\t\tStarterKit.configure({\n\t\t\t\tlink: false,\n\t\t\t\tunderline: false,\n\t\t\t\t// Keep codeBlock (the JSON container) and history; drop everything\n\t\t\t\t// that has no meaning inside raw JSON.\n\t\t\t\tbold: false,\n\t\t\t\titalic: false,\n\t\t\t\tstrike: false,\n\t\t\t\tcode: false,\n\t\t\t\theading: false,\n\t\t\t\tbulletList: false,\n\t\t\t\torderedList: false,\n\t\t\t\tblockquote: false,\n\t\t\t\thorizontalRule: false,\n\t\t\t}),\n\t\t\tPlaceholder.configure({\n\t\t\t\tplaceholder: config.placeholder ?? '{\\n \\n}',\n\t\t\t}),\n\t\t\tJsonHighlightExtension,\n\t\t\tSendShortcutExtension.configure({\n\t\t\t\tonSend: config.onSend,\n\t\t\t\tsendShortcut: config.sendShortcut,\n\t\t\t\textraShortcuts: config.shortcuts ?? [],\n\t\t\t}),\n\t\t\t...(config.maxCharacters\n\t\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\n\t\t\t\t: []),\n\t\t];\n\t}\n\n\tconst hasRichPaste = config.features?.richPaste ?? false;\n\tconst hasRichTypography = config.features?.richTypography ?? false;\n\n\t// When allowedMarks is specified only those marks are registered in the schema.\n\t// This disables rendering, keyboard shortcuts AND paste-preservation for the\n\t// excluded marks — all three come for free when the extension is absent.\n\tconst allowedMarks = config.features?.allowedMarks;\n\tconst isMark = (m: 'bold' | 'italic' | 'strike' | 'underline' | 'code') =>\n\t\t!allowedMarks || allowedMarks.includes(m);\n\n\t// Soft line break. Shift-Enter inserts a <br> inside the current block\n\t// (matches Gmail); plain Enter still splits the block into a new paragraph\n\t// via StarterKit's default. HardBreak is registered standalone — like Link\n\t// and Underline above — instead of through StarterKit, so we can bind ONLY\n\t// Shift-Enter here and leave Mod-Enter free for the send shortcut.\n\tconst softBreak = HardBreak.extend({\n\t\taddKeyboardShortcuts() {\n\t\t\treturn {\n\t\t\t\t'Shift-Enter': () => this.editor.commands.setHardBreak(),\n\t\t\t};\n\t\t},\n\t});\n\n\t// Paragraph that preserves a zero block-margin from the source (Gmail-style).\n\t// Most sources (ChatGPT, typed text) use plain <p> → no margin attr → the\n\t// editor/viewer default 1em margin provides the gap. Google-Docs-style\n\t// content uses margin:0 paragraphs and a separate blank-line paragraph for\n\t// spacing; we keep that margin:0 so the blank line — not stacked margins —\n\t// provides a single-line gap, exactly like Gmail. The paste pipeline also\n\t// sets margin:'0' on every paragraph when a paste contains blank-line\n\t// paragraphs (see applyParagraphSpacing), so spacing comes from EITHER the\n\t// margin OR the blank line, never both (no double gap).\n\tconst isZeroLen = (v: string) =>\n\t\tv === '0' || v === '0px' || v === '0pt' || v === '0em';\n\tconst ParagraphWithMargin = Paragraph.extend({\n\t\taddAttributes() {\n\t\t\treturn {\n\t\t\t\t...(this.parent?.() ?? {}),\n\t\t\t\tmargin: {\n\t\t\t\t\tdefault: null,\n\t\t\t\t\tparseHTML: (el: HTMLElement) =>\n\t\t\t\t\t\tisZeroLen(el.style.marginTop) && isZeroLen(el.style.marginBottom)\n\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\trenderHTML: (attrs: { margin?: string | null }) =>\n\t\t\t\t\t\tattrs.margin === '0' ? { style: 'margin: 0px' } : {},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t});\n\n\tconst base = [\n\t\t// Exclude Link and Underline from StarterKit — TipTap v3 bundles both.\n\t\t// Without this, two copies of each are registered and the StarterKit copy's\n\t\t// click handler calls window.open even when openOnClick: false is set.\n\t\tStarterKit.configure({\n\t\t\tlink: false,\n\t\t\tunderline: false,\n\t\t\thardBreak: false,\n\t\t\tparagraph: false,\n\t\t\tbold: isMark('bold') ? {} : false,\n\t\t\titalic: isMark('italic') ? {} : false,\n\t\t\tstrike: isMark('strike') ? {} : false,\n\t\t\tcode: isMark('code') ? {} : false,\n\t\t}),\n\t\tParagraphWithMargin,\n\t\tsoftBreak,\n\t\t...(isMark('underline') ? [Underline] : []),\n\t\t// Extend Link to strip addPasteRules() and addInputRules() so pasting a\n\t\t// URL never creates a hyperlink regardless of autolink/linkOnPaste values.\n\t\tLink.extend({\n\t\t\taddPasteRules: () => [],\n\t\t\taddInputRules: () => [],\n\t\t}).configure({\n\t\t\topenOnClick: false,\n\t\t\tautolink: false,\n\t\t\tlinkOnPaste: false,\n\t\t\t// Block javascript:/data:/vbscript: hrefs. TipTap keeps the href\n\t\t\t// attribute verbatim, so scheme validation must live here.\n\t\t\tisAllowedUri: (url) => isAllowedLinkUrl(url),\n\t\t\tHTMLAttributes: {\n\t\t\t\trel: 'noopener noreferrer',\n\t\t\t\tclass: 'bik-link',\n\t\t\t},\n\t\t}),\n\t\tTextStyle,\n\t\tPlaceholder.configure({\n\t\t\tplaceholder: config.placeholder ?? 'Type a message...',\n\t\t}),\n\t\t// Consumer paste callback runs first. If it returns true the event is\n\t\t// consumed and neither PlainClipboardExtension nor the editor's default\n\t\t// paste handling will run for that event.\n\t\t...(config.onPaste\n\t\t\t? [PasteExtension.configure({ onPaste: config.onPaste })]\n\t\t\t: []),\n\t\tPasteNormalizationExtension.configure({\n\t\t\tpreserveMarks: hasRichPaste,\n\t\t\t// Only email + signature (richPaste) keep the rich HTML paste pipeline.\n\t\t\t// Every other channel (WhatsApp, IG, FB, comments) forces plain-text\n\t\t\t// paste for BOTH Cmd/Ctrl+V and Cmd/Ctrl+Shift+V — no formatting.\n\t\t\tplainOnly: !hasRichPaste,\n\t\t}),\n\t\tSendShortcutExtension.configure({\n\t\t\tonSend: config.onSend,\n\t\t\tsendShortcut: config.sendShortcut,\n\t\t\textraShortcuts: config.shortcuts ?? [],\n\t\t}),\n\t\tVariableDecorationExtension,\n\t\t// Strip complete HTML tags from typed text in non-email channels.\n\t\t// Email (richPaste) keeps tags because the editor legitimately renders HTML.\n\t\t...(!hasRichPaste ? [HtmlTagStripExtension] : []),\n\t\t...(config.maxCharacters\n\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\n\t\t\t: []),\n\t\t...(config.characterLimit\n\t\t\t? [CharacterLimitExtension.configure({ limit: config.characterLimit })]\n\t\t\t: []),\n\t\t// Always register SectionDividerNode so the custom <div data-section-divider>\n\t\t// node is part of the schema in every editor instance. This means imperative\n\t\t// callers (setBodyAndSections / setSectionContent) work even when no\n\t\t// `sections` prop was provided at mount time.\n\t\tSectionDividerNode,\n\t];\n\n\tconst mentionExtensions = [\n\t\t...(config.mentions?.agents\n\t\t\t? [\n\t\t\t\t\tbuildAgentMentionExtension(\n\t\t\t\t\t\tconfig.mentions.agents,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t\tconfig.removeMentionTriggerOnDismiss,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.mentions?.teams\n\t\t\t? [\n\t\t\t\t\tbuildTeamMentionExtension(\n\t\t\t\t\t\tconfig.mentions.teams,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t\tconfig.removeMentionTriggerOnDismiss,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.slashCommands\n\t\t\t? [\n\t\t\t\t\tbuildSlashCommandExtension(\n\t\t\t\t\t\tconfig.slashCommands,\n\t\t\t\t\t\tconfig.onSlashCommandSelected,\n\t\t\t\t\t\tconfig.renderSlashCommandItem,\n\t\t\t\t\t\tconfig.renderSlashCommandDropdown,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t];\n\n\tconst richExtensions = hasRichTypography\n\t\t? [\n\t\t\t\tColor,\n\t\t\t\tHighlight.configure({ multicolor: true }),\n\t\t\t\tFontFamily,\n\t\t\t\tFontSizeExtension,\n\t\t\t\tTextAlign.configure({ types: ['heading', 'paragraph'] }),\n\t\t\t\tSubscript,\n\t\t\t\tSuperscript,\n\t\t\t\tImage,\n\t\t ]\n\t\t: [Color];\n\n\treturn [...base, ...mentionExtensions, ...richExtensions];\n}\n"],"names":["buildExtensions","config","StarterKit","Placeholder","JsonHighlightExtension","SendShortcutExtension","CharacterCount","hasRichPaste","hasRichTypography","allowedMarks","isMark","m","softBreak","HardBreak","isZeroLen","v","ParagraphWithMargin","Paragraph","el","attrs","base","Underline","Link","url","isAllowedLinkUrl","TextStyle","PasteExtension","PasteNormalizationExtension","VariableDecorationExtension","HtmlTagStripExtension","CharacterLimitExtension","SectionDividerNode","mentionExtensions","buildAgentMentionExtension","buildTeamMentionExtension","buildSlashCommandExtension","richExtensions","Color","Highlight","FontFamily","FontSizeExtension","TextAlign","Subscript","Superscript","Image"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFO,SAASA,GAAgBC,GAAyB;AAIxD,MAAIA,EAAO,UAAU;AACpB,WAAO;AAAA,MACNC,EAAW,UAAU;AAAA,QACpB,MAAM;AAAA,QACN,WAAW;AAAA;AAAA;AAAA,QAGX,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,QAAQ;AAAA,QACR,MAAM;AAAA,QACN,SAAS;AAAA,QACT,YAAY;AAAA,QACZ,aAAa;AAAA,QACb,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAAA,CAChB;AAAA,MACDC,EAAY,UAAU;AAAA,QACrB,aAAaF,EAAO,eAAe;AAAA;AAAA;AAAA,MAAA,CACnC;AAAA,MACDG;AAAA,MACAC,EAAsB,UAAU;AAAA,QAC/B,QAAQJ,EAAO;AAAA,QACf,cAAcA,EAAO;AAAA,QACrB,gBAAgBA,EAAO,aAAa,CAAA;AAAA,MAAC,CACrC;AAAA,MACD,GAAIA,EAAO,gBACR,CAACK,EAAe,UAAU,EAAE,OAAOL,EAAO,cAAA,CAAe,CAAC,IAC1D,CAAA;AAA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AAA,IACH,GAAIA,EAAO,UAAU,QAClB;AAAA,MACAiC;AAAA,QACCjC,EAAO,SAAS;AAAA,QAChBA,EAAO;AAAA,QACPA,EAAO;AAAA,QACPA,EAAO;AAAA,QACPA,EAAO;AAAA,MAAA;AAAA,IACR,IAEA,CAAA;AAAA,IACH,GAAIA,EAAO,gBACR;AAAA,MACAkC;AAAA,QACClC,EAAO;AAAA,QACPA,EAAO;AAAA,QACPA,EAAO;AAAA,QACPA,EAAO;AAAA,MAAA;AAAA,IACR,IAEA,CAAA;AAAA,EAAC,GAGCmC,IAAiB5B,IACpB;AAAA,IACA6B;AAAA,IACAC,EAAU,UAAU,EAAE,YAAY,IAAM;AAAA,IACxCC;AAAA,IACAC;AAAA,IACAC,EAAU,UAAU,EAAE,OAAO,CAAC,WAAW,WAAW,GAAG;AAAA,IACvDC;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA,IAEA,CAACP,CAAK;AAET,SAAO,CAAC,GAAGjB,GAAM,GAAGY,GAAmB,GAAGI,CAAc;AACzD;"}
|
|
1
|
+
{"version":3,"file":"buildExtensions.js","sources":["../../../../src/editor/extensions/buildExtensions.ts"],"sourcesContent":["import CharacterCount from '@tiptap/extension-character-count';\nimport Color from '@tiptap/extension-color';\nimport FontFamily from '@tiptap/extension-font-family';\nimport HardBreak from '@tiptap/extension-hard-break';\nimport Highlight from '@tiptap/extension-highlight';\nimport Image from '@tiptap/extension-image';\nimport Link from '@tiptap/extension-link';\nimport Paragraph from '@tiptap/extension-paragraph';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Subscript from '@tiptap/extension-subscript';\nimport Superscript from '@tiptap/extension-superscript';\nimport TextAlign from '@tiptap/extension-text-align';\nimport { TextStyle } from '@tiptap/extension-text-style';\nimport Underline from '@tiptap/extension-underline';\nimport StarterKit from '@tiptap/starter-kit';\nimport type { ReactNode } from 'react';\nimport { isAllowedLinkUrl } from '../../helpers/sanitize';\nimport type {\n\tEditorFeatures,\n\tEditorSnapshot,\n\tKeyboardShortcut,\n\tMentionDropdownRenderProps,\n\tMentionItem,\n\tPasteData,\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../BikEditor.types';\nimport { CharacterLimitExtension } from './characterLimit/CharacterLimitExtension';\nimport { FontSizeExtension } from './FontSizeExtension';\nimport { HtmlTagStripExtension } from './htmlTagStrip/HtmlTagStripExtension';\nimport { JsonHighlightExtension } from './jsonHighlight/JsonHighlightExtension';\nimport {\n\tbuildAgentMentionExtension,\n\tbuildTeamMentionExtension,\n} from './mention/MentionExtension';\nimport { PasteExtension } from './paste/PasteExtension';\nimport { PasteNormalizationExtension } from './plainClipboard/PasteNormalizationExtension';\nimport { SectionDividerNode } from './sectionDivider/SectionDividerNode';\nimport { SendShortcutExtension } from './sendShortcut/SendShortcutExtension';\nimport { buildSlashCommandExtension } from './slashCommand/SlashCommandExtension';\nimport { VariableDecorationExtension } from './variable/VariableDecorationExtension';\n\ninterface ExtensionConfig {\n\tfeatures?: EditorFeatures;\n\tplaceholder?: string;\n\tmaxCharacters?: number;\n\t/**\n\t * Soft character limit. Unlike `maxCharacters` (which hard-blocks all input),\n\t * this blocks typing past the limit but ALLOWS paste to overflow, rendering\n\t * the excess characters greyed (`.bik-editor-overflow`). Purely visual +\n\t * typing-guard; the consumer shows the count/error and gates send itself.\n\t */\n\tcharacterLimit?: number;\n\thasSections?: boolean;\n\tmentions?: {\n\t\tagents?: { current: MentionItem[] };\n\t\tteams?: { current: MentionItem[] };\n\t};\n\tslashCommands?: { current: SlashCommandItem[] };\n\tonPaste?: (data: PasteData) => boolean | void;\n\tonSend?: (content: EditorSnapshot) => void;\n\tsendShortcut?:\n\t\t| { key: string; modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'> }\n\t\t| Array<{\n\t\t\t\tkey: string;\n\t\t\t\tmodifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;\n\t\t }>;\n\tshortcuts?: KeyboardShortcut[];\n\tonMentionSelected?: (item: MentionItem, char: '@' | '#') => void;\n\tonSlashCommandSelected?: (command: SlashCommandItem) => void;\n\trenderMentionItem?: (item: MentionItem, isActive: boolean) => ReactNode;\n\trenderMentionDropdown?: (props: MentionDropdownRenderProps) => ReactNode;\n\tremoveMentionTriggerOnDismiss?: boolean;\n\trenderSlashCommandItem?: (\n\t\titem: SlashCommandItem,\n\t\tisActive: boolean,\n\t) => ReactNode;\n\trenderSlashCommandDropdown?: (\n\t\tprops: SlashCommandDropdownRenderProps,\n\t) => ReactNode;\n}\n\nexport function buildExtensions(config: ExtensionConfig) {\n\t// JSON body mode is a dedicated code editor — it deliberately skips the rich\n\t// text stack (mentions, typography, rich paste, sections) and turns the whole\n\t// document into one syntax-highlighted JSON code block, Postman-style.\n\tif (config.features?.jsonMode) {\n\t\treturn [\n\t\t\tStarterKit.configure({\n\t\t\t\tlink: false,\n\t\t\t\tunderline: false,\n\t\t\t\t// Keep codeBlock (the JSON container) and history; drop everything\n\t\t\t\t// that has no meaning inside raw JSON.\n\t\t\t\tbold: false,\n\t\t\t\titalic: false,\n\t\t\t\tstrike: false,\n\t\t\t\tcode: false,\n\t\t\t\theading: false,\n\t\t\t\tbulletList: false,\n\t\t\t\torderedList: false,\n\t\t\t\tblockquote: false,\n\t\t\t\thorizontalRule: false,\n\t\t\t}),\n\t\t\tPlaceholder.configure({\n\t\t\t\tplaceholder: config.placeholder ?? '{\\n \\n}',\n\t\t\t}),\n\t\t\tJsonHighlightExtension,\n\t\t\tSendShortcutExtension.configure({\n\t\t\t\tonSend: config.onSend,\n\t\t\t\tsendShortcut: config.sendShortcut,\n\t\t\t\textraShortcuts: config.shortcuts ?? [],\n\t\t\t}),\n\t\t\t...(config.maxCharacters\n\t\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\n\t\t\t\t: []),\n\t\t];\n\t}\n\n\tconst hasRichPaste = config.features?.richPaste ?? false;\n\tconst hasRichTypography = config.features?.richTypography ?? false;\n\n\t// When allowedMarks is specified only those marks are registered in the schema.\n\t// This disables rendering, keyboard shortcuts AND paste-preservation for the\n\t// excluded marks — all three come for free when the extension is absent.\n\tconst allowedMarks = config.features?.allowedMarks;\n\tconst isMark = (m: 'bold' | 'italic' | 'strike' | 'underline' | 'code') =>\n\t\t!allowedMarks || allowedMarks.includes(m);\n\n\t// Soft line break. Shift-Enter inserts a <br> inside the current block\n\t// (matches Gmail); plain Enter still splits the block into a new paragraph\n\t// via StarterKit's default. HardBreak is registered standalone — like Link\n\t// and Underline above — instead of through StarterKit, so we can bind ONLY\n\t// Shift-Enter here and leave Mod-Enter free for the send shortcut.\n\tconst softBreak = HardBreak.extend({\n\t\taddKeyboardShortcuts() {\n\t\t\treturn {\n\t\t\t\t'Shift-Enter': () => this.editor.commands.setHardBreak(),\n\t\t\t};\n\t\t},\n\t});\n\n\t// Paragraph that preserves a zero block-margin from the source (Gmail-style).\n\t// Most sources (ChatGPT, typed text) use plain <p> → no margin attr → the\n\t// editor/viewer default 1em margin provides the gap. Google-Docs-style\n\t// content uses margin:0 paragraphs and a separate blank-line paragraph for\n\t// spacing; we keep that margin:0 so the blank line — not stacked margins —\n\t// provides a single-line gap, exactly like Gmail. The paste pipeline also\n\t// sets margin:'0' on every paragraph when a paste contains blank-line\n\t// paragraphs (see applyParagraphSpacing), so spacing comes from EITHER the\n\t// margin OR the blank line, never both (no double gap).\n\tconst isZeroLen = (v: string) =>\n\t\tv === '0' || v === '0px' || v === '0pt' || v === '0em';\n\tconst ParagraphWithMargin = Paragraph.extend({\n\t\taddAttributes() {\n\t\t\treturn {\n\t\t\t\t...(this.parent?.() ?? {}),\n\t\t\t\tmargin: {\n\t\t\t\t\tdefault: null,\n\t\t\t\t\tparseHTML: (el: HTMLElement) =>\n\t\t\t\t\t\tisZeroLen(el.style.marginTop) && isZeroLen(el.style.marginBottom)\n\t\t\t\t\t\t\t? '0'\n\t\t\t\t\t\t\t: null,\n\t\t\t\t\trenderHTML: (attrs: { margin?: string | null }) =>\n\t\t\t\t\t\tattrs.margin === '0' ? { style: 'margin: 0px' } : {},\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t});\n\n\tconst base = [\n\t\t// Exclude Link and Underline from StarterKit — TipTap v3 bundles both.\n\t\t// Without this, two copies of each are registered and the StarterKit copy's\n\t\t// click handler calls window.open even when openOnClick: false is set.\n\t\tStarterKit.configure({\n\t\t\tlink: false,\n\t\t\tunderline: false,\n\t\t\thardBreak: false,\n\t\t\tparagraph: false,\n\t\t\tbold: isMark('bold') ? {} : false,\n\t\t\titalic: isMark('italic') ? {} : false,\n\t\t\tstrike: isMark('strike') ? {} : false,\n\t\t\tcode: isMark('code') ? {} : false,\n\t\t}),\n\t\tParagraphWithMargin,\n\t\tsoftBreak,\n\t\t...(isMark('underline') ? [Underline] : []),\n\t\t// Extend Link to strip addPasteRules() and addInputRules() so pasting a\n\t\t// URL never creates a hyperlink regardless of autolink/linkOnPaste values.\n\t\tLink.extend({\n\t\t\taddPasteRules: () => [],\n\t\t\taddInputRules: () => [],\n\t\t}).configure({\n\t\t\topenOnClick: false,\n\t\t\tautolink: false,\n\t\t\tlinkOnPaste: false,\n\t\t\t// Block javascript:/data:/vbscript: hrefs. TipTap keeps the href\n\t\t\t// attribute verbatim, so scheme validation must live here.\n\t\t\tisAllowedUri: (url) => isAllowedLinkUrl(url),\n\t\t\tHTMLAttributes: {\n\t\t\t\trel: 'noopener noreferrer',\n\t\t\t\tclass: 'bik-link',\n\t\t\t},\n\t\t}),\n\t\tTextStyle,\n\t\tPlaceholder.configure({\n\t\t\tplaceholder: config.placeholder ?? 'Type a message...',\n\t\t}),\n\t\t// Consumer paste callback runs first. If it returns true the event is\n\t\t// consumed and neither PlainClipboardExtension nor the editor's default\n\t\t// paste handling will run for that event.\n\t\t...(config.onPaste\n\t\t\t? [PasteExtension.configure({ onPaste: config.onPaste })]\n\t\t\t: []),\n\t\tPasteNormalizationExtension.configure({\n\t\t\tpreserveMarks: hasRichPaste,\n\t\t\t// Only email + signature (richPaste) keep the rich HTML paste pipeline.\n\t\t\t// Every other channel (WhatsApp, IG, FB, comments) forces plain-text\n\t\t\t// paste for BOTH Cmd/Ctrl+V and Cmd/Ctrl+Shift+V — no formatting.\n\t\t\tplainOnly: !hasRichPaste,\n\t\t}),\n\t\tSendShortcutExtension.configure({\n\t\t\tonSend: config.onSend,\n\t\t\tsendShortcut: config.sendShortcut,\n\t\t\textraShortcuts: config.shortcuts ?? [],\n\t\t}),\n\t\tVariableDecorationExtension,\n\t\t// Strip HTML tags from typed text.\n\t\t// Non-email (WhatsApp, IG, private note): strip ALL tags.\n\t\t// Email (richPaste): strip only dangerous tags (script, iframe, form, etc.)\n\t\t// while preserving legitimate email tags (h1, table, div, etc.).\n\t\tHtmlTagStripExtension.configure({ stripAll: !hasRichPaste }),\n\t\t...(config.maxCharacters\n\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\n\t\t\t: []),\n\t\t...(config.characterLimit\n\t\t\t? [CharacterLimitExtension.configure({ limit: config.characterLimit })]\n\t\t\t: []),\n\t\t// Always register SectionDividerNode so the custom <div data-section-divider>\n\t\t// node is part of the schema in every editor instance. This means imperative\n\t\t// callers (setBodyAndSections / setSectionContent) work even when no\n\t\t// `sections` prop was provided at mount time.\n\t\tSectionDividerNode,\n\t];\n\n\tconst mentionExtensions = [\n\t\t...(config.mentions?.agents\n\t\t\t? [\n\t\t\t\t\tbuildAgentMentionExtension(\n\t\t\t\t\t\tconfig.mentions.agents,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t\tconfig.removeMentionTriggerOnDismiss,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.mentions?.teams\n\t\t\t? [\n\t\t\t\t\tbuildTeamMentionExtension(\n\t\t\t\t\t\tconfig.mentions.teams,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t\tconfig.removeMentionTriggerOnDismiss,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.slashCommands\n\t\t\t? [\n\t\t\t\t\tbuildSlashCommandExtension(\n\t\t\t\t\t\tconfig.slashCommands,\n\t\t\t\t\t\tconfig.onSlashCommandSelected,\n\t\t\t\t\t\tconfig.renderSlashCommandItem,\n\t\t\t\t\t\tconfig.renderSlashCommandDropdown,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t];\n\n\tconst richExtensions = hasRichTypography\n\t\t? [\n\t\t\t\tColor,\n\t\t\t\tHighlight.configure({ multicolor: true }),\n\t\t\t\tFontFamily,\n\t\t\t\tFontSizeExtension,\n\t\t\t\tTextAlign.configure({ types: ['heading', 'paragraph'] }),\n\t\t\t\tSubscript,\n\t\t\t\tSuperscript,\n\t\t\t\tImage,\n\t\t ]\n\t\t: [Color];\n\n\treturn [...base, ...mentionExtensions, ...richExtensions];\n}\n"],"names":["buildExtensions","config","StarterKit","Placeholder","JsonHighlightExtension","SendShortcutExtension","CharacterCount","hasRichPaste","hasRichTypography","allowedMarks","isMark","m","softBreak","HardBreak","isZeroLen","v","ParagraphWithMargin","Paragraph","el","attrs","base","Underline","Link","url","isAllowedLinkUrl","TextStyle","PasteExtension","PasteNormalizationExtension","VariableDecorationExtension","HtmlTagStripExtension","CharacterLimitExtension","SectionDividerNode","mentionExtensions","buildAgentMentionExtension","buildTeamMentionExtension","buildSlashCommandExtension","richExtensions","Color","Highlight","FontFamily","FontSizeExtension","TextAlign","Subscript","Superscript","Image"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkFO,SAASA,GAAgBC,GAAyB;AAIxD,MAAIA,EAAO,UAAU;AACpB,WAAO;AAAA,MACNC,EAAW,UAAU;AAAA,QACpB,MAAM;AAAA,QACN,WAAW;AAAA;AAAA;AAAA,QAGX,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,QAAQ;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real time.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Two modes controlled by `stripAll`:
|
|
6
|
+
* - `true` (non-email): strip ALL complete tags — `<h1>Hello</h1>` → `Hello`
|
|
7
|
+
* - `false` (email): strip only DANGEROUS tags — `<script>`, `<iframe>`,
|
|
8
|
+
* `<form>`, etc. — while preserving legitimate email tags like `<h1>`, `<table>`
|
|
8
9
|
*
|
|
9
10
|
* Incomplete tags like `<h` are preserved (the regex requires a closing `>`).
|
|
10
11
|
* Non-tag angle brackets like `2 < 3` are also preserved.
|
|
11
|
-
*
|
|
12
|
-
* Uses `appendTransaction` so the strip happens in the same undo step as
|
|
13
|
-
* the keystroke — Cmd+Z undoes both the tag and the strip together.
|
|
14
12
|
*/
|
|
15
13
|
export declare const HtmlTagStripExtension: Extension<any, any>;
|
|
@@ -1,32 +1,64 @@
|
|
|
1
|
-
import { Extension as
|
|
2
|
-
import { Plugin as
|
|
3
|
-
const
|
|
1
|
+
import { Extension as u } from "../../../node_modules/@tiptap/core/dist/index.js";
|
|
2
|
+
import { Plugin as d } from "@tiptap/pm/state";
|
|
3
|
+
const n = /<\/?[a-zA-Z][a-zA-Z0-9]*(?:\s[^>]*)?\/?>/g, f = /* @__PURE__ */ new Set([
|
|
4
|
+
"script",
|
|
5
|
+
"iframe",
|
|
6
|
+
"object",
|
|
7
|
+
"embed",
|
|
8
|
+
"applet",
|
|
9
|
+
"form",
|
|
10
|
+
"input",
|
|
11
|
+
"button",
|
|
12
|
+
"select",
|
|
13
|
+
"option",
|
|
14
|
+
"textarea",
|
|
15
|
+
"style",
|
|
16
|
+
"link",
|
|
17
|
+
"meta",
|
|
18
|
+
"base",
|
|
19
|
+
"svg",
|
|
20
|
+
"math",
|
|
21
|
+
"noscript",
|
|
22
|
+
"template"
|
|
23
|
+
]), g = /<\/?([a-zA-Z][a-zA-Z0-9]*)/;
|
|
24
|
+
function x(a) {
|
|
25
|
+
const r = a.match(g);
|
|
26
|
+
return r ? f.has(r[1].toLowerCase()) : !1;
|
|
27
|
+
}
|
|
28
|
+
const E = u.create({
|
|
4
29
|
name: "htmlTagStrip",
|
|
30
|
+
addOptions() {
|
|
31
|
+
return { stripAll: !0 };
|
|
32
|
+
},
|
|
5
33
|
addProseMirrorPlugins() {
|
|
34
|
+
const { stripAll: a } = this.options, r = a ? () => !0 : (s) => x(s);
|
|
6
35
|
return [
|
|
7
|
-
new
|
|
8
|
-
appendTransaction(
|
|
9
|
-
if (!
|
|
10
|
-
const { tr: e } =
|
|
11
|
-
let
|
|
12
|
-
return
|
|
13
|
-
if (!t.isText || !t.text || (
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
36
|
+
new d({
|
|
37
|
+
appendTransaction(s, A, i) {
|
|
38
|
+
if (!s.some((t) => t.docChanged)) return null;
|
|
39
|
+
const { tr: e } = i;
|
|
40
|
+
let l = !1;
|
|
41
|
+
return i.doc.descendants((t, o) => {
|
|
42
|
+
if (!t.isText || !t.text || (n.lastIndex = 0, !n.test(t.text))) return;
|
|
43
|
+
n.lastIndex = 0;
|
|
44
|
+
const p = t.text.replace(
|
|
45
|
+
n,
|
|
46
|
+
(c) => r(c) ? "" : c
|
|
47
|
+
);
|
|
48
|
+
if (p === t.text) return;
|
|
49
|
+
const m = o + t.nodeSize;
|
|
50
|
+
p ? e.replaceWith(
|
|
51
|
+
e.mapping.map(o),
|
|
52
|
+
e.mapping.map(m),
|
|
53
|
+
i.schema.text(p, t.marks)
|
|
54
|
+
) : e.delete(e.mapping.map(o), e.mapping.map(m)), l = !0;
|
|
55
|
+
}), l ? (e.setMeta("addToHistory", !1), e) : null;
|
|
24
56
|
}
|
|
25
57
|
})
|
|
26
58
|
];
|
|
27
59
|
}
|
|
28
60
|
});
|
|
29
61
|
export {
|
|
30
|
-
|
|
62
|
+
E as HtmlTagStripExtension
|
|
31
63
|
};
|
|
32
64
|
//# sourceMappingURL=HtmlTagStripExtension.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HtmlTagStripExtension.js","sources":["../../../../../src/editor/extensions/htmlTagStrip/HtmlTagStripExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { Plugin } from '@tiptap/pm/state';\n\nconst COMPLETE_TAG = /<\\/?[a-zA-Z][a-zA-Z0-9]*(?:\\s[^>]*)?\\/?>/g;\n\n/**\n * Strips
|
|
1
|
+
{"version":3,"file":"HtmlTagStripExtension.js","sources":["../../../../../src/editor/extensions/htmlTagStrip/HtmlTagStripExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { Plugin } from '@tiptap/pm/state';\n\nconst COMPLETE_TAG = /<\\/?[a-zA-Z][a-zA-Z0-9]*(?:\\s[^>]*)?\\/?>/g;\n\n// Tags that have no business in an email — stripped even in rich-paste mode.\nconst DANGEROUS_TAG_NAMES = new Set([\n\t'script',\n\t'iframe',\n\t'object',\n\t'embed',\n\t'applet',\n\t'form',\n\t'input',\n\t'button',\n\t'select',\n\t'option',\n\t'textarea',\n\t'style',\n\t'link',\n\t'meta',\n\t'base',\n\t'svg',\n\t'math',\n\t'noscript',\n\t'template',\n]);\n\nconst TAG_NAME_RE = /<\\/?([a-zA-Z][a-zA-Z0-9]*)/;\n\nfunction isDangerousTag(tag: string): boolean {\n\tconst m = tag.match(TAG_NAME_RE);\n\treturn m ? DANGEROUS_TAG_NAMES.has(m[1].toLowerCase()) : false;\n}\n\n/**\n * Strips HTML tags from typed text in real time.\n *\n * Two modes controlled by `stripAll`:\n * - `true` (non-email): strip ALL complete tags — `<h1>Hello</h1>` → `Hello`\n * - `false` (email): strip only DANGEROUS tags — `<script>`, `<iframe>`,\n * `<form>`, etc. — while preserving legitimate email tags like `<h1>`, `<table>`\n *\n * Incomplete tags like `<h` are preserved (the regex requires a closing `>`).\n * Non-tag angle brackets like `2 < 3` are also preserved.\n */\nexport const HtmlTagStripExtension = Extension.create({\n\tname: 'htmlTagStrip',\n\taddOptions() {\n\t\treturn { stripAll: true };\n\t},\n\taddProseMirrorPlugins() {\n\t\tconst { stripAll } = this.options;\n\t\tconst shouldStrip = stripAll\n\t\t\t? () => true\n\t\t\t: (tag: string) => isDangerousTag(tag);\n\n\t\treturn [\n\t\t\tnew Plugin({\n\t\t\t\tappendTransaction(transactions, _oldState, newState) {\n\t\t\t\t\tif (!transactions.some((t) => t.docChanged)) return null;\n\n\t\t\t\t\tconst { tr } = newState;\n\t\t\t\t\tlet changed = false;\n\n\t\t\t\t\tnewState.doc.descendants((node, pos) => {\n\t\t\t\t\t\tif (!node.isText || !node.text) return;\n\t\t\t\t\t\tCOMPLETE_TAG.lastIndex = 0;\n\t\t\t\t\t\tif (!COMPLETE_TAG.test(node.text)) return;\n\n\t\t\t\t\t\tCOMPLETE_TAG.lastIndex = 0;\n\t\t\t\t\t\tconst stripped = node.text.replace(COMPLETE_TAG, (match) =>\n\t\t\t\t\t\t\tshouldStrip(match) ? '' : match,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (stripped === node.text) return;\n\n\t\t\t\t\t\tconst end = pos + node.nodeSize;\n\t\t\t\t\t\tif (stripped) {\n\t\t\t\t\t\t\ttr.replaceWith(\n\t\t\t\t\t\t\t\ttr.mapping.map(pos),\n\t\t\t\t\t\t\t\ttr.mapping.map(end),\n\t\t\t\t\t\t\t\tnewState.schema.text(stripped, node.marks),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\ttr.delete(tr.mapping.map(pos), tr.mapping.map(end));\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchanged = true;\n\t\t\t\t\t});\n\n\t\t\t\t\tif (!changed) return null;\n\t\t\t\t\ttr.setMeta('addToHistory', false);\n\t\t\t\t\treturn tr;\n\t\t\t\t},\n\t\t\t}),\n\t\t];\n\t},\n});\n"],"names":["COMPLETE_TAG","DANGEROUS_TAG_NAMES","TAG_NAME_RE","isDangerousTag","tag","m","HtmlTagStripExtension","Extension","stripAll","shouldStrip","Plugin","transactions","_oldState","newState","tr","changed","node","pos","stripped","match","end"],"mappings":";;AAGA,MAAMA,IAAe,6CAGfC,wBAA0B,IAAI;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC,GAEKC,IAAc;AAEpB,SAASC,EAAeC,GAAsB;AAC7C,QAAMC,IAAID,EAAI,MAAMF,CAAW;AAC/B,SAAOG,IAAIJ,EAAoB,IAAII,EAAE,CAAC,EAAE,YAAA,CAAa,IAAI;AAC1D;AAaO,MAAMC,IAAwBC,EAAU,OAAO;AAAA,EACrD,MAAM;AAAA,EACN,aAAa;AACZ,WAAO,EAAE,UAAU,GAAA;AAAA,EACpB;AAAA,EACA,wBAAwB;AACvB,UAAM,EAAE,UAAAC,MAAa,KAAK,SACpBC,IAAcD,IACjB,MAAM,KACN,CAACJ,MAAgBD,EAAeC,CAAG;AAEtC,WAAO;AAAA,MACN,IAAIM,EAAO;AAAA,QACV,kBAAkBC,GAAcC,GAAWC,GAAU;AACpD,cAAI,CAACF,EAAa,KAAK,CAAC,MAAM,EAAE,UAAU,EAAG,QAAO;AAEpD,gBAAM,EAAE,IAAAG,MAAOD;AACf,cAAIE,IAAU;AA0Bd,iBAxBAF,EAAS,IAAI,YAAY,CAACG,GAAMC,MAAQ;AAGvC,gBAFI,CAACD,EAAK,UAAU,CAACA,EAAK,SAC1BhB,EAAa,YAAY,GACrB,CAACA,EAAa,KAAKgB,EAAK,IAAI,GAAG;AAEnC,YAAAhB,EAAa,YAAY;AACzB,kBAAMkB,IAAWF,EAAK,KAAK;AAAA,cAAQhB;AAAA,cAAc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