This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/app/components/topic-title.js
2020-09-04 13:42:47 +02:00

34 lines
868 B
JavaScript

import Component from "@ember/component";
import KeyEnterEscape from "discourse/mixins/key-enter-escape";
import { schedule } from "@ember/runloop";
export let topicTitleDecorators = [];
export function addTopicTitleDecorator(decorator) {
topicTitleDecorators.push(decorator);
}
export function resetTopicTitleDecorators() {
topicTitleDecorators = [];
}
export default Component.extend(KeyEnterEscape, {
elementId: "topic-title",
didInsertElement() {
this._super(...arguments);
schedule("afterRender", () => {
if (this.element && !this.isDestroying && !this.isDestroyed) {
const fancyTitle = this.element.querySelector(".fancy-title");
fancyTitle &&
topicTitleDecorators &&
topicTitleDecorators.forEach((cb) =>
cb(this.model, fancyTitle, "topic-title")
);
}
});
},
});