@bikdotai/bik-component-library 0.0.809-beta.17 → 0.0.809-beta.19

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.
Files changed (105) hide show
  1. package/dist/cjs/components/list-item/themes.js +1 -1
  2. package/dist/cjs/components/list-item/themes.js.map +1 -1
  3. package/dist/cjs/components/variable-picker-v3/Content.js +1 -1
  4. package/dist/cjs/components/variable-picker-v3/Content.js.map +1 -1
  5. package/dist/cjs/components/variable-picker-v3/SubHeaderItems.js +1 -1
  6. package/dist/cjs/components/variable-picker-v3/SubHeaderItems.js.map +1 -1
  7. package/dist/cjs/components/variable-picker-v3/context.js +1 -1
  8. package/dist/cjs/components/variable-picker-v3/context.js.map +1 -1
  9. package/dist/cjs/editor/BikEditor.js +1 -1
  10. package/dist/cjs/editor/BikEditor.js.map +1 -1
  11. package/dist/cjs/editor/BikEditor.styles.js +3 -13
  12. package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
  13. package/dist/cjs/editor/BikEditor.types.js.map +1 -1
  14. package/dist/cjs/editor/BikEditor.utils.js +1 -1
  15. package/dist/cjs/editor/BikEditor.utils.js.map +1 -1
  16. package/dist/cjs/editor/extensions/buildExtensions.js +1 -1
  17. package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
  18. package/dist/cjs/editor/extensions/plainClipboard/ClipboardNormalizationExtension.js +2 -0
  19. package/dist/cjs/editor/extensions/plainClipboard/ClipboardNormalizationExtension.js.map +1 -0
  20. package/dist/cjs/editor/extensions/plainClipboard/PlainClipboardExtension.js +2 -0
  21. package/dist/cjs/editor/extensions/plainClipboard/PlainClipboardExtension.js.map +1 -0
  22. package/dist/cjs/editor/extensions/plainClipboard/pasteUtils.js +1 -1
  23. package/dist/cjs/editor/extensions/plainClipboard/pasteUtils.js.map +1 -1
  24. package/dist/cjs/src/components/variable-picker-v3/context.d.ts +4 -0
  25. package/dist/cjs/src/editor/BikEditor.styles.d.ts +0 -1
  26. package/dist/cjs/src/editor/BikEditor.types.d.ts +0 -2
  27. package/dist/cjs/src/editor/BikEditor.utils.d.ts +4 -8
  28. package/dist/cjs/src/editor/extensions/plainClipboard/ClipboardNormalizationExtension.d.ts +7 -0
  29. package/dist/cjs/src/editor/extensions/plainClipboard/PlainClipboardExtension.d.ts +2 -0
  30. package/dist/cjs/src/editor/extensions/plainClipboard/pasteUtils.d.ts +8 -40
  31. package/dist/cjs/src/icons/Actions/Common actions/SendAirplane2.d.ts +7 -0
  32. package/dist/cjs/src/icons/BIK AI specific/AiAgent.d.ts +7 -0
  33. package/dist/cjs/src/icons/Informational/Communication/AtSymbol.d.ts +7 -0
  34. package/dist/cjs/src/icons/Informational/Communication/Hangup.d.ts +7 -0
  35. package/dist/cjs/src/icons/Informational/Communication/IncomingCall.d.ts +7 -0
  36. package/dist/cjs/src/icons/Informational/Communication/OutgoingCall.d.ts +7 -0
  37. package/dist/cjs/src/icons/Informational/Communication/PhoneCall.d.ts +7 -0
  38. package/dist/cjs/src/icons/Informational/Communication/Transcript.d.ts +7 -0
  39. package/dist/cjs/src/icons/Informational/Files and folders/BookOpen.d.ts +7 -0
  40. package/dist/cjs/src/icons/Informational/Identity/AiVoiceAgent.d.ts +7 -0
  41. package/dist/cjs/src/icons/Social/Channels/Subdued/FbCommentTicket.d.ts +6 -0
  42. package/dist/cjs/src/icons/Social/Channels/Subdued/FbTicket.d.ts +6 -0
  43. package/dist/cjs/src/icons/Social/Channels/Subdued/IgCommentTicket.d.ts +6 -0
  44. package/dist/cjs/src/icons/Social/Channels/Subdued/IgTicket.d.ts +6 -0
  45. package/dist/cjs/src/icons/Social/Channels/Subdued/MailTicket.d.ts +6 -0
  46. package/dist/cjs/src/icons/Social/Channels/Subdued/PhoneTicket.d.ts +6 -0
  47. package/dist/cjs/src/icons/Social/Channels/Subdued/TaskTicket.d.ts +6 -0
  48. package/dist/cjs/src/icons/Social/Channels/Subdued/WhatsappTicket.d.ts +6 -0
  49. package/dist/cjs/src/icons/Social/Channels/Subdued/index.d.ts +8 -0
  50. package/dist/esm/components/list-item/themes.js +1 -1
  51. package/dist/esm/components/list-item/themes.js.map +1 -1
  52. package/dist/esm/components/variable-picker-v3/Content.js +1 -1
  53. package/dist/esm/components/variable-picker-v3/Content.js.map +1 -1
  54. package/dist/esm/components/variable-picker-v3/SubHeaderItems.js +1 -1
  55. package/dist/esm/components/variable-picker-v3/SubHeaderItems.js.map +1 -1
  56. package/dist/esm/components/variable-picker-v3/context.js +1 -1
  57. package/dist/esm/components/variable-picker-v3/context.js.map +1 -1
  58. package/dist/esm/editor/BikEditor.js +1 -1
  59. package/dist/esm/editor/BikEditor.js.map +1 -1
  60. package/dist/esm/editor/BikEditor.styles.js +7 -17
  61. package/dist/esm/editor/BikEditor.styles.js.map +1 -1
  62. package/dist/esm/editor/BikEditor.types.js.map +1 -1
  63. package/dist/esm/editor/BikEditor.utils.js +1 -1
  64. package/dist/esm/editor/BikEditor.utils.js.map +1 -1
  65. package/dist/esm/editor/extensions/buildExtensions.js +1 -1
  66. package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
  67. package/dist/esm/editor/extensions/plainClipboard/ClipboardNormalizationExtension.js +2 -0
  68. package/dist/esm/editor/extensions/plainClipboard/ClipboardNormalizationExtension.js.map +1 -0
  69. package/dist/esm/editor/extensions/plainClipboard/PlainClipboardExtension.js +2 -0
  70. package/dist/esm/editor/extensions/plainClipboard/PlainClipboardExtension.js.map +1 -0
  71. package/dist/esm/editor/extensions/plainClipboard/pasteUtils.js +1 -1
  72. package/dist/esm/editor/extensions/plainClipboard/pasteUtils.js.map +1 -1
  73. package/dist/esm/src/components/variable-picker-v3/context.d.ts +4 -0
  74. package/dist/esm/src/editor/BikEditor.styles.d.ts +0 -1
  75. package/dist/esm/src/editor/BikEditor.types.d.ts +0 -2
  76. package/dist/esm/src/editor/BikEditor.utils.d.ts +4 -8
  77. package/dist/esm/src/editor/extensions/plainClipboard/ClipboardNormalizationExtension.d.ts +7 -0
  78. package/dist/esm/src/editor/extensions/plainClipboard/PlainClipboardExtension.d.ts +2 -0
  79. package/dist/esm/src/editor/extensions/plainClipboard/pasteUtils.d.ts +8 -40
  80. package/dist/esm/src/icons/Actions/Common actions/SendAirplane2.d.ts +7 -0
  81. package/dist/esm/src/icons/BIK AI specific/AiAgent.d.ts +7 -0
  82. package/dist/esm/src/icons/Informational/Communication/AtSymbol.d.ts +7 -0
  83. package/dist/esm/src/icons/Informational/Communication/Hangup.d.ts +7 -0
  84. package/dist/esm/src/icons/Informational/Communication/IncomingCall.d.ts +7 -0
  85. package/dist/esm/src/icons/Informational/Communication/OutgoingCall.d.ts +7 -0
  86. package/dist/esm/src/icons/Informational/Communication/PhoneCall.d.ts +7 -0
  87. package/dist/esm/src/icons/Informational/Communication/Transcript.d.ts +7 -0
  88. package/dist/esm/src/icons/Informational/Files and folders/BookOpen.d.ts +7 -0
  89. package/dist/esm/src/icons/Informational/Identity/AiVoiceAgent.d.ts +7 -0
  90. package/dist/esm/src/icons/Social/Channels/Subdued/FbCommentTicket.d.ts +6 -0
  91. package/dist/esm/src/icons/Social/Channels/Subdued/FbTicket.d.ts +6 -0
  92. package/dist/esm/src/icons/Social/Channels/Subdued/IgCommentTicket.d.ts +6 -0
  93. package/dist/esm/src/icons/Social/Channels/Subdued/IgTicket.d.ts +6 -0
  94. package/dist/esm/src/icons/Social/Channels/Subdued/MailTicket.d.ts +6 -0
  95. package/dist/esm/src/icons/Social/Channels/Subdued/PhoneTicket.d.ts +6 -0
  96. package/dist/esm/src/icons/Social/Channels/Subdued/TaskTicket.d.ts +6 -0
  97. package/dist/esm/src/icons/Social/Channels/Subdued/WhatsappTicket.d.ts +6 -0
  98. package/dist/esm/src/icons/Social/Channels/Subdued/index.d.ts +8 -0
  99. package/package.json +1 -1
  100. package/dist/cjs/editor/extensions/plainClipboard/PasteNormalizationExtension.js +0 -2
  101. package/dist/cjs/editor/extensions/plainClipboard/PasteNormalizationExtension.js.map +0 -1
  102. package/dist/cjs/src/editor/extensions/plainClipboard/PasteNormalizationExtension.d.ts +0 -13
  103. package/dist/esm/editor/extensions/plainClipboard/PasteNormalizationExtension.js +0 -2
  104. package/dist/esm/editor/extensions/plainClipboard/PasteNormalizationExtension.js.map +0 -1
  105. package/dist/esm/src/editor/extensions/plainClipboard/PasteNormalizationExtension.d.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"BikEditor.styles.js","sources":["../../../src/editor/BikEditor.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { COLORS } from '../constants/Theme';\n\nexport const BikEditorShell = styled.div<{\n\tminHeight?: string;\n\tmaxHeight?: string;\n\tparagraphGap?: string;\n}>`\n\tposition: relative;\n\twidth: 100%;\n\n\t.ProseMirror {\n\t\tmin-height: ${({ minHeight }) => minHeight ?? '80px'};\n\t\tmax-height: ${({ maxHeight }) => maxHeight ?? 'none'};\n\t\toverflow-y: auto;\n\t\toutline: none;\n\t\tpadding: 8px 12px;\n\t\tfont-size: 14px;\n\t\tline-height: 1.5;\n\t\tword-break: break-word;\n\n\t\tp {\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\n\t\t/* Enter = new paragraph → visible gap. Shift+Enter = <br> inside\n\t\t the same paragraph → no gap. Matches Google Docs / Word behavior. */\n\t\tp + p {\n\t\t\tmargin-top: ${({ paragraphGap }) => paragraphGap ?? '4px'};\n\t\t}\n\n\t\t/* Blank lines (empty paragraphs) get their height from line-height\n\t\t alone — no extra margins. Prevents double-spacing when paragraphGap\n\t\t is large (e.g. 1em for email). */\n\t\tp.is-blank {\n\t\t\tmargin-top: 0;\n\t\t}\n\t\tp.is-blank + p {\n\t\t\tmargin-top: 0;\n\t\t}\n\n\t\tul,\n\t\tol {\n\t\t\tmargin: 0;\n\t\t\tpadding-left: 1.5em;\n\t\t}\n\n\t\tli + li {\n\t\t\tmargin-top: 2px;\n\t\t}\n\n\t\tp.is-editor-empty:first-child::before {\n\t\t\tcontent: attr(data-placeholder);\n\t\t\tfloat: left;\n\t\t\tcolor: #adb5bd;\n\t\t\tpointer-events: none;\n\t\t\theight: 0;\n\t\t}\n\t}\n\n\t.bik-mention {\n\t\tcolor: ${COLORS.content.brand};\n\t\tpadding: 1px 4px;\n\t}\n\t.bik-mention--team {\n\t\tcolor: ${COLORS.content.brand};\n\t}\n\t.bik-variable {\n\t}\n\n\ta,\n\t.bik-link {\n\t\tcolor: #4f46e5;\n\t\ttext-decoration: underline;\n\t\ttext-decoration-color: #a5b4fc;\n\t\ttext-underline-offset: 2px;\n\t\tcursor: pointer;\n\t\t&:hover {\n\t\t\tcolor: #3730a3;\n\t\t\ttext-decoration-color: #6366f1;\n\t\t}\n\t}\n`;\n"],"names":["BikEditorShell","styled","div","_ref","minHeight","_ref2","maxHeight","_ref3","paragraphGap","COLORS","content","brand"],"mappings":"gFAGaA,MAAAA,EAAiBC,EAAOC,GAInC;;;;;gBAKcC,IAAA,IAACC,UAAEA,GAAWD,EAAA,OAAKC,QAAAA,EAAa,MAAM;gBACtCC,IAAA,IAACC,UAAEA,GAAWD,EAAA,OAAKC,QAAAA,EAAa,MAAM;;;;;;;;;;;;;;;;iBAgBrCC,IAAA,IAACC,aAAEA,GAAcD,EAAA,OAAKC,QAAAA,EAAgB,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAiCjDC,EAAOC,QAAQC;;;;WAIfF,EAAOC,QAAQC;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"BikEditor.styles.js","sources":["../../../src/editor/BikEditor.styles.ts"],"sourcesContent":["import styled from 'styled-components';\nimport { COLORS } from '../constants/Theme';\n\nexport const BikEditorShell = styled.div<{\n\tminHeight?: string;\n\tmaxHeight?: string;\n}>`\n\tposition: relative;\n\twidth: 100%;\n\n\t.ProseMirror {\n\t\tmin-height: ${({ minHeight }) => minHeight ?? '80px'};\n\t\tmax-height: ${({ maxHeight }) => maxHeight ?? 'none'};\n\t\toverflow-y: auto;\n\t\toutline: none;\n\t\tpadding: 8px 12px;\n\t\tfont-size: 14px;\n\t\tline-height: 1.5;\n\t\tword-break: break-word;\n\n\t\tp {\n\t\t\tmargin: 0;\n\t\t\tpadding: 0;\n\t\t}\n\n\t\t/* Enter = new paragraph → visible gap. Shift+Enter = <br> inside\n\t\t the same paragraph → no gap. Matches Google Docs / Word behavior. */\n\t\tp + p {\n\t\t\tmargin-top: 4px;\n\t\t}\n\n\t\tul,\n\t\tol {\n\t\t\tmargin: 0;\n\t\t\tpadding-left: 1.5em;\n\t\t}\n\n\t\tli + li {\n\t\t\tmargin-top: 2px;\n\t\t}\n\n\t\tp.is-editor-empty:first-child::before {\n\t\t\tcontent: attr(data-placeholder);\n\t\t\tfloat: left;\n\t\t\tcolor: #adb5bd;\n\t\t\tpointer-events: none;\n\t\t\theight: 0;\n\t\t}\n\t}\n\n\t.bik-mention {\n\t\tcolor: ${COLORS.content.brand};\n\t\tpadding: 1px 4px;\n\t}\n\t.bik-mention--team {\n\t\tcolor: ${COLORS.content.brand};\n\t}\n\t.bik-variable {\n\t}\n\n\ta,\n\t.bik-link {\n\t\tcolor: #4f46e5;\n\t\ttext-decoration: underline;\n\t\ttext-decoration-color: #a5b4fc;\n\t\ttext-underline-offset: 2px;\n\t\tcursor: pointer;\n\t\t&:hover {\n\t\t\tcolor: #3730a3;\n\t\t\ttext-decoration-color: #6366f1;\n\t\t}\n\t}\n`;\n"],"names":["BikEditorShell","styled","div","_ref","minHeight","_ref2","maxHeight","COLORS","content","brand"],"mappings":"gFAGaA,MAAAA,EAAiBC,EAAOC,GAGnC;;;;;gBAKcC,IAAA,IAACC,UAAEA,GAAWD,EAAA,OAAKC,QAAAA,EAAa,MAAM;gBACtCC,IAAA,IAACC,UAAEA,GAAWD,EAAA,OAAKC,QAAAA,EAAa,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAuC3CC,EAAOC,QAAQC;;;;WAIfF,EAAOC,QAAQC;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"BikEditor.types.js","sources":["../../../src/editor/BikEditor.types.ts"],"sourcesContent":["/**\n * ┌─────────────────────────────────────────────────────────────────────────┐\n * │ PUBLIC API LAYER — zero editor-framework imports │\n * │ │\n * │ This file is the consumer contract for BikEditor. It has NO dependency │\n * │ on TipTap, Lexical, Slate, or any other rich-text library. │\n * │ │\n * │ If the underlying editor is ever swapped, ONLY the implementation files │\n * │ change — this file, src/editor/index.ts, and all consumer code stay as- │\n * │ is. The files that would change are: │\n * │ • BikEditor.tsx — wires props into the editor instance │\n * │ • BikEditor.utils.ts — HTML / document-state adapters │\n * │ • extensions/ — extension / plugin layer │\n * └─────────────────────────────────────────────────────────────────────────┘\n */\nimport React from 'react';\n\n/**\n * Opt in to specific editor capabilities. Both default to `false`.\n *\n * @example\n * // Email editor with full rich text support\n * <BikEditor features={{ richPaste: true, richTypography: true }} />\n */\nexport interface EditorFeatures {\n\t/** Preserve HTML formatting on paste. Default: `false`. */\n\trichPaste?: boolean;\n\t/** Enable font family, font size, text alignment, highlight, subscript, superscript, and image. Default: `false`. */\n\trichTypography?: boolean;\n\t/**\n\t * Restrict which inline marks are active in the editor.\n\t * When set, only the listed marks are registered — all others are disabled\n\t * (no rendering, no keyboard shortcuts, no paste preservation).\n\t * Omit to allow all marks (default).\n\t *\n\t * @example\n\t * // LiveChat: bold only, no italic / underline / strike\n\t * features={{ allowedMarks: ['bold'] }}\n\t */\n\tallowedMarks?: Array<'bold' | 'italic' | 'strike' | 'underline' | 'code'>;\n}\n\n/**\n * A named content section placed below the main body, separated by an invisible divider.\n *\n * Sections let you split a single editor instance into independently readable\n * and writable zones — for example: body / signature / forwarded mail.\n *\n * @example\n * sections={[\n * { id: 'signature', content: '<p>Best regards,<br/>Alice</p>' },\n * { id: 'forwarded', content: '<p>--- Forwarded message ---</p>' },\n * ]}\n */\nexport interface EditorSection {\n\t/**\n\t * Unique identifier. Used in ref methods: `getSectionContent(id)`,\n\t * `setSectionContent(id, html)`, `focusSection(id)`, `clearSection(id)`.\n\t * The string `'body'` is reserved for the main content above all dividers.\n\t */\n\tid: string;\n\t/** Initial HTML content of this section. */\n\tcontent: string;\n}\n\n/**\n * Data passed to the `onPaste` callback.\n * Return `true` from your handler to suppress BikEditor's default paste handling\n * (rich-paste and plain-text stripping won't run for that event).\n */\nexport interface PasteData {\n\t/** All files in the clipboard (images, PDFs, etc.). */\n\tfiles: File[];\n\t/** Image files only — a filtered subset of `files`. */\n\timages: File[];\n\t/** Plain text from the clipboard. */\n\ttext: string;\n\t/** HTML from the clipboard (empty string if the source doesn't provide HTML). */\n\thtml: string;\n\t/** The raw browser ClipboardEvent — for advanced use. */\n\tevent: ClipboardEvent;\n}\n\n/**\n * A custom keyboard shortcut registered with the editor.\n *\n * @example\n * shortcuts={[\n * // Mod = Cmd on Mac, Ctrl on Windows/Linux\n * { key: 'Enter', modifiers: ['mod'], handler: handleSend },\n * { key: 's', modifiers: ['mod'], handler: handleSave },\n * { key: 'k', modifiers: ['mod', 'shift'], handler: openLinkModal },\n * ]}\n */\nexport interface KeyboardShortcut {\n\t/** Key name. Use the same strings as KeyboardEvent.key, e.g. `'Enter'`, `'s'`, `'k'`. */\n\tkey: string;\n\t/**\n\t * Modifier keys.\n\t * `'mod'` maps to Cmd on macOS and Ctrl on Windows/Linux — prefer it over\n\t * `'ctrl'` for cross-platform shortcuts.\n\t */\n\tmodifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;\n\t/** Called when the shortcut fires. Returning nothing is fine. */\n\thandler: () => void;\n}\n\n/** Content object returned by onChange, onSend, getContent(), and getSectionContent(). */\nexport interface EditorSnapshot {\n\t/** Serialised HTML. Safe to pass back to setContent() or setSectionContent(). */\n\thtml: string;\n\t/** Plain text, stripped of all marks and block nodes. */\n\ttext: string;\n\t/** True when the document contains no user-visible content. */\n\tisEmpty: boolean;\n\t/** Character count at this point in time. */\n\tcharacterCount: number;\n}\n\n/** One item shown in the @agent or #team mention dropdown. */\nexport interface MentionItem {\n\t/** Unique identifier stored as a node attribute. Used to look up the item later. */\n\tid: string | number;\n\t/** Display name shown in the dropdown and inserted into the document. */\n\tlabel: string;\n\t/** Avatar image URL. Shown in the built-in row when renderMentionItem is not provided. */\n\tavatarUrl?: string;\n\t/** When true, a green presence dot appears in the built-in row. */\n\tisOnline?: boolean;\n\t/** Any extra data your app needs. Passed back as-is in onMentionSelected. */\n\tmeta?: Record<string, unknown>;\n}\n\n/** One item shown in the / slash-command dropdown. */\nexport interface SlashCommandItem {\n\t/** Unique identifier. */\n\tid: string;\n\t/** Short command name shown as the primary label in the menu. */\n\tlabel: string;\n\t/** Optional one-line description shown below the label in the built-in row. */\n\tdescription?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Feature config objects — pass one object per feature instead of N flat props\n// ---------------------------------------------------------------------------\n\n/**\n * Props passed to the `renderDropdown` function in `MentionConfig`.\n * `activeIndex` is the keyboard-navigated row — highlight it in your UI.\n * Call `onSelect(item)` when the user picks one.\n */\nexport interface MentionDropdownRenderProps {\n\titems: MentionItem[];\n\t/** The text the user typed after the `@` or `#` trigger. */\n\tquery: string;\n\t/**\n\t * Index of the currently highlighted row (arrow-key navigation).\n\t * The editor manages this automatically — just use it for visual highlighting.\n\t */\n\tactiveIndex: number;\n\t/** Call this when the user selects an item (click, touch, etc.). */\n\tonSelect: (item: MentionItem) => void;\n}\n\n/**\n * Everything related to @ and # mention dropdowns, in one place.\n *\n * @example\n * mentions={{\n * agents: [{ id: 1, label: 'Alice', avatarUrl: '...' }],\n * teams: [{ id: 't1', label: 'Support' }],\n * onSelect: (item, char) => console.log(char, item),\n * }}\n */\nexport interface MentionConfig {\n\t/** Items shown when the user types `@`. */\n\tagents?: MentionItem[];\n\t/** Items shown when the user types `#`. */\n\tteams?: MentionItem[];\n\t/** Called when the user picks an item. `char` is `'@'` or `'#'`. */\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void;\n\t/**\n\t * Custom renderer for each row in the dropdown.\n\t * `isActive` is `true` when that row is currently highlighted by keyboard\n\t * navigation (arrows move it, Enter selects it). Use it to apply a highlight\n\t * style so the user can see which item they're about to select.\n\t * Omit to use the built-in avatar + name row.\n\t *\n\t * Use `renderDropdown` instead when you need a completely different structure.\n\t *\n\t * @example\n\t * renderItem={(item, isActive) => (\n\t * <div style={{ background: isActive ? '#f0f0f0' : undefined }}>\n\t * {item.label}\n\t * </div>\n\t * )}\n\t */\n\trenderItem?: (item: MentionItem, isActive: boolean) => React.ReactNode;\n\t/**\n\t * Render the entire dropdown yourself instead of individual rows.\n\t * The editor still manages keyboard navigation — `activeIndex` tells you\n\t * which row is highlighted, and `onSelect(item)` confirms the selection.\n\t * Takes priority over `renderItem` when both are provided.\n\t *\n\t * @example\n\t * renderDropdown={({ items, query, activeIndex, onSelect }) => (\n\t * <MyDropdown\n\t * items={items}\n\t * highlightedIndex={activeIndex}\n\t * onPick={onSelect}\n\t * />\n\t * )}\n\t */\n\trenderDropdown?: (props: MentionDropdownRenderProps) => React.ReactNode;\n}\n\n/**\n * Props passed to the `renderDropdown` function in `SlashCommandConfig`.\n */\nexport interface SlashCommandDropdownRenderProps {\n\titems: SlashCommandItem[];\n\t/** The text the user typed after `/`. */\n\tquery: string;\n\t/** Index of the currently highlighted row. Use for visual highlighting. */\n\tactiveIndex: number;\n\t/** Call this when the user selects an item. */\n\tonSelect: (item: SlashCommandItem) => void;\n}\n\n/**\n * Everything related to the `/` slash-command menu, in one place.\n *\n * @example\n * slashCommands={{\n * items: [{ id: 'ai-reply', label: 'AI Reply', description: 'Generate a reply' }],\n * onSelect: (cmd) => triggerAI(cmd.id),\n * }}\n */\nexport interface SlashCommandConfig {\n\t/** The list of commands. Filtered client-side as the user types after `/`. */\n\titems: SlashCommandItem[];\n\t/** Called when the user selects a command. The `/` trigger is removed from the doc. */\n\tonSelect?: (command: SlashCommandItem) => void;\n\t/**\n\t * Custom renderer for each row.\n\t * `isActive` is `true` when that row is highlighted by keyboard navigation.\n\t * Omit to use the built-in label + description row.\n\t *\n\t * Use `renderDropdown` instead when you need a completely different structure.\n\t */\n\trenderItem?: (item: SlashCommandItem, isActive: boolean) => React.ReactNode;\n\t/**\n\t * Render the entire slash-command dropdown yourself.\n\t * The editor manages keyboard navigation — use `activeIndex` to highlight\n\t * the active row and call `onSelect(item)` to confirm selection.\n\t * Takes priority over `renderItem` when both are provided.\n\t *\n\t * @example\n\t * renderDropdown={({ items, activeIndex, onSelect }) => (\n\t * <MyCmdPalette commands={items} active={activeIndex} onPick={onSelect} />\n\t * )}\n\t */\n\trenderDropdown?: (props: SlashCommandDropdownRenderProps) => React.ReactNode;\n}\n\n/**\n * Configuration for how hyperlinks behave in the editor.\n *\n * @example\n * link={{ renderTooltip: ({ href, text, onOpen, onRemove }) => (\n * <MyLinkPopover href={href} onOpen={onOpen} onRemove={onRemove} />\n * )}}\n */\nexport interface LinkConfig {\n\t/**\n\t * Custom tooltip rendered when the user clicks a link.\n\t * Receives the href, display text, bounding rect (for positioning),\n\t * and ready-to-call action handlers.\n\t * Omit to use the minimal built-in tooltip.\n\t */\n\trenderTooltip?: (props: LinkTooltipProps) => React.ReactNode;\n}\n\n/**\n * Snapshot of all active marks and block types at the current cursor or selection.\n * Returned by onSelectionChange and ref.getActiveFormats().\n *\n * Keep this in component state and pass it to BikEditorToolbar (or your own toolbar)\n * to keep button active-states in sync.\n *\n * @example\n * const [formats, setFormats] = useState(DEFAULT_ACTIVE_FORMATS);\n * <BikEditor onSelectionChange={setFormats} ... />\n * <BikEditorToolbar activeFormats={formats} ... />\n */\nexport interface FormatState {\n\tbold: boolean;\n\titalic: boolean;\n\tunderline: boolean;\n\tstrike: boolean;\n\tbulletList: boolean;\n\torderedList: boolean;\n\tblockquote: boolean;\n\tcodeBlock: boolean;\n\t/** Non-null when the cursor is inside (or selection spans) a hyperlink. */\n\tlink: { href: string } | null;\n\ttextAlign: 'left' | 'center' | 'right' | 'justify' | null;\n\tfontFamily: string | null;\n\tfontSize: string | null;\n\t/** Active text colour as a CSS colour string, or null if none. */\n\tcolor: string | null;\n\t/** Active highlight (background) colour, or null if none. */\n\thighlight: string | null;\n\t/** True when the cursor/selection is in a superscript. */\n\tsuperscript: boolean;\n\t/** True when the cursor/selection is in a subscript. */\n\tsubscript: boolean;\n}\n\nexport const DEFAULT_FORMAT_STATE: FormatState = {\n\tbold: false,\n\titalic: false,\n\tunderline: false,\n\tstrike: false,\n\tbulletList: false,\n\torderedList: false,\n\tblockquote: false,\n\tcodeBlock: false,\n\tlink: null,\n\ttextAlign: null,\n\tfontFamily: null,\n\tfontSize: null,\n\tcolor: null,\n\thighlight: null,\n\tsuperscript: false,\n\tsubscript: false,\n};\n\n/**\n * All formatting and insertion commands. Access via `editorRef.current.actions`.\n *\n * Every method focuses the editor internally — no need to call `.focus()` first.\n *\n * @example\n * editorRef.current?.actions.toggleBold();\n * editorRef.current?.actions.setLink('https://example.com', 'Visit example');\n */\nexport interface EditorActions {\n\t// ── Basic marks ───────────────────────────────────────────────────────────\n\ttoggleBold: () => void;\n\ttoggleItalic: () => void;\n\ttoggleUnderline: () => void;\n\ttoggleStrike: () => void;\n\n\t// ── Blocks ────────────────────────────────────────────────────────────────\n\ttoggleBulletList: () => void;\n\ttoggleOrderedList: () => void;\n\ttoggleBlockquote: () => void;\n\ttoggleCodeBlock: () => void;\n\n\t// ── Alignment & typography ────────────────────────────────────────────────\n\tsetTextAlign: (align: 'left' | 'center' | 'right' | 'justify') => void;\n\t/** Pass a CSS font-family value, e.g. `'Inter, sans-serif'`. Only works when richTypography is on. */\n\tsetFontFamily: (font: string) => void;\n\t/** Pass a CSS size value, e.g. `'16px'` or `'1.25rem'`. Only works when richTypography is on. */\n\tsetFontSize: (size: string) => void;\n\n\t// ── Colour ────────────────────────────────────────────────────────────────\n\t/** Sets the text colour. Pass any CSS colour value, e.g. `'#e53e3e'`. */\n\tsetColor: (color: string) => void;\n\t/** Sets the highlight (background) colour. */\n\tsetHighlight: (color: string) => void;\n\t/** Removes the text colour mark from the current selection. */\n\tunsetColor: () => void;\n\t/** Removes the highlight mark from the current selection. */\n\tunsetHighlight: () => void;\n\n\t// ── Links ─────────────────────────────────────────────────────────────────\n\t/**\n\t * Applies a hyperlink to the current selection, or updates the link the\n\t * cursor is already inside.\n\t *\n\t * @param href The URL.\n\t * @param text Optional display text. When provided, the visible text of the\n\t * linked range is replaced atomically in the same undo step.\n\t *\n\t * @example\n\t * actions.setLink('https://example.com');\n\t * actions.setLink('https://example.com', 'Visit example');\n\t */\n\tsetLink: (href: string, text?: string) => void;\n\t/** Updates only the href of the link at the current cursor. */\n\tupdateLink: (href: string) => void;\n\t/** Removes the link mark but keeps the visible text. */\n\tremoveLink: () => void;\n\n\t// ── Insertions ────────────────────────────────────────────────────────────\n\t/** Inserts an emoji character at the cursor. */\n\tinsertEmoji: (emoji: string) => void;\n\t/**\n\t * Inserts a `{{variableName}}` token at the cursor.\n\t * The token renders with a distinct highlight inside the editor.\n\t */\n\tinsertVariable: (variableName: string) => void;\n\t/** Inserts arbitrary HTML at the current cursor position. */\n\tinsertHtml: (html: string) => void;\n\n\t// ── History ───────────────────────────────────────────────────────────────\n\tundo: () => void;\n\tredo: () => void;\n\tcanUndo: () => boolean;\n\tcanRedo: () => boolean;\n\n\t// ── Rich typography (richTypography feature required) ─────────────────────\n\t/** Toggles superscript on the selection. Only works when richTypography is on. */\n\ttoggleSuperscript: () => void;\n\t/** Toggles subscript on the selection. Only works when richTypography is on. */\n\ttoggleSubscript: () => void;\n\t/** Inserts an inline image at the cursor. Only works when richTypography is on. */\n\tinsertImage: (src: string) => void;\n}\n\n/** Props passed to your renderLinkTooltip render prop. */\nexport interface LinkTooltipProps {\n\t/** The href of the active link. */\n\thref: string;\n\t/** The display text of the link. */\n\ttext: string;\n\t/** Bounding rect of the link element — use this to position your popover. */\n\trect: DOMRect;\n\t/** Opens the link in a new tab. */\n\tonOpen: () => void;\n\t/** Removes the link mark but keeps the visible text. */\n\tonRemove: () => void;\n\t/** Hides the bubble menu. Call this before opening an edit modal so the tooltip doesn't linger. */\n\tonHide: () => void;\n}\n\n/**\n * Imperative handle exposed by BikEditor.\n *\n * Obtain via `useRef<BikEditorRef>()` and pass to `<BikEditor ref={...} />`.\n * All methods are safe to call after the first render.\n *\n * @example\n * const ref = useRef<BikEditorRef>(null);\n * <BikEditor ref={ref} ... />\n * ref.current?.clearContent();\n * ref.current?.actions.toggleBold();\n */\nexport interface BikEditorRef {\n\t// ── Focus ─────────────────────────────────────────────────────────────────\n\t/** Moves focus into the editor. Optionally pass a position: 'start', 'end', 'all', or a numeric offset. */\n\tfocus: (position?: 'start' | 'end' | 'all' | number | boolean | null) => void;\n\t/** Removes focus from the editor. */\n\tblur: () => void;\n\n\t// ── Content ───────────────────────────────────────────────────────────────\n\t/** Clears the entire document and fires onChange. */\n\tclearContent: () => void;\n\t/**\n\t * Replaces the full document with the given HTML and fires onChange.\n\t * Overwrites all sections. Use setSectionContent() / setBodyContent() to\n\t * update a single section without touching the others.\n\t */\n\tsetContent: (html: string) => void;\n\t/** Inserts HTML at the current cursor position without replacing anything. */\n\tinsertContent: (html: string) => void;\n\t/**\n\t * Inserts HTML inline at the current cursor position, unwrapping block\n\t * wrappers (e.g. `<p>`) so the content merges into the surrounding paragraph\n\t * instead of creating new blocks. Use for macros, quick replies, etc.\n\t */\n\tinsertInlineContent: (html: string) => void;\n\t/** Inserts HTML at the very start of the document. */\n\tinsertAtStart: (html: string) => void;\n\t/** Inserts HTML as a new block at the end of the document. */\n\tinsertBlock: (html: string) => void;\n\t/**\n\t * Appends HTML inline inside the last paragraph of the document.\n\t * Ideal for streaming — call repeatedly with each text chunk.\n\t * Use `appendBodyContent` instead if the editor has named sections.\n\t */\n\tappendInline: (html: string) => void;\n\t/** @deprecated Use `insertBlock` */\n\tinsertAtEnd: (html: string) => void;\n\t/** @deprecated Use `appendInline` */\n\tappendContent: (html: string) => void;\n\t/** Returns the full document as `{ html, text, isEmpty, characterCount }`. */\n\tgetContent: () => EditorSnapshot;\n\t/**\n\t * Returns the raw TipTap document as a plain JSON object.\n\t * Returns `null` when the editor is not yet mounted.\n\t */\n\tgetJSON: () => Record<string, unknown> | null;\n\t/**\n\t * Walks the document and returns all mention IDs currently in the editor,\n\t * split by type. IDs are deduplicated and returned as arrays.\n\t *\n\t * @example\n\t * const { agentIds, teamIds } = ref.current?.getMentions() ?? { agentIds: [], teamIds: [] };\n\t */\n\tgetMentions: () => { agentIds: string[]; teamIds: string[] };\n\n\t// ── Selection ─────────────────────────────────────────────────────────────\n\t/**\n\t * Returns the current cursor / selection position as a `{ from, to }` pair.\n\t * When nothing is selected, `from === to` (a collapsed cursor).\n\t * Pass the returned value to `insertAtPosition()` to insert at an exact spot.\n\t *\n\t * @example\n\t * const { from } = ref.current?.getCursorPosition() ?? { from: 0, to: 0 };\n\t * ref.current?.insertAtPosition(from, '<strong>inserted</strong>');\n\t */\n\tgetCursorPosition: () => { from: number; to: number };\n\t/**\n\t * Inserts HTML at an explicit document position rather than at the current cursor.\n\t * Use `getCursorPosition()` to get the position, or any value from\n\t * `findSectionStartPos` / `findSectionEndPos` if you need section-relative insertion.\n\t *\n\t * @example\n\t * const { from } = ref.current!.getCursorPosition();\n\t * ref.current?.insertAtPosition(from, '<em>hello</em>');\n\t */\n\tinsertAtPosition: (pos: number, html: string) => void;\n\t/**\n\t * Returns the currently selected plain text.\n\t * When the cursor is inside a link with nothing selected, returns the full\n\t * link text — useful for pre-filling a link modal's text field.\n\t */\n\tgetSelectedText: () => string;\n\n\t// ── Character count ───────────────────────────────────────────────────────\n\t/**\n\t * Returns the current character count and the configured limit (or null).\n\t * Use this to render your own character counter anywhere you like.\n\t *\n\t * @example\n\t * const { count, limit } = ref.current?.getCharacterCount() ?? { count: 0, limit: null };\n\t * <span style={{ color: count >= (limit ?? Infinity) ? 'red' : 'inherit' }}>\n\t * {count}{limit != null ? ` / ${limit}` : ''}\n\t * </span>\n\t */\n\tgetCharacterCount: () => { count: number; limit: number | null };\n\n\t// ── Sections ─────────────────────────────────────────────────────────────\n\t/**\n\t * Returns content for a named section.\n\t * Use `'body'` to get the main content above all section dividers.\n\t *\n\t * @example\n\t * const sig = ref.current?.getSectionContent('signature');\n\t */\n\tgetSectionContent: (sectionId: string) => EditorSnapshot;\n\t/**\n\t * Replaces the content of a named section without touching other sections.\n\t * If the section doesn't exist yet it is appended at the end.\n\t *\n\t * @example\n\t * ref.current?.setSectionContent('signature', '<p>New signature</p>');\n\t * ref.current?.setSectionContent('body', rephrased); // same as setBodyContent\n\t */\n\tsetSectionContent: (sectionId: string, html: string) => void;\n\t/**\n\t * Moves the cursor to the start of a named section.\n\t * Use `'body'` to focus the main content area.\n\t */\n\tfocusSection: (sectionId: string) => void;\n\t/** Clears all content in a named section (replaces with an empty paragraph). */\n\tclearSection: (sectionId: string) => void;\n\n\t// ── Convenience body shorthands ───────────────────────────────────────────\n\t/** Shorthand for `getSectionContent('body')`. */\n\tgetBodyContent: () => EditorSnapshot;\n\t/** Shorthand for `setSectionContent('body', html)`. */\n\tsetBodyContent: (html: string) => void;\n\t/**\n\t * Atomically sets the body AND all sections in a single editor update.\n\t * Sections are laid out in the exact order supplied — use this instead of\n\t * multiple `setSectionContent()` calls whenever order matters (e.g. forward\n\t * mail where signature must appear before the forwarded thread).\n\t *\n\t * @example\n\t * ref.current?.setBodyAndSections('<p></p>', [\n\t * { id: 'signature', content: '<p>Alice</p>' },\n\t * { id: 'forwarded', content: '<p>--- Forwarded ---</p>' },\n\t * ]);\n\t */\n\tsetBodyAndSections: (\n\t\tbody: string,\n\t\tsections: Array<{ id: string; content: string }>,\n\t) => void;\n\t/**\n\t * Appends HTML to the end of the body section without moving the cursor.\n\t * Ideal for streaming AI-generated content — call repeatedly with each chunk.\n\t * Does NOT clear existing content; call `setBodyContent('')` first if needed.\n\t *\n\t * @example\n\t * // Stream AI response chunk-by-chunk\n\t * ref.current?.setBodyContent('');\n\t * for await (const chunk of aiStream) {\n\t * ref.current?.appendBodyContent(chunk);\n\t * }\n\t */\n\tappendBodyContent: (html: string) => void;\n\n\t/**\n\t * Inserts HTML at the start of a named section (or `'body'`).\n\t * Inserts at the very start of the document when `sectionId` is `'body'`.\n\t */\n\tinsertAtSectionStart: (sectionId: string, html: string) => void;\n\t/**\n\t * Inserts HTML at the end of a named section (or `'body'`).\n\t * For `'body'`, inserts just before the first section divider (or at end of doc).\n\t */\n\tinsertAtSectionEnd: (sectionId: string, html: string) => void;\n\n\t// ── Formats & actions ─────────────────────────────────────────────────────\n\t/** Returns a snapshot of all active marks at the current cursor or selection. */\n\tgetActiveFormats: () => FormatState;\n\t/** All formatting and insertion commands. See EditorActions. */\n\tactions: EditorActions;\n}\n\n/**\n * Props for `<BikEditor />`. All props are optional.\n */\nexport interface BikEditorProps {\n\t// ── Features ──────────────────────────────────────────────────────────────\n\t/**\n\t * Opt in to specific editor capabilities. Both default to `false`.\n\t *\n\t * @example\n\t * <BikEditor features={{ richPaste: true, richTypography: true }} />\n\t */\n\tfeatures?: EditorFeatures;\n\n\t// ── Content ───────────────────────────────────────────────────────────────\n\t/**\n\t * HTML loaded on mount. Ignored after first render.\n\t * Use `ref.setContent()` to change content imperatively later.\n\t */\n\tinitialContent?: string;\n\t/**\n\t * Named sections placed below the main body.\n\t * Each section is separated from the previous one by an invisible divider node.\n\t * The array order determines the visual order in the document.\n\t *\n\t * These are only the INITIAL values — use `ref.setSectionContent()` to update\n\t * a section after mount without re-mounting the editor.\n\t *\n\t * @example\n\t * sections={[\n\t * { id: 'signature', content: '<p>Best regards, Alice</p>' },\n\t * { id: 'forwarded', content: '<p>--- Forwarded message ---</p>' },\n\t * ]}\n\t */\n\tsections?: EditorSection[];\n\t/** Placeholder text shown when the editor is empty. */\n\tplaceholder?: string;\n\n\t// ── Behaviour ─────────────────────────────────────────────────────────────\n\t/** Makes the editor read-only. The toolbar still renders but actions are no-ops. */\n\tdisabled?: boolean;\n\t/**\n\t * Hard character limit. The editor refuses to accept input beyond this point.\n\t * The limit is enforced silently — no UI is rendered. Use\n\t * `ref.getCharacterCount()` or `onChange.characterCount` to display it yourself.\n\t */\n\tmaxCharacters?: number;\n\n\t// ── Keyboard shortcuts ────────────────────────────────────────────────────\n\t/**\n\t * Custom keyboard shortcuts. BikEditor registers no shortcuts of its own —\n\t * every shortcut must be explicitly listed here.\n\t *\n\t * @example\n\t * shortcuts={[\n\t * { key: 'Enter', modifiers: ['mod'], handler: handleSend },\n\t * { key: 's', modifiers: ['mod', 'shift'], handler: handleDraft },\n\t * ]}\n\t */\n\tshortcuts?: KeyboardShortcut[];\n\t/**\n\t * Shortcut key that fires `onSend`. No key is bound to `onSend` unless you\n\t * set this explicitly. Requires `onSend` to also be provided.\n\t *\n\t * `'mod'` maps to Cmd on macOS and Ctrl on Windows/Linux.\n\t *\n\t * @example\n\t * // Single shortcut\n\t * sendShortcut={{ key: 'Enter', modifiers: ['mod'] }}\n\t * // Multiple shortcuts\n\t * sendShortcut={[\n\t * { key: 'Enter', modifiers: ['mod'] },\n\t * { key: 's', modifiers: ['mod'] },\n\t * ]}\n\t */\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\n\t// ── Mentions ─────────────────────────────────────────────────────────────\n\t/**\n\t * Enables `@` (agent) and `#` (team) mention dropdowns.\n\t * Bundle all mention-related config in one object so it's easy to find.\n\t *\n\t * @example\n\t * mentions={{\n\t * agents: myAgents,\n\t * teams: myTeams,\n\t * onSelect: (item, char) => track(char, item.id),\n\t * }}\n\t */\n\tmentions?: MentionConfig;\n\n\t// ── Slash commands ────────────────────────────────────────────────────────\n\t/**\n\t * Enables the `/` slash-command menu.\n\t * Bundle all slash-command config in one object.\n\t *\n\t * @example\n\t * slashCommands={{\n\t * items: MY_COMMANDS,\n\t * onSelect: (cmd) => handleCommand(cmd.id),\n\t * }}\n\t */\n\tslashCommands?: SlashCommandConfig;\n\n\t// ── Link ─────────────────────────────────────────────────────────────────\n\t/**\n\t * Link-related configuration — currently just the click tooltip.\n\t *\n\t * @example\n\t * link={{ renderTooltip: ({ href, onOpen, onRemove }) => (\n\t * <MyTooltip href={href} onOpen={onOpen} onRemove={onRemove} />\n\t * )}}\n\t */\n\tlink?: LinkConfig;\n\n\t// ── Callbacks ─────────────────────────────────────────────────────────────\n\t/**\n\t * Called once, immediately after the editor finishes initializing.\n\t * Any imperative ref methods called before this fires are queued internally\n\t * and executed automatically once the editor is ready — consumers do not\n\t * need timers or readiness guards.\n\t *\n\t * @example\n\t * <BikEditor\n\t * ref={editorRef}\n\t * onReady={() => editorRef.current?.setContent(savedDraft)}\n\t * />\n\t */\n\tonReady?: () => void;\n\t/** Called on every document change. */\n\tonChange?: (content: EditorSnapshot) => void;\n\t/**\n\t * Called when the user presses the key combo defined by `sendShortcut`.\n\t * Only fires when both `onSend` and `sendShortcut` are provided.\n\t */\n\tonSend?: (content: EditorSnapshot) => void;\n\t/** Called when the editor gains focus. */\n\tonFocus?: () => void;\n\t/** Called when the editor loses focus. */\n\tonBlur?: () => void;\n\t/**\n\t * Called on every paste event. Return `true` to fully suppress BikEditor's\n\t * own paste handling (useful when you want to handle images or HTML yourself).\n\t *\n\t * @example\n\t * onPaste={({ images }) => {\n\t * if (images.length) {\n\t * uploadImages(images).then(urls => {\n\t * urls.forEach(url => ref.current?.actions.insertHtml(`<img src=\"${url}\" />`));\n\t * });\n\t * return true; // suppress default — don't embed the raw image data\n\t * }\n\t * }}\n\t */\n\tonPaste?: (data: PasteData) => boolean | void;\n\t/**\n\t * Called on every cursor move or selection change with a snapshot of all\n\t * active marks. Keep in state and pass to your toolbar to sync button states.\n\t */\n\tonSelectionChange?: (activeFormats: FormatState) => void;\n\n\t// ── Styling ───────────────────────────────────────────────────────────────\n\t// Outer wrapper — use these to control the shell (border, border-radius,\n\t// background, shadow, etc.).\n\t/** Extra class name applied to the outer wrapper div. */\n\tclassName?: string;\n\t/** Inline styles applied to the outer wrapper div. */\n\tstyle?: React.CSSProperties;\n\n\t// Inner editable area — use these to control the content div itself\n\t// (padding, font, line-height, etc.).\n\t/** Extra class name applied to the content-editable area (`.ProseMirror` in TipTap). */\n\teditorClassName?: string;\n\t/** Inline styles applied to the content-editable area. */\n\teditorStyle?: React.CSSProperties;\n\n\t// Sizing — applied to the content-editable area.\n\t/** Minimum height of the editable area. CSS value, e.g. `'80px'`. */\n\tminHeight?: string;\n\t/** Maximum height. The editor scrolls internally when exceeded. CSS value, e.g. `'400px'`. */\n\tmaxHeight?: string;\n\t/** Gap between consecutive paragraphs. CSS value, defaults to `'4px'`. */\n\tparagraphGap?: string;\n}\n"],"names":["DEFAULT_FORMAT_STATE","bold","italic","underline","strike","bulletList","orderedList","blockquote","codeBlock","link","textAlign","fontFamily","fontSize","color","highlight","superscript","subscript"],"mappings":"AAgUO,MAAMA,EAAoC,CAChDC,MAAM,EACNC,QAAQ,EACRC,WAAW,EACXC,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,KAAM,KACNC,UAAW,KACXC,WAAY,KACZC,SAAU,KACVC,MAAO,KACPC,UAAW,KACXC,aAAa,EACbC,WAAW"}
