@haluo/biz 2.0.42-next.3 → 2.0.42

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/README.md CHANGED
@@ -34,4 +34,7 @@ npm unlink @haluo/biz # 删除项目符号链接
34
34
  3、查看依赖包(非必需)
35
35
  npm list # 查看所有依赖包
36
36
  npm list -g --depth=0 # 查看全局依赖包
37
+
38
+ 4、如果热更失效,可以
39
+ rm -rf node_modules && npm i && npm link @haluo/biz && npm run dev
37
40
  ```
package/dist/haluo-biz.js CHANGED
@@ -4460,7 +4460,9 @@ const _sfc_main$3 = {
4460
4460
  // 全局弹框DOM引用
4461
4461
  globalContainer: null,
4462
4462
  globalMask: null
4463
- }
4463
+ },
4464
+ // 中文输入法状态
4465
+ isComposing: false
4464
4466
  };
4465
4467
  },
4466
4468
  methods: {
@@ -4477,17 +4479,69 @@ const _sfc_main$3 = {
4477
4479
  if (!this.editorDom)
4478
4480
  return;
4479
4481
  this.editorDom.addEventListener("keydown", this.handleTopicInput.bind(this));
4482
+ this.editorDom.addEventListener("compositionstart", this.handleCompositionStart.bind(this));
4483
+ this.editorDom.addEventListener("compositionend", this.handleCompositionEnd.bind(this));
4484
+ this.editorDom.addEventListener("input", this.handleInput.bind(this));
4480
4485
  },
4481
4486
  // 解绑编辑器事件
4482
4487
  unbindEditorEvents() {
4483
4488
  if (!this.editorDom)
4484
4489
  return;
4485
4490
  this.editorDom.removeEventListener("keydown", this.handleTopicInput.bind(this));
4491
+ this.editorDom.removeEventListener("compositionstart", this.handleCompositionStart.bind(this));
4492
+ this.editorDom.removeEventListener("compositionend", this.handleCompositionEnd.bind(this));
4493
+ this.editorDom.removeEventListener("input", this.handleInput.bind(this));
4494
+ },
4495
+ // 中文输入法开始事件
4496
+ handleCompositionStart() {
4497
+ this.isComposing = true;
4498
+ },
4499
+ // 中文输入法结束事件(中文)
4500
+ handleCompositionEnd() {
4501
+ this.isComposing = false;
4502
+ setTimeout(() => {
4503
+ this.handleInputChange();
4504
+ }, 10);
4505
+ },
4506
+ // input事件处理(英文)
4507
+ handleInput() {
4508
+ if (!this.isComposing) {
4509
+ setTimeout(() => {
4510
+ this.handleInputChange();
4511
+ }, 10);
4512
+ }
4513
+ },
4514
+ // 处理输入变化
4515
+ handleInputChange() {
4516
+ var _a;
4517
+ const selection = window.getSelection();
4518
+ if (selection.rangeCount === 0)
4519
+ return;
4520
+ const range = selection.getRangeAt(0);
4521
+ const container = range.startContainer;
4522
+ if (!this.editorDom.contains(container))
4523
+ return;
4524
+ let currentNode = container;
4525
+ while (currentNode && currentNode !== this.editorDom) {
4526
+ if (currentNode.nodeType === Node.ELEMENT_NODE && currentNode.tagName === "MDD-TOPIC") {
4527
+ return;
4528
+ }
4529
+ currentNode = currentNode.parentNode;
4530
+ }
4531
+ let paragraph = container;
4532
+ while (paragraph && paragraph.nodeType !== Node.ELEMENT_NODE) {
4533
+ paragraph = paragraph.parentNode;
4534
+ }
4535
+ while (paragraph && !((_a = paragraph.classList) == null ? void 0 : _a.contains("halo-paragraph"))) {
4536
+ paragraph = paragraph.parentNode;
4537
+ }
4538
+ if (!paragraph)
4539
+ return;
4540
+ this.checkAndTriggerSearch(paragraph);
4486
4541
  },
4487
4542
  // 话题输入处理
4488
4543
  handleTopicInput(event) {
4489
4544
  var _a;
4490
- console.log(111, event.key, event);
4491
4545
  const activeElement = document.activeElement;
4492
4546
  if (activeElement && (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA")) {
4493
4547
  return;
@@ -4532,20 +4586,12 @@ const _sfc_main$3 = {
4532
4586
  };
4533
4587
  this.showTopicPopover("hot", position, "", triggerInfo);
4534
4588
  }, 10);
4535
- } else {
4536
- console.log(222);
4537
- this.checkAndTriggerSearch(paragraph);
4538
4589
  }
4539
4590
  },
4540
- shouldTriggerSearch(key) {
4541
- console.log(key);
4542
- return key.length === 1 || key === "Backspace" || key === "Delete";
4543
- },
4544
4591
  checkAndTriggerSearch(paragraph) {
4545
4592
  const selection = window.getSelection();
4546
4593
  if (selection.rangeCount === 0)
4547
4594
  return;
4548
- console.log(333);
4549
4595
  const range = selection.getRangeAt(0);
4550
4596
  let currentNode = range.startContainer;
4551
4597
  while (currentNode && currentNode !== paragraph) {
@@ -4558,10 +4604,8 @@ const _sfc_main$3 = {
4558
4604
  const { textContent: paragraphText, cursorPosition } = this.getParagraphTextExcludingTopics(paragraph, range);
4559
4605
  const beforeCursor = paragraphText.substring(0, cursorPosition);
4560
4606
  const hashIndex = beforeCursor.lastIndexOf("#");
4561
- console.log("search content", beforeCursor, beforeCursor.substring(hashIndex + 1));
4562
4607
  if (hashIndex !== -1) {
4563
4608
  const afterHash = beforeCursor.substring(hashIndex + 1).replace(/\u00A0/g, " ");
4564
- console.log(444);
4565
4609
  if (afterHash.indexOf(" ") === -1) {
4566
4610
  if (afterHash.length <= 15) {
4567
4611
  const position = this.getCaretPosition();
@@ -4570,7 +4614,6 @@ const _sfc_main$3 = {
4570
4614
  hashIndex,
4571
4615
  cursorPosition
4572
4616
  };
4573
- console.log(555);
4574
4617
  if (afterHash.length === 0) {
4575
4618
  this.showTopicPopover("hot", position, "", triggerInfo);
4576
4619
  } else {
@@ -4663,7 +4706,6 @@ const _sfc_main$3 = {
4663
4706
  },
4664
4707
  // 话题弹框相关方法
4665
4708
  showTopicPopover(type, position, searchKeyword = "", triggerInfo = null) {
4666
- console.log(666);
4667
4709
  if (!this.request || !this.request.getTopic) {
4668
4710
  console.warn("话题功能需要提供 request.getTopic 方法");
4669
4711
  return;
@@ -4459,7 +4459,9 @@
4459
4459
  // 全局弹框DOM引用
4460
4460
  globalContainer: null,
4461
4461
  globalMask: null
4462
- }
4462
+ },
4463
+ // 中文输入法状态
4464
+ isComposing: false
4463
4465
  };
4464
4466
  },
4465
4467
  methods: {
@@ -4476,17 +4478,69 @@
4476
4478
  if (!this.editorDom)
4477
4479
  return;
4478
4480
  this.editorDom.addEventListener("keydown", this.handleTopicInput.bind(this));
4481
+ this.editorDom.addEventListener("compositionstart", this.handleCompositionStart.bind(this));
4482
+ this.editorDom.addEventListener("compositionend", this.handleCompositionEnd.bind(this));
4483
+ this.editorDom.addEventListener("input", this.handleInput.bind(this));
4479
4484
  },
4480
4485
  // 解绑编辑器事件
4481
4486
  unbindEditorEvents() {
4482
4487
  if (!this.editorDom)
4483
4488
  return;
4484
4489
  this.editorDom.removeEventListener("keydown", this.handleTopicInput.bind(this));
4490
+ this.editorDom.removeEventListener("compositionstart", this.handleCompositionStart.bind(this));
4491
+ this.editorDom.removeEventListener("compositionend", this.handleCompositionEnd.bind(this));
4492
+ this.editorDom.removeEventListener("input", this.handleInput.bind(this));
4493
+ },
4494
+ // 中文输入法开始事件
4495
+ handleCompositionStart() {
4496
+ this.isComposing = true;
4497
+ },
4498
+ // 中文输入法结束事件(中文)
4499
+ handleCompositionEnd() {
4500
+ this.isComposing = false;
4501
+ setTimeout(() => {
4502
+ this.handleInputChange();
4503
+ }, 10);
4504
+ },
4505
+ // input事件处理(英文)
4506
+ handleInput() {
4507
+ if (!this.isComposing) {
4508
+ setTimeout(() => {
4509
+ this.handleInputChange();
4510
+ }, 10);
4511
+ }
4512
+ },
4513
+ // 处理输入变化
4514
+ handleInputChange() {
4515
+ var _a;
4516
+ const selection = window.getSelection();
4517
+ if (selection.rangeCount === 0)
4518
+ return;
4519
+ const range = selection.getRangeAt(0);
4520
+ const container = range.startContainer;
4521
+ if (!this.editorDom.contains(container))
4522
+ return;
4523
+ let currentNode = container;
4524
+ while (currentNode && currentNode !== this.editorDom) {
4525
+ if (currentNode.nodeType === Node.ELEMENT_NODE && currentNode.tagName === "MDD-TOPIC") {
4526
+ return;
4527
+ }
4528
+ currentNode = currentNode.parentNode;
4529
+ }
4530
+ let paragraph = container;
4531
+ while (paragraph && paragraph.nodeType !== Node.ELEMENT_NODE) {
4532
+ paragraph = paragraph.parentNode;
4533
+ }
4534
+ while (paragraph && !((_a = paragraph.classList) == null ? void 0 : _a.contains("halo-paragraph"))) {
4535
+ paragraph = paragraph.parentNode;
4536
+ }
4537
+ if (!paragraph)
4538
+ return;
4539
+ this.checkAndTriggerSearch(paragraph);
4485
4540
  },
4486
4541
  // 话题输入处理
4487
4542
  handleTopicInput(event) {
4488
4543
  var _a;
4489
- console.log(111, event.key, event);
4490
4544
  const activeElement = document.activeElement;
4491
4545
  if (activeElement && (activeElement.tagName === "INPUT" || activeElement.tagName === "TEXTAREA")) {
4492
4546
  return;
@@ -4531,20 +4585,12 @@
4531
4585
  };
4532
4586
  this.showTopicPopover("hot", position, "", triggerInfo);
4533
4587
  }, 10);
4534
- } else {
4535
- console.log(222);
4536
- this.checkAndTriggerSearch(paragraph);
4537
4588
  }
4538
4589
  },
4539
- shouldTriggerSearch(key) {
4540
- console.log(key);
4541
- return key.length === 1 || key === "Backspace" || key === "Delete";
4542
- },
4543
4590
  checkAndTriggerSearch(paragraph) {
4544
4591
  const selection = window.getSelection();
4545
4592
  if (selection.rangeCount === 0)
4546
4593
  return;
4547
- console.log(333);
4548
4594
  const range = selection.getRangeAt(0);
4549
4595
  let currentNode = range.startContainer;
4550
4596
  while (currentNode && currentNode !== paragraph) {
@@ -4557,10 +4603,8 @@
4557
4603
  const { textContent: paragraphText, cursorPosition } = this.getParagraphTextExcludingTopics(paragraph, range);
4558
4604
  const beforeCursor = paragraphText.substring(0, cursorPosition);
4559
4605
  const hashIndex = beforeCursor.lastIndexOf("#");
4560
- console.log("search content", beforeCursor, beforeCursor.substring(hashIndex + 1));
4561
4606
  if (hashIndex !== -1) {
4562
4607
  const afterHash = beforeCursor.substring(hashIndex + 1).replace(/\u00A0/g, " ");
4563
- console.log(444);
4564
4608
  if (afterHash.indexOf(" ") === -1) {
4565
4609
  if (afterHash.length <= 15) {
4566
4610
  const position = this.getCaretPosition();
@@ -4569,7 +4613,6 @@
4569
4613
  hashIndex,
4570
4614
  cursorPosition
4571
4615
  };
4572
- console.log(555);
4573
4616
  if (afterHash.length === 0) {
4574
4617
  this.showTopicPopover("hot", position, "", triggerInfo);
4575
4618
  } else {
@@ -4662,7 +4705,6 @@
4662
4705
  },
4663
4706
  // 话题弹框相关方法
4664
4707
  showTopicPopover(type, position, searchKeyword = "", triggerInfo = null) {
4665
- console.log(666);
4666
4708
  if (!this.request || !this.request.getTopic) {
4667
4709
  console.warn("话题功能需要提供 request.getTopic 方法");
4668
4710
  return;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@haluo/biz",
3
3
  "description": "rich text",
4
- "version": "2.0.42-next.3",
4
+ "version": "2.0.42",
5
5
  "type": "module",
6
6
  "module": "./dist/haluo-biz.js",
7
7
  "main": "./dist/haluo-biz.umd.cjs",
@@ -19,10 +19,9 @@
19
19
  "dev": "vite",
20
20
  "build": "vue-tsc --noEmit && vite build",
21
21
  "build:watch": "vue-tsc --noEmit && vite build --watch",
22
- "preview": "vite preview",
23
- "next": "npm version prerelease --preid=next",
24
22
  "pub": "npm publish",
25
- "pub:next": "npm publish --tag=next"
23
+ "pub:next": "npm publish --tag=next",
24
+ "v:next": "npm version prerelease --preid=next"
26
25
  },
27
26
  "dependencies": {
28
27
  "element-plus": "^2.2.28",