This commit is contained in:
Vanessa 2023-10-22 23:59:17 +08:00
parent ab9590d950
commit bb3518b01e
2 changed files with 11 additions and 6 deletions

View file

@ -375,7 +375,7 @@ export const hintRef = (key: string, protyle: IProtyle, source: THintSource): IH
response.data.blocks.forEach((item: IBlock) => { response.data.blocks.forEach((item: IBlock) => {
let value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="d">${item.name || item.refText}</span>`; let value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="d">${item.name || item.refText}</span>`;
if (source === "search") { if (source === "search") {
value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${key}</span>`; value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${key}${Constants.ZWSP}${item.name || item.refText}</span>`;
} }
dataList.push({ dataList.push({
value, value,

View file

@ -61,10 +61,9 @@ export class Hint {
if (this.source !== "search") { if (this.source !== "search") {
this.fill(decodeURIComponent(btnElement.getAttribute("data-value")), protyle, true, isCtrl(event)); this.fill(decodeURIComponent(btnElement.getAttribute("data-value")), protyle, true, isCtrl(event));
} else { } else {
// 划选引用点击,需先重置 range
setTimeout(() => { setTimeout(() => {
this.fill(decodeURIComponent(btnElement.getAttribute("data-value")), protyle); this.fill(decodeURIComponent(btnElement.getAttribute("data-value")), protyle, true, !isCtrl(event));
}, 148); }, 148); // 划选引用点击,需先重置 range
} }
focusByRange(protyle.toolbar.range); focusByRange(protyle.toolbar.range);
@ -303,8 +302,8 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
upDownHint(this.element.lastElementChild, event); upDownHint(this.element.lastElementChild, event);
if (event.key === "Enter") { if (event.key === "Enter") {
setTimeout(() => { setTimeout(() => {
this.fill(decodeURIComponent(this.element.querySelector(".b3-list-item--focus").getAttribute("data-value")), protyle); this.fill(decodeURIComponent(this.element.querySelector(".b3-list-item--focus").getAttribute("data-value")), protyle, true, !isCtrl(event));
}, 148); }, 148); // 划选引用点击,需先重置 range
focusByRange(protyle.toolbar.range); focusByRange(protyle.toolbar.range);
event.preventDefault(); event.preventDefault();
} else if (event.key === "Escape") { } else if (event.key === "Escape") {
@ -542,6 +541,12 @@ ${genHintItemHTML(item)}
tempElement.setAttribute("data-subtype", "s"); tempElement.setAttribute("data-subtype", "s");
tempElement.innerText = staticText; tempElement.innerText = staticText;
} }
} else {
tempElement.setAttribute("data-subtype", "d");
const dynamicTexts = tempElement.innerText.split(Constants.ZWSP);
if (dynamicTexts.length === 2) {
tempElement.innerText = dynamicTexts[1];
}
} }
protyle.toolbar.setInlineMark(protyle, "block-ref", "range", { protyle.toolbar.setInlineMark(protyle, "block-ref", "range", {
type: "id", type: "id",