|
24 | 24 | let showToolbar: boolean = false; |
25 | 25 |
|
26 | 26 | const getAllDocIds = getContext("getAllDocIds") as () => BlockId[]; |
27 | | - const getLoadedDocIds = getContext("getLoadedDocIds") as () => BlockId[]; |
| 27 | + // const getLoadedDocIds = getContext("getLoadedDocIds") as () => BlockId[]; |
28 | 28 | const jumpToDoc = getContext("jumpToDoc") as (id: BlockId) => void; |
29 | 29 |
|
30 | 30 | function onConfigChanged() { |
|
169 | 169 | }); |
170 | 170 | }; |
171 | 171 |
|
| 172 | + const getDocsFlow = getContext("docsFlow") as () => HTMLElement; |
| 173 | +
|
| 174 | + const getCurrentProtyle = (): BlockId[] => { |
| 175 | + const docsFlow = getDocsFlow(); |
| 176 | + if (!docsFlow) return []; |
| 177 | +
|
| 178 | + // 获取容器在视口中的实际可见位置 |
| 179 | + const rect = docsFlow.getBoundingClientRect(); |
| 180 | + const visibleTop = rect.top; |
| 181 | + const visibleBottom = rect.bottom; |
| 182 | +
|
| 183 | + const protyles = docsFlow.querySelectorAll(".docs-flow__doc"); |
| 184 | + const visibleIds: BlockId[] = []; |
| 185 | +
|
| 186 | + protyles.forEach((protyle: HTMLElement) => { |
| 187 | + const protyleRect = protyle.getBoundingClientRect(); |
| 188 | + const id = protyle.getAttribute("data-node-id"); |
| 189 | +
|
| 190 | + if (protyleRect.bottom > visibleTop && protyleRect.top < visibleBottom && id) { |
| 191 | + visibleIds.push(id); |
| 192 | + } |
| 193 | + }); |
| 194 | +
|
| 195 | + return visibleIds; |
| 196 | + }; |
| 197 | +
|
172 | 198 | const showDocsFlowOutline = () => { |
| 199 | + const ids = getCurrentProtyle(); |
| 200 | + // console.log(visibleIds); |
173 | 201 |
|
174 | 202 | const { close } = svelteDialog({ |
175 | 203 | title: "Outline", |
|
178 | 206 | target: container, |
179 | 207 | props: { |
180 | 208 | allDocIds: getAllDocIds(), |
181 | | - loadedDocIds: getLoadedDocIds(), |
| 209 | + hightlightIds: ids || [], |
182 | 210 | jumpToDoc: (id: BlockId) => { |
183 | 211 | jumpToDoc(id); |
184 | 212 | close(); |
185 | | - } |
| 213 | + }, |
186 | 214 | }, |
187 | 215 | }); |
188 | 216 | }, |
|
205 | 233 | </script> |
206 | 234 |
|
207 | 235 | <div |
208 | | - class="docs-flow__toolbar {classNamePin}" |
| 236 | + class="docs-flow__toolbar {classNamePin} {isMobile() ? 'is-mobile' : ''}" |
209 | 237 | on:mouseenter={() => { |
210 | 238 | if (pinToolbar) return; |
211 | 239 | showToolbar = true; |
|
248 | 276 | </svg> |
249 | 277 |
|
250 | 278 | <svg |
251 | | - class="svg-button ariaLabel" |
| 279 | + class="svg-button ariaLabel hide-if-very-narrow" |
252 | 280 | aria-label={i18n.button.reverse} |
253 | 281 | on:click={() => { |
254 | 282 | listDocumentIds = listDocumentIds.reverse(); |
|
260 | 288 | </svg> |
261 | 289 |
|
262 | 290 | <svg |
263 | | - class="svg-button ariaLabel" |
| 291 | + class="svg-button ariaLabel hide-if-very-narrow" |
264 | 292 | aria-label={i18n.button.edit} |
265 | 293 | on:click={editRuleValue} |
266 | 294 | on:keypress={() => {}} |
|
294 | 322 |
|
295 | 323 | <input |
296 | 324 | id="displayBreadcrumb" |
297 | | - class="b3-switch fn__flex-center" |
| 325 | + class="b3-switch fn__flex-center hide-if-very-narrow" |
298 | 326 | type="checkbox" |
299 | 327 | bind:checked={config.breadcrumb} |
300 | 328 | on:change={onConfigChanged} |
|
312 | 340 | class="fn__flex {isMobile() ? 'fn__none' : ''}" |
313 | 341 | style="gap: 5px;" |
314 | 342 | > |
315 | | - <button class="b3-button hide-if-need" on:click={onRenameThis} |
| 343 | + <button class="b3-button hide-if-narrow" on:click={onRenameThis} |
316 | 344 | >{i18n.nameTab}</button |
317 | 345 | > |
318 | | - <button class="b3-button" on:click={onSaveThis}> |
| 346 | + <button |
| 347 | + class="b3-button hide-if-very-narrow" |
| 348 | + on:click={onSaveThis} |
| 349 | + > |
319 | 350 | {i18n.saveRule} |
320 | 351 | </button> |
321 | | - <button class="b3-button hide-if-need" on:click={onCopyLink}> |
| 352 | + <button class="b3-button hide-if-narrow" on:click={onCopyLink}> |
322 | 353 | {i18n.copyLink} |
323 | 354 | </button> |
324 | 355 | </div> |
|
330 | 361 | .docs-flow__toolbar { |
331 | 362 | height: 3rem; |
332 | 363 | padding: 0; |
333 | | -
|
334 | 364 | position: absolute; |
| 365 | +
|
| 366 | + --width: 70%; |
| 367 | + --left: calc(calc(100% - var(--width)) / 2); |
| 368 | +
|
335 | 369 | width: var(--width); |
336 | 370 | left: var(--left); |
337 | 371 |
|
338 | 372 | top: 15px; |
339 | 373 | z-index: 10; |
340 | | -
|
341 | 374 | display: flex; |
342 | 375 | justify-content: center; |
343 | 376 | align-items: center; |
| 377 | +
|
| 378 | + container-type: inline-size; |
| 379 | + container-name: docs-flow-toolbar; |
344 | 380 | } |
345 | 381 |
|
346 | 382 | .docs-flow__toolbar section.docs-flow__toolbar-body { |
347 | 383 | display: flex; |
348 | 384 | flex-wrap: wrap; |
349 | 385 | align-items: center; |
350 | 386 | gap: 5px; |
351 | | -
|
352 | 387 | padding: 4px 5px; |
353 | | - width: 600px; |
354 | | - height: 30px; |
355 | 388 |
|
| 389 | + height: 30px; |
356 | 390 | background-color: var(--b3-theme-surface); |
357 | 391 | opacity: 1; |
358 | 392 | border-radius: 10px; |
359 | 393 | box-shadow: |
360 | 394 | 0 0.5em 1em -0.125em var(--b3-theme-primary-light), |
361 | 395 | 0 0 0 1px var(--b3-theme-primary-light); |
362 | 396 |
|
363 | | - overflow: hidden; /* 添加这行以隐藏溢出的内容 */ |
364 | | -
|
365 | 397 | #space { |
366 | 398 | flex: 1; |
367 | 399 | } |
| 400 | +
|
| 401 | + flex-wrap: nowrap; |
| 402 | +
|
| 403 | + @container docs-flow-toolbar (max-width: 600px) { |
| 404 | + .b3-label__text { |
| 405 | + display: none; |
| 406 | + } |
| 407 | + .hide-if-narrow { |
| 408 | + display: none; |
| 409 | + } |
| 410 | + } |
| 411 | +
|
| 412 | + @container docs-flow-toolbar (max-width: 400px) { |
| 413 | + .hide-if-very-narrow { |
| 414 | + display: none; |
| 415 | + } |
| 416 | + } |
| 417 | + } |
| 418 | +
|
| 419 | + .docs-flow__toolbar.is-mobile { |
| 420 | + --width: 90%; |
| 421 | + top: 25px; |
| 422 | + section.docs-flow__toolbar-body { |
| 423 | + width: 70%; |
| 424 | + min-width: max-content; |
| 425 | + } |
| 426 | + } |
| 427 | + .docs-flow__toolbar:not(.is-mobile) { |
| 428 | + --width: 80%; |
| 429 | +
|
| 430 | + section.docs-flow__toolbar-body { |
| 431 | + @container docs-flow-toolbar (min-width: 720px) { |
| 432 | + width: 720px; |
| 433 | + } |
| 434 | + @container docs-flow-toolbar (max-width: 720px) { |
| 435 | + width: 100%; |
| 436 | + } |
| 437 | + } |
368 | 438 | } |
369 | 439 |
|
370 | 440 | .docs-flow__toolbar svg.svg-button { |
|
0 commit comments