@gravity-ui/markdown-editor 14.12.6 → 14.13.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.
@@ -185,7 +185,8 @@ const YfmHtmlBlockView = ({ onChange, node, getPos, view, options: { useConfig,
185
185
  const head = `<head>${headContent || additional}</head>`;
186
186
  const body = `<body>${(_a = node.attrs[const_1.YfmHtmlBlockConsts.NodeAttrs.srcdoc]) !== null && _a !== void 0 ? _a : ''}</body>`;
187
187
  const html = `<!DOCTYPE html><html>${head}${body}</html>`;
188
- const resultHtml = sanitize ? sanitize(html) : html;
188
+ const sanitizeFunction = typeof sanitize === 'function' ? sanitize : sanitize === null || sanitize === void 0 ? void 0 : sanitize.body;
189
+ const resultHtml = sanitizeFunction ? sanitizeFunction(html) : html;
189
190
  return (react_1.default.createElement("div", { className: b(), onDoubleClick: setEditing },
190
191
  react_1.default.createElement(uikit_1.Label, { className: b('label'), icon: react_1.default.createElement(uikit_1.Icon, { size: 16, data: icons_1.Eye }) }, (0, common_1.i18n)('preview')),
191
192
  react_1.default.createElement(YfmHtmlBlockPreview, { html: resultHtml, "on\u0421lick": handleClick, config: config }),
@@ -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 '14.12.6' !== 'undefined' ? '14.12.6' : 'unknown';
5
+ exports.VERSION = typeof '14.13.0' !== 'undefined' ? '14.13.0' : 'unknown';
@@ -1,4 +1,5 @@
1
1
  import React, { ComponentType, RefAttributes } from 'react';
2
+ import type { HTMLRuntimeConfig } from '@diplodoc/html-extension';
2
3
  import { IHTMLIFrameElementConfig } from '@diplodoc/html-extension/runtime';
3
4
  import type { PluginRuntime, TransformMeta } from '../withMermaid/types';
4
5
  export declare type WithYfmHtmlBlockOptions = {
@@ -7,6 +8,8 @@ export declare type WithYfmHtmlBlockOptions = {
7
8
  export declare type WithYfmHtmlBlockProps = {
8
9
  meta: TransformMeta;
9
10
  yfmHtmlBlockConfig?: IHTMLIFrameElementConfig;
11
+ /** Works only with html-extension dep version 2.7.1 and higher */
12
+ htmlRuntimeConfig?: HTMLRuntimeConfig;
10
13
  };
11
14
  export declare function withYfmHtmlBlock(opts: WithYfmHtmlBlockOptions): <T extends {
12
15
  html: string;
@@ -7,8 +7,8 @@ const react_2 = require("@diplodoc/html-extension/react");
7
7
  const useYfmHtmlBlockRuntime_1 = require("./useYfmHtmlBlockRuntime");
8
8
  function withYfmHtmlBlock(opts) {
9
9
  return (Component) => (0, react_1.forwardRef)(function WithYfmHtml(props, ref) {
10
- const { meta, html, yfmHtmlBlockConfig } = props;
11
- (0, useYfmHtmlBlockRuntime_1.useYfmHtmlBlockRuntime)(meta, opts.runtime);
10
+ const { meta, html, yfmHtmlBlockConfig, htmlRuntimeConfig } = props;
11
+ (0, useYfmHtmlBlockRuntime_1.useYfmHtmlBlockRuntime)(meta, opts.runtime, htmlRuntimeConfig);
12
12
  const yfmHtmlBlock = (0, react_2.useDiplodocEmbeddedContentController)();
13
13
  (0, react_1.useEffect)(() => {
14
14
  if (yfmHtmlBlock) {
@@ -24,10 +24,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.useYfmHtmlBlockRuntime = void 0;
27
+ const utils_1 = require("@diplodoc/html-extension/utils");
27
28
  /** @internal */
28
- function useYfmHtmlBlockRuntime(meta, runtime = '_assets/html-extension.js') {
29
+ function useYfmHtmlBlockRuntime(meta, runtime = '_assets/html-extension.js', htmlRuntimeConfig = {}) {
29
30
  var _a;
30
31
  if ((_a = meta === null || meta === void 0 ? void 0 : meta.script) === null || _a === void 0 ? void 0 : _a.includes(runtime)) {
32
+ // MAJOR: update html-extension peer on ^2.7.1 and remove optional chain
33
+ utils_1.setupRuntimeConfig === null || utils_1.setupRuntimeConfig === void 0 ? void 0 : (0, utils_1.setupRuntimeConfig)(htmlRuntimeConfig);
31
34
  Promise.resolve().then(() => __importStar(require(/* webpackChunkName: "yfm-html-runtime" */ '@diplodoc/html-extension/runtime')));
32
35
  }
33
36
  }
@@ -181,7 +181,8 @@ export const YfmHtmlBlockView = ({ onChange, node, getPos, view, options: { useC
181
181
  const head = `<head>${headContent || additional}</head>`;
182
182
  const body = `<body>${(_a = node.attrs[YfmHtmlBlockConsts.NodeAttrs.srcdoc]) !== null && _a !== void 0 ? _a : ''}</body>`;
183
183
  const html = `<!DOCTYPE html><html>${head}${body}</html>`;
184
- const resultHtml = sanitize ? sanitize(html) : html;
184
+ const sanitizeFunction = typeof sanitize === 'function' ? sanitize : sanitize === null || sanitize === void 0 ? void 0 : sanitize.body;
185
+ const resultHtml = sanitizeFunction ? sanitizeFunction(html) : html;
185
186
  return (React.createElement("div", { className: b(), onDoubleClick: setEditing },
186
187
  React.createElement(Label, { className: b('label'), icon: React.createElement(Icon, { size: 16, data: Eye }) }, i18n('preview')),
187
188
  React.createElement(YfmHtmlBlockPreview, { html: resultHtml, "on\u0421lick": handleClick, config: config }),
@@ -1,2 +1,2 @@
1
1
  /** During build process, the current version will be injected here */
2
- export const VERSION = typeof '14.12.6' !== 'undefined' ? '14.12.6' : 'unknown';
2
+ export const VERSION = typeof '14.13.0' !== 'undefined' ? '14.13.0' : 'unknown';
@@ -1,4 +1,5 @@
1
1
  import React, { ComponentType, RefAttributes } from 'react';
2
+ import type { HTMLRuntimeConfig } from '@diplodoc/html-extension';
2
3
  import { IHTMLIFrameElementConfig } from '@diplodoc/html-extension/runtime';
3
4
  import type { PluginRuntime, TransformMeta } from '../withMermaid/types';
4
5
  export declare type WithYfmHtmlBlockOptions = {
@@ -7,6 +8,8 @@ export declare type WithYfmHtmlBlockOptions = {
7
8
  export declare type WithYfmHtmlBlockProps = {
8
9
  meta: TransformMeta;
9
10
  yfmHtmlBlockConfig?: IHTMLIFrameElementConfig;
11
+ /** Works only with html-extension dep version 2.7.1 and higher */
12
+ htmlRuntimeConfig?: HTMLRuntimeConfig;
10
13
  };
11
14
  export declare function withYfmHtmlBlock(opts: WithYfmHtmlBlockOptions): <T extends {
12
15
  html: string;
@@ -3,8 +3,8 @@ import { useDiplodocEmbeddedContentController } from '@diplodoc/html-extension/r
3
3
  import { useYfmHtmlBlockRuntime } from './useYfmHtmlBlockRuntime';
4
4
  export function withYfmHtmlBlock(opts) {
5
5
  return (Component) => forwardRef(function WithYfmHtml(props, ref) {
6
- const { meta, html, yfmHtmlBlockConfig } = props;
7
- useYfmHtmlBlockRuntime(meta, opts.runtime);
6
+ const { meta, html, yfmHtmlBlockConfig, htmlRuntimeConfig } = props;
7
+ useYfmHtmlBlockRuntime(meta, opts.runtime, htmlRuntimeConfig);
8
8
  const yfmHtmlBlock = useDiplodocEmbeddedContentController();
9
9
  useEffect(() => {
10
10
  if (yfmHtmlBlock) {
@@ -1,7 +1,10 @@
1
+ import { setupRuntimeConfig } from '@diplodoc/html-extension/utils';
1
2
  /** @internal */
2
- export function useYfmHtmlBlockRuntime(meta, runtime = '_assets/html-extension.js') {
3
+ export function useYfmHtmlBlockRuntime(meta, runtime = '_assets/html-extension.js', htmlRuntimeConfig = {}) {
3
4
  var _a;
4
5
  if ((_a = meta === null || meta === void 0 ? void 0 : meta.script) === null || _a === void 0 ? void 0 : _a.includes(runtime)) {
6
+ // MAJOR: update html-extension peer on ^2.7.1 and remove optional chain
7
+ setupRuntimeConfig === null || setupRuntimeConfig === void 0 ? void 0 : setupRuntimeConfig(htmlRuntimeConfig);
5
8
  import(/* webpackChunkName: "yfm-html-runtime" */ '@diplodoc/html-extension/runtime');
6
9
  }
7
10
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/markdown-editor",
3
- "version": "14.12.6",
3
+ "version": "14.13.0",
4
4
  "description": "Markdown wysiwyg and markup editor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -206,7 +206,7 @@
206
206
  "devDependencies": {
207
207
  "@diplodoc/cut-extension": "^0.6.1",
208
208
  "@diplodoc/folding-headings-extension": "0.1.0",
209
- "@diplodoc/html-extension": "^2.5.0",
209
+ "@diplodoc/html-extension": "2.7.1",
210
210
  "@diplodoc/latex-extension": "1.0.3",
211
211
  "@diplodoc/mermaid-extension": "1.2.1",
212
212
  "@diplodoc/tabs-extension": "^3.5.1",