This commit is contained in:
Vanessa 2023-03-08 22:34:46 +08:00
parent fe6e88ea45
commit bbd1333f93
6 changed files with 16 additions and 12 deletions

View file

@ -6,10 +6,10 @@ import {Dialog} from "../dialog";
import {isMobile} from "../util/functions";
export const AIActions = (elements: Element[], protyle: IProtyle) => {
const ids: string[] = []
const ids: string[] = [];
elements.forEach(item => {
ids.push(item.getAttribute("data-node-id"))
})
ids.push(item.getAttribute("data-node-id"));
});
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconSparkles",
label: window.siyuan.languages.ai,
@ -136,4 +136,4 @@ export const AIActions = (elements: Element[], protyle: IProtyle) => {
}
}]
}).element);
}
};

View file

@ -36,4 +36,4 @@ export const AIChat = (protyle:IProtyle) => {
insertHTML(`${inputElement.value}${respContent}`, protyle, true);
});
});
}
};

View file

@ -4,7 +4,7 @@ import {Model} from "./Model";
import {Editor} from "../editor";
import {hasClosestByTag} from "../protyle/util/hasClosest";
import {Constants} from "../constants";
import {escapeHtml} from "../util/escape";
import {escapeGreat, escapeHtml} from "../util/escape";
import {unicode2Emoji} from "../emoji";
import {fetchPost} from "../util/fetch";
import {showTooltip} from "../dialog/tooltip";
@ -63,9 +63,9 @@ export class Tab {
id
}, (response) => {
if (!this.headElement.getAttribute("aria-label")) {
showTooltip(escapeHtml(response.data), this.headElement);
showTooltip(escapeGreat(response.data), this.headElement);
}
this.headElement.setAttribute("aria-label", escapeHtml(response.data));
this.headElement.setAttribute("aria-label", escapeGreat(response.data));
});
}
});
@ -79,7 +79,7 @@ export class Tab {
const tabElement = hasClosestByTag(event.target, "LI");
if (tabElement) {
event.dataTransfer.setData("text/html", tabElement.outerHTML);
const modeJSON = {id:this.id};
const modeJSON = {id: this.id};
layoutToJSON(this, modeJSON);
event.dataTransfer.setData(Constants.SIYUAN_DROP_TAB, JSON.stringify(modeJSON));
event.dataTransfer.dropEffect = "move";

View file

@ -969,9 +969,9 @@ const genImageWidthMenu = (label: string, assetElement: HTMLElement, imgElement:
assetElement.style.width = "";
assetElement.style.maxWidth = "";
} else {
assetElement.removeAttribute("style")
assetElement.removeAttribute("style");
}
imgElement.removeAttribute("style")
imgElement.removeAttribute("style");
} else {
assetElement.style.width = label;
assetElement.style.maxWidth = "";

View file

@ -111,7 +111,7 @@ export const goForward = () => {
export const goBack = () => {
if (window.JSAndroid) {
if (window.siyuan.menus.menu.element.classList.contains("b3-menu--fullscreen") && !window.siyuan.menus.menu.element.classList.contains("fn__none")) {
window.siyuan.menus.menu.element.dispatchEvent(new CustomEvent("click", {detail: "back"}))
window.siyuan.menus.menu.element.dispatchEvent(new CustomEvent("click", {detail: "back"}));
return;
} else if (window.siyuan.backStack.length < 1) {
window.JSAndroid.returnDesktop();

View file

@ -2,6 +2,10 @@ export const escapeHtml = (html: string) => {
return html.replace(/&/g, "&amp;").replace(/</g, "&lt;");
};
export const escapeGreat = (html: string) => {
return html.replace(/</g, "&lt;");
};
export const escapeAttr = (html: string) => {
return html.replace(/"/g, "&quot;").replace(/'/g, "&apos;");
};