A platform for community discussion. Free, open, simple.
Revert "DEV: Convert topic-title to glimmer/gjs (#26775)" (#26794)
Jarek Radosz5d568d0bab1c
diff --git a/app/assets/javascripts/discourse/app/components/topic-title.gjs b/app/assets/javascripts/discourse/app/components/topic-title.gjsdeleted file mode 100644index 5e3ab195052..00000000000--- a/app/assets/javascripts/discourse/app/components/topic-title.gjs+++ /dev/null@@ -1,71 +0,0 @@-import Component from "@glimmer/component";-import { hash } from "@ember/helper";-import { on } from "@ember/modifier";-import { action } from "@ember/object";-import didInsert from "@ember/render-modifiers/modifiers/did-insert";-import PluginOutlet from "discourse/components/plugin-outlet";-import { isiPad } from "discourse/lib/utilities";--export let topicTitleDecorators = [];--export function addTopicTitleDecorator(decorator) {- topicTitleDecorators.push(decorator);-}--export function resetTopicTitleDecorators() {- topicTitleDecorators.length = 0;-}--export default class TopicTitle extends Component {- @action- applyDecorators(element) {- const fancyTitle = element.querySelector(".fancy-title");-- if (fancyTitle) {- topicTitleDecorators?.forEach((cb) =>- cb(this.args.model, fancyTitle, "topic-title")- );- }- }-- @action- keyDown(e) {- if (document.body.classList.contains("modal-open")) {- return;- }-- if (e.key === "Escape") {- e.preventDefault();- this.args.cancelled();- } else if (- e.key === "Enter" &&- (e.ctrlKey || e.metaKey || (isiPad() && e.altKey))- ) {- // Ctrl+Enter or Cmd+Enter- // iPad physical keyboard does not offer Command or Ctrl detection- // so use Alt+Enter- e.preventDefault();- this.args.save(undefined, e);- }- }-- <template>- {{! template-lint-disable no-invalid-interactive }}- <div- {{didInsert this.applyDecorators}}- {{on "keydown" this.keyDown}}- id="topic-title"- class="container"- >- <div class="title-wrapper">- {{yield}}- </div>-- <PluginOutlet- @name="topic-title"- @connectorTagName="div"- @outletArgs={{hash model=@model}}- />- </div>- </template>-}diff --git a/app/assets/javascripts/discourse/app/components/topic-title.hbs b/app/assets/javascripts/discourse/app/components/topic-title.hbsnew file mode 100644index 00000000000..d7f72e1f35a--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/topic-title.hbs@@ -0,0 +1,12 @@+<div class="container">+ <div class="title-wrapper">+ {{yield}}+ </div>+ <span>+ <PluginOutlet+ @name="topic-title"+ @connectorTagName="div"+ @outletArgs={{hash model=this.model}}+ />+ </span>+</div>\ No newline at end of filediff --git a/app/assets/javascripts/discourse/app/components/topic-title.js b/app/assets/javascripts/discourse/app/components/topic-title.jsnew file mode 100644index 00000000000..107590f7f69--- /dev/null+++ b/app/assets/javascripts/discourse/app/components/topic-title.js@@ -0,0 +1,53 @@+import Component from "@ember/component";+import { schedule } from "@ember/runloop";+import { isiPad } from "discourse/lib/utilities";++export let topicTitleDecorators = [];++export function addTopicTitleDecorator(decorator) {+ topicTitleDecorators.push(decorator);+}++export function resetTopicTitleDecorators() {+ topicTitleDecorators.length = 0;+}++export default Component.extend({+ 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")+ );+ }+ });+ },++ keyDown(e) {+ if (document.body.classList.contains("modal-open")) {+ return;+ }++ if (e.key === "Escape") {+ e.preventDefault();+ this.cancelled();+ } else if (+ e.key === "Enter" &&+ (e.ctrlKey || e.metaKey || (isiPad() && e.altKey))+ ) {+ // Ctrl+Enter or Cmd+Enter+ // iPad physical keyboard does not offer Command or Ctrl detection+ // so use Alt+Enter+ e.preventDefault();+ this.save(undefined, e);+ }+ },+});