@bikdotai/bik-component-library 0.0.806-beta.3 → 0.0.806-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/editor/extensions/plainClipboard/PlainClipboardExtension.js +1 -1
- package/dist/cjs/editor/extensions/plainClipboard/PlainClipboardExtension.js.map +1 -1
- package/dist/esm/editor/extensions/plainClipboard/PlainClipboardExtension.js +1 -1
- package/dist/esm/editor/extensions/plainClipboard/PlainClipboardExtension.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/pm/model"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/pm/model"),n=require("@tiptap/pm/state");function r(e){const n=[];return e.forEach((e=>{e.isText?n.push(e.mark([])):n.push(e.copy(r(e.content)))})),t.Fragment.from(n)}const o=e.Extension.create({name:"plainClipboard",addProseMirrorPlugins:()=>[new n.Plugin({props:{handlePaste(e,n){var o,a,i,l;if(null===(a=null===(o=n.clipboardData)||void 0===o?void 0:o.files)||void 0===a?void 0:a.length)return!1;const s=null===(i=n.clipboardData)||void 0===i?void 0:i.getData("text/html"),c=null===(l=n.clipboardData)||void 0===l?void 0:l.getData("text/plain");if(!c)return!1;if(console.log("[PASTE-DEBUG] clipboard html:",s),console.log("[PASTE-DEBUG] clipboard text:",JSON.stringify(c)),console.log("[PASTE-DEBUG] has data-pm-slice:",null==s?void 0:s.includes("data-pm-slice")),null==s?void 0:s.includes("data-pm-slice"))return console.log("[PASTE-DEBUG] → returning false, letting ProseMirror handle"),!1;const d=e.state.schema;if(s){const n=document.createElement("div");n.innerHTML=s;const o=t.DOMParser.fromSchema(d).parseSlice(n),a=new t.Slice(r(o.content),o.openStart,o.openEnd);return e.dispatch(e.state.tr.replaceSelection(a)),!0}const p=c.split("\n").map((e=>d.node("paragraph",null,e?[d.text(e)]:[]))),u=new t.Slice(t.Fragment.fromArray(p),1,1);return e.dispatch(e.state.tr.replaceSelection(u)),!0}}})]});exports.PlainClipboardExtension=o;
|
|
2
2
|
//# sourceMappingURL=PlainClipboardExtension.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlainClipboardExtension.js","sources":["../../../../../src/editor/extensions/plainClipboard/PlainClipboardExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport {\n\tFragment,\n\tNode as PMNode,\n\tDOMParser as ProseMirrorDOMParser,\n\tSlice,\n} from '@tiptap/pm/model';\nimport { Plugin } from '@tiptap/pm/state';\n\nfunction stripMarks(fragment: Fragment): Fragment {\n\tconst nodes: PMNode[] = [];\n\tfragment.forEach((node) => {\n\t\tif (node.isText) {\n\t\t\tnodes.push(node.mark([]));\n\t\t} else {\n\t\t\tnodes.push(node.copy(stripMarks(node.content)));\n\t\t}\n\t});\n\treturn Fragment.from(nodes);\n}\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; // let ImagePaste handle\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\t// ProseMirror stamps its own clipboard with data-pm-slice.\n\t\t\t\t\t\t// Let ProseMirror handle its own format natively — it round-trips perfectly.\n\t\t\t\t\t\tif (html?.includes('data-pm-slice'))
|
|
1
|
+
{"version":3,"file":"PlainClipboardExtension.js","sources":["../../../../../src/editor/extensions/plainClipboard/PlainClipboardExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport {\n\tFragment,\n\tNode as PMNode,\n\tDOMParser as ProseMirrorDOMParser,\n\tSlice,\n} from '@tiptap/pm/model';\nimport { Plugin } from '@tiptap/pm/state';\n\nfunction stripMarks(fragment: Fragment): Fragment {\n\tconst nodes: PMNode[] = [];\n\tfragment.forEach((node) => {\n\t\tif (node.isText) {\n\t\t\tnodes.push(node.mark([]));\n\t\t} else {\n\t\t\tnodes.push(node.copy(stripMarks(node.content)));\n\t\t}\n\t});\n\treturn Fragment.from(nodes);\n}\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; // let ImagePaste handle\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\tconsole.log('[PASTE-DEBUG] clipboard html:', html);\n\t\t\t\t\t\tconsole.log('[PASTE-DEBUG] clipboard text:', JSON.stringify(text));\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t'[PASTE-DEBUG] has data-pm-slice:',\n\t\t\t\t\t\t\thtml?.includes('data-pm-slice'),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// ProseMirror stamps its own clipboard with data-pm-slice.\n\t\t\t\t\t\t// Let ProseMirror handle its own format natively — it round-trips perfectly.\n\t\t\t\t\t\tif (html?.includes('data-pm-slice')) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t'[PASTE-DEBUG] → returning false, letting ProseMirror handle',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\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\t// Parse the HTML to get the correct block structure,\n\t\t\t\t\t\t\t// then strip all inline marks (bold, italic, links, etc.)\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 parsed =\n\t\t\t\t\t\t\t\tProseMirrorDOMParser.fromSchema(schema).parseSlice(container);\n\t\t\t\t\t\t\tconst stripped = new Slice(\n\t\t\t\t\t\t\t\tstripMarks(parsed.content),\n\t\t\t\t\t\t\t\tparsed.openStart,\n\t\t\t\t\t\t\t\tparsed.openEnd,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t_view.dispatch(_view.state.tr.replaceSelection(stripped));\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Plain text only (no HTML): split on newlines\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":["stripMarks","fragment","nodes","forEach","node","isText","push","mark","copy","content","Fragment","from","PlainClipboardExtension","Extension","create","name","addProseMirrorPlugins","Plugin","props","handlePaste","_view","event","_b","clipboardData","_a","files","length","html","_c","getData","text","_d","console","log","JSON","stringify","includes","schema","state","container","document","createElement","innerHTML","parsed","ProseMirrorDOMParser","fromSchema","parseSlice","stripped","Slice","openStart","openEnd","dispatch","tr","replaceSelection","paragraphs","split","map","line","slice","fromArray"],"mappings":"kMASA,SAASA,EAAWC,GACnB,MAAMC,EAAkB,GAQxB,OAPAD,EAASE,SAASC,IACbA,EAAKC,OACRH,EAAMI,KAAKF,EAA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ADAlC,EAAM+B,SAAS/B,EAAMkB,MAAMc,GAAGC,iBAAiBK,KACxC,CACR"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Extension as t}from"../../../node_modules/@tiptap/core/dist/index.js";import{DOMParser as e,Slice as
|
|
1
|
+
import{Extension as t}from"../../../node_modules/@tiptap/core/dist/index.js";import{DOMParser as e,Slice as o,Fragment as n}from"@tiptap/pm/model";import{Plugin as r}from"@tiptap/pm/state";function a(t){const e=[];return t.forEach((t=>{t.isText?e.push(t.mark([])):e.push(t.copy(a(t.content)))})),n.from(e)}const i=t.create({name:"plainClipboard",addProseMirrorPlugins:()=>[new r({props:{handlePaste(t,r){var i,l,s,c;if(null===(l=null===(i=r.clipboardData)||void 0===i?void 0:i.files)||void 0===l?void 0:l.length)return!1;const p=null===(s=r.clipboardData)||void 0===s?void 0:s.getData("text/html"),d=null===(c=r.clipboardData)||void 0===c?void 0:c.getData("text/plain");if(!d)return!1;if(console.log("[PASTE-DEBUG] clipboard html:",p),console.log("[PASTE-DEBUG] clipboard text:",JSON.stringify(d)),console.log("[PASTE-DEBUG] has data-pm-slice:",null==p?void 0:p.includes("data-pm-slice")),null==p?void 0:p.includes("data-pm-slice"))return console.log("[PASTE-DEBUG] → returning false, letting ProseMirror handle"),!1;const m=t.state.schema;if(p){const n=document.createElement("div");n.innerHTML=p;const r=e.fromSchema(m).parseSlice(n),i=new o(a(r.content),r.openStart,r.openEnd);return t.dispatch(t.state.tr.replaceSelection(i)),!0}const u=d.split("\n").map((t=>m.node("paragraph",null,t?[m.text(t)]:[]))),f=new o(n.fromArray(u),1,1);return t.dispatch(t.state.tr.replaceSelection(f)),!0}}})]});export{i as PlainClipboardExtension};
|
|
2
2
|
//# sourceMappingURL=PlainClipboardExtension.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlainClipboardExtension.js","sources":["../../../../../src/editor/extensions/plainClipboard/PlainClipboardExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport {\n\tFragment,\n\tNode as PMNode,\n\tDOMParser as ProseMirrorDOMParser,\n\tSlice,\n} from '@tiptap/pm/model';\nimport { Plugin } from '@tiptap/pm/state';\n\nfunction stripMarks(fragment: Fragment): Fragment {\n\tconst nodes: PMNode[] = [];\n\tfragment.forEach((node) => {\n\t\tif (node.isText) {\n\t\t\tnodes.push(node.mark([]));\n\t\t} else {\n\t\t\tnodes.push(node.copy(stripMarks(node.content)));\n\t\t}\n\t});\n\treturn Fragment.from(nodes);\n}\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; // let ImagePaste handle\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\t// ProseMirror stamps its own clipboard with data-pm-slice.\n\t\t\t\t\t\t// Let ProseMirror handle its own format natively — it round-trips perfectly.\n\t\t\t\t\t\tif (html?.includes('data-pm-slice'))
|
|
1
|
+
{"version":3,"file":"PlainClipboardExtension.js","sources":["../../../../../src/editor/extensions/plainClipboard/PlainClipboardExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport {\n\tFragment,\n\tNode as PMNode,\n\tDOMParser as ProseMirrorDOMParser,\n\tSlice,\n} from '@tiptap/pm/model';\nimport { Plugin } from '@tiptap/pm/state';\n\nfunction stripMarks(fragment: Fragment): Fragment {\n\tconst nodes: PMNode[] = [];\n\tfragment.forEach((node) => {\n\t\tif (node.isText) {\n\t\t\tnodes.push(node.mark([]));\n\t\t} else {\n\t\t\tnodes.push(node.copy(stripMarks(node.content)));\n\t\t}\n\t});\n\treturn Fragment.from(nodes);\n}\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; // let ImagePaste handle\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\tconsole.log('[PASTE-DEBUG] clipboard html:', html);\n\t\t\t\t\t\tconsole.log('[PASTE-DEBUG] clipboard text:', JSON.stringify(text));\n\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t'[PASTE-DEBUG] has data-pm-slice:',\n\t\t\t\t\t\t\thtml?.includes('data-pm-slice'),\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\t// ProseMirror stamps its own clipboard with data-pm-slice.\n\t\t\t\t\t\t// Let ProseMirror handle its own format natively — it round-trips perfectly.\n\t\t\t\t\t\tif (html?.includes('data-pm-slice')) {\n\t\t\t\t\t\t\tconsole.log(\n\t\t\t\t\t\t\t\t'[PASTE-DEBUG] → returning false, letting ProseMirror handle',\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\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\t// Parse the HTML to get the correct block structure,\n\t\t\t\t\t\t\t// then strip all inline marks (bold, italic, links, etc.)\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 parsed =\n\t\t\t\t\t\t\t\tProseMirrorDOMParser.fromSchema(schema).parseSlice(container);\n\t\t\t\t\t\t\tconst stripped = new Slice(\n\t\t\t\t\t\t\t\tstripMarks(parsed.content),\n\t\t\t\t\t\t\t\tparsed.openStart,\n\t\t\t\t\t\t\t\tparsed.openEnd,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t_view.dispatch(_view.state.tr.replaceSelection(stripped));\n\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// Plain text only (no HTML): split on newlines\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":["stripMarks","fragment","nodes","forEach","node","isText","push","mark","copy","content","Fragment","from","PlainClipboardExtension","Extension","create","name","addProseMirrorPlugins","Plugin","props","handlePaste","_view","event","_b","clipboardData","_a","files","length","html","_c","getData","text","_d","console","log","JSON","stringify","includes","schema","state","container","document","createElement","innerHTML","parsed","ProseMirrorDOMParser","fromSchema","parseSlice","stripped","Slice","openStart","openEnd","dispatch","tr","replaceSelection","paragraphs","split","map","line","slice","fromArray"],"mappings":"6LASA,SAASA,EAAWC,GACnB,MAAMC,EAAkB,GAQxB,OAPAD,EAASE,SAASC,IACbA,EAAKC,OACRH,EAAMI,KAAKF,EAAKG,KAAK,KAErBL,EAAMI,KAAKF,EAAKI,KAAKR,EAAWI,EAAKK,UACrC,IAEKC,EAASC,KAAKT,EACtB,OAEaU,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,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