添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

This seems to be the case. The whole dom tree seems to consist of an “app” node and nothing else. If I add elements via provideUI(), document.getElementById will always return ‘null’ for the ids of these elements. But I can see the element in the debug tools window … Is there a way to access the elements via typescript? Here is some (non working) code as example. Clicking on the link in the popup after /openproject should log a reference to the element, but does not:

import "@logseq/libs";
function main() {
  logseq.provideModel({
    openCalendar () {
      console.log("hi, calendar");
      console.log(document.getElementById('tryFindMe'));
      console.log(document.getElementById('app')?.childNodes);
  logseq.Editor.registerSlashCommand("openproject", async () => {
    logseq.provideUI({
      key: 'miktest',
      template: `
        <button
        id="tryFindMe"
        data-on-click="openCalendar">
        Go Calendar
        </button>
logseq.ready(main).catch(console.error);

Regards, Michael

Try ths:

      console.log(parent.document.getElementById('tryFindMe'));
      console.log(parent.document.getElementById('app')?.childNodes);

As an additional note, a plugin is sandboxed within <iframe>.