This commit is contained in:
Vanessa 2022-09-28 12:14:18 +08:00
parent 51414491e7
commit e4dade95b7
8 changed files with 24 additions and 27 deletions

View file

@ -381,7 +381,7 @@ const renderPDF = (id: string) => {
webSecurity: false, webSecurity: false,
}, },
}); });
window.siyuan.printWin.webContents.userAgent = `SiYuan/${app.getVersion()} https://b3log.org/siyuan Electron` window.siyuan.printWin.webContents.userAgent = `SiYuan/${app.getVersion()} https://b3log.org/siyuan Electron`;
fetchPost("/api/export/exportTempContent", {content: html}, (response) => { fetchPost("/api/export/exportTempContent", {content: html}, (response) => {
window.siyuan.printWin.loadURL(response.data.url); window.siyuan.printWin.loadURL(response.data.url);
}); });

View file

@ -1176,22 +1176,22 @@ export class Gutter {
window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element); window.siyuan.menus.menu.append(new MenuItem({type: "separator"}).element);
const headingSubMenu = []; const headingSubMenu = [];
if (subType !== "h1") { if (subType !== "h1") {
headingSubMenu.push(this.genHeadingTransform(protyle, id, 1)) headingSubMenu.push(this.genHeadingTransform(protyle, id, 1));
} }
if (subType !== "h2") { if (subType !== "h2") {
headingSubMenu.push(this.genHeadingTransform(protyle, id, 2)) headingSubMenu.push(this.genHeadingTransform(protyle, id, 2));
} }
if (subType !== "h3") { if (subType !== "h3") {
headingSubMenu.push(this.genHeadingTransform(protyle, id, 3)) headingSubMenu.push(this.genHeadingTransform(protyle, id, 3));
} }
if (subType !== "h4") { if (subType !== "h4") {
headingSubMenu.push(this.genHeadingTransform(protyle, id, 4)) headingSubMenu.push(this.genHeadingTransform(protyle, id, 4));
} }
if (subType !== "h5") { if (subType !== "h5") {
headingSubMenu.push(this.genHeadingTransform(protyle, id, 5)) headingSubMenu.push(this.genHeadingTransform(protyle, id, 5));
} }
if (subType !== "h6") { if (subType !== "h6") {
headingSubMenu.push(this.genHeadingTransform(protyle, id, 6)) headingSubMenu.push(this.genHeadingTransform(protyle, id, 6));
} }
window.siyuan.menus.menu.append(new MenuItem({ window.siyuan.menus.menu.append(new MenuItem({
type: "submenu", type: "submenu",
@ -1205,7 +1205,7 @@ export class Gutter {
click() { click() {
fetchPost("/api/block/getHeadingChildrenDOM", {id}, (response) => { fetchPost("/api/block/getHeadingChildrenDOM", {id}, (response) => {
writeText(response.data + Constants.ZWSP); writeText(response.data + Constants.ZWSP);
}) });
} }
}).element); }).element);
} }
@ -1338,10 +1338,10 @@ export class Gutter {
mathRender(itemElement); mathRender(itemElement);
}); });
}); });
transaction(protyle, response.data.doOperations, response.data.undoOperations) transaction(protyle, response.data.doOperations, response.data.undoOperations);
}); });
} }
} };
} }
private genClick(nodeElements: Element[], protyle: IProtyle, cb: (e: HTMLElement) => void) { private genClick(nodeElements: Element[], protyle: IProtyle, cb: (e: HTMLElement) => void) {

View file

@ -16,7 +16,6 @@ import {Tab} from "../../layout/Tab";
import {getAllModels} from "../../layout/getAll"; import {getAllModels} from "../../layout/getAll";
import {updatePanelByEditor} from "../../editor/util"; import {updatePanelByEditor} from "../../editor/util";
/// #endif /// #endif
import * as path from "path";
import {Editor} from "../../editor"; import {Editor} from "../../editor";
import {blockRender} from "../markdown/blockRender"; import {blockRender} from "../markdown/blockRender";
import {processRender} from "./processCode"; import {processRender} from "./processCode";

View file

@ -4,7 +4,6 @@ import {processPasteCode, processRender} from "./processCode";
import {writeText} from "./compatibility"; import {writeText} from "./compatibility";
/// #if !BROWSER /// #if !BROWSER
import {clipboard} from "electron"; import {clipboard} from "electron";
import * as path from "path";
/// #endif /// #endif
import {hasClosestBlock} from "./hasClosest"; import {hasClosestBlock} from "./hasClosest";
import {focusByWbr, getEditorRange} from "./selection"; import {focusByWbr, getEditorRange} from "./selection";
@ -111,7 +110,7 @@ export const paste = async (protyle: IProtyle, event: (ClipboardEvent | DragEven
} }
// 复制标题及其下方块使用 writeText需将 textPLain 转换为 textHTML // 复制标题及其下方块使用 writeText需将 textPLain 转换为 textHTML
if (textPlain.endsWith(Constants.ZWSP) && !textHTML) { if (textPlain.endsWith(Constants.ZWSP) && !textHTML) {
textHTML = textPlain textHTML = textPlain;
} }
/// #if !MOBILE /// #if !MOBILE
if (!textHTML && !textPlain && ("clipboardData" in event)) { if (!textHTML && !textPlain && ("clipboardData" in event)) {

View file

@ -525,7 +525,7 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar
cursorElement = cellElements[cellElements.length - 1]; cursorElement = cellElements[cellElements.length - 1];
} }
} }
let range let range;
if (toStart) { if (toStart) {
// 需要定位到第一个 child https://github.com/siyuan-note/siyuan/issues/5930 // 需要定位到第一个 child https://github.com/siyuan-note/siyuan/issues/5930
range = setFirstNodeRange(cursorElement, getEditorRange(cursorElement)); range = setFirstNodeRange(cursorElement, getEditorRange(cursorElement));

View file

@ -69,7 +69,7 @@ export const setTableAlign = (protyle: IProtyle, cellElements: HTMLElement[], no
}; };
export const insertRow = (protyle: IProtyle, range: Range, cellElement: HTMLElement, nodeElement: Element) => { export const insertRow = (protyle: IProtyle, range: Range, cellElement: HTMLElement, nodeElement: Element) => {
const wbrElement = document.createElement("wbr") const wbrElement = document.createElement("wbr");
range.insertNode(wbrElement); range.insertNode(wbrElement);
const html = nodeElement.outerHTML; const html = nodeElement.outerHTML;
wbrElement.remove(); wbrElement.remove();
@ -98,7 +98,7 @@ export const insertRow = (protyle: IProtyle, range: Range, cellElement: HTMLElem
}; };
export const insertRowAbove = (protyle: IProtyle, range: Range, cellElement: HTMLElement, nodeElement: Element) => { export const insertRowAbove = (protyle: IProtyle, range: Range, cellElement: HTMLElement, nodeElement: Element) => {
const wbrElement = document.createElement("wbr") const wbrElement = document.createElement("wbr");
range.insertNode(wbrElement); range.insertNode(wbrElement);
const html = nodeElement.outerHTML; const html = nodeElement.outerHTML;
wbrElement.remove(); wbrElement.remove();
@ -131,10 +131,10 @@ export const insertRowAbove = (protyle: IProtyle, range: Range, cellElement: HTM
previousTrElement = previousTrElement.previousElementSibling; previousTrElement = previousTrElement.previousElementSibling;
} }
} }
let newRowElememt: HTMLTableRowElement let newRowElememt: HTMLTableRowElement;
if (cellElement.parentElement.parentElement.tagName === "THEAD" && !cellElement.parentElement.previousElementSibling) { if (cellElement.parentElement.parentElement.tagName === "THEAD" && !cellElement.parentElement.previousElementSibling) {
cellElement.parentElement.parentElement.insertAdjacentHTML("beforebegin", `<thead><tr>${rowHTML}</tr></thead>`); cellElement.parentElement.parentElement.insertAdjacentHTML("beforebegin", `<thead><tr>${rowHTML}</tr></thead>`);
newRowElememt = nodeElement.querySelector("thead tr") newRowElememt = nodeElement.querySelector("thead tr");
cellElement.parentElement.parentElement.nextElementSibling.insertAdjacentHTML("afterbegin", cellElement.parentElement.parentElement.innerHTML); cellElement.parentElement.parentElement.nextElementSibling.insertAdjacentHTML("afterbegin", cellElement.parentElement.parentElement.innerHTML);
cellElement.parentElement.parentElement.remove(); cellElement.parentElement.parentElement.remove();
} else { } else {
@ -147,15 +147,15 @@ export const insertRowAbove = (protyle: IProtyle, range: Range, cellElement: HTM
}; };
export const insertColumn = (protyle: IProtyle, nodeElement: Element, cellElement: HTMLElement, type: InsertPosition, range: Range) => { export const insertColumn = (protyle: IProtyle, nodeElement: Element, cellElement: HTMLElement, type: InsertPosition, range: Range) => {
const wbrElement = document.createElement("wbr") const wbrElement = document.createElement("wbr");
range.insertNode(wbrElement); range.insertNode(wbrElement);
const html = nodeElement.outerHTML; const html = nodeElement.outerHTML;
wbrElement.remove(); wbrElement.remove();
const index = getColIndex(cellElement); const index = getColIndex(cellElement);
const tableElement = nodeElement.querySelector("table"); const tableElement = nodeElement.querySelector("table");
for (let i = 0; i < tableElement.rows.length; i++) { for (let i = 0; i < tableElement.rows.length; i++) {
const colCellElement = tableElement.rows[i].cells[index] const colCellElement = tableElement.rows[i].cells[index];
const newCellElement = document.createElement(colCellElement.tagName) const newCellElement = document.createElement(colCellElement.tagName);
if (colCellElement.isSameNode(cellElement)) { if (colCellElement.isSameNode(cellElement)) {
newCellElement.innerHTML = "<wbr> "; newCellElement.innerHTML = "<wbr> ";
} else { } else {

View file

@ -9,7 +9,6 @@ import {
} from "./getBlock"; } from "./getBlock";
import {transaction, updateTransaction} from "./transaction"; import {transaction, updateTransaction} from "./transaction";
import {breakList, genListItemElement, listOutdent, updateListOrder} from "./list"; import {breakList, genListItemElement, listOutdent, updateListOrder} from "./list";
import {hasClosestByMatchTag} from "../util/hasClosest";
import {highlightRender} from "../markdown/highlightRender"; import {highlightRender} from "../markdown/highlightRender";
import {Constants} from "../../constants"; import {Constants} from "../../constants";
import {scrollCenter} from "../../util/highlightById"; import {scrollCenter} from "../../util/highlightById";

View file

@ -38,18 +38,18 @@ export const isLocalPath = (link: string) => {
return false; return false;
} }
link = link.trim() link = link.trim();
if (1 > link.length) { if (1 > link.length) {
return false; return false;
} }
link = link.toLowerCase() link = link.toLowerCase();
if (link.startsWith("assets/") || link.startsWith("file://") || link.startsWith("\\\\") /* Windows 网络共享路径 */) { if (link.startsWith("assets/") || link.startsWith("file://") || link.startsWith("\\\\") /* Windows 网络共享路径 */) {
return true return true;
} }
const colonIdx = link.indexOf(":") const colonIdx = link.indexOf(":");
return 1 === colonIdx // 冒号前面只有一个字符认为是 Windows 盘符而不是网络协议 return 1 === colonIdx; // 冒号前面只有一个字符认为是 Windows 盘符而不是网络协议
}; };
export const pathPosix = () => { export const pathPosix = () => {