Skip to content
Open
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
1 change: 1 addition & 0 deletions src/bundle/Editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
export type ToolbarActionData = {
editorMode: EditorMode;
id: string;
attrs?: {[key: string]: any};

Check warning on line 43 in src/bundle/Editor.ts

View workflow job for this annotation

GitHub Actions / Verify Files

Unexpected any. Specify a different type
};

export interface EventMap {
Expand Down Expand Up @@ -71,7 +71,7 @@

moveCursor(position: 'start' | 'end' | {line: number}): void;

/** @internal used in demo for dev-tools */

Check warning on line 74 in src/bundle/Editor.ts

View workflow job for this annotation

GitHub Actions / Verify Files

@internal should be empty
readonly _wysiwygView?: PMEditorView;
}

Expand Down Expand Up @@ -307,6 +307,7 @@
}).concat(this.#markupConfig?.languageData || []),
},
autocompletion: this.#markupConfig.autocompletion,
tooltips: this.#markupConfig.tooltips,
directiveSyntax: this.directiveSyntax,
receiver: this,
searchPanel: this.#markupConfig.searchPanel,
Expand Down
2 changes: 2 additions & 0 deletions src/bundle/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export type MarkdownEditorMarkupConfig = {
languageData?: YfmLangOptions['languageData'];
/** Config for @codemirror/autocomplete https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig */
autocompletion?: CreateCodemirrorParams['autocompletion'];
/** Config for tooltips https://codemirror.net/docs/ref/#view.tooltips */
tooltips?: CreateCodemirrorParams['tooltips'];
/**
* The function, used to determine if the pasted text is the image url and should be inserted as an image
*/
Expand Down
8 changes: 8 additions & 0 deletions src/markup/codemirror/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
type KeyBinding,
keymap,
placeholder,
tooltips,
} from '@codemirror/view';

import {InputState} from 'src/utils/input-state';
Expand Down Expand Up @@ -62,6 +63,7 @@ import {type YfmLangOptions, yfmLang} from './yfm';
export type {YfmLangOptions};

type Autocompletion = Parameters<typeof autocompletion>[0];
type Tooltips = Parameters<typeof tooltips>[0];

const linkRegex = /\[[\s\S]*?]\([\s\S]*?\)/g;

Expand All @@ -88,6 +90,7 @@ export type CreateCodemirrorParams = {
receiver?: Receiver<EventMap>;
yfmLangOptions?: YfmLangOptions;
autocompletion?: Autocompletion;
tooltips?: Tooltips;
directiveSyntax: DirectiveSyntaxContext;
preserveEmptyRows: boolean;
searchPanel?: boolean;
Expand All @@ -110,6 +113,7 @@ export function createCodemirror(params: CreateCodemirrorParams) {
extensions: extraExtensions,
placeholder: placeholderContent,
autocompletion: autocompletionConfig,
tooltips: tooltipsConfig,
parseHtmlOnPaste,
parseInsertedUrlAsImage,
directiveSyntax,
Expand Down Expand Up @@ -317,6 +321,10 @@ export function createCodemirror(params: CreateCodemirrorParams) {
);
}

if (tooltipsConfig) {
extensions.push(tooltips(tooltipsConfig));
}

if (extraExtensions) {
extensions.push(...extraExtensions);
}
Expand Down
Loading