DEV: Add outlet + scroll event to support DiscoTOC (#75)
This commit is contained in:
parent
f8ac536160
commit
39f956fa13
|
@ -1,18 +1,16 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { reads } from "@ember/object/computed";
|
import { reads } from "@ember/object/computed";
|
||||||
import computed from "discourse-common/utils/decorators";
|
import computed, { bind } from "discourse-common/utils/decorators";
|
||||||
|
import discourseDebounce from "discourse-common/lib/debounce";
|
||||||
|
|
||||||
export default Component.extend({
|
export default Component.extend({
|
||||||
classNames: "docs-topic",
|
classNames: "docs-topic",
|
||||||
|
|
||||||
originalPostContent: reads("post.cooked"),
|
originalPostContent: reads("post.cooked"),
|
||||||
|
|
||||||
@computed("topic")
|
@computed("topic.post_stream")
|
||||||
post() {
|
post(stream) {
|
||||||
return this.store.createRecord(
|
return this.store.createRecord("post", stream?.posts.firstObject);
|
||||||
"post",
|
|
||||||
this.topic.post_stream.posts.firstObject
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("post", "topic")
|
@computed("post", "topic")
|
||||||
|
@ -26,15 +24,27 @@ export default Component.extend({
|
||||||
return post;
|
return post;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@bind
|
||||||
|
_emitScrollEvent() {
|
||||||
|
this.appEvents.trigger("docs-topic:current-post-scrolled");
|
||||||
|
},
|
||||||
|
|
||||||
|
@bind
|
||||||
|
debounceScrollEvent() {
|
||||||
|
discourseDebounce(this, this._emitScrollEvent, 200);
|
||||||
|
},
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
document.querySelector("body").classList.add("archetype-docs-topic");
|
document.querySelector("body").classList.add("archetype-docs-topic");
|
||||||
|
document.addEventListener("scroll", this.debounceScrollEvent);
|
||||||
},
|
},
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
document.querySelector("body").classList.remove("archetype-docs-topic");
|
document.querySelector("body").classList.remove("archetype-docs-topic");
|
||||||
|
document.removeEventListener("scroll", this.debounceScrollEvent);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
{{#if selectedTopic}}
|
{{#if selectedTopic}}
|
||||||
{{#conditional-loading-spinner condition=isTopicLoading}}
|
{{#conditional-loading-spinner condition=isTopicLoading}}
|
||||||
{{docs-topic topic=topic return=(action "returnToList")}}
|
{{docs-topic topic=topic return=(action "returnToList")}}
|
||||||
|
{{plugin-outlet name="below-docs-topic" tagName="" connectorTagName="div"}}
|
||||||
{{/conditional-loading-spinner}}
|
{{/conditional-loading-spinner}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="docs-results">
|
<div class="docs-results">
|
||||||
|
|
Loading…
Reference in New Issue