@bikdotai/bik-component-library 0.0.811 → 0.0.812
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/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/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,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",
|
|
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",
|