# 기본값을 마크다운 모드로 설정할 수 없음

**URL:** https://meta.discourse.org/t/unable-to-set-default-to-markdown-mode/379243
**Category:** Bug
**Tags:** composer, fixed
**Created:** [8월 18, 2025, 11:49오전 UTC](https://meta.discourse.org/t/unable-to-set-default-to-markdown-mode/379243 "2025-08-18T11:49:01Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![GaurangBlaze](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gaurangblaze/32/279249_2.png) [@GaurangBlaze](https://meta.discourse.org/u/GaurangBlaze)
#### Post date: [8월 19, 2025, 7:08오전 UTC](https://meta.discourse.org/t/unable-to-set-default-to-markdown-mode/379243/2 "2025-08-19T07:08:47Z")

</div>

이어서 말씀드리자면, “wrap\_open” BBCode 토큰을 사용하는 플러그인이 있습니다. 이 토큰은 아직 리치 텍스트 에디터에서 지원되지 않으므로, 당분간 마크다운 모드를 유지하도록 해야 합니다.

이를 보장하기 위해 Claude Sonnet을 사용하여 아래 코드를 생성했습니다. 개선할 수 있는 부분에 대한 피드백(특히 버그가 있는 경우 😅)을 주시면 감사하겠습니다. 다른 포럼 관리자분들에게도 도움이 될 수 있으니 공유합니다. 이 코드는 테마 설정 \> JS (/admin/customize/themes/2/common/js/edit)에 입력합니다:

```js
import {
  apiInitializer
} from "discourse/lib/api";

export default apiInitializer((api) => {
  // Force switch the user's editor to markdown mode
  function switchToMarkdownMode() {
    const currentUser = api.getCurrentUser();

    // User should be signed in if composer was opened
    if (!currentUser) {
      console.error('No user found');
      return;
    }

    // Got this option from here
    // https://github.com/discourse/discourse/blob/f0fc5646dc9bd29b0e814faea490e34800e9b322/app/assets/javascripts/discourse/app/models/user.js#L262C1-L266C4
    const currentMode = currentUser.get('user_option.composition_mode');

    if (currentMode !== 0) {
      // Only switch if not already in markdown mode
      // Example usage: https://github.com/discourse/discourse/blob/87476ce2c18fb8f856dda7ff03804ed5fbb0ff38/app/assets/javascripts/discourse/app/services/user-tips.js#L127
      currentUser.set('user_option.composition_mode', 0);

      // Save the user preference to the server
      currentUser.save(['composition_mode']).then(() => {
        console.log('Successfully switched to markdown mode');
      }).catch((error) => {
        console.error('Failed to update composition mode:', error);
      });

      // Immediately toggle the current composer UI
      setTimeout(() => {
        const toggleButton = document.querySelector('.composer-toggle-switch[data-rich-editor]');
        if (toggleButton) {
          const isRichTextActive = toggleButton.getAttribute('aria-checked') === 'true';
          if (isRichTextActive) {
            toggleButton.click();
            console.log('Toggled current composer to markdown mode');
          }
        }
      }, 100); // Small delay to ensure composer is fully rendered
    } else {
      console.log('Already in markdown mode, no change needed');
    }
  }

  api.onAppEvent('composer:opened', () => {
    switchToMarkdownMode();
  });
});

```

---

_[View the full topic](https://meta.discourse.org/t/unable-to-set-default-to-markdown-mode/379243)._
