@gravity-ui/markdown-editor 13.14.0 → 13.15.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.
@@ -63,6 +63,8 @@ export declare type MarkupConfig = {
63
63
  * See more https://codemirror.net/docs/ref/#state.EditorState.languageDataAt
64
64
  */
65
65
  languageData?: YfmLangOptions['languageData'];
66
+ /** Config for @codemirror/autocomplete https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig */
67
+ autocompletion?: CreateCodemirrorParams['autocompletion'];
66
68
  };
67
69
  export declare type EscapeConfig = {
68
70
  commonEscape?: RegExp;
@@ -165,6 +165,7 @@ class EditorImpl extends event_emitter_1.SafeEventEmitter {
165
165
  disabledExtensions: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").disabledExtensions,
166
166
  keymaps: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").keymaps,
167
167
  yfmLangOptions: { languageData: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").languageData },
168
+ autocompletion: tslib_1.__classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").autocompletion,
168
169
  receiver: this,
169
170
  })), "f");
170
171
  }
@@ -23,12 +23,20 @@ const YfmHeadingSpecs = (builder, opts) => {
23
23
  defining: true,
24
24
  selectable: true,
25
25
  parseDOM: [
26
- { tag: 'h1', getAttrs: (0, utils_1.getNodeAttrs)(1) },
27
- { tag: 'h2', getAttrs: (0, utils_1.getNodeAttrs)(2) },
28
- { tag: 'h3', getAttrs: (0, utils_1.getNodeAttrs)(3) },
29
- { tag: 'h4', getAttrs: (0, utils_1.getNodeAttrs)(4) },
30
- { tag: 'h5', getAttrs: (0, utils_1.getNodeAttrs)(5) },
31
- { tag: 'h6', getAttrs: (0, utils_1.getNodeAttrs)(6) },
26
+ { tag: 'h1', getAttrs: (0, utils_1.getNodeAttrs)(1), priority: 100, consuming: true },
27
+ { tag: 'h2', getAttrs: (0, utils_1.getNodeAttrs)(2), priority: 100, consuming: true },
28
+ { tag: 'h3', getAttrs: (0, utils_1.getNodeAttrs)(3), priority: 100, consuming: true },
29
+ { tag: 'h4', getAttrs: (0, utils_1.getNodeAttrs)(4), priority: 100, consuming: true },
30
+ { tag: 'h5', getAttrs: (0, utils_1.getNodeAttrs)(5), priority: 100, consuming: true },
31
+ { tag: 'h6', getAttrs: (0, utils_1.getNodeAttrs)(6), priority: 100, consuming: true },
32
+ {
33
+ // ignore anchor link inside headings
34
+ tag: 'a.yfm-anchor',
35
+ context: `${const_1.headingNodeName}/`,
36
+ skip: true,
37
+ ignore: true,
38
+ priority: 1000,
39
+ },
32
40
  ],
33
41
  toDOM(node) {
34
42
  const id = node.attrs[const_1.YfmHeadingAttr.Id];
@@ -1,12 +1,9 @@
1
- import { BaseTarget, StylesObject } from '@diplodoc/html-extension/plugin';
1
+ import { PluginOptions } from '@diplodoc/html-extension/plugin/transform';
2
2
  import type { ExtensionNodeSpec } from '../../../../core';
3
3
  export { yfmHtmlBlockNodeName } from './const';
4
- export declare type YfmHtmlBlockSpecsOptions = {
4
+ export interface YfmHtmlBlockSpecsOptions extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle'> {
5
5
  nodeView?: ExtensionNodeSpec['view'];
6
- sanitize?: (dirtyHtml: string) => string;
7
- styles?: string | StylesObject;
8
- baseTarget?: BaseTarget;
9
- };
6
+ }
10
7
  export declare const YfmHtmlBlockSpecs: import("../../../../core").ExtensionWithOptions<YfmHtmlBlockSpecsOptions> & {
11
8
  readonly NodeName: "yfm_html_block";
12
9
  readonly NodeAttrs: typeof import("./const").YfmHtmlBlockAttrs;
@@ -1,14 +1,10 @@
1
- import { BaseTarget, StylesObject } from '@diplodoc/html-extension/plugin';
1
+ import { PluginOptions } from '@diplodoc/html-extension/plugin/transform';
2
2
  import type { IHTMLIFrameElementConfig } from '@diplodoc/html-extension/runtime';
3
3
  import { Action, ExtensionAuto } from '../../../core';
4
4
  import { YfmHtmlBlockAction } from './YfmHtmlBlockSpecs/const';
5
- export declare type YfmHtmlBlockOptions = {
5
+ export interface YfmHtmlBlockOptions extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle'> {
6
6
  useConfig?: () => IHTMLIFrameElementConfig | undefined;
7
- sanitize?: (dirtyHtml: string) => string;
8
- styles?: string | StylesObject;
9
- baseTarget?: BaseTarget;
10
- head?: string;
11
- };
7
+ }
12
8
  export declare const YfmHtmlBlock: ExtensionAuto<YfmHtmlBlockOptions>;
13
9
  declare global {
14
10
  namespace WysiwygEditor {
@@ -1,3 +1,4 @@
1
+ import { autocompletion } from '@codemirror/autocomplete';
1
2
  import type { Extension, StateCommand } from '@codemirror/state';
2
3
  import { EditorView, EditorViewConfig, KeyBinding } from '@codemirror/view';
3
4
  import { EventMap } from '../../bundle/Editor';
@@ -6,6 +7,7 @@ import { Receiver } from '../../utils';
6
7
  import { FileUploadHandler } from './files-upload-facet';
7
8
  import { type YfmLangOptions } from './yfm';
8
9
  export type { YfmLangOptions };
10
+ declare type Autocompletion = Parameters<typeof autocompletion>[0];
9
11
  export declare type CreateCodemirrorParams = {
10
12
  doc: EditorViewConfig['doc'];
11
13
  placeholderText: string;
@@ -24,6 +26,7 @@ export declare type CreateCodemirrorParams = {
24
26
  keymaps?: readonly KeyBinding[];
25
27
  receiver?: Receiver<EventMap>;
26
28
  yfmLangOptions?: YfmLangOptions;
29
+ autocompletion?: Autocompletion;
27
30
  };
28
31
  export declare function createCodemirror(params: CreateCodemirrorParams): EditorView;
29
32
  export declare function withLogger(action: string, command: StateCommand): StateCommand;
@@ -16,7 +16,7 @@ const react_facet_1 = require("./react-facet");
16
16
  const plugin_1 = require("./search-plugin/plugin");
17
17
  const yfm_1 = require("./yfm");
18
18
  function createCodemirror(params) {
19
- const { doc, placeholderText, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, extensions: extraExtensions, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, } = params;
19
+ const { doc, placeholderText, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, extensions: extraExtensions, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, autocompletion: autocompletionConfig, } = params;
20
20
  const extensions = [gravity_1.gravityTheme, (0, view_1.placeholder)(placeholderText)];
21
21
  if (!disabledExtensions.history) {
22
22
  extensions.push((0, commands_1.history)());
@@ -58,7 +58,7 @@ function createCodemirror(params) {
58
58
  ...commands_1.defaultKeymap,
59
59
  ...(disabledExtensions.history ? [] : commands_1.historyKeymap),
60
60
  ...keymaps,
61
- ]), (0, autocomplete_1.autocompletion)(), (0, yfm_1.yfmLang)(yfmLangOptions), react_facet_1.ReactRendererFacet.of(reactRenderer), pairing_chars_1.PairingCharactersExtension, view_1.EditorView.lineWrapping, view_1.EditorView.contentAttributes.of({ spellcheck: 'true' }), view_1.EditorView.domEventHandlers({
61
+ ]), (0, autocomplete_1.autocompletion)(autocompletionConfig), (0, yfm_1.yfmLang)(yfmLangOptions), react_facet_1.ReactRendererFacet.of(reactRenderer), pairing_chars_1.PairingCharactersExtension, view_1.EditorView.lineWrapping, view_1.EditorView.contentAttributes.of({ spellcheck: 'true' }), view_1.EditorView.domEventHandlers({
62
62
  scroll(event) {
63
63
  onScroll(event);
64
64
  },
@@ -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.14.0' !== 'undefined' ? '13.14.0' : 'unknown';
5
+ exports.VERSION = typeof '13.15.0' !== 'undefined' ? '13.15.0' : 'unknown';
@@ -63,6 +63,8 @@ export declare type MarkupConfig = {
63
63
  * See more https://codemirror.net/docs/ref/#state.EditorState.languageDataAt
64
64
  */
65
65
  languageData?: YfmLangOptions['languageData'];
66
+ /** Config for @codemirror/autocomplete https://codemirror.net/docs/ref/#autocomplete.autocompletion%5Econfig */
67
+ autocompletion?: CreateCodemirrorParams['autocompletion'];
66
68
  };
67
69
  export declare type EscapeConfig = {
68
70
  commonEscape?: RegExp;
@@ -162,6 +162,7 @@ export class EditorImpl extends SafeEventEmitter {
162
162
  disabledExtensions: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").disabledExtensions,
163
163
  keymaps: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").keymaps,
164
164
  yfmLangOptions: { languageData: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").languageData },
165
+ autocompletion: __classPrivateFieldGet(this, _EditorImpl_markupConfig, "f").autocompletion,
165
166
  receiver: this,
166
167
  })), "f");
167
168
  }
@@ -19,12 +19,20 @@ export const YfmHeadingSpecs = (builder, opts) => {
19
19
  defining: true,
20
20
  selectable: true,
21
21
  parseDOM: [
22
- { tag: 'h1', getAttrs: getNodeAttrs(1) },
23
- { tag: 'h2', getAttrs: getNodeAttrs(2) },
24
- { tag: 'h3', getAttrs: getNodeAttrs(3) },
25
- { tag: 'h4', getAttrs: getNodeAttrs(4) },
26
- { tag: 'h5', getAttrs: getNodeAttrs(5) },
27
- { tag: 'h6', getAttrs: getNodeAttrs(6) },
22
+ { tag: 'h1', getAttrs: getNodeAttrs(1), priority: 100, consuming: true },
23
+ { tag: 'h2', getAttrs: getNodeAttrs(2), priority: 100, consuming: true },
24
+ { tag: 'h3', getAttrs: getNodeAttrs(3), priority: 100, consuming: true },
25
+ { tag: 'h4', getAttrs: getNodeAttrs(4), priority: 100, consuming: true },
26
+ { tag: 'h5', getAttrs: getNodeAttrs(5), priority: 100, consuming: true },
27
+ { tag: 'h6', getAttrs: getNodeAttrs(6), priority: 100, consuming: true },
28
+ {
29
+ // ignore anchor link inside headings
30
+ tag: 'a.yfm-anchor',
31
+ context: `${headingNodeName}/`,
32
+ skip: true,
33
+ ignore: true,
34
+ priority: 1000,
35
+ },
28
36
  ],
29
37
  toDOM(node) {
30
38
  const id = node.attrs[YfmHeadingAttr.Id];
@@ -1,12 +1,9 @@
1
- import { BaseTarget, StylesObject } from '@diplodoc/html-extension/plugin';
1
+ import { PluginOptions } from '@diplodoc/html-extension/plugin/transform';
2
2
  import type { ExtensionNodeSpec } from '../../../../core';
3
3
  export { yfmHtmlBlockNodeName } from './const';
4
- export declare type YfmHtmlBlockSpecsOptions = {
4
+ export interface YfmHtmlBlockSpecsOptions extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle'> {
5
5
  nodeView?: ExtensionNodeSpec['view'];
6
- sanitize?: (dirtyHtml: string) => string;
7
- styles?: string | StylesObject;
8
- baseTarget?: BaseTarget;
9
- };
6
+ }
10
7
  export declare const YfmHtmlBlockSpecs: import("../../../../core").ExtensionWithOptions<YfmHtmlBlockSpecsOptions> & {
11
8
  readonly NodeName: "yfm_html_block";
12
9
  readonly NodeAttrs: typeof import("./const").YfmHtmlBlockAttrs;
@@ -1,14 +1,10 @@
1
- import { BaseTarget, StylesObject } from '@diplodoc/html-extension/plugin';
1
+ import { PluginOptions } from '@diplodoc/html-extension/plugin/transform';
2
2
  import type { IHTMLIFrameElementConfig } from '@diplodoc/html-extension/runtime';
3
3
  import { Action, ExtensionAuto } from '../../../core';
4
4
  import { YfmHtmlBlockAction } from './YfmHtmlBlockSpecs/const';
5
- export declare type YfmHtmlBlockOptions = {
5
+ export interface YfmHtmlBlockOptions extends Omit<PluginOptions, 'runtimeJsPath' | 'containerClasses' | 'bundle'> {
6
6
  useConfig?: () => IHTMLIFrameElementConfig | undefined;
7
- sanitize?: (dirtyHtml: string) => string;
8
- styles?: string | StylesObject;
9
- baseTarget?: BaseTarget;
10
- head?: string;
11
- };
7
+ }
12
8
  export declare const YfmHtmlBlock: ExtensionAuto<YfmHtmlBlockOptions>;
13
9
  declare global {
14
10
  namespace WysiwygEditor {
@@ -1,3 +1,4 @@
1
+ import { autocompletion } from '@codemirror/autocomplete';
1
2
  import type { Extension, StateCommand } from '@codemirror/state';
2
3
  import { EditorView, EditorViewConfig, KeyBinding } from '@codemirror/view';
3
4
  import { EventMap } from '../../bundle/Editor';
@@ -6,6 +7,7 @@ import { Receiver } from '../../utils';
6
7
  import { FileUploadHandler } from './files-upload-facet';
7
8
  import { type YfmLangOptions } from './yfm';
8
9
  export type { YfmLangOptions };
10
+ declare type Autocompletion = Parameters<typeof autocompletion>[0];
9
11
  export declare type CreateCodemirrorParams = {
10
12
  doc: EditorViewConfig['doc'];
11
13
  placeholderText: string;
@@ -24,6 +26,7 @@ export declare type CreateCodemirrorParams = {
24
26
  keymaps?: readonly KeyBinding[];
25
27
  receiver?: Receiver<EventMap>;
26
28
  yfmLangOptions?: YfmLangOptions;
29
+ autocompletion?: Autocompletion;
27
30
  };
28
31
  export declare function createCodemirror(params: CreateCodemirrorParams): EditorView;
29
32
  export declare function withLogger(action: string, command: StateCommand): StateCommand;
@@ -13,7 +13,7 @@ import { ReactRendererFacet } from './react-facet';
13
13
  import { SearchPanelPlugin } from './search-plugin/plugin';
14
14
  import { yfmLang } from './yfm';
15
15
  export function createCodemirror(params) {
16
- const { doc, placeholderText, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, extensions: extraExtensions, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, } = params;
16
+ const { doc, placeholderText, reactRenderer, onCancel, onScroll, onSubmit, onChange, onDocChange, extensions: extraExtensions, disabledExtensions = {}, keymaps = [], receiver, yfmLangOptions, autocompletion: autocompletionConfig, } = params;
17
17
  const extensions = [gravityTheme, placeholder(placeholderText)];
18
18
  if (!disabledExtensions.history) {
19
19
  extensions.push(history());
@@ -55,7 +55,7 @@ export function createCodemirror(params) {
55
55
  ...defaultKeymap,
56
56
  ...(disabledExtensions.history ? [] : historyKeymap),
57
57
  ...keymaps,
58
- ]), autocompletion(), yfmLang(yfmLangOptions), ReactRendererFacet.of(reactRenderer), PairingCharactersExtension, EditorView.lineWrapping, EditorView.contentAttributes.of({ spellcheck: 'true' }), EditorView.domEventHandlers({
58
+ ]), autocompletion(autocompletionConfig), yfmLang(yfmLangOptions), ReactRendererFacet.of(reactRenderer), PairingCharactersExtension, EditorView.lineWrapping, EditorView.contentAttributes.of({ spellcheck: 'true' }), EditorView.domEventHandlers({
59
59
  scroll(event) {
60
60
  onScroll(event);
61
61
  },
@@ -1,2 +1,2 @@
1
1
  /** During build process, the current version will be injected here */
2
- export const VERSION = typeof '13.14.0' !== 'undefined' ? '13.14.0' : 'unknown';
2
+ export const VERSION = typeof '13.15.0' !== 'undefined' ? '13.15.0' : 'unknown';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/markdown-editor",
3
- "version": "13.14.0",
3
+ "version": "13.15.0",
4
4
  "description": "Markdown wysiwyg and markup editor",
5
5
  "license": "MIT",
6
6
  "repository": {