Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions ui/bits/src/bits.cms.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import * as xhr from 'common/xhr';
import { throttle } from 'common/timing';
import Editor from '@toast-ui/editor';
import { currentTheme } from 'common/theme';
import tablesort from 'tablesort';
import { storedJsonProp } from 'common/storage';
import { Editor, EditorType } from '@toast-ui/editor';

site.load.then(() => {
$('.markdown-editor').each(function (this: HTMLTextAreaElement) {
Expand All @@ -29,13 +30,14 @@ site.load.then(() => {
const setupMarkdownEditor = (el: HTMLTextAreaElement) => {
const postProcess = (markdown: string) => markdown.replace(/<br>/g, '').replace(/\n\s*#\s/g, '\n## ');

const initialEditType = storedJsonProp<EditorType>('markdown.initial-edit-type', () => 'wysiwyg');
const editor: Editor = new Editor({
el,
usageStatistics: false,
height: '60vh',
theme: currentTheme(),
initialValue: $('#form3-markdown').val() as string,
initialEditType: 'wysiwyg',
initialEditType: initialEditType(),
language: $('html').attr('lang') as string,
toolbarItems: [
['heading', 'bold', 'italic', 'strike'],
Expand All @@ -47,7 +49,10 @@ const setupMarkdownEditor = (el: HTMLTextAreaElement) => {
],
autofocus: false,
events: {
change: throttle(500, () => $('#form3-markdown').val(postProcess(editor.getMarkdown()))),
change: throttle(500, (mode: EditorType) => {
$('#form3-markdown').val(postProcess(editor.getMarkdown()));
initialEditType(mode);
}),
},
hooks: {
addImageBlobHook: (blob, cb) => {
Expand Down
11 changes: 8 additions & 3 deletions ui/bits/src/bits.ublogForm.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import * as xhr from 'common/xhr';
import { throttle } from 'common/timing';
import Editor from '@toast-ui/editor';
import { Editor, EditorType } from '@toast-ui/editor';
import Tagify from '@yaireo/tagify';
import { currentTheme } from 'common/theme';
import { wireCropDialog } from './exports/crop';
import { storedJsonProp } from 'common/storage';

site.load.then(() => {
$('.markdown-editor').each(function (this: HTMLTextAreaElement) {
Expand Down Expand Up @@ -35,13 +36,14 @@ const setupTopics = (el: HTMLTextAreaElement) =>
const setupMarkdownEditor = (el: HTMLTextAreaElement) => {
const postProcess = (markdown: string) => markdown.replace(/<br>/g, '').replace(/\n\s*#\s/g, '\n## ');

const initialEditType = storedJsonProp<EditorType>('markdown.initial-edit-type', () => 'wysiwyg');
const editor: Editor = new Editor({
el,
usageStatistics: false,
height: '60vh',
theme: currentTheme(),
initialValue: $('#form3-markdown').val() as string,
initialEditType: 'wysiwyg',
initialEditType: initialEditType(),
language: $('html').attr('lang') as string,
toolbarItems: [
['heading', 'bold', 'italic', 'strike'],
Expand All @@ -53,7 +55,10 @@ const setupMarkdownEditor = (el: HTMLTextAreaElement) => {
],
autofocus: false,
events: {
change: throttle(500, () => $('#form3-markdown').val(postProcess(editor.getMarkdown()))),
change: throttle(500, (mode: EditorType) => {
$('#form3-markdown').val(postProcess(editor.getMarkdown()));
initialEditType(mode);
}),
},
hooks: {
addImageBlobHook: (blob, cb) => {
Expand Down