@haluo/biz 2.0.22 → 2.0.24

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/haluo-biz.js CHANGED
@@ -5503,12 +5503,20 @@ const _sfc_main = {
5503
5503
  me2.editor.addEventListener("willPaste", function(type, handler) {
5504
5504
  function validateDom() {
5505
5505
  const fragment = type && type.fragment || {};
5506
+ const textContent = fragment.textContent || "";
5506
5507
  let tmpNode = document.createElement("div");
5507
5508
  tmpNode.appendChild(fragment.cloneNode(true));
5508
5509
  const str = tmpNode.innerHTML;
5509
- const text = tmpNode.innerText || "";
5510
- const isTextNode = fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName === "#text";
5511
- type.defaultPrevented = str.indexOf("<img") > -1 || str.indexOf("<video") > -1 || !isTextNode && text.length > 1;
5510
+ const notDefault = str.indexOf("<img") > -1 || str.indexOf("<video") > -1;
5511
+ if (!notDefault) {
5512
+ const frag = document.createDocumentFragment();
5513
+ const div = document.createElement("p");
5514
+ div.innerText = textContent;
5515
+ div.className = "halo-paragraph";
5516
+ frag.appendChild(div);
5517
+ type.fragment = frag;
5518
+ }
5519
+ type.defaultPrevented = notDefault;
5512
5520
  tmpNode = null;
5513
5521
  }
5514
5522
  validateDom();
@@ -5505,12 +5505,20 @@
5505
5505
  me2.editor.addEventListener("willPaste", function(type, handler) {
5506
5506
  function validateDom() {
5507
5507
  const fragment = type && type.fragment || {};
5508
+ const textContent = fragment.textContent || "";
5508
5509
  let tmpNode = document.createElement("div");
5509
5510
  tmpNode.appendChild(fragment.cloneNode(true));
5510
5511
  const str = tmpNode.innerHTML;
5511
- const text = tmpNode.innerText || "";
5512
- const isTextNode = fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName === "#text";
5513
- type.defaultPrevented = str.indexOf("<img") > -1 || str.indexOf("<video") > -1 || !isTextNode && text.length > 1;
5512
+ const notDefault = str.indexOf("<img") > -1 || str.indexOf("<video") > -1;
5513
+ if (!notDefault) {
5514
+ const frag = document.createDocumentFragment();
5515
+ const div = document.createElement("p");
5516
+ div.innerText = textContent;
5517
+ div.className = "halo-paragraph";
5518
+ frag.appendChild(div);
5519
+ type.fragment = frag;
5520
+ }
5521
+ type.defaultPrevented = notDefault;
5514
5522
  tmpNode = null;
5515
5523
  }
5516
5524
  validateDom();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@haluo/biz",
3
3
  "description": "rich text",
4
- "version": "2.0.22",
4
+ "version": "2.0.24",
5
5
  "type": "module",
6
6
  "module": "./dist/haluo-biz.js",
7
7
  "main": "./dist/haluo-biz.umd.cjs",