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

View file

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

View file

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

View file

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

View file

@ -191,11 +191,11 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, rowIndex)}
viewData = item; viewData = item;
} }
}); });
let avBackground = '--av-background:var(--b3-theme-background)' let avBackground = "--av-background:var(--b3-theme-background)";
if (e.style.backgroundColor) { if (e.style.backgroundColor) {
avBackground = '--av-background:' + e.style.backgroundColor avBackground = "--av-background:" + e.style.backgroundColor;
} else if (hasClosestByAttribute(e, "data-type", "NodeBlockQueryEmbed")) { } 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}"> e.firstElementChild.outerHTML = `<div class="av__container" style="${avBackground}">
<div class="av__header"> <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 => { item.querySelectorAll('[data-type="search-mark"]').forEach(markItem => {
markItem.outerHTML = markItem.innerHTML; markItem.outerHTML = markItem.innerHTML;
}); });
const id = item.getAttribute("data-node-id") const id = item.getAttribute("data-node-id");
sourceIds.push(id); sourceIds.push(id);
srcs.push({ srcs.push({
id, id,
isDetached: false, isDetached: false,
}) });
}); });
hideElements(["gutter"], protyle); hideElements(["gutter"], protyle);