@haluo/biz 0.1.20 → 0.1.22

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
@@ -5103,6 +5103,7 @@ const _sfc_main = {
5103
5103
  });
5104
5104
  },
5105
5105
  imgUploadHandler(type, imgSrc) {
5106
+ const me = this;
5106
5107
  if (type && imgSrc) {
5107
5108
  if (type === "uploadAgainImages") {
5108
5109
  this.updateImage(imgSrc, this.currentImg);
@@ -5114,7 +5115,7 @@ const _sfc_main = {
5114
5115
  src: imgSrc,
5115
5116
  img: imgSrc,
5116
5117
  selected: false,
5117
- seamlessFlag: this.replaceSeamless,
5118
+ seamlessFlag: me.replaceSeamless,
5118
5119
  type: "2"
5119
5120
  }, this.range);
5120
5121
  } else {
@@ -5175,7 +5176,7 @@ const _sfc_main = {
5175
5176
  return;
5176
5177
  const current = me.findParentByClass(e.target, "halo-img-content");
5177
5178
  const range = document.createRange();
5178
- range.setEnd(current.previousElementSibling || current, 1);
5179
+ range.setEnd(current.previousElementSibling, 1);
5179
5180
  range.collapse(false);
5180
5181
  me.range = range;
5181
5182
  me.replaceSeamless = data.seamlessFlag || "0";
@@ -5186,6 +5187,24 @@ const _sfc_main = {
5186
5187
  delBtn.onclick = function(e) {
5187
5188
  if (me.disabled)
5188
5189
  return;
5190
+ const cur = me.findParentByClass(e.target, "halo-img-content");
5191
+ const currentImg = cur.getElementsByClassName("halo-picture-area")[0];
5192
+ const currentData = JSON.parse(currentImg.getAttribute("data"));
5193
+ if (currentData.seamlessFlag === "0") {
5194
+ if (!cur.previousElementSibling)
5195
+ return;
5196
+ try {
5197
+ const imgcont = cur.previousElementSibling.previousElementSibling;
5198
+ const input = imgcont.getElementsByClassName("desc-input-wrap")[0];
5199
+ const pic = imgcont.getElementsByClassName("halo-picture-area")[0];
5200
+ const data2 = JSON.parse(pic.getAttribute("data"));
5201
+ data2.seamlessFlag = "0";
5202
+ pic.setAttribute("data", JSON.stringify(data2));
5203
+ input.style.display = "";
5204
+ } catch (e2) {
5205
+ console.log(e2);
5206
+ }
5207
+ }
5189
5208
  me.removeParentByClass(e.target, "halo-img-content");
5190
5209
  me.updateData(true);
5191
5210
  };
@@ -5290,6 +5309,7 @@ const _sfc_main = {
5290
5309
  window.Squire.prototype.insertImages = function(src, data = {}, range) {
5291
5310
  var isHaloImage = me.isHaloImage(src);
5292
5311
  var scrollTop = document.documentElement.scrollTop;
5312
+ const isSeameless = data.seamlessFlag === "1";
5293
5313
  var loading = this.createElement("div", {
5294
5314
  "class": "img-loading",
5295
5315
  "contenteditable": "false"
@@ -5317,7 +5337,7 @@ const _sfc_main = {
5317
5337
  "src": src,
5318
5338
  "class": isHaloImage ? "halo-picture-area" : "halo-picture-area no-upload",
5319
5339
  "data": JSON.stringify(data),
5320
- "style": data.seamlessFlag === "1" ? "margin: 0" : "margin-top: 0",
5340
+ "style": isSeameless ? "margin: 0" : "margin-top: 0",
5321
5341
  "data-content": data.content || "",
5322
5342
  "contenteditable": "false"
5323
5343
  });
@@ -5332,16 +5352,11 @@ const _sfc_main = {
5332
5352
  "class": "halo-img-content",
5333
5353
  "contenteditable": "false"
5334
5354
  }, [...childList]);
5335
- if (me.imgType === "seamless") {
5336
- me.countList.push(p);
5337
- if (me.countList.length === me.imgList.length) {
5338
- var ct = this.createElement("div", {}, [...me.countList]);
5339
- this.insertElement(ct, range);
5340
- this.imgType = "normal";
5341
- }
5342
- return;
5343
- }
5344
5355
  this.insertElement(p, range);
5356
+ if (isSeameless) {
5357
+ me.removeDefault(p, "nextElementSibling");
5358
+ me.removeDefault(p, "previousElementSibling");
5359
+ }
5345
5360
  setTimeout(() => {
5346
5361
  document.documentElement.scrollTop = scrollTop;
5347
5362
  }, 50);
@@ -5415,6 +5430,23 @@ const _sfc_main = {
5415
5430
  };
5416
5431
  me.sticky();
5417
5432
  },
5433
+ removeDefault(next, key) {
5434
+ const me = this;
5435
+ const cur = next[key];
5436
+ if (!cur || cur.innerText !== "\n")
5437
+ return;
5438
+ const blockDefault = cur.classList.contains("halo-paragraph") || false;
5439
+ const isLasterBlock = next.classList.contains("halo-paragraph") || false;
5440
+ if (blockDefault && isLasterBlock) {
5441
+ cur.remove();
5442
+ me.removeDefault(cur, key);
5443
+ } else {
5444
+ if (blockDefault) {
5445
+ cur.style.display = "none";
5446
+ me.removeDefault(cur, key);
5447
+ }
5448
+ }
5449
+ },
5418
5450
  generateDelLinkIcon() {
5419
5451
  const me = this;
5420
5452
  const del = this.editor.createElement("img", {
@@ -5108,6 +5108,7 @@
5108
5108
  });
5109
5109
  },
5110
5110
  imgUploadHandler(type, imgSrc) {
5111
+ const me = this;
5111
5112
  if (type && imgSrc) {
5112
5113
  if (type === "uploadAgainImages") {
5113
5114
  this.updateImage(imgSrc, this.currentImg);
@@ -5119,7 +5120,7 @@
5119
5120
  src: imgSrc,
5120
5121
  img: imgSrc,
5121
5122
  selected: false,
5122
- seamlessFlag: this.replaceSeamless,
5123
+ seamlessFlag: me.replaceSeamless,
5123
5124
  type: "2"
5124
5125
  }, this.range);
5125
5126
  } else {
@@ -5180,7 +5181,7 @@
5180
5181
  return;
5181
5182
  const current = me.findParentByClass(e.target, "halo-img-content");
5182
5183
  const range = document.createRange();
5183
- range.setEnd(current.previousElementSibling || current, 1);
5184
+ range.setEnd(current.previousElementSibling, 1);
5184
5185
  range.collapse(false);
5185
5186
  me.range = range;
5186
5187
  me.replaceSeamless = data.seamlessFlag || "0";
@@ -5191,6 +5192,24 @@
5191
5192
  delBtn.onclick = function(e) {
5192
5193
  if (me.disabled)
5193
5194
  return;
5195
+ const cur = me.findParentByClass(e.target, "halo-img-content");
5196
+ const currentImg = cur.getElementsByClassName("halo-picture-area")[0];
5197
+ const currentData = JSON.parse(currentImg.getAttribute("data"));
5198
+ if (currentData.seamlessFlag === "0") {
5199
+ if (!cur.previousElementSibling)
5200
+ return;
5201
+ try {
5202
+ const imgcont = cur.previousElementSibling.previousElementSibling;
5203
+ const input = imgcont.getElementsByClassName("desc-input-wrap")[0];
5204
+ const pic = imgcont.getElementsByClassName("halo-picture-area")[0];
5205
+ const data2 = JSON.parse(pic.getAttribute("data"));
5206
+ data2.seamlessFlag = "0";
5207
+ pic.setAttribute("data", JSON.stringify(data2));
5208
+ input.style.display = "";
5209
+ } catch (e2) {
5210
+ console.log(e2);
5211
+ }
5212
+ }
5194
5213
  me.removeParentByClass(e.target, "halo-img-content");
5195
5214
  me.updateData(true);
5196
5215
  };
@@ -5295,6 +5314,7 @@
5295
5314
  window.Squire.prototype.insertImages = function(src, data = {}, range) {
5296
5315
  var isHaloImage = me.isHaloImage(src);
5297
5316
  var scrollTop = document.documentElement.scrollTop;
5317
+ const isSeameless = data.seamlessFlag === "1";
5298
5318
  var loading = this.createElement("div", {
5299
5319
  "class": "img-loading",
5300
5320
  "contenteditable": "false"
@@ -5322,7 +5342,7 @@
5322
5342
  "src": src,
5323
5343
  "class": isHaloImage ? "halo-picture-area" : "halo-picture-area no-upload",
5324
5344
  "data": JSON.stringify(data),
5325
- "style": data.seamlessFlag === "1" ? "margin: 0" : "margin-top: 0",
5345
+ "style": isSeameless ? "margin: 0" : "margin-top: 0",
5326
5346
  "data-content": data.content || "",
5327
5347
  "contenteditable": "false"
5328
5348
  });
@@ -5337,16 +5357,11 @@
5337
5357
  "class": "halo-img-content",
5338
5358
  "contenteditable": "false"
5339
5359
  }, [...childList]);
5340
- if (me.imgType === "seamless") {
5341
- me.countList.push(p);
5342
- if (me.countList.length === me.imgList.length) {
5343
- var ct = this.createElement("div", {}, [...me.countList]);
5344
- this.insertElement(ct, range);
5345
- this.imgType = "normal";
5346
- }
5347
- return;
5348
- }
5349
5360
  this.insertElement(p, range);
5361
+ if (isSeameless) {
5362
+ me.removeDefault(p, "nextElementSibling");
5363
+ me.removeDefault(p, "previousElementSibling");
5364
+ }
5350
5365
  setTimeout(() => {
5351
5366
  document.documentElement.scrollTop = scrollTop;
5352
5367
  }, 50);
@@ -5420,6 +5435,23 @@
5420
5435
  };
5421
5436
  me.sticky();
5422
5437
  },
5438
+ removeDefault(next, key) {
5439
+ const me = this;
5440
+ const cur = next[key];
5441
+ if (!cur || cur.innerText !== "\n")
5442
+ return;
5443
+ const blockDefault = cur.classList.contains("halo-paragraph") || false;
5444
+ const isLasterBlock = next.classList.contains("halo-paragraph") || false;
5445
+ if (blockDefault && isLasterBlock) {
5446
+ cur.remove();
5447
+ me.removeDefault(cur, key);
5448
+ } else {
5449
+ if (blockDefault) {
5450
+ cur.style.display = "none";
5451
+ me.removeDefault(cur, key);
5452
+ }
5453
+ }
5454
+ },
5423
5455
  generateDelLinkIcon() {
5424
5456
  const me = this;
5425
5457
  const del = this.editor.createElement("img", {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@haluo/biz",
3
3
  "description": "rich text",
4
- "version": "0.1.20",
4
+ "version": "0.1.22",
5
5
  "type": "module",
6
6
  "module": "./dist/haluo-biz.js",
7
7
  "main": "./dist/haluo-biz.umd.cjs",