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

Bug: adjust hierarchy notes show nothing #330

Closed
HananoshikaYomaru opened this issue Feb 7, 2022 · 5 comments
Closed

Bug: adjust hierarchy notes show nothing #330

HananoshikaYomaru opened this issue Feb 7, 2022 · 5 comments
Labels
bug Something isn't working

Comments

@HananoshikaYomaru
Copy link
Contributor

I try out the adjust hierarchy note feature but it shows nothing.

I have no idea what the problem is. The index refresh without any problem. Should be some problem in the code.

CleanShot.2022-02-07.at.15.39.19.mp4

Version: 2.52.0

@HananoshikaYomaru HananoshikaYomaru added the bug Something isn't working label Feb 7, 2022
@HananoshikaYomaru
Copy link
Contributor Author

CleanShot 2022-02-07 at 17 03 29

in HierNoteModal.ts, when user put a folder in the hierarchy note setting, the length should not be 1, instead it should search the folder.

@HananoshikaYomaru
Copy link
Contributor Author

HananoshikaYomaru commented Feb 7, 2022

export let modal: ModifyHierItemModal;
  export let settings: BCSettings;
  export let hnItem: HNItem;
  export let file: TFile;
  export let rel: "up" | "same" | "down";

  interface HNItem {
    depth: number;
    line: string;
    lineNo: number;
  }
  let inputEl: HTMLInputElement;

  let newItem = modal.app.workspace.activeLeaf.view.file.basename

  const buildNewItem = (
    newItem: string,
    depth = hnItem.depth,
    preview = false
  ) =>
    `${" ".repeat(Math.round(depth / (preview ? 2 : 1)))}- ${
      preview ? newItem || "<Empty>" : makeWiki(newItem)
    }`;

default value of quick add HN should be file name.

@HananoshikaYomaru
Copy link
Contributor Author

in HierarchyNoteManipulator.ts this make more sense becasue the purpose of adjust hierarchy is to adjust the hierarchy note without going to the hierarchy note. Therefore the most common key (click and enter) should be map to command Add child instead of enter the note.

only shift + enter can enter the note.

 onChooseItem(item: HNItem, evt: MouseEvent | KeyboardEvent): void {
    if (evt instanceof KeyboardEvent && evt.key === "Delete") {
      this.deleteItem(item);
    }else if (evt instanceof KeyboardEvent && evt.key == "Enter" && evt.shiftKey ){
      const view = this.app.workspace.getActiveViewOfType(MarkdownView);
      const { editor } = view ?? {};
      if (!editor) return;
      //@ts-ignore
      view.leaf.openFile(this.file, { active: true, mode: "source" });
      editor.setCursor({ line: item.lineNo, ch: item.depth + 2 });
    } else if (evt instanceof KeyboardEvent  || evt instanceof MouseEvent) {
      let  rel : "up" | "down" | "same" ;
      if (evt instanceof MouseEvent && evt.type == "click") { 
        rel = "down"
      }
      if ( evt instanceof KeyboardEvent ) { 
        if ( evt.key === "Enter") rel = "down"
      }
      if ( evt instanceof KeyboardEvent && evt.shiftKey )   { 
        if (evt.key === "ArrowUp") rel = "up" 
        if ( evt.key === "ArrowDown" ) rel = "down" 
        if (evt.key === "ArrowRight") rel = "same" 
      }

      new ModifyHierItemModal(
        this.app,
        this.plugin,
        item,
        this.file,
        rel
      ).open();
      this.close();
    } 
  }

@HananoshikaYomaru
Copy link
Contributor Author

also using if clause is clearer than ? : operation.

@SkepticMystic
Copy link
Owner

This will be resolved by your PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants