@haluo/biz 2.0.12 → 2.0.13-beta.1

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
@@ -1804,7 +1804,9 @@ const _sfc_main = {
1804
1804
  },
1805
1805
  countList: [],
1806
1806
  replaceSeamless: 0,
1807
- seamlessCount: 0
1807
+ seamlessCount: 0,
1808
+ overLine: "",
1809
+ currentVideo: null
1808
1810
  };
1809
1811
  },
1810
1812
  computed: {
@@ -1954,6 +1956,12 @@ const _sfc_main = {
1954
1956
  this.imgUploadHandler(type, src);
1955
1957
  });
1956
1958
  },
1959
+ replacePoster(e) {
1960
+ this.$emit("insertImgs", e.target.files, "replace-poster", (type, src) => {
1961
+ this.visibleImg = false;
1962
+ this.imgUploadHandler(type, src);
1963
+ });
1964
+ },
1957
1965
  againImg(e) {
1958
1966
  this.$emit("insertImgs", e.target.files, "uploadAgainImages", (type, src) => {
1959
1967
  this.visibleImg = false;
@@ -2143,7 +2151,9 @@ const _sfc_main = {
2143
2151
  node.onclick = function() {
2144
2152
  me.setToast("\u4E0D\u652F\u6301\u64AD\u653E");
2145
2153
  };
2154
+ const replaceBtn = me.insertVideoBtns(this, video);
2146
2155
  node.appendChild(delBtn);
2156
+ node.appendChild(replaceBtn);
2147
2157
  },
2148
2158
  async parseArticle(node) {
2149
2159
  const data = JSON.parse(node.dataset.article);
@@ -2275,6 +2285,20 @@ const _sfc_main = {
2275
2285
  seamlessFlag: me.replaceSeamless,
2276
2286
  type: "2"
2277
2287
  }, this.range);
2288
+ } else if (type === "replace-poster") {
2289
+ if (this.currentVideo) {
2290
+ this.currentVideo.poster = imgSrc;
2291
+ try {
2292
+ const videoData = JSON.parse(this.currentVideo.getAttribute("data") || "{}");
2293
+ this.currentVideo.setAttribute("data", JSON.stringify({ ...videoData, img: imgSrc }));
2294
+ const contentNode = this.currentVideo.parentNode;
2295
+ const contentData = JSON.parse(contentNode.dataset.video || "{}");
2296
+ contentNode.dataset.video = JSON.stringify({ ...contentData, img: imgSrc });
2297
+ } catch (error) {
2298
+ console.log(error);
2299
+ }
2300
+ this.currentVideo = null;
2301
+ }
2278
2302
  } else {
2279
2303
  this.seamlessCount++;
2280
2304
  const isLast = this.seamlessCount === this.imgList.length;
@@ -2293,6 +2317,21 @@ const _sfc_main = {
2293
2317
  this.setToast(rst.origin.name + "\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
2294
2318
  }
2295
2319
  },
2320
+ insertVideoBtns(editor, node) {
2321
+ const me = this;
2322
+ var replaceBtn = editor.createElement("div", {
2323
+ "class": "video-cover-replace pointer",
2324
+ "contenteditable": "false"
2325
+ });
2326
+ replaceBtn.onclick = function(e) {
2327
+ const posterBtn = document.querySelector(".replace-poster");
2328
+ posterBtn.click();
2329
+ me.currentVideo = node;
2330
+ e.stopPropagation();
2331
+ };
2332
+ replaceBtn.innerText = "\u66F4\u6362\u5C01\u9762";
2333
+ return replaceBtn;
2334
+ },
2296
2335
  insertImgOperateBtns(editor, data) {
2297
2336
  const me = this;
2298
2337
  var replaceBtn = editor.createElement("div", {
@@ -2405,7 +2444,7 @@ const _sfc_main = {
2405
2444
  },
2406
2445
  initSquire() {
2407
2446
  const me = this;
2408
- me.editorDom;
2447
+ const editorDom = me.editorDom;
2409
2448
  me.editor = new window.Squire(me.editorDom, {
2410
2449
  blockTag: "p",
2411
2450
  blockAttributes: {
@@ -2524,7 +2563,8 @@ const _sfc_main = {
2524
2563
  "data": JSON.stringify(data),
2525
2564
  "style": isSeameless ? "margin: 0" : "margin-top: 0",
2526
2565
  "data-content": data.content || "",
2527
- "contenteditable": "false"
2566
+ "contenteditable": "false",
2567
+ "draggable": "false"
2528
2568
  });
2529
2569
  const btns = me.insertImgOperateBtns(this, data);
2530
2570
  var childList = [];
@@ -2535,8 +2575,15 @@ const _sfc_main = {
2535
2575
  !isHaloImage && childList.push(again);
2536
2576
  var p = this.createElement("div", {
2537
2577
  "class": "halo-img-content",
2538
- "contenteditable": "false"
2578
+ "contenteditable": "false",
2579
+ "draggable": "false"
2539
2580
  }, [...childList]);
2581
+ p.onfocus = function() {
2582
+ img.style["outline"] = "1px solid #1a74ff";
2583
+ };
2584
+ p.onblur = function() {
2585
+ img.style["outline"] = "none";
2586
+ };
2540
2587
  this.insertElement(p, range);
2541
2588
  if (isSeameless) {
2542
2589
  me.removeDefault(p, "nextElementSibling");
@@ -2585,14 +2632,41 @@ const _sfc_main = {
2585
2632
  }
2586
2633
  });
2587
2634
  console.log(delBtn);
2635
+ const posterBtn = me.insertVideoBtns(this, video);
2588
2636
  var p = this.createElement("DIV", {
2589
2637
  "class": "halo-video-content",
2590
- "contenteditable": "true",
2591
- "data-video": JSON.stringify(data)
2592
- }, [video, delBtn]);
2638
+ "contenteditable": "false",
2639
+ "data-video": JSON.stringify(data),
2640
+ "draggable": "true"
2641
+ }, [video, delBtn, posterBtn]);
2593
2642
  p.onclick = function() {
2594
2643
  me.setToast("\u4E0D\u652F\u6301\u64AD\u653E");
2595
2644
  };
2645
+ let targetMove = "";
2646
+ p.ondragstart = function(e) {
2647
+ if (!(e.target.className.indexOf("halo-video-content") < 0)) {
2648
+ e.dataTransfer.setData("text/html", e.target);
2649
+ e.dataTransfer.effectAllowed = "move";
2650
+ e.dataTransfer.dropEffect = "move";
2651
+ targetMove = e.target;
2652
+ }
2653
+ };
2654
+ editorDom.ondragover = function(e) {
2655
+ if (targetMove && !(targetMove.className.indexOf("halo-video-content") < 0)) {
2656
+ e.preventDefault();
2657
+ }
2658
+ };
2659
+ editorDom.ondrop = function(e) {
2660
+ if (targetMove && !(targetMove.className.indexOf("halo-video-content") < 0)) {
2661
+ if (e.target === editorDom) {
2662
+ e.target.appendChild(targetMove);
2663
+ } else {
2664
+ e.target.after(targetMove);
2665
+ }
2666
+ targetMove = "";
2667
+ e.preventDefault();
2668
+ }
2669
+ };
2596
2670
  this.insertElement(p);
2597
2671
  setTimeout(() => {
2598
2672
  document.documentElement.scrollTop = scrollTop;
@@ -3160,6 +3234,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
3160
3234
  class: "replace-input hide",
3161
3235
  accept: "image/*",
3162
3236
  onChange: _cache[12] || (_cache[12] = (...args) => $options.replaceImg && $options.replaceImg(...args))
3237
+ }, null, 32),
3238
+ createElementVNode("input", {
3239
+ type: "file",
3240
+ name: "file",
3241
+ class: "replace-poster hide",
3242
+ accept: "image/*",
3243
+ onChange: _cache[13] || (_cache[13] = (...args) => $options.replacePoster && $options.replacePoster(...args))
3163
3244
  }, null, 32)
3164
3245
  ]);
3165
3246
  }
@@ -1806,7 +1806,9 @@
1806
1806
  },
1807
1807
  countList: [],
1808
1808
  replaceSeamless: 0,
1809
- seamlessCount: 0
1809
+ seamlessCount: 0,
1810
+ overLine: "",
1811
+ currentVideo: null
1810
1812
  };
1811
1813
  },
1812
1814
  computed: {
@@ -1956,6 +1958,12 @@
1956
1958
  this.imgUploadHandler(type, src);
1957
1959
  });
