Skip to content

Commit

Permalink
🎨 #9419
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Oct 13, 2023
1 parent a11ea9c commit f95084e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/src/protyle/render/av/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {openAsset} from "../../../editor/util";
import {getSearch, isMobile} from "../../../util/functions";
import {unicode2Emoji} from "../../../emoji";
import {selectRow} from "./row";
import * as dayjs from "dayjs";

export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLElement }) => {
const blockElement = hasClosestBlock(event.target);
Expand Down Expand Up @@ -330,19 +331,30 @@ export const avContextmenu = (protyle: IProtyle, rowElement: HTMLElement, positi

export const updateAVName = (protyle: IProtyle, blockElement: Element) => {
const avId = blockElement.getAttribute("data-av-id");
const id = blockElement.getAttribute("data-node-id");
const nameElement = blockElement.querySelector(".av__title") as HTMLElement;
const newData = nameElement.textContent.trim();
if (newData === nameElement.dataset.title.trim()) {
return;
}
const newUpdated = dayjs().format("YYYYMMDDHHmmss")
blockElement.setAttribute("updated", newUpdated);
transaction(protyle, [{
action: "setAttrViewName",
id: avId,
data: newData,
}, {
action: "doUpdateUpdated",
id,
data: newUpdated,
}], [{
action: "setAttrViewName",
id: avId,
name: nameElement.dataset.title,
}, {
action: "doUpdateUpdated",
id,
data: blockElement.getAttribute("updated")
}]);
nameElement.dataset.title = newData;
};
Expand Down
1 change: 1 addition & 0 deletions app/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type TOperation =
| "removeAttrViewColOption"
| "updateAttrViewColOption"
| "setAttrViewName"
| "doUpdateUpdated"
| "setAttrViewColIcon"
| "setAttrViewFilters"
| "setAttrViewSorts"
Expand Down

0 comments on commit f95084e

Please sign in to comment.