1
+ {"version":3,"file":"BikEditor.types.js","sources":["../../../src/editor/BikEditor.types.ts"],"sourcesContent":["/**\n * ┌─────────────────────────────────────────────────────────────────────────┐\n * │ PUBLIC API LAYER — zero editor-framework imports │\n * │ │\n * │ This file is the consumer contract for BikEditor. It has NO dependency │\n * │ on TipTap, Lexical, Slate, or any other rich-text library. │\n * │ │\n * │ If the underlying editor is ever swapped, ONLY the implementation files │\n * │ change — this file, src/editor/index.ts, and all consumer code stay as- │\n * │ is. The files that would change are: │\n * │ • BikEditor.tsx — wires props into the editor instance │\n * │ • BikEditor.utils.ts — HTML / document-state adapters │\n * │ • extensions/ — extension / plugin layer │\n * └─────────────────────────────────────────────────────────────────────────┘\n */\nimport React from 'react';\n\n/**\n * Opt in to specific editor capabilities. Both default to `false`.\n *\n * @example\n * // Email editor with full rich text support\n * <BikEditor features={{ richPaste: true, richTypography: true }} />\n */\nexport interface EditorFeatures {\n\t/** Preserve HTML formatting on paste. Default: `false`. */\n\trichPaste?: boolean;\n\t/** Enable font family, font size, text alignment, highlight, subscript, superscript, and image. Default: `false`. */\n\trichTypography?: boolean;\n\t/**\n\t * Restrict which inline marks are active in the editor.\n\t * When set, only the listed marks are registered — all others are disabled\n\t * (no rendering, no keyboard shortcuts, no paste preservation).\n\t * Omit to allow all marks (default).\n\t *\n\t * @example\n\t * // LiveChat: bold only, no italic / underline / strike\n\t * features={{ allowedMarks: ['bold'] }}\n\t */\n\tallowedMarks?: Array<'bold' | 'italic' | 'strike' | 'underline' | 'code'>;\n}\n\n/**\n * A named content section placed below the main body, separated by an invisible divider.\n *\n * Sections let you split a single editor instance into independently readable\n * and writable zones — for example: body / signature / forwarded mail.\n *\n * @example\n * sections={[\n * { id: 'signature', content: '<p>Best regards,<br/>Alice</p>' },\n * { id: 'forwarded', content: '<p>--- Forwarded message ---</p>' },\n * ]}\n */\nexport interface EditorSection {\n\t/**\n\t * Unique identifier. Used in ref methods: `getSectionContent(id)`,\n\t * `setSectionContent(id, html)`, `focusSection(id)`, `clearSection(id)`.\n\t * The string `'body'` is reserved for the main content above all dividers.\n\t */\n\tid: string;\n\t/** Initial HTML content of this section. */\n\tcontent: string;\n}\n\n/**\n * Data passed to the `onPaste` callback.\n * Return `true` from your handler to suppress BikEditor's default paste handling\n * (rich-paste and plain-text stripping won't run for that event).\n */\nexport interface PasteData {\n\t/** All files in the clipboard (images, PDFs, etc.). */\n\tfiles: File[];\n\t/** Image files only — a filtered subset of `files`. */\n\timages: File[];\n\t/** Plain text from the clipboard. */\n\ttext: string;\n\t/** HTML from the clipboard (empty string if the source doesn't provide HTML). */\n\thtml: string;\n\t/** The raw browser ClipboardEvent — for advanced use. */\n\tevent: ClipboardEvent;\n}\n\n/**\n * A custom keyboard shortcut registered with the editor.\n *\n * @example\n * shortcuts={[\n * // Mod = Cmd on Mac, Ctrl on Windows/Linux\n * { key: 'Enter', modifiers: ['mod'], handler: handleSend },\n * { key: 's', modifiers: ['mod'], handler: handleSave },\n * { key: 'k', modifiers: ['mod', 'shift'], handler: openLinkModal },\n * ]}\n */\nexport interface KeyboardShortcut {\n\t/** Key name. Use the same strings as KeyboardEvent.key, e.g. `'Enter'`, `'s'`, `'k'`. */\n\tkey: string;\n\t/**\n\t * Modifier keys.\n\t * `'mod'` maps to Cmd on macOS and Ctrl on Windows/Linux — prefer it over\n\t * `'ctrl'` for cross-platform shortcuts.\n\t */\n\tmodifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;\n\t/** Called when the shortcut fires. Returning nothing is fine. */\n\thandler: () => void;\n}\n\n/** Content object returned by onChange, onSend, getContent(), and getSectionContent(). */\nexport interface EditorSnapshot {\n\t/** Serialised HTML. Safe to pass back to setContent() or setSectionContent(). */\n\thtml: string;\n\t/** Plain text, stripped of all marks and block nodes. */\n\ttext: string;\n\t/** True when the document contains no user-visible content. */\n\tisEmpty: boolean;\n\t/** Character count at this point in time. */\n\tcharacterCount: number;\n}\n\n/** One item shown in the @agent or #team mention dropdown. */\nexport interface MentionItem {\n\t/** Unique identifier stored as a node attribute. Used to look up the item later. */\n\tid: string | number;\n\t/** Display name shown in the dropdown and inserted into the document. */\n\tlabel: string;\n\t/** Avatar image URL. Shown in the built-in row when renderMentionItem is not provided. */\n\tavatarUrl?: string;\n\t/** When true, a green presence dot appears in the built-in row. */\n\tisOnline?: boolean;\n\t/** Any extra data your app needs. Passed back as-is in onMentionSelected. */\n\tmeta?: Record<string, unknown>;\n}\n\n/** One item shown in the / slash-command dropdown. */\nexport interface SlashCommandItem {\n\t/** Unique identifier. */\n\tid: string;\n\t/** Short command name shown as the primary label in the menu. */\n\tlabel: string;\n\t/** Optional one-line description shown below the label in the built-in row. */\n\tdescription?: string;\n}\n\n// ---------------------------------------------------------------------------\n// Feature config objects — pass one object per feature instead of N flat props\n// ---------------------------------------------------------------------------\n\n/**\n * Props passed to the `renderDropdown` function in `MentionConfig`.\n * `activeIndex` is the keyboard-navigated row — highlight it in your UI.\n * Call `onSelect(item)` when the user picks one.\n */\nexport interface MentionDropdownRenderProps {\n\titems: MentionItem[];\n\t/** The text the user typed after the `@` or `#` trigger. */\n\tquery: string;\n\t/**\n\t * Index of the currently highlighted row (arrow-key navigation).\n\t * The editor manages this automatically — just use it for visual highlighting.\n\t */\n\tactiveIndex: number;\n\t/** Call this when the user selects an item (click, touch, etc.). */\n\tonSelect: (item: MentionItem) => void;\n}\n\n/**\n * Everything related to @ and # mention dropdowns, in one place.\n *\n * @example\n * mentions={{\n * agents: [{ id: 1, label: 'Alice', avatarUrl: '...' }],\n * teams: [{ id: 't1', label: 'Support' }],\n * onSelect: (item, char) => console.log(char, item),\n * }}\n */\nexport interface MentionConfig {\n\t/** Items shown when the user types `@`. */\n\tagents?: MentionItem[];\n\t/** Items shown when the user types `#`. */\n\tteams?: MentionItem[];\n\t/** Called when the user picks an item. `char` is `'@'` or `'#'`. */\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void;\n\t/**\n\t * Custom renderer for each row in the dropdown.\n\t * `isActive` is `true` when that row is currently highlighted by keyboard\n\t * navigation (arrows move it, Enter selects it). Use it to apply a highlight\n\t * style so the user can see which item they're about to select.\n\t * Omit to use the built-in avatar + name row.\n\t *\n\t * Use `renderDropdown` instead when you need a completely different structure.\n\t *\n\t * @example\n\t * renderItem={(item, isActive) => (\n\t * <div style={{ background: isActive ? '#f0f0f0' : undefined }}>\n\t * {item.label}\n\t * </div>\n\t * )}\n\t */\n\trenderItem?: (item: MentionItem, isActive: boolean) => React.ReactNode;\n\t/**\n\t * Render the entire dropdown yourself instead of individual rows.\n\t * The editor still manages keyboard navigation — `activeIndex` tells you\n\t * which row is highlighted, and `onSelect(item)` confirms the selection.\n\t * Takes priority over `renderItem` when both are provided.\n\t *\n\t * @example\n\t * renderDropdown={({ items, query, activeIndex, onSelect }) => (\n\t * <MyDropdown\n\t * items={items}\n\t * highlightedIndex={activeIndex}\n\t * onPick={onSelect}\n\t * />\n\t * )}\n\t */\n\trenderDropdown?: (props: MentionDropdownRenderProps) => React.ReactNode;\n}\n\n/**\n * Props passed to the `renderDropdown` function in `SlashCommandConfig`.\n */\nexport interface SlashCommandDropdownRenderProps {\n\titems: SlashCommandItem[];\n\t/** The text the user typed after `/`. */\n\tquery: string;\n\t/** Index of the currently highlighted row. Use for visual highlighting. */\n\tactiveIndex: number;\n\t/** Call this when the user selects an item. */\n\tonSelect: (item: SlashCommandItem) => void;\n}\n\n/**\n * Everything related to the `/` slash-command menu, in one place.\n *\n * @example\n * slashCommands={{\n * items: [{ id: 'ai-reply', label: 'AI Reply', description: 'Generate a reply' }],\n * onSelect: (cmd) => triggerAI(cmd.id),\n * }}\n */\nexport interface SlashCommandConfig {\n\t/** The list of commands. Filtered client-side as the user types after `/`. */\n\titems: SlashCommandItem[];\n\t/** Called when the user selects a command. The `/` trigger is removed from the doc. */\n\tonSelect?: (command: SlashCommandItem) => void;\n\t/**\n\t * Custom renderer for each row.\n\t * `isActive` is `true` when that row is highlighted by keyboard navigation.\n\t * Omit to use the built-in label + description row.\n\t *\n\t * Use `renderDropdown` instead when you need a completely different structure.\n\t */\n\trenderItem?: (item: SlashCommandItem, isActive: boolean) => React.ReactNode;\n\t/**\n\t * Render the entire slash-command dropdown yourself.\n\t * The editor manages keyboard navigation — use `activeIndex` to highlight\n\t * the active row and call `onSelect(item)` to confirm selection.\n\t * Takes priority over `renderItem` when both are provided.\n\t *\n\t * @example\n\t * renderDropdown={({ items, activeIndex, onSelect }) => (\n\t * <MyCmdPalette commands={items} active={activeIndex} onPick={onSelect} />\n\t * )}\n\t */\n\trenderDropdown?: (props: SlashCommandDropdownRenderProps) => React.ReactNode;\n}\n\n/**\n * Configuration for how hyperlinks behave in the editor.\n *\n * @example\n * link={{ renderTooltip: ({ href, text, onOpen, onRemove }) => (\n * <MyLinkPopover href={href} onOpen={onOpen} onRemove={onRemove} />\n * )}}\n */\nexport interface LinkConfig {\n\t/**\n\t * Custom tooltip rendered when the user clicks a link.\n\t * Receives the href, display text, bounding rect (for positioning),\n\t * and ready-to-call action handlers.\n\t * Omit to use the minimal built-in tooltip.\n\t */\n\trenderTooltip?: (props: LinkTooltipProps) => React.ReactNode;\n}\n\n/**\n * Snapshot of all active marks and block types at the current cursor or selection.\n * Returned by onSelectionChange and ref.getActiveFormats().\n *\n * Keep this in component state and pass it to BikEditorToolbar (or your own toolbar)\n * to keep button active-states in sync.\n *\n * @example\n * const [formats, setFormats] = useState(DEFAULT_ACTIVE_FORMATS);\n * <BikEditor onSelectionChange={setFormats} ... />\n * <BikEditorToolbar activeFormats={formats} ... />\n */\nexport interface FormatState {\n\tbold: boolean;\n\titalic: boolean;\n\tunderline: boolean;\n\tstrike: boolean;\n\tbulletList: boolean;\n\torderedList: boolean;\n\tblockquote: boolean;\n\tcodeBlock: boolean;\n\t/** Non-null when the cursor is inside (or selection spans) a hyperlink. */\n\tlink: { href: string } | null;\n\ttextAlign: 'left' | 'center' | 'right' | 'justify' | null;\n\tfontFamily: string | null;\n\tfontSize: string | null;\n\t/** Active text colour as a CSS colour string, or null if none. */\n\tcolor: string | null;\n\t/** Active highlight (background) colour, or null if none. */\n\thighlight: string | null;\n\t/** True when the cursor/selection is in a superscript. */\n\tsuperscript: boolean;\n\t/** True when the cursor/selection is in a subscript. */\n\tsubscript: boolean;\n}\n\nexport const DEFAULT_FORMAT_STATE: FormatState = {\n\tbold: false,\n\titalic: false,\n\tunderline: false,\n\tstrike: false,\n\tbulletList: false,\n\torderedList: false,\n\tblockquote: false,\n\tcodeBlock: false,\n\tlink: null,\n\ttextAlign: null,\n\tfontFamily: null,\n\tfontSize: null,\n\tcolor: null,\n\thighlight: null,\n\tsuperscript: false,\n\tsubscript: false,\n};\n\n/**\n * All formatting and insertion commands. Access via `editorRef.current.actions`.\n *\n * Every method focuses the editor internally — no need to call `.focus()` first.\n *\n * @example\n * editorRef.current?.actions.toggleBold();\n * editorRef.current?.actions.setLink('https://example.com', 'Visit example');\n */\nexport interface EditorActions {\n\t// ── Basic marks ───────────────────────────────────────────────────────────\n\ttoggleBold: () => void;\n\ttoggleItalic: () => void;\n\ttoggleUnderline: () => void;\n\ttoggleStrike: () => void;\n\n\t// ── Blocks ────────────────────────────────────────────────────────────────\n\ttoggleBulletList: () => void;\n\ttoggleOrderedList: () => void;\n\ttoggleBlockquote: () => void;\n\ttoggleCodeBlock: () => void;\n\n\t// ── Alignment & typography ────────────────────────────────────────────────\n\tsetTextAlign: (align: 'left' | 'center' | 'right' | 'justify') => void;\n\t/** Pass a CSS font-family value, e.g. `'Inter, sans-serif'`. Only works when richTypography is on. */\n\tsetFontFamily: (font: string) => void;\n\t/** Pass a CSS size value, e.g. `'16px'` or `'1.25rem'`. Only works when richTypography is on. */\n\tsetFontSize: (size: string) => void;\n\n\t// ── Colour ────────────────────────────────────────────────────────────────\n\t/** Sets the text colour. Pass any CSS colour value, e.g. `'#e53e3e'`. */\n\tsetColor: (color: string) => void;\n\t/** Sets the highlight (background) colour. */\n\tsetHighlight: (color: string) => void;\n\t/** Removes the text colour mark from the current selection. */\n\tunsetColor: () => void;\n\t/** Removes the highlight mark from the current selection. */\n\tunsetHighlight: () => void;\n\n\t// ── Links ─────────────────────────────────────────────────────────────────\n\t/**\n\t * Applies a hyperlink to the current selection, or updates the link the\n\t * cursor is already inside.\n\t *\n\t * @param href The URL.\n\t * @param text Optional display text. When provided, the visible text of the\n\t * linked range is replaced atomically in the same undo step.\n\t *\n\t * @example\n\t * actions.setLink('https://example.com');\n\t * actions.setLink('https://example.com', 'Visit example');\n\t */\n\tsetLink: (href: string, text?: string) => void;\n\t/** Updates only the href of the link at the current cursor. */\n\tupdateLink: (href: string) => void;\n\t/** Removes the link mark but keeps the visible text. */\n\tremoveLink: () => void;\n\n\t// ── Insertions ────────────────────────────────────────────────────────────\n\t/** Inserts an emoji character at the cursor. */\n\tinsertEmoji: (emoji: string) => void;\n\t/**\n\t * Inserts a `{{variableName}}` token at the cursor.\n\t * The token renders with a distinct highlight inside the editor.\n\t */\n\tinsertVariable: (variableName: string) => void;\n\t/** Inserts arbitrary HTML at the current cursor position. */\n\tinsertHtml: (html: string) => void;\n\n\t// ── History ───────────────────────────────────────────────────────────────\n\tundo: () => void;\n\tredo: () => void;\n\tcanUndo: () => boolean;\n\tcanRedo: () => boolean;\n\n\t// ── Rich typography (richTypography feature required) ─────────────────────\n\t/** Toggles superscript on the selection. Only works when richTypography is on. */\n\ttoggleSuperscript: () => void;\n\t/** Toggles subscript on the selection. Only works when richTypography is on. */\n\ttoggleSubscript: () => void;\n\t/** Inserts an inline image at the cursor. Only works when richTypography is on. */\n\tinsertImage: (src: string) => void;\n}\n\n/** Props passed to your renderLinkTooltip render prop. */\nexport interface LinkTooltipProps {\n\t/** The href of the active link. */\n\thref: string;\n\t/** The display text of the link. */\n\ttext: string;\n\t/** Bounding rect of the link element — use this to position your popover. */\n\trect: DOMRect;\n\t/** Opens the link in a new tab. */\n\tonOpen: () => void;\n\t/** Removes the link mark but keeps the visible text. */\n\tonRemove: () => void;\n\t/** Hides the bubble menu. Call this before opening an edit modal so the tooltip doesn't linger. */\n\tonHide: () => void;\n}\n\n/**\n * Imperative handle exposed by BikEditor.\n *\n * Obtain via `useRef<BikEditorRef>()` and pass to `<BikEditor ref={...} />`.\n * All methods are safe to call after the first render.\n *\n * @example\n * const ref = useRef<BikEditorRef>(null);\n * <BikEditor ref={ref} ... />\n * ref.current?.clearContent();\n * ref.current?.actions.toggleBold();\n */\nexport interface BikEditorRef {\n\t// ── Focus ─────────────────────────────────────────────────────────────────\n\t/** Moves focus into the editor. Optionally pass a position: 'start', 'end', 'all', or a numeric offset. */\n\tfocus: (position?: 'start' | 'end' | 'all' | number | boolean | null) => void;\n\t/** Removes focus from the editor. */\n\tblur: () => void;\n\n\t// ── Content ───────────────────────────────────────────────────────────────\n\t/** Clears the entire document and fires onChange. */\n\tclearContent: () => void;\n\t/**\n\t * Replaces the full document with the given HTML and fires onChange.\n\t * Overwrites all sections. Use setSectionContent() / setBodyContent() to\n\t * update a single section without touching the others.\n\t */\n\tsetContent: (html: string) => void;\n\t/** Inserts HTML at the current cursor position without replacing anything. */\n\tinsertContent: (html: string) => void;\n\t/**\n\t * Inserts HTML inline at the current cursor position, unwrapping block\n\t * wrappers (e.g. `<p>`) so the content merges into the surrounding paragraph\n\t * instead of creating new blocks. Use for macros, quick replies, etc.\n\t */\n\tinsertInlineContent: (html: string) => void;\n\t/** Inserts HTML at the very start of the document. */\n\tinsertAtStart: (html: string) => void;\n\t/** Inserts HTML as a new block at the end of the document. */\n\tinsertBlock: (html: string) => void;\n\t/**\n\t * Appends HTML inline inside the last paragraph of the document.\n\t * Ideal for streaming — call repeatedly with each text chunk.\n\t * Use `appendBodyContent` instead if the editor has named sections.\n\t */\n\tappendInline: (html: string) => void;\n\t/** @deprecated Use `insertBlock` */\n\tinsertAtEnd: (html: string) => void;\n\t/** @deprecated Use `appendInline` */\n\tappendContent: (html: string) => void;\n\t/** Returns the full document as `{ html, text, isEmpty, characterCount }`. */\n\tgetContent: () => EditorSnapshot;\n\t/**\n\t * Returns the raw TipTap document as a plain JSON object.\n\t * Returns `null` when the editor is not yet mounted.\n\t */\n\tgetJSON: () => Record<string, unknown> | null;\n\t/**\n\t * Walks the document and returns all mention IDs currently in the editor,\n\t * split by type. IDs are deduplicated and returned as arrays.\n\t *\n\t * @example\n\t * const { agentIds, teamIds } = ref.current?.getMentions() ?? { agentIds: [], teamIds: [] };\n\t */\n\tgetMentions: () => { agentIds: string[]; teamIds: string[] };\n\n\t// ── Selection ─────────────────────────────────────────────────────────────\n\t/**\n\t * Returns the current cursor / selection position as a `{ from, to }` pair.\n\t * When nothing is selected, `from === to` (a collapsed cursor).\n\t * Pass the returned value to `insertAtPosition()` to insert at an exact spot.\n\t *\n\t * @example\n\t * const { from } = ref.current?.getCursorPosition() ?? { from: 0, to: 0 };\n\t * ref.current?.insertAtPosition(from, '<strong>inserted</strong>');\n\t */\n\tgetCursorPosition: () => { from: number; to: number };\n\t/**\n\t * Inserts HTML at an explicit document position rather than at the current cursor.\n\t * Use `getCursorPosition()` to get the position, or any value from\n\t * `findSectionStartPos` / `findSectionEndPos` if you need section-relative insertion.\n\t *\n\t * @example\n\t * const { from } = ref.current!.getCursorPosition();\n\t * ref.current?.insertAtPosition(from, '<em>hello</em>');\n\t */\n\tinsertAtPosition: (pos: number, html: string) => void;\n\t/**\n\t * Returns the currently selected plain text.\n\t * When the cursor is inside a link with nothing selected, returns the full\n\t * link text — useful for pre-filling a link modal's text field.\n\t */\n\tgetSelectedText: () => string;\n\n\t// ── Character count ───────────────────────────────────────────────────────\n\t/**\n\t * Returns the current character count and the configured limit (or null).\n\t * Use this to render your own character counter anywhere you like.\n\t *\n\t * @example\n\t * const { count, limit } = ref.current?.getCharacterCount() ?? { count: 0, limit: null };\n\t * <span style={{ color: count >= (limit ?? Infinity) ? 'red' : 'inherit' }}>\n\t * {count}{limit != null ? ` / ${limit}` : ''}\n\t * </span>\n\t */\n\tgetCharacterCount: () => { count: number; limit: number | null };\n\n\t// ── Sections ─────────────────────────────────────────────────────────────\n\t/**\n\t * Returns content for a named section.\n\t * Use `'body'` to get the main content above all section dividers.\n\t *\n\t * @example\n\t * const sig = ref.current?.getSectionContent('signature');\n\t */\n\tgetSectionContent: (sectionId: string) => EditorSnapshot;\n\t/**\n\t * Replaces the content of a named section without touching other sections.\n\t * If the section doesn't exist yet it is appended at the end.\n\t *\n\t * @example\n\t * ref.current?.setSectionContent('signature', '<p>New signature</p>');\n\t * ref.current?.setSectionContent('body', rephrased); // same as setBodyContent\n\t */\n\tsetSectionContent: (sectionId: string, html: string) => void;\n\t/**\n\t * Moves the cursor to the start of a named section.\n\t * Use `'body'` to focus the main content area.\n\t */\n\tfocusSection: (sectionId: string) => void;\n\t/** Clears all content in a named section (replaces with an empty paragraph). */\n\tclearSection: (sectionId: string) => void;\n\n\t// ── Convenience body shorthands ───────────────────────────────────────────\n\t/** Shorthand for `getSectionContent('body')`. */\n\tgetBodyContent: () => EditorSnapshot;\n\t/** Shorthand for `setSectionContent('body', html)`. */\n\tsetBodyContent: (html: string) => void;\n\t/**\n\t * Atomically sets the body AND all sections in a single editor update.\n\t * Sections are laid out in the exact order supplied — use this instead of\n\t * multiple `setSectionContent()` calls whenever order matters (e.g. forward\n\t * mail where signature must appear before the forwarded thread).\n\t *\n\t * @example\n\t * ref.current?.setBodyAndSections('<p></p>', [\n\t * { id: 'signature', content: '<p>Alice</p>' },\n\t * { id: 'forwarded', content: '<p>--- Forwarded ---</p>' },\n\t * ]);\n\t */\n\tsetBodyAndSections: (\n\t\tbody: string,\n\t\tsections: Array<{ id: string; content: string }>,\n\t) => void;\n\t/**\n\t * Appends HTML to the end of the body section without moving the cursor.\n\t * Ideal for streaming AI-generated content — call repeatedly with each chunk.\n\t * Does NOT clear existing content; call `setBodyContent('')` first if needed.\n\t *\n\t * @example\n\t * // Stream AI response chunk-by-chunk\n\t * ref.current?.setBodyContent('');\n\t * for await (const chunk of aiStream) {\n\t * ref.current?.appendBodyContent(chunk);\n\t * }\n\t */\n\tappendBodyContent: (html: string) => void;\n\n\t/**\n\t * Inserts HTML at the start of a named section (or `'body'`).\n\t * Inserts at the very start of the document when `sectionId` is `'body'`.\n\t */\n\tinsertAtSectionStart: (sectionId: string, html: string) => void;\n\t/**\n\t * Inserts HTML at the end of a named section (or `'body'`).\n\t * For `'body'`, inserts just before the first section divider (or at end of doc).\n\t */\n\tinsertAtSectionEnd: (sectionId: string, html: string) => void;\n\n\t// ── Formats & actions ─────────────────────────────────────────────────────\n\t/** Returns a snapshot of all active marks at the current cursor or selection. */\n\tgetActiveFormats: () => FormatState;\n\t/** All formatting and insertion commands. See EditorActions. */\n\tactions: EditorActions;\n}\n\n/**\n * Props for `<BikEditor />`. All props are optional.\n */\nexport interface BikEditorProps {\n\t// ── Features ──────────────────────────────────────────────────────────────\n\t/**\n\t * Opt in to specific editor capabilities. Both default to `false`.\n\t *\n\t * @example\n\t * <BikEditor features={{ richPaste: true, richTypography: true }} />\n\t */\n\tfeatures?: EditorFeatures;\n\n\t// ── Content ───────────────────────────────────────────────────────────────\n\t/**\n\t * HTML loaded on mount. Ignored after first render.\n\t * Use `ref.setContent()` to change content imperatively later.\n\t */\n\tinitialContent?: string;\n\t/**\n\t * Named sections placed below the main body.\n\t * Each section is separated from the previous one by an invisible divider node.\n\t * The array order determines the visual order in the document.\n\t *\n\t * These are only the INITIAL values — use `ref.setSectionContent()` to update\n\t * a section after mount without re-mounting the editor.\n\t *\n\t * @example\n\t * sections={[\n\t * { id: 'signature', content: '<p>Best regards, Alice</p>' },\n\t * { id: 'forwarded', content: '<p>--- Forwarded message ---</p>' },\n\t * ]}\n\t */\n\tsections?: EditorSection[];\n\t/** Placeholder text shown when the editor is empty. */\n\tplaceholder?: string;\n\n\t// ── Behaviour ─────────────────────────────────────────────────────────────\n\t/** Makes the editor read-only. The toolbar still renders but actions are no-ops. */\n\tdisabled?: boolean;\n\t/**\n\t * Hard character limit. The editor refuses to accept input beyond this point.\n\t * The limit is enforced silently — no UI is rendered. Use\n\t * `ref.getCharacterCount()` or `onChange.characterCount` to display it yourself.\n\t */\n\tmaxCharacters?: number;\n\n\t// ── Keyboard shortcuts ────────────────────────────────────────────────────\n\t/**\n\t * Custom keyboard shortcuts. BikEditor registers no shortcuts of its own —\n\t * every shortcut must be explicitly listed here.\n\t *\n\t * @example\n\t * shortcuts={[\n\t * { key: 'Enter', modifiers: ['mod'], handler: handleSend },\n\t * { key: 's', modifiers: ['mod', 'shift'], handler: handleDraft },\n\t * ]}\n\t */\n\tshortcuts?: KeyboardShortcut[];\n\t/**\n\t * Shortcut key that fires `onSend`. No key is bound to `onSend` unless you\n\t * set this explicitly. Requires `onSend` to also be provided.\n\t *\n\t * `'mod'` maps to Cmd on macOS and Ctrl on Windows/Linux.\n\t *\n\t * @example\n\t * // Single shortcut\n\t * sendShortcut={{ key: 'Enter', modifiers: ['mod'] }}\n\t * // Multiple shortcuts\n\t * sendShortcut={[\n\t * { key: 'Enter', modifiers: ['mod'] },\n\t * { key: 's', modifiers: ['mod'] },\n\t * ]}\n\t */\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\n\t// ── Mentions ─────────────────────────────────────────────────────────────\n\t/**\n\t * Enables `@` (agent) and `#` (team) mention dropdowns.\n\t * Bundle all mention-related config in one object so it's easy to find.\n\t *\n\t * @example\n\t * mentions={{\n\t * agents: myAgents,\n\t * teams: myTeams,\n\t * onSelect: (item, char) => track(char, item.id),\n\t * }}\n\t */\n\tmentions?: MentionConfig;\n\n\t// ── Slash commands ────────────────────────────────────────────────────────\n\t/**\n\t * Enables the `/` slash-command menu.\n\t * Bundle all slash-command config in one object.\n\t *\n\t * @example\n\t * slashCommands={{\n\t * items: MY_COMMANDS,\n\t * onSelect: (cmd) => handleCommand(cmd.id),\n\t * }}\n\t */\n\tslashCommands?: SlashCommandConfig;\n\n\t// ── Link ─────────────────────────────────────────────────────────────────\n\t/**\n\t * Link-related configuration — currently just the click tooltip.\n\t *\n\t * @example\n\t * link={{ renderTooltip: ({ href, onOpen, onRemove }) => (\n\t * <MyTooltip href={href} onOpen={onOpen} onRemove={onRemove} />\n\t * )}}\n\t */\n\tlink?: LinkConfig;\n\n\t// ── Callbacks ─────────────────────────────────────────────────────────────\n\t/**\n\t * Called once, immediately after the editor finishes initializing.\n\t * Any imperative ref methods called before this fires are queued internally\n\t * and executed automatically once the editor is ready — consumers do not\n\t * need timers or readiness guards.\n\t *\n\t * @example\n\t * <BikEditor\n\t * ref={editorRef}\n\t * onReady={() => editorRef.current?.setContent(savedDraft)}\n\t * />\n\t */\n\tonReady?: () => void;\n\t/** Called on every document change. */\n\tonChange?: (content: EditorSnapshot) => void;\n\t/**\n\t * Called when the user presses the key combo defined by `sendShortcut`.\n\t * Only fires when both `onSend` and `sendShortcut` are provided.\n\t */\n\tonSend?: (content: EditorSnapshot) => void;\n\t/** Called when the editor gains focus. */\n\tonFocus?: () => void;\n\t/** Called when the editor loses focus. */\n\tonBlur?: () => void;\n\t/**\n\t * Called on every paste event. Return `true` to fully suppress BikEditor's\n\t * own paste handling (useful when you want to handle images or HTML yourself).\n\t *\n\t * @example\n\t * onPaste={({ images }) => {\n\t * if (images.length) {\n\t * uploadImages(images).then(urls => {\n\t * urls.forEach(url => ref.current?.actions.insertHtml(`<img src=\"${url}\" />`));\n\t * });\n\t * return true; // suppress default — don't embed the raw image data\n\t * }\n\t * }}\n\t */\n\tonPaste?: (data: PasteData) => boolean | void;\n\t/**\n\t * Called on every cursor move or selection change with a snapshot of all\n\t * active marks. Keep in state and pass to your toolbar to sync button states.\n\t */\n\tonSelectionChange?: (activeFormats: FormatState) => void;\n\n\t// ── Styling ───────────────────────────────────────────────────────────────\n\t// Outer wrapper — use these to control the shell (border, border-radius,\n\t// background, shadow, etc.).\n\t/** Extra class name applied to the outer wrapper div. */\n\tclassName?: string;\n\t/** Inline styles applied to the outer wrapper div. */\n\tstyle?: React.CSSProperties;\n\n\t// Inner editable area — use these to control the content div itself\n\t// (padding, font, line-height, etc.).\n\t/** Extra class name applied to the content-editable area (`.ProseMirror` in TipTap). */\n\teditorClassName?: string;\n\t/** Inline styles applied to the content-editable area. */\n\teditorStyle?: React.CSSProperties;\n\n\t// Sizing — applied to the content-editable area.\n\t/** Minimum height of the editable area. CSS value, e.g. `'80px'`. */\n\tminHeight?: string;\n\t/** Maximum height. The editor scrolls internally when exceeded. CSS value, e.g. `'400px'`. */\n\tmaxHeight?: string;\n}\n"],"names":["DEFAULT_FORMAT_STATE","bold","italic","underline","strike","bulletList","orderedList","blockquote","codeBlock","link","textAlign","fontFamily","fontSize","color","highlight","superscript","subscript"],"mappings":"AAgUO,MAAMA,EAAoC,CAChDC,MAAM,EACNC,QAAQ,EACRC,WAAW,EACXC,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,YAAY,EACZC,WAAW,EACXC,KAAM,KACNC,UAAW,KACXC,WAAY,KACZC,SAAU,KACVC,MAAO,KACPC,UAAW,KACXC,aAAa,EACbC,WAAW"}
@@ -1,2 +1,2 @@
1
- import{DOMSerializer as t,DOMParser as e}from"../node_modules/prosemirror-model/dist/index.js";import{normalizeHardBreaks as n}from"./extensions/plainClipboard/pasteUtils.js";function i(t){return t.replace(/<\/?span[^>]*>/gi,"").replace(/(<p[^>]*>)\s*<br\s*\/?>\s*(<\/p>)/gi,"$1$2")}function r(t){const e=document.createElement("div");e.innerHTML=t;for(const t of Array.from(e.querySelectorAll("p"))){if(0===t.childNodes.length){t.appendChild(document.createElement("br"));continue}t.lastChild instanceof HTMLBRElement&&t.childNodes.length>1&&t.appendChild(document.createElement("br"))}return e.innerHTML}function o(t,n){const r=i(n),o=document.createElement("div");o.innerHTML=r;const s=e.fromSchema(t.schema).parseSlice(o);if(0===s.size)return;const{from:c,to:l}=t.state.selection,d=t.state.tr.replaceRange(c,l,s);t.view.dispatch(d)}const s=t=>`<div data-section-divider="${t}" style="display:none;height:0;line-height:0;overflow:hidden;"></div>`;function c(t,e){let n=t;for(const t of e)n+=s(t.id)+t.content;return n}function l(t){var e;if(!t)return"";return null!==(e=u(t).get("body"))&&void 0!==e?e:t}function d(t){if(!t)return"";const e=l(t);return t.substring(e.length)}function u(t){const e=new Map,n=/<div[^>]*data-section-divider="([^"]*)[^>]*>\s*<\/div>/g,i=[];let r;for(;null!==(r=n.exec(t));)i.push({id:r[1],index:r.index,endIndex:r.index+r[0].length});if(0===i.length)return e.set("body",t),e;e.set("body",t.slice(0,i[0].index));for(let n=0;n<i.length;n++){const r=i[n].endIndex,o=n+1<i.length?i[n+1].index:t.length;e.set(i[n].id,t.slice(r,o))}return e}function a(e,n){var i;const o=p(e,n);if(-1===o)return{html:"",text:"",isEmpty:!0,characterCount:0};const s=g(e,n),c=e.state.doc.slice(o,s),l=document.createElement("div"),d=t.fromSchema(e.schema);l.appendChild(d.serializeFragment(c.content));const u=r(l.innerHTML),a=null!==(i=l.textContent)&&void 0!==i?i:"";return{html:u,text:a,isEmpty:!a.trim(),characterCount:a.length}}function f(t,n,i){const r=p(t,n);if(-1===r){const e=t.state.doc.content.size,r=s(n)+i;return void t.commands.insertContentAt(e,r,{updateSelection:!1})}const o=g(t,n),c=function(t,n){const i=document.createElement("div");return i.innerHTML=n,e.fromSchema(t.schema).parse(i).content}(t,i),{tr:l}=t.state,d="body"===n?0:r;l.replaceWith(d,o,c),l.setMeta("addToHistory",!1),t.view.dispatch(l)}function h(t){return a(t,"body")}function m(t){var e,n,i,r;return{bold:t.isActive("bold"),italic:t.isActive("italic"),underline:t.isActive("underline"),strike:t.isActive("strike"),bulletList:t.isActive("bulletList"),orderedList:t.isActive("orderedList"),blockquote:t.isActive("blockquote"),codeBlock:t.isActive("codeBlock"),link:(()=>{var e,n,i;if(t.isActive("link"))return{href:null!==(e=t.getAttributes("link").href)&&void 0!==e?e:""};const{$from:r}=t.state.selection;if(r.pos>0){const t=r.doc.resolve(r.pos).marks().find((t=>"link"===t.type.name));if(t)return{href:null!==(i=t.attrs.href)&&void 0!==i?i:""};{const t=r.nodeBefore,e=null==t?void 0:t.marks.find((t=>"link"===t.type.name));if(e)return{href:null!==(n=e.attrs.href)&&void 0!==n?n:""}}}return null})(),textAlign:t.isActive({textAlign:"center"})?"center":t.isActive({textAlign:"right"})?"right":t.isActive({textAlign:"justify"})?"justify":t.isActive({textAlign:"left"})?"left":null,fontFamily:null!==(e=t.getAttributes("textStyle").fontFamily)&&void 0!==e?e:null,fontSize:null!==(n=t.getAttributes("textStyle").fontSize)&&void 0!==n?n:null,color:null!==(i=t.getAttributes("textStyle").color)&&void 0!==i?i:null,highlight:t.isActive("highlight")?null!==(r=t.getAttributes("highlight").color)&&void 0!==r?r:"default":null,superscript:t.isActive("superscript"),subscript:t.isActive("subscript")}}function v(t){const e=r(t.getHTML()),i=n(t.state.doc.content),o=t.schema.node("doc",null,i),s=o.textBetween(0,o.content.size,"\n\n");return{html:e,text:s,isEmpty:t.isEmpty,characterCount:s.length}}function p(t,e){if("body"===e)return 1;let n=-1;return t.state.doc.descendants(((t,i)=>{if(-1!==n)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(n=i+t.nodeSize)})),n}function g(t,e){const n=t.state.doc,i=n.content.size;if("body"===e){let t=-1;return n.descendants(((e,n)=>{if(-1!==t)return!1;"sectionDivider"===e.type.name&&(t=n)})),-1!==t?t:i}let r=!1,o=-1;return n.descendants(((t,n)=>-1===o&&(r?void("sectionDivider"===t.type.name&&(o=n)):("sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(r=!0),!1)))),-1!==o?o:i}export{s as SECTION_DIVIDER_HTML,c as buildSectionedContent,m as extractActiveFormats,u as extractAllSectionsFromHtml,h as extractBodyContent,v as extractContent,a as extractSectionContent,g as findSectionEndPos,p as findSectionStartPos,l as getBodyHtml,d as getSectionsHtml,o as insertInlineHtml,i as normalizeHtml,f as setSectionContentInEditor,r as toPortableHtml};
1
+ import{DOMSerializer as t,DOMParser as e}from"../node_modules/prosemirror-model/dist/index.js";function n(t){return t.replace(/<\/?span[^>]*>/gi,"").replace(/(<p[^>]*>)\s*<br\s*\/?>\s*(<\/p>)/gi,"$1$2")}function i(t){return t.replace(/<p><\/p>/g,"<p><br></p>")}function r(t,i){const r=n(i),o=document.createElement("div");o.innerHTML=r;const s=e.fromSchema(t.schema).parseSlice(o);if(0===s.size)return;const{from:c,to:l}=t.state.selection,d=t.state.tr.replaceRange(c,l,s);t.view.dispatch(d)}const o=t=>`<div data-section-divider="${t}" style="display:none;height:0;line-height:0;overflow:hidden;"></div>`;function s(t,e){let n=t;for(const t of e)n+=o(t.id)+t.content;return n}function c(t){var e;if(!t)return"";return null!==(e=d(t).get("body"))&&void 0!==e?e:t}function l(t){if(!t)return"";const e=c(t);return t.substring(e.length)}function d(t){const e=new Map,n=/<div[^>]*data-section-divider="([^"]*)[^>]*>\s*<\/div>/g,i=[];let r;for(;null!==(r=n.exec(t));)i.push({id:r[1],index:r.index,endIndex:r.index+r[0].length});if(0===i.length)return e.set("body",t),e;e.set("body",t.slice(0,i[0].index));for(let n=0;n<i.length;n++){const r=i[n].endIndex,o=n+1<i.length?i[n+1].index:t.length;e.set(i[n].id,t.slice(r,o))}return e}function u(e,n){var r;const o=m(e,n);if(-1===o)return{html:"",text:"",isEmpty:!0,characterCount:0};const s=p(e,n),c=e.state.doc.slice(o,s),l=document.createElement("div"),d=t.fromSchema(e.schema);l.appendChild(d.serializeFragment(c.content));const u=i(l.innerHTML),a=null!==(r=l.textContent)&&void 0!==r?r:"";return{html:u,text:a,isEmpty:!a.trim(),characterCount:a.length}}function a(t,n,i){const r=m(t,n);if(-1===r){const e=t.state.doc.content.size,r=o(n)+i;return void t.commands.insertContentAt(e,r,{updateSelection:!1})}const s=p(t,n),c=function(t,n){const i=document.createElement("div");return i.innerHTML=n,e.fromSchema(t.schema).parse(i).content}(t,i),{tr:l}=t.state,d="body"===n?0:r;l.replaceWith(d,s,c),l.setMeta("addToHistory",!1),t.view.dispatch(l)}function f(t){return u(t,"body")}function v(t){var e,n,i,r;return{bold:t.isActive("bold"),italic:t.isActive("italic"),underline:t.isActive("underline"),strike:t.isActive("strike"),bulletList:t.isActive("bulletList"),orderedList:t.isActive("orderedList"),blockquote:t.isActive("blockquote"),codeBlock:t.isActive("codeBlock"),link:(()=>{var e,n,i;if(t.isActive("link"))return{href:null!==(e=t.getAttributes("link").href)&&void 0!==e?e:""};const{$from:r}=t.state.selection;if(r.pos>0){const t=r.doc.resolve(r.pos).marks().find((t=>"link"===t.type.name));if(t)return{href:null!==(i=t.attrs.href)&&void 0!==i?i:""};{const t=r.nodeBefore,e=null==t?void 0:t.marks.find((t=>"link"===t.type.name));if(e)return{href:null!==(n=e.attrs.href)&&void 0!==n?n:""}}}return null})(),textAlign:t.isActive({textAlign:"center"})?"center":t.isActive({textAlign:"right"})?"right":t.isActive({textAlign:"justify"})?"justify":t.isActive({textAlign:"left"})?"left":null,fontFamily:null!==(e=t.getAttributes("textStyle").fontFamily)&&void 0!==e?e:null,fontSize:null!==(n=t.getAttributes("textStyle").fontSize)&&void 0!==n?n:null,color:null!==(i=t.getAttributes("textStyle").color)&&void 0!==i?i:null,highlight:t.isActive("highlight")?null!==(r=t.getAttributes("highlight").color)&&void 0!==r?r:"default":null,superscript:t.isActive("superscript"),subscript:t.isActive("subscript")}}function h(t){var e,n,r;return{html:i(t.getHTML()),text:t.getText(),isEmpty:t.isEmpty,characterCount:null!==(r=null===(n=null===(e=t.storage.characterCount)||void 0===e?void 0:e.characters)||void 0===n?void 0:n.call(e))&&void 0!==r?r:t.getText().length}}function m(t,e){if("body"===e)return 1;let n=-1;return t.state.doc.descendants(((t,i)=>{if(-1!==n)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(n=i+t.nodeSize)})),n}function p(t,e){const n=t.state.doc,i=n.content.size;if("body"===e){let t=-1;return n.descendants(((e,n)=>{if(-1!==t)return!1;"sectionDivider"===e.type.name&&(t=n)})),-1!==t?t:i}let r=!1,o=-1;return n.descendants(((t,n)=>-1===o&&(r?void("sectionDivider"===t.type.name&&(o=n)):("sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(r=!0),!1)))),-1!==o?o:i}export{o as SECTION_DIVIDER_HTML,s as buildSectionedContent,v as extractActiveFormats,d as extractAllSectionsFromHtml,f as extractBodyContent,h as extractContent,u as extractSectionContent,p as findSectionEndPos,m as findSectionStartPos,c as getBodyHtml,l as getSectionsHtml,r as insertInlineHtml,n as normalizeHtml,a as setSectionContentInEditor,i as toPortableHtml};
2
2
  //# sourceMappingURL=BikEditor.utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BikEditor.utils.js","sources":["../../../src/editor/BikEditor.utils.ts"],"sourcesContent":["import { Editor } from '@tiptap/core';\nimport { DOMParser, DOMSerializer } from 'prosemirror-model';\nimport { EditorSnapshot, FormatState } from './BikEditor.types';\nimport { normalizeHardBreaks } from './extensions/plainClipboard/pasteUtils';\n\n// ---------------------------------------------------------------------------\n// HTML normalisation\n// ---------------------------------------------------------------------------\n\n/**\n * Normalise HTML before passing it to TipTap.\n *\n * 1. Strip all `<span>` tags first (keeps inner content). This exposes\n * bare `<br>` inside otherwise-empty paragraphs like Quill's\n * `<p><span class=\"ql-cursor\"><br></span></p>`.\n * 2. Then convert `<p><br></p>` → `<p></p>`. ProseMirror parses `<p></p>`\n * as an empty paragraph node and adds its own DOM `<br>` for cursor\n * positioning — one blank line, correct height. Leaving the `<br>`\n * would create a `hard_break` child AND the cursor `<br>`, producing\n * double-height blank lines.\n */\nexport function normalizeHtml(html: string): string {\n\treturn html\n\t\t.replace(/<\\/?span[^>]*>/gi, '')\n\t\t.replace(/(<p[^>]*>)\\s*<br\\s*\\/?>\\s*(<\\/p>)/gi, '$1$2');\n}\n\n/**\n * Make editor HTML portable across email clients and chat renderers.\n *\n * 1. Double trailing `<br>` in content paragraphs so the blank line is\n * visible. A single trailing `<br>` before `</p>` is swallowed by most\n * email clients; `<br><br>` renders as a visible blank line (matches\n * Gmail's output).\n * 2. Convert empty `<p></p>` to `<p><br></p>` — email clients collapse\n * zero-height paragraphs without a `<br>`.\n */\nexport function toPortableHtml(html: string): string {\n\tconst div = document.createElement('div');\n\tdiv.innerHTML = html;\n\tfor (const p of Array.from(div.querySelectorAll('p'))) {\n\t\tif (p.childNodes.length === 0) {\n\t\t\tp.appendChild(document.createElement('br'));\n\t\t\tcontinue;\n\t\t}\n\t\tconst last = p.lastChild;\n\t\tif (last instanceof HTMLBRElement && p.childNodes.length > 1) {\n\t\t\tp.appendChild(document.createElement('br'));\n\t\t}\n\t}\n\treturn div.innerHTML;\n}\n\n// ---------------------------------------------------------------------------\n// Inline content insertion\n// ---------------------------------------------------------------------------\n\n/**\n * Insert HTML at the current cursor position, merging the first paragraph\n * inline while preserving the block structure of subsequent paragraphs/lists.\n *\n * Uses `parseSlice` which returns an open-ended Slice — the first block merges\n * at the cursor, middle blocks stay intact, and the last block merges with any\n * text that follows the cursor.\n */\nexport function insertInlineHtml(editor: Editor, html: string): void {\n\tconst normalised = normalizeHtml(html);\n\tconst dom = document.createElement('div');\n\tdom.innerHTML = normalised;\n\tconst slice = DOMParser.fromSchema(editor.schema).parseSlice(dom);\n\n\tif (slice.size === 0) return;\n\n\tconst { from, to } = editor.state.selection;\n\tconst tr = editor.state.tr.replaceRange(from, to, slice);\n\teditor.view.dispatch(tr);\n}\n\n// ---------------------------------------------------------------------------\n// Section divider HTML\n// ---------------------------------------------------------------------------\n\nexport const SECTION_DIVIDER_HTML = (id: string) =>\n\t`<div data-section-divider=\"${id}\" style=\"display:none;height:0;line-height:0;overflow:hidden;\"></div>`;\n\n/**\n * Build initial HTML for an editor with one or more named sections below the body.\n * Each section is separated by an invisible divider node.\n *\n * @example\n * buildSectionedContent('<p>Body</p>', [\n * { id: 'signature', content: '<p>Alice</p>' },\n * { id: 'forwarded', content: '<p>--- fwd ---</p>' },\n * ])\n */\nexport function buildSectionedContent(\n\tbody: string,\n\tsections: Array<{ id: string; content: string }>,\n): string {\n\tlet html = body;\n\tfor (const s of sections) {\n\t\thtml += SECTION_DIVIDER_HTML(s.id) + s.content;\n\t}\n\treturn html;\n}\n\n// ---------------------------------------------------------------------------\n// Section extraction\n// ---------------------------------------------------------------------------\n\n/**\n * Parse the editor HTML into a Map of sectionId → raw HTML string.\n * The special key `'body'` always holds the content before the first divider.\n * Map iteration order matches document order.\n */\nexport function extractAllSections(editor: Editor): Map<string, string> {\n\treturn extractAllSectionsFromHtml(editor.getHTML());\n}\n\n/**\n * Extract just the body portion (everything before the first section divider)\n * from an HTML string produced by BikEditor. Safe to call on plain HTML too —\n * returns the full string when no dividers are present.\n */\nexport function getBodyHtml(html: string): string {\n\tif (!html) return '';\n\tconst sections = extractAllSectionsFromHtml(html);\n\treturn sections.get('body') ?? html;\n}\n\n/**\n * Extract everything from the first section divider onward (dividers + their\n * content). Returns an empty string when there are no sections.\n */\nexport function getSectionsHtml(html: string): string {\n\tif (!html) return '';\n\tconst body = getBodyHtml(html);\n\treturn html.substring(body.length);\n}\n\nexport function extractAllSectionsFromHtml(html: string): Map<string, string> {\n\tconst sections = new Map<string, string>();\n\tconst dividerRegex =\n\t\t/<div[^>]*data-section-divider=\"([^\"]*)[^>]*>\\s*<\\/div>/g;\n\tconst dividers: Array<{ id: string; index: number; endIndex: number }> = [];\n\n\tlet match: RegExpExecArray | null;\n\twhile ((match = dividerRegex.exec(html)) !== null) {\n\t\tdividers.push({\n\t\t\tid: match[1],\n\t\t\tindex: match.index,\n\t\t\tendIndex: match.index + match[0].length,\n\t\t});\n\t}\n\n\tif (dividers.length === 0) {\n\t\tsections.set('body', html);\n\t\treturn sections;\n\t}\n\n\tsections.set('body', html.slice(0, dividers[0].index));\n\tfor (let i = 0; i < dividers.length; i++) {\n\t\tconst start = dividers[i].endIndex;\n\t\tconst end = i + 1 < dividers.length ? dividers[i + 1].index : html.length;\n\t\tsections.set(dividers[i].id, html.slice(start, end));\n\t}\n\n\treturn sections;\n}\n\n/** Returns BikEditorContent for a single named section (or 'body'). */\nexport function extractSectionContent(\n\teditor: Editor,\n\tid: string,\n): EditorSnapshot {\n\tconst startPos = findSectionStartPos(editor, id);\n\tif (startPos === -1)\n\t\treturn { html: '', text: '', isEmpty: true, characterCount: 0 };\n\tconst endPos = findSectionEndPos(editor, id);\n\tconst slice = editor.state.doc.slice(startPos, endPos);\n\tconst container = document.createElement('div');\n\tconst serializer = DOMSerializer.fromSchema(editor.schema);\n\tcontainer.appendChild(serializer.serializeFragment(slice.content));\n\tconst html = toPortableHtml(container.innerHTML);\n\tconst text = container.textContent ?? '';\n\treturn { html, text, isEmpty: !text.trim(), characterCount: text.length };\n}\n\n/**\n * Parse an HTML string into ProseMirror nodes using the editor's schema.\n */\nfunction parseHtmlToNodes(editor: Editor, html: string) {\n\tconst container = document.createElement('div');\n\tcontainer.innerHTML = html;\n\treturn DOMParser.fromSchema(editor.schema).parse(container).content;\n}\n\n/**\n * Replace the content of a single named section without touching others.\n * Uses a ProseMirror transaction to replace only the target range,\n * preserving undo history and other sections' state.\n * If the section doesn't exist yet, it is appended at the end of the document.\n */\nexport function setSectionContentInEditor(\n\teditor: Editor,\n\tid: string,\n\thtml: string,\n): void {\n\tconst startPos = findSectionStartPos(editor, id);\n\tif (startPos === -1) {\n\t\tconst endPos = editor.state.doc.content.size;\n\t\tconst dividerHtml = SECTION_DIVIDER_HTML(id) + html;\n\t\teditor.commands.insertContentAt(endPos, dividerHtml, {\n\t\t\tupdateSelection: false,\n\t\t});\n\t\treturn;\n\t}\n\tconst endPos = findSectionEndPos(editor, id);\n\tconst fragment = parseHtmlToNodes(editor, html);\n\tconst { tr } = editor.state;\n\t// For body, replace from position 0 (before the first paragraph's opening\n\t// boundary) so ProseMirror swaps entire block nodes cleanly. Position 1\n\t// (inside the paragraph) would force ProseMirror to close the open paragraph\n\t// first, creating a ghost empty <p></p>.\n\tconst replaceFrom = id === 'body' ? 0 : startPos;\n\ttr.replaceWith(replaceFrom, endPos, fragment);\n\ttr.setMeta('addToHistory', false);\n\teditor.view.dispatch(tr);\n}\n\n// ---------------------------------------------------------------------------\n// Convenience shorthands (body = first section)\n// ---------------------------------------------------------------------------\n\n/** Extract BikEditorContent for just the body (before the first divider). */\nexport function extractBodyContent(editor: Editor): EditorSnapshot {\n\treturn extractSectionContent(editor, 'body');\n}\n\n// ---------------------------------------------------------------------------\n// Active formats\n// ---------------------------------------------------------------------------\n\nexport function extractActiveFormats(editor: Editor): FormatState {\n\treturn {\n\t\tbold: editor.isActive('bold'),\n\t\titalic: editor.isActive('italic'),\n\t\tunderline: editor.isActive('underline'),\n\t\tstrike: editor.isActive('strike'),\n\t\tbulletList: editor.isActive('bulletList'),\n\t\torderedList: editor.isActive('orderedList'),\n\t\tblockquote: editor.isActive('blockquote'),\n\t\tcodeBlock: editor.isActive('codeBlock'),\n\t\tlink: (() => {\n\t\t\tif (editor.isActive('link')) {\n\t\t\t\treturn { href: editor.getAttributes('link')['href'] ?? '' };\n\t\t\t}\n\t\t\tconst { $from } = editor.state.selection;\n\t\t\tif ($from.pos > 0) {\n\t\t\t\tconst before = $from.doc.resolve($from.pos);\n\t\t\t\tconst linkMark = before.marks().find((m) => m.type.name === 'link');\n\t\t\t\tif (!linkMark) {\n\t\t\t\t\tconst nodeBefore = $from.nodeBefore;\n\t\t\t\t\tconst markOnPrev = nodeBefore?.marks.find(\n\t\t\t\t\t\t(m) => m.type.name === 'link',\n\t\t\t\t\t);\n\t\t\t\t\tif (markOnPrev) {\n\t\t\t\t\t\treturn { href: markOnPrev.attrs['href'] ?? '' };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn { href: linkMark.attrs['href'] ?? '' };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t})(),\n\t\ttextAlign: editor.isActive({ textAlign: 'center' })\n\t\t\t? 'center'\n\t\t\t: editor.isActive({ textAlign: 'right' })\n\t\t\t? 'right'\n\t\t\t: editor.isActive({ textAlign: 'justify' })\n\t\t\t? 'justify'\n\t\t\t: editor.isActive({ textAlign: 'left' })\n\t\t\t? 'left'\n\t\t\t: null,\n\t\tfontFamily: editor.getAttributes('textStyle')['fontFamily'] ?? null,\n\t\tfontSize: editor.getAttributes('textStyle')['fontSize'] ?? null,\n\t\tcolor: editor.getAttributes('textStyle')['color'] ?? null,\n\t\thighlight: editor.isActive('highlight')\n\t\t\t? editor.getAttributes('highlight')['color'] ?? 'default'\n\t\t\t: null,\n\t\tsuperscript: editor.isActive('superscript'),\n\t\tsubscript: editor.isActive('subscript'),\n\t};\n}\n\nexport function extractContent(editor: Editor): EditorSnapshot {\n\tconst html = toPortableHtml(editor.getHTML());\n\tconst normalized = normalizeHardBreaks(editor.state.doc.content);\n\tconst doc = editor.schema.node('doc', null, normalized);\n\tconst text = doc.textBetween(0, doc.content.size, '\\n\\n');\n\treturn {\n\t\thtml,\n\t\ttext,\n\t\tisEmpty: editor.isEmpty,\n\t\tcharacterCount: text.length,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Section position helpers (used by insertAtSectionStart/End and appendBodyContent)\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the ProseMirror position immediately after a section's opening divider\n * (i.e. the start of the section's own content).\n * For `'body'`, returns 1 (beginning of the document).\n * Returns -1 if the named section's divider is not found.\n */\nexport function findSectionStartPos(editor: Editor, sectionId: string): number {\n\tif (sectionId === 'body') return 1;\n\tlet startPos = -1;\n\teditor.state.doc.descendants((node, pos) => {\n\t\tif (startPos !== -1) return false;\n\t\tif (\n\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t) {\n\t\t\tstartPos = pos + node.nodeSize; // position right after the divider\n\t\t}\n\t});\n\treturn startPos;\n}\n\n/**\n * Returns the ProseMirror position at the end of a named section's content:\n * - For `'body'`: position of the first section divider, or end of document.\n * - For a named section: position of the next divider, or end of document.\n */\nexport function findSectionEndPos(editor: Editor, sectionId: string): number {\n\tconst doc = editor.state.doc;\n\tconst docSize = doc.content.size;\n\n\tif (sectionId === 'body') {\n\t\tlet firstDividerPos = -1;\n\t\tdoc.descendants((node, pos) => {\n\t\t\tif (firstDividerPos !== -1) return false;\n\t\t\tif (node.type.name === 'sectionDivider') {\n\t\t\t\tfirstDividerPos = pos;\n\t\t\t}\n\t\t});\n\t\treturn firstDividerPos !== -1 ? firstDividerPos : docSize;\n\t}\n\n\tlet passedSection = false;\n\tlet nextDividerPos = -1;\n\tdoc.descendants((node, pos) => {\n\t\tif (nextDividerPos !== -1) return false;\n\t\tif (!passedSection) {\n\t\t\tif (\n\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t\t) {\n\t\t\t\tpassedSection = true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\tif (node.type.name === 'sectionDivider') {\n\t\t\tnextDividerPos = pos;\n\t\t}\n\t});\n\treturn nextDividerPos !== -1 ? nextDividerPos : docSize;\n}\n"],"names":["normalizeHtml","html","replace","toPortableHtml","div","document","createElement","innerHTML","p","Array","from","querySelectorAll","childNodes","length","appendChild","lastChild","HTMLBRElement","insertInlineHtml","editor","normalised","dom","slice","DOMParser","fromSchema","schema","parseSlice","size","to","state","selection","tr","replaceRange","view","dispatch","SECTION_DIVIDER_HTML","id","buildSectionedContent","body","sections","s","content","getBodyHtml","_a","extractAllSectionsFromHtml","get","getSectionsHtml","substring","Map","dividerRegex","dividers","match","exec","push","index","endIndex","set","i","start","end","extractSectionContent","startPos","findSectionStartPos","text","isEmpty","characterCount","endPos","findSectionEndPos","doc","container","serializer","DOMSerializer","serializeFragment","textContent","trim","setSectionContentInEditor","dividerHtml","commands","insertContentAt","updateSelection","fragment","parse","parseHtmlToNodes","replaceFrom","replaceWith","setMeta","extractBodyContent","extractActiveFormats","bold","isActive","italic","underline","strike","bulletList","orderedList","blockquote","codeBlock","link","href","getAttributes","$from","pos","linkMark","resolve","marks","find","m","type","name","_c","attrs","nodeBefore","markOnPrev","_b","textAlign","fontFamily","fontSize","color","highlight","_d","superscript","subscript","extractContent","getHTML","normalized","normalizeHardBreaks","node","textBetween","sectionId","descendants","nodeSize","docSize","firstDividerPos","passedSection","nextDividerPos"],"mappings":"+KAqBM,SAAUA,EAAcC,GAC7B,OAAOA,EACLC,QAAQ,mBAAoB,IAC5BA,QAAQ,sCAAuC,OAClD,CAYM,SAAUC,EAAeF,GAC9B,MAAMG,EAAMC,SAASC,cAAc,OACnCF,EAAIG,UAAYN,EAChB,IAAK,MAAMO,KAAKC,MAAMC,KAAKN,EAAIO,iBAAiB,MAAO,CACtD,GAA4B,IAAxBH,EAAEI,WAAWC,OAAc,CAC9BL,EAAEM,YAAYT,SAASC,cAAc,OACrC,QACA,CACYE,EAAEO,qBACKC,eAAiBR,EAAEI,WAAWC,OAAS,GAC1DL,EAAEM,YAAYT,SAASC,cAAc,MAEtC,C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D,EAAMjD,EAAOU,MAAMuC,IACnB+D,EAAU/D,EAAI3B,QAAQd,KAE5B,GAAkB,SAAdqG,EAAsB,CACzB,IAAII,GAAmB,EAOvB,OANAhE,EAAI6D,aAAY,CAACH,EAAMzB,KACtB,IAAyB,IAArB+B,EAAwB,OAAO,EACZ,mBAAnBN,EAAKnB,KAAKC,OACbwB,EAAkB/B,EAClB,KAE0B,IAArB+B,EAAyBA,EAAkBD,CAClD,CAED,IAAIE,GAAgB,EAChBC,GAAkB,EAgBtB,OAfAlE,EAAI6D,aAAY,CAACH,EAAMzB,KACE,IAApBiC,IACCD,OASkB,mBAAnBP,EAAKnB,KAAKC,OACb0B,EAAiBjC,KARG,mBAAnByB,EAAKnB,KAAKC,MACVkB,EAAKhB,MAAiB,YAAMkB,IAE5BK,GAAgB,IAEV,OAMkB,IAApBC,EAAwBA,EAAiBH,CACjD"}
1
+ {"version":3,"file":"BikEditor.utils.js","sources":["../../../src/editor/BikEditor.utils.ts"],"sourcesContent":["import { Editor } from '@tiptap/core';\nimport { DOMParser, DOMSerializer } from 'prosemirror-model';\nimport { EditorSnapshot, FormatState } from './BikEditor.types';\n\n// ---------------------------------------------------------------------------\n// HTML normalisation\n// ---------------------------------------------------------------------------\n\n/**\n * Normalise HTML before passing it to TipTap.\n *\n * 1. Strip all `<span>` tags first (keeps inner content). This exposes\n * bare `<br>` inside otherwise-empty paragraphs like Quill's\n * `<p><span class=\"ql-cursor\"><br></span></p>`.\n * 2. Then convert `<p><br></p>` → `<p></p>`. ProseMirror parses `<p></p>`\n * as an empty paragraph node and adds its own DOM `<br>` for cursor\n * positioning — one blank line, correct height. Leaving the `<br>`\n * would create a `hard_break` child AND the cursor `<br>`, producing\n * double-height blank lines.\n */\nexport function normalizeHtml(html: string): string {\n\treturn html\n\t\t.replace(/<\\/?span[^>]*>/gi, '')\n\t\t.replace(/(<p[^>]*>)\\s*<br\\s*\\/?>\\s*(<\\/p>)/gi, '$1$2');\n}\n\n/**\n * Convert ProseMirror's `<p></p>` empty paragraphs to the universally\n * rendered `<p><br></p>` format before the HTML leaves the editor.\n * Email clients, chat bubbles, and every renderer understand `<p><br></p>`\n * as a visible blank line, whereas `<p></p>` collapses to zero height.\n */\nexport function toPortableHtml(html: string): string {\n\treturn html.replace(/<p><\\/p>/g, '<p><br></p>');\n}\n\n// ---------------------------------------------------------------------------\n// Inline content insertion\n// ---------------------------------------------------------------------------\n\n/**\n * Insert HTML at the current cursor position, merging the first paragraph\n * inline while preserving the block structure of subsequent paragraphs/lists.\n *\n * Uses `parseSlice` which returns an open-ended Slice — the first block merges\n * at the cursor, middle blocks stay intact, and the last block merges with any\n * text that follows the cursor.\n */\nexport function insertInlineHtml(editor: Editor, html: string): void {\n\tconst normalised = normalizeHtml(html);\n\tconst dom = document.createElement('div');\n\tdom.innerHTML = normalised;\n\tconst slice = DOMParser.fromSchema(editor.schema).parseSlice(dom);\n\n\tif (slice.size === 0) return;\n\n\tconst { from, to } = editor.state.selection;\n\tconst tr = editor.state.tr.replaceRange(from, to, slice);\n\teditor.view.dispatch(tr);\n}\n\n// ---------------------------------------------------------------------------\n// Section divider HTML\n// ---------------------------------------------------------------------------\n\nexport const SECTION_DIVIDER_HTML = (id: string) =>\n\t`<div data-section-divider=\"${id}\" style=\"display:none;height:0;line-height:0;overflow:hidden;\"></div>`;\n\n/**\n * Build initial HTML for an editor with one or more named sections below the body.\n * Each section is separated by an invisible divider node.\n *\n * @example\n * buildSectionedContent('<p>Body</p>', [\n * { id: 'signature', content: '<p>Alice</p>' },\n * { id: 'forwarded', content: '<p>--- fwd ---</p>' },\n * ])\n */\nexport function buildSectionedContent(\n\tbody: string,\n\tsections: Array<{ id: string; content: string }>,\n): string {\n\tlet html = body;\n\tfor (const s of sections) {\n\t\thtml += SECTION_DIVIDER_HTML(s.id) + s.content;\n\t}\n\treturn html;\n}\n\n// ---------------------------------------------------------------------------\n// Section extraction\n// ---------------------------------------------------------------------------\n\n/**\n * Parse the editor HTML into a Map of sectionId → raw HTML string.\n * The special key `'body'` always holds the content before the first divider.\n * Map iteration order matches document order.\n */\nexport function extractAllSections(editor: Editor): Map<string, string> {\n\treturn extractAllSectionsFromHtml(editor.getHTML());\n}\n\n/**\n * Extract just the body portion (everything before the first section divider)\n * from an HTML string produced by BikEditor. Safe to call on plain HTML too —\n * returns the full string when no dividers are present.\n */\nexport function getBodyHtml(html: string): string {\n\tif (!html) return '';\n\tconst sections = extractAllSectionsFromHtml(html);\n\treturn sections.get('body') ?? html;\n}\n\n/**\n * Extract everything from the first section divider onward (dividers + their\n * content). Returns an empty string when there are no sections.\n */\nexport function getSectionsHtml(html: string): string {\n\tif (!html) return '';\n\tconst body = getBodyHtml(html);\n\treturn html.substring(body.length);\n}\n\nexport function extractAllSectionsFromHtml(html: string): Map<string, string> {\n\tconst sections = new Map<string, string>();\n\tconst dividerRegex =\n\t\t/<div[^>]*data-section-divider=\"([^\"]*)[^>]*>\\s*<\\/div>/g;\n\tconst dividers: Array<{ id: string; index: number; endIndex: number }> = [];\n\n\tlet match: RegExpExecArray | null;\n\twhile ((match = dividerRegex.exec(html)) !== null) {\n\t\tdividers.push({\n\t\t\tid: match[1],\n\t\t\tindex: match.index,\n\t\t\tendIndex: match.index + match[0].length,\n\t\t});\n\t}\n\n\tif (dividers.length === 0) {\n\t\tsections.set('body', html);\n\t\treturn sections;\n\t}\n\n\tsections.set('body', html.slice(0, dividers[0].index));\n\tfor (let i = 0; i < dividers.length; i++) {\n\t\tconst start = dividers[i].endIndex;\n\t\tconst end = i + 1 < dividers.length ? dividers[i + 1].index : html.length;\n\t\tsections.set(dividers[i].id, html.slice(start, end));\n\t}\n\n\treturn sections;\n}\n\n/** Returns BikEditorContent for a single named section (or 'body'). */\nexport function extractSectionContent(\n\teditor: Editor,\n\tid: string,\n): EditorSnapshot {\n\tconst startPos = findSectionStartPos(editor, id);\n\tif (startPos === -1)\n\t\treturn { html: '', text: '', isEmpty: true, characterCount: 0 };\n\tconst endPos = findSectionEndPos(editor, id);\n\tconst slice = editor.state.doc.slice(startPos, endPos);\n\tconst container = document.createElement('div');\n\tconst serializer = DOMSerializer.fromSchema(editor.schema);\n\tcontainer.appendChild(serializer.serializeFragment(slice.content));\n\tconst html = toPortableHtml(container.innerHTML);\n\tconst text = container.textContent ?? '';\n\treturn { html, text, isEmpty: !text.trim(), characterCount: text.length };\n}\n\n/**\n * Parse an HTML string into ProseMirror nodes using the editor's schema.\n */\nfunction parseHtmlToNodes(editor: Editor, html: string) {\n\tconst container = document.createElement('div');\n\tcontainer.innerHTML = html;\n\treturn DOMParser.fromSchema(editor.schema).parse(container).content;\n}\n\n/**\n * Replace the content of a single named section without touching others.\n * Uses a ProseMirror transaction to replace only the target range,\n * preserving undo history and other sections' state.\n * If the section doesn't exist yet, it is appended at the end of the document.\n */\nexport function setSectionContentInEditor(\n\teditor: Editor,\n\tid: string,\n\thtml: string,\n): void {\n\tconst startPos = findSectionStartPos(editor, id);\n\tif (startPos === -1) {\n\t\tconst endPos = editor.state.doc.content.size;\n\t\tconst dividerHtml = SECTION_DIVIDER_HTML(id) + html;\n\t\teditor.commands.insertContentAt(endPos, dividerHtml, {\n\t\t\tupdateSelection: false,\n\t\t});\n\t\treturn;\n\t}\n\tconst endPos = findSectionEndPos(editor, id);\n\tconst fragment = parseHtmlToNodes(editor, html);\n\tconst { tr } = editor.state;\n\t// For body, replace from position 0 (before the first paragraph's opening\n\t// boundary) so ProseMirror swaps entire block nodes cleanly. Position 1\n\t// (inside the paragraph) would force ProseMirror to close the open paragraph\n\t// first, creating a ghost empty <p></p>.\n\tconst replaceFrom = id === 'body' ? 0 : startPos;\n\ttr.replaceWith(replaceFrom, endPos, fragment);\n\ttr.setMeta('addToHistory', false);\n\teditor.view.dispatch(tr);\n}\n\n// ---------------------------------------------------------------------------\n// Convenience shorthands (body = first section)\n// ---------------------------------------------------------------------------\n\n/** Extract BikEditorContent for just the body (before the first divider). */\nexport function extractBodyContent(editor: Editor): EditorSnapshot {\n\treturn extractSectionContent(editor, 'body');\n}\n\n// ---------------------------------------------------------------------------\n// Active formats\n// ---------------------------------------------------------------------------\n\nexport function extractActiveFormats(editor: Editor): FormatState {\n\treturn {\n\t\tbold: editor.isActive('bold'),\n\t\titalic: editor.isActive('italic'),\n\t\tunderline: editor.isActive('underline'),\n\t\tstrike: editor.isActive('strike'),\n\t\tbulletList: editor.isActive('bulletList'),\n\t\torderedList: editor.isActive('orderedList'),\n\t\tblockquote: editor.isActive('blockquote'),\n\t\tcodeBlock: editor.isActive('codeBlock'),\n\t\tlink: (() => {\n\t\t\tif (editor.isActive('link')) {\n\t\t\t\treturn { href: editor.getAttributes('link')['href'] ?? '' };\n\t\t\t}\n\t\t\tconst { $from } = editor.state.selection;\n\t\t\tif ($from.pos > 0) {\n\t\t\t\tconst before = $from.doc.resolve($from.pos);\n\t\t\t\tconst linkMark = before.marks().find((m) => m.type.name === 'link');\n\t\t\t\tif (!linkMark) {\n\t\t\t\t\tconst nodeBefore = $from.nodeBefore;\n\t\t\t\t\tconst markOnPrev = nodeBefore?.marks.find(\n\t\t\t\t\t\t(m) => m.type.name === 'link',\n\t\t\t\t\t);\n\t\t\t\t\tif (markOnPrev) {\n\t\t\t\t\t\treturn { href: markOnPrev.attrs['href'] ?? '' };\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\treturn { href: linkMark.attrs['href'] ?? '' };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn null;\n\t\t})(),\n\t\ttextAlign: editor.isActive({ textAlign: 'center' })\n\t\t\t? 'center'\n\t\t\t: editor.isActive({ textAlign: 'right' })\n\t\t\t? 'right'\n\t\t\t: editor.isActive({ textAlign: 'justify' })\n\t\t\t? 'justify'\n\t\t\t: editor.isActive({ textAlign: 'left' })\n\t\t\t? 'left'\n\t\t\t: null,\n\t\tfontFamily: editor.getAttributes('textStyle')['fontFamily'] ?? null,\n\t\tfontSize: editor.getAttributes('textStyle')['fontSize'] ?? null,\n\t\tcolor: editor.getAttributes('textStyle')['color'] ?? null,\n\t\thighlight: editor.isActive('highlight')\n\t\t\t? editor.getAttributes('highlight')['color'] ?? 'default'\n\t\t\t: null,\n\t\tsuperscript: editor.isActive('superscript'),\n\t\tsubscript: editor.isActive('subscript'),\n\t};\n}\n\nexport function extractContent(editor: Editor): EditorSnapshot {\n\treturn {\n\t\thtml: toPortableHtml(editor.getHTML()),\n\t\ttext: editor.getText(),\n\t\tisEmpty: editor.isEmpty,\n\t\tcharacterCount:\n\t\t\teditor.storage.characterCount?.characters?.() ?? editor.getText().length,\n\t};\n}\n\n// ---------------------------------------------------------------------------\n// Section position helpers (used by insertAtSectionStart/End and appendBodyContent)\n// ---------------------------------------------------------------------------\n\n/**\n * Returns the ProseMirror position immediately after a section's opening divider\n * (i.e. the start of the section's own content).\n * For `'body'`, returns 1 (beginning of the document).\n * Returns -1 if the named section's divider is not found.\n */\nexport function findSectionStartPos(editor: Editor, sectionId: string): number {\n\tif (sectionId === 'body') return 1;\n\tlet startPos = -1;\n\teditor.state.doc.descendants((node, pos) => {\n\t\tif (startPos !== -1) return false;\n\t\tif (\n\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t) {\n\t\t\tstartPos = pos + node.nodeSize; // position right after the divider\n\t\t}\n\t});\n\treturn startPos;\n}\n\n/**\n * Returns the ProseMirror position at the end of a named section's content:\n * - For `'body'`: position of the first section divider, or end of document.\n * - For a named section: position of the next divider, or end of document.\n */\nexport function findSectionEndPos(editor: Editor, sectionId: string): number {\n\tconst doc = editor.state.doc;\n\tconst docSize = doc.content.size;\n\n\tif (sectionId === 'body') {\n\t\tlet firstDividerPos = -1;\n\t\tdoc.descendants((node, pos) => {\n\t\t\tif (firstDividerPos !== -1) return false;\n\t\t\tif (node.type.name === 'sectionDivider') {\n\t\t\t\tfirstDividerPos = pos;\n\t\t\t}\n\t\t});\n\t\treturn firstDividerPos !== -1 ? firstDividerPos : docSize;\n\t}\n\n\tlet passedSection = false;\n\tlet nextDividerPos = -1;\n\tdoc.descendants((node, pos) => {\n\t\tif (nextDividerPos !== -1) return false;\n\t\tif (!passedSection) {\n\t\t\tif (\n\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t\t) {\n\t\t\t\tpassedSection = true;\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\t\tif (node.type.name === 'sectionDivider') {\n\t\t\tnextDividerPos = pos;\n\t\t}\n\t});\n\treturn nextDividerPos !== -1 ? nextDividerPos : docSize;\n}\n"],"names":["normalizeHtml","html","replace","toPortableHtml","insertInlineHtml","editor","normalised","dom","document","createElement","innerHTML","slice","DOMParser","fromSchema","schema","parseSlice","size","from","to","state","selection","tr","replaceRange","view","dispatch","SECTION_DIVIDER_HTML","id","buildSectionedContent","body","sections","s","content","getBodyHtml","_a","extractAllSectionsFromHtml","get","getSectionsHtml","substring","length","Map","dividerRegex","dividers","match","exec","push","index","endIndex","set","i","start","end","extractSectionContent","startPos","findSectionStartPos","text","isEmpty","characterCount","endPos","findSectionEndPos","doc","container","serializer","DOMSerializer","appendChild","serializeFragment","textContent","trim","setSectionContentInEditor","dividerHtml","commands","insertContentAt","updateSelection","fragment","parse","parseHtmlToNodes","replaceFrom","replaceWith","setMeta","extractBodyContent","extractActiveFormats","bold","isActive","italic","underline","strike","bulletList","orderedList","blockquote","codeBlock","link","href","getAttributes","$from","pos","linkMark","resolve","marks","find","m","type","name","_c","attrs","nodeBefore","markOnPrev","_b","textAlign","fontFamily","fontSize","color","highlight","_d","superscript","subscript","extractContent","getHTML","getText","storage","characters","sectionId","descendants","node","nodeSize","docSize","firstDividerPos","passedSection","nextDividerPos"],"mappings":"+FAoBM,SAAUA,EAAcC,GAC7B,OAAOA,EACLC,QAAQ,mBAAoB,IAC5BA,QAAQ,sCAAuC,OAClD,CAQM,SAAUC,EAAeF,GAC9B,OAAOA,EAAKC,QAAQ,YAAa,cAClC,CAcgB,SAAAE,EAAiBC,EAAgBJ,GAChD,MAAMK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B,OANAjE,EAAI6D,aAAY,CAACC,EAAM5B,KACtB,IAAyB,IAArB+B,EAAwB,OAAO,EACZ,mBAAnBH,EAAKtB,KAAKC,OACbwB,EAAkB/B,EAClB,KAE0B,IAArB+B,EAAyBA,EAAkBD,CAClD,CAED,IAAIE,GAAgB,EAChBC,GAAkB,EAgBtB,OAfAnE,EAAI6D,aAAY,CAACC,EAAM5B,KACE,IAApBiC,IACCD,OASkB,mBAAnBJ,EAAKtB,KAAKC,OACb0B,EAAiBjC,KARG,mBAAnB4B,EAAKtB,KAAKC,MACVqB,EAAKnB,MAAiB,YAAMiB,IAE5BM,GAAgB,IAEV,OAMkB,IAApBC,EAAwBA,EAAiBH,CACjD"}
@@ -1,2 +1,2 @@
1
- import e from"@tiptap/extension-character-count";import o from"@tiptap/extension-color";import t from"@tiptap/extension-font-family";import n from"@tiptap/extension-highlight";import i from"@tiptap/extension-image";import r from"@tiptap/extension-link";import s from"@tiptap/extension-placeholder";import a from"@tiptap/extension-subscript";import m from"@tiptap/extension-superscript";import p from"@tiptap/extension-text-align";import{TextStyle as l}from"@tiptap/extension-text-style";import d from"@tiptap/extension-underline";import c from"@tiptap/starter-kit";import{FontSizeExtension as u}from"./FontSizeExtension.js";import{buildAgentMentionExtension as f,buildTeamMentionExtension as h}from"./mention/MentionExtension.js";import{PasteExtension as x}from"./paste/PasteExtension.js";import{PasteNormalizationExtension as g}from"./plainClipboard/PasteNormalizationExtension.js";import{SectionDividerNode as v}from"./sectionDivider/SectionDividerNode.js";import{SendShortcutExtension as S}from"./sendShortcut/SendShortcutExtension.js";import{buildSlashCommandExtension as k}from"./slashCommand/SlashCommandExtension.js";import{VariableDecorationExtension as C}from"./variable/VariableDecorationExtension.js";function M(M){var b,j,P,E,y,D,w,I,T;const z=null!==(j=null===(b=M.features)||void 0===b?void 0:b.richPaste)&&void 0!==j&&j,N=null!==(E=null===(P=M.features)||void 0===P?void 0:P.richTypography)&&void 0!==E&&E,O=null===(y=M.features)||void 0===y?void 0:y.allowedMarks,R=e=>!O||O.includes(e);return[...[c.configure({link:!1,underline:!1,bold:!!R("bold")&&{},italic:!!R("italic")&&{},strike:!!R("strike")&&{},code:!!R("code")&&{}}),...R("underline")?[d]:[],r.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),l,s.configure({placeholder:null!==(D=M.placeholder)&&void 0!==D?D:"Type a message..."}),...M.onPaste?[x.configure({onPaste:M.onPaste})]:[],g.configure({preserveMarks:z}),S.configure({onSend:M.onSend,sendShortcut:M.sendShortcut,extraShortcuts:null!==(w=M.shortcuts)&&void 0!==w?w:[]}),C,...M.maxCharacters?[e.configure({limit:M.maxCharacters})]:[],v],...[...(null===(I=M.mentions)||void 0===I?void 0:I.agents)?[f(M.mentions.agents,M.onMentionSelected,M.renderMentionItem,M.renderMentionDropdown)]:[],...(null===(T=M.mentions)||void 0===T?void 0:T.teams)?[h(M.mentions.teams,M.onMentionSelected,M.renderMentionItem,M.renderMentionDropdown)]:[],...M.slashCommands?[k(M.slashCommands,M.onSlashCommandSelected,M.renderSlashCommandItem,M.renderSlashCommandDropdown)]:[]],...N?[o,n.configure({multicolor:!0}),t,u,p.configure({types:["heading","paragraph"]}),a,m,i]:[o]]}export{M as buildExtensions};
1
+ import o from"@tiptap/extension-character-count";import e from"@tiptap/extension-color";import t from"@tiptap/extension-font-family";import n from"@tiptap/extension-highlight";import i from"@tiptap/extension-image";import r from"@tiptap/extension-link";import a from"@tiptap/extension-placeholder";import s from"@tiptap/extension-subscript";import m from"@tiptap/extension-superscript";import p from"@tiptap/extension-text-align";import{TextStyle as l}from"@tiptap/extension-text-style";import d from"@tiptap/extension-underline";import c from"@tiptap/starter-kit";import{FontSizeExtension as u}from"./FontSizeExtension.js";import{buildAgentMentionExtension as f,buildTeamMentionExtension as h}from"./mention/MentionExtension.js";import{PasteExtension as x}from"./paste/PasteExtension.js";import{ClipboardNormalizationExtension as g}from"./plainClipboard/ClipboardNormalizationExtension.js";import{PlainClipboardExtension as v}from"./plainClipboard/PlainClipboardExtension.js";import{SectionDividerNode as S}from"./sectionDivider/SectionDividerNode.js";import{SendShortcutExtension as C}from"./sendShortcut/SendShortcutExtension.js";import{buildSlashCommandExtension as b}from"./slashCommand/SlashCommandExtension.js";import{VariableDecorationExtension as k}from"./variable/VariableDecorationExtension.js";function j(j){var M,E,P,y,D,w,I,T,z;const N=null!==(E=null===(M=j.features)||void 0===M?void 0:M.richPaste)&&void 0!==E&&E,O=null!==(y=null===(P=j.features)||void 0===P?void 0:P.richTypography)&&void 0!==y&&y,R=null===(D=j.features)||void 0===D?void 0:D.allowedMarks,A=o=>!R||R.includes(o);return[...[c.configure({link:!1,underline:!1,bold:!!A("bold")&&{},italic:!!A("italic")&&{},strike:!!A("strike")&&{},code:!!A("code")&&{}}),...A("underline")?[d]:[],r.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),l,a.configure({placeholder:null!==(w=j.placeholder)&&void 0!==w?w:"Type a message..."}),...j.onPaste?[x.configure({onPaste:j.onPaste})]:[],...N?[g]:[v],C.configure({onSend:j.onSend,sendShortcut:j.sendShortcut,extraShortcuts:null!==(I=j.shortcuts)&&void 0!==I?I:[]}),k,...j.maxCharacters?[o.configure({limit:j.maxCharacters})]:[],S],...[...(null===(T=j.mentions)||void 0===T?void 0:T.agents)?[f(j.mentions.agents,j.onMentionSelected,j.renderMentionItem,j.renderMentionDropdown)]:[],...(null===(z=j.mentions)||void 0===z?void 0:z.teams)?[h(j.mentions.teams,j.onMentionSelected,j.renderMentionItem,j.renderMentionDropdown)]:[],...j.slashCommands?[b(j.slashCommands,j.onSlashCommandSelected,j.renderSlashCommandItem,j.renderSlashCommandDropdown)]:[]],...O?[e,n.configure({multicolor:!0}),t,u,p.configure({types:["heading","paragraph"]}),s,m,i]:[e]]}export{j as buildExtensions};
2
2
  //# 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 Highlight from '@tiptap/extension-highlight';\nimport Image from '@tiptap/extension-image';\nimport Link from '@tiptap/extension-link';\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 type {\n\tEditorFeatures,\n\tEditorSnapshot,\n\tKeyboardShortcut,\n\tMentionDropdownRenderProps,\n\tMentionItem,\n\tPasteData,\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../BikEditor.types';\nimport { FontSizeExtension } from './FontSizeExtension';\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\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\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\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\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\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\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\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}),\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...(config.maxCharacters\n\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\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),\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),\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","hasRichPaste","_b","_a","features","richPaste","hasRichTypography","_d","_c","richTypography","allowedMarks","_e","isMark","m","includes","StarterKit","configure","link","underline","bold","italic","strike","code","Underline","Link","extend","addPasteRules","addInputRules","openOnClick","autolink","linkOnPaste","HTMLAttributes","rel","class","TextStyle","Placeholder","placeholder","_f","onPaste","PasteExtension","PasteNormalizationExtension","preserveMarks","SendShortcutExtension","onSend","sendShortcut","extraShortcuts","_g","shortcuts","VariableDecorationExtension","maxCharacters","CharacterCount","limit","SectionDividerNode","_h","mentions","agents","buildAgentMentionExtension","onMentionSelected","renderMentionItem","renderMentionDropdown","_j","teams","buildTeamMentionExtension","slashCommands","buildSlashCommandExtension","onSlashCommandSelected","renderSlashCommandItem","renderSlashCommandDropdown","Color","Highlight","multicolor","FontFamily","FontSizeExtension","TextAlign","types","Subscript","Superscript","Image"],"mapp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D,EAAO0D,kBACP1D,EAAO2D,wBAGR,eACCC,EAAA5D,EAAOsD,+BAAUO,OAClB,CACAC,EACC9D,EAAOsD,SAASO,MAChB7D,EAAOyD,kBACPzD,EAAO0D,kBACP1D,EAAO2D,wBAGR,MACC3D,EAAO+D,cACR,CACAC,EACChE,EAAO+D,cACP/D,EAAOiE,uBACPjE,EAAOkE,uBACPlE,EAAOmE,6BAGR,OAGmB7D,EACpB,CACA8D,EACAC,EAAUrD,UAAU,CAAEsD,YAAY,IAClCC,EACAC,EACAC,EAAUzD,UAAU,CAAE0D,MAAO,CAAC,UAAW,eACzCC,EACAC,EACAC,GAEA,CAACT,GAGL"}
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 Highlight from '@tiptap/extension-highlight';\nimport Image from '@tiptap/extension-image';\nimport Link from '@tiptap/extension-link';\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 type {\n\tEditorFeatures,\n\tEditorSnapshot,\n\tKeyboardShortcut,\n\tMentionDropdownRenderProps,\n\tMentionItem,\n\tPasteData,\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../BikEditor.types';\nimport { FontSizeExtension } from './FontSizeExtension';\nimport {\n\tbuildAgentMentionExtension,\n\tbuildTeamMentionExtension,\n} from './mention/MentionExtension';\nimport { PasteExtension } from './paste/PasteExtension';\nimport { ClipboardNormalizationExtension } from './plainClipboard/ClipboardNormalizationExtension';\nimport { PlainClipboardExtension } from './plainClipboard/PlainClipboardExtension';\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\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\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\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\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\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\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\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\t// Non-rich editors: strip rich marks + normalize blanks on paste.\n\t\t// Rich editors (email): only normalize blanks (fix Google Docs spacing).\n\t\t...(!hasRichPaste\n\t\t\t? [PlainClipboardExtension]\n\t\t\t: [ClipboardNormalizationExtension]),\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...(config.maxCharacters\n\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\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),\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),\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","hasRichPaste","_b","_a","features","richPaste","hasRichTypography","_d","_c","richTypography","allowedMarks","_e","isMark","m","includes","StarterKit","configure","link","underline","bold","italic","strike","code","Underline","Link","extend","addPasteRules","addInputRules","openOnClick","autolink","linkOnPaste","HTMLAttributes","rel","class","TextStyle","Placeholder","placeholder","_f","onPaste","PasteExtension","ClipboardNormalizationExtension","PlainClipboardExtension","SendShortcutExtension","onSend","sendShortcut","extraShortcuts","_g","shortcuts","VariableDecorationExtension","maxCharacters","CharacterCount","limit","SectionDividerNode","_h","mentions","agents","buildAgentMentionExtension","onMentionSelected","renderMentionItem","renderMentionDropdown","_j","teams","buildTeamMentionExtension","slashCommands","buildSlashCommandExtension","onSlashCommandSelected","renderSlashCommandItem","renderSlashCommandDropdown","Color","Highlight","multicolor","FontFamily","FontSizeExtension","TextAlign","types","Subscript","Superscript","Image"],"mappings":"0xCAqEM,SAAUA,EAAgBC,yBAC/B,MAAMC,EAA6C,QAA9BC,EAAiB,QAAjBC,EAAAH,EAAOI,gBAAU,IAAAD,OAAA,EAAAA,EAAAE,iBAAa,IAAAH,GAAAA,EAC7CI,EAAuD,QAAnCC,EAAiB,QAAjBC,EAAAR,EAAOI,gBAAU,IAAAI,OAAA,EAAAA,EAAAC,sBAAkB,IAAAF,GAAAA,EAKvDG,EAA8B,QAAfC,EAAAX,EAAOI,gBAAQ,IAAAO,OAAA,EAAAA,EAAED,aAChCE,EAAUC,IACdH,GAAgBA,EAAaI,SAASD,GA0GxC,MAAO,IAxGM,CAIZE,EAAWC,UAAU,CACpBC,MAAM,EACNC,WAAW,EACXC,OAAMP,EAAO,SAAU,CAAE,EACzBQ,SAAQR,EAAO,WAAY,CAAE,EAC7BS,SAAQT,EAAO,WAAY,CAAE,EAC7BU,OAAMV,EAAO,SAAU,CAAE,OAEtBA,EAAO,aAAe,CAACW,GAAa,GAGxCC,EAAKC,OAAO,CACXC,cAAeA,IAAM,GACrBC,cAAeA,IAAM,KACnBX,UAAU,CACZY,aAAa,EACbC,UAAU,EACVC,aAAa,EACbC,eAAgB,CACfC,IAAK,sBACLC,MAAO,cAGTC,EACAC,EAAYnB,UAAU,CACrBoB,oBAAaC,EAAArC,EAAOoC,2BAAe,yBAKhCpC,EAAOsC,QACR,CAACC,EAAevB,UAAU,CAAEsB,QAAStC,EAAOsC,WAC5C,MAGErC,EAEF,CAACuC,GADD,CAACC,GAEJC,EAAsB1B,UAAU,CAC/B2B,OAAQ3C,EAAO2C,OACfC,aAAc5C,EAAO4C,aACrBC,uBAAgBC,EAAA9C,EAAO+C,yBAAa,KAErCC,KACIhD,EAAOiD,cACR,CAACC,EAAelC,UAAU,CAAEmC,MAAOnD,EAAOiD,iBAC1C,GAKHG,MAGyB,aACrBC,EAAArD,EAAOsD,+BAAUC,QAClB,CACAC,EACCxD,EAAOsD,SAASC,OAChBvD,EAAOyD,kBACPzD,EAAO0D,kBACP1D,EAAO2D,wBAGR,eACCC,EAAA5D,EAAOsD,+BAAUO,OAClB,CACAC,EACC9D,EAAOsD,SAASO,MAChB7D,EAAOyD,kBACPzD,EAAO0D,kBACP1D,EAAO2D,wBAGR,MACC3D,EAAO+D,cACR,CACAC,EACChE,EAAO+D,cACP/D,EAAOiE,uBACPjE,EAAOkE,uBACPlE,EAAOmE,6BAGR,OAGmB7D,EACpB,CACA8D,EACAC,EAAUrD,UAAU,CAAEsD,YAAY,IAClCC,EACAC,EACAC,EAAUzD,UAAU,CAAE0D,MAAO,CAAC,UAAW,eACzCC,EACAC,EACAC,GAEA,CAACT,GAGL"}
@@ -0,0 +1,2 @@
1
+ import{Extension as t}from"../../../node_modules/@tiptap/core/dist/index.js";import{DOMParser as e,Slice as r}from"@tiptap/pm/model";import{Plugin as o}from"@tiptap/pm/state";import{BLOCK_SELECTOR as i,cleanBlockBrs as a,normalizeBlanks as n}from"./pasteUtils.js";const l=t.create({name:"clipboardNormalization",addProseMirrorPlugins:()=>[new o({props:{handlePaste(t,o){var l,p,d;if(null===(p=null===(l=o.clipboardData)||void 0===l?void 0:l.files)||void 0===p?void 0:p.length)return!1;const s=null===(d=o.clipboardData)||void 0===d?void 0:d.getData("text/html");if(!s)return!1;if(s.includes("data-pm-slice"))return!1;const c=document.createElement("div");if(c.innerHTML=s,!c.querySelector(i))return!1;a(c);const m=t.state.schema,u=e.fromSchema(m).parseSlice(c),f=n(u.content),v=new r(f,u.openStart,u.openEnd);return t.dispatch(t.state.tr.replaceSelection(v)),!0}}})]});export{l as ClipboardNormalizationExtension};
2
+ //# sourceMappingURL=ClipboardNormalizationExtension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClipboardNormalizationExtension.js","sources":["../../../../../src/editor/extensions/plainClipboard/ClipboardNormalizationExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { DOMParser as ProseMirrorDOMParser, Slice } from '@tiptap/pm/model';\nimport { Plugin } from '@tiptap/pm/state';\nimport { BLOCK_SELECTOR, cleanBlockBrs, normalizeBlanks } from './pasteUtils';\n\n/**\n * Lightweight paste normalizer for rich-paste editors (email).\n * Fixes Google Docs' standalone `<br>` between paragraphs and collapses\n * consecutive empty paragraphs — but keeps ALL formatting marks intact.\n */\nexport const ClipboardNormalizationExtension = Extension.create({\n\tname: 'clipboardNormalization',\n\taddProseMirrorPlugins() {\n\t\treturn [\n\t\t\tnew Plugin({\n\t\t\t\tprops: {\n\t\t\t\t\thandlePaste(_view, event) {\n\t\t\t\t\t\tif (event.clipboardData?.files?.length) return false;\n\t\t\t\t\t\tconst html = event.clipboardData?.getData('text/html');\n\t\t\t\t\t\tif (!html) return false;\n\t\t\t\t\t\tif (html.includes('data-pm-slice')) return false;\n\n\t\t\t\t\t\tconst container = document.createElement('div');\n\t\t\t\t\t\tcontainer.innerHTML = html;\n\t\t\t\t\t\tif (!container.querySelector(BLOCK_SELECTOR)) return false;\n\n\t\t\t\t\t\tcleanBlockBrs(container);\n\t\t\t\t\t\tconst schema = _view.state.schema;\n\t\t\t\t\t\tconst parsed =\n\t\t\t\t\t\t\tProseMirrorDOMParser.fromSchema(schema).parseSlice(container);\n\t\t\t\t\t\tconst cleaned = normalizeBlanks(parsed.content);\n\t\t\t\t\t\tconst slice = new Slice(cleaned, parsed.openStart, parsed.openEnd);\n\t\t\t\t\t\t_view.dispatch(_view.state.tr.replaceSelection(slice));\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t];\n\t},\n});\n"],"names":["ClipboardNormalizationExtension","Extension","create","name","addProseMirrorPlugins","Plugin","props","handlePaste","_view","event","_b","clipboardData","_a","files","length","html","_c","getData","includes","container","document","createElement","innerHTML","querySelector","BLOCK_SELECTOR","cleanBlockBrs","schema","state","parsed","ProseMirrorDOMParser","fromSchema","parseSlice","cleaned","normalizeBlanks","content","slice","Slice","openStart","openEnd","dispatch","tr","replaceSelection"],"mappings":"8QAUaA,EAAkCC,EAAUC,OAAO,CAC/DC,KAAM,yBACNC,sBAAqBA,IACb,CACN,IAAIC,EAAO,CACVC,MAAO,CACNC,YAAYC,EAAOC,aAClB,WAAIC,EAAqB,UAArBD,EAAME,qBAAe,IAAAC,OAAA,EAAAA,EAAAC,4BAAOC,OAAQ,OAAO,EAC/C,MAAMC,EAA0B,QAAnBC,EAAAP,EAAME,qBAAa,IAAAK,OAAA,EAAAA,EAAEC,QAAQ,aAC1C,IAAKF,EAAM,OAAO,EAClB,GAAIA,EAAKG,SAAS,iBAAkB,OAAO,EAE3C,MAAMC,EAAYC,SAASC,cAAc,OAEzC,GADAF,EAAUG,UAAYP,GACjBI,EAAUI,cAAcC,GAAiB,OAAO,EAErDC,EAAcN,GACd,MAAMO,EAASlB,EAAMmB,MAAMD,OACrBE,EACLC,EAAqBC,WAAWJ,GAAQK,WAAWZ,GAC9Ca,EAAUC,EAAgBL,EAAOM,SACjCC,EAAQ,IAAIC,EAAMJ,EAASJ,EAAOS,UAAWT,EAAOU,SAE1D,OADA9B,EAAM+B,SAAS/B,EAAMmB,MAAMa,GAAGC,iBAAiBN,KACxC,CACR"}
@@ -0,0 +1,2 @@
1
+ import{Extension as t}from"../../../node_modules/@tiptap/core/dist/index.js";import{DOMParser as e,Slice as r,Fragment as a}from"@tiptap/pm/model";import{Plugin as o}from"@tiptap/pm/state";import{BLOCK_SELECTOR as i,cleanBlockBrs as n,normalizeBlanks as l,stripRichMarks as p}from"./pasteUtils.js";const d=t.create({name:"plainClipboard",addProseMirrorPlugins:()=>[new o({props:{handlePaste(t,o){var d,s,c,m;if(null===(s=null===(d=o.clipboardData)||void 0===d?void 0:d.files)||void 0===s?void 0:s.length)return!1;const u=null===(c=o.clipboardData)||void 0===c?void 0:c.getData("text/html"),f=null===(m=o.clipboardData)||void 0===m?void 0:m.getData("text/plain");if(!f)return!1;if(null==u?void 0:u.includes("data-pm-slice"))return!1;const v=t.state.schema;if(u){const a=document.createElement("div");a.innerHTML=u;if(a.querySelector(i)){n(a);const o=e.fromSchema(v).parseSlice(a),i=l(p(o.content)),d=new r(i,o.openStart,o.openEnd);return t.dispatch(t.state.tr.replaceSelection(d)),!0}}const h=f.split("\n").map((t=>v.node("paragraph",null,t?[v.text(t)]:[]))),S=new r(a.fromArray(h),1,1);return t.dispatch(t.state.tr.replaceSelection(S)),!0}}})]});export{d as PlainClipboardExtension};
2
+ //# sourceMappingURL=PlainClipboardExtension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlainClipboardExtension.js","sources":["../../../../../src/editor/extensions/plainClipboard/PlainClipboardExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport {\n\tFragment,\n\tDOMParser as ProseMirrorDOMParser,\n\tSlice,\n} from '@tiptap/pm/model';\nimport { Plugin } from '@tiptap/pm/state';\nimport {\n\tBLOCK_SELECTOR,\n\tcleanBlockBrs,\n\tnormalizeBlanks,\n\tstripRichMarks,\n} from './pasteUtils';\n\nexport const PlainClipboardExtension = Extension.create({\n\tname: 'plainClipboard',\n\taddProseMirrorPlugins() {\n\t\treturn [\n\t\t\tnew Plugin({\n\t\t\t\tprops: {\n\t\t\t\t\thandlePaste(_view, event) {\n\t\t\t\t\t\tif (event.clipboardData?.files?.length) return false;\n\t\t\t\t\t\tconst html = event.clipboardData?.getData('text/html');\n\t\t\t\t\t\tconst text = event.clipboardData?.getData('text/plain');\n\t\t\t\t\t\tif (!text) return false;\n\n\t\t\t\t\t\tif (html?.includes('data-pm-slice')) return false;\n\n\t\t\t\t\t\tconst schema = _view.state.schema;\n\n\t\t\t\t\t\tif (html) {\n\t\t\t\t\t\t\tconst container = document.createElement('div');\n\t\t\t\t\t\t\tcontainer.innerHTML = html;\n\t\t\t\t\t\t\tconst hasBlocks = container.querySelector(BLOCK_SELECTOR);\n\t\t\t\t\t\t\tif (hasBlocks) {\n\t\t\t\t\t\t\t\tcleanBlockBrs(container);\n\t\t\t\t\t\t\t\tconst parsed =\n\t\t\t\t\t\t\t\t\tProseMirrorDOMParser.fromSchema(schema).parseSlice(container);\n\t\t\t\t\t\t\t\tconst cleaned = normalizeBlanks(stripRichMarks(parsed.content));\n\t\t\t\t\t\t\t\tconst slice = new Slice(\n\t\t\t\t\t\t\t\t\tcleaned,\n\t\t\t\t\t\t\t\t\tparsed.openStart,\n\t\t\t\t\t\t\t\t\tparsed.openEnd,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t_view.dispatch(_view.state.tr.replaceSelection(slice));\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst paragraphs = text\n\t\t\t\t\t\t\t.split('\\n')\n\t\t\t\t\t\t\t.map((line) =>\n\t\t\t\t\t\t\t\tschema.node('paragraph', null, line ? [schema.text(line)] : []),\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\tconst slice = new Slice(Fragment.fromArray(paragraphs), 1, 1);\n\t\t\t\t\t\t_view.dispatch(_view.state.tr.replaceSelection(slice));\n\t\t\t\t\t\treturn true;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t}),\n\t\t];\n\t},\n});\n"],"names":["PlainClipboardExtension","Extension","create","name","addProseMirrorPlugins","Plugin","props","handlePaste","_view","event","_b","clipboardData","_a","files","length","html","_c","getData","text","_d","includes","schema","state","container","document","createElement","innerHTML","querySelector","BLOCK_SELECTOR","cleanBlockBrs","parsed","ProseMirrorDOMParser","fromSchema","parseSlice","cleaned","normalizeBlanks","stripRichMarks","content","slice","Slice","openStart","openEnd","dispatch","tr","replaceSelection","paragraphs","split","map","line","node","Fragment","fromArray"],"mappings":"gTAcaA,EAA0BC,EAAUC,OAAO,CACvDC,KAAM,iBACNC,sBAAqBA,IACb,CACN,IAAIC,EAAO,CACVC,MAAO,CACNC,YAAYC,EAAOC,eAClB,WAAIC,EAAqB,UAArBD,EAAME,qBAAe,IAAAC,OAAA,EAAAA,EAAAC,4BAAOC,OAAQ,OAAO,EAC/C,MAAMC,EAA0B,QAAnBC,EAAAP,EAAME,qBAAa,IAAAK,OAAA,EAAAA,EAAEC,QAAQ,aACpCC,EAA0B,QAAnBC,EAAAV,EAAME,qBAAa,IAAAQ,OAAA,EAAAA,EAAEF,QAAQ,cAC1C,IAAKC,EAAM,OAAO,EAElB,GAAIH,aAAI,EAAJA,EAAMK,SAAS,iBAAkB,OAAO,EAE5C,MAAMC,EAASb,EAAMc,MAAMD,OAE3B,GAAIN,EAAM,CACT,MAAMQ,EAAYC,SAASC,cAAc,OACzCF,EAAUG,UAAYX,EAEtB,GADkBQ,EAAUI,cAAcC,GAC3B,CACdC,EAAcN,GACd,MAAMO,EACLC,EAAqBC,WAAWX,GAAQY,WAAWV,GAC9CW,EAAUC,EAAgBC,EAAeN,EAAOO,UAChDC,EAAQ,IAAIC,EACjBL,EACAJ,EAAOU,UACPV,EAAOW,SAGR,OADAjC,EAAMkC,SAASlC,EAAMc,MAAMqB,GAAGC,iBAAiBN,KACxC,CACP,CACD,CAED,MAAMO,EAAa3B,EACjB4B,MAAM,MACNC,KAAKC,GACL3B,EAAO4B,KAAK,YAAa,KAAMD,EAAO,CAAC3B,EAAOH,KAAK8B,IAAS,MAExDV,EAAQ,IAAIC,EAAMW,EAASC,UAAUN,GAAa,EAAG,GAE3D,OADArC,EAAMkC,SAASlC,EAAMc,MAAMqB,GAAGC,iBAAiBN,KACxC,CACR"}
@@ -1,2 +1,2 @@
1
- import{Fragment as e,Slice as t}from"@tiptap/pm/model";const n=new Set(["P","LI","H1","H2","H3","H4","H5","H6","TD","TH","PRE"]),r="p,div,h1,h2,h3,h4,h5,h6,ul,ol,li,blockquote,table,pre",o=new Set(["bold","italic","strike","underline","code"]);function l(e){if(e.querySelector(r))return;const t=Array.from(e.childNodes),n=[[]];for(let e=0;e<t.length;e++){const r=t[e];r instanceof HTMLBRElement&&t[e+1]instanceof HTMLBRElement?(n.push([]),e++):n[n.length-1].push(r)}for(;e.firstChild;)e.firstChild.remove();for(const t of n){const n=document.createElement("p");for(const e of t)n.appendChild(e);e.appendChild(n)}}function a(e){const t=Array.from(e.querySelectorAll("br"));for(const r of t){let t=!1,o=r.parentElement;for(;o&&o!==e;){if(n.has(o.tagName)){t=!0;break}o=o.parentElement}t||r.parentElement.replaceChild(document.createElement("p"),r)}}function c(e){for(const t of["p","div"])for(const n of Array.from(e.querySelectorAll(t))){const e=n.lastElementChild;"BR"===(null==e?void 0:e.tagName)&&n.childNodes.length>1&&e.remove()}}function i(t){const n=[];return t.forEach((t=>{var r,o;if("paragraph"===t.type.name){if(1===t.childCount&&"hardBreak"===(null===(r=t.firstChild)||void 0===r?void 0:r.type.name))return void n.push(t.type.create(t.attrs));if(t.childCount>1&&"hardBreak"===(null===(o=t.lastChild)||void 0===o?void 0:o.type.name)){const r=[];return t.content.forEach(((e,n,o)=>{o<t.childCount-1&&r.push(e)})),void n.push(t.copy(e.from(r)))}}t.isBlock&&!t.isLeaf?n.push(t.copy(i(t.content))):n.push(t)})),e.from(n)}function s(t){const n=[];return t.forEach((e=>{if(e.isText){const t=e.marks.filter((e=>o.has(e.type.name)));n.push(t.length===e.marks.length?e:e.mark(t))}else n.push(e.copy(s(e.content)))})),e.from(n)}function h(n,r){const o=n.split("\n").map((e=>r.node("paragraph",null,e?[r.text(e)]:[])));return new t(e.fromArray(o),1,1)}function p(n,r){const o=n.replace(/\n+$/,"");if(!o)return new t(e.from(r.node("paragraph",null,[])),1,1);const l=r.nodes.hardBreak,a=o.split("\n"),c=[];return a.forEach(((e,t)=>{e&&c.push(r.text(e)),t<a.length-1&&l&&c.push(l.create())})),new t(e.from(r.node("paragraph",null,c.length?c:[])),1,1)}export{r as BLOCK_SELECTOR,n as TEXTBLOCK_TAGS,a as cleanBlockBrs,i as normalizeHardBreaks,h as parseClipboardText,p as parseClipboardTextAsBreaks,s as stripRichMarks,c as stripTrailingBrs,l as wrapInlineContent};
1
+ import{Fragment as e}from"@tiptap/pm/model";const t=new Set(["P","LI","H1","H2","H3","H4","H5","H6","TD","TH","PRE"]),r="p,div,h1,h2,h3,h4,h5,h6,ul,ol,li,blockquote,table,pre",n=new Set(["bold","italic","strike","underline","code"]);function o(e){const r=Array.from(e.querySelectorAll("br"));for(const n of r){let r=!1,o=n.parentElement;for(;o&&o!==e;){if(t.has(o.tagName)){r=!0;break}o=o.parentElement}r||n.parentElement.replaceChild(document.createElement("p"),n)}}function a(t){const r=[];let n=!1;return t.forEach((e=>{var t;if("paragraph"===e.type.name&&1===e.childCount&&"hardBreak"===(null===(t=e.firstChild)||void 0===t?void 0:t.type.name))return n||r.push(e.type.create(e.attrs)),void(n=!0);const o="paragraph"===e.type.name&&0===e.childCount;o&&n||(n=o,e.isBlock&&!e.isLeaf?r.push(e.copy(a(e.content))):r.push(e))})),e.from(r)}function l(t){const r=[];return t.forEach((e=>{if(e.isText){const t=e.marks.filter((e=>n.has(e.type.name)));r.push(t.length===e.marks.length?e:e.mark(t))}else r.push(e.copy(l(e.content)))})),e.from(r)}export{r as BLOCK_SELECTOR,t as TEXTBLOCK_TAGS,o as cleanBlockBrs,a as normalizeBlanks,l as stripRichMarks};
2
2
  //# sourceMappingURL=pasteUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"pasteUtils.js","sources":["../../../../../src/editor/extensions/plainClipboard/pasteUtils.ts"],"sourcesContent":["import { Fragment, Node as PMNode, Schema, Slice } from '@tiptap/pm/model';\n\nexport const TEXTBLOCK_TAGS = new Set([\n\t'P',\n\t'LI',\n\t'H1',\n\t'H2',\n\t'H3',\n\t'H4',\n\t'H5',\n\t'H6',\n\t'TD',\n\t'TH',\n\t'PRE',\n]);\n\nexport const BLOCK_SELECTOR =\n\t'p,div,h1,h2,h3,h4,h5,h6,ul,ol,li,blockquote,table,pre';\n\nconst BASIC_MARKS = new Set(['bold', 'italic', 'strike', 'underline', 'code']);\n\n/**\n * When pasted HTML is entirely inline (no block elements), split at\n * `<br><br>` boundaries into `<p>` elements. Single `<br>` stays as a\n * line break inside the paragraph.\n */\nexport function wrapInlineContent(container: HTMLElement): void {\n\tif (container.querySelector(BLOCK_SELECTOR)) return;\n\n\tconst children = Array.from(container.childNodes);\n\tconst groups: Node[][] = [[]];\n\n\tfor (let i = 0; i < children.length; i++) {\n\t\tconst node = children[i];\n\t\tif (\n\t\t\tnode instanceof HTMLBRElement &&\n\t\t\tchildren[i + 1] instanceof HTMLBRElement\n\t\t) {\n\t\t\tgroups.push([]);\n\t\t\ti++;\n\t\t\tcontinue;\n\t\t}\n\t\tgroups[groups.length - 1].push(node);\n\t}\n\n\twhile (container.firstChild) container.firstChild.remove();\n\n\tfor (const group of groups) {\n\t\tconst p = document.createElement('p');\n\t\tfor (const node of group) p.appendChild(node);\n\t\tcontainer.appendChild(p);\n\t}\n}\n\n/**\n * Replace `<br>` elements that sit at block level (not inside a textblock\n * like `<p>`, `<li>`, etc.) with empty `<p></p>` elements. Google Docs\n * puts standalone `<br>` tags between paragraphs to represent blank lines.\n */\nexport function cleanBlockBrs(container: HTMLElement): void {\n\tconst brs = Array.from(container.querySelectorAll('br'));\n\tfor (const br of brs) {\n\t\tlet insideTextblock = false;\n\t\tlet el = br.parentElement;\n\t\twhile (el && el !== container) {\n\t\t\tif (TEXTBLOCK_TAGS.has(el.tagName)) {\n\t\t\t\tinsideTextblock = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tel = el.parentElement;\n\t\t}\n\t\tif (!insideTextblock) {\n\t\t\tbr.parentElement!.replaceChild(document.createElement('p'), br);\n\t\t}\n\t}\n}\n\n/**\n * Strip trailing `<br>` from content paragraphs in the DOM.\n * Google Docs adds a `<br>` at the end of non-empty paragraphs as a cursor\n * placeholder. Without this, ProseMirror creates a trailing hardBreak that\n * adds a visual blank line at the bottom of the paragraph.\n */\nexport function stripTrailingBrs(container: HTMLElement): void {\n\tfor (const tag of ['p', 'div']) {\n\t\tfor (const el of Array.from(container.querySelectorAll(tag))) {\n\t\t\tconst last = el.lastElementChild;\n\t\t\tif (last?.tagName === 'BR' && el.childNodes.length > 1) {\n\t\t\t\tlast.remove();\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Convert paragraphs containing only a hardBreak into truly empty paragraphs.\n * Google Docs represents blank lines as `<p><br></p>` — ProseMirror parses\n * the `<br>` as a hardBreak node, which renders double-height. Converting to\n * an empty paragraph (childCount 0) gives a single-height blank line.\n *\n * Does NOT collapse consecutive empties — that would destroy user intent.\n */\nexport function normalizeHardBreaks(fragment: Fragment): Fragment {\n\tconst nodes: PMNode[] = [];\n\tfragment.forEach((node) => {\n\t\tif (node.type.name === 'paragraph') {\n\t\t\tif (node.childCount === 1 && node.firstChild?.type.name === 'hardBreak') {\n\t\t\t\tnodes.push(node.type.create(node.attrs));\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (node.childCount > 1 && node.lastChild?.type.name === 'hardBreak') {\n\t\t\t\tconst children: PMNode[] = [];\n\t\t\t\tnode.content.forEach((child, _offset, index) => {\n\t\t\t\t\tif (index < node.childCount - 1) children.push(child);\n\t\t\t\t});\n\t\t\t\tnodes.push(node.copy(Fragment.from(children)));\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tif (node.isBlock && !node.isLeaf) {\n\t\t\tnodes.push(node.copy(normalizeHardBreaks(node.content)));\n\t\t} else {\n\t\t\tnodes.push(node);\n\t\t}\n\t});\n\treturn Fragment.from(nodes);\n}\n\n/**\n * Strip \"rich\" marks (link, textStyle, highlight, etc.) while keeping\n * basic marks (bold, italic, strike, underline, code) that messaging\n * channels can represent.\n */\nexport function stripRichMarks(fragment: Fragment): Fragment {\n\tconst nodes: PMNode[] = [];\n\tfragment.forEach((node) => {\n\t\tif (node.isText) {\n\t\t\tconst kept = node.marks.filter((m) => BASIC_MARKS.has(m.type.name));\n\t\t\tnodes.push(kept.length === node.marks.length ? node : node.mark(kept));\n\t\t} else {\n\t\t\tnodes.push(node.copy(stripRichMarks(node.content)));\n\t\t}\n\t});\n\treturn Fragment.from(nodes);\n}\n\n/**\n * Parse plain clipboard text into a ProseMirror Slice, preserving blank\n * lines as empty paragraphs. This replaces ProseMirror's default text\n * parser which uses `\\n+` and loses all blank lines.\n *\n * Best for channels with compact paragraph gaps (e.g. WhatsApp) where\n * blank lines need structural representation as empty paragraphs.\n */\nexport function parseClipboardText(text: string, schema: Schema): Slice {\n\tconst paragraphs = text\n\t\t.split('\\n')\n\t\t.map((line) =>\n\t\t\tschema.node('paragraph', null, line ? [schema.text(line)] : []),\n\t\t);\n\treturn new Slice(Fragment.fromArray(paragraphs), 1, 1);\n}\n\n/**\n * Parse plain clipboard text into a single paragraph with hardBreaks for\n * every `\\n`. Produces the same structure as Gmail's Cmd+Shift+V output:\n * one block element with `<br>` for line breaks and `<br><br>` for blank\n * lines. This gives identical html and text output to Gmail.\n */\nexport function parseClipboardTextAsBreaks(\n\ttext: string,\n\tschema: Schema,\n): Slice {\n\tconst trimmed = text.replace(/\\n+$/, '');\n\tif (!trimmed) {\n\t\treturn new Slice(Fragment.from(schema.node('paragraph', null, [])), 1, 1);\n\t}\n\tconst hardBreak = schema.nodes['hardBreak'];\n\tconst lines = trimmed.split('\\n');\n\tconst children: PMNode[] = [];\n\tlines.forEach((line, i) => {\n\t\tif (line) children.push(schema.text(line));\n\t\tif (i < lines.length - 1 && hardBreak) {\n\t\t\tchildren.push(hardBreak.create());\n\t\t}\n\t});\n\treturn new Slice(\n\t\tFragment.from(\n\t\t\tschema.node('paragraph', null, children.length ? children : []),\n\t\t),\n\t\t1,\n\t\t1,\n\t);\n}\n"],"names":["TEXTBLOCK_TAGS","Set","BLOCK_SELECTOR","BASIC_MARKS","wrapInlineContent","container","querySelector","children","Array","from","childNodes","groups","i","length","node","HTMLBRElement","push","firstChild","remove","group","p","document","createElement","appendChild","cleanBlockBrs","brs","querySelectorAll","br","insideTextblock","el","parentElement","has","tagName","replaceChild","stripTrailingBrs","tag","last","lastElementChild","normalizeHardBreaks","fragment","nodes","forEach","type","name","childCount","_a","create","attrs","_b","lastChild","content","child","_offset","index","copy","Fragment","isBlock","isLeaf","stripRichMarks","isText","kept","marks","filter","m","mark","parseClipboardText","text","schema","paragraphs","split","map","line","Slice","fromArray","parseClipboardTextAsBreaks","trimmed","replace","hardBreak","lines"],"mappings":"uDAEaA,MAAAA,EAAiB,IAAIC,IAAI,CACrC,IACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,QAGYC,EACZ,wDAEKC,EAAc,IAAIF,IAAI,CAAC,OAAQ,SAAU,SAAU,YAAa,SAOhE,SAAUG,EAAkBC,GACjC,GAAIA,EAAUC,cAAcJ,GAAiB,OAE7C,MAAMK,EAAWC,MAAMC,KAAKJ,EAAUK,YAChCC,EAAmB,CAAC,IAE1B,IAAK,IAAIC,EAAI,EAAGA,EAAIL,EAASM,OAAQD,IAAK,CACzC,MAAME,EAAOP,EAASK,GAErBE,aAAgBC,eAChBR,EAASK,EAAI,aAAcG,eAE3BJ,EAAOK,KAAK,IACZJ,KAGDD,EAAOA,EAAOE,OAAS,GAAGG,KAAKF,EAC/B,CAED,KAAOT,EAAUY,YAAYZ,EAAUY,WAAWC,SAElD,IAAK,MAAMC,KAASR,EAAQ,CAC3B,MAAMS,EAAIC,SAASC,cAAc,KACjC,IAAK,MAAMR,KAAQK,EAAOC,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,KAAMP,EAASM,OAASN,EAAW,KAE7D,EACA,EAEF"}
1
+ {"version":3,"file":"pasteUtils.js","sources":["../../../../../src/editor/extensions/plainClipboard/pasteUtils.ts"],"sourcesContent":["import { Fragment, Node as PMNode } from '@tiptap/pm/model';\n\nexport const TEXTBLOCK_TAGS = new Set([\n\t'P',\n\t'LI',\n\t'H1',\n\t'H2',\n\t'H3',\n\t'H4',\n\t'H5',\n\t'H6',\n\t'TD',\n\t'TH',\n\t'PRE',\n]);\n\nexport const BLOCK_SELECTOR =\n\t'p,div,h1,h2,h3,h4,h5,h6,ul,ol,li,blockquote,table,pre';\n\nconst BASIC_MARKS = new Set(['bold', 'italic', 'strike', 'underline', 'code']);\n\n/**\n * Replace `<br>` elements that sit at block level (not inside a textblock\n * like `<p>`, `<li>`, etc.) with empty `<p></p>` elements. Google Docs\n * puts standalone `<br>` tags between paragraphs to represent blank lines.\n * Without this, ProseMirror parses them as top-level hardBreak nodes.\n */\nexport function cleanBlockBrs(container: HTMLElement): void {\n\tconst brs = Array.from(container.querySelectorAll('br'));\n\tfor (const br of brs) {\n\t\tlet insideTextblock = false;\n\t\tlet el = br.parentElement;\n\t\twhile (el && el !== container) {\n\t\t\tif (TEXTBLOCK_TAGS.has(el.tagName)) {\n\t\t\t\tinsideTextblock = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tel = el.parentElement;\n\t\t}\n\t\tif (!insideTextblock) {\n\t\t\tbr.parentElement!.replaceChild(document.createElement('p'), br);\n\t\t}\n\t}\n}\n\n/**\n * 1. Convert paragraphs containing only a hard_break into empty paragraphs.\n * 2. Collapse consecutive empty paragraphs into one.\n */\nexport function normalizeBlanks(fragment: Fragment): Fragment {\n\tconst nodes: PMNode[] = [];\n\tlet prevEmpty = false;\n\tfragment.forEach((node) => {\n\t\tconst isHardBreakOnly =\n\t\t\tnode.type.name === 'paragraph' &&\n\t\t\tnode.childCount === 1 &&\n\t\t\tnode.firstChild?.type.name === 'hardBreak';\n\t\tif (isHardBreakOnly) {\n\t\t\tif (!prevEmpty) nodes.push(node.type.create(node.attrs));\n\t\t\tprevEmpty = true;\n\t\t\treturn;\n\t\t}\n\t\tconst isEmpty = node.type.name === 'paragraph' && node.childCount === 0;\n\t\tif (isEmpty && prevEmpty) return;\n\t\tprevEmpty = isEmpty;\n\t\tif (node.isBlock && !node.isLeaf) {\n\t\t\tnodes.push(node.copy(normalizeBlanks(node.content)));\n\t\t} else {\n\t\t\tnodes.push(node);\n\t\t}\n\t});\n\treturn Fragment.from(nodes);\n}\n\n/**\n * Strip only \"rich\" marks (link, textStyle, highlight, etc.) while keeping\n * basic formatting marks (bold, italic, strike, underline, code) that\n * messaging channels can represent.\n */\nexport function stripRichMarks(fragment: Fragment): Fragment {\n\tconst nodes: PMNode[] = [];\n\tfragment.forEach((node) => {\n\t\tif (node.isText) {\n\t\t\tconst kept = node.marks.filter((m) => BASIC_MARKS.has(m.type.name));\n\t\t\tnodes.push(kept.length === node.marks.length ? node : node.mark(kept));\n\t\t} else {\n\t\t\tnodes.push(node.copy(stripRichMarks(node.content)));\n\t\t}\n\t});\n\treturn Fragment.from(nodes);\n}\n"],"names":["TEXTBLOCK_TAGS","Set","BLOCK_SELECTOR","BASIC_MARKS","cleanBlockBrs","container","brs","Array","from","querySelectorAll","br","insideTextblock","el","parentElement","has","tagName","replaceChild","document","createElement","normalizeBlanks","fragment","nodes","prevEmpty","forEach","node","type","name","childCount","_a","firstChild","push","create","attrs","isEmpty","isBlock","isLeaf","copy","content","Fragment","stripRichMarks","isText","kept","marks","filter","m","length","mark"],"mappings":"4CAEaA,MAAAA,EAAiB,IAAIC,IAAI,CACrC,IACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,KACA,QAGYC,EACZ,wDAEKC,EAAc,IAAIF,IAAI,CAAC,OAAQ,SAAU,SAAU,YAAa,SAQhE,SAAUG,EAAcC,GAC7B,MAAMC,EAAMC,MAAMC,KAAKH,EAAUI,iBAAiB,OAClD,IAAK,MAAMC,KAAMJ,EAAK,CACrB,IAAIK,GAAkB,EAClBC,EAAKF,EAAGG,cACZ,KAAOD,GAAMA,IAAOP,GAAW,CAC9B,GAAIL,EAAec,IAAIF,EAAGG,SAAU,CACnCJ,GAAkB,EAClB,KACA,CACDC,EAAKA,EAAGC,aACR,CACIF,GACJD,EAAGG,cAAeG,aAAaC,SAASC,cAAc,KAAMR,EAE7D,CACF,CAMM,SAAUS,EAAgBC,GAC/B,MAAMC,EAAkB,GACxB,IAAIC,GAAY,EAoBhB,OAnBAF,EAASG,SAASC,UAKjB,GAHoB,cAAnBA,EAAKC,KAAKC,MACU,IAApBF,EAAKG,YAC0B,eAAhB,QAAfC,EAAAJ,EAAKK,kBAAU,IAAAD,OAAA,EAAAA,EAAEH,KAAKC,MAItB,OAFKJ,GAAWD,EAAMS,KAAKN,EAAKC,KAAKM,OAAOP,EAAKQ,aACjDV,GAAY,GAGb,MAAMW,EAA6B,cAAnBT,EAAKC,KAAKC,MAA4C,IAApBF,EAAKG,WACnDM,GAAWX,IACfA,EAAYW,EACRT,EAAKU,UAAYV,EAAKW,OACzBd,EAAMS,KAAKN,EAAKY,KAAKjB,EAAgBK,EAAKa,WAE1ChB,EAAMS,KAAKN,GACX,IAEKc,EAAS9B,KAAKa,EACtB,CAOM,SAAUkB,EAAenB,GAC9B,MAAMC,EAAkB,GASxB,OARAD,EAASG,SAASC,IACjB,GAAIA,EAAKgB,OAAQ,CAChB,MAAMC,EAAOjB,EAAKkB,MAAMC,QAAQC,GAAMzC,EAAYW,IAAI8B,EAAEnB,KAAKC,QAC7DL,EAAMS,KAAKW,EAAKI,SAAWrB,EAAKkB,MAAMG,OAASrB,EAAOA,EAAKsB,KAAKL,GAChE,MACApB,EAAMS,KAAKN,EAAKY,KAAKG,EAAef,EAAKa,UACzC,IAEKC,EAAS9B,KAAKa,EACtB"}
@@ -8,6 +8,8 @@ export declare const VariablePickerContext: React.Context<{
8
8
  setVariables: React.Dispatch<React.SetStateAction<any[]>>;
9
9
  showRecommended: boolean;
10
10
  setShowRecommended: React.Dispatch<React.SetStateAction<boolean>>;
11
+ containerRef: React.RefObject<HTMLDivElement | null>;
12
+ scrollPositionStack: React.MutableRefObject<number[]>;
11
13
  }>;
12
14
  export declare const useVariablePickerContext: () => {
13
15
  searchText: string;
@@ -18,4 +20,6 @@ export declare const useVariablePickerContext: () => {
18
20
  setVariables: React.Dispatch<React.SetStateAction<any[]>>;
19
21
  showRecommended: boolean;
20
22
  setShowRecommended: React.Dispatch<React.SetStateAction<boolean>>;
23
+ containerRef: React.RefObject<HTMLDivElement | null>;
24
+ scrollPositionStack: React.MutableRefObject<number[]>;
21
25
  };
@@ -1,5 +1,4 @@
1
1
  export declare const BikEditorShell: import("styled-components").StyledComponent<"div", any, {
2
2
  minHeight?: string | undefined;
3
3
  maxHeight?: string | undefined;
4
- paragraphGap?: string | undefined;
5
4
  }, never>;
@@ -728,6 +728,4 @@ export interface BikEditorProps {
728
728
  minHeight?: string;
729
729
  /** Maximum height. The editor scrolls internally when exceeded. CSS value, e.g. `'400px'`. */
730
730
  maxHeight?: string;
731
- /** Gap between consecutive paragraphs. CSS value, defaults to `'4px'`. */
732
- paragraphGap?: string;
733
731
  }
@@ -14,14 +14,10 @@ import { EditorSnapshot, FormatState } from './BikEditor.types';
14
14
  */
15
15
  export declare function normalizeHtml(html: string): string;
16
16
  /**
17
- * Make editor HTML portable across email clients and chat renderers.
18
- *
19
- * 1. Double trailing `<br>` in content paragraphs so the blank line is
20
- * visible. A single trailing `<br>` before `</p>` is swallowed by most
21
- * email clients; `<br><br>` renders as a visible blank line (matches
22
- * Gmail's output).
23
- * 2. Convert empty `<p></p>` to `<p><br></p>` — email clients collapse
24
- * zero-height paragraphs without a `<br>`.
17
+ * Convert ProseMirror's `<p></p>` empty paragraphs to the universally
18
+ * rendered `<p><br></p>` format before the HTML leaves the editor.
19
+ * Email clients, chat bubbles, and every renderer understand `<p><br></p>`
20
+ * as a visible blank line, whereas `<p></p>` collapses to zero height.
25
21
  */
26
22
  export declare function toPortableHtml(html: string): string;
27
23
  /**