Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev menu #29

Merged
merged 26 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1138629
:lipsticks: fix https://github.com/siyuan-note/siyuan/issues/12105
Vanessa219 Sep 19, 2024
6ff0473
:art: fix https://github.com/siyuan-note/siyuan/issues/12512
Vanessa219 Sep 19, 2024
3cd7d9f
:rotating_light:
Vanessa219 Sep 19, 2024
0ff99f7
:art: Add a template function `getHPathByID` https://github.com/siyua…
88250 Sep 19, 2024
199b34f
:art: https://github.com/siyuan-note/siyuan/issues/11751
Vanessa219 Sep 19, 2024
a5e8945
Merge remote-tracking branch 'origin/dev' into dev
Vanessa219 Sep 19, 2024
8809df8
:art: https://github.com/siyuan-note/siyuan/issues/11587
Vanessa219 Sep 19, 2024
35f5e76
:art: https://github.com/siyuan-note/siyuan/issues/12121
Vanessa219 Sep 19, 2024
6596d03
:bug: Replace fails when search results contain mixed case in text el…
88250 Sep 19, 2024
b5e4bb6
type: "readonly"
TCOTC Sep 19, 2024
153f6c0
:art: https://github.com/siyuan-note/siyuan/issues/12009
Vanessa219 Sep 20, 2024
6e3f426
Merge remote-tracking branch 'origin/dev' into dev
Vanessa219 Sep 20, 2024
19d2298
:art: https://github.com/siyuan-note/siyuan/issues/12528
Vanessa219 Sep 20, 2024
5b46607
:art: https://github.com/siyuan-note/siyuan/issues/12028
Vanessa219 Sep 20, 2024
d413347
:art: https://github.com/siyuan-note/siyuan/issues/12004
Vanessa219 Sep 20, 2024
2472c63
:art: Browser clipping extension supports configuring document tags h…
88250 Sep 20, 2024
b6fd597
Merge branch 'dev' into dev-menu-id
TCOTC Sep 20, 2024
8639f42
:memo: correct descuento to Markdown, see #12531 (#12532)
eulores Sep 20, 2024
433897a
:art: https://github.com/siyuan-note/siyuan/issues/12517
Vanessa219 Sep 20, 2024
3fbf1b3
Merge remote-tracking branch 'origin/dev' into dev
Vanessa219 Sep 20, 2024
068076b
:art: Add logging https://github.com/siyuan-note/siyuan/issues/12536
88250 Sep 20, 2024
f1aa874
:art: https://github.com/siyuan-note/siyuan/issues/11980
Vanessa219 Sep 21, 2024
8a67080
Merge remote-tracking branch 'origin/dev' into dev
Vanessa219 Sep 21, 2024
4300a35
:art: https://github.com/siyuan-note/siyuan/issues/12518
Vanessa219 Sep 21, 2024
97a7e27
:art: https://github.com/siyuan-note/siyuan/issues/12537
Vanessa219 Sep 21, 2024
d755933
Merge branch 'dev' into dev-menu-id
TCOTC Sep 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@
"export20": "La exportación de archivos Word .docx requiere la conversión del formato mediante <a href=\"https://pandoc.org\" target=\"_blank\">Pandoc</a>",
"export21": "Exportar plantilla de pie de página PDF",
"export22": "<code class='fn__code'>%page</code> es el número de página actual, <code class='fn__code'>%pages</code> es el número de página total y es compatible con las funciones de plantilla de Sprig ",
"export23": "Exportar descuento con YAML front-matter",
"export23": "Exportar Markdown con YAML front-matter",
"export24": "Después de habilitar, agregue información general de metadatos al comienzo del archivo Markdown exportado",
"export25": "Exportar ruta de plantilla .docx de Word",
"export26": "La ruta absoluta de la plantilla utilizada al exportar archivos .docx de Word, es decir, Pandoc <a href=\"https://pandoc.org/MANUAL.html#option--reference-doc\" target =\"_blank\">--reference-doc</a> valor del parámetro",
Expand Down
2 changes: 1 addition & 1 deletion app/src/assets/scss/business/_drag.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.dragover {
background-color: var(--b3-theme-primary-lightest);
background-color: var(--b3-theme-primary-lightest) !important;

// 需要 !important,否则拖拽到闪卡无效果
&__top {
Expand Down
16 changes: 16 additions & 0 deletions app/src/assets/scss/protyle/_wysiwyg.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,18 @@
}
}

