Some doubts about join.views.dialogs

  1. I need to use join. views. toolbarButtons. create (shareButton, shareButton, ToolbarButtonLocation. EditorToolbar);
  2. After clicking, I encountered some issues when calling join.views.dialogs based on the conditions。
  3. If I use await hackmdDialogs. open (handle), no matter how many times I click, it will only show the following dialog box once after I click one of the buttons,It seems like there's no way to display it again
    Snipaste_2023-05-10_23-33-16
  4. If using a method of packaging, always prompt for duplicate creation, as shown below
  5. I am a beginner and cannot find a show method in the API dialogs panels to display or close it, or there are some issues with my code. I would like to consult everyone
async function hackmdDialogs(hmdApiClient, note, id) {
    let hackmdDialogs = joplin.views.dialogs
    let handle = await hackmdDialogs.create('hackmdDialog');
    await hackmdDialogs.setHtml(handle, '<div><p>Note already shared on HackMD, check footer part of your note for HackMD link,<br>or remove that part to share on HackMD again.</p></div>');
    await hackmdDialogs.setButtons(handle, [
        {
            id: 'update',
            title: 'update'
        },
        {
            id: 'delete',
            title: 'delete'
        },
        {
            id: 'cancel'
        },
    ]);
    id = (await hackmdDialogs.open(handle)).id;
    console.debug("after", id);
    await hackmdNote(hmdApiClient, note, id);
}

You need to create the dialog once, then keep a reference to it. Then use the hide/show methods to display it or not

I did not find the hide/show method in the API

I can't check because I'm on mobile and you only gave a screenshot, but I'm sure there's a way

Use joplin.views.dialogs.open

Flow for create and reuse

  1. Create, store reference to dialog as dialogRef
  2. setButtons, use dialogRef for handle
  3. setHtml, use dialogRef for handle
  4. open, use dialogRef for handle
  5. User interaction with Dialog
  6. To open again, start by 2 or 3
2 Likes