@haluo/biz 2.0.21 → 2.0.23

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
@@ -5395,15 +5395,33 @@ const _sfc_main = {
5395
5395
  this.styleStatus.color = this.fontInfo.color;
5396
5396
  });
5397
5397
  editorDom.ondragover = function(e) {
5398
+ e.preventDefault();
5398
5399
  if (me2.targetMove && me2.moverClasses.includes(me2.targetMove.className)) {
5399
5400
  if (e.target.offsetParent === editorDom) {
5400
5401
  me2.overLine = e.target.offsetHeight + e.target.offsetTop + "px";
5401
5402
  me2.lasteDropDom = e.target;
5402
5403
  }
5403
- e.preventDefault();
5404
+ }
5405
+ const bottom = document.body.clientHeight - e.clientY - 280;
5406
+ if (e.clientY < 310) {
5407
+ scrollBy({
5408
+ top: -20,
5409
+ left: 0,
5410
+ behavior: "smooth"
5411
+ });
5412
+ } else if (bottom < 100) {
5413
+ scrollBy({
5414
+ top: 20,
5415
+ left: 0,
5416
+ behavior: "smooth"
5417
+ });
5404
5418
  }
5405
5419
  };
5420
+ editorDom.ondragenter = function(e) {
5421
+ e.preventDefault();
5422
+ };
5406
5423
  editorDom.ondrop = function(e) {
5424
+ e.preventDefault();
5407
5425
  if (me2.targetMove && me2.moverClasses.includes(me2.targetMove.className)) {
5408
5426
  const target = me2.lasteDropDom || e.target;
5409
5427
  if (target.parentNode !== editorDom) {
@@ -5416,7 +5434,6 @@ const _sfc_main = {
5416
5434
  }
5417
5435
  me2.targetMove = "";
5418
5436
  me2.lasteDropDom = "";
5419
- e.preventDefault();
5420
5437
  }
5421
5438
  me2.overLine = "";
5422
5439
  };
@@ -5442,8 +5459,8 @@ const _sfc_main = {
5442
5459
  });
5443
5460
  }
5444
5461
  });
5445
- event.preventDefault();
5446
5462
  }
5463
+ event.preventDefault();
5447
5464
  });
5448
5465
  me2.editor.addEventListener("keydown", function(event) {
5449
5466
  if (event.keyCode === 8 || event.keyCode === 46) {
@@ -5486,12 +5503,19 @@ const _sfc_main = {
5486
5503
  me2.editor.addEventListener("willPaste", function(type, handler) {
5487
5504
  function validateDom() {
5488
5505
  const fragment = type && type.fragment || {};
5506
+ const textContent = fragment.textContent || "";
5489
5507
  let tmpNode = document.createElement("div");
5490
5508
  tmpNode.appendChild(fragment.cloneNode(true));
5491
5509
  const str = tmpNode.innerHTML;
5492
- const text = tmpNode.innerText || "";
5493
- const isTextNode = fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName === "#text";
5494
- type.defaultPrevented = str.indexOf("<img") > -1 || str.indexOf("<video") > -1 || !isTextNode && text.length > 1;
5510
+ if (textContent.length < 200) {
5511
+ const frag = document.createDocumentFragment();
5512
+ const div = document.createElement("p");
5513
+ div.innerText = textContent;
5514
+ div.className = "halo-paragraph";
5515
+ frag.appendChild(div);
5516
+ type.fragment = frag;
5517
+ }
5518
+ type.defaultPrevented = str.indexOf("<img") > -1 || str.indexOf("<video") > -1 || textContent.length > 200;
5495
5519
  tmpNode = null;
5496
5520
  }
5497
5521
  validateDom();
@@ -5397,15 +5397,33 @@
5397
5397
  this.styleStatus.color = this.fontInfo.color;
5398
5398
  });
5399
5399
  editorDom.ondragover = function(e) {
5400
+ e.preventDefault();
5400
5401
  if (me2.targetMove && me2.moverClasses.includes(me2.targetMove.className)) {
5401
5402
  if (e.target.offsetParent === editorDom) {
5402
5403
  me2.overLine = e.target.offsetHeight + e.target.offsetTop + "px";
5403
5404
  me2.lasteDropDom = e.target;
5404
5405
  }
5405
- e.preventDefault();
5406
5406
  }
5407
+ const bottom = document.body.clientHeight - e.clientY - 280;
5408
+ if (e.clientY < 310) {
5409
+ scrollBy({
5410
+ top: -20,
5411
+ left: 0,
5412
+ behavior: "smooth"
5413
+ });
5414
+ } else if (bottom < 100) {
5415
+ scrollBy({
5416
+ top: 20,
5417
+ left: 0,
5418
+ behavior: "smooth"
5419
+ });
5420
+ }
5421
+ };
5422
+ editorDom.ondragenter = function(e) {
5423
+ e.preventDefault();
5407
5424
  };
5408
5425
  editorDom.ondrop = function(e) {
5426
+ e.preventDefault();
5409
5427
  if (me2.targetMove && me2.moverClasses.includes(me2.targetMove.className)) {
5410
5428
  const target = me2.lasteDropDom || e.target;
5411
5429
  if (target.parentNode !== editorDom) {
@@ -5418,7 +5436,6 @@
5418
5436
  }
5419
5437
  me2.targetMove = "";
5420
5438
  me2.lasteDropDom = "";
5421
- e.preventDefault();
5422
5439
  }
5423
5440
  me2.overLine = "";
5424
5441
  };
@@ -5444,8 +5461,8 @@
5444
5461
  });
5445
5462
  }
5446
5463
  });
5447
- event.preventDefault();
5448
5464
  }
5465
+ event.preventDefault();
5449
5466
  });
5450
5467
  me2.editor.addEventListener("keydown", function(event) {
5451
5468
  if (event.keyCode === 8 || event.keyCode === 46) {
@@ -5488,12 +5505,19 @@
5488
5505
  me2.editor.addEventListener("willPaste", function(type, handler) {
5489
5506
  function validateDom() {
5490
5507
  const fragment = type && type.fragment || {};
5508
+ const textContent = fragment.textContent || "";
5491
5509
  let tmpNode = document.createElement("div");
5492
5510
  tmpNode.appendChild(fragment.cloneNode(true));
5493
5511
  const str = tmpNode.innerHTML;
5494
- const text = tmpNode.innerText || "";
5495
- const isTextNode = fragment.childNodes.length === 1 && fragment.childNodes[0].nodeName === "#text";
5496
- type.defaultPrevented = str.indexOf("<img") > -1 || str.indexOf("<video") > -1 || !isTextNode && text.length > 1;
5512
+ if (textContent.length < 200) {
5513
+ const frag = document.createDocumentFragment();
5514
+ const div = document.createElement("p");
5515
+ div.innerText = textContent;
5516
+ div.className = "halo-paragraph";
5517
+ frag.appendChild(div);
5518
+ type.fragment = frag;
5519
+ }
5520
+ type.defaultPrevented = str.indexOf("<img") > -1 || str.indexOf("<video") > -1 || textContent.length > 200;
5497
5521
  tmpNode = null;
5498
5522
  }
5499
5523
  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.21",
4
+ "version": "2.0.23",
5
5
  "type": "module",
6
6
  "module": "./dist/haluo-biz.js",
7
7
  "main": "./dist/haluo-biz.umd.cjs",