1958
1960
  },
1961
+ replacePoster(e) {
1962
+ this.$emit("insertImgs", e.target.files, "replace-poster", (type, src) => {
1963
+ this.visibleImg = false;
1964
+ this.imgUploadHandler(type, src);
1965
+ });
1966
+ },
1959
1967
  againImg(e) {
1960
1968
  this.$emit("insertImgs", e.target.files, "uploadAgainImages", (type, src) => {
1961
1969
  this.visibleImg = false;
@@ -2145,7 +2153,9 @@
2145
2153
  node.onclick = function() {
2146
2154
  me.setToast("\u4E0D\u652F\u6301\u64AD\u653E");
2147
2155
  };
2156
+ const replaceBtn = me.insertVideoBtns(this, video);
2148
2157
  node.appendChild(delBtn);
2158
+ node.appendChild(replaceBtn);
2149
2159
  },
2150
2160
  async parseArticle(node) {
2151
2161
  const data = JSON.parse(node.dataset.article);
@@ -2277,6 +2287,20 @@
2277
2287
  seamlessFlag: me.replaceSeamless,
2278
2288
  type: "2"
2279
2289
  }, this.range);
2290
+ } else if (type === "replace-poster") {
2291
+ if (this.currentVideo) {
2292
+ this.currentVideo.poster = imgSrc;
2293
+ try {
2294
+ const videoData = JSON.parse(this.currentVideo.getAttribute("data") || "{}");
2295
+ this.currentVideo.setAttribute("data", JSON.stringify({ ...videoData, img: imgSrc }));
2296
+ const contentNode = this.currentVideo.parentNode;
2297
+ const contentData = JSON.parse(contentNode.dataset.video || "{}");
2298
+ contentNode.dataset.video = JSON.stringify({ ...contentData, img: imgSrc });
2299
+ } catch (error) {
2300
+ console.log(error);
2301
+ }
2302
+ this.currentVideo = null;
2303
+ }
2280
2304
  } else {
2281
2305
  this.seamlessCount++;
2282
2306
  const isLast = this.seamlessCount === this.imgList.length;
@@ -2295,6 +2319,21 @@
2295
2319
  this.setToast(rst.origin.name + "\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
2296
2320
  }
2297
2321
  },
