This commit is contained in:
Vanessa 2024-03-22 16:58:25 +08:00
parent 09b4304df2
commit ab69eb5732
9 changed files with 45 additions and 73 deletions

View file

@ -342,7 +342,7 @@ export const bazaar = {
html += this._genUpdateItemHTML(item, "widgets"); html += this._genUpdateItemHTML(item, "widgets");
}); });
const allCount = response.data.themes.length + response.data.icons.length + response.data.widgets.length + response.data.plugins.length + response.data.templates.length const allCount = response.data.themes.length + response.data.icons.length + response.data.widgets.length + response.data.plugins.length + response.data.templates.length;
if (allCount === 0) { if (allCount === 0) {
this.element.querySelector('[data-type="downloaded-update"]').innerHTML = ""; this.element.querySelector('[data-type="downloaded-update"]').innerHTML = "";
return; return;
@ -354,7 +354,7 @@ export const bazaar = {
<div class="counter counter--bg fn__flex-center">${allCount}</div> <div class="counter counter--bg fn__flex-center">${allCount}</div>
</div> </div>
<div class="config-bazaar__content">${html}</div>`; <div class="config-bazaar__content">${html}</div>`;
}) });
}, },
_genMyHTML(bazaarType: TBazaarType, app: App, updateUpdate = true) { _genMyHTML(bazaarType: TBazaarType, app: App, updateUpdate = true) {
const contentElement = bazaar.element.querySelector("#configBazaarDownloaded"); const contentElement = bazaar.element.querySelector("#configBazaarDownloaded");
@ -708,7 +708,7 @@ export const bazaar = {
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (type === "install-all") { } else if (type === "install-all") {
confirmDialog('⬆️ ' + window.siyuan.languages.updateAll, window.siyuan.languages.confirmUpdateAll, () => { confirmDialog("⬆️ " + window.siyuan.languages.updateAll, window.siyuan.languages.confirmUpdateAll, () => {
fetchPost("/api/bazaar/batchUpdatePackage", {frontend: getFrontend()}); fetchPost("/api/bazaar/batchUpdatePackage", {frontend: getFrontend()});
}); });
event.preventDefault(); event.preventDefault();
@ -716,7 +716,7 @@ export const bazaar = {
break; break;
} else if (type === "install-t") { } else if (type === "install-t") {
if (!target.classList.contains("b3-button--progress")) { if (!target.classList.contains("b3-button--progress")) {
confirmDialog('⬆️ ' + window.siyuan.languages.update, window.siyuan.languages.confirmUpdate, () => { confirmDialog("⬆️ " + window.siyuan.languages.update, window.siyuan.languages.confirmUpdate, () => {
const bazaarType = dataObj.bazaarType as TBazaarType; const bazaarType = dataObj.bazaarType as TBazaarType;
let url = "/api/bazaar/installBazaarTemplate"; let url = "/api/bazaar/installBazaarTemplate";
if (bazaarType === "themes") { if (bazaarType === "themes") {

View file

@ -98,7 +98,7 @@ export const workspaceMenu = (app: App, rect: DOMRect) => {
if (response.data.isWorkspace) { if (response.data.isWorkspace) {
openWorkspace(localPath.filePaths[0]); openWorkspace(localPath.filePaths[0]);
} else { } else {
confirmDialog('🏗️ ' + window.siyuan.languages.createWorkspace, window.siyuan.languages.createWorkspaceTip + `<br><br><code class="fn__code">${localPath.filePaths[0]}</code>`, () => { confirmDialog("🏗️ " + window.siyuan.languages.createWorkspace, window.siyuan.languages.createWorkspaceTip + `<br><br><code class="fn__code">${localPath.filePaths[0]}</code>`, () => {
openWorkspace(localPath.filePaths[0]); openWorkspace(localPath.filePaths[0]);
}); });
} }

View file

@ -25,6 +25,7 @@ import {
} from "../../search/assets"; } from "../../search/assets";
import {addClearButton} from "../../util/addClearButton"; import {addClearButton} from "../../util/addClearButton";
import {checkFold} from "../../util/noRelyPCFunction"; import {checkFold} from "../../util/noRelyPCFunction";
import {getDefaultType} from "../../search/util";
const replace = (element: Element, config: ISearchOption, isAll: boolean) => { const replace = (element: Element, config: ISearchOption, isAll: boolean) => {
if (config.method === 1 || config.method === 2) { if (config.method === 1 || config.method === 2) {
@ -484,21 +485,7 @@ const initSearchEvent = (app: App, element: Element, config: ISearchOption) => {
k: "", k: "",
r: "", r: "",
page: 1, page: 1,
types: { types: getDefaultType(),
document: window.siyuan.config.search.document,
heading: window.siyuan.config.search.heading,
list: window.siyuan.config.search.list,
listItem: window.siyuan.config.search.listItem,
codeBlock: window.siyuan.config.search.codeBlock,
htmlBlock: window.siyuan.config.search.htmlBlock,
mathBlock: window.siyuan.config.search.mathBlock,
table: window.siyuan.config.search.table,
blockquote: window.siyuan.config.search.blockquote,
superBlock: window.siyuan.config.search.superBlock,
paragraph: window.siyuan.config.search.paragraph,
embedBlock: window.siyuan.config.search.embedBlock,
databaseBlock: window.siyuan.config.search.databaseBlock,
},
replaceTypes: Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES), replaceTypes: Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES),
}, config); }, config);
}); });

View file

@ -317,13 +317,13 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
${window.siyuan.languages.insertRowBefore.replace("${x}", '<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" placeholder="Enter" class="b3-text-field"><span class="fn__space"></span>')} ${window.siyuan.languages.insertRowBefore.replace("${x}", '<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" placeholder="Enter" class="b3-text-field"><span class="fn__space"></span>')}
</div>`, </div>`,
bind(element) { bind(element) {
const inputElement = element.querySelector("input") const inputElement = element.querySelector("input");
inputElement.addEventListener("keydown", (event: KeyboardEvent) => { inputElement.addEventListener("keydown", (event: KeyboardEvent) => {
if (!event.isComposing && event.key === "Enter") { if (!event.isComposing && event.key === "Enter") {
insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].previousElementSibling.getAttribute("data-id")); insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].previousElementSibling.getAttribute("data-id"));
menu.close(); menu.close();
} }
}) });
} }
}); });
menu.addItem({ menu.addItem({
@ -333,13 +333,13 @@ ${window.siyuan.languages.insertRowBefore.replace("${x}", '<span class="fn__spac
${window.siyuan.languages.insertRowAfter.replace("${x}", '<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" placeholder="Enter" class="b3-text-field"><span class="fn__space"></span>')} ${window.siyuan.languages.insertRowAfter.replace("${x}", '<span class="fn__space"></span><input style="width:64px" type="number" step="1" min="1" placeholder="Enter" class="b3-text-field"><span class="fn__space"></span>')}
</div>`, </div>`,
bind(element) { bind(element) {
const inputElement = element.querySelector("input") const inputElement = element.querySelector("input");
inputElement.addEventListener("keydown", (event: KeyboardEvent) => { inputElement.addEventListener("keydown", (event: KeyboardEvent) => {
if (!event.isComposing && event.key === "Enter") { if (!event.isComposing && event.key === "Enter") {
insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].getAttribute("data-id")); insertRows(blockElement, protyle, parseInt(inputElement.value), rowElements[0].getAttribute("data-id"));
menu.close(); menu.close();
} }
}) });
} }
}); });
menu.addSeparator(); menu.addSeparator();

