|
@@ -317,6 +317,35 @@ export const hintTag = (key: string, protyle: IProtyle): IHintData[] => {
|
|
|
return [];
|
|
|
};
|
|
|
|
|
|
+export const genHintItemHTML = (item: IBlock) => {
|
|
|
+ let iconHTML;
|
|
|
+ if (item.type === "NodeDocument" && item.ial.icon) {
|
|
|
+ iconHTML = unicode2Emoji(item.ial.icon, "b3-list-item__graphic popover__block", true);
|
|
|
+ iconHTML = iconHTML.replace('popover__block"', `popover__block" data-id="${item.id}"`);
|
|
|
+ } else {
|
|
|
+ iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.type)}"></use></svg>`;
|
|
|
+ }
|
|
|
+ let attrHTML = "";
|
|
|
+ if (item.name) {
|
|
|
+ attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconN"></use></svg><span>${item.name}</span></span><span class="fn__space"></span>`;
|
|
|
+ }
|
|
|
+ if (item.alias) {
|
|
|
+ attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconA"></use></svg><span>${item.alias}</span></span><span class="fn__space"></span>`;
|
|
|
+ }
|
|
|
+ if (item.memo) {
|
|
|
+ attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconM"></use></svg><span>${item.memo}</span></span>`;
|
|
|
+ }
|
|
|
+ if (attrHTML) {
|
|
|
+ attrHTML = `<div class="fn__flex b3-list-item__meta b3-list-item__showall">${attrHTML}</div>`;
|
|
|
+ }
|
|
|
+
|
|
|
+ return `${attrHTML}<div class="b3-list-item__first">
|
|
|
+ ${iconHTML}
|
|
|
+ <span class="b3-list-item__text">${item.content}</span>
|
|
|
+</div>
|
|
|
+<div class="b3-list-item__meta b3-list-item__showall" style="margin-bottom: 4px">${item.hPath}</div>`;
|
|
|
+}
|
|
|
+
|
|
|
export const hintRef = (key: string, protyle: IProtyle, isQuick = false): IHintData[] => {
|
|
|
const nodeElement = hasClosestBlock(getEditorRange(protyle.wysiwyg.element).startContainer);
|
|
|
protyle.hint.genLoading(protyle);
|
|
@@ -337,37 +366,13 @@ export const hintRef = (key: string, protyle: IProtyle, isQuick = false): IHintD
|
|
|
});
|
|
|
}
|
|
|
response.data.blocks.forEach((item: IBlock) => {
|
|
|
- let iconHTML;
|
|
|
- if (item.type === "NodeDocument" && item.ial.icon) {
|
|
|
- iconHTML = unicode2Emoji(item.ial.icon, "b3-list-item__graphic popover__block", true);
|
|
|
- iconHTML = iconHTML.replace('popover__block"', `popover__block" data-id="${item.id}"`);
|
|
|
- } else {
|
|
|
- iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.type)}"></use></svg>`;
|
|
|
- }
|
|
|
- let attrHTML = "";
|
|
|
- if (item.name) {
|
|
|
- attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconN"></use></svg><span>${item.name}</span></span><span class="fn__space"></span>`;
|
|
|
- }
|
|
|
- if (item.alias) {
|
|
|
- attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconA"></use></svg><span>${item.alias}</span></span><span class="fn__space"></span>`;
|
|
|
- }
|
|
|
- if (item.memo) {
|
|
|
- attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconM"></use></svg><span>${item.memo}</span></span>`;
|
|
|
- }
|
|
|
- if (attrHTML) {
|
|
|
- attrHTML = `<div class="fn__flex b3-list-item__meta b3-list-item__showall">${attrHTML}</div>`;
|
|
|
- }
|
|
|
let value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="d">${item.name || item.refText}</span>`;
|
|
|
if (isQuick) {
|
|
|
value = `<span data-type="block-ref" data-id="${item.id}" data-subtype="s">${key}</span>`;
|
|
|
}
|
|
|
dataList.push({
|
|
|
value,
|
|
|
- html: `${attrHTML}<div class="b3-list-item__first">
|
|
|
- ${iconHTML}
|
|
|
- <span class="b3-list-item__text">${item.content}</span>
|
|
|
-</div>
|
|
|
-<div class="b3-list-item__meta b3-list-item__showall" style="margin-bottom: 4px">${item.hPath}</div>`,
|
|
|
+ html: genHintItemHTML(item),
|
|
|
});
|
|
|
});
|
|
|
if (isQuick) {
|
|
@@ -401,33 +406,9 @@ export const hintEmbed = (key: string, protyle: IProtyle): IHintData[] => {
|
|
|
}, (response) => {
|
|
|
const dataList: IHintData[] = [];
|
|
|
response.data.blocks.forEach((item: IBlock) => {
|
|
|
- let iconHTML;
|
|
|
- if (item.type === "NodeDocument" && item.ial.icon) {
|
|
|
- iconHTML = unicode2Emoji(item.ial.icon, "b3-list-item__graphic popover__block", true);
|
|
|
- iconHTML = iconHTML.replace('popover__block"', `popover__block" data-id="${item.id}"`);
|
|
|
- } else {
|
|
|
- iconHTML = `<svg class="b3-list-item__graphic popover__block" data-id="${item.id}"><use xlink:href="#${getIconByType(item.type)}"></use></svg>`;
|
|
|
- }
|
|
|
- let attrHTML = "";
|
|
|
- if (item.name) {
|
|
|
- attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconN"></use></svg>${item.name}</span><span class="fn__space"></span>`;
|
|
|
- }
|
|
|
- if (item.alias) {
|
|
|
- attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconA"></use></svg>${item.alias}</span><span class="fn__space"></span>`;
|
|
|
- }
|
|
|
- if (item.memo) {
|
|
|
- attrHTML += `<span class="fn__flex"><svg class="b3-list-item__hinticon"><use xlink:href="#iconM"></use></svg>${item.memo}</span>`;
|
|
|
- }
|
|
|
- if (attrHTML) {
|
|
|
- attrHTML = `<div class="fn__flex b3-list-item__meta b3-list-item__showall">${attrHTML}</div>`;
|
|
|
- }
|
|
|
dataList.push({
|
|
|
value: `{{select * from blocks where id='${item.id}'}}`,
|
|
|
- html: `${attrHTML}<div class="b3-list-item__first">
|
|
|
- ${iconHTML}
|
|
|
- <span class="b3-list-item__text">${item.content}</span>
|
|
|
-</div>
|
|
|
-<div class="b3-list-item__meta b3-list-item__showall" style="margin-bottom: 4px">${item.hPath}</div>`,
|
|
|
+ html: genHintItemHTML(item),
|
|
|
});
|
|
|
});
|
|
|
if (dataList.length === 0) {
|