Skip to content

Commit

Permalink
fix: remove focus from plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
v8tenko committed Sep 3, 2024
1 parent ba1250c commit d563d57
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions src/runtime/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,12 @@ export class YfmCutController {
constructor(doc: Document) {
this.__doc = doc;
this.__doc.addEventListener('click', this._onDocClick);
this.__doc.addEventListener('DOMContentLoaded', this._focusActiveCut);
}

destroy() {
this.__doc.removeEventListener('click', this._onDocClick);
}

_focusActiveCut() {
const cutId = window.location.hash.slice(1);
const cutNode = document.getElementById(cutId) as HTMLDetailsElement | null;

if (!(cutNode instanceof HTMLElement)) {
return;
}

if (!cutNode.matches(Selector.CUT)) {
return;
}

cutNode.classList.toggle(ClassName.OPEN);
cutNode.setAttribute('open', 'true');

setTimeout(() => {
cutNode.classList.add('cut-highlight');
cutNode.scrollIntoView();
}, 70);

setTimeout(() => {
cutNode.classList.remove('cut-highlight');
}, 1_000);
}

private _onDocClick = (event: MouseEvent) => {
if (isCustom(event)) {
return;
Expand Down

0 comments on commit d563d57

Please sign in to comment.