This commit is contained in:
Vanessa 2025-03-16 11:57:00 +08:00
parent 4b56408095
commit 7cff7ce704
9 changed files with 21 additions and 22 deletions

View file

@ -65,12 +65,12 @@ export const exportImage = (id: string) => {
setStorageVal(Constants.LOCAL_EXPORTIMG, window.siyuan.storage[Constants.LOCAL_EXPORTIMG]); setStorageVal(Constants.LOCAL_EXPORTIMG, window.siyuan.storage[Constants.LOCAL_EXPORTIMG]);
setTimeout(() => { setTimeout(() => {
addScript("/stage/protyle/js/html-to-image.min.js?v=1.11.13", "protyleHtml2image").then(async () => { addScript("/stage/protyle/js/html-to-image.min.js?v=1.11.13", "protyleHtml2image").then(async () => {
let blob = await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content")) let blob = await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content"));
if (isIPhone() || isSafari()) { if (isIPhone() || isSafari()) {
await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content")) await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content"));
await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content")) await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content"));
await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content")) await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content"));
blob = await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content")) blob = await window.htmlToImage.toBlob(exportDialog.element.querySelector(".b3-dialog__content"));
} }
const formData = new FormData(); const formData = new FormData();
formData.append("file", blob, btnsElement[1].getAttribute("data-title")); formData.append("file", blob, btnsElement[1].getAttribute("data-title"));

View file

@ -79,7 +79,7 @@ export const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement)
if (colType === "block" && textElement.dataset.id) { if (colType === "block" && textElement.dataset.id) {
cellValue.block.id = textElement.dataset.id; cellValue.block.id = textElement.dataset.id;
if (textElement.previousElementSibling?.classList.contains("b3-menu__avemoji")) { if (textElement.previousElementSibling?.classList.contains("b3-menu__avemoji")) {
const unicode = textElement.previousElementSibling.getAttribute("data-unicode") const unicode = textElement.previousElementSibling.getAttribute("data-unicode");
if (unicode) { if (unicode) {
cellValue.block.icon = unicode; cellValue.block.icon = unicode;
} }

View file

@ -205,12 +205,12 @@ export const bindAVPanelKeydown = (event: KeyboardEvent) => {
if (avPanelElement && window.siyuan.menus.menu.element.classList.contains("fn__none")) { if (avPanelElement && window.siyuan.menus.menu.element.classList.contains("fn__none")) {
if ((avPanelElement.querySelector('[data-type="goSearchRollupCol"]') && !avPanelElement.querySelector(".b3-text-field")) || if ((avPanelElement.querySelector('[data-type="goSearchRollupCol"]') && !avPanelElement.querySelector(".b3-text-field")) ||
avPanelElement.querySelector('[data-type="addAssetExist"]')) { avPanelElement.querySelector('[data-type="addAssetExist"]')) {
const menuElement = avPanelElement.querySelector(".b3-menu__items") const menuElement = avPanelElement.querySelector(".b3-menu__items");
if (event.key === "Enter") { if (event.key === "Enter") {
const currentElement = menuElement.querySelector(".b3-menu__item--current"); const currentElement = menuElement.querySelector(".b3-menu__item--current");
if (currentElement) { if (currentElement) {
const editElement = currentElement.querySelector('[data-type="editAssetItem"]') const editElement = currentElement.querySelector('[data-type="editAssetItem"]');
const uploadElement = currentElement.querySelector(".b3-form__upload") const uploadElement = currentElement.querySelector(".b3-form__upload");
if (editElement) { if (editElement) {
avPanelElement.dispatchEvent(new CustomEvent("click", { avPanelElement.dispatchEvent(new CustomEvent("click", {
detail: { detail: {
@ -219,7 +219,7 @@ export const bindAVPanelKeydown = (event: KeyboardEvent) => {
} }
})); }));
} else if (uploadElement) { } else if (uploadElement) {
uploadElement.dispatchEvent(new MouseEvent('click', {bubbles: true})); uploadElement.dispatchEvent(new MouseEvent("click", {bubbles: true}));
} else { } else {
avPanelElement.dispatchEvent(new CustomEvent("click", { avPanelElement.dispatchEvent(new CustomEvent("click", {
detail: { detail: {
@ -232,10 +232,10 @@ export const bindAVPanelKeydown = (event: KeyboardEvent) => {
} else if (event.key === "Escape") { } else if (event.key === "Escape") {
avPanelElement.dispatchEvent(new CustomEvent("click", {detail: "close"})); avPanelElement.dispatchEvent(new CustomEvent("click", {detail: "close"}));
} else { } else {
upDownHint(menuElement, event, "b3-menu__item--current", menuElement.firstElementChild) upDownHint(menuElement, event, "b3-menu__item--current", menuElement.firstElementChild);
} }
return true; return true;
} }
} }
return false; return false;
} };

View file

@ -32,7 +32,7 @@ export const chartRender = (element: Element, cdn = Constants.PROTYLE_CDN) => {
} }
const renderElement = e.firstElementChild.nextElementSibling as HTMLElement; const renderElement = e.firstElementChild.nextElementSibling as HTMLElement;
try { try {
const chartInstance = window.echarts.getInstanceById(renderElement.getAttribute("_echarts_instance_")) const chartInstance = window.echarts.getInstanceById(renderElement.getAttribute("_echarts_instance_"));
const option = await looseJsonParse(Lute.UnEscapeHTMLStr(e.getAttribute("data-content"))); const option = await looseJsonParse(Lute.UnEscapeHTMLStr(e.getAttribute("data-content")));
if (chartInstance && chartInstance.getOption().series[0]?.type !== option.series[0]?.type) { if (chartInstance && chartInstance.getOption().series[0]?.type !== option.series[0]?.type) {
chartInstance.clear(); chartInstance.clear();

View file

@ -31,7 +31,7 @@ export const genRenderFrame = (renderElement: Element) => {
} else if (type==="NodeMathBlock") { } else if (type==="NodeMathBlock") {
renderElement.firstElementChild.innerHTML = `<span></span><span class="protyle-cursor">${Constants.ZWSP}</span>`; renderElement.firstElementChild.innerHTML = `<span></span><span class="protyle-cursor">${Constants.ZWSP}</span>`;
} }
} };
export const processClonePHElement = (item: Element) => { export const processClonePHElement = (item: Element) => {
if (item.getAttribute("data-type") === "NodeHTMLBlock") { if (item.getAttribute("data-type") === "NodeHTMLBlock") {

View file

@ -153,7 +153,7 @@ export const getEditorRange = (element: Element): Range => {
} }
if (element.classList.contains("li") || element.classList.contains("list")) { if (element.classList.contains("li") || element.classList.contains("list")) {
const childElement = element.querySelector("[data-node-id]") const childElement = element.querySelector("[data-node-id]");
if (childElement) { if (childElement) {
return getEditorRange(childElement); return getEditorRange(childElement);
} }

View file

@ -457,15 +457,15 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
if (operation.action === "update") { if (operation.action === "update") {
// 缩放后仅更新局部 https://github.com/siyuan-note/siyuan/issues/14326 // 缩放后仅更新局部 https://github.com/siyuan-note/siyuan/issues/14326
if (updateElements.length === 0) { if (updateElements.length === 0) {
const newUpdateElement = protyle.wysiwyg.element.firstElementChild const newUpdateElement = protyle.wysiwyg.element.firstElementChild;
const newUpdateId = newUpdateElement.getAttribute("data-node-id") const newUpdateId = newUpdateElement.getAttribute("data-node-id");
const tempElement = document.createElement("template"); const tempElement = document.createElement("template");
tempElement.innerHTML = operation.data; tempElement.innerHTML = operation.data;
const newTempElement = tempElement.content.querySelector(`[data-node-id="${newUpdateId}"]`); const newTempElement = tempElement.content.querySelector(`[data-node-id="${newUpdateId}"]`);
if (newTempElement) { if (newTempElement) {
updateElements.push(newUpdateElement) updateElements.push(newUpdateElement);
operation.data = newTempElement.outerHTML operation.data = newTempElement.outerHTML;
operation.id = newUpdateId operation.id = newUpdateId;
} }
} }
if (updateElements.length > 0) { if (updateElements.length > 0) {

View file

@ -13,7 +13,6 @@ import {replaceFileName, validateName} from "../editor/rename";
import {hideElements} from "../protyle/ui/hideElements"; import {hideElements} from "../protyle/ui/hideElements";
import {openMobileFileById} from "../mobile/editor"; import {openMobileFileById} from "../mobile/editor";
import {App} from "../index"; import {App} from "../index";
import {escapeHtml} from "./escape";
export const getNewFilePath = (useSavePath: boolean) => { export const getNewFilePath = (useSavePath: boolean) => {
let notebookId = ""; let notebookId = "";

View file

@ -62,7 +62,7 @@ class App {
break; break;
case "reloadEmbedBlock": case "reloadEmbedBlock":
reloadEmbedBlock(data.data); reloadEmbedBlock(data.data);
break break;
case "reloadPlugin": case "reloadPlugin":
reloadPlugin(this, data.data); reloadPlugin(this, data.data);
break; break;