🎨 Clean code

This commit is contained in:
Daniel 2024-04-23 13:29:32 +08:00
parent 7da3dec244
commit e082ce983d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
6 changed files with 17 additions and 18 deletions

View file

@ -65,7 +65,6 @@ import {workspaceMenu} from "../../menus/workspace";
import {resize} from "../../protyle/util/resize";
import {Search} from "../../search";
import {Custom} from "../../layout/dock/Custom";
import {Protyle} from "../../protyle";
import {transaction} from "../../protyle/wysiwyg/transaction";
import {quickMakeCard} from "../../card/makeCard";
import {copyPNG} from "../../menus/util";
@ -221,7 +220,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
protyle = item.protyle;
return true;
}
})
});
}
}
if (!protyle) {

View file

@ -468,7 +468,7 @@ export class Backlink extends Model {
}
this.editors.forEach(item => {
item.destroy();
})
});
const element = this.element.querySelector('.block__icon[data-type="refresh"] svg');
element.classList.add("fn__rotate");
fetchPost("/api/ref/refreshBacklink", {

View file

@ -25,8 +25,8 @@ export const getAllEditor = () => {
});
models.custom.forEach(item => {
item.editors?.forEach(eItem => {
editors.push(eItem)
})
editors.push(eItem);
});
});
models.backlink.forEach(item => {
item.editors.forEach(editorItem => {

View file

@ -4,25 +4,25 @@ import {transaction} from "../../wysiwyg/transaction";
import {openEditorTab} from "../../../menus/util";
import {copySubMenu} from "../../../menus/commonMenuItem";
import {
addDragFill, genCellValueByElement,
addDragFill,
genCellValueByElement,
getCellText,
getTypeByCellElement,
popTextCell,
renderCell,
renderCellAttr, updateCellsValue,
renderCellAttr,
updateCellsValue,
updateHeaderCell
} from "./cell";
import {getColIconByType, showColMenu} from "./col";
import {deleteRow, insertRows, setPageSize, updateHeader} from "./row";
import {addCol, getColIconByType, showColMenu} from "./col";
import {deleteRow, insertRows, selectRow, setPageSize, updateHeader} from "./row";
import {emitOpenMenu} from "../../../plugin/EventBus";
import {addCol} from "./col";
import {openMenuPanel} from "./openMenuPanel";
import {hintRef} from "../../hint/extend";
import {focusByRange} from "../../util/selection";
import {showMessage} from "../../../dialog/message";
import {previewImage} from "../../preview/image";
import {unicode2Emoji} from "../../../emoji";
import {selectRow} from "./row";
import * as dayjs from "dayjs";
import {openCalcMenu} from "./calc";
import {avRender} from "./render";
@ -283,7 +283,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
const srcs: IOperationSrcs[] = [];
const sourceIds: string[] = [];
rowElements.forEach(item => {
const rowId = item.getAttribute("data-id")
const rowId = item.getAttribute("data-id");
const blockValue = genCellValueByElement("block", item.querySelector(".av__cell[data-block-id]"));
srcs.push({
content: blockValue.block.content,
@ -291,7 +291,7 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi
isDetached: blockValue.isDetached,
});
sourceIds.push(rowId);
})
});
const avID = listItemElement.dataset.avId;
transaction(protyle, [{
action: "insertAttrViewBlock",

View file

@ -191,11 +191,11 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex)}
viewData = item;
}
});
let avBackground = '--av-background:var(--b3-theme-background)'
let avBackground = "--av-background:var(--b3-theme-background)";
if (e.style.backgroundColor) {
avBackground = '--av-background:' + e.style.backgroundColor
avBackground = "--av-background:" + e.style.backgroundColor;
} else if (hasClosestByAttribute(e, "data-type", "NodeBlockQueryEmbed")) {
avBackground = '--av-background:var(--b3-theme-surface)'
avBackground = "--av-background:var(--b3-theme-surface)";
}
e.firstElementChild.outerHTML = `<div class="av__container" style="${avBackground}">
<div class="av__header">

View file

@ -808,12 +808,12 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
item.querySelectorAll('[data-type="search-mark"]').forEach(markItem => {
markItem.outerHTML = markItem.innerHTML;
});
const id = item.getAttribute("data-node-id")
const id = item.getAttribute("data-node-id");
sourceIds.push(id);
srcs.push({
id,
isDetached: false,
})
});
});
hideElements(["gutter"], protyle);