View file

@ -829,4 +829,4 @@ export const addDragFill = (cellElement: Element) => {
} }
cellElement.classList.add("av__cell--active"); cellElement.classList.add("av__cell--active");
cellElement.insertAdjacentHTML("beforeend", `<div aria-label="${window.siyuan.languages.dragFill}" class="av__drag-fill ariaLabel"></div>`); cellElement.insertAdjacentHTML("beforeend", `<div aria-label="${window.siyuan.languages.dragFill}" class="av__drag-fill ariaLabel"></div>`);
} };

View file

@ -50,7 +50,7 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, v
if (selectCellElement) { if (selectCellElement) {
selectCellId = (hasClosestByClassName(selectCellElement, "av__row") as HTMLElement).dataset.id + Constants.ZWSP + selectCellElement.getAttribute("data-col-id"); selectCellId = (hasClosestByClassName(selectCellElement, "av__row") as HTMLElement).dataset.id + Constants.ZWSP + selectCellElement.getAttribute("data-col-id");
} }
let dragFillId = "" let dragFillId = "";
const dragFillElement = e.querySelector(".av__drag-fill") as HTMLElement; const dragFillElement = e.querySelector(".av__drag-fill") as HTMLElement;
if (dragFillElement) { if (dragFillElement) {
dragFillId = (hasClosestByClassName(dragFillElement, "av__row") as HTMLElement).dataset.id + Constants.ZWSP + dragFillElement.parentElement.getAttribute("data-col-id"); dragFillId = (hasClosestByClassName(dragFillElement, "av__row") as HTMLElement).dataset.id + Constants.ZWSP + dragFillElement.parentElement.getAttribute("data-col-id");
@ -58,7 +58,7 @@ export const avRender = (element: Element, protyle: IProtyle, cb?: () => void, v
const activeIds: string[] = []; const activeIds: string[] = [];
e.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => { e.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => {
activeIds.push((hasClosestByClassName(item, "av__row") as HTMLElement).dataset.id + Constants.ZWSP + item.getAttribute("data-col-id")); activeIds.push((hasClosestByClassName(item, "av__row") as HTMLElement).dataset.id + Constants.ZWSP + item.getAttribute("data-col-id"));
}) });
const created = protyle.options.history?.created; const created = protyle.options.history?.created;
const snapshot = protyle.options.history?.snapshot; const snapshot = protyle.options.history?.snapshot;
let newViewID = e.getAttribute(Constants.CUSTOM_SY_AV_VIEW) || ""; let newViewID = e.getAttribute(Constants.CUSTOM_SY_AV_VIEW) || "";
@ -288,11 +288,11 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value)}</div>`;
} }
} }
if (dragFillId) { if (dragFillId) {
addDragFill(e.querySelector(`.av__row[data-id="${dragFillId.split(Constants.ZWSP)[0]}"] .av__cell[data-col-id="${dragFillId.split(Constants.ZWSP)[1]}"]`)) addDragFill(e.querySelector(`.av__row[data-id="${dragFillId.split(Constants.ZWSP)[0]}"] .av__cell[data-col-id="${dragFillId.split(Constants.ZWSP)[1]}"]`));
} }
activeIds.forEach(activeId => { activeIds.forEach(activeId => {
e.querySelector(`.av__row[data-id="${activeId.split(Constants.ZWSP)[0]}"] .av__cell[data-col-id="${activeId.split(Constants.ZWSP)[1]}"]`)?.classList.add("av__cell--active") e.querySelector(`.av__row[data-id="${activeId.split(Constants.ZWSP)[0]}"] .av__cell[data-col-id="${activeId.split(Constants.ZWSP)[1]}"]`)?.classList.add("av__cell--active");
}) });
if (getSelection().rangeCount > 0) { if (getSelection().rangeCount > 0) {
// 修改表头后光标重新定位 // 修改表头后光标重新定位
const range = getSelection().getRangeAt(0); const range = getSelection().getRangeAt(0);

View file

@ -380,4 +380,4 @@ export const insertRows = (blockElement: HTMLElement, protyle: IProtyle, count:
}]); }]);
insertAttrViewBlockAnimation(protyle, blockElement, srcIDs, previousID, avID); insertAttrViewBlockAnimation(protyle, blockElement, srcIDs, previousID, avID);
blockElement.setAttribute("updated", newUpdated); blockElement.setAttribute("updated", newUpdated);
} };

View file

@ -12,7 +12,7 @@ import {input} from "../wysiwyg/input";
import {objEquals} from "../../util/functions"; import {objEquals} from "../../util/functions";
const processAV = (range: Range, html: string, protyle: IProtyle, blockElement: HTMLElement) => { const processAV = (range: Range, html: string, protyle: IProtyle, blockElement: HTMLElement) => {
const tempElement = document.createElement("template") const tempElement = document.createElement("template");
tempElement.innerHTML = html; tempElement.innerHTML = html;
let values: IAVCellValue[] = []; let values: IAVCellValue[] = [];
if (html.endsWith("]") && html.startsWith("[")) { if (html.endsWith("]") && html.startsWith("[")) {
@ -27,9 +27,9 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
values.push({ values.push({
text: {content: cell.textContent}, text: {content: cell.textContent},
type: "text" type: "text"
}) });
}) });
}) });
} }
if (values && Array.isArray(values) && values.length > 0) { if (values && Array.isArray(values) && values.length > 0) {
const cellElements: Element[] = Array.from(blockElement.querySelectorAll(".av__cell--active, .av__cell--select")) || []; const cellElements: Element[] = Array.from(blockElement.querySelectorAll(".av__cell--active, .av__cell--select")) || [];

View file

@ -51,6 +51,27 @@ import {addClearButton} from "../util/addClearButton";
import {checkFold} from "../util/noRelyPCFunction"; import {checkFold} from "../util/noRelyPCFunction";
import {getUnRefList, openSearchUnRef, unRefMoreMenu} from "./unRef"; import {getUnRefList, openSearchUnRef, unRefMoreMenu} from "./unRef";
export const getDefaultType = () => {
return {
audioBlock: window.siyuan.config.search.audioBlock,
videoBlock: window.siyuan.config.search.videoBlock,
iFrameBlock: window.siyuan.config.search.iFrameBlock,
widgetBlock: window.siyuan.config.search.widgetBlock,
document: window.siyuan.config.search.document,
heading: window.siyuan.config.search.heading,
list: window.siyuan.config.search.list,
listItem: window.siyuan.config.search.listItem,
codeBlock: window.siyuan.config.search.codeBlock,
htmlBlock: window.siyuan.config.search.htmlBlock,
mathBlock: window.siyuan.config.search.mathBlock,
table: window.siyuan.config.search.table,
blockquote: window.siyuan.config.search.blockquote,
superBlock: window.siyuan.config.search.superBlock,
paragraph: window.siyuan.config.search.paragraph,
embedBlock: window.siyuan.config.search.embedBlock,
databaseBlock: window.siyuan.config.search.databaseBlock,
};
};
export const toggleReplaceHistory = (searchElement: Element) => { export const toggleReplaceHistory = (searchElement: Element) => {
const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS]; const list = window.siyuan.storage[Constants.LOCAL_SEARCHKEYS];
if (!list.replaceKeys || list.replaceKeys.length === 0) { if (!list.replaceKeys || list.replaceKeys.length === 0) {
@ -506,25 +527,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
k: "", k: "",
r: "", r: "",
page: 1, page: 1,
types: { types: getDefaultType(),
audioBlock: window.siyuan.config.search.audioBlock,
videoBlock: window.siyuan.config.search.videoBlock,
iFrameBlock: window.siyuan.config.search.iFrameBlock,
widgetBlock: window.siyuan.config.search.widgetBlock,
document: window.siyuan.config.search.document,
heading: window.siyuan.config.search.heading,
list: window.siyuan.config.search.list,
listItem: window.siyuan.config.search.listItem,
codeBlock: window.siyuan.config.search.codeBlock,
htmlBlock: window.siyuan.config.search.htmlBlock,
mathBlock: window.siyuan.config.search.mathBlock,
table: window.siyuan.config.search.table,
blockquote: window.siyuan.config.search.blockquote,
superBlock: window.siyuan.config.search.superBlock,
paragraph: window.siyuan.config.search.paragraph,
embedBlock: window.siyuan.config.search.embedBlock,
databaseBlock: window.siyuan.config.search.databaseBlock,
},
replaceTypes: Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES), replaceTypes: Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES),
}, config, edit); }, config, edit);
element.querySelector(".b3-chip--current")?.classList.remove("b3-chip--current"); element.querySelector(".b3-chip--current")?.classList.remove("b3-chip--current");
@ -766,25 +769,7 @@ export const genSearch = (app: App, config: ISearchOption, element: Element, clo
k: "", k: "",
r: "", r: "",
page: 1, page: 1,
types: { types: getDefaultType(),
audioBlock: window.siyuan.config.search.audioBlock,
videoBlock: window.siyuan.config.search.videoBlock,
iFrameBlock: window.siyuan.config.search.iFrameBlock,
widgetBlock: window.siyuan.config.search.widgetBlock,
document: window.siyuan.config.search.document,
heading: window.siyuan.config.search.heading,
list: window.siyuan.config.search.list,
listItem: window.siyuan.config.search.listItem,
codeBlock: window.siyuan.config.search.codeBlock,
htmlBlock: window.siyuan.config.search.htmlBlock,
mathBlock: window.siyuan.config.search.mathBlock,
table: window.siyuan.config.search.table,
blockquote: window.siyuan.config.search.blockquote,
superBlock: window.siyuan.config.search.superBlock,
paragraph: window.siyuan.config.search.paragraph,
embedBlock: window.siyuan.config.search.embedBlock,
databaseBlock: window.siyuan.config.search.databaseBlock,
},
replaceTypes: Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES), replaceTypes: Object.assign({}, Constants.SIYUAN_DEFAULT_REPLACETYPES),
}, config, edit); }, config, edit);
element.querySelector("#criteria .b3-chip--current")?.classList.remove("b3-chip--current"); element.querySelector("#criteria .b3-chip--current")?.classList.remove("b3-chip--current");