Skip to content

Commit b6b61f8

Browse files
authored
feat(markup): added ability to override default placeholder in markup mode (#376)
1 parent ac0028f commit b6b61f8

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/bundle/Editor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ export type MarkupConfig = {
118118
disabledExtensions?: CreateCodemirrorParams['disabledExtensions'];
119119
/** Additional keymaps for codemirror instance */
120120
keymaps?: CreateCodemirrorParams['keymaps'];
121+
/** Overrides the default placeholder content. */
122+
placeholder?: CreateCodemirrorParams['placeholder'];
121123
/**
122124
* Additional language data for markdown language in codemirror.
123125
* Can be used to configure additional autocompletions and others.
@@ -300,7 +302,7 @@ export class EditorImpl extends SafeEventEmitter<EventMapInt> implements EditorI
300302
this.#markupEditor = new MarkupEditor(
301303
createCodemirror({
302304
doc: this.#markup,
303-
placeholderText: i18n('markup_placeholder'),
305+
placeholder: this.#markupConfig.placeholder ?? i18n('markup_placeholder'),
304306
onCancel: () => this.emit('cancel', null),
305307
onSubmit: () => this.emit('submit', null),
306308
onChange: () => this.emit('rerender-toolbar', null),

src/markup/codemirror/create.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ type Autocompletion = Parameters<typeof autocompletion>[0];
4747

4848
export type CreateCodemirrorParams = {
4949
doc: EditorViewConfig['doc'];
50-
placeholderText: string;
50+
placeholder: Parameters<typeof placeholder>[0];
5151
onCancel: () => void;
5252
onSubmit: () => void;
5353
onChange: () => void;
@@ -69,22 +69,22 @@ export type CreateCodemirrorParams = {
6969
export function createCodemirror(params: CreateCodemirrorParams) {
7070
const {
7171
doc,
72-
placeholderText,
7372
reactRenderer,
7473
onCancel,
7574
onScroll,
7675
onSubmit,
7776
onChange,
7877
onDocChange,
79-
extensions: extraExtensions,
8078
disabledExtensions = {},
8179
keymaps = [],
8280
receiver,
8381
yfmLangOptions,
82+
extensions: extraExtensions,
83+
placeholder: placeholderContent,
8484
autocompletion: autocompletionConfig,
8585
} = params;
8686

87-
const extensions: Extension[] = [gravityTheme, placeholder(placeholderText)];
87+
const extensions: Extension[] = [gravityTheme, placeholder(placeholderContent)];
8888

8989
if (!disabledExtensions.history) {
9090
extensions.push(history());

0 commit comments

Comments
 (0)