Benature / obsidian-metadata-hider

Hide metadata property if its value is empty
MIT License
12 stars 0 forks source link

Add event listener to "add property" button: only then show the last property #2

Closed Benature closed 6 months ago

Benature commented 6 months ago

From getEventListeners(document.getElementsByClassName("metadata-add-button")[2]) know the class is listened by click and keydown.

  1. add an event listener to .metadata-add-button: add CSS to show the last property
  2. add an event listener to the property (metadata) table (.metadata-container), when it is not focused:
    1. remove the CSS that shows the last property.
    2. remove the listener itself

sample code for referenece

// 定义点击事件处理函数
function clickHandler() {
    console.log('Button clicked!');

    // 在事件处理完成后立即移除监听器
    document.getElementById('myButton').removeEventListener('click', clickHandler);
}

// 添加一次性的点击事件监听器
document.getElementById('myButton').addEventListener('click', clickHandler);
Benature commented 6 months ago

Rather than only showing the last property, I would like to show all properties when the table is focused, which is convenient to input to empty properties. In the past, I need to switch to source mode to fill out empty properties.

This feature is supported in v0.1.0