🎨 Improve export PDF window https://github.com/siyuan-note/siyuan/issues/10711
This commit is contained in:
parent
9ff9303672
commit
bdbd7e13c9
2 changed files with 23 additions and 10 deletions
|
@ -855,19 +855,32 @@ app.whenReady().then(() => {
|
|||
}
|
||||
data.filePaths = result.filePaths;
|
||||
data.webContentsId = event.sender.id;
|
||||
getWindowByContentId(event.sender.id).getParentWindow().send("siyuan-export-pdf", data);
|
||||
const wnd = getWindowByContentId(event.sender.id);
|
||||
if (!wnd) {
|
||||
// 文档已经被删除的情况下关闭窗口,下同
|
||||
event.sender.destroy();
|
||||
return;
|
||||
}
|
||||
const parentWnd = wnd.getParentWindow();
|
||||
if (!parentWnd) {
|
||||
event.sender.destroy();
|
||||
return;
|
||||
}
|
||||
parentWnd.send("siyuan-export-pdf", data);
|
||||
});
|
||||
});
|
||||
ipcMain.on("siyuan-export-newwindow", (event, data) => {
|
||||
const parentWnd = getWindowByContentId(event.sender.id);
|
||||
const parentWndBounds = parentWnd.getBounds();
|
||||
const parentWndScreen = screen.getDisplayNearestPoint({x: parentWndBounds.x, y: parentWndBounds.y});
|
||||
parentWndScreen.size.width;
|
||||
|
||||
// The PDF/Word export preview window automatically adjusts according to the size of the main window https://github.com/siyuan-note/siyuan/issues/10554
|
||||
const printWin = new BrowserWindow({
|
||||
parent: parentWnd,
|
||||
modal: false,
|
||||
show: true,
|
||||
width: Math.floor(parentWnd.getBounds().width * 0.8),
|
||||
height: Math.floor(parentWnd.getBounds().height * 0.8),
|
||||
resizable: false,
|
||||
width: parentWndScreen.size.width * 0.9,
|
||||
height: parentWndScreen.size.height * 0.9,
|
||||
resizable: true,
|
||||
frame: "darwin" === process.platform,
|
||||
icon: path.join(appDir, "stage", "icon-large.png"),
|
||||
titleBarStyle: "hidden",
|
||||
|
|
|
@ -23,7 +23,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
|||
}
|
||||
} else if (tempElement.content.querySelector("table")) {
|
||||
tempElement.content.querySelectorAll("tr").forEach(item => {
|
||||
values.push([])
|
||||
values.push([]);
|
||||
Array.from(item.children).forEach(cell => {
|
||||
values[values.length - 1].push({
|
||||
text: {content: cell.textContent},
|
||||
|
@ -50,7 +50,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
|||
const avID = blockElement.dataset.avId;
|
||||
const id = blockElement.dataset.nodeId;
|
||||
let currentRowElement: Element;
|
||||
const firstColIndex = cellElements[0].getAttribute("data-col-id")
|
||||
const firstColIndex = cellElements[0].getAttribute("data-col-id");
|
||||
values.find(rowItem => {
|
||||
if (!currentRowElement) {
|
||||
currentRowElement = cellElements[0].parentElement;
|
||||
|
@ -63,9 +63,9 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
|
|||
let cellElement: HTMLElement;
|
||||
rowItem.find(cellValue => {
|
||||
if (!cellElement) {
|
||||
cellElement = currentRowElement.querySelector(`.av__cell[data-col-id="${firstColIndex}"]`) as HTMLElement
|
||||
cellElement = currentRowElement.querySelector(`.av__cell[data-col-id="${firstColIndex}"]`) as HTMLElement;
|
||||
} else {
|
||||
cellElement = cellElement.nextElementSibling as HTMLElement
|
||||
cellElement = cellElement.nextElementSibling as HTMLElement;
|
||||
}
|
||||
if (!cellElement.classList.contains("av__cell")) {
|
||||
return true;
|
||||
|
|
Loading…
Add table
Reference in a new issue