@haluo/biz 2.0.12 → 2.0.13-beta

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,11 @@ 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
+ this.currentVideo = null;
2292
+ }
2278
2293
  } else {
2279
2294
  this.seamlessCount++;
2280
2295
  const isLast = this.seamlessCount === this.imgList.length;
@@ -2293,6 +2308,21 @@ const _sfc_main = {
2293
2308
  this.setToast(rst.origin.name + "\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
2294
2309
  }
2295
2310
  },
2311
+ insertVideoBtns(editor, node) {
2312
+ const me = this;
2313
+ var replaceBtn = editor.createElement("div", {
2314
+ "class": "video-cover-replace pointer",
2315
+ "contenteditable": "false"
2316
+ });
2317
+ replaceBtn.onclick = function(e) {
2318
+ const posterBtn = document.querySelector(".replace-poster");
2319
+ posterBtn.click();
2320
+ me.currentVideo = node;
2321
+ e.stopPropagation();
2322
+ };
2323
+ replaceBtn.innerText = "\u66F4\u6362\u5C01\u9762";
2324
+ return replaceBtn;
2325
+ },
2296
2326
  insertImgOperateBtns(editor, data) {
2297
2327
  const me = this;
2298
2328
  var replaceBtn = editor.createElement("div", {
@@ -2405,7 +2435,7 @@ const _sfc_main = {
2405
2435
  },
2406
2436
  initSquire() {
2407
2437
  const me = this;
2408
- me.editorDom;
2438
+ const editorDom = me.editorDom;
2409
2439
  me.editor = new window.Squire(me.editorDom, {
2410
2440
  blockTag: "p",
2411
2441
  blockAttributes: {
@@ -2524,7 +2554,8 @@ const _sfc_main = {
2524
2554
  "data": JSON.stringify(data),
2525
2555
  "style": isSeameless ? "margin: 0" : "margin-top: 0",
2526
2556
  "data-content": data.content || "",
2527
- "contenteditable": "false"
2557
+ "contenteditable": "false",
2558
+ "draggable": "false"
2528
2559
  });
2529
2560
  const btns = me.insertImgOperateBtns(this, data);
2530
2561
  var childList = [];
@@ -2535,8 +2566,15 @@ const _sfc_main = {
2535
2566
  !isHaloImage && childList.push(again);
2536
2567
  var p = this.createElement("div", {
2537
2568
  "class": "halo-img-content",
2538
- "contenteditable": "false"
2569
+ "contenteditable": "false",
2570
+ "draggable": "false"
2539
2571
  }, [...childList]);
2572
+ p.onfocus = function() {
2573
+ img.style["outline"] = "1px solid #1a74ff";
2574
+ };
2575
+ p.onblur = function() {
2576
+ img.style["outline"] = "none";
2577
+ };
2540
2578
  this.insertElement(p, range);
2541
2579
  if (isSeameless) {
2542
2580
  me.removeDefault(p, "nextElementSibling");
@@ -2585,14 +2623,33 @@ const _sfc_main = {
2585
2623
  }
2586
2624
  });
2587
2625
  console.log(delBtn);
2626
+ const posterBtn = me.insertVideoBtns(this, video);
2588
2627
  var p = this.createElement("DIV", {
2589
2628
  "class": "halo-video-content",
2590
- "contenteditable": "true",
2591
- "data-video": JSON.stringify(data)
2592
- }, [video, delBtn]);
2629
+ "contenteditable": "false",
2630
+ "data-video": JSON.stringify(data),
2631
+ "draggable": "true"
2632
+ }, [video, delBtn, posterBtn]);
2593
2633
  p.onclick = function() {
2594
2634
  me.setToast("\u4E0D\u652F\u6301\u64AD\u653E");
2595
2635
  };
2636
+ let targetMove = null;
2637
+ p.ondragstart = function(e) {
2638
+ e.dataTransfer.setData("text/html", e.target);
2639
+ e.dataTransfer.effectAllowed = "move";
2640
+ e.dataTransfer.dropEffect = "move";
2641
+ targetMove = e.target;
2642
+ console.log(e, "drag");
2643
+ };
2644
+ editorDom.ondragover = function(e) {
2645
+ console.log(e, "over", me);
2646
+ e.preventDefault();
2647
+ };
2648
+ editorDom.ondrop = function(e) {
2649
+ console.log(e, "ondrop");
2650
+ e.target.after(targetMove);
2651
+ e.preventDefault();
2652
+ };
2596
2653
  this.insertElement(p);
2597
2654
  setTimeout(() => {
2598
2655
  document.documentElement.scrollTop = scrollTop;
@@ -3160,6 +3217,13 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
3160
3217
  class: "replace-input hide",
3161
3218
  accept: "image/*",
3162
3219
  onChange: _cache[12] || (_cache[12] = (...args) => $options.replaceImg && $options.replaceImg(...args))
3220
+ }, null, 32),
3221
+ createElementVNode("input", {
3222
+ type: "file",
3223
+ name: "file",
3224
+ class: "replace-poster hide",
3225
+ accept: "image/*",
3226
+ onChange: _cache[13] || (_cache[13] = (...args) => $options.replacePoster && $options.replacePoster(...args))
3163
3227
  }, null, 32)
3164
3228
  ]);
3165
3229
  }
@@ -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,11 @@
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
+ this.currentVideo = null;
2294
+ }
2280
2295
  } else {
2281
2296
  this.seamlessCount++;
2282
2297
  const isLast = this.seamlessCount === this.imgList.length;
@@ -2295,6 +2310,21 @@
2295
2310
  this.setToast(rst.origin.name + "\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5");
2296
2311
  }
