@haluo/biz 2.0.42-next.2 → 2.0.42-next.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 +56 -18
- package/dist/haluo-biz.umd.cjs +56 -18
- package/package.json +1 -1
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,24 +4586,12 @@ const _sfc_main$3 = {
|
|
|
4532
4586
|
};
|
|
4533
4587
|
this.showTopicPopover("hot", position, "", triggerInfo);
|
|
4534
4588
|
}, 10);
|
|
4535
|
-
} else if (this.shouldTriggerSearch(event.key)) {
|
|
4536
|
-
console.log(222);
|
|
4537
|
-
setTimeout(() => {
|
|
4538
|
-
this.checkAndTriggerSearch(paragraph);
|
|
4539
|
-
}, 10);
|
|
4540
|
-
} else {
|
|
4541
|
-
this.hideTopicPopover();
|
|
4542
4589
|
}
|
|
4543
4590
|
},
|
|
4544
|
-
shouldTriggerSearch(key) {
|
|
4545
|
-
console.log(key);
|
|
4546
|
-
return key.length === 1 || key === "Backspace" || key === "Delete";
|
|
4547
|
-
},
|
|
4548
4591
|
checkAndTriggerSearch(paragraph) {
|
|
4549
4592
|
const selection = window.getSelection();
|
|
4550
4593
|
if (selection.rangeCount === 0)
|
|
4551
4594
|
return;
|
|
4552
|
-
console.log(333);
|
|
4553
4595
|
const range = selection.getRangeAt(0);
|
|
4554
4596
|
let currentNode = range.startContainer;
|
|
4555
4597
|
while (currentNode && currentNode !== paragraph) {
|
|
@@ -4562,10 +4604,8 @@ const _sfc_main$3 = {
|
|
|
4562
4604
|
const { textContent: paragraphText, cursorPosition } = this.getParagraphTextExcludingTopics(paragraph, range);
|
|
4563
4605
|
const beforeCursor = paragraphText.substring(0, cursorPosition);
|
|
4564
4606
|
const hashIndex = beforeCursor.lastIndexOf("#");
|
|
4565
|
-
console.log("search content", beforeCursor, beforeCursor.substring(hashIndex + 1));
|
|
4566
4607
|
if (hashIndex !== -1) {
|
|
4567
4608
|
const afterHash = beforeCursor.substring(hashIndex + 1).replace(/\u00A0/g, " ");
|
|
4568
|
-
console.log(444);
|
|
4569
4609
|
if (afterHash.indexOf(" ") === -1) {
|
|
4570
4610
|
if (afterHash.length <= 15) {
|
|
4571
4611
|
const position = this.getCaretPosition();
|
|
@@ -4574,7 +4614,6 @@ const _sfc_main$3 = {
|
|
|
4574
4614
|
hashIndex,
|
|
4575
4615
|
cursorPosition
|
|
4576
4616
|
};
|
|
4577
|
-
console.log(555);
|
|
4578
4617
|
if (afterHash.length === 0) {
|
|
4579
4618
|
this.showTopicPopover("hot", position, "", triggerInfo);
|
|
4580
4619
|
} else {
|
|
@@ -4667,7 +4706,6 @@ const _sfc_main$3 = {
|
|
|
4667
4706
|
},
|
|
4668
4707
|
// 话题弹框相关方法
|
|
4669
4708
|
showTopicPopover(type, position, searchKeyword = "", triggerInfo = null) {
|
|
4670
|
-
console.log(666);
|
|
4671
4709
|
if (!this.request || !this.request.getTopic) {
|
|
4672
4710
|
console.warn("话题功能需要提供 request.getTopic 方法");
|
|
4673
4711
|
return;
|
package/dist/haluo-biz.umd.cjs
CHANGED
|
@@ -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,24 +4585,12 @@
|
|
|
4531
4585
|
};
|
|
4532
4586
|
this.showTopicPopover("hot", position, "", triggerInfo);
|
|
4533
4587
|
}, 10);
|
|
4534
|
-
} else if (this.shouldTriggerSearch(event.key)) {
|
|
4535
|
-
console.log(222);
|
|
4536
|
-
setTimeout(() => {
|
|
4537
|
-
this.checkAndTriggerSearch(paragraph);
|
|
4538
|
-
}, 10);
|
|
4539
|
-
} else {
|
|
4540
|
-
this.hideTopicPopover();
|
|
4541
4588
|
}
|
|
4542
4589
|
},
|
|
4543
|
-
shouldTriggerSearch(key) {
|
|
4544
|
-
console.log(key);
|
|
4545
|
-
return key.length === 1 || key === "Backspace" || key === "Delete";
|
|
4546
|
-
},
|
|
4547
4590
|
checkAndTriggerSearch(paragraph) {
|
|
4548
4591
|
const selection = window.getSelection();
|
|
4549
4592
|
if (selection.rangeCount === 0)
|
|
4550
4593
|
return;
|
|
4551
|
-
console.log(333);
|
|
4552
4594
|
const range = selection.getRangeAt(0);
|
|
4553
4595
|
let currentNode = range.startContainer;
|
|
4554
4596
|
while (currentNode && currentNode !== paragraph) {
|
|
@@ -4561,10 +4603,8 @@
|
|
|
4561
4603
|
const { textContent: paragraphText, cursorPosition } = this.getParagraphTextExcludingTopics(paragraph, range);
|
|
4562
4604
|
const beforeCursor = paragraphText.substring(0, cursorPosition);
|
|
4563
4605
|
const hashIndex = beforeCursor.lastIndexOf("#");
|
|
4564
|
-
console.log("search content", beforeCursor, beforeCursor.substring(hashIndex + 1));
|
|
4565
4606
|
if (hashIndex !== -1) {
|
|
4566
4607
|
const afterHash = beforeCursor.substring(hashIndex + 1).replace(/\u00A0/g, " ");
|
|
4567
|
-
console.log(444);
|
|
4568
4608
|
if (afterHash.indexOf(" ") === -1) {
|
|
4569
4609
|
if (afterHash.length <= 15) {
|
|
4570
4610
|
const position = this.getCaretPosition();
|
|
@@ -4573,7 +4613,6 @@
|
|
|
4573
4613
|
hashIndex,
|
|
4574
4614
|
cursorPosition
|
|
4575
4615
|
};
|
|
4576
|
-
console.log(555);
|
|
4577
4616
|
if (afterHash.length === 0) {
|
|
4578
4617
|
this.showTopicPopover("hot", position, "", triggerInfo);
|
|
4579
4618
|
} else {
|
|
@@ -4666,7 +4705,6 @@
|
|
|
4666
4705
|
},
|
|
4667
4706
|
// 话题弹框相关方法
|
|
4668
4707
|
showTopicPopover(type, position, searchKeyword = "", triggerInfo = null) {
|
|
4669
|
-
console.log(666);
|
|
4670
4708
|
if (!this.request || !this.request.getTopic) {
|
|
4671
4709
|
console.warn("话题功能需要提供 request.getTopic 方法");
|
|
4672
4710
|
return;
|