joplin-plugin-minimap 1.1.4 → 1.1.7
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 +1 -1
- package/publish/index.js +63 -6
- package/publish/manifest.json +1 -1
- package/publish/minimap-view.js +31 -0
- package/publish/plugin.jpl +0 -0
package/package.json
CHANGED
package/publish/index.js
CHANGED
|
@@ -7,8 +7,65 @@
|
|
|
7
7
|
// SettingItemType numeric values: Int=1, String=2, Bool=3 (no 'api' import in plain JS)
|
|
8
8
|
const TYPE_INT = 1;
|
|
9
9
|
|
|
10
|
+
// Settings-screen strings, resolved from the app locale at registration time
|
|
11
|
+
// (matching Joplin's own restart-on-language-switch behavior).
|
|
12
|
+
const SETTINGS_I18N = {
|
|
13
|
+
en_US: {
|
|
14
|
+
minHeadings: 'Minimum headings',
|
|
15
|
+
minHeadingsDesc: 'Hide the minimap when the note has fewer headings than this. Default: 2.',
|
|
16
|
+
panelWidth: 'Expanded panel width (px)',
|
|
17
|
+
panelWidthDesc: 'Maximum width of the hover-expanded table of contents. Default: 240.',
|
|
18
|
+
rightOffset: 'Distance from right edge (px)',
|
|
19
|
+
rightOffsetDesc: 'Gap between the minimap and the right edge of the viewer. Default: 6.',
|
|
20
|
+
},
|
|
21
|
+
zh_CN: {
|
|
22
|
+
minHeadings: '最少标题数',
|
|
23
|
+
minHeadingsDesc: '笔记标题数少于此值时隐藏小地图。默认 2。',
|
|
24
|
+
panelWidth: '展开面板宽度(px)',
|
|
25
|
+
panelWidthDesc: '悬停展开的目录面板最大宽度。默认 240。',
|
|
26
|
+
rightOffset: '距右边缘距离(px)',
|
|
27
|
+
rightOffsetDesc: '小地图与阅读器右边缘的间距。默认 6。',
|
|
28
|
+
},
|
|
29
|
+
zh_TW: {
|
|
30
|
+
minHeadings: '最少標題數',
|
|
31
|
+
minHeadingsDesc: '筆記標題數少於此值時隱藏小地圖。預設 2。',
|
|
32
|
+
panelWidth: '展開面板寬度(px)',
|
|
33
|
+
panelWidthDesc: '懸停展開的目錄面板最大寬度。預設 240。',
|
|
34
|
+
rightOffset: '距右邊緣距離(px)',
|
|
35
|
+
rightOffsetDesc: '小地圖與檢視器右邊緣的間距。預設 6。',
|
|
36
|
+
},
|
|
37
|
+
ru: {
|
|
38
|
+
minHeadings: 'Минимум заголовков',
|
|
39
|
+
minHeadingsDesc: 'Скрывать миникарту, если заголовков в заметке меньше. По умолчанию: 2.',
|
|
40
|
+
panelWidth: 'Ширина развёрнутой панели (px)',
|
|
41
|
+
panelWidthDesc: 'Максимальная ширина оглавления при наведении. По умолчанию: 240.',
|
|
42
|
+
rightOffset: 'Отступ от правого края (px)',
|
|
43
|
+
rightOffsetDesc: 'Зазор между миникартой и правым краем просмотра. По умолчанию: 6.',
|
|
44
|
+
},
|
|
45
|
+
ja_JP: {
|
|
46
|
+
minHeadings: '最小見出し数',
|
|
47
|
+
minHeadingsDesc: 'ノートの見出しがこの数より少ない場合はミニマップを隠します。既定値:2。',
|
|
48
|
+
panelWidth: '展開パネルの幅(px)',
|
|
49
|
+
panelWidthDesc: 'ホバーで展開する目次の最大幅。既定値:240。',
|
|
50
|
+
rightOffset: '右端からの距離(px)',
|
|
51
|
+
rightOffsetDesc: 'ミニマップとビューアー右端の間隔。既定値:6。',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
function settingsI18n(locale) {
|
|
56
|
+
if (SETTINGS_I18N[locale]) return SETTINGS_I18N[locale];
|
|
57
|
+
const lang = String(locale || '').split('_')[0];
|
|
58
|
+
if (lang === 'zh') return SETTINGS_I18N.zh_CN;
|
|
59
|
+
if (lang === 'ru') return SETTINGS_I18N.ru;
|
|
60
|
+
if (lang === 'ja') return SETTINGS_I18N.ja_JP;
|
|
61
|
+
return SETTINGS_I18N.en_US;
|
|
62
|
+
}
|
|
63
|
+
|
|
10
64
|
joplin.plugins.register({
|
|
11
65
|
onStart: async function () {
|
|
66
|
+
const locale = (await joplin.settings.globalValue('locale')) || 'en_US';
|
|
67
|
+
const t = settingsI18n(locale);
|
|
68
|
+
|
|
12
69
|
await joplin.settings.registerSection('minimap', {
|
|
13
70
|
label: 'Joplin Minimap',
|
|
14
71
|
iconName: 'fas fa-list',
|
|
@@ -22,8 +79,8 @@ joplin.plugins.register({
|
|
|
22
79
|
type: TYPE_INT,
|
|
23
80
|
section: 'minimap',
|
|
24
81
|
public: true,
|
|
25
|
-
label:
|
|
26
|
-
description:
|
|
82
|
+
label: t.minHeadings,
|
|
83
|
+
description: t.minHeadingsDesc,
|
|
27
84
|
},
|
|
28
85
|
'minimapPanelWidth': {
|
|
29
86
|
value: 240,
|
|
@@ -31,8 +88,8 @@ joplin.plugins.register({
|
|
|
31
88
|
type: TYPE_INT,
|
|
32
89
|
section: 'minimap',
|
|
33
90
|
public: true,
|
|
34
|
-
label:
|
|
35
|
-
description:
|
|
91
|
+
label: t.panelWidth,
|
|
92
|
+
description: t.panelWidthDesc,
|
|
36
93
|
},
|
|
37
94
|
'minimapRightOffset': {
|
|
38
95
|
value: 6,
|
|
@@ -40,8 +97,8 @@ joplin.plugins.register({
|
|
|
40
97
|
type: TYPE_INT,
|
|
41
98
|
section: 'minimap',
|
|
42
99
|
public: true,
|
|
43
|
-
label:
|
|
44
|
-
description:
|
|
100
|
+
label: t.rightOffset,
|
|
101
|
+
description: t.rightOffsetDesc,
|
|
45
102
|
},
|
|
46
103
|
});
|
|
47
104
|
} catch (error) {
|
package/publish/manifest.json
CHANGED
|
@@ -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.
|
|
5
|
+
"version": "1.1.7",
|
|
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",
|
package/publish/minimap-view.js
CHANGED
|
@@ -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) {
|
package/publish/plugin.jpl
CHANGED
|
Binary file
|