Fixed copy-to-clipboard re-appearing after document switch

This commit is contained in:
squidfunk 2020-02-29 12:38:11 +01:00
parent 6029122f96
commit a1393fdbc3
7 changed files with 17 additions and 13 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
{
"assets/javascripts/bundle.js": "assets/javascripts/bundle.bc60b539.min.js",
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.bc60b539.min.js.map",
"assets/javascripts/bundle.js": "assets/javascripts/bundle.2f004b84.min.js",
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.2f004b84.min.js.map",
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.926ffd9e.min.js",
"assets/javascripts/worker/search.js.map": "assets/javascripts/worker/search.926ffd9e.min.js.map",
"assets/stylesheets/main.scss": "assets/stylesheets/main.1e07d700.min.css",

View File

@ -195,7 +195,7 @@
{% endblock %}
</div>
{% block scripts %}
<script src="{{ 'assets/javascripts/bundle.bc60b539.min.js' | url }}"></script>
<script src="{{ 'assets/javascripts/bundle.2f004b84.min.js' | url }}"></script>
{%- set translations = {} -%}
{%- for key in [
"clipboard.copy",

View File

@ -314,16 +314,19 @@ export function initialize(config: unknown) {
* Location change
*/
interface State {
url: URL // TODO: use URL!?
url: URL
data?: ViewportOffset
}
function isInternalLink(el: HTMLAnchorElement | URL) {
return el.hostname === location.hostname
return el.host === location.host && (
!el.pathname || /\/[\w-]+(?:\/?|\.html)$/i.test(el.pathname)
)
}
// on same page!
function isAnchorLink(el: HTMLAnchorElement | URL) {
return el.hash.length > 0
return el.pathname === location.pathname && el.hash.length > 0
}
function compareState(
@ -421,7 +424,7 @@ export function initialize(config: unknown) {
prev.url.href.match(next.url.href) !== null &&
isAnchorLink(prev.url)
) {
dialog$.next(`Potential Candidate: ${JSON.stringify(next.data)}`, ) // awesome debugging.
// dialog$.next(`Potential Candidate: ${JSON.stringify(next.data)}`, ) // awesome debugging.
setViewportOffset(next.data || { y: 0 })
}
// console.log("Potential Candidate")

View File

@ -20,13 +20,14 @@
* IN THE SOFTWARE.
*/
import { Subject, animationFrameScheduler } from "rxjs"
import { Subject, animationFrameScheduler, of } from "rxjs"
import {
delay,
map,
observeOn,
switchMap,
tap
tap,
withLatestFrom
} from "rxjs/operators"
import { useComponent } from "components"
@ -65,7 +66,7 @@ export function setupDialog(
/* Display dialog */
dialog$
.pipe(
switchMap(text => useComponent("container")
switchMap(text => of(document.body) // useComponent("container")
.pipe(
map(container => container.appendChild(dialog)),
observeOn(animationFrameScheduler),