Files
openide/python/python-restructuredtext/resources/js/script.js
Andrey Lisin 638dce38d7 PY-71930 Restore reStructuredText plugin
This commit partially reverts changes from 4da3e7da. While the consolidation of reStructuredText support into a single module is retained, it needs to be available as a plugin since some IDEs do not include it by default but can still benefit from its capabilities.


Merge-request: IJ-MR-139650
Merged-by: Andrey Lisin <andrey.lisin@jetbrains.com>

GitOrigin-RevId: bc5cde2970a0760e32ceaee61ceef8427e8f8fe5
2024-07-31 12:47:03 +00:00

21 lines
726 B
JavaScript

// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
window.__IntelliJTools = {};
window.onclick = e => {
if (e.target.tagName !== "A") return true;
e.stopPropagation();
e.preventDefault();
const href = e.target.href;
if (href.indexOf("#") !== -1 && !/^https?:\/\//i.test(href)) { // internal link
const elementId = href.split('#')[1];
const elementById = window.document.getElementById(elementId);
if (elementById) {
elementById.scrollIntoViewIfNeeded();
}
return;
}
if (window.__IntelliJTools.openInBrowserCallback !== undefined) {
window.__IntelliJTools.openInBrowserCallback(href);
}
};