joplin-plugin-minimap 1.1.10 → 1.2.0
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/README.md +3 -0
- package/package.json +1 -1
- package/publish/index.js +24 -0
- package/publish/manifest.json +1 -1
- package/publish/minimap-view.js +141 -10
- package/publish/plugin.jpl +0 -0
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@ A hover-to-expand table of contents minimap for the [Joplin](https://joplinapp.o
|
|
|
8
8
|
|
|
9
9
|
- **Tick Bar Minimap** — Each heading is shown as a small horizontal bar on the right edge of the note viewer; bar length reflects the heading level (H1 longest)
|
|
10
10
|
- **Hover to Expand** — Move the mouse over the bars and they expand into a full table of contents overlay, indented by level, with long titles ellipsized
|
|
11
|
+
- **Depth Stepper** — `+` / `-` buttons at the top of the expanded panel raise or lower how deep the outline goes, so a long nested note collapses to its top-level structure in one click
|
|
12
|
+
- **Heading Tiers** — Top-level headings render larger and heavier than nested ones, so the shape of the document is readable at a glance
|
|
11
13
|
- **Click to Jump** — Click any entry to smooth-scroll to that heading
|
|
12
14
|
- **Reading Position** — The section currently in view is highlighted automatically
|
|
13
15
|
- **Live Rebuild** — Rebuilds itself when you switch notes or edit content (listens to `joplin-noteDidUpdate` with a MutationObserver fallback)
|
|
@@ -52,6 +54,7 @@ Configurable in **Tools → Options → Joplin Minimap**:
|
|
|
52
54
|
- **Minimum headings** — hide the minimap when the note has fewer headings than this (default 2)
|
|
53
55
|
- **Expanded panel width (px)** — maximum width of the hover-expanded table of contents (default 240)
|
|
54
56
|
- **Minimap side** — which edge of the viewer the minimap docks to, right or left (default right)
|
|
57
|
+
- **Default depth** — deepest heading level shown when a note opens; the `+`/`-` buttons change it on the fly (default 6, every level)
|
|
55
58
|
- **Edge distance (px)** — gap between the minimap and the viewer edge it sits on (default 6)
|
|
56
59
|
|
|
57
60
|
Changed settings apply on the next render (switch notes or edit the note).
|
package/package.json
CHANGED
package/publish/index.js
CHANGED
|
@@ -23,6 +23,8 @@ const SETTINGS_I18N = {
|
|
|
23
23
|
sideDesc: 'Which edge of the viewer the minimap sits on. Default: right.',
|
|
24
24
|
sideRight: 'Right',
|
|
25
25
|
sideLeft: 'Left',
|
|
26
|
+
maxLevel: 'Default depth',
|
|
27
|
+
maxLevelDesc: 'Deepest heading level shown when a note opens. The +/- buttons at the top of the expanded panel change it on the fly. Default: 6 (every level).',
|
|
26
28
|
showTodos: 'Show to-do markers',
|
|
27
29
|
showTodosDesc: 'Show a small red dot before a section\'s tick bar when it contains open to-dos. Default: on.',
|
|
28
30
|
},
|
|
@@ -37,6 +39,8 @@ const SETTINGS_I18N = {
|
|
|
37
39
|
sideDesc: '小地图停靠在阅读器的哪一侧边缘。默认靠右。',
|
|
38
40
|
sideRight: '右侧',
|
|
39
41
|
sideLeft: '左侧',
|
|
42
|
+
maxLevel: '默认层级深度',
|
|
43
|
+
maxLevelDesc: '打开笔记时显示到第几级标题。展开面板顶部的 +/- 按钮可随时调整。默认 6(全部层级)。',
|
|
40
44
|
showTodos: '显示待办标记',
|
|
41
45
|
showTodosDesc: '当章节内含未完成待办时,在该章节横线前显示一个小红点提醒。默认开启。',
|
|
42
46
|
},
|
|
@@ -51,6 +55,8 @@ const SETTINGS_I18N = {
|
|
|
51
55
|
sideDesc: '小地圖停靠在檢視器的哪一側邊緣。預設靠右。',
|
|
52
56
|
sideRight: '右側',
|
|
53
57
|
sideLeft: '左側',
|
|
58
|
+
maxLevel: '預設層級深度',
|
|
59
|
+
maxLevelDesc: '開啟筆記時顯示到第幾級標題。展開面板頂部的 +/- 按鈕可隨時調整。預設 6(全部層級)。',
|
|
54
60
|
showTodos: '顯示待辦標記',
|
|
55
61
|
showTodosDesc: '當章節內含未完成待辦時,在該章節橫線前顯示一個小紅點提醒。預設開啟。',
|
|
56
62
|
},
|
|
@@ -65,6 +71,8 @@ const SETTINGS_I18N = {
|
|
|
65
71
|
sideDesc: 'У какого края области просмотра располагается миникарта. По умолчанию: справа.',
|
|
66
72
|
sideRight: 'Справа',
|
|
67
73
|
sideLeft: 'Слева',
|
|
74
|
+
maxLevel: 'Глубина по умолчанию',
|
|
75
|
+
maxLevelDesc: 'До какого уровня заголовков показывать при открытии заметки. Кнопки +/- вверху развёрнутой панели меняют её на лету. По умолчанию: 6 (все уровни).',
|
|
68
76
|
showTodos: 'Показывать метки задач',
|
|
69
77
|
showTodosDesc: 'Показывать маленькую красную точку перед линией раздела, если в нём есть открытые задачи. По умолчанию: вкл.',
|
|
70
78
|
},
|
|
@@ -79,6 +87,8 @@ const SETTINGS_I18N = {
|
|
|
79
87
|
sideDesc: 'ミニマップをビューアーのどちら側の端に表示するか。既定値:右。',
|
|
80
88
|
sideRight: '右',
|
|
81
89
|
sideLeft: '左',
|
|
90
|
+
maxLevel: '既定の階層の深さ',
|
|
91
|
+
maxLevelDesc: 'ノートを開いたときに表示する見出しの深さ。展開パネル上部の +/- ボタンでいつでも変更できます。既定値:6(すべての階層)。',
|
|
82
92
|
showTodos: 'ToDoマーカーを表示',
|
|
83
93
|
showTodosDesc: '未完了のToDoを含むセクションの線の前に小さな赤い点を表示します。既定値:オン。',
|
|
84
94
|
},
|
|
@@ -147,6 +157,19 @@ joplin.plugins.register({
|
|
|
147
157
|
label: t.side,
|
|
148
158
|
description: t.sideDesc,
|
|
149
159
|
},
|
|
160
|
+
// Only the STARTING depth. The stepper in the panel overrides it for
|
|
161
|
+
// the rest of the session without writing back here - a setting that
|
|
162
|
+
// rewrote itself on every click would fight the user's own default.
|
|
163
|
+
'minimapMaxLevel': {
|
|
164
|
+
value: 6,
|
|
165
|
+
minimum: 1,
|
|
166
|
+
maximum: 6,
|
|
167
|
+
type: TYPE_INT,
|
|
168
|
+
section: 'minimap',
|
|
169
|
+
public: true,
|
|
170
|
+
label: t.maxLevel,
|
|
171
|
+
description: t.maxLevelDesc,
|
|
172
|
+
},
|
|
150
173
|
'minimapShowTodos': {
|
|
151
174
|
value: true,
|
|
152
175
|
type: TYPE_BOOL,
|
|
@@ -173,6 +196,7 @@ joplin.plugins.register({
|
|
|
173
196
|
panelWidth: await joplin.settings.value('minimapPanelWidth'),
|
|
174
197
|
rightOffset: await joplin.settings.value('minimapRightOffset'),
|
|
175
198
|
side: await joplin.settings.value('minimapSide'),
|
|
199
|
+
maxLevel: await joplin.settings.value('minimapMaxLevel'),
|
|
176
200
|
showTodos: await joplin.settings.value('minimapShowTodos'),
|
|
177
201
|
};
|
|
178
202
|
}
|
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.
|
|
5
|
+
"version": "1.2.0",
|
|
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
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
// Defaults; overridden from Joplin's plugin settings (Tools > Options > Minimap)
|
|
10
10
|
// when webviewApi is available in this webview.
|
|
11
|
-
var settings = { minHeadings: 2, panelWidth: 240, rightOffset: 6, side: 'right', showTodos: true };
|
|
11
|
+
var settings = { minHeadings: 2, panelWidth: 240, rightOffset: 6, side: 'right', maxLevel: 6, showTodos: true };
|
|
12
12
|
|
|
13
13
|
function loadSettings() {
|
|
14
14
|
if (typeof webviewApi === 'undefined' || !webviewApi.postMessage) {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
// then renders UNSTYLED as flow content below the note (looks like a
|
|
48
48
|
// duplicated outline under the document). Keeping the CSS inline and
|
|
49
49
|
// re-injecting guarantees the nav and its styling live and die together.
|
|
50
|
-
var MINIMAP_CSS = "/* Joplin Minimap \u2014 collapsed tick bars, hover-expanded ToC panel.\n * Colors use currentColor / rgba so it follows both light and dark themes.\n */\n\n#jp-minimap {\n\tuser-select: none;\n\t-webkit-user-select: none;\n\tcaret-color: transparent;\n\tcursor: default;\n\tposition: fixed;\n\ttop: 50%;\n\tright: 6px;\n\ttransform: translateY(-50%);\n\tz-index: 9999;\n\tfont-size: 12.5px;\n\tline-height: 1.35;\n\tcolor: inherit;\n\t/* Collapsed geometry is direction-independent: the tick bars always\n\t * hug the docked edge, whichever side that is, even in an RTL note. Per-item direction applies\n\t * to the expanded panel only (see the dir=rtl rule below). */\n\tdirection: ltr;\n}\n\n.jp-mm-list {\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: flex-end;\n\tpadding: 8px 6px;\n\tmax-height: 84vh;\n\toverflow: hidden;\n\tborder-radius: 10px;\n\ttransition: background 0.15s ease, box-shadow 0.15s ease;\n}\n\n.jp-mm-item {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: flex-end;\n\tpadding: 3px 4px;\n\tborder-radius: 6px;\n\ttext-decoration: none;\n\tcolor: inherit;\n\topacity: 0.5;\n\tcursor: pointer;\n\toutline: none;\n\tdirection: ltr;\n}\n\n/* ---- collapsed state: tick bars, width by heading level ---- */\n\n.jp-mm-bar {\n\tdisplay: block;\n\theight: 2px;\n\tborder-radius: 1px;\n\tbackground: currentColor;\n}\n\n.jp-mm-l1 .jp-mm-bar { width: 18px; }\n.jp-mm-l2 .jp-mm-bar { width: 13px; }\n.jp-mm-l3 .jp-mm-bar { width: 9px; }\n.jp-mm-l4 .jp-mm-bar { width: 7px; }\n.jp-mm-l5 .jp-mm-bar { width: 5px; }\n.jp-mm-l6 .jp-mm-bar { width: 5px; }\n\n.jp-mm-label { display: none; }\n\n/* ---- docked on the left edge ---- */\n\n/* Mirror the collapsed alignment so the tick bars hug the left border.\n * direction is pinned to ltr above, so flex-start is unambiguously the left\n * side whatever language the note is in. Placed BEFORE the :hover rules on\n * purpose: they carry the same specificity, so source order decides. */\n#jp-minimap.jp-mm-left .jp-mm-list { align-items: flex-start; }\n#jp-minimap.jp-mm-left .jp-mm-item { justify-content: flex-start; }\n\n/* The to-do dot mirrors too: docked right it hangs left of the tick bar,\n * docked left it must hang RIGHT of it - otherwise a dotted row pushes its\n * bar 9px inward (4px dot + 5px gap) and the flush bar column goes ragged.\n * order= reorders the flex row without touching the DOM, so the expanded\n * panel can put the dot back in front of the label. */\n#jp-minimap.jp-mm-left .jp-mm-dot {\n\torder: 1;\n\tmargin-inline-start: 5px;\n\tmargin-inline-end: 0;\n}\n\n/* ---- expanded state (hover) ---- */\n\n#jp-minimap:hover .jp-mm-list {\n\talign-items: stretch;\n\toverflow-y: auto;\n\toverscroll-behavior: contain;\n\tbackground: rgba(127, 127, 127, 0.16);\n\tbackdrop-filter: blur(10px);\n\t-webkit-backdrop-filter: blur(10px);\n\tbox-shadow: 0 6px 28px rgba(0, 0, 0, 0.28);\n}\n\n#jp-minimap:hover .jp-mm-bar { display: none; }\n\n#jp-minimap:hover .jp-mm-item { justify-content: flex-start; }\n\n#jp-minimap:hover .jp-mm-label {\n\tdisplay: block;\n\tmax-width: var(--jp-mm-width, 240px);\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\ttext-align: start;\n}\n\n/* RTL headings (Persian/Arabic/Hebrew) read right-to-left in the expanded\n * panel: justify-content, padding-inline-start and text-align:start all flip\n * with the row direction, so the label hugs the right edge and nested levels\n * indent inward from the right. build() sets dir per row (first strong char). */\n#jp-minimap:hover .jp-mm-item[dir=\"rtl\"] { direction: rtl; }\n\n/* indent by heading level when expanded (logical: left in LTR, right in RTL) */\n#jp-minimap:hover .jp-mm-l2 { padding-inline-start: 16px; }\n#jp-minimap:hover .jp-mm-l3 { padding-inline-start: 28px; }\n#jp-minimap:hover .jp-mm-l4 { padding-inline-start: 40px; }\n#jp-minimap:hover .jp-mm-l5 { padding-inline-start: 52px; }\n#jp-minimap:hover .jp-mm-l6 { padding-inline-start: 52px; }\n\n/* Expanded, the dot reads as a marker BEFORE the title on either edge. */\n#jp-minimap.jp-mm-left:hover .jp-mm-dot {\n\torder: 0;\n\tmargin-inline-start: 0;\n\tmargin-inline-end: 5px;\n}\n\n/* ---- shared states ---- */\n\n.jp-mm-item:hover {\n\topacity: 1;\n\tbackground: rgba(127, 127, 127, 0.22);\n}\n\n.jp-mm-active { opacity: 1; }\n\n#jp-minimap:hover .jp-mm-active {\n\tbackground: rgba(127, 127, 127, 0.18);\n}\n\n/* No scrollbar in the expanded panel: the wheel handler owns scrolling,\n * and a visible scrollbar at the panel edge invites overlay-scrollbar\n * style hover/click interference. */\n.jp-mm-list::-webkit-scrollbar { display: none; }\n.jp-mm-list { scrollbar-width: none; }\n\n/* ---- open-to-do section dot: one muted red dot before the tick bar of\n * any section that contains at least one unchecked checkbox ---- */\n.jp-mm-dot {\n\tdisplay:
|
|
50
|
+
var MINIMAP_CSS = "/* Joplin Minimap \u2014 collapsed tick bars, hover-expanded ToC panel.\n * Colors use currentColor / rgba so it follows both light and dark themes.\n */\n\n#jp-minimap {\n\tuser-select: none;\n\t-webkit-user-select: none;\n\tcaret-color: transparent;\n\tcursor: default;\n\tposition: fixed;\n\ttop: 50%;\n\tright: 6px;\n\ttransform: translateY(-50%);\n\tz-index: 9999;\n\tfont-size: 12.5px;\n\tline-height: 1.35;\n\tcolor: inherit;\n\t/* Collapsed geometry is direction-independent: the tick bars always\n\t * hug the docked edge, whichever side that is, even in an RTL note. Per-item direction applies\n\t * to the expanded panel only (see the dir=rtl rule below). */\n\tdirection: ltr;\n}\n\n.jp-mm-list {\n\tdisplay: flex;\n\tflex-direction: column;\n\talign-items: flex-end;\n\tpadding: 8px 6px;\n\tmax-height: 84vh;\n\toverflow: hidden;\n\tborder-radius: 10px;\n\ttransition: background 0.15s ease, box-shadow 0.15s ease;\n}\n\n.jp-mm-item {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: flex-end;\n\tpadding: 3px 4px;\n\tborder-radius: 6px;\n\ttext-decoration: none;\n\tcolor: inherit;\n\topacity: 0.5;\n\tcursor: pointer;\n\toutline: none;\n\tdirection: ltr;\n}\n\n/* ---- collapsed state: tick bars, width by heading level ---- */\n\n.jp-mm-bar {\n\tdisplay: block;\n\theight: 2px;\n\tborder-radius: 1px;\n\tbackground: currentColor;\n}\n\n.jp-mm-l1 .jp-mm-bar { width: 18px; }\n.jp-mm-l2 .jp-mm-bar { width: 13px; }\n.jp-mm-l3 .jp-mm-bar { width: 9px; }\n.jp-mm-l4 .jp-mm-bar { width: 7px; }\n.jp-mm-l5 .jp-mm-bar { width: 5px; }\n.jp-mm-l6 .jp-mm-bar { width: 5px; }\n\n.jp-mm-label { display: none; }\n\n/* ---- depth stepper (issue #2) ---- */\n\n/* Rows deeper than the current depth are HIDDEN, not removed: keeping the\n * nav element alive is what lets the panel stay open across a depth change,\n * since the whole expansion rides on :hover over #jp-minimap. */\n#jp-minimap[data-depth=\"1\"] .jp-mm-l2,\n#jp-minimap[data-depth=\"1\"] .jp-mm-l3,\n#jp-minimap[data-depth=\"1\"] .jp-mm-l4,\n#jp-minimap[data-depth=\"1\"] .jp-mm-l5,\n#jp-minimap[data-depth=\"1\"] .jp-mm-l6,\n#jp-minimap[data-depth=\"2\"] .jp-mm-l3,\n#jp-minimap[data-depth=\"2\"] .jp-mm-l4,\n#jp-minimap[data-depth=\"2\"] .jp-mm-l5,\n#jp-minimap[data-depth=\"2\"] .jp-mm-l6,\n#jp-minimap[data-depth=\"3\"] .jp-mm-l4,\n#jp-minimap[data-depth=\"3\"] .jp-mm-l5,\n#jp-minimap[data-depth=\"3\"] .jp-mm-l6,\n#jp-minimap[data-depth=\"4\"] .jp-mm-l5,\n#jp-minimap[data-depth=\"4\"] .jp-mm-l6,\n#jp-minimap[data-depth=\"5\"] .jp-mm-l6 { display: none; }\n\n/* The stepper is part of the expanded panel only - collapsed, the minimap\n * stays the same narrow strip of tick marks it has always been. */\n.jp-mm-head { display: none; }\n\n\n/* ---- docked on the left edge ---- */\n\n/* Mirror the collapsed alignment so the tick bars hug the left border.\n * direction is pinned to ltr above, so flex-start is unambiguously the left\n * side whatever language the note is in. Placed BEFORE the :hover rules on\n * purpose: they carry the same specificity, so source order decides. */\n#jp-minimap.jp-mm-left .jp-mm-list { align-items: flex-start; }\n#jp-minimap.jp-mm-left .jp-mm-item { justify-content: flex-start; }\n\n/* The to-do dot mirrors too: docked right it hangs left of the tick bar,\n * docked left it must hang RIGHT of it - otherwise a dotted row pushes its\n * bar 9px inward (4px dot + 5px gap) and the flush bar column goes ragged.\n * order= reorders the flex row without touching the DOM, so the expanded\n * panel can put the dot back in front of the label. */\n#jp-minimap.jp-mm-left .jp-mm-dot {\n\torder: 1;\n\tmargin-inline-start: 5px;\n\tmargin-inline-end: 0;\n}\n\n/* ---- expanded state (hover) ---- */\n\n#jp-minimap:hover .jp-mm-list {\n\talign-items: stretch;\n\toverflow-y: auto;\n\toverscroll-behavior: contain;\n\tbackground: rgba(127, 127, 127, 0.16);\n\tbackdrop-filter: blur(10px);\n\t-webkit-backdrop-filter: blur(10px);\n\tbox-shadow: 0 6px 28px rgba(0, 0, 0, 0.28);\n}\n\n#jp-minimap:hover .jp-mm-bar { display: none; }\n\n#jp-minimap:hover .jp-mm-item { justify-content: flex-start; }\n\n#jp-minimap:hover .jp-mm-label {\n\tdisplay: block;\n\tmax-width: var(--jp-mm-width, 240px);\n\twhite-space: nowrap;\n\toverflow: hidden;\n\ttext-overflow: ellipsis;\n\ttext-align: start;\n}\n\n/* RTL headings (Persian/Arabic/Hebrew) read right-to-left in the expanded\n * panel: justify-content, padding-inline-start and text-align:start all flip\n * with the row direction, so the label hugs the right edge and nested levels\n * indent inward from the right. build() sets dir per row (first strong char). */\n#jp-minimap:hover .jp-mm-item[dir=\"rtl\"] { direction: rtl; }\n\n/* indent by heading level when expanded (logical: left in LTR, right in RTL) */\n#jp-minimap:hover .jp-mm-l2 { padding-inline-start: 16px; }\n#jp-minimap:hover .jp-mm-l3 { padding-inline-start: 28px; }\n#jp-minimap:hover .jp-mm-l4 { padding-inline-start: 40px; }\n#jp-minimap:hover .jp-mm-l5 { padding-inline-start: 52px; }\n#jp-minimap:hover .jp-mm-l6 { padding-inline-start: 52px; }\n\n#jp-minimap:hover .jp-mm-head {\n\tdisplay: flex;\n\talign-items: center;\n\tjustify-content: center;\n\tgap: 7px;\n\tpadding: 0 4px 5px;\n\tmargin-bottom: 4px;\n\tborder-bottom: 1px solid rgba(127, 127, 127, 0.3);\n\tfont-size: 11px;\n\topacity: 0.8;\n\t/* The control reads the same either way round, and the panel is pinned\n\t * to ltr anyway - keep it out of the per-row bidi logic entirely. */\n\tdirection: ltr;\n}\n\n.jp-mm-step {\n\tmin-width: 15px;\n\ttext-align: center;\n\tborder-radius: 4px;\n\tfont-weight: 700;\n\tcursor: pointer;\n\tbackground: rgba(127, 127, 127, 0.22);\n}\n\n#jp-minimap:hover .jp-mm-step:hover { background: rgba(127, 127, 127, 0.45); }\n\n/* Already at the shallowest / deepest level this note has. */\n.jp-mm-step-off { opacity: 0.3; cursor: default; }\n#jp-minimap:hover .jp-mm-step-off:hover { background: rgba(127, 127, 127, 0.22); }\n\n.jp-mm-depth { font-variant-numeric: tabular-nums; }\n\n/* ---- heading tiers (issue #2): indentation alone is a weak cue when\n * scanning a long outline. Size and weight only - NEVER a colour. The\n * panel has to stay legible on every Joplin theme, so the palette is\n * limited to currentColor and neutral rgba (see CLAUDE.md). ---- */\n#jp-minimap:hover .jp-mm-r0 .jp-mm-label { font-size: 13.5px; font-weight: 600; }\n#jp-minimap:hover .jp-mm-r1 .jp-mm-label { font-weight: 500; }\n#jp-minimap:hover .jp-mm-r2 .jp-mm-label { font-size: 11.5px; opacity: 0.8; }\n\n\n/* Expanded, the dot reads as a marker BEFORE the title on either edge. */\n#jp-minimap.jp-mm-left:hover .jp-mm-dot {\n\torder: 0;\n\tmargin-inline-start: 0;\n\tmargin-inline-end: 5px;\n}\n\n/* ---- shared states ---- */\n\n.jp-mm-item:hover {\n\topacity: 1;\n\tbackground: rgba(127, 127, 127, 0.22);\n}\n\n.jp-mm-active { opacity: 1; }\n\n#jp-minimap:hover .jp-mm-active {\n\tbackground: rgba(127, 127, 127, 0.18);\n}\n\n/* No scrollbar in the expanded panel: the wheel handler owns scrolling,\n * and a visible scrollbar at the panel edge invites overlay-scrollbar\n * style hover/click interference. */\n.jp-mm-list::-webkit-scrollbar { display: none; }\n.jp-mm-list { scrollbar-width: none; }\n\n/* ---- open-to-do section dot: one muted red dot before the tick bar of\n * any section that contains at least one unchecked checkbox ---- */\n.jp-mm-dot {\n\tdisplay: none;\n\twidth: 4px;\n\theight: 4px;\n\tborder-radius: 50%;\n\tbackground: rgba(205, 97, 85, 0.85);\n\tmargin-inline-end: 5px;\n\tflex: none;\n}\n\n.jp-mm-dot.jp-mm-on { display: block; }\n\n/* don't show over printed/exported output */\n@media print {\n\t#jp-minimap { display: none; }\n}\n";
|
|
51
51
|
|
|
52
52
|
function ensureStyle() {
|
|
53
53
|
if (document.getElementById('jp-minimap-style')) return;
|
|
@@ -89,6 +89,22 @@
|
|
|
89
89
|
// after a click (the re-render case), the jump is re-applied afterwards.
|
|
90
90
|
var pendingJump = null; // { index, text, until }
|
|
91
91
|
|
|
92
|
+
// Deepest heading level the panel shows. null = follow the setting; once the
|
|
93
|
+
// reader touches the stepper their choice sticks for the rest of the webview
|
|
94
|
+
// session. It CANNOT live on the DOM: build() rebuilds the whole nav on every
|
|
95
|
+
// note render, so anything held there is gone on the next keystroke.
|
|
96
|
+
var userDepth = null;
|
|
97
|
+
|
|
98
|
+
// Snap a wanted depth onto a level this note actually has (notes routinely
|
|
99
|
+
// start at H2 or skip a level).
|
|
100
|
+
function clampDepth(levels, want) {
|
|
101
|
+
var best = levels[0];
|
|
102
|
+
for (var i = 0; i < levels.length; i++) {
|
|
103
|
+
if (levels[i] <= want) best = levels[i];
|
|
104
|
+
}
|
|
105
|
+
return best;
|
|
106
|
+
}
|
|
107
|
+
|
|
92
108
|
function liveHeadings() {
|
|
93
109
|
var root = document.getElementById('rendered-md') || document.body;
|
|
94
110
|
return Array.prototype.slice.call(root.querySelectorAll('h1, h2, h3, h4, h5, h6'));
|
|
@@ -141,6 +157,16 @@
|
|
|
141
157
|
);
|
|
142
158
|
if (headings.length < settings.minHeadings) return;
|
|
143
159
|
|
|
160
|
+
// Distinct levels present, shallow to deep. The stepper walks THIS list
|
|
161
|
+
// rather than 1-6, so every click visibly changes something.
|
|
162
|
+
var levels = [];
|
|
163
|
+
for (var li = 0; li < headings.length; li++) {
|
|
164
|
+
var lvl = Number(headings[li].tagName.charAt(1));
|
|
165
|
+
if (levels.indexOf(lvl) < 0) levels.push(lvl);
|
|
166
|
+
}
|
|
167
|
+
levels.sort(function (a, b) { return a - b; });
|
|
168
|
+
var maxLevel = clampDepth(levels, userDepth === null ? settings.maxLevel : userDepth);
|
|
169
|
+
|
|
144
170
|
// Which sections contain at least one OPEN checkbox: walk headings and
|
|
145
171
|
// checkboxes in one document-ordered pass, attributing each unchecked
|
|
146
172
|
// box to the nearest preceding heading. One dot per section, however
|
|
@@ -158,6 +184,7 @@
|
|
|
158
184
|
}
|
|
159
185
|
}
|
|
160
186
|
|
|
187
|
+
|
|
161
188
|
var nav = document.createElement('nav');
|
|
162
189
|
nav.id = 'jp-minimap';
|
|
163
190
|
// Applied in BOTH collapsed and expanded states: shifting only on hover
|
|
@@ -183,6 +210,7 @@
|
|
|
183
210
|
// and the browser then draws a :focus-visible ring on the scroll
|
|
184
211
|
// container. Natural mouse focus never shows a ring.
|
|
185
212
|
nav.setAttribute('contenteditable', 'false');
|
|
213
|
+
nav.setAttribute('data-depth', maxLevel);
|
|
186
214
|
// Own the wheel entirely while the cursor is over the minimap:
|
|
187
215
|
// scroll the ToC list ourselves and never let the event chain
|
|
188
216
|
// through to the note underneath (scroll chaining feels erratic).
|
|
@@ -194,13 +222,91 @@
|
|
|
194
222
|
var list = document.createElement('div');
|
|
195
223
|
list.className = 'jp-mm-list';
|
|
196
224
|
|
|
225
|
+
// Depth stepper. It lives INSIDE the nav on purpose: clicking it keeps the
|
|
226
|
+
// cursor over #jp-minimap, so the hover-expanded panel never collapses
|
|
227
|
+
// mid-interaction and no click-to-pin state has to be invented. Pointless
|
|
228
|
+
// when the note only has one heading level, so it is omitted entirely.
|
|
229
|
+
var head = null;
|
|
230
|
+
var minusBtn = null;
|
|
231
|
+
var plusBtn = null;
|
|
232
|
+
var depthText = null;
|
|
233
|
+
if (levels.length > 1) {
|
|
234
|
+
head = document.createElement('div');
|
|
235
|
+
head.className = 'jp-mm-head';
|
|
236
|
+
minusBtn = stepButton('-', -1);
|
|
237
|
+
depthText = document.createElement('span');
|
|
238
|
+
depthText.className = 'jp-mm-depth';
|
|
239
|
+
plusBtn = stepButton('+', 1);
|
|
240
|
+
head.appendChild(minusBtn);
|
|
241
|
+
head.appendChild(depthText);
|
|
242
|
+
head.appendChild(plusBtn);
|
|
243
|
+
list.appendChild(head);
|
|
244
|
+
renderHead();
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
function stepButton(sign, delta) {
|
|
248
|
+
var b = document.createElement('span');
|
|
249
|
+
b.className = 'jp-mm-step';
|
|
250
|
+
b.textContent = sign;
|
|
251
|
+
// mousedown for the same reason the rows use it (see below), and the
|
|
252
|
+
// event must not reach anything underneath: adjusting the depth should
|
|
253
|
+
// never scroll the note.
|
|
254
|
+
b.addEventListener('mousedown', function (e) {
|
|
255
|
+
if (e.button !== 0) return;
|
|
256
|
+
e.preventDefault();
|
|
257
|
+
e.stopPropagation();
|
|
258
|
+
setDepth(levels[levels.indexOf(maxLevel) + delta]);
|
|
259
|
+
});
|
|
260
|
+
return b;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
function renderHead() {
|
|
264
|
+
if (!head) return;
|
|
265
|
+
var lo = levels[0];
|
|
266
|
+
depthText.textContent = lo === maxLevel ? ('H' + lo) : ('H' + lo + '-H' + maxLevel);
|
|
267
|
+
minusBtn.classList.toggle('jp-mm-step-off', maxLevel === lo);
|
|
268
|
+
plusBtn.classList.toggle('jp-mm-step-off', maxLevel === levels[levels.length - 1]);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function setDepth(next) {
|
|
272
|
+
if (next === undefined) return;
|
|
273
|
+
// The panel is vertically centred (top: 50% + translateY(-50%)), so
|
|
274
|
+
// hiding rows slides its top edge DOWN and the stepper crawls out from
|
|
275
|
+
// under the cursor - after a couple of clicks the pointer leaves the
|
|
276
|
+
// panel entirely and it collapses. Measure the header, apply the
|
|
277
|
+
// change, then pin the header back where it was. The inline top lasts
|
|
278
|
+
// only until the next build(), which re-centres from scratch.
|
|
279
|
+
var beforeY = head.getBoundingClientRect().top;
|
|
280
|
+
maxLevel = next;
|
|
281
|
+
userDepth = next;
|
|
282
|
+
nav.setAttribute('data-depth', maxLevel);
|
|
283
|
+
renderHead();
|
|
284
|
+
applyTodoDots();
|
|
285
|
+
var afterY = head.getBoundingClientRect().top;
|
|
286
|
+
if (afterY !== beforeY) {
|
|
287
|
+
var box = nav.getBoundingClientRect();
|
|
288
|
+
var limit = window.innerHeight - box.height - 4;
|
|
289
|
+
var top = box.top + (beforeY - afterY);
|
|
290
|
+
nav.style.top = Math.max(4, Math.min(top, limit > 4 ? limit : 4)) + 'px';
|
|
291
|
+
nav.style.transform = 'none';
|
|
292
|
+
}
|
|
293
|
+
updateActive();
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// A row is built for EVERY heading; the stepper hides the deep ones with
|
|
297
|
+
// CSS rather than rebuilding, so the nav element - and with it the :hover
|
|
298
|
+
// state holding the panel open - survives a depth change untouched.
|
|
197
299
|
var items = headings.map(function (h, index) {
|
|
198
300
|
var level = Number(h.tagName.charAt(1));
|
|
301
|
+
// Size/weight tier keys off the RANK among the levels this note uses,
|
|
302
|
+
// not the absolute level: a note that starts at H2 still gets a proper
|
|
303
|
+
// top tier instead of looking uniformly like sub-headings.
|
|
304
|
+
var rank = Math.min(levels.indexOf(level), 2);
|
|
199
305
|
|
|
200
306
|
// NOT an <a>: Joplin's viewer shows a "Ctrl+click to open" tooltip
|
|
201
307
|
// on anchors and treats them as external links.
|
|
202
308
|
var item = document.createElement('div');
|
|
203
|
-
item.className = 'jp-mm-item jp-mm-l' + level;
|
|
309
|
+
item.className = 'jp-mm-item jp-mm-l' + level + ' jp-mm-r' + rank;
|
|
204
310
|
|
|
205
311
|
var bar = document.createElement('span');
|
|
206
312
|
bar.className = 'jp-mm-bar';
|
|
@@ -216,12 +322,12 @@
|
|
|
216
322
|
item.setAttribute('dir', textDirection(label.textContent, h));
|
|
217
323
|
|
|
218
324
|
// Muted red reminder dot before the bar (and before the label when
|
|
219
|
-
// expanded - same element, flex order does the work).
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
325
|
+
// expanded - same element, flex order does the work). Built for every
|
|
326
|
+
// row and shown with a class, because WHICH row carries a dot depends
|
|
327
|
+
// on the current depth and the stepper changes that without rebuilding.
|
|
328
|
+
var dot = document.createElement('span');
|
|
329
|
+
dot.className = 'jp-mm-dot';
|
|
330
|
+
item.appendChild(dot);
|
|
225
331
|
item.appendChild(bar);
|
|
226
332
|
item.appendChild(label);
|
|
227
333
|
|
|
@@ -245,13 +351,38 @@
|
|
|
245
351
|
nav.appendChild(list);
|
|
246
352
|
document.body.appendChild(nav);
|
|
247
353
|
|
|
354
|
+
// Open to-dos in a section the stepper has collapsed away roll up to the
|
|
355
|
+
// nearest visible ancestor. Without this, lowering the depth silently
|
|
356
|
+
// hides the only signal that a branch still holds unfinished work - which
|
|
357
|
+
// is worse than having no dots at all, because the panel looks clean.
|
|
358
|
+
function applyTodoDots() {
|
|
359
|
+
var owner = {};
|
|
360
|
+
if (settings.showTodos !== false) {
|
|
361
|
+
var visible = -1;
|
|
362
|
+
for (var i = 0; i < headings.length; i++) {
|
|
363
|
+
if (Number(headings[i].tagName.charAt(1)) <= maxLevel) visible = i;
|
|
364
|
+
if (sectionHasTodo[i] && visible >= 0) owner[visible] = true;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
for (var j = 0; j < items.length; j++) {
|
|
368
|
+
items[j].firstChild.classList.toggle('jp-mm-on', owner[j] === true);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
applyTodoDots();
|
|
372
|
+
|
|
248
373
|
function updateActive() {
|
|
249
374
|
var activeIndex = 0;
|
|
250
375
|
for (var i = 0; i < headings.length; i++) {
|
|
251
376
|
if (headings[i].getBoundingClientRect().top <= 90) activeIndex = i;
|
|
252
377
|
}
|
|
378
|
+
// A heading hidden by the stepper highlights its nearest VISIBLE
|
|
379
|
+
// ancestor instead, so the panel always shows where you are.
|
|
380
|
+
var activeRow = 0;
|
|
381
|
+
for (var k = 0; k <= activeIndex; k++) {
|
|
382
|
+
if (Number(headings[k].tagName.charAt(1)) <= maxLevel) activeRow = k;
|
|
383
|
+
}
|
|
253
384
|
for (var j = 0; j < items.length; j++) {
|
|
254
|
-
items[j].classList.toggle('jp-mm-active', j ===
|
|
385
|
+
items[j].classList.toggle('jp-mm-active', j === activeRow);
|
|
255
386
|
}
|
|
256
387
|
}
|
|
257
388
|
|
package/publish/plugin.jpl
CHANGED
|
Binary file
|