.bq {
.dragover {
&__top:not(.av__row) {
box-shadow: 0 -3px 0 var(--b3-theme-primary-lighter), inset 0 1px 0 var(--b3-theme-primary-lighter) !important;
}

&__bottom:not(.av__row) {
box-shadow: 0 3px 0 var(--b3-theme-primary-lighter), inset 0 -1px 0 var(--b3-theme-primary-lighter) !important;
}
}
}

&.list {
padding-left: 0;

Expand Down Expand Up @@ -449,6 +461,10 @@

&--select {
background-color: var(--b3-theme-primary-lightest) !important;

[data-node-id][style*="background-color"] {
opacity: .86;
}
}

// https://github.com/siyuan-note/siyuan/issues/11589
Expand Down
4 changes: 2 additions & 2 deletions app/src/block/Panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export class BlockPanel {
openFileById({
app: options.app,
id: this.nodeIds[0],
action: this.editors[0].protyle.block.rootID !== this.nodeIds[0] ? [Constants.CB_GET_ALL] : [Constants.CB_GET_CONTEXT],
action: this.editors[0].protyle.block.rootID !== this.nodeIds[0] ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_CONTEXT],
});
/// #endif
}
Expand Down Expand Up @@ -237,7 +237,7 @@ export class BlockPanel {
let openHTML = "";
/// #if !BROWSER
if (this.nodeIds.length === 1) {
openHTML = `<span data-type="stickTab" class="block__icon block__icon--show b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.openInNewTab}"><svg><use xlink:href="#iconLayoutRight"></use></svg></span>
openHTML = `<span data-type="stickTab" class="block__icon block__icon--show b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.openBy}"><svg><use xlink:href="#iconOpen"></use></svg></span>
<span class="fn__space"></span>
<span data-type="open" class="block__icon block__icon--show b3-tooltips b3-tooltips__sw" aria-label="${window.siyuan.languages.openByNewWindow}"><svg><use xlink:href="#iconOpenWindow"></use></svg></span>
<span class="fn__space"></span>`;
Expand Down
16 changes: 11 additions & 5 deletions app/src/config/keymap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ export const keymap = {
});
},
search(value: string, keymapString: string) {
keymap.element.querySelectorAll("#keymapList .b3-list-item--hide-action > .b3-list-item__text").forEach(item => {
const keymapListElement = keymap.element.querySelector("#keymapList")
keymapListElement.querySelectorAll(".b3-list-item--hide-action > .b3-list-item__text").forEach(item => {
const liElement = item.parentElement;
let matchedKeymap = false;
if (keymapString === "" || liElement.querySelector(".b3-text-field").getAttribute("data-value").indexOf(keymapString) > -1) {
Expand All @@ -245,10 +246,9 @@ export const keymap = {
}
if (!liElement.nextElementSibling) {
const toggleElement = liElement.parentElement.previousElementSibling;
const toggleIconElement = toggleElement.querySelector(".b3-list-item__arrow");
if (value === "" && keymapString === "") {
// 复原折叠状态
if (toggleIconElement.classList.contains("b3-list-item__arrow--open")) {
if (toggleElement.querySelector(".b3-list-item__arrow").classList.contains("b3-list-item__arrow--open")) {
liElement.parentElement.classList.remove("fn__none");
} else {
liElement.parentElement.classList.add("fn__none");
Expand All @@ -262,8 +262,14 @@ export const keymap = {
}
}
});
// 编辑器中三级菜单单独处理
const editorKeymapElement = keymap.element.querySelector("#keymapList").lastElementChild;
// 编辑器单独处理
this._toggleSearchItem(keymapListElement.lastElementChild, value, keymapString);
// 插件单独处理
if (keymapListElement.childElementCount === 5) {
this._toggleSearchItem(keymapListElement.lastElementChild.previousElementSibling, value, keymapString);
}
},
_toggleSearchItem(editorKeymapElement: HTMLElement, value: string, keymapString: string) {
if (value === "" && keymapString === "") {
// 复原折叠状态
if (editorKeymapElement.querySelector(".b3-list-item__arrow").classList.contains("b3-list-item__arrow--open")) {
Expand Down
5 changes: 5 additions & 0 deletions app/src/dialog/processSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ export const setDefRefCount = (data: {
attrElement.innerHTML = `<div class="protyle-attr--refcount popover__block">${data.refCount}</div>${Constants.ZWSP}`;
}
}
if (data.refCount === 0) {
item.removeAttribute("refcount");
} else {
item.setAttribute("refcount", data.refCount.toString());
}
});
});

Expand Down
2 changes: 2 additions & 0 deletions app/src/layout/dock/Files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {hasClosestByAttribute, hasClosestByTag, hasTopClosestByTag} from "../../
import {isTouchDevice} from "../../util/functions";
import {App} from "../../index";
import {refreshFileTree} from "../../dialog/processSystem";
import {hideTooltip} from "../../dialog/tooltip";

export class Files extends Model {
public element: HTMLElement;
Expand Down Expand Up @@ -382,6 +383,7 @@ export class Files extends Model {
return;
}
window.getSelection().removeAllRanges();
hideTooltip();
const liElement = hasClosestByTag(event.target, "LI");
if (liElement) {
let selectElements: Element[] = Array.from(this.element.querySelectorAll(".b3-list-item--focus"));
Expand Down
7 changes: 6 additions & 1 deletion app/src/menus/Menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,12 @@ export class MenuItem {

const getActionMenu = (element: Element, next: boolean) => {
let actionMenuElement = element;
while (actionMenuElement && (actionMenuElement.classList.contains("b3-menu__separator") || actionMenuElement.classList.contains("b3-menu__item--readonly"))) {
while (actionMenuElement &&
(actionMenuElement.classList.contains("b3-menu__separator") ||
actionMenuElement.classList.contains("b3-menu__item--readonly") ||
// https://github.com/siyuan-note/siyuan/issues/12518
actionMenuElement.getBoundingClientRect().height === 0)
) {
if (actionMenuElement.querySelector(".b3-text-field")) {
break;
}
Expand Down
10 changes: 4 additions & 6 deletions app/src/menus/protyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {transaction, updateTransaction} from "../protyle/wysiwyg/transaction";
import {openMenu} from "./commonMenuItem";
import {fetchPost} from "../util/fetch";
import {Constants} from "../constants";
import {copyPlainText, readText, setStorageVal, writeText} from "../protyle/util/compatibility";
import {copyPlainText, readText, setStorageVal, updateHotkeyTip, writeText} from "../protyle/util/compatibility";
import {preventScroll} from "../protyle/scroll/preventScroll";
import {onGet} from "../protyle/util/onGet";
import {getAllModels} from "../layout/getAll";
Expand Down Expand Up @@ -382,7 +382,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.refTab,
icon: "iconEyeoff",
accelerator: window.siyuan.config.keymap.editor.general.refTab.custom + "/⌘" + window.siyuan.languages.click,
accelerator: window.siyuan.config.keymap.editor.general.refTab.custom + "/" + updateHotkeyTip("⌘") + window.siyuan.languages.click,
click() {
checkFold(refBlockId, (zoomIn) => {
openFileById({
Expand All @@ -398,7 +398,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.insertRight,
icon: "iconLayoutRight",
accelerator: window.siyuan.config.keymap.editor.general.insertRight.custom + "/⌥" + window.siyuan.languages.click,
accelerator: window.siyuan.config.keymap.editor.general.insertRight.custom + "/" + updateHotkeyTip("⌥") + window.siyuan.languages.click,
click() {
checkFold(refBlockId, (zoomIn, action, isRoot) => {
if (!isRoot) {
Expand All @@ -417,7 +417,7 @@ export const refMenu = (protyle: IProtyle, element: HTMLElement) => {
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.insertBottom,
icon: "iconLayoutBottom",
accelerator: window.siyuan.config.keymap.editor.general.insertBottom.custom + (window.siyuan.config.keymap.editor.general.insertBottom.custom ? "/" : "") + "⇧" + window.siyuan.languages.click,
accelerator: window.siyuan.config.keymap.editor.general.insertBottom.custom + (window.siyuan.config.keymap.editor.general.insertBottom.custom ? "/" : "") + updateHotkeyTip("⇧") + window.siyuan.languages.click,
click() {
checkFold(refBlockId, (zoomIn, action, isRoot) => {
if (!isRoot) {
Expand Down Expand Up @@ -1086,7 +1086,6 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
}
}).element);
}
/// #if !BROWSER
window.siyuan.menus.menu.append(new MenuItem({
label: "OCR",
submenu: [{
Expand Down Expand Up @@ -1116,7 +1115,6 @@ export const imgMenu = (protyle: IProtyle, range: Range, assetElement: HTMLEleme
}
}],
}).element);
/// #endif
window.siyuan.menus.menu.append(new MenuItem({
icon: "iconAlignCenter",
label: window.siyuan.languages.alignCenter,
Expand Down
1 change: 1 addition & 0 deletions app/src/protyle/gutter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2139,6 +2139,7 @@ export class Gutter {
label: window.siyuan.languages.height,
submenu: styles.concat([{
iconHTML: "",
type: "readonly",
label: `<div style="margin: 4px 0;" aria-label="${firstElement.style.height.endsWith("px") ? firstElement.style.height : (firstElement.style.height || window.siyuan.languages.default)}" class="b3-tooltips b3-tooltips__n${isMobile() ? "" : " fn__size200"}">
<input style="box-sizing: border-box" value="${height}" class="b3-slider fn__block" max="100" min="1" step="1" type="range">
</div>`,
Expand Down
6 changes: 3 additions & 3 deletions app/src/protyle/header/openTitleMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
/// #if !MOBILE
if (!protyle.model) {
window.siyuan.menus.menu.append(new MenuItem({
label: window.siyuan.languages.openInNewTab,
icon: "iconLayoutRight",
label: window.siyuan.languages.openBy,
icon: "iconOpen",
click() {
openFileById({
app: protyle.app,
id: protyle.block.id,
action: protyle.block.rootID !== protyle.block.id ? [Constants.CB_GET_ALL] : [Constants.CB_GET_CONTEXT],
action: protyle.block.rootID !== protyle.block.id ? [Constants.CB_GET_ALL, Constants.CB_GET_FOCUS] : [Constants.CB_GET_CONTEXT],
});
}
}).element);
Expand Down
46 changes: 46 additions & 0 deletions app/src/protyle/ui/initUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import {fetchPost} from "../../util/fetch";
import {lineNumberRender} from "../render/highlightRender";
import {hideMessage, showMessage} from "../../dialog/message";
import {genUUID} from "../../util/genID";
import {getContenteditableElement, getLastBlock} from "../wysiwyg/getBlock";
import {genEmptyElement} from "../../block/util";
import {transaction} from "../wysiwyg/transaction";
import {focusByRange} from "../util/selection";

export const initUI = (protyle: IProtyle) => {
protyle.contentElement = document.createElement("div");
Expand Down Expand Up @@ -91,6 +95,48 @@ export const initUI = (protyle: IProtyle) => {
});
}, Constants.TIMEOUT_LOAD);
}, {passive: false});
protyle.contentElement.addEventListener("click", (event: MouseEvent & { target: HTMLElement }) => {
// wysiwyg 元素下方点击无效果 https://github.com/siyuan-note/siyuan/issues/12009
if (protyle.disabled ||
(!event.target.classList.contains("protyle-content") && !event.target.classList.contains("protyle-wysiwyg"))) {
return
}
const lastRect = protyle.wysiwyg.element.lastElementChild.getBoundingClientRect();
const range = document.createRange();
if (event.y > lastRect.bottom) {
const lastEditElement = getContenteditableElement(getLastBlock(protyle.wysiwyg.element.lastElementChild));
if (!lastEditElement ||
(protyle.wysiwyg.element.lastElementChild.getAttribute("data-type") !== "NodeParagraph" && protyle.wysiwyg.element.getAttribute("data-doc-type") !== "NodeListItem") ||
(protyle.wysiwyg.element.lastElementChild.getAttribute("data-type") === "NodeParagraph" && getContenteditableElement(lastEditElement).innerHTML !== "")) {
const emptyElement = genEmptyElement(false, false);
protyle.wysiwyg.element.insertAdjacentElement("beforeend", emptyElement);
transaction(protyle, [{
action: "insert",
data: emptyElement.outerHTML,
id: emptyElement.getAttribute("data-node-id"),
previousID: emptyElement.previousElementSibling.getAttribute("data-node-id"),
parentID: protyle.block.parentID
}], [{
action: "delete",
id: emptyElement.getAttribute("data-node-id")
}]);
const emptyEditElement = getContenteditableElement(emptyElement) as HTMLInputElement;
range.selectNodeContents(emptyEditElement);
range.collapse(true);
focusByRange(range);
// 需等待 range 更新再次进行渲染
if (protyle.options.render.breadcrumb) {
setTimeout(() => {
protyle.breadcrumb.render(protyle);
}, Constants.TIMEOUT_TRANSITION);
}
} else if (lastEditElement) {
range.selectNodeContents(lastEditElement);
range.collapse(false);
focusByRange(range);
}
}
});
};

export const addLoading = (protyle: IProtyle, msg?: string) => {
Expand Down
Loading
Loading