ep_markdown_toc 1.0.8 → 1.0.10
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 +2 -1
- package/package.json +1 -1
- package/static/css/popup.css +33 -1
- package/static/css/toc.css +10 -10
- package/static/js/client_hooks.js +31 -5
- package/templates/markdownPopup.ejs +64 -40
- package/templates/tocSettings.ejs +1 -6
package/README.md
CHANGED
|
@@ -7,7 +7,8 @@ It does this in multiple ways:
|
|
|
7
7
|
- It enables automatic generation of a Table of Contents based on Markdown-style hashsign headings (#, ##, etc.) in Etherpad documents (can be disabled through settings). === style headings are not supported at the moment, and likely will never be.
|
|
8
8
|
- It styles the headings to make it easier to scan long documents for chapters (can be disabled through settings)
|
|
9
9
|
- It adds a button to the toolbar that shows a quick cheatsheet for Markdown syntax
|
|
10
|
-
- It removes the default text styling buttons from the toolbar
|
|
10
|
+
- It removes the default text styling buttons from the toolbar and disables the associated shortcuts.
|
|
11
|
+
- Tries to remove rich text when pasting
|
|
11
12
|
|
|
12
13
|
It was developed as a compagnion to [Octomode](https://cc.vvvvvvaria.org/wiki/Octomode), a collective editing space for PDF making, using Etherpad, Paged.js and Flask.
|
|
13
14
|
It borrows heavily from the excellent [ep_headings2](https://github.com/ether/ep_headings2) plugin.
|
package/package.json
CHANGED
package/static/css/popup.css
CHANGED
|
@@ -27,4 +27,36 @@
|
|
|
27
27
|
|
|
28
28
|
#markdown-cheat .popup-content pre {
|
|
29
29
|
white-space: break-spaces;
|
|
30
|
-
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.cheat-grid {
|
|
33
|
+
display: grid;
|
|
34
|
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
35
|
+
gap: 10px;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.cheat-block {
|
|
39
|
+
background: #f7f7f7;
|
|
40
|
+
border: 1px solid #ddd;
|
|
41
|
+
border-radius: 4px;
|
|
42
|
+
padding: 10px;
|
|
43
|
+
font-family: monospace;
|
|
44
|
+
font-size: 12px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.cheat-block h3 {
|
|
48
|
+
margin: 0 0 6px 0;
|
|
49
|
+
font-size: 13px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.cheat-lines {
|
|
53
|
+
list-style: none;
|
|
54
|
+
padding: 0;
|
|
55
|
+
margin: 0;
|
|
56
|
+
line-height: 1.5;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.cheat-lines li {
|
|
60
|
+
margin: 0 0 4px 0;
|
|
61
|
+
white-space: pre-line;
|
|
62
|
+
}
|
package/static/css/toc.css
CHANGED
|
@@ -53,15 +53,15 @@ Add a margin for the TOC when enabled
|
|
|
53
53
|
For hiding the regular Ace/Etherpad editor buttons.
|
|
54
54
|
TODO: We might be able to this through manipulating the settings instead
|
|
55
55
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
#editbar .menu_left [data-key="bold"],
|
|
57
|
+
#editbar .menu_left [data-key="italic"],
|
|
58
|
+
#editbar .menu_left [data-key="underline"],
|
|
59
|
+
#editbar .menu_left [data-key="strikethrough"],
|
|
60
|
+
#editbar .menu_left [data-key="bold"],
|
|
61
|
+
#editbar .menu_left [data-key="insertorderedlist"],
|
|
62
|
+
#editbar .menu_left [data-key="insertunorderedlist"],
|
|
63
|
+
#editbar .menu_left [data-key="indent"],
|
|
64
|
+
#editbar .menu_left [data-key="outdent"],
|
|
65
|
+
#editbar .menu_left [data-key="bold"] + li {
|
|
66
66
|
display: none !important;
|
|
67
67
|
}
|
|
@@ -18,6 +18,7 @@ exports.postAceInit = (hook, context) => {
|
|
|
18
18
|
_ace = context.ace;
|
|
19
19
|
// Initialize plain paste handler (if enabled).
|
|
20
20
|
maybeInitPlainPaste(context);
|
|
21
|
+
initShortcutBlocker(context);
|
|
21
22
|
updateTOC();
|
|
22
23
|
};
|
|
23
24
|
|
|
@@ -173,10 +174,6 @@ function initSettingsUI() {
|
|
|
173
174
|
prefs.hideToc = false; // defaults to false
|
|
174
175
|
padcookie.setPref('userPrefs', prefs);
|
|
175
176
|
}
|
|
176
|
-
if (typeof prefs.hideButtons === 'undefined') {
|
|
177
|
-
prefs.hideButtons = true; // defaults to true
|
|
178
|
-
padcookie.setPref('userPrefs', prefs);
|
|
179
|
-
}
|
|
180
177
|
if (typeof prefs.styleHeadings === 'undefined') {
|
|
181
178
|
prefs.styleHeadings = true; // also true
|
|
182
179
|
padcookie.setPref('userPrefs', prefs);
|
|
@@ -217,7 +214,6 @@ function initSettingsUI() {
|
|
|
217
214
|
}
|
|
218
215
|
|
|
219
216
|
bindToggleSetting('#options-hideToc', 'hide-toc', 'hideToc');
|
|
220
|
-
bindToggleSetting('#options-hideButtons', 'hide-buttons', 'hideButtons');
|
|
221
217
|
bindToggleSetting('#options-styleHeadings', 'style-md-headings', 'styleHeadings');
|
|
222
218
|
|
|
223
219
|
// Plain paste toggle
|
|
@@ -259,3 +255,33 @@ function maybeInitPlainPaste(context) {
|
|
|
259
255
|
//const plainPaste = require('./plain_paste');
|
|
260
256
|
//plainPaste.ensure(context);
|
|
261
257
|
}
|
|
258
|
+
|
|
259
|
+
// Disable common rich-text keyboard shortcuts (Ctrl/Cmd+B/I/U, etc.)
|
|
260
|
+
function initShortcutBlocker(context) {
|
|
261
|
+
const padOuter = document.querySelector('iframe[name="ace_outer"]');
|
|
262
|
+
const padInner = padOuter?.contentDocument?.querySelector('iframe[name="ace_inner"]');
|
|
263
|
+
const innerDoc = padInner?.contentDocument;
|
|
264
|
+
if (!innerDoc) return;
|
|
265
|
+
|
|
266
|
+
const handler = (e) => {
|
|
267
|
+
const key = (e.key || '').toLowerCase();
|
|
268
|
+
const meta = e.metaKey || e.ctrlKey;
|
|
269
|
+
if (!meta) return;
|
|
270
|
+
// Block common formatting combos:
|
|
271
|
+
// b (bold), i (italic), u (underline), 5 (strike);
|
|
272
|
+
// Shift+L (bullet), Shift+N (numbered list), Shift+1 (heading), Shift+C (color).
|
|
273
|
+
const block =
|
|
274
|
+
['b', 'i', 'u', '5'].includes(key) ||
|
|
275
|
+
(e.shiftKey && ['l', 'n', '1', 'c'].includes(key));
|
|
276
|
+
if (block) {
|
|
277
|
+
e.preventDefault();
|
|
278
|
+
e.stopPropagation();
|
|
279
|
+
return false;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
if (!innerDoc._tocShortcutBlockerBound) {
|
|
284
|
+
innerDoc.addEventListener('keydown', handler, true);
|
|
285
|
+
innerDoc._tocShortcutBlockerBound = true;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
@@ -5,51 +5,75 @@
|
|
|
5
5
|
href="https://garrettgman.github.io/rmarkdown/authoring_pandoc_markdown.html" target="_blank">Pandoc Markdown
|
|
6
6
|
Authoring Guide</a></p>
|
|
7
7
|
</p>
|
|
8
|
-
<h3>Headings</h3>
|
|
9
|
-
<pre><code># Heading 1
|
|
10
|
-
## Heading 2
|
|
11
|
-
### Heading 3
|
|
12
|
-
### Heading 3
|
|
13
|
-
</code></pre>
|
|
14
|
-
<h3>Styling text</h3>
|
|
15
|
-
<pre><code>
|
|
16
|
-
For a paragraph break, follow a line by two or more spaces.
|
|
17
8
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
9
|
+
<div class="cheat-grid">
|
|
10
|
+
<div class="cheat-block">
|
|
11
|
+
<h3>Headings</h3>
|
|
12
|
+
<ul class="cheat-lines">
|
|
13
|
+
<li># Heading 1</li>
|
|
14
|
+
<li>## Heading 2</li>
|
|
15
|
+
<li>### Heading 3</li>
|
|
16
|
+
</ul>
|
|
17
|
+
</div>
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
<div class="cheat-block">
|
|
20
|
+
<h3>Styling</h3>
|
|
21
|
+
<ul class="cheat-lines">
|
|
22
|
+
<li>**bold**</li>
|
|
23
|
+
<li>*italic*</li>
|
|
24
|
+
<li>~~strikethrough~~</li>
|
|
25
|
+
<li>`inline code`</li>
|
|
26
|
+
</ul>
|
|
27
|
+
</div>
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
29
|
+
<div class="cheat-block">
|
|
30
|
+
<h3>Spacing</h3>
|
|
31
|
+
<ul class="cheat-lines">
|
|
32
|
+
<li>A line containing a row of three or more *, -, or _ characters (optionally separated by spaces) produces a horizontal rule: <br>
|
|
33
|
+
* * * *<br>
|
|
34
|
+
---------------<br>
|
|
35
|
+
It is strongly recommended that horizontal rules be separated from surrounding text by blank lines. </li>
|
|
36
|
+
<li>Line break: end a line with two trailing spaces␠␠</li>
|
|
37
|
+
<li>Line break: end a line with backslash \</li>
|
|
38
|
+
</ul>
|
|
39
|
+
</div>
|
|
27
40
|
|
|
28
|
-
>
|
|
29
|
-
</
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</
|
|
35
|
-
<h3>Links & Images</h3>
|
|
36
|
-
<pre><code>
|
|
37
|
-
[link text](https://example.com)
|
|
38
|
-

|
|
39
|
-
{.class}
|
|
40
|
-
</code></pre>
|
|
41
|
+
<div class="cheat-block">
|
|
42
|
+
<h3>Lists</h3>
|
|
43
|
+
<ul class="cheat-lines">
|
|
44
|
+
<li>- Unordered item</li>
|
|
45
|
+
<li>1. Ordered item</li>
|
|
46
|
+
</ul>
|
|
47
|
+
</div>
|
|
41
48
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
49
|
+
<div class="cheat-block">
|
|
50
|
+
<h3>Links & Images</h3>
|
|
51
|
+
<ul class="cheat-lines">
|
|
52
|
+
<li>[link text](https://example.com)</li>
|
|
53
|
+
<li></li>
|
|
54
|
+
<li>{.class}</li>
|
|
55
|
+
</ul>
|
|
56
|
+
</div>
|
|
45
57
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
58
|
+
<div class="cheat-block">
|
|
59
|
+
<h3>Footnotes</h3>
|
|
60
|
+
<ul class="cheat-lines">
|
|
61
|
+
<li>You can use inline footnotes: ^[All content here will be a footnote.]</li>
|
|
62
|
+
<li>Note: support for two-part Pandoc-style footnotes is sketchy.</li>
|
|
63
|
+
</ul>
|
|
64
|
+
</div>
|
|
49
65
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
</
|
|
66
|
+
<div class="cheat-block">
|
|
67
|
+
<h3>Blocks (Pandoc)</h3>
|
|
68
|
+
<ul class="cheat-lines">
|
|
69
|
+
<li>::: intro</li>
|
|
70
|
+
<li>This is the intro block.</li>
|
|
71
|
+
<li>:::</li>
|
|
72
|
+
<li>::: main</li>
|
|
73
|
+
<li>This is the main block.</li>
|
|
74
|
+
<li>:::</li>
|
|
75
|
+
</ul>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
54
78
|
</div>
|
|
55
|
-
</div>
|
|
79
|
+
</div>
|
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
<input type="checkbox" id="options-hideToc" />
|
|
5
5
|
<label for="options-hideToc" aria-label="Hide TOC">Hide TOC</label>
|
|
6
6
|
</p>
|
|
7
|
-
|
|
8
|
-
<p>
|
|
9
|
-
<input type="checkbox" id="options-hideButtons" />
|
|
10
|
-
<label for="options-hideButtons" aria-label="Hide text styling buttons">Hide text styling buttons</label>
|
|
11
|
-
</p>
|
|
12
|
-
|
|
7
|
+
|
|
13
8
|
<p>
|
|
14
9
|
<input type="checkbox" id="options-styleHeadings" />
|
|
15
10
|
<label for="options-styleHeadings" aria-label="Enable/Disable styling of the markdown headings">Style Markdown headings</label>
|