@gravity-ui/markdown-editor 13.11.0 → 13.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,11 +39,12 @@ export interface EventMap {
39
39
  export interface Editor extends Receiver<EventMap>, CommonEditor {
40
40
  readonly currentMode: EditorMode;
41
41
  readonly toolbarVisible: boolean;
42
- setEditorMode(mode: EditorMode): void;
42
+ setEditorMode(mode: EditorMode, opts?: SetEditorModeOptions): void;
43
43
  moveCursor(position: 'start' | 'end' | {
44
44
  line: number;
45
45
  }): void;
46
46
  }
47
+ declare type SetEditorModeOptions = Pick<ChangeEditorModeOptions, 'emit'>;
47
48
  export declare type MarkupConfig = {
48
49
  /** Additional extensions for codemirror instance. */
49
50
  extensions?: CreateCodemirrorParams['extensions'];
@@ -88,3 +89,4 @@ export declare type EditorOptions = Pick<WysiwygEditorOptions, 'allowHTML' | 'li
88
89
  extraMarkupExtensions?: CodemirrorExtension[];
89
90
  markupConfig?: MarkupConfig;
90
91
  };
92
+ export {};
@@ -195,15 +195,16 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
195
195
  tslib_1.__classPrivateFieldSet(this, _EditorImpl_markupEditor, undefined, "f");
196
196
  tslib_1.__classPrivateFieldSet(this, _EditorImpl_wysiwygEditor, undefined, "f");
197
197
  }
198
- setEditorMode(mode) {
199
- this.changeEditorMode({ mode, reason: 'manually' });
198
+ setEditorMode(mode, opts) {
199
+ this.changeEditorMode({ mode, reason: 'manually', emit: opts === null || opts === void 0 ? void 0 : opts.emit });
200
200
  }
201
- changeEditorMode(opts) {
201
+ changeEditorMode(_a) {
202
+ var { emit = true } = _a, opts = tslib_1.__rest(_a, ["emit"]);
202
203
  if (tslib_1.__classPrivateFieldGet(this, _EditorImpl_editorMode, "f") === opts.mode)
203
204
  return;
204
205
  this.currentMode = opts.mode;
205
206
  this.emit('rerender', null);
206
- if (opts.reason !== 'error-boundary') {
207
+ if (emit) {
207
208
  this.emit('change-editor-mode', opts);
208
209
  }
209
210
  }
@@ -90,7 +90,11 @@ exports.MarkdownEditorView = react_1.default.forwardRef((props, ref) => {
90
90
  });
91
91
  setTimeout(() => {
92
92
  resetErrorBoundary();
93
- editor.changeEditorMode({ mode: 'markup', reason: 'error-boundary' });
93
+ editor.changeEditorMode({
94
+ mode: 'markup',
95
+ reason: 'error-boundary',
96
+ emit: false,
97
+ });
94
98
  });
95
99
  return null;
96
100
  } },
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  /** During build process, the current version will be injected here */
5
- exports.VERSION = typeof '13.11.0' !== 'undefined' ? '13.11.0' : 'unknown';
5
+ exports.VERSION = typeof '13.12.0' !== 'undefined' ? '13.12.0' : 'unknown';
@@ -39,11 +39,12 @@ export interface EventMap {
39
39
  export interface Editor extends Receiver<EventMap>, CommonEditor {
40
40
  readonly currentMode: EditorMode;
41
41
  readonly toolbarVisible: boolean;
42
- setEditorMode(mode: EditorMode): void;
42
+ setEditorMode(mode: EditorMode, opts?: SetEditorModeOptions): void;
43
43
  moveCursor(position: 'start' | 'end' | {
44
44
  line: number;
45
45
  }): void;
46
46
  }
47
+ declare type SetEditorModeOptions = Pick<ChangeEditorModeOptions, 'emit'>;
47
48
  export declare type MarkupConfig = {
48
49
  /** Additional extensions for codemirror instance. */
49
50
  extensions?: CreateCodemirrorParams['extensions'];
@@ -88,3 +89,4 @@ export declare type EditorOptions = Pick<WysiwygEditorOptions, 'allowHTML' | 'li
88
89
  extraMarkupExtensions?: CodemirrorExtension[];
89
90
  markupConfig?: MarkupConfig;
90
91
  };
92
+ export {};
@@ -1,5 +1,5 @@
1
1
  var _EditorImpl_markup, _EditorImpl_editorMode, _EditorImpl_toolbarVisible, _EditorImpl_splitModeEnabled, _EditorImpl_splitMode, _EditorImpl_renderPreview, _EditorImpl_wysiwygEditor, _EditorImpl_markupEditor, _EditorImpl_markupConfig, _EditorImpl_preset, _EditorImpl_allowHTML, _EditorImpl_linkify, _EditorImpl_linkifyTlds, _EditorImpl_extensions, _EditorImpl_renderStorage, _EditorImpl_fileUploadHandler, _EditorImpl_needToSetDimensionsForUploadedImages, _EditorImpl_prepareRawMarkup;
2
- import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet, __rest } from "tslib";
3
3
  import { TextSelection } from 'prosemirror-state';
4
4
  import { WysiwygEditor } from '../core';
5
5
  import { i18n } from '../i18n/bundle';
@@ -192,15 +192,16 @@ export class EditorImpl extends SafeEventEmitter {
192
192
  __classPrivateFieldSet(this, _EditorImpl_markupEditor, undefined, "f");
193
193
  __classPrivateFieldSet(this, _EditorImpl_wysiwygEditor, undefined, "f");
194
194
  }
195
- setEditorMode(mode) {
196
- this.changeEditorMode({ mode, reason: 'manually' });
195
+ setEditorMode(mode, opts) {
196
+ this.changeEditorMode({ mode, reason: 'manually', emit: opts === null || opts === void 0 ? void 0 : opts.emit });
197
197
  }
198
- changeEditorMode(opts) {
198
+ changeEditorMode(_a) {
199
+ var { emit = true } = _a, opts = __rest(_a, ["emit"]);
199
200
  if (__classPrivateFieldGet(this, _EditorImpl_editorMode, "f") === opts.mode)
200
201
  return;
201
202
  this.currentMode = opts.mode;
202
203
  this.emit('rerender', null);
203
- if (opts.reason !== 'error-boundary') {
204
+ if (emit) {
204
205
  this.emit('change-editor-mode', opts);
205
206
  }
206
207
  }
@@ -87,7 +87,11 @@ export const MarkdownEditorView = React.forwardRef((props, ref) => {
87
87
  });
88
88
  setTimeout(() => {
89
89
  resetErrorBoundary();
90
- editor.changeEditorMode({ mode: 'markup', reason: 'error-boundary' });
90
+ editor.changeEditorMode({
91
+ mode: 'markup',
92
+ reason: 'error-boundary',
93
+ emit: false,
94
+ });
91
95
  });
92
96
  return null;
93
97
  } },
@@ -1,2 +1,2 @@
1
1
  /** During build process, the current version will be injected here */
2
- export const VERSION = typeof '13.11.0' !== 'undefined' ? '13.11.0' : 'unknown';
2
+ export const VERSION = typeof '13.12.0' !== 'undefined' ? '13.12.0' : 'unknown';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/markdown-editor",
3
- "version": "13.11.0",
3
+ "version": "13.12.0",
4
4
  "description": "Markdown wysiwyg and markup editor",
5
5
  "license": "MIT",
6
6
  "repository": {