Skip to content

Commit 9484137

Browse files
author
github-actions
committed
Aggregate documentation
0 parents  commit 9484137

File tree

245 files changed

+20589
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

245 files changed

+20589
-0
lines changed

assets/default/flexsearch.bundle.js

Lines changed: 33 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/default/flexsearch.css

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
#multi-page-nav .search {
2+
margin-left: auto;
3+
font-size: 16px;
4+
}
5+
6+
#multi-page-nav .search .search-keybinding {
7+
float: right;
8+
width: 0;
9+
transform: translateX(-1em);
10+
color: #999;
11+
}
12+
13+
#multi-page-nav .search:focus-within .search-keybinding {
14+
display: none;
15+
}
16+
17+
#multi-page-nav .search #search-input {
18+
border: 1px solid #666;
19+
border-radius: 3.2px;
20+
color: #999;
21+
background-color: unset;
22+
height: 28px;
23+
font-family: Glober;
24+
width: 20em;
25+
font-size: 14px;
26+
padding: 0 8px;
27+
}
28+
29+
#multi-page-nav .search #search-input::placeholder {
30+
color: #999;
31+
opacity: 1;
32+
}
33+
34+
#multi-page-nav .search:focus-within #search-input {
35+
background-color: #fff;
36+
outline: none;
37+
box-shadow: none;
38+
color: #000;
39+
}
40+
41+
.theme--documenter-dark #multi-page-nav .search:focus-within #search-input {
42+
background-color: #202227;
43+
color: #eee;
44+
}
45+
46+
#multi-page-nav .search:focus-within .suggestions {
47+
display: block;
48+
}
49+
50+
#multi-page-nav .hidden {
51+
display: none !important;
52+
}
53+
54+
#multi-page-nav .suggestions {
55+
margin: -10px 20px 0 0;
56+
display: none;
57+
background: #fff;
58+
min-width: 20em;
59+
max-width: 50vw;
60+
position: absolute;
61+
border: 1px solid #cfd4db;
62+
border-radius: 6px;
63+
padding: .4rem;
64+
list-style-type: none;
65+
z-index: 10;
66+
right: 0;
67+
max-height: max(50vh, 250px);
68+
overflow-y: auto;
69+
}
70+
71+
.theme--documenter-dark #multi-page-nav .suggestions {
72+
background: #2e3138;
73+
border: 1px solid #5e6d6f;
74+
}
75+
76+
.theme--documenter-dark #multi-page-nav .suggestion a:hover,
77+
.theme--documenter-dark #multi-page-nav .suggestion a:focus {
78+
background-color: #202227;
79+
}
80+
81+
#multi-page-nav .suggestions .suggestion {
82+
line-height: 1.4;
83+
border-radius: 4px;
84+
cursor: pointer;
85+
overflow: hidden;
86+
text-overflow: ellipsis;
87+
word-break: break-all;
88+
}
89+
90+
#multi-page-nav .suggestion a {
91+
padding: .4rem .6rem;
92+
display: block;
93+
overflow: hidden;
94+
text-overflow: ellipsis;
95+
color: black;
96+
}
97+
98+
.theme--documenter-dark #multi-page-nav .suggestion a {
99+
color: white;
100+
}
101+
102+
#multi-page-nav .suggestion a:hover,
103+
#multi-page-nav .suggestion a:focus {
104+
background-color: #eee;
105+
}
106+
107+
#multi-page-nav .suggestions .suggestion .page-title {
108+
font-weight: bold;
109+
}
110+
111+
@media screen and (max-width: 1055px) {
112+
#multi-page-nav .search #search-input {
113+
width: 100%;
114+
}
115+
#multi-page-nav .suggestions {
116+
max-width: 100vw;
117+
width: calc(100% - 7.5rem);
118+
margin: 10px 2em 4.5em 0;
119+
}
120+
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
// custom search widget
2+
(function() {
3+
const MAX_RESULTS = 40
4+
const flexsearchIdx = new FlexSearch.Document({
5+
document: {
6+
id: 'id',
7+
store: ['title', 'pagetitle', 'ref'],
8+
index: [
9+
{
10+
field: 'content',
11+
}
12+
]
13+
},
14+
});
15+
16+
let successfullyLoadedIndex = null
17+
18+
function loadIndex(flexsearchIdx) {
19+
const input = document.getElementById('search-input')
20+
input.setAttribute('placeholder', 'Loading...')
21+
successfullyLoadedIndex = false
22+
const keys = ['content.cfg', 'content.ctx', 'content.map', 'reg', 'store']
23+
const rootPath = window.MULTIDOCUMENTER_ROOT_PATH ?? '/'
24+
const promises = keys.map(key => {
25+
return new Promise((resolve, reject) => {
26+
fetch(`${rootPath}search-data/${key}.json`).then(r => {
27+
if (r && r.ok) {
28+
r.json().then(idx => {
29+
flexsearchIdx.import(key, idx)
30+
resolve()
31+
}).catch(() => {
32+
reject()
33+
})
34+
} else {
35+
reject()
36+
}
37+
}).catch(() => {
38+
reject()
39+
})
40+
})
41+
})
42+
43+
Promise.all(promises).then(() => {
44+
input.setAttribute('placeholder', 'Search...')
45+
successfullyLoadedIndex = true
46+
}).catch(() => {
47+
input.setAttribute('placeholder', 'Error loading search data...')
48+
successfullyLoadedIndex = false
49+
})
50+
}
51+
52+
function registerSearchListener() {
53+
const input = document.getElementById('search-input')
54+
const suggestions = document.getElementById('search-result-container')
55+
56+
let lastQuery = ''
57+
58+
function runSearch() {
59+
if (successfullyLoadedIndex === null) {
60+
loadIndex(flexsearchIdx)
61+
} else if (successfullyLoadedIndex === false) {
62+
return
63+
}
64+
const query = input.value
65+
66+
if (flexsearchIdx && query !== lastQuery) {
67+
lastQuery = query
68+
69+
console.time('search')
70+
let results = flexsearchIdx.search(query, {
71+
limit: MAX_RESULTS,
72+
enrich: true
73+
})
74+
console.timeEnd('search')
75+
76+
if (results.length > 0) {
77+
buildResults(results[0].result.map(r => r.doc))
78+
} else {
79+
suggestions.classList.add('hidden')
80+
}
81+
}
82+
}
83+
84+
input.addEventListener('keyup', ev => {
85+
runSearch()
86+
})
87+
88+
input.addEventListener('keydown', ev => {
89+
if (ev.key === 'ArrowDown') {
90+
suggestions.firstChild.firstChild.focus()
91+
ev.preventDefault()
92+
return
93+
} else if (ev.key === 'ArrowUp') {
94+
suggestions.lastChild.firstChild.focus()
95+
ev.preventDefault()
96+
return
97+
}
98+
})
99+
100+
suggestions.addEventListener('keydown', ev => {
101+
if (ev.target.dataset.index !== undefined) {
102+
const li = ev.target.parentElement
103+
if (ev.key === 'ArrowDown') {
104+
const el = li.nextSibling
105+
if (el) {
106+
el.firstChild.focus()
107+
ev.preventDefault()
108+
} else {
109+
input.focus()
110+
}
111+
} else if (ev.key === 'ArrowUp') {
112+
const el = li.previousSibling
113+
if (el) {
114+
el.firstChild.focus()
115+
ev.preventDefault()
116+
} else {
117+
input.focus()
118+
}
119+
}
120+
}
121+
})
122+
123+
input.addEventListener('focus', ev => {
124+
runSearch()
125+
})
126+
}
127+
128+
function buildResults(results) {
129+
const suggestions = document.getElementById('search-result-container')
130+
131+
suggestions.classList.remove('hidden')
132+
133+
console.log(results)
134+
135+
const children = results.slice(0, MAX_RESULTS - 1).map((r, i) => {
136+
const entry = document.createElement('li')
137+
entry.classList.add('suggestion')
138+
const link = document.createElement('a')
139+
link.setAttribute('href', r.ref)
140+
link.dataset.index = i
141+
const page = document.createElement('span')
142+
page.classList.add('page-title')
143+
page.innerText = r.pagetitle
144+
const section = document.createElement('span')
145+
section.innerText = ' > ' + r.title
146+
section.classList.add('section-title')
147+
link.appendChild(page)
148+
link.appendChild(section)
149+
entry.appendChild(link)
150+
return entry
151+
})
152+
suggestions.replaceChildren(
153+
...children
154+
)
155+
}
156+
157+
function initialize() {
158+
registerSearchListener()
159+
160+
document.body.addEventListener('keydown', ev => {
161+
if (document.activeElement === document.body && (ev.key === '/' || ev.key === 's')) {
162+
document.getElementById('search-input').focus()
163+
ev.preventDefault()
164+
}
165+
})
166+
}
167+
168+
if (document.readyState === 'loading') {
169+
document.addEventListener('DOMContentLoaded', initialize)
170+
} else {
171+
initialize()
172+
};
173+
})()

0 commit comments

Comments
 (0)