-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path000 Menu.js
More file actions
108 lines (95 loc) · 4.55 KB
/
000 Menu.js
File metadata and controls
108 lines (95 loc) · 4.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
function onInstall(e) {
onOpen(e);
}
function onOpen(e) {
Menu_HePaNumbering().addToUi();
}
function Menu_HePaNumbering() {
const activeStyle = getHeadingStyle();
const debugMode = getDebugMode();
// Select H1 prefix
const subMenuPrefixes = DocumentApp.getUi().createMenu('Select prefix');
let selectedPrefixMarker = '';
for (let prefix in prefixes) {
if (prefix.toString() == activeStyle.prefix) {
selectedPrefixMarker = activeStyle.prefixMarker;
} else {
selectedPrefixMarker = '';
}
subMenuPrefixes.addItem(prefixes[prefix]['name'] + ' ' + selectedPrefixMarker, 'prefixes.' + prefix + '.run');
}
// End. Select H1 prefix
// Select style submenu
const subMenuStyles = DocumentApp.getUi().createMenu('Select style')
.addItem('Show current style', 'showCurrentStyle')
.addSubMenu(DocumentApp.getUi().createMenu('Configure ignored text')
.addItem('Show current setting', 'ignoredTextShowCurrentSetting')
.addItem('Edit setting', 'ignoredTextEditSetting')
.addItem('Restore default', 'ignoredTextRestoreDefault'))
.addSeparator();
greenCheckboxMenuHelper(subMenuStyles, tryToRetrieveProperties = true, 'withoutDots', withWithoutDotsStyles, 'withWithoutDotsStyles', 'WITH_WITHOUT_DOTS_SETTINGS');
let selectedStyleMarker = '';
let menuItemText;
for (let styleName in headingStyles) {
menuItemText = headingStyles[styleName]['name'];
if (styleName.toString() === 'boldFugureH6') {
const boldFugureH6Style = getBoldFigureStyle(true);
selectedStyleMarker = boldFugureH6Style.marker;
} else {
if (styleName.toString() == activeStyle.value) {
selectedStyleMarker = activeStyle.marker;
} else {
selectedStyleMarker = '';
}
}
if (headingStyles[styleName]['separatorAbove'] === true) {
subMenuStyles.addSeparator();
}
if (headingStyles[styleName]['overrideH1PrefixWithCustomPrefix'] === true || headingStyles[styleName]['overrideAllHPrefixWithCustomPrefix'] === true) {
menuItemText = menuItemText.replaceAll('~PREFIX~', activeStyle.prefixText);
}
subMenuStyles.addItem(menuItemText + ' ' + selectedStyleMarker, 'headingStyles.' + styleName + '.run');
if (headingStyles[styleName]['subMenuBelow'] === true) {
subMenuStyles.addSubMenu(subMenuPrefixes);
}
}
// End. Select style submenu
const submenu_util = DocumentApp.getUi().createMenu('Utilities')
.addItem('Add/update heading numbers only [links not updated]', 'doNumberHeadings')
.addSeparator()
.addItem('Links: Update numbers in (hyper)links (to headings)', 'updateNumbersInLinksToHeadings')
.addItem('Links: Replace entire link text with text of corresponding heading', 'resetFullLinkTextInLinksToHeadings')
.addSeparator()
.addItem('nhr Remove all heading numbers', 'removeAllHeadingNumbers')
.addSeparator()
.addItem('Mark internal heading links', 'markInternalHeadingLinks')
.addItem('Clear internal heading link markers', 'clearInternalLinkMarkers')
.addSeparator()
.addItem('nhprefix prefix all headings with a string', 'prefixHeadings')
.addItem('nh6t Heading 6 tables/figures only', 'updateFigureNumbers');
const submenu_para = DocumentApp.getUi().createMenu('Paragraphs')
.addItem('pna Paragraph numbers add, with ⟦ and ⟧', 'paraNumAdd')
.addItem('pnr Paragraph numbers remove', 'paraNumRemove')
.addItem('psna Paragraph/sentence numbers add, with ⟦ and ⟧', 'paraSenNumAdd')
.addItem('psnr Paragraph/sentence numbers remove', 'paraSenNumRemove')
.addSeparator()
.addItem('psnm Paragraph/sentence numbers minify', 'minifyParaSenMarker')
.addItem('psnshow Paragraph/sentence numbers - restore size', 'maxifyParaSenMarker')
.addSeparator()
.addItem('Move ⟦…⟧ end notes into place (single paragraph)', 'moveParagraphNotes_afterRefs_tablesAndLists_single')
.addItem('Move ⟦…⟧ end notes into place (multiple paragraphs)', 'moveParagraphNotes_afterRefs_tablesAndLists_multiple')
.addItem('Format notes (purple text)', 'setPurpleForegroundNotes')
.addItem('Format notes (yellow highlight)', 'setYellowBackgroundNotes')
const menu = DocumentApp.getUi().createMenu('Heading & paragraph numbering')
.addItem('nha Add/update heading numbers and links', 'doNumberHeadingsAndLinks')
.addSeparator()
.addSubMenu(subMenuStyles)
.addSubMenu(submenu_util)
.addSubMenu(submenu_para);
if (debugMode === true) {
menu.addItem('Turn off debug mode', 'turnOffDebugMode');
} else {
menu.addItem('Turn on debug mode', 'turnOnDebugMode');
}
return menu;
}