mirror of
https://github.com/makeplane/plane.git
synced 2026-02-24 20:20:49 +01:00
fix: file plugin object reference
This commit is contained in:
@@ -7,9 +7,11 @@ import { TFileHandler } from "@/types";
|
||||
// local imports
|
||||
import { TFileNode } from "./types";
|
||||
|
||||
const DELETE_PLUGIN_KEY = new PluginKey("delete-utility");
|
||||
|
||||
export const TrackFileDeletionPlugin = (editor: Editor, deleteHandler: TFileHandler["delete"]): Plugin =>
|
||||
new Plugin({
|
||||
key: new PluginKey("delete-utility"),
|
||||
key: DELETE_PLUGIN_KEY,
|
||||
appendTransaction: (transactions: readonly Transaction[], oldState: EditorState, newState: EditorState) => {
|
||||
const newFileSources: {
|
||||
[nodeType: string]: Set<string> | undefined;
|
||||
@@ -20,10 +22,10 @@ export const TrackFileDeletionPlugin = (editor: Editor, deleteHandler: TFileHand
|
||||
const nodeType = node.type.name;
|
||||
const nodeFileSetDetails = NODE_FILE_MAP[nodeType];
|
||||
if (nodeFileSetDetails) {
|
||||
if (newFileSources.nodeType) {
|
||||
newFileSources.nodeType.add(node.attrs.src);
|
||||
if (newFileSources[nodeType]) {
|
||||
newFileSources[nodeType].add(node.attrs.src);
|
||||
} else {
|
||||
newFileSources.nodeType = new Set([node.attrs.src]);
|
||||
newFileSources[nodeType] = new Set([node.attrs.src]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,9 +9,11 @@ import { TFileHandler } from "@/types";
|
||||
// local imports
|
||||
import { TFileNode } from "./types";
|
||||
|
||||
const RESTORE_PLUGIN_KEY = new PluginKey("restore-utility");
|
||||
|
||||
export const TrackFileRestorationPlugin = (editor: Editor, restoreHandler: TFileHandler["restore"]): Plugin =>
|
||||
new Plugin({
|
||||
key: new PluginKey("restore-utility"),
|
||||
key: RESTORE_PLUGIN_KEY,
|
||||
appendTransaction: (transactions: readonly Transaction[], oldState: EditorState, newState: EditorState) => {
|
||||
if (!transactions.some((tr) => tr.docChanged)) return null;
|
||||
|
||||
@@ -22,10 +24,10 @@ export const TrackFileRestorationPlugin = (editor: Editor, restoreHandler: TFile
|
||||
const nodeType = node.type.name;
|
||||
const nodeFileSetDetails = NODE_FILE_MAP[nodeType];
|
||||
if (nodeFileSetDetails) {
|
||||
if (oldFileSources.nodeType) {
|
||||
oldFileSources.nodeType.add(node.attrs.src);
|
||||
if (oldFileSources[nodeType]) {
|
||||
oldFileSources[nodeType].add(node.attrs.src);
|
||||
} else {
|
||||
oldFileSources.nodeType = new Set([node.attrs.src]);
|
||||
oldFileSources[nodeType] = new Set([node.attrs.src]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user