joplin-plugin-minimap 1.1.4 → 1.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "joplin-plugin-minimap",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "A hover-to-expand table of contents minimap for the Joplin note viewer",
5
5
  "author": "lim0513",
6
6
  "homepage": "https://github.com/lim0513/joplin-minimap",
@@ -2,7 +2,7 @@
2
2
  "manifest_version": 1,
3
3
  "id": "com.github.joplin-minimap",
4
4
  "app_min_version": "2.8",
5
- "version": "1.1.4",
5
+ "version": "1.1.6",
6
6
  "name": "Joplin Minimap",
7
7
  "description": "A hover-to-expand table of contents minimap for the note viewer. Shows heading tick marks on the right edge; hover to expand into a full ToC, click to jump.",
8
8
  "author": "lim0513",
@@ -19,6 +19,22 @@
19
19
  }).catch(function () { /* keep defaults (e.g. print/export context) */ });
20
20
  }
21
21
 
22
+ // NEVER run inside an editable context (the Rich Text editor renders
23
+ // notes through the same pipeline and would execute this asset). If the
24
+ // nav lands in the RTE document, Joplin's HTML->markdown round-trip
25
+ // SERIALIZES it into the note body on save - the heading list becomes
26
+ // real note content and syncs to every device. This was the true root
27
+ // cause of the "outline below the document" reports.
28
+ function isEditableContext() {
29
+ var b = document.body;
30
+ if (!b) return false;
31
+ if (b.isContentEditable) return true;
32
+ if (b.id === 'tinymce') return true;
33
+ if (b.classList && b.classList.contains('mce-content-body')) return true;
34
+ return false;
35
+ }
36
+ if (isEditableContext()) return;
37
+
22
38
  // Only ever install one instance of the watcher per webview session.
23
39
  if (window.__jpMinimapInstalled) return;
24
40
  window.__jpMinimapInstalled = true;
@@ -84,6 +100,11 @@
84
100
 
85
101
  function build() {
86
102
  if (cleanup) { cleanup(); cleanup = null; }
103
+ if (isEditableContext()) {
104
+ var stale = document.getElementById('jp-minimap');
105
+ if (stale) stale.remove();
106
+ return;
107
+ }
87
108
  ensureStyle();
88
109
 
89
110
  var old = document.getElementById('jp-minimap');
@@ -208,6 +229,16 @@
208
229
  // Joplin fires this after each note render/update.
209
230
  document.addEventListener('joplin-noteDidUpdate', scheduleBuild);
210
231
 
232
+ // Joplin's asset cleanup can remove our <style> from <head> AFTER the
233
+ // last body mutation - nothing rebuilds, and the nav sits unstyled in
234
+ // the page (the "outline below the document" bug, second incarnation:
235
+ // v1.1.4 only re-checked the style during rebuilds). Watch the head
236
+ // and re-inject immediately.
237
+ var headObserver = new MutationObserver(function () {
238
+ if (!document.getElementById('jp-minimap-style')) ensureStyle();
239
+ });
240
+ if (document.head) headObserver.observe(document.head, { childList: true });
241
+
211
242
  // Fallback: watch for the rendered content being swapped out
212
243
  // (note switch replaces the DOM without re-running this script).
213
244
  var mo = new MutationObserver(function (mutations) {
Binary file