2322
+ insertVideoBtns(editor, node) {
2323
+ const me = this;
2324
+ var replaceBtn = editor.createElement("div", {
2325
+ "class": "video-cover-replace pointer",
2326
+ "contenteditable": "false"
2327
+ });
2328
+ replaceBtn.onclick = function(e) {
2329
+ const posterBtn = document.querySelector(".replace-poster");
2330
+ posterBtn.click();
2331
+ me.currentVideo = node;
2332
+ e.stopPropagation();
2333
+ };
2334
+ replaceBtn.innerText = "\u66F4\u6362\u5C01\u9762";
2335
+ return replaceBtn;
2336
+ },
2298
2337
  insertImgOperateBtns(editor, data) {
2299
2338
  const me = this;
2300
2339
  var replaceBtn = editor.createElement("div", {
@@ -2407,7 +2446,7 @@
2407
2446
  },
2408
2447
  initSquire() {
2409
2448
  const me = this;
2410
- me.editorDom;
2449
+ const editorDom = me.editorDom;
2411
2450
  me.editor = new window.Squire(me.editorDom, {
2412
2451
  blockTag: "p",
2413
2452
  blockAttributes: {
@@ -2526,7 +2565,8 @@
2526
2565
  "data": JSON.stringify(data),
2527
2566
  "style": isSeameless ? "margin: 0" : "margin-top: 0",
2528
2567
  "data-content": data.content || "",
2529
- "contenteditable": "false"
2568
+ "contenteditable": "false",
2569
+ "draggable": "false"
2530
2570
  });
2531
2571
  const btns = me.insertImgOperateBtns(this, data);
2532
2572
  var childList = [];
@@ -2537,8 +2577,15 @@
2537
2577
  !isHaloImage && childList.push(again);
2538
2578
  var p = this.createElement("div", {
2539
2579
  "class": "halo-img-content",
2540
- "contenteditable": "false"
2580
+ "contenteditable": "false",
2581
+ "draggable": "false"
2541
2582
  }, [...childList]);
2583
+ p.onfocus = function() {
2584
+ img.style["outline"] = "1px solid #1a74ff";
2585
+ };
2586
+ p.onblur = function() {
2587
+ img.style["outline"] = "none";
2588
+ };
2542
2589
  this.insertElement(p, range);
2543
2590
  if (isSeameless) {
2544
2591
  me.removeDefault(p, "nextElementSibling");
@@ -2587,14 +2634,41 @@
2587
2634
  }
2588
2635
  });
2589
2636
  console.log(delBtn);
2637
+ const posterBtn = me.insertVideoBtns(this, video);
2590
2638
  var p = this.createElement("DIV", {
2591
2639
  "class": "halo-video-content",
2592
- "contenteditable": "true",
2593
- "data-video": JSON.stringify(data)
2594
- }, [video, delBtn]);
2640
+ "contenteditable": "false",
2641
+ "data-video": JSON.stringify(data),
2642
+ "draggable": "true"
2643
+ }, [video, delBtn, posterBtn]);
2595
2644
  p.onclick = function() {
2596
2645
  me.setToast("\u4E0D\u652F\u6301\u64AD\u653E");
2597
2646
  };
