Skip to content

Commit

Permalink
Merge remote-tracking branch 'fork-siyuan/dev' into v0.29
Browse files Browse the repository at this point in the history
  • Loading branch information
Soltus committed Apr 11, 2024
2 parents ba0728d + 1fc1695 commit f22967d
Show file tree
Hide file tree
Showing 22 changed files with 160 additions and 77 deletions.
3 changes: 2 additions & 1 deletion app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@
"238": "Marketplace package [%s] update failed, please try again later",
"239": "Related operations are being processed, please try again later",
"240": "Drag heading under container blocks in the doc is not supported",
"241": "Drag to its subheading is not supported"
"241": "Drag to its subheading is not supported",
"242": "The binding block already exists in the current database"
}
}
3 changes: 2 additions & 1 deletion app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@
"238": "Error en la actualización del paquete Marketplace [%s], inténtalo de nuevo más tarde",
"239": "Las operaciones relacionadas se están procesando, inténtalo de nuevo más tarde",
"240": "No se admite arrastrar encabezado debajo de los bloques contenedores en el documento",
"241": "No se admite arrastrar a su subtítulo"
"241": "No se admite arrastrar a su subtítulo",
"242": "El bloque de enlace ya existe en la base de datos actual"
}
}
3 changes: 2 additions & 1 deletion app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@
"238": "La mise à jour du package Marketplace [%s] a échoué, veuillez réessayer plus tard",
"239": "Les opérations associées sont en cours de traitement, veuillez réessayer plus tard",
"240": "Le déplacement du titre sous les blocs conteneurs dans la doc n'est pas pris en charge",
"241": "Le glisser vers son sous-titre n'est pas pris en charge"
"241": "Le glisser vers son sous-titre n'est pas pris en charge",
"242": "Le bloc de liaison existe déjà dans la base de données actuelle"
}
}
3 changes: 2 additions & 1 deletion app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@
"238": "市集包 [%s] 更新失敗,請稍後再試",
"239": "相關操作正在處理中,請稍後再試",
"240": "不支援拖曳文件中容器區塊下的標題",
"241": "不支持拖曳為自己的子標題"
"241": "不支持拖曳為自己的子標題",
"242": "目前資料庫中已經存在該綁定區塊"
}
}
3 changes: 2 additions & 1 deletion app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1473,6 +1473,7 @@
"238": "集市包 [%s] 更新失败,请稍后再试",
"239": "相关操作正在处理中,请稍后再试",
"240": "不支持拖拽文档中容器块下的标题",
"241": "不支持拖拽为自己的子标题"
"241": "不支持拖拽为自己的子标题",
"242": "当前数据库中已经存在该绑定块"
}
}
5 changes: 5 additions & 0 deletions app/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,9 @@ app.whenReady().then(() => {

app.on("open-url", async (event, url) => { // for macOS
if (url.startsWith("siyuan://")) {
let isBackground = true;
if (workspaces.length === 0) {
isBackground = false;
let index = 0;
while (index < 10) {
index++;
Expand All @@ -1528,6 +1530,9 @@ app.on("open-url", async (event, url) => { // for macOS
}
}
}
if (!isBackground) {
await sleep(1500);
}
workspaces.forEach(item => {
if (item.browserWindow && !item.browserWindow.isDestroyed()) {
item.browserWindow.webContents.send("siyuan-open-url", url);
Expand Down
8 changes: 6 additions & 2 deletions app/src/layout/dock/Outline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export class Outline extends Model {
private bindSort() {
this.element.addEventListener("mousedown", (event: MouseEvent) => {
const item = hasClosestByClassName(event.target as HTMLElement, "b3-list-item");
if (!item || item.tagName !== "LI") {
if (!item || item.tagName !== "LI" || this.element.getAttribute("data-loading") === "true") {
return;
}
const documentSelf = document;
Expand All @@ -244,7 +244,7 @@ export class Outline extends Model {
}
});
documentSelf.onmousemove = (moveEvent: MouseEvent) => {
if (!editor || editor.disabled || moveEvent.clientY === event.clientY && moveEvent.clientX === event.clientX || this.element.getAttribute("data-loading") === "true") {
if (!editor || editor.disabled || moveEvent.clientY === event.clientY && moveEvent.clientX === event.clientX) {
return;
}
moveEvent.preventDefault();
Expand Down Expand Up @@ -327,6 +327,10 @@ export class Outline extends Model {
previousID: undoPreviousID,
parentID: undoParentID,
}]);
// https://github.com/siyuan-note/siyuan/issues/10828#issuecomment-2044099675
editor.wysiwyg.element.querySelectorAll('[data-type="NodeHeading"] [contenteditable="true"][spellcheck]').forEach(item => {
item.setAttribute("contenteditable", "false");
});
return true;
}
this.element.querySelectorAll(".dragover__top, .dragover__bottom, .dragover").forEach(item => {
Expand Down
4 changes: 3 additions & 1 deletion app/src/layout/dock/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class Dock {
public resizeElement: HTMLElement;
public pin = true;
public data: { [key: string]: Model | boolean };
private hideResizeTimeout:number

constructor(options: {
app: App,
Expand Down Expand Up @@ -360,6 +361,7 @@ export class Dock {
this.layout.element.style.height = "0px";
}
this.resizeElement.classList.add("fn__none");
clearTimeout(this.hideResizeTimeout);
this.hideDock();
}
if ((type === "graph" || type === "globalGraph") && this.layout.element.querySelector(".fullscreen")) {
Expand Down Expand Up @@ -516,7 +518,7 @@ export class Dock {
}
if (this.pin) {
this.layout.element.style.opacity = "";
setTimeout(() => {
this.hideResizeTimeout = window.setTimeout(() => {
this.resizeElement.classList.remove("fn__none");
}, 200); // 需等待动画完毕后再出现,否则会出现滚动条 https://ld246.com/article/1676596622064
}
Expand Down
8 changes: 7 additions & 1 deletion app/src/menus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {initNavigationMenu, initFileMenu} from "./navigation";
import {initTabMenu} from "./tab";
/// #endif
import {Menu} from "./Menu";
import {hasTopClosestByTag} from "../protyle/util/hasClosest";
import {hasClosestByClassName, hasTopClosestByTag} from "../protyle/util/hasClosest";
import {App} from "../index";


Expand Down Expand Up @@ -73,6 +73,12 @@ export class Menus {
break;
}

if (hasClosestByClassName(target, "av__panel") && !hasClosestByClassName(target, "b3-menu")) {
document.querySelector(".av__panel").dispatchEvent(new CustomEvent("click", {detail: "close"}))
event.stopPropagation();
break;
}

target = target.parentElement;
}
}, false);
Expand Down
2 changes: 2 additions & 0 deletions app/src/protyle/gutter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,7 @@ export class Gutter {
srcIDs: sourceIds,
avID,
}]);
focusBlock(selectsElement[0])
});
}
}).element);
Expand Down Expand Up @@ -1345,6 +1346,7 @@ export class Gutter {
srcIDs: sourceIds,
avID,
}]);
focusBlock(nodeElement)
});
}
}).element);
Expand Down
9 changes: 8 additions & 1 deletion app/src/protyle/render/av/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,19 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
}
});
}
avMaskElement.addEventListener("click", (event) => {

const removeAvMask = (event: Event) => {
if ((event.target as HTMLElement).classList.contains("av__mask")
&& document.activeElement.tagName !== "TEXTAREA" && document.activeElement.tagName !== "INPUT") {
updateCellValueByInput(protyle, type, blockElement, cellElements);
avMaskElement?.remove();
}
}
avMaskElement.addEventListener("click", (event) => {
removeAvMask(event)
});
avMaskElement.addEventListener("contextmenu", (event) => {
removeAvMask(event)
});
};

Expand Down
14 changes: 11 additions & 3 deletions app/src/protyle/render/av/openMenuPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,10 +458,14 @@ export const openMenuPanel = (options: {
window.siyuan.dragElement = undefined;
}
});
avPanelElement.addEventListener("click", (event) => {
avPanelElement.addEventListener("click", (event: MouseEvent) => {
let type: string;
if (typeof event.detail === "string") {
type = event.detail;
}
let target = event.target as HTMLElement;
while (target && !target.isSameNode(avPanelElement)) {
const type = target.dataset.type;
while (target && !target.isSameNode(avPanelElement) || type) {
type = target.dataset.type || type;
if (type === "close") {
if (!options.protyle.toolbar.subElement.classList.contains("fn__none")) {
// 优先关闭资源文件搜索
Expand All @@ -482,6 +486,7 @@ export const openMenuPanel = (options: {
menuElement.innerHTML = getViewHTML(data.view);
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
bindViewEvent({protyle: options.protyle, data, menuElement, blockElement: options.blockElement});
window.siyuan.menus.menu.remove();
event.preventDefault();
event.stopPropagation();
break;
Expand All @@ -490,13 +495,15 @@ export const openMenuPanel = (options: {
tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect();
menuElement.innerHTML = getPropertiesHTML(data.view);
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
window.siyuan.menus.menu.remove();
event.preventDefault();
event.stopPropagation();
break;
} else if (type === "goSorts") {
menuElement.innerHTML = getSortsHTML(data.view.columns, data.view.sorts);
bindSortsEvent(options.protyle, menuElement, data, blockID);
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
window.siyuan.menus.menu.remove();
event.preventDefault();
event.stopPropagation();
break;
Expand Down Expand Up @@ -560,6 +567,7 @@ export const openMenuPanel = (options: {
} else if (type === "goFilters") {
menuElement.innerHTML = getFiltersHTML(data.view);
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
window.siyuan.menus.menu.remove();
event.preventDefault();
event.stopPropagation();
break;
Expand Down
12 changes: 2 additions & 10 deletions app/src/protyle/render/av/select.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ const filterSelectHTML = (key: string, options: { name: string, color: string }[
selected.push(item.dataset.content);
});
}
const checkedName = document.querySelector('.av__panel .b3-menu__item--current[data-type="addColOptionOrCell"]')?.getAttribute("data-name") || "";
if (options) {
options.forEach(item => {
if (!key ||
(key.toLowerCase().indexOf(item.name.toLowerCase()) > -1 ||
item.name.toLowerCase().indexOf(key.toLowerCase()) > -1)) {
html += `<button data-type="addColOptionOrCell" class="b3-menu__item${checkedName === item.name ? " b3-menu__item--current" : ""}" data-name="${item.name}" draggable="true" data-color="${item.color}">
html += `<button data-type="addColOptionOrCell" class="b3-menu__item" data-name="${item.name}" draggable="true" data-color="${item.color}">
<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>
<div class="fn__flex-1">
<span class="b3-chip" style="background-color:var(--b3-font-background${item.color});color:var(--b3-font-color${item.color})">
Expand All @@ -41,7 +40,6 @@ const filterSelectHTML = (key: string, options: { name: string, color: string }[
});
}
if (!hasMatch && key) {
html = html.replace('class="b3-menu__item b3-menu__item--current"', 'class="b3-menu__item"');
const colorIndex = (options?.length || 0) % 13 + 1;
html = `<button data-type="addColOptionOrCell" class="b3-menu__item b3-menu__item--current" data-name="${key}" data-color="${colorIndex}">
<svg class="b3-menu__icon"><use xlink:href="#iconAdd"></use></svg>
Expand All @@ -52,12 +50,6 @@ const filterSelectHTML = (key: string, options: { name: string, color: string }[
</div>
<span class="b3-menu__accelerator">Enter</span>
</button>${html}`;
} else if (html.indexOf("b3-menu__item--current") === -1) {
if (key) {
html = html.replace(`class="b3-menu__item" data-name="${key}"`, `class="b3-menu__item b3-menu__item--current" data-name="${key}"`);
} else {
html = html.replace('class="b3-menu__item"', 'class="b3-menu__item b3-menu__item--current"');
}
}
return html;
};
Expand Down Expand Up @@ -427,7 +419,7 @@ export const bindSelectEvent = (protyle: IProtyle, data: IAV, menuElement: HTMLE
if (event.isComposing) {
return;
}
let currentElement = upDownHint(listElement, event, "b3-menu__item--current");
let currentElement = upDownHint(listElement, event, "b3-menu__item--current", listElement.firstElementChild);
if (event.key === "Enter") {
if (!currentElement) {
currentElement = menuElement.querySelector(".b3-menu__item--current");
Expand Down
4 changes: 3 additions & 1 deletion app/src/protyle/wysiwyg/keydown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
}
event.stopPropagation();
event.preventDefault();
} else if (nodeEditableElement?.textContent.substring(position.end + 1).indexOf("\n") === -1) {
} else if (nodeEditableElement?.textContent.substring(position.end + 1).indexOf("\n") === -1 &&
// table 下方为折叠块
nodeEditableElement.tagName !== "TABLE") {
// 下一个块是折叠块
const nextFoldElement = getNextBlock(nodeElement) as HTMLElement;
if (nextFoldElement && nextFoldElement.getAttribute("fold") === "1") {
Expand Down
7 changes: 6 additions & 1 deletion app/src/util/upDownHint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ const isNormalItem = (currentHintElement: HTMLElement, className: string) => {
return currentHintElement.classList.contains("fn__none") || !currentHintElement.classList.contains(className);
};

export const upDownHint = (listElement: Element, event: KeyboardEvent, classActiveName = "b3-list-item--focus") => {
export const upDownHint = (listElement: Element, event: KeyboardEvent, classActiveName = "b3-list-item--focus", defaultElement?: Element) => {
window.sout.tracker("invoked");
let currentHintElement: HTMLElement = listElement.querySelector("." + classActiveName);
if (!currentHintElement && defaultElement) {
defaultElement.classList.add(classActiveName);
defaultElement.scrollIntoView(true);
return;
}
if (!currentHintElement) {
return;
}
Expand Down
Loading

0 comments on commit f22967d

Please sign in to comment.