@haluo/biz 2.0.19-beta.2 → 2.0.19-beta.4

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
@@ -479,8 +479,8 @@ const _sfc_main$7 = {
479
479
  const target = this.$refs["align"];
480
480
  const font = this.$refs["font"];
481
481
  const list = this.$refs["list"];
482
- const img2 = this.$refs["img"];
483
- if ((target == null ? void 0 : target.contains(e)) || (font == null ? void 0 : font.contains(e)) || (list == null ? void 0 : list.contains(e)) || (img2 == null ? void 0 : img2.contains(e)))
482
+ const img = this.$refs["img"];
483
+ if ((target == null ? void 0 : target.contains(e)) || (font == null ? void 0 : font.contains(e)) || (list == null ? void 0 : list.contains(e)) || (img == null ? void 0 : img.contains(e)))
484
484
  return;
485
485
  this.popoverVisible = false;
486
486
  this.popoverVisibleFont = false;
@@ -3866,8 +3866,8 @@ const _sfc_main$4 = defineComponent({
3866
3866
  e.target.value = "";
3867
3867
  emits("update:imgList", tempImgs);
3868
3868
  };
3869
- const deleteImg = (img2) => {
3870
- const arr = props.imgList.filter((item) => item.id !== img2.id);
3869
+ const deleteImg = (img) => {
3870
+ const arr = props.imgList.filter((item) => item.id !== img.id);
3871
3871
  emits("update:imgList", arr);
3872
3872
  };
3873
3873
  const emitEvent = () => {
@@ -3930,9 +3930,9 @@ const _sfc_main$4 = defineComponent({
3930
3930
  const imgList = node.querySelectorAll(".halo-picture-area");
3931
3931
  if (imgList && imgList.length) {
3932
3932
  const list = [];
3933
- imgList.forEach((img2) => {
3934
- if (!list.includes(img2.src)) {
3935
- list.push(img2.src);
3933
+ imgList.forEach((img) => {
3934
+ if (!list.includes(img.src)) {
3935
+ list.push(img.src);
3936
3936
  }
3937
3937
  });
3938
3938
  list.forEach((src, i) => {
@@ -4709,7 +4709,7 @@ const _sfc_main = {
4709
4709
  me2.editorDom = document.getElementById("editor-content");
4710
4710
  me2.editorDom.addEventListener("blur", this.canSetAlign);
4711
4711
  if (!window.Squire) {
4712
- import("./squire-raw.7e84068d.js").then(function() {
4712
+ import("./squire-raw.d3e06d90.js").then(function() {
4713
4713
  me2.initSquire();
4714
4714
  });
4715
4715
  } else {
@@ -4847,7 +4847,7 @@ const _sfc_main = {
4847
4847
  const data = this.filterHtml(html, type);
4848
4848
  return data;
4849
4849
  },
4850
- generateImgHtml(img2, isGif, desc) {
4850
+ generateImgHtml(img, isGif, desc) {
4851
4851
  let descHtml = "";
4852
4852
  if (desc) {
4853
4853
  descHtml = ` <div
@@ -4861,7 +4861,7 @@ const _sfc_main = {
4861
4861
  <div class="show-img-content">
4862
4862
  <img
4863
4863
  alt
4864
- src="${img2}"
4864
+ src="${img}"
4865
4865
  class="detail-imgs"
4866
4866
  onerror="onerror=null;src='/static/img/web_img_zhanwei.png'"
4867
4867
  />
@@ -4888,13 +4888,13 @@ const _sfc_main = {
4888
4888
  if (node.nodeType === 1) {
4889
4889
  if (node.classList.contains("halo-img-content")) {
4890
4890
  const children = [...node.childNodes];
4891
- const img2 = node.querySelector(".halo-picture-area");
4892
- const isGif = img2.src.indexOf(".gif!nowater") > -1;
4891
+ const img = node.querySelector(".halo-picture-area");
4892
+ const isGif = img.src.indexOf(".gif!nowater") > -1;
4893
4893
  if (isGif && type === "preview") {
4894
- img2.src = img2.src.replace(".gif!nowater", ".gif");
4894
+ img.src = img.src.replace(".gif!nowater", ".gif");
4895
4895
  }
4896
4896
  if (type === "preview") {
4897
- node.innerHTML = this.generateImgHtml(img2.src, isGif, img2.dataset.desc);
4897
+ node.innerHTML = this.generateImgHtml(img.src, isGif, img.dataset.desc);
4898
4898
  return;
4899
4899
  }
4900
4900
  children.forEach((child) => {
@@ -4919,9 +4919,9 @@ const _sfc_main = {
4919
4919
  node.innerHTML = this.generateLinkHtml(a.dataset.url, a.innerText);
4920
4920
  return;
4921
4921
  }
4922
- const img2 = node.querySelector(".link-img");
4922
+ const img = node.querySelector(".link-img");
4923
4923
  const del = node.querySelector(".img-delete");
4924
- node.removeChild(img2);
4924
+ node.removeChild(img);
4925
4925
  node.removeChild(del);
4926
4926
  }
4927
4927
  }
@@ -4933,7 +4933,6 @@ const _sfc_main = {
4933
4933
  },
4934
4934
  async parseHtml(html, essayPicRelVOList) {
4935
4935
  var _a;
4936
- const me2 = this;
4937
4936
  const div = document.createElement("div");
4938
4937
  div.innerHTML = html;
4939
4938
  const frag = document.createDocumentFragment();
@@ -4947,27 +4946,19 @@ const _sfc_main = {
4947
4946
  } else if (node.tagName.toLowerCase() === "halo-good") {
4948
4947
  this.parseGood(node);
4949
4948
  } else if (node.classList.contains("halo-img-content")) {
4950
- const img2 = node.querySelector("img");
4949
+ const img = node.querySelector("img");
4951
4950
  node.setAttribute("tabindex", -1);
4952
4951
  node.setAttribute("draggable", true);
4953
4952
  node.setAttribute("contenteditable", false);
4954
- img2.setAttribute("draggable", false);
4955
- node.onclick = function(e) {
4956
- me2.selectDom = node;
4957
- img2.classList.add("halo-select");
4958
- };
4959
- node.onblur = function(e) {
4960
- img2.classList.remove("halo-select");
4961
- me2.selectDom = null;
4962
- };
4963
- this.setDragMove(node);
4964
- const desc = img2.dataset.desc;
4965
- img2.style.margin = "0";
4966
- const seamlessFlag = ((_a = JSON.parse(img2.getAttribute("data"))) == null ? void 0 : _a.seamlessFlag) || "0";
4953
+ img.setAttribute("draggable", false);
4954
+ this.setListener(node);
4955
+ const desc = img.dataset.desc;
4956
+ img.style.margin = "0";
4957
+ const seamlessFlag = ((_a = JSON.parse(img.getAttribute("data"))) == null ? void 0 : _a.seamlessFlag) || "0";
4967
4958
  if (essayPicRelVOList) {
4968
- const arr = img2.src.split("/");
4959
+ const arr = img.src.split("/");
4969
4960
  const id = arr[arr.length - 1];
4970
- img2.src = essayPicRelVOList.find((obj) => obj.id === String(id)).url;
4961
+ img.src = essayPicRelVOList.find((obj) => obj.id === String(id)).url;
4971
4962
  }
4972
4963
  this.insertImgOperateBtns(this.editor, {
4973
4964
  content: desc,
@@ -4985,12 +4976,12 @@ const _sfc_main = {
4985
4976
  return frag;
4986
4977
  },
4987
4978
  parseLink(node) {
4988
- const img2 = this.editor.createElement("img", {
4979
+ const img = this.editor.createElement("img", {
4989
4980
  class: "link-img",
4990
4981
  src: "/static/img/icon_link@3x.png"
4991
4982
  });
4992
4983
  const del = this.generateDelLinkIcon();
4993
- node.prepend(img2);
4984
+ node.prepend(img);
4994
4985
  node.appendChild(del);
4995
4986
  },
4996
4987
  parseVideo(node, essayPicRelVOList) {
@@ -5016,20 +5007,12 @@ const _sfc_main = {
5016
5007
  e.stopPropagation();
5017
5008
  }
5018
5009
  });
5019
- node.onclick = function(e) {
5020
- me2.selectDom = node;
5021
- video.classList.add("halo-select");
5022
- };
5023
- node.onblur = function(e) {
5024
- video.classList.remove("halo-select");
5025
- me2.selectDom = null;
5026
- };
5027
5010
  const replaceBtn = me2.insertVideoBtns(me2.editor, video);
5028
5011
  node.appendChild(delBtn);
5029
5012
  node.appendChild(replaceBtn);
5030
5013
  node.setAttribute("tabindex", -1);
5031
5014
  node.setAttribute("draggable", true);
5032
- me2.setDragMove(node);
5015
+ me2.setListener(node);
5033
5016
  },
5034
5017
  async parseArticle(node) {
5035
5018
  const data = JSON.parse(node.dataset.article);
@@ -5168,8 +5151,8 @@ const _sfc_main = {
5168
5151
  if (this.imgType === "coverImg") {
5169
5152
  this.$emit("insertImgs", imgList_new, this.imgType);
5170
5153
  } else {
5171
- imgList_new.forEach((img2) => {
5172
- this.imgUploadHandler("img", img2.src);
5154
+ imgList_new.forEach((img) => {
5155
+ this.imgUploadHandler("img", img.src);
5173
5156
  });
5174
5157
  }
5175
5158
  this.visibleImg = false;
@@ -5313,8 +5296,8 @@ const _sfc_main = {
5313
5296
  descInput.disabled = me2.disabled;
5314
5297
  descInput.oninput = function(e) {
5315
5298
  const parent = me2.findParentByClass(e.target, "halo-img-content");
5316
- const img2 = parent.querySelector(".halo-picture-area");
5317
- img2.dataset.desc = e.target.value;
5299
+ const img = parent.querySelector(".halo-picture-area");
5300
+ img.dataset.desc = e.target.value;
5318
5301
  if (e.target.value.length > 49) {
5319
5302
  return me2.setToast("\u9650\u523650\u4E2A\u5B57\u7B26");
5320
5303
  }
@@ -5465,11 +5448,18 @@ const _sfc_main = {
5465
5448
  me2.editor.addEventListener("keydown", function(event) {
5466
5449
  if (event.keyCode === 8 || event.keyCode === 46) {
5467
5450
  try {
5451
+ const selection = getSelection();
5468
5452
  if (me2.selectDom && me2.moverClasses.includes(me2.selectDom.className)) {
5469
- me2.selectDom.remove();
5453
+ const range = document.createRange();
5454
+ range.selectNodeContents(me2.selectDom.previousElementSibling);
5455
+ range.collapse(false);
5456
+ selection.removeAllRanges();
5457
+ selection.addRange(range);
5458
+ const removeDom = me2.selectDom || event.target;
5459
+ removeDom.remove();
5470
5460
  me2.selectDom = null;
5461
+ event.preventDefault();
5471
5462
  } else {
5472
- const selection = getSelection();
5473
5463
  if (selection.isCollapsed) {
5474
5464
  const node = selection.focusNode;
5475
5465
  const offSet = selection.focusOffset;
@@ -5480,11 +5470,6 @@ const _sfc_main = {
5480
5470
  if (curSelect) {
5481
5471
  previousSibling.click();
5482
5472
  previousSibling.focus();
5483
- const range = document.createRange();
5484
- range.selectNodeContents(previousSibling);
5485
- range.collapse(false);
5486
- selection.removeAllRanges();
5487
- selection.addRange(range);
5488
5473
  event.preventDefault();
5489
5474
  }
5490
5475
  }
@@ -5495,6 +5480,9 @@ const _sfc_main = {
5495
5480
  }
5496
5481
  }
5497
5482
  });
5483
+ me2.editor.addEventListener("reAddListener", function(event) {
5484
+ me2.setListener();
5485
+ });
5498
5486
  me2.editor.addEventListener("willPaste", function(type, handler) {
5499
5487
  function validateDom() {
5500
5488
  const fragment = type && type.fragment || {};
@@ -5502,7 +5490,8 @@ const _sfc_main = {
5502
5490
  tmpNode.appendChild(fragment.cloneNode(true));
5503
5491
  const str = tmpNode.innerHTML;
5504
5492
  const text = tmpNode.innerText || "";
5505
- type.defaultPrevented = str.indexOf("<img") > -1 || str.indexOf("<video") > -1 || text.length > 1;
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;
5506
5495
  tmpNode = null;
5507
5496
  }
5508
5497
  validateDom();
@@ -5592,7 +5581,7 @@ const _sfc_main = {
5592
5581
  if (isGif) {
5593
5582
  src = src.replace(".gif", ".gif!nowater");
5594
5583
  }
5595
- var img2 = this.createElement("img", {
5584
+ var img = this.createElement("img", {
5596
5585
  "id": isHaloImage ? "" : src,
5597
5586
  "src": src,
5598
5587
  "class": isHaloImage ? "halo-picture-area" : "halo-picture-area no-upload",
@@ -5605,7 +5594,7 @@ const _sfc_main = {
5605
5594
  });
5606
5595
  const btns = me2.insertImgOperateBtns(this, data);
5607
5596
  var childList = [];
5608
- childList.push(img2);
5597
+ childList.push(img);
5609
5598
  childList.push(...btns);
5610
5599
  !isHaloImage && childList.push(loading);
5611
5600
  !isHaloImage && childList.push(fail);
@@ -5616,21 +5605,17 @@ const _sfc_main = {
5616
5605
  "draggable": "true",
5617
5606
  "tabindex": "-1"
5618
5607
  }, [...childList]);
5619
- me2.setDragMove(p);
5620
- p.onclick = function(e) {
5621
- me2.selectDom = p;
5622
- img2.classList.add("halo-select");
5623
- };
5624
- p.onblur = function(e) {
5625
- img2.classList.remove("halo-select");
5626
- me2.selectDom = null;
5627
- };
5608
+ me2.setListener(p);
5628
5609
  this.insertElement(p, range);
5629
5610
  if (isSeameless) {
5630
5611
  me2.removeDefault(p, "nextElementSibling");
5631
5612
  me2.removeDefault(p, "previousElementSibling");
5632
5613
  } else {
5633
- me2.removeDefault(p, "previousElementSibling");
5614
+ const pre = p.previousElementSibling;
5615
+ const isBlock = (pre == null ? void 0 : pre.classList.contains("halo-paragraph")) || false;
5616
+ if (isBlock && (!pre.texContent || pre.innerText === "\n")) {
5617
+ pre.remove();
5618
+ }
5634
5619
  }
5635
5620
  setTimeout(() => {
5636
5621
  document.documentElement.scrollTop = scrollTop;
@@ -5680,17 +5665,10 @@ const _sfc_main = {
5680
5665
  "class": "halo-video-content",
5681
5666
  "contenteditable": "false",
5682
5667
  "data-video": JSON.stringify(data),
5683
- "draggable": "true"
5668
+ "draggable": "true",
5669
+ "tabindex": "-1"
5684
5670
  }, [video, delBtn, posterBtn]);
5685
- p.onclick = function() {
5686
- me2.selectDom = p;
5687
- video.classList.add("halo-select");
5688
- };
5689
- p.onblur = function(e) {
5690
- img.classList.remove("halo-select");
5691
- me2.selectDom = null;
5692
- };
5693
- me2.setDragMove(p);
5671
+ me2.setListener(p);
5694
5672
  this.insertElement(p);
5695
5673
  setTimeout(() => {
5696
5674
  document.documentElement.scrollTop = scrollTop;
@@ -5698,14 +5676,14 @@ const _sfc_main = {
5698
5676
  };
5699
5677
  window.Squire.prototype.insertLink = function(link, text) {
5700
5678
  var scrollTop = document.documentElement.scrollTop;
5701
- var img2 = `<img class="link-img" src='/static/img/icon_link@3x.png'></img>`;
5679
+ var img = `<img class="link-img" src='/static/img/icon_link@3x.png'></img>`;
5702
5680
  var a = `<a class="halo-link-mes" data-url="${link}" target="_blank">${text}</a>`;
5703
5681
  const del = me2.generateDelLinkIcon();
5704
5682
  var p = this.createElement("DIV", {
5705
5683
  "class": "halo-link",
5706
5684
  "contenteditable": "false"
5707
5685
  });
5708
- p.innerHTML = img2 + a;
5686
+ p.innerHTML = img + a;
5709
5687
  p.appendChild(del);
5710
5688
  this.insertElement(p);
5711
5689
  setTimeout(() => {
@@ -5726,6 +5704,47 @@ const _sfc_main = {
5726
5704
  }
5727
5705
  };
5728
5706
  },
5707
+ setListener(dom) {
5708
+ const me2 = this;
5709
+ const doms = dom ? [dom] : Array.from(this.editorDom.children);
5710
+ doms.forEach((p) => {
5711
+ if (me2.moverClasses.includes(p.className)) {
5712
+ me2.setDragMove(p);
5713
+ const area = p.firstChild;
5714
+ p.onclick = function() {
5715
+ var _a;
5716
+ if (area.nodeName === "VIDEO" && ((_a = me2.selectDom) == null ? void 0 : _a.className) === "halo-video-content") {
5717
+ me2.setToast("\u4E0D\u652F\u6301\u64AD\u653E");
5718
+ }
5719
+ me2.selectDom = p;
5720
+ const selected = document.querySelector(".halo-select");
5721
+ selected && selected.classList.remove("halo-select");
5722
+ area.classList.add("halo-select");
5723
+ p.focus();
5724
+ };
5725
+ p.onblur = function(e) {
5726
+ area.classList.remove("halo-select");
5727
+ me2.selectDom = null;
5728
+ };
5729
+ const deleteVideo = p.querySelector(".video-delete");
5730
+ const deleteImg = p.querySelector(".img-delete");
5731
+ if (deleteImg) {
5732
+ deleteImg.onclick = function(e) {
5733
+ if (me2.disabled)
5734
+ return;
5735
+ me2.removeSeamlessLaster(e);
5736
+ p.remove();
5737
+ me2.updateData(true);
5738
+ };
5739
+ }
5740
+ if (deleteVideo) {
5741
+ deleteVideo.onclick = function() {
5742
+ p.remove();
5743
+ };
5744
+ }
5745
+ }
5746
+ });
5747
+ },
5729
5748
  removeDefault(next, key) {
5730
5749
  const me2 = this;
5731
5750
  const cur = next[key];
@@ -5783,9 +5802,9 @@ const _sfc_main = {
5783
5802
  count += text.replace(/\n/g, "").length;
5784
5803
  isNotParagraph = false;
5785
5804
  } else if (value.className === "halo-img-content") {
5786
- const img2 = value.querySelector(".halo-picture-area");
5805
+ const img = value.querySelector(".halo-picture-area");
5787
5806
  isNotParagraph = false;
5788
- if (img2.src.indexOf("jddmoto") === -1 && img2.src.indexOf("58moto") === -1) {
5807
+ if (img.src.indexOf("jddmoto") === -1 && img.src.indexOf("58moto") === -1) {
5789
5808
  hasFailUploadImg = true;
5790
5809
  return;
5791
5810
  }
@@ -5886,8 +5905,8 @@ const _sfc_main = {
5886
5905
  businessId: 2
5887
5906
  }).then((_) => {
5888
5907
  if (_.data.code === 0 && _.data.data) {
5889
- const img2 = _.data.data.thirdPartyImageUrl;
5890
- me2.updateImage(img2, currentImg);
5908
+ const img = _.data.data.thirdPartyImageUrl;
5909
+ me2.updateImage(img, currentImg);
5891
5910
  } else {
5892
5911
  parent && uploadFailHandler(currentImg);
5893
5912
  }
@@ -5901,10 +5920,10 @@ const _sfc_main = {
5901
5920
  parent && uploadFailHandler(currentImg);
5902
5921
  });
5903
5922
  },
5904
- updateImage(img2, currentImg = {}) {
5923
+ updateImage(img, currentImg = {}) {
5905
5924
  const data = JSON.parse(currentImg.getAttribute("data") || "{}");
5906
- data.img = img2;
5907
- currentImg.setAttribute("src", img2);
5925
+ data.img = img;
5926
+ currentImg.setAttribute("src", img);
5908
5927
  currentImg.setAttribute("data", JSON.stringify(data));
5909
5928
  currentImg.className = "halo-picture-area";
5910
5929
  const parent = currentImg.parentNode || "";
@@ -481,8 +481,8 @@
481
481
  const target = this.$refs["align"];
482
482
  const font = this.$refs["font"];
483
483
  const list = this.$refs["list"];
484
- const img2 = this.$refs["img"];
485
- if ((target == null ? void 0 : target.contains(e)) || (font == null ? void 0 : font.contains(e)) || (list == null ? void 0 : list.contains(e)) || (img2 == null ? void 0 : img2.contains(e)))
484
+ const img = this.$refs["img"];
485
+ if ((target == null ? void 0 : target.contains(e)) || (font == null ? void 0 : font.contains(e)) || (list == null ? void 0 : list.contains(e)) || (img == null ? void 0 : img.contains(e)))
486
486
  return;
487
487
  this.popoverVisible = false;
488
488
  this.popoverVisibleFont = false;
@@ -3868,8 +3868,8 @@
3868
3868
  e.target.value = "";
3869
3869
  emits("update:imgList", tempImgs);
3870
3870
  };
3871
- const deleteImg = (img2) => {
3872
- const arr = props.imgList.filter((item) => item.id !== img2.id);
3871
+ const deleteImg = (img) => {
3872
+ const arr = props.imgList.filter((item) => item.id !== img.id);
3873
3873
  emits("update:imgList", arr);
3874
3874
  };
3875
3875
  const emitEvent = () => {
@@ -3932,9 +3932,9 @@
3932
3932
  const imgList = node.querySelectorAll(".halo-picture-area");
3933
3933
  if (imgList && imgList.length) {
3934
3934
  const list = [];
3935
- imgList.forEach((img2) => {
3936
- if (!list.includes(img2.src)) {
3937
- list.push(img2.src);
3935
+ imgList.forEach((img) => {
3936
+ if (!list.includes(img.src)) {
3937
+ list.push(img.src);
3938
3938
  }
3939
3939
  });
3940
3940
  list.forEach((src, i) => {
@@ -4849,7 +4849,7 @@
4849
4849
  const data = this.filterHtml(html, type);
4850
4850
  return data;
4851
4851
  },
4852
- generateImgHtml(img2, isGif, desc) {
4852
+ generateImgHtml(img, isGif, desc) {
4853
4853
  let descHtml = "";
4854
4854
  if (desc) {
4855
4855
  descHtml = ` <div
@@ -4863,7 +4863,7 @@
4863
4863
  <div class="show-img-content">
4864
4864
  <img
4865
4865
  alt
4866
- src="${img2}"
4866
+ src="${img}"
4867
4867
  class="detail-imgs"
4868
4868
  onerror="onerror=null;src='/static/img/web_img_zhanwei.png'"
4869
4869
  />
@@ -4890,13 +4890,13 @@
4890
4890
  if (node.nodeType === 1) {
4891
4891
  if (node.classList.contains("halo-img-content")) {
4892
4892
  const children = [...node.childNodes];
4893
- const img2 = node.querySelector(".halo-picture-area");
4894
- const isGif = img2.src.indexOf(".gif!nowater") > -1;
4893
+ const img = node.querySelector(".halo-picture-area");
4894
+ const isGif = img.src.indexOf(".gif!nowater") > -1;
4895
4895
  if (isGif && type === "preview") {
4896
- img2.src = img2.src.replace(".gif!nowater", ".gif");
4896
+ img.src = img.src.replace(".gif!nowater", ".gif");
4897
4897
  }
4898
4898
  if (type === "preview") {
4899
- node.innerHTML = this.generateImgHtml(img2.src, isGif, img2.dataset.desc);
4899
+ node.innerHTML = this.generateImgHtml(img.src, isGif, img.dataset.desc);
4900
4900
  return;
4901
4901
  }
4902
4902
  children.forEach((child) => {
@@ -4921,9 +4921,9 @@
4921
4921
  node.innerHTML = this.generateLinkHtml(a.dataset.url, a.innerText);
4922
4922
  return;
4923
4923
  }
4924
- const img2 = node.querySelector(".link-img");
4924
+ const img = node.querySelector(".link-img");
4925
4925
  const del = node.querySelector(".img-delete");
4926
- node.removeChild(img2);
4926
+ node.removeChild(img);
4927
4927
  node.removeChild(del);
4928
4928
  }
4929
4929
  }
@@ -4935,7 +4935,6 @@
4935
4935
  },
4936
4936
  async parseHtml(html, essayPicRelVOList) {
4937
4937
  var _a;
4938
- const me2 = this;
4939
4938
  const div = document.createElement("div");
4940
4939
  div.innerHTML = html;
4941
4940
  const frag = document.createDocumentFragment();
@@ -4949,27 +4948,19 @@
4949
4948
  } else if (node.tagName.toLowerCase() === "halo-good") {
4950
4949
  this.parseGood(node);
4951
4950
  } else if (node.classList.contains("halo-img-content")) {
4952
- const img2 = node.querySelector("img");
4951
+ const img = node.querySelector("img");
4953
4952
  node.setAttribute("tabindex", -1);
4954
4953
  node.setAttribute("draggable", true);
4955
4954
  node.setAttribute("contenteditable", false);
4956
- img2.setAttribute("draggable", false);
4957
- node.onclick = function(e) {
4958
- me2.selectDom = node;
4959
- img2.classList.add("halo-select");
4960
- };
4961
- node.onblur = function(e) {
4962
- img2.classList.remove("halo-select");
4963
- me2.selectDom = null;
4964
- };
4965
- this.setDragMove(node);
4966
- const desc = img2.dataset.desc;
4967
- img2.style.margin = "0";
4968
- const seamlessFlag = ((_a = JSON.parse(img2.getAttribute("data"))) == null ? void 0 : _a.seamlessFlag) || "0";
4955
+ img.setAttribute("draggable", false);
4956
+ this.setListener(node);
4957
+ const desc = img.dataset.desc;
4958
+ img.style.margin = "0";
4959
+ const seamlessFlag = ((_a = JSON.parse(img.getAttribute("data"))) == null ? void 0 : _a.seamlessFlag) || "0";
4969
4960
  if (essayPicRelVOList) {
4970
- const arr = img2.src.split("/");
4961
+ const arr = img.src.split("/");
4971
4962
  const id = arr[arr.length - 1];
4972
- img2.src = essayPicRelVOList.find((obj) => obj.id === String(id)).url;
4963
+ img.src = essayPicRelVOList.find((obj) => obj.id === String(id)).url;
4973
4964
  }
4974
4965
  this.insertImgOperateBtns(this.editor, {
4975
4966
  content: desc,
@@ -4987,12 +4978,12 @@
4987
4978
  return frag;
4988
4979
  },
4989
4980
  parseLink(node) {
4990
- const img2 = this.editor.createElement("img", {
4981
+ const img = this.editor.createElement("img", {
4991
4982
  class: "link-img",
4992
4983
  src: "/static/img/icon_link@3x.png"
4993
4984
  });
4994
4985
  const del = this.generateDelLinkIcon();
4995
- node.prepend(img2);
4986
+ node.prepend(img);
4996
4987
  node.appendChild(del);
4997
4988
  },
4998
4989
  parseVideo(node, essayPicRelVOList) {
@@ -5018,20 +5009,12 @@
5018
5009
  e.stopPropagation();
5019
5010
  }
5020
5011
  });
5021
- node.onclick = function(e) {
5022
- me2.selectDom = node;
5023
- video.classList.add("halo-select");
5024
- };
5025
- node.onblur = function(e) {
5026
- video.classList.remove("halo-select");
5027
- me2.selectDom = null;
5028
- };
5029
5012
  const replaceBtn = me2.insertVideoBtns(me2.editor, video);
5030
5013
  node.appendChild(delBtn);
5031
5014
  node.appendChild(replaceBtn);
5032
5015
  node.setAttribute("tabindex", -1);
5033
5016
  node.setAttribute("draggable", true);
5034
- me2.setDragMove(node);
5017
+ me2.setListener(node);
5035
5018
  },
5036
5019
  async parseArticle(node) {
5037
5020
  const data = JSON.parse(node.dataset.article);
@@ -5170,8 +5153,8 @@
5170
5153
  if (this.imgType === "coverImg") {
5171
5154
  this.$emit("insertImgs", imgList_new, this.imgType);
5172
5155
  } else {
5173
- imgList_new.forEach((img2) => {
5174
- this.imgUploadHandler("img", img2.src);
5156
+ imgList_new.forEach((img) => {
5157
+ this.imgUploadHandler("img", img.src);
5175
5158
  });
5176
5159
  }
5177
5160
  this.visibleImg = false;
@@ -5315,8 +5298,8 @@
5315
5298
  descInput.disabled = me2.disabled;
5316
5299
  descInput.oninput = function(e) {
5317
5300
  const parent = me2.findParentByClass(e.target, "halo-img-content");
5318
- const img2 = parent.querySelector(".halo-picture-area");
5319
- img2.dataset.desc = e.target.value;
5301
+ const img = parent.querySelector(".halo-picture-area");
5302
+ img.dataset.desc = e.target.value;
5320
5303
  if (e.target.value.length > 49) {
5321
5304
  return me2.setToast("\u9650\u523650\u4E2A\u5B57\u7B26");
5322
5305
  }
@@ -5467,11 +5450,18 @@
5467
5450
  me2.editor.addEventListener("keydown", function(event) {
5468
5451
  if (event.keyCode === 8 || event.keyCode === 46) {
5469
5452
  try {
5453
+ const selection = getSelection();
5470
5454
  if (me2.selectDom && me2.moverClasses.includes(me2.selectDom.className)) {
5471
- me2.selectDom.remove();
5455
+ const range = document.createRange();
5456
+ range.selectNodeContents(me2.selectDom.previousElementSibling);
5457
+ range.collapse(false);
5458
+ selection.removeAllRanges();
5459
+ selection.addRange(range);
5460
+ const removeDom = me2.selectDom || event.target;
5461
+ removeDom.remove();
5472
5462
  me2.selectDom = null;
5463
+ event.preventDefault();
5473
5464
  } else {
5474
- const selection = getSelection();
5475
5465
  if (selection.isCollapsed) {
5476
5466
  const node = selection.focusNode;
5477
5467
  const offSet = selection.focusOffset;
@@ -5482,11 +5472,6 @@
5482
5472
  if (curSelect) {
5483
5473
  previousSibling.click();
5484
5474
  previousSibling.focus();
5485
- const range = document.createRange();
5486
- range.selectNodeContents(previousSibling);
5487
- range.collapse(false);
5488
- selection.removeAllRanges();
5489
- selection.addRange(range);
5490
5475
  event.preventDefault();
5491
5476
  }
5492
5477
  }
@@ -5497,6 +5482,9 @@
5497
5482
  }
5498
5483
  }
5499
5484
  });
5485
+ me2.editor.addEventListener("reAddListener", function(event) {
5486
+ me2.setListener();
5487
+ });
5500
5488
  me2.editor.addEventListener("willPaste", function(type, handler) {
5501
5489
  function validateDom() {
5502
5490
  const fragment = type && type.fragment || {};
@@ -5504,7 +5492,8 @@
5504
5492
  tmpNode.appendChild(fragment.cloneNode(true));
5505
5493
  const str = tmpNode.innerHTML;
5506
5494
  const text = tmpNode.innerText || "";
5507
- type.defaultPrevented = str.indexOf("<img") > -1 || str.indexOf("<video") > -1 || text.length > 1;
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;
5508
5497
  tmpNode = null;
5509
5498
  }
5510
5499
  validateDom();
@@ -5594,7 +5583,7 @@
5594
5583
  if (isGif) {
5595
5584
  src = src.replace(".gif", ".gif!nowater");
5596
5585
  }
5597
- var img2 = this.createElement("img", {
5586
+ var img = this.createElement("img", {
5598
5587
  "id": isHaloImage ? "" : src,
5599
5588
  "src": src,
5600
5589
  "class": isHaloImage ? "halo-picture-area" : "halo-picture-area no-upload",
@@ -5607,7 +5596,7 @@
5607
5596
  });
5608
5597
  const btns = me2.insertImgOperateBtns(this, data);
5609
5598
  var childList = [];
5610
- childList.push(img2);
5599
+ childList.push(img);
5611
5600
  childList.push(...btns);
5612
5601
  !isHaloImage && childList.push(loading);
5613
5602
  !isHaloImage && childList.push(fail);
@@ -5618,21 +5607,17 @@
5618
5607
  "draggable": "true",
5619
5608
  "tabindex": "-1"
5620
5609
  }, [...childList]);
5621
- me2.setDragMove(p);
5622
- p.onclick = function(e) {
5623
- me2.selectDom = p;
5624
- img2.classList.add("halo-select");
5625
- };
5626
- p.onblur = function(e) {
5627
- img2.classList.remove("halo-select");
5628
- me2.selectDom = null;
5629
- };
5610
+ me2.setListener(p);
5630
5611
  this.insertElement(p, range);
5631
5612
  if (isSeameless) {
5632
5613
  me2.removeDefault(p, "nextElementSibling");
5633
5614
  me2.removeDefault(p, "previousElementSibling");
5634
5615
  } else {
5635
- me2.removeDefault(p, "previousElementSibling");
5616
+ const pre = p.previousElementSibling;
5617
+ const isBlock = (pre == null ? void 0 : pre.classList.contains("halo-paragraph")) || false;
5618
+ if (isBlock && (!pre.texContent || pre.innerText === "\n")) {
5619
+ pre.remove();
5620
+ }
5636
5621
  }
5637
5622
  setTimeout(() => {
5638
5623
  document.documentElement.scrollTop = scrollTop;
@@ -5682,17 +5667,10 @@
5682
5667
  "class": "halo-video-content",
5683
5668
  "contenteditable": "false",
5684
5669
  "data-video": JSON.stringify(data),
5685
- "draggable": "true"
5670
+ "draggable": "true",
5671
+ "tabindex": "-1"
5686
5672
  }, [video, delBtn, posterBtn]);
5687
- p.onclick = function() {
5688
- me2.selectDom = p;
5689
- video.classList.add("halo-select");
5690
- };
5691
- p.onblur = function(e) {
5692
- img.classList.remove("halo-select");
5693
- me2.selectDom = null;
5694
- };
5695
- me2.setDragMove(p);
5673
+ me2.setListener(p);
5696
5674
  this.insertElement(p);
5697
5675
  setTimeout(() => {
5698
5676
  document.documentElement.scrollTop = scrollTop;
@@ -5700,14 +5678,14 @@
5700
5678
  };
5701
5679
  window.Squire.prototype.insertLink = function(link, text) {
5702
5680
  var scrollTop = document.documentElement.scrollTop;
5703
- var img2 = `<img class="link-img" src='/static/img/icon_link@3x.png'></img>`;
5681
+ var img = `<img class="link-img" src='/static/img/icon_link@3x.png'></img>`;
5704
5682
  var a = `<a class="halo-link-mes" data-url="${link}" target="_blank">${text}</a>`;
5705
5683
  const del = me2.generateDelLinkIcon();
5706
5684
  var p = this.createElement("DIV", {
5707
5685
  "class": "halo-link",
5708
5686
  "contenteditable": "false"
5709
5687
  });
5710
- p.innerHTML = img2 + a;
5688
+ p.innerHTML = img + a;
5711
5689
  p.appendChild(del);
5712
5690
  this.insertElement(p);
5713
5691
  setTimeout(() => {
@@ -5728,6 +5706,47 @@
5728
5706
  }
5729
5707
  };
5730
5708
  },
5709
+ setListener(dom) {
5710
+ const me2 = this;
5711
+ const doms = dom ? [dom] : Array.from(this.editorDom.children);
5712
+ doms.forEach((p) => {
5713
+ if (me2.moverClasses.includes(p.className)) {
5714
+ me2.setDragMove(p);
5715
+ const area = p.firstChild;
5716
+ p.onclick = function() {
5717
+ var _a;
5718
+ if (area.nodeName === "VIDEO" && ((_a = me2.selectDom) == null ? void 0 : _a.className) === "halo-video-content") {
5719
+ me2.setToast("\u4E0D\u652F\u6301\u64AD\u653E");
5720
+ }
5721
+ me2.selectDom = p;
5722
+ const selected = document.querySelector(".halo-select");
5723
+ selected && selected.classList.remove("halo-select");
5724
+ area.classList.add("halo-select");
5725
+ p.focus();
5726
+ };
5727
+ p.onblur = function(e) {
5728
+ area.classList.remove("halo-select");
5729
+ me2.selectDom = null;
5730
+ };
5731
+ const deleteVideo = p.querySelector(".video-delete");
5732
+ const deleteImg = p.querySelector(".img-delete");
5733
+ if (deleteImg) {
5734
+ deleteImg.onclick = function(e) {
5735
+ if (me2.disabled)
5736
+ return;
5737
+ me2.removeSeamlessLaster(e);
5738
+ p.remove();
5739
+ me2.updateData(true);
5740
+ };
5741
+ }
5742
+ if (deleteVideo) {
5743
+ deleteVideo.onclick = function() {
5744
+ p.remove();
5745
+ };
5746
+ }
5747
+ }
5748
+ });
5749
+ },
5731
5750
  removeDefault(next, key) {
5732
5751
  const me2 = this;
5733
5752
  const cur = next[key];
@@ -5785,9 +5804,9 @@
5785
5804
  count += text.replace(/\n/g, "").length;
5786
5805
  isNotParagraph = false;
5787
5806
  } else if (value.className === "halo-img-content") {
5788
- const img2 = value.querySelector(".halo-picture-area");
5807
+ const img = value.querySelector(".halo-picture-area");
5789
5808
  isNotParagraph = false;
5790
- if (img2.src.indexOf("jddmoto") === -1 && img2.src.indexOf("58moto") === -1) {
5809
+ if (img.src.indexOf("jddmoto") === -1 && img.src.indexOf("58moto") === -1) {
5791
5810
  hasFailUploadImg = true;
5792
5811
  return;
5793
5812
  }
@@ -5888,8 +5907,8 @@
5888
5907
  businessId: 2
5889
5908
  }).then((_) => {
5890
5909
  if (_.data.code === 0 && _.data.data) {
5891
- const img2 = _.data.data.thirdPartyImageUrl;
5892
- me2.updateImage(img2, currentImg);
5910
+ const img = _.data.data.thirdPartyImageUrl;
5911
+ me2.updateImage(img, currentImg);
5893
5912
  } else {
5894
5913
  parent && uploadFailHandler(currentImg);
5895
5914
  }
@@ -5903,10 +5922,10 @@
5903
5922
  parent && uploadFailHandler(currentImg);
5904
5923
  });
5905
5924
  },
5906
- updateImage(img2, currentImg = {}) {
5925
+ updateImage(img, currentImg = {}) {
5907
5926
  const data = JSON.parse(currentImg.getAttribute("data") || "{}");
5908
- data.img = img2;
5909
- currentImg.setAttribute("src", img2);
5927
+ data.img = img;
5928
+ currentImg.setAttribute("src", img);
5910
5929
  currentImg.setAttribute("data", JSON.stringify(data));
5911
5930
  currentImg.className = "halo-picture-area";
5912
5931
  const parent = currentImg.parentNode || "";
@@ -9409,8 +9428,8 @@
9409
9428
  const node2 = nodes[i];
9410
9429
  if (node2.nodeType === 1) {
9411
9430
  if (node2.classList.contains("halo-img-content")) {
9412
- var img2 = node2.querySelector("img");
9413
- var desc = img2.dataset.desc;
9431
+ var img = node2.querySelector("img");
9432
+ var desc = img.dataset.desc;
9414
9433
  var textarea = node2.querySelector("textarea");
9415
9434
  textarea.innerHTML = "";
9416
9435
  textarea.value = desc || "";
@@ -9423,6 +9442,7 @@
9423
9442
  var node = root;
9424
9443
  node.innerHTML = html;
9425
9444
  fixTextarea(node);
9445
+ this.fireEvent("reAddListener", node);
9426
9446
  do {
9427
9447
  fixCursor(node, root);
9428
9448
  } while (node = getNextBlock(node, root));
@@ -9535,11 +9555,11 @@
9535
9555
  return this;
9536
9556
  };
9537
9557
  proto.insertImage = function(src, attributes) {
9538
- var img2 = this.createElement("IMG", mergeObjects({
9558
+ var img = this.createElement("IMG", mergeObjects({
9539
9559
  src
9540
9560
  }, attributes, true));
9541
- this.insertElement(img2);
9542
- return img2;
9561
+ this.insertElement(img);
9562
+ return img;
9543
9563
  };
9544
9564
  var linkRegExp = /\b((?:(?:ht|f)tps?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,}\/)(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))|([\w\-.%+]+@(?:[\w\-]+\.)+[A-Z]{2,}\b)(?:\?[^&?\s]+=[^&?\s]+(?:&[^&?\s]+=[^&?\s]+)*)?/i;
9545
9565
  var addLinks = function(frag, root, self2) {
@@ -3131,6 +3131,7 @@
3131
3131
  var node = root;
3132
3132
  node.innerHTML = html;
3133
3133
  fixTextarea(node);
3134
+ this.fireEvent("reAddListener", node);
3134
3135
  do {
3135
3136
  fixCursor(node, root);
3136
3137
  } while (node = getNextBlock(node, root));
package/dist/style.css CHANGED
@@ -821,6 +821,10 @@
821
821
  top: 0;
822
822
  width: 440px;
823
823
  height: 100%;
824
+ left: 50%;
825
+ -webkit-transform: translateX(-50%);
826
+ -ms-transform: translateX(-50%);
827
+ transform: translateX(-50%);
824
828
  line-height: 25px;
825
829
  font-size: 18px;
826
830
  z-index: 1;
@@ -850,6 +854,10 @@
850
854
  font-weight: 400;
851
855
  color: #fff;
852
856
  z-index: 1;
857
+ left: 50%;
858
+ -webkit-transform: translateX(-50%);
859
+ -ms-transform: translateX(-50%);
860
+ transform: translateX(-50%);
853
861
  width: 90px;
854
862
  line-height: 32px;
855
863
  height: 32px;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@haluo/biz",
3
3
  "description": "rich text",
4
- "version": "2.0.19-beta.2",
4
+ "version": "2.0.19-beta.4",
5
5
  "type": "module",
6
6
  "module": "./dist/haluo-biz.js",
7
7
  "main": "./dist/haluo-biz.umd.cjs",