Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue #134, dom reference error. #137

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ build
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
!.yarn/versions

#System Files
.DS_Store
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"eslint.format.enable": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
// Disable vscode formatting for js,jsx,ts,tsx files
// to allow dbaeumer.vscode-eslint to format them
Expand Down
2 changes: 1 addition & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import obPlugin from "@aidenlx/esbuild-plugin-obsidian";
import obPlugin from "./scripts/obPlugin.mjs";
import { build, context } from "esbuild";
import { lessLoader } from "esbuild-plugin-less";

Expand Down
12 changes: 12 additions & 0 deletions log.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Removed following packages no longer available from developer on Github
"@aidenlx/esbuild-plugin-obsidian": "^0.1.8",
"@aidenlx/obsidian-plugin-bumper": "^0.1.12",

obPlugin module was recovered from https://www.npmjs.com/package/@aidenlx/esbuild-plugin-obsidian

Changes marked as following
//Note: Bug fix introduced in v1.5.4

Adjusted manifest name to "AidenLx's Folder Note Reworked" for testing along side active plugin


2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "alx-folder-note",
"name": "AidenLx's Folder Note",
"version": "0.16.5",
"version": "0.17.0",
"minAppVersion": "1.1.0",
"description": "Add description, summary and more info to folders with folder notes.",
"author": "AidenLx",
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
"author": "",
"license": "MIT",
"devDependencies": {
"@aidenlx/esbuild-plugin-obsidian": "^0.1.8",
"@aidenlx/folder-note-core": "^1.3.3",
"@aidenlx/obsidian-icon-shortcodes": "^0.9.0",
"@aidenlx/obsidian-plugin-bumper": "^0.1.12",
"@release-it/bumper": "^4.0.0",
"@release-it/conventional-changelog": "^5.1.0",
"@types/array.prototype.flat": "^1.2.1",
Expand Down
48 changes: 48 additions & 0 deletions scripts/obPlugin.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { promises } from "fs";
import { dirname, join } from "path";

const { copyFile, rename, writeFile } = promises;

/**
* @param {{ hotreload?: boolean, beta?:boolean }} config
* @returns {import("esbuild").Plugin}
*/
const obPlugin = (config = {}) => ({
name: "obsidian-plugin",
setup: (build) => {
const { hotreload = true, beta = false } = config;
build.onEnd(async () => {
const outDir = dirname(build.initialOptions.outfile ?? "main.js");
// fix default css output file name
const { outfile } = build.initialOptions;
try {
await rename(
outfile.replace(/\.js$/, ".css"),
outfile.replace(/main\.js$/, "styles.css"),
);
} catch (err) {
if (err.code !== "ENOENT") throw err;
}

// copy manifest.json to build dir
if (!beta) {
await copyFile("manifest.json", join(outDir, "manifest.json"));
} else {
await copyFile("manifest-beta.json", join(outDir, "manifest.json"));
}

// create .hotreload if it doesn't exist
if (hotreload) {
try {
await writeFile(join(outDir, ".hotreload"), "", { flag: "wx" });
} catch (err) {
if (err.code !== "EEXIST") throw err;
}
}

console.log("build finished");
});
},
});

export default obPlugin;
4 changes: 3 additions & 1 deletion src/click-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export const getClickHandler = (plugin: ALxFolderNote) => {
getFileItemInnerTitleEl(item).contains(evt.target as Node)
) ||
// ignore file being renamed
item.fileExplorer.fileBeingRenamed === item.file

//Note: Bug fix introduced in v1.5.4
item.fileExplorer?.fileBeingRenamed === item.file
)
return false;

Expand Down
8 changes: 6 additions & 2 deletions src/fe-handler/file-explorer.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
body:not(.alx-no-hide-note) .nav-file.alx-folder-note > .nav-file-title {
display: none;
body:not(.alx-no-hide-note) {
.nav-file.alx-folder-note {
> .nav-file-title {
display: none;
}
}
}

.nav-folder.alx-folder-with-note {
Expand Down
9 changes: 6 additions & 3 deletions src/fe-handler/folder-focus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,18 +49,21 @@ export default class FolderFocus extends FEHandler_Base {
? { folder: item, collapsedCache: item.collapsed }
: null;
// unfold folder if it's collapsed

//Note: Bug fix introduced in v1.5.4
if (item && item.collapsed) {
item.setCollapsed(false);
// @ts-ignore
this.plugin.app.nextFrame(() => {
// @ts-ignore
this.fileExplorer.dom.infinityScroll.computeSync();
this.fileExplorer.tree.infinityScroll.computeSync();
// @ts-ignore
this.fileExplorer.dom.infinityScroll.scrollIntoView(item);
this.fileExplorer.tree.infinityScroll.scrollIntoView(item);
});
}
this.fileExplorer.dom.navFileContainerEl.toggleClass(focusModeCls, !!item);
this.fileExplorer.navFileContainerEl.toggleClass(focusModeCls, !!item);
}

toggleFocusFolder(folder: TFolder | null) {
const folderItem = folder
? (this.getAfItem(folder.path) as FolderItem | null)
Expand Down
6 changes: 5 additions & 1 deletion src/fe-patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ const PatchFileExplorer = (plugin: ALxFolderNote) => {
const self = this;
next.call(self);
self.folderNoteUtils = getFileExplorerHandlers(plugin, self);
AddLongPressEvt(plugin, self.dom.navFileContainerEl);

// Note: Bug fix introduced in v1.5.4
// self.dom.navFileContainerEl
AddLongPressEvt(plugin, self.navFileContainerEl);

self.containerEl.on(
"auxclick",
".nav-folder",
Expand Down