// https://indy0.peergos.me/app/wiki/assets/pad/index.html?t=25~daily.note-2026-04

function xtra() {

    let editableDiv = document.getElementById('rte-editbox-0');

    editableDiv.addEventListener('keydown', function (event) {
      debugger
      if (event.shiftKey && event.keyCode === 9) {
            event.preventDefault();
           
           $('#outdent0').click()
        return
        }
        if (event.keyCode === 9) {
            event.preventDefault();
           
           $('#indent0').click()
        }

    })



    editableDiv.addEventListener('keyup', function () {
        // Get the current node (e.g., the <p> tag where the cursor is)
        const selection = window.getSelection();
        if (!selection.rangeCount) return;
        const node = selection.focusNode?.parentNode;

        // Check if the text starts with or contains the target string
        const text = node.innerText;
        if (text.startsWith('- ')) {
            console.log("Target string found!");
            node.innerText = ""
            // Call your function here
            document.execCommand("insertunorderedlist")
            // myCustomFunction();
        }
    });

}


window.xtra = xtra