mirror of
https://github.com/discourse/DiscoTOC.git
synced 2025-07-15 06:33:25 +00:00
parent
14432d0d4b
commit
ee0d7478fd
@ -105,9 +105,7 @@
|
|||||||
const previousHeader = $(self.options.selectors).eq(index - 1);
|
const previousHeader = $(self.options.selectors).eq(index - 1);
|
||||||
const previousTagName = previousHeader.prop("tagName").charAt(1);
|
const previousTagName = previousHeader.prop("tagName").charAt(1);
|
||||||
|
|
||||||
const currentTagName = $(this)
|
const currentTagName = $(this).prop("tagName").charAt(1);
|
||||||
.prop("tagName")
|
|
||||||
.charAt(1);
|
|
||||||
|
|
||||||
if (currentTagName < previousTagName) {
|
if (currentTagName < previousTagName) {
|
||||||
self.element
|
self.element
|
||||||
@ -166,7 +164,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
highlightItemsOnScroll: self => {
|
highlightItemsOnScroll: self => {
|
||||||
$('html, body')
|
$("html, body")
|
||||||
.promise()
|
.promise()
|
||||||
.done(function () {
|
.done(function () {
|
||||||
const winScrollTop = $(window).scrollTop();
|
const winScrollTop = $(window).scrollTop();
|
||||||
@ -234,7 +232,7 @@
|
|||||||
scrollTo: function (elem) {
|
scrollTo: function (elem) {
|
||||||
const currentDiv = $(`[data-d-toc="${elem.attr("data-d-toc")}"]`);
|
const currentDiv = $(`[data-d-toc="${elem.attr("data-d-toc")}"]`);
|
||||||
|
|
||||||
$('html, body').animate(
|
$("html, body").animate(
|
||||||
{
|
{
|
||||||
scrollTop: `${currentDiv.offset().top - minimumOffset()}`
|
scrollTop: `${currentDiv.offset().top - minimumOffset()}`
|
||||||
},
|
},
|
||||||
@ -250,7 +248,8 @@
|
|||||||
});
|
});
|
||||||
})(() => {});
|
})(() => {});
|
||||||
|
|
||||||
api.decorateCooked($elem => {
|
api.decorateCooked(
|
||||||
|
$elem => {
|
||||||
run.scheduleOnce("actions", () => {
|
run.scheduleOnce("actions", () => {
|
||||||
if ($elem.hasClass("d-editor-preview")) return;
|
if ($elem.hasClass("d-editor-preview")) return;
|
||||||
if (!$elem.parents("article#post_1").length) return;
|
if (!$elem.parents("article#post_1").length) return;
|
||||||
@ -335,7 +334,9 @@
|
|||||||
selectors: dTocHeadingSelectors
|
selectors: dTocHeadingSelectors
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, {id: "disco-toc"});
|
},
|
||||||
|
{ id: "disco-toc" }
|
||||||
|
);
|
||||||
|
|
||||||
api.cleanupStream(() => {
|
api.cleanupStream(() => {
|
||||||
$(window).off("scroll.d-toc");
|
$(window).off("scroll.d-toc");
|
||||||
@ -362,7 +363,6 @@
|
|||||||
}
|
}
|
||||||
I18n.translations[I18n.currentLocale()].js.composer.contains_dtoc = " ";
|
I18n.translations[I18n.currentLocale()].js.composer.contains_dtoc = " ";
|
||||||
|
|
||||||
|
|
||||||
api.addToolbarPopupMenuOptionsCallback(() => {
|
api.addToolbarPopupMenuOptionsCallback(() => {
|
||||||
const composerController = api.container.lookup("controller:composer");
|
const composerController = api.container.lookup("controller:composer");
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user