# Opening a reply window via URL

**URL:** https://meta.discourse.org/t/opening-a-reply-window-via-url/44781
**Category:** Feature
**Tags:** composer
**Created:** [5월 25, 2016, 10:21오전 UTC](https://meta.discourse.org/t/opening-a-reply-window-via-url/44781 "2016-05-25T10:21:42Z")
**Posts on this page:** 1
**Showing post:** 18

<div class="post-metadata">

### Author: ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)
#### Post date: [2월 10, 2021, 2:12오후 UTC](https://meta.discourse.org/t/opening-a-reply-window-via-url/44781/18 "2021-02-10T14:12:01Z")

</div>

저는 인스턴스에서 이를 위해 간단한 테마 컴포넌트를 사용합니다. 아래는 제 코드에서 가져온 변형 버전으로, `#reply` 외에도 `#upload`(데스크톱에서 업로드 창을 여는 새 답변)와 `#edit`(위키 OP용)를 지원합니다.

`setTimeout`을 피하고 `draftSequence`를 올바르게 관리하는 것(`topic.draft_sequence`이 맞는지 의문입니다) 등 아직 다듬어야 할 부분이 있으며, 여기에서 최선의 관행이 무엇인지도 정확히 알지 못합니다. 그렇다고 해도 제 환경에서는 잘 작동하고 있습니다.

`/t/[slug]/[id]#reply`와 같은 형태로 어떤 주제(Topic)로 이동하더라도 빈 새 답변이 입력된 컴포저가 열립니다.

사전 입력된 텍스트가 필요하다면 `composer.open`에 전달하는 객체의 `reply` 속성을 설정하면 됩니다. 또한 해당 주제에 이미 초안이 있으면, 이 새 답변을 생성하기 전에 초안을 저장할지 삭제할지 묻게 됩니다 – 원하는 동작이 해당 초안을 이어서 작성하는 것이라면 `draftSequence`가 정확해야 합니다.

```js
<script type="text/discourse-plugin" version="0.4">
  if (/.*#reply$/g.test(document.URL)) {
    const { REPLY } = require('discourse/models/composer').default;
    
    const composer = Discourse. __container__.lookup('controller:composer');
    
    setTimeout(function() {
      const topic = Discourse. __container__.lookup("controller:topic").get("model");
      if (topic) {
        composer.open({
            action: REPLY,
            draftKey: topic.draft_key,
            draftSequence: topic.draft_sequence,
            topic,
        });
      }
    }, 0)
  }
</script>

```

도움이 되길 바랍니다.

---

_[View the full topic](https://meta.discourse.org/t/opening-a-reply-window-via-url/44781)._
