Skip to content

Commit bf38e78

Browse files
bakkotljharb
authored andcommitted
pin the biblio
1 parent b34026a commit bf38e78

File tree

3 files changed

+118
-7
lines changed

3 files changed

+118
-7
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,25 @@ Please ensure the following:
1212
## Create your proposal repo
1313

1414
Follow these steps:
15-
1. Click the green ["use this template"](https://github.com/tc39/template-for-proposals/generate) button in the repo header. (Note: Do not fork this repo in GitHub's web interface, as that will later prevent transfer into the TC39 organization)
16-
1. Go to your repo settings “Options” page, under “GitHub Pages”, and set the source to the **main branch** under the root (and click Save, if it does not autosave this setting)
15+
1. Click the green ["use this template"](https://github.com/tc39/template-for-proposals/generate) button in the repo header. (Note: Do not fork this repo in GitHub's web interface, as that will later prevent transfer into the TC39 organization)
16+
1. Update the biblio to the latest version: `npm install --save-dev --save-exact @tc39/ecma262-biblio@latest`.
17+
1. Go to your repo settings “Options” page, under “GitHub Pages”, and set the source to the **main branch** under the root (and click Save, if it does not autosave this setting)
1718
1. check "Enforce HTTPS"
1819
1. On "Options", under "Features", Ensure "Issues" is checked, and disable "Wiki", and "Projects" (unless you intend to use Projects)
1920
1. Under "Merge button", check "automatically delete head branches"
2021
<!--
21-
1. Avoid merge conflicts with build process output files by running:
22+
1. Avoid merge conflicts with build process output files by running:
2223
```sh
2324
git config --local --add merge.output.driver true
2425
git config --local --add merge.output.driver true
2526
```
26-
1. Add a post-rewrite git hook to auto-rebuild the output on every commit:
27+
1. Add a post-rewrite git hook to auto-rebuild the output on every commit:
2728
```sh
2829
cp hooks/post-rewrite .git/hooks/post-rewrite
2930
chmod +x .git/hooks/post-rewrite
3031
```
3132
-->
32-
3. ["How to write a good explainer"][explainer] explains how to make a good first impression.
33+
3. ["How to write a good explainer"][explainer] explains how to make a good first impression.
3334

3435
> Each TC39 proposal should have a `README.md` file which explains the purpose
3536
> of the proposal and its shape at a high level.

index.html

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@
902902
e.preventDefault();
903903
e.stopPropagation();
904904
menu.togglePinEntry(this.entry.id);
905+
this.$pinLink.textContent = menu._pinnedIds[this.entry.id] ? 'Unpin' : 'Pin';
905906
});
906907
907908
this.$refsLink = document.createElement('a');
@@ -922,6 +923,7 @@
922923
sdoBox.deactivate();
923924
this.active = true;
924925
this.entry = entry;
926+
this.$pinLink.textContent = menu._pinnedIds[entry.id] ? 'Unpin' : 'Pin';
925927
this.$outer.classList.add('active');
926928
this.top = el.offsetTop - this.$outer.offsetHeight;
927929
this.left = el.offsetLeft - 10;
@@ -1117,6 +1119,114 @@
11171119
referencePane.init();
11181120
});
11191121
1122+
// preserve state during navigation
1123+
1124+
function getTocPath(li) {
1125+
let path = [];
1126+
let pointer = li;
1127+
while (true) {
1128+
let parent = pointer.parentElement;
1129+
if (parent == null) {
1130+
return null;
1131+
}
1132+
let index = [].indexOf.call(parent.children, pointer);
1133+
if (index == -1) {
1134+
return null;
1135+
}
1136+
path.unshift(index);
1137+
pointer = parent.parentElement;
1138+
if (pointer == null) {
1139+
return null;
1140+
}
1141+
if (pointer.id === 'menu-toc') {
1142+
break;
1143+
}
1144+
if (pointer.tagName !== 'LI') {
1145+
return null;
1146+
}
1147+
}
1148+
return path;
1149+
}
1150+
1151+
function activateTocPath(path) {
1152+
try {
1153+
let pointer = document.getElementById('menu-toc');
1154+
for (let index of path) {
1155+
pointer = pointer.querySelector('ol').children[index];
1156+
}
1157+
pointer.classList.add('active');
1158+
} catch (e) {
1159+
// pass
1160+
}
1161+
}
1162+
1163+
function getActiveTocPaths() {
1164+
return [...menu.$menu.querySelectorAll('.active')].map(getTocPath).filter(p => p != null);
1165+
}
1166+
1167+
function loadStateFromSessionStorage() {
1168+
if (!window.sessionStorage || typeof menu === 'undefined' || window.navigating) {
1169+
return;
1170+
}
1171+
if (sessionStorage.referencePaneState != null) {
1172+
let state = JSON.parse(sessionStorage.referencePaneState);
1173+
if (state != null) {
1174+
if (state.type === 'ref') {
1175+
let entry = menu.search.biblio.byId[state.id];
1176+
if (entry != null) {
1177+
referencePane.showReferencesFor(entry);
1178+
}
1179+
} else if (state.type === 'sdo') {
1180+
let sdos = sdoMap[state.id];
1181+
if (sdos != null) {
1182+
referencePane.$headerText.innerHTML = state.html;
1183+
referencePane.showSDOsBody(sdos, state.id);
1184+
}
1185+
}
1186+
delete sessionStorage.referencePaneState;
1187+
}
1188+
}
1189+
1190+
if (sessionStorage.activeTocPaths != null) {
1191+
document
1192+
.getElementById('menu-toc')
1193+
.querySelectorAll('.active')
1194+
.forEach(e => {
1195+
e.classList.remove('active');
1196+
});
1197+
let active = JSON.parse(sessionStorage.activeTocPaths);
1198+
active.forEach(activateTocPath);
1199+
delete sessionStorage.activeTocPaths;
1200+
}
1201+
1202+
if (sessionStorage.searchValue != null) {
1203+
let value = JSON.parse(sessionStorage.searchValue);
1204+
menu.search.$searchBox.value = value;
1205+
menu.search.search(value);
1206+
delete sessionStorage.searchValue;
1207+
}
1208+
1209+
if (sessionStorage.tocScroll != null) {
1210+
let tocScroll = JSON.parse(sessionStorage.tocScroll);
1211+
menu.$toc.scrollTop = tocScroll;
1212+
delete sessionStorage.tocScroll;
1213+
}
1214+
}
1215+
1216+
document.addEventListener('DOMContentLoaded', loadStateFromSessionStorage);
1217+
1218+
window.addEventListener('pageshow', loadStateFromSessionStorage);
1219+
1220+
window.addEventListener('beforeunload', () => {
1221+
if (!window.sessionStorage || typeof menu === 'undefined') {
1222+
return;
1223+
}
1224+
sessionStorage.referencePaneState = JSON.stringify(referencePane.state || null);
1225+
sessionStorage.activeTocPaths = JSON.stringify(getActiveTocPaths());
1226+
sessionStorage.searchValue = JSON.stringify(menu.search.$searchBox.value);
1227+
sessionStorage.tocScroll = JSON.stringify(menu.$toc.scrollTop);
1228+
});
1229+
11201230
'use strict';
11211231
let decimalBullet = Array.from({ length: 100 }, (a, i) => '' + (i + 1));
11221232
let alphaBullet = Array.from({ length: 26 }, (a, i) => String.fromCharCode('a'.charCodeAt(0) + i));
@@ -2414,7 +2524,7 @@
24142524
</ul></div><div id="menu-toggle"><svg xmlns="http://www.w3.org/2000/svg" style="width:100%; height:100%; stroke:currentColor" viewBox="0 0 120 120">
24152525
<title>Menu</title>
24162526
<path stroke-width="10" stroke-linecap="round" d="M30,60 h60 M30,30 m0,5 h60 M30,90 m0,-5 h60"></path>
2417-
</svg></div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-demo-clause" title="This is an emu-clause"><span class="secnum">1</span> This is an emu-clause</a></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage -1 Draft / April 8, 2022</h1><h1 class="title">Proposal Title Goes Here</h1>
2527+
</svg></div><div id="menu-spacer"></div><div id="menu"><div id="menu-search"><input type="text" id="menu-search-box" placeholder="Search..."><div id="menu-search-results" class="inactive"></div></div><div id="menu-pins"><div class="menu-pane-header">Pins</div><ul id="menu-pins-list"></ul></div><div class="menu-pane-header">Table of Contents</div><div id="menu-toc"><ol class="toc"><li><span class="item-toggle-none"></span><a href="#sec-demo-clause" title="This is an emu-clause"><span class="secnum">1</span> This is an emu-clause</a></li><li><span class="item-toggle-none"></span><a href="#sec-copyright-and-software-license" title="Copyright &amp; Software License"><span class="secnum">A</span> Copyright &amp; Software License</a></li></ol></div></div><div id="spec-container"><h1 class="version">Stage -1 Draft / May 23, 2022</h1><h1 class="title">Proposal Title Goes Here</h1>
24182528

24192529
<emu-clause id="sec-demo-clause">
24202530
<h1><span class="secnum">1</span> This is an emu-clause</h1>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"license": "MIT",
1616
"devDependencies": {
17-
"@tc39/ecma262-biblio": "^2.0.2288",
17+
"@tc39/ecma262-biblio": "2.0.2322",
1818
"ecmarkup": "^12.0.2"
1919
}
2020
}

0 commit comments

Comments
 (0)