2647
+ let targetMove = "";
2648
+ p.ondragstart = function(e) {
2649
+ if (!(e.target.className.indexOf("halo-video-content") < 0)) {
2650
+ e.dataTransfer.setData("text/html", e.target);
2651
+ e.dataTransfer.effectAllowed = "move";
2652
+ e.dataTransfer.dropEffect = "move";
2653
+ targetMove = e.target;
2654
+ }
2655
+ };
2656
+ editorDom.ondragover = function(e) {
2657
+ if (targetMove && !(targetMove.className.indexOf("halo-video-content") < 0)) {
2658
+ e.preventDefault();
2659
+ }
2660
+ };
2661
+ editorDom.ondrop = function(e) {
2662
+ if (targetMove && !(targetMove.className.indexOf("halo-video-content") < 0)) {
2663
+ if (e.target === editorDom) {
2664
+ e.target.appendChild(targetMove);
2665
+ } else {
2666
+ e.target.after(targetMove);
2667
+ }
2668
+ targetMove = "";
2669
+ e.preventDefault();
2670
+ }
2671
+ };
2598
2672
  this.insertElement(p);
2599
2673
  setTimeout(() => {
2600
2674
  document.documentElement.scrollTop = scrollTop;
@@ -3162,6 +3236,13 @@
3162
3236
  class: "replace-input hide",
3163
3237
  accept: "image/*",
3164
3238
  onChange: _cache[12] || (_cache[12] = (...args) => $options.replaceImg && $options.replaceImg(...args))
3239
+ }, null, 32),
3240
+ vue.createElementVNode("input", {
3241
+ type: "file",
3242
+ name: "file",
3243
+ class: "replace-poster hide",
3244
+ accept: "image/*",
3245
+ onChange: _cache[13] || (_cache[13] = (...args) => $options.replacePoster && $options.replacePoster(...args))
3165
3246
  }, null, 32)
3166
3247
  ]);
3167
3248
  }
package/dist/style.css CHANGED
@@ -722,6 +722,9 @@
722
722
  min-height: 150px;
723
723
  margin: 5px 0;
724
724
  }
725
+ .editor #editor-content .halo-img-content .halo-picture-area::focus {
726
+ outline: 1px solid #1a74ff;
727
+ }
725
728
  .editor #editor-content .halo-img-content .no-upload,
726
729
  .editor #editor-content .halo-img-content .upload-fail {
727
730
  -webkit-filter: brightness(0.5);
@@ -742,6 +745,19 @@
742
745
  -ms-transform: translate(-50%, -50%);
743
746
  transform: translate(-50%, -50%);
744
747
  }
748
+ .editor #editor-content .video-cover-replace {
749
+ cursor: pointer;
750
+ position: absolute;
751
+ top: 10px;
752
+ left: 204px;
753
+ text-align: center;
754
+ font-size: 14px;
755
+ width: 88px;
756
+ line-height: 32px;
757
+ border-radius: 4px;
758
+ background-color: rgba(0, 0, 0, 0.5);
759
+ color: #fff;
760
+ }
745
761
  .editor #editor-content .halo-video-area {
746
762
  max-height: 200px;
747
763
  width: 500px;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@haluo/biz",
3
3
  "description": "rich text",
4
- "version": "2.0.12",
4
+ "version": "2.0.13-beta.1",
5
5
  "type": "module",
6
6
  "module": "./dist/haluo-biz.js",
7
7
  "main": "./dist/haluo-biz.umd.cjs",