@bikdotai/bik-component-library 0.0.811 → 0.0.812-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/editor/BikEditor.js +1 -1
- package/dist/cjs/editor/BikEditor.js.map +1 -1
- package/dist/cjs/editor/BikEditor.styles.js +12 -14
- package/dist/cjs/editor/BikEditor.styles.js.map +1 -1
- package/dist/cjs/editor/BikEditor.types.js.map +1 -1
- package/dist/cjs/editor/BikEditor.utils.js +1 -1
- package/dist/cjs/editor/BikEditor.utils.js.map +1 -1
- package/dist/cjs/editor/extensions/buildExtensions.js +1 -1
- package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
- package/dist/cjs/editor/extensions/plainClipboard/PasteNormalizationExtension.js +1 -1
- package/dist/cjs/editor/extensions/plainClipboard/PasteNormalizationExtension.js.map +1 -1
- package/dist/cjs/editor/extensions/plainClipboard/pasteUtils.js +1 -1
- package/dist/cjs/editor/extensions/plainClipboard/pasteUtils.js.map +1 -1
- package/dist/cjs/editor/serializers/toLiveChatText.js +1 -1
- package/dist/cjs/editor/serializers/toLiveChatText.js.map +1 -1
- package/dist/cjs/editor/serializers/toWhatsAppText.js +1 -1
- package/dist/cjs/editor/serializers/toWhatsAppText.js.map +1 -1
- package/dist/cjs/src/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
- package/dist/cjs/src/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/cjs/src/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
- package/dist/cjs/src/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/cjs/src/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
- package/dist/cjs/src/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/src/editor/BikEditor.styles.d.ts +1 -1
- package/dist/cjs/src/editor/BikEditor.types.d.ts +0 -2
- package/dist/cjs/src/editor/BikEditor.utils.d.ts +14 -8
- package/dist/cjs/src/editor/extensions/buildExtensions.d.ts +1 -2
- package/dist/cjs/src/editor/extensions/plainClipboard/PasteNormalizationExtension.d.ts +22 -4
- package/dist/cjs/src/editor/extensions/plainClipboard/pasteUtils.d.ts +28 -5
- package/dist/esm/editor/BikEditor.js +1 -1
- package/dist/esm/editor/BikEditor.js.map +1 -1
- package/dist/esm/editor/BikEditor.styles.js +12 -14
- package/dist/esm/editor/BikEditor.styles.js.map +1 -1
- package/dist/esm/editor/BikEditor.types.js.map +1 -1
- package/dist/esm/editor/BikEditor.utils.js +1 -1
- package/dist/esm/editor/BikEditor.utils.js.map +1 -1
- package/dist/esm/editor/extensions/buildExtensions.js +1 -1
- package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
- package/dist/esm/editor/extensions/plainClipboard/PasteNormalizationExtension.js +1 -1
- package/dist/esm/editor/extensions/plainClipboard/PasteNormalizationExtension.js.map +1 -1
- package/dist/esm/editor/extensions/plainClipboard/pasteUtils.js +1 -1
- package/dist/esm/editor/extensions/plainClipboard/pasteUtils.js.map +1 -1
- package/dist/esm/editor/serializers/toLiveChatText.js +1 -1
- package/dist/esm/editor/serializers/toLiveChatText.js.map +1 -1
- package/dist/esm/editor/serializers/toWhatsAppText.js +1 -1
- package/dist/esm/editor/serializers/toWhatsAppText.js.map +1 -1
- package/dist/esm/src/components/QueryBuilder/Triggers/EVENTS/components/EventsTrigger.d.ts +1 -1
- package/dist/esm/src/components/QueryBuilder/Triggers/EVENTS/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/esm/src/components/QueryBuilder/Triggers/IG/components/IGTrigger.d.ts +1 -1
- package/dist/esm/src/components/QueryBuilder/Triggers/IG/selectors/useIGTriggerNameCacheSelector.d.ts +1 -1
- package/dist/esm/src/components/QueryBuilder/Triggers/components/BaseTriggerQueryBuilderNode.d.ts +2 -2
- package/dist/esm/src/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/src/editor/BikEditor.styles.d.ts +1 -1
- package/dist/esm/src/editor/BikEditor.types.d.ts +0 -2
- package/dist/esm/src/editor/BikEditor.utils.d.ts +14 -8
- package/dist/esm/src/editor/extensions/buildExtensions.d.ts +1 -2
- package/dist/esm/src/editor/extensions/plainClipboard/PasteNormalizationExtension.d.ts +22 -4
- package/dist/esm/src/editor/extensions/plainClipboard/pasteUtils.d.ts +28 -5
- package/package.json +2 -1
|
@@ -3,14 +3,20 @@ import { EditorSnapshot, FormatState } from './BikEditor.types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Normalise HTML before passing it to TipTap.
|
|
5
5
|
*
|
|
6
|
-
* 1.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
6
|
+
* 1. Unwrap style-less `<span>` wrappers (plain spans, and editor-cursor spans
|
|
7
|
+
* like Quill's `<span class="ql-cursor">`). Spans that carry inline styling
|
|
8
|
+
* (`color` / `font-family` / `font-size` render as styled spans) or that
|
|
9
|
+
* represent a `{{variable}}` token are PRESERVED — otherwise a setContent
|
|
10
|
+
* round-trip would silently drop colour/font formatting that paste keeps.
|
|
11
|
+
* 2. Collapse placeholder paragraphs (`<p><br></p>`) to `<p></p>`. ProseMirror
|
|
12
|
+
* parses `<p></p>` as an empty paragraph and adds its own DOM `<br>` for the
|
|
13
|
+
* cursor — one blank line, correct height. Leaving the source `<br>` would
|
|
14
|
+
* create a `hard_break` child AND the cursor `<br>` → double-height blank line.
|
|
15
|
+
*
|
|
16
|
+
* Uses the DOM (regex cannot selectively pair span tags). `normalizeHtml` runs
|
|
17
|
+
* in the component body for `initialContent`, so it is guarded for SSR: the
|
|
18
|
+
* editor is created lazily on the client (`immediatelyRender: false`), meaning
|
|
19
|
+
* the value is only parsed client-side and passing through on the server is safe.
|
|
14
20
|
*/
|
|
15
21
|
export declare function normalizeHtml(html: string): string;
|
|
16
22
|
/**
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
2
1
|
import type { ReactNode } from 'react';
|
|
3
2
|
import type { EditorFeatures, EditorSnapshot, KeyboardShortcut, MentionDropdownRenderProps, MentionItem, PasteData, SlashCommandDropdownRenderProps, SlashCommandItem } from '../BikEditor.types';
|
|
4
3
|
interface ExtensionConfig {
|
|
@@ -34,5 +33,5 @@ interface ExtensionConfig {
|
|
|
34
33
|
renderSlashCommandItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode;
|
|
35
34
|
renderSlashCommandDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode;
|
|
36
35
|
}
|
|
37
|
-
export declare function buildExtensions(config: ExtensionConfig): (import("@tiptap/core").Node<import("@tiptap/extension-
|
|
36
|
+
export declare function buildExtensions(config: ExtensionConfig): (import("@tiptap/core").Node<import("@tiptap/extension-hard-break").HardBreakOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-paragraph").ParagraphOptions, any> | import("@tiptap/core").Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-underline").UnderlineOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").PlaceholderOptions, any> | import("@tiptap/core").Extension<any, any> | import("@tiptap/core").Extension<import("@tiptap/extensions").CharacterCountOptions, import("@tiptap/extensions").CharacterCountStorage> | import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-style").ColorOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-highlight").HighlightOptions, any> | import("@tiptap/core").Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any>)[];
|
|
38
37
|
export {};
|
|
@@ -3,11 +3,29 @@ import { Extension } from '@tiptap/core';
|
|
|
3
3
|
* Unified paste normalizer for all editor channels.
|
|
4
4
|
*
|
|
5
5
|
* Uses ProseMirror's recommended hooks instead of overriding handlePaste:
|
|
6
|
-
* - clipboardTextParser: plain text → Slice (
|
|
6
|
+
* - clipboardTextParser: plain text → Slice (one block, <br> per line)
|
|
7
7
|
* - transformPastedHTML: HTML → HTML (cleans Google Docs / Word artifacts)
|
|
8
|
-
* - transformPasted: Slice → Slice (
|
|
8
|
+
* - transformPasted: Slice → Slice (normalize hardBreaks, strip marks,
|
|
9
|
+
* mirror the source paragraph-margin convention)
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
11
|
+
* Margins MIRROR the source (like Gmail): they are not added structurally, so
|
|
12
|
+
* ChatGPT-pasted `<p>` keeps its default margin (gaps) while Google-Docs and
|
|
13
|
+
* plain/paste-without-formatting content stays margin:0 (tight).
|
|
14
|
+
*
|
|
15
|
+
* `appendTransaction` does two bounded touch-ups:
|
|
16
|
+
* 1. Repairs the FIRST pasted paragraph — ProseMirror merges it into the
|
|
17
|
+
* cursor's paragraph at paste time, dropping its margin attr; we record that
|
|
18
|
+
* margin (in transformPasted / the plain handlePaste) and reapply it at the
|
|
19
|
+
* paste position.
|
|
20
|
+
* 2. Typed-Enter inheritance — splitBlock gives a paragraph created at a block
|
|
21
|
+
* end DEFAULT attrs, so an empty paragraph that follows a margin:0 paragraph
|
|
22
|
+
* is set to margin:0 too. Typing inside tight content stays tight; default
|
|
23
|
+
* content stays default; non-empty (pasted) paragraphs are never touched.
|
|
24
|
+
*
|
|
25
|
+
* `plainOnly` (channels with no rich formatting — WhatsApp, IG, FB, comments)
|
|
26
|
+
* forces EVERY paste through the plain-text path: even Cmd/Ctrl+V ignores the
|
|
27
|
+
* clipboard HTML and pastes text only, since those channels don't support
|
|
28
|
+
* formatting anyway. Email and the signature editor (richPaste) keep the full
|
|
29
|
+
* HTML pipeline.
|
|
12
30
|
*/
|
|
13
31
|
export declare const PasteNormalizationExtension: Extension<any, any>;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Fragment, Schema, Slice } from '@tiptap/pm/model';
|
|
2
2
|
export declare const TEXTBLOCK_TAGS: Set<string>;
|
|
3
3
|
export declare const BLOCK_SELECTOR = "p,div,h1,h2,h3,h4,h5,h6,ul,ol,li,blockquote,table,pre";
|
|
4
|
+
/** Normalise clipboard newlines: Windows CRLF and lone CR → LF. */
|
|
5
|
+
export declare function normalizeNewlines(text: string): string;
|
|
4
6
|
/**
|
|
5
7
|
* When pasted HTML is entirely inline (no block elements), split at
|
|
6
8
|
* `<br><br>` boundaries into `<p>` elements. Single `<br>` stays as a
|
|
@@ -21,14 +23,31 @@ export declare function cleanBlockBrs(container: HTMLElement): void;
|
|
|
21
23
|
*/
|
|
22
24
|
export declare function stripTrailingBrs(container: HTMLElement): void;
|
|
23
25
|
/**
|
|
24
|
-
* Convert
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* Convert a paragraph whose ONLY child is a hardBreak (`<p><br></p>`) into a
|
|
27
|
+
* truly empty paragraph. ProseMirror parses the `<br>` as a hardBreak node AND
|
|
28
|
+
* adds its own cursor `<br>`, rendering double-height; an empty paragraph
|
|
29
|
+
* (childCount 0) gives a single-height blank line.
|
|
28
30
|
*
|
|
29
|
-
* Does NOT
|
|
31
|
+
* Does NOT strip trailing hardBreaks from content paragraphs, and does NOT
|
|
32
|
+
* collapse consecutive empties — those `<br>`s/blank lines are intentional
|
|
33
|
+
* (e.g. shift+enter / enter runs from Google Docs) and Gmail preserves them.
|
|
30
34
|
*/
|
|
31
35
|
export declare function normalizeHardBreaks(fragment: Fragment): Fragment;
|
|
36
|
+
/**
|
|
37
|
+
* Mirror the source paragraph-margin convention across a pasted block.
|
|
38
|
+
*
|
|
39
|
+
* Gmail decides spacing from the SOURCE: it keeps default margins for content
|
|
40
|
+
* pasted from ChatGPT/plain `<p>`, and `margin:0` for Google-Docs-style content
|
|
41
|
+
* (whose paragraphs carry `margin:0`). We do the same. A paragraph's margin is
|
|
42
|
+
* already preserved from the source (the Paragraph node's `margin` attribute),
|
|
43
|
+
* so the only gap is the synthesized blank-line paragraphs (created from a
|
|
44
|
+
* Google-Docs block-level `<br>`), which have no source margin. If the pasted
|
|
45
|
+
* block is margin:0-style (any paragraph carries margin:0), apply margin:0 to
|
|
46
|
+
* every paragraph of THIS paste — so the blank lines match. Pastes with no
|
|
47
|
+
* margin:0 paragraph (ChatGPT, plain text) are left untouched → default margins.
|
|
48
|
+
* Scoped to the pasted slice, so it never tightens existing/typed content.
|
|
49
|
+
*/
|
|
50
|
+
export declare function mirrorParagraphMargins(fragment: Fragment): Fragment;
|
|
32
51
|
/**
|
|
33
52
|
* Strip "rich" marks (link, textStyle, highlight, etc.) while keeping
|
|
34
53
|
* basic marks (bold, italic, strike, underline, code) that messaging
|
|
@@ -49,5 +68,9 @@ export declare function parseClipboardText(text: string, schema: Schema): Slice;
|
|
|
49
68
|
* every `\n`. Produces the same structure as Gmail's Cmd+Shift+V output:
|
|
50
69
|
* one block element with `<br>` for line breaks and `<br><br>` for blank
|
|
51
70
|
* lines. This gives identical html and text output to Gmail.
|
|
71
|
+
*
|
|
72
|
+
* The paragraph is tight (`margin: '0'`) — plain/paste-without-formatting is
|
|
73
|
+
* Gmail's `<div>` (no margin), and typed Enter inherits this margin, so
|
|
74
|
+
* splitting plain-pasted text stays tight like Gmail (not default-margin gaps).
|
|
52
75
|
*/
|
|
53
76
|
export declare function parseClipboardTextAsBreaks(text: string, schema: Schema): Slice;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bikdotai/bik-component-library",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.812-beta.0",
|
|
4
4
|
"description": "Bik Component Library",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@tiptap/extension-character-count": "^3.22.5",
|
|
72
72
|
"@tiptap/extension-color": "^3.22.5",
|
|
73
73
|
"@tiptap/extension-font-family": "^3.22.5",
|
|
74
|
+
"@tiptap/extension-hard-break": "^3.22.5",
|
|
74
75
|
"@tiptap/extension-highlight": "^3.22.5",
|
|
75
76
|
"@tiptap/extension-image": "^3.22.5",
|
|
76
77
|
"@tiptap/extension-link": "^3.22.5",
|