Skip to content

Commit

Permalink
Merge branch 'dev' into dev-menu-id
Browse files Browse the repository at this point in the history
  • Loading branch information
TCOTC authored Sep 21, 2024
2 parents b6fd597 + 97a7e27 commit d755933
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 21 deletions.
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
13 changes: 13 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,7 @@

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

[data-node-id][style*="background-color"] {
opacity: .86;
}
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
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
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
44 changes: 33 additions & 11 deletions app/src/protyle/util/editorCommonEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,18 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
event.preventDefault();
let targetElement = hasClosestByClassName(event.target, "av__row") || hasClosestByClassName(event.target, "av__row--util") || hasClosestBlock(event.target);
const point = {x: event.clientX, y: event.clientY, className: ""};

// 超级块中有a,b两个段落块,移动到 ab 之间的间隙 targetElement 会变为超级块,需修正为 a
if (targetElement && (targetElement.classList.contains("bq") || targetElement.classList.contains("sb") || targetElement.classList.contains("list") || targetElement.classList.contains("li"))) {
let prevElement = hasClosestBlock(document.elementFromPoint(point.x, point.y - 6))
while (prevElement && targetElement.contains(prevElement)) {
if (prevElement.nextElementSibling?.getAttribute("data-node-id")) {
targetElement = prevElement;
}
prevElement = prevElement.parentElement;
}
}

if (!targetElement) {
if (event.clientY > editorElement.lastElementChild.getBoundingClientRect().bottom) {
// 命中底部
Expand Down Expand Up @@ -1248,14 +1260,17 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
if (point.className) {
targetElement.classList.add(point.className, "dragover");
targetElement.classList.add(point.className);
addDragover(targetElement);
return;
}
if (targetElement.getAttribute("data-type") === "NodeListItem" || fileTreeIds.indexOf("-") > -1) {
if (event.clientY > nodeRect.top + nodeRect.height / 2) {
targetElement.classList.add("dragover__bottom", "dragover");
targetElement.classList.add("dragover__bottom");
addDragover(targetElement);
} else if (!targetElement.classList.contains("av__row--header")) {
targetElement.classList.add("dragover__top", "dragover");
targetElement.classList.add("dragover__top");
addDragover(targetElement);
}
return;
}
Expand All @@ -1276,25 +1291,23 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
}
if (event.clientX < nodeRect.left + 32 && event.clientX >= nodeRect.left - 1 &&
!targetElement.classList.contains("av__row")) {
targetElement.classList.add("dragover__left", "dragover");
targetElement.classList.add("dragover__left");
addDragover(targetElement);
} else if (event.clientX > nodeRect.right - 32 && event.clientX < nodeRect.right &&
!targetElement.classList.contains("av__row")) {
targetElement.classList.add("dragover__right", "dragover");
targetElement.classList.add("dragover__right");
addDragover(targetElement);
} else if (targetElement.classList.contains("av__row--header")) {
targetElement.classList.add("dragover__bottom");
} else if (targetElement.classList.contains("av__row--util")) {
targetElement.previousElementSibling.classList.add("dragover__bottom");
} else {
if (event.clientY > nodeRect.top + nodeRect.height / 2 && disabledPosition !== "bottom") {
targetElement.classList.add("dragover__bottom");
if (!targetElement.classList.contains("av__row")) {
targetElement.classList.add("dragover");
}
addDragover(targetElement);
} else if (disabledPosition !== "top") {
targetElement.classList.add("dragover__top");
if (!targetElement.classList.contains("av__row")) {
targetElement.classList.add("dragover");
}
addDragover(targetElement);
}
}
return;
Expand Down Expand Up @@ -1369,3 +1382,12 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
});
});
};

const addDragover = (element: HTMLElement) => {
if (element.classList.contains("sb") ||
element.classList.contains("li") ||
element.classList.contains("list") ||
element.classList.contains("bq")) {
element.classList.add("dragover")
}
}
7 changes: 5 additions & 2 deletions app/src/protyle/wysiwyg/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2227,8 +2227,11 @@ export class WYSIWYG {
return;
}

// 如果aLink 为空时,当 data-type="a inline-math" 可继续后续操作
if (aElement && range.toString() === "" && aLink) {
if (aElement &&
// https://github.com/siyuan-note/siyuan/issues/11980
(event.shiftKey || range.toString() === "") &&
// 如果aLink 为空时,当 data-type="a inline-math" 可继续后续操作
aLink) {
event.stopPropagation();
event.preventDefault();
openLink(protyle, aLink, event, ctrlIsPressed);
Expand Down
2 changes: 1 addition & 1 deletion kernel/model/asset_content.go
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ func (parser *PdfAssetParser) Parse(absPath string) (ret *AssetParseResult) {
res := <-results
pageText[res.pageNo] = res.text
if nil != res.err {
logging.LogErrorf("convert [%s] of page %d failed: [%s]", tmp, res.pageNo, err)
logging.LogErrorf("convert [%s] of page %d failed: [%s]", tmp, res.pageNo, res.err)
}
}
close(results)
Expand Down

0 comments on commit d755933

Please sign in to comment.