diff --git a/README.md b/README.md index 00e6c52..8f9278a 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Obsidian Plugins Annotations is a plugin for [Obsidian](https://obsidian.md) tha - Annotations are saved persistently and can be edited at any time. - Annotations are displayed directly below the plugin information. - Detailed instructions how to edit the annotations are provided in the _setting pane_ of the plugin. +- Possible to lock the annotations with the lock button next to the title "Installed plugins". This feature is useful in combination with the toggle hiding the annotations fields where there is no user annotation yet. ## Installation diff --git a/docs/images/screenshot.jpg b/docs/images/screenshot.jpg index ab36071..2876df7 100644 Binary files a/docs/images/screenshot.jpg and b/docs/images/screenshot.jpg differ diff --git a/manifest.json b/manifest.json index 824c22b..cfa30c6 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "plugins-annotations", "name": "Plugins Annotations", - "version": "1.3.0", + "version": "1.4.0", "minAppVersion": "1.5.0", "description": "Allows adding personal comments to each installed plugin.", "author": "Andrea Alberti", diff --git a/src/main.ts b/src/main.ts index beb01a3..7af5e39 100644 --- a/src/main.ts +++ b/src/main.ts @@ -235,7 +235,7 @@ export default class PluginsAnnotations extends Plugin { } } - async render_annotation(annotation_div: HTMLDivElement, t:AnnotationType,c:string) { + async render_annotation(annotation_div: HTMLDivElement, t:AnnotationType, c:string) { switch(t) { case AnnotationType.text: { const p = document.createElement('p'); @@ -282,7 +282,8 @@ export default class PluginsAnnotations extends Plugin { annotation_div.contentEditable = this.settings.editable ? 'true' : 'false'; - const placeholder = `Add your personal comment about '${pluginName}' here...`; + const placeholder = (this.settings.label_placeholder).replace(/\$\{plugin_name\}/g, pluginName); + let isPlaceholder = this.settings.annotations[pluginId] ? false : true; let annotation_text = ((this.settings.annotations[pluginId] && this.settings.annotations[pluginId].anno) || placeholder).trim(); @@ -299,6 +300,9 @@ export default class PluginsAnnotations extends Plugin { ({type,content} = this.parse_annotation(annotation_div,annotation_text)); // Initial render + if(isPlaceholder) { + type = AnnotationType.html; + } this.render_annotation(annotation_div,type,content); let clickedLink = false; @@ -345,7 +349,7 @@ export default class PluginsAnnotations extends Plugin { const handleBlur = (event:FocusEvent) => { if(!this.settings.editable) { return; } if (isPlaceholder || annotation_div.innerText.trim() === '') { - annotation_div.innerText = placeholder; + annotation_div.innerHTML = placeholder; annotation_div.classList.add('plugin-comment-placeholder'); if (this.settings.hide_placeholders) { annotation_container.classList.add('plugin-comment-placeholder'); @@ -404,7 +408,7 @@ export default class PluginsAnnotations extends Plugin { const svg_unlocked = '\ \ - \ + \ '; const svg_locked ='\ @@ -698,6 +702,20 @@ class PluginsAnnotationsSettingTab extends PluginSettingTab { })}); } + new Setting(containerEl) + .setName('Placeholder label:') + .setDesc(createFragment((frag) => { + frag.appendText('Choose the label appearing where no user annotation is provied yet. Use '); + frag.createEl('em').appendText('${plugin_name}'); + frag.appendText(' to refer to the plugin name.')})) + .addText(text => { + text.setPlaceholder('Annotation label'); + text.setValue(this.plugin.settings.label_placeholder); + text.onChange(async (value: string) => { + this.plugin.settings.label_placeholder = value; + this.plugin.debouncedSaveAnnotations(); + })}); + new Setting(containerEl) .setName('Hide empty annotations:') .setDesc(createFragment((frag) => { diff --git a/src/types.ts b/src/types.ts index 12dc552..e3bad66 100644 --- a/src/types.ts +++ b/src/types.ts @@ -18,6 +18,7 @@ export interface PluginsAnnotationsSettings { delete_placeholder_string_on_insertion: boolean; label_mobile: string; label_desktop: string; + label_placeholder: string; editable: boolean; automatic_remove: boolean; } diff --git a/styles/styles.css b/styles/styles.css index d90a76b..5addc2c 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -9,7 +9,6 @@ .plugin-comment-annotation.plugin-comment-placeholder { color: #CCCCCC; /* Standard placeholder color */ - font-style: italic; } .plugin-comment.plugin-comment-hidden, @@ -25,8 +24,9 @@ margin-bottom: 0; } -.plugin-comment-annotation::after { - content: "" !important; +/* Mobile specific styles */ +.is-mobile .plugin-comment-annotation::after { + content: "" !important; } .plugin-comment-annotation {