2297
2312
  },
2313
+ insertVideoBtns(editor, node) {
2314
+ const me = this;
2315
+ var replaceBtn = editor.createElement("div", {
2316
+ "class": "video-cover-replace pointer",
2317
+ "contenteditable": "false"
2318
+ });
2319
+ replaceBtn.onclick = function(e) {
2320
+ const posterBtn = document.querySelector(".replace-poster");
2321
+ posterBtn.click();
2322
+ me.currentVideo = node;
2323
+ e.stopPropagation();
2324
+ };
2325
+ replaceBtn.innerText = "\u66F4\u6362\u5C01\u9762";
2326
+ return replaceBtn;
2327
+ },
2298
2328
  insertImgOperateBtns(editor, data) {
2299
2329
  const me = this;
2300
2330
  var replaceBtn = editor.createElement("div", {
@@ -2407,7 +2437,7 @@
2407
2437
  },
2408
2438
  initSquire() {
2409
2439
  const me = this;
2410
- me.editorDom;
2440
+ const editorDom = me.editorDom;
2411
2441
  me.editor = new window.Squire(me.editorDom, {
2412
2442
  blockTag: "p",
2413
2443
  blockAttributes: {
@@ -2526,7 +2556,8 @@
2526
2556
  "data": JSON.stringify(data),
2527
2557
  "style": isSeameless ? "margin: 0" : "margin-top: 0",
2528
2558
  "data-content": data.content || "",
2529
- "contenteditable": "false"
2559
+ "contenteditable": "false",
2560
+ "draggable": "false"
2530
2561
  });
2531
2562
  const btns = me.insertImgOperateBtns(this, data);
2532
2563
  var childList = [];
@@ -2537,8 +2568,15 @@
2537
2568
  !isHaloImage && childList.push(again);
2538
2569
  var p = this.createElement("div", {
2539
2570
  "class": "halo-img-content",
2540
- "contenteditable": "false"
2571
+ "contenteditable": "false",
2572
+ "draggable": "false"
2541
2573
  }, [...childList]);
2574
+ p.onfocus = function() {
2575
+ img.style["outline"] = "1px solid #1a74ff";
2576
+ };
2577
+ p.onblur = function() {
2578
+ img.style["outline"] = "none";
2579
+ };
2542
2580
  this.insertElement(p, range);
2543
2581
  if (isSeameless) {
2544
2582
  me.removeDefault(p, "nextElementSibling");
@@ -2587,14 +2625,33 @@
2587
2625
  }
2588
2626
  });
2589
2627
  console.log(delBtn);
2628
+ const posterBtn = me.insertVideoBtns(this, video);
2590
2629
  var p = this.createElement("DIV", {
2591
2630
  "class": "halo-video-content",
2592
- "contenteditable": "true",
2593
- "data-video": JSON.stringify(data)
2594
- }, [video, delBtn]);
2631
+ "contenteditable": "false",
2632
+ "data-video": JSON.stringify(data),
2633
+ "draggable": "true"
2634
+ }, [video, delBtn, posterBtn]);
2595
2635
  p.onclick = function() {
2596
2636
  me.setToast("\u4E0D\u652F\u6301\u64AD\u653E");
2597
2637
  };
2638
+ let targetMove = null;
2639
+ p.ondragstart = function(e) {
2640
+ e.dataTransfer.setData("text/html", e.target);
2641
+ e.dataTransfer.effectAllowed = "move";
2642
+ e.dataTransfer.dropEffect = "move";
2643
+ targetMove = e.target;
2644
+ console.log(e, "drag");
2645
+ };
2646
+ editorDom.ondragover = function(e) {
2647
+ console.log(e, "over", me);
2648
+ e.preventDefault();
2649
+ };
2650
+ editorDom.ondrop = function(e) {
2651
+ console.log(e, "ondrop");
2652
+ e.target.after(targetMove);
2653
+ e.preventDefault();
2654
+ };
2598
2655
  this.insertElement(p);
2599
2656
  setTimeout(() => {
2600
2657
  document.documentElement.scrollTop = scrollTop;
@@ -3162,6 +3219,13 @@
3162
3219
  class: "replace-input hide",
3163
3220
  accept: "image/*",
3164
3221
  onChange: _cache[12] || (_cache[12] = (...args) => $options.replaceImg && $options.replaceImg(...args))
3222
+ }, null, 32),
3223
+ vue.createElementVNode("input", {
3224
+ type: "file",
3225
+ name: "file",
3226
+ class: "replace-poster hide",
3227
+ accept: "image/*",
3228
+ onChange: _cache[13] || (_cache[13] = (...args) => $options.replacePoster && $options.replacePoster(...args))
3165
3229
  }, null, 32)
3166
3230
  ]);
3167
3231
  }
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",
5
5
  "type": "module",
6
6
  "module": "./dist/haluo-biz.js",
7
7
  "main": "./dist/haluo-biz.umd.cjs",