diff --git a/app/src/search/assets.ts b/app/src/search/assets.ts index 147273da9..668b8e1b8 100644 --- a/app/src/search/assets.ts +++ b/app/src/search/assets.ts @@ -5,7 +5,7 @@ import * as path from "path"; import {Constants} from "../constants"; import {fetchPost} from "../util/fetch"; import {upDownHint} from "../util/upDownHint"; -import {escapeHtml} from "../util/escape"; +import {escapeAriaLabel, escapeHtml} from "../util/escape"; import {setStorageVal} from "../protyle/util/compatibility"; /// #if !MOBILE import {getQueryTip} from "./util"; @@ -278,7 +278,7 @@ export const assetInputEvent = (element: Element, localSearch?: ISearchAssetOpti ${item.content} ${item.hSize} -${item.name} +${item.name} `; }); const previewElement = element.querySelector("#searchAssetPreview"); diff --git a/app/src/search/util.ts b/app/src/search/util.ts index ca15db2e9..9e9d44400 100644 --- a/app/src/search/util.ts +++ b/app/src/search/util.ts @@ -4,7 +4,7 @@ import {shell} from "electron"; import * as path from "path"; /// #endif import {Constants} from "../constants"; -import {escapeAttr, escapeGreat, escapeHtml} from "../util/escape"; +import {escapeAriaLabel, escapeAttr, escapeGreat, escapeHtml} from "../util/escape"; import {fetchPost} from "../util/fetch"; import {openFile, openFileById} from "../editor/util"; import {showMessage} from "../dialog/message"; @@ -198,10 +198,10 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo - + - + ${escapeHtml(config.hPath)} @@ -418,7 +418,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo config.hPath = ""; config.page = 1; searchPathInputElement.innerHTML = config.hPath; - searchPathInputElement.setAttribute("title", ""); + searchPathInputElement.setAttribute("aria-label", ""); inputTimeout = inputEvent(element, config, inputTimeout, edit, true); const includeElement = element.querySelector("#searchInclude"); includeElement.classList.remove("b3-button--cancel"); @@ -467,7 +467,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo config.hPath = hPathList.join(" "); config.page = 1; searchPathInputElement.innerHTML = `${escapeHtml(config.hPath)}`; - searchPathInputElement.setAttribute("title", config.hPath); + searchPathInputElement.setAttribute("aria-label", escapeHtml(config.hPath)); const includeElement = element.querySelector("#searchInclude"); includeElement.classList.remove("b3-button--cancel"); if (enableIncludeChild) { @@ -1042,10 +1042,10 @@ const updateConfig = (element: Element, item: ISearchOption, config: ISearchOpti const searchPathInputElement = element.querySelector("#searchPathInput"); if (item.hPath) { searchPathInputElement.innerHTML = `${escapeHtml(item.hPath)}`; - searchPathInputElement.setAttribute("title", item.hPath); + searchPathInputElement.setAttribute("aria-label", escapeHtml(item.hPath)); } else { searchPathInputElement.innerHTML = ""; - searchPathInputElement.setAttribute("title", ""); + searchPathInputElement.setAttribute("aria-label", ""); } if (config.group !== item.group) { if (item.group === 0) { @@ -1298,7 +1298,7 @@ const onSearch = (data: IBlock[], edit: Protyle, element: Element, config: ISear ${unicode2Emoji(getNotebookIcon(item.box) || Constants.SIYUAN_IMAGE_NOTE, "b3-list-item__graphic", true)} -${escapeGreat(title)} +${escapeGreat(title)}
`; item.children.forEach((childItem, childIndex) => { resultHTML += `
@@ -1313,7 +1313,7 @@ ${unicode2Emoji(childItem.ial.icon, "b3-list-item__graphic", true)} ${unicode2Emoji(item.ial.icon, "b3-list-item__graphic", true)} ${item.content} -${escapeGreat(title)} +${escapeGreat(title)}
`; } }); diff --git a/app/src/util/escape.ts b/app/src/util/escape.ts index 214377cda..f9e71c556 100644 --- a/app/src/util/escape.ts +++ b/app/src/util/escape.ts @@ -9,3 +9,8 @@ export const escapeGreat = (html: string) => { export const escapeAttr = (html: string) => { return html.replace(/"/g, """).replace(/'/g, "'"); }; + +export const escapeAriaLabel = (html: string) => { + return html.replace(/"/g, """).replace(/'/g, "'") + .replace(/