@gravity-ui/markdown-editor 14.0.1 → 14.0.3
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.
- package/build/cjs/bundle/useMarkdownEditor.js +4 -3
- package/build/cjs/core/markdown/MarkdownSerializer.js +1 -1
- package/build/cjs/shortcuts/formatter.js +1 -5
- package/build/cjs/version.js +1 -1
- package/build/esm/bundle/useMarkdownEditor.js +4 -3
- package/build/esm/core/markdown/MarkdownSerializer.js +1 -1
- package/build/esm/shortcuts/formatter.js +1 -5
- package/build/esm/version.js +1 -1
- package/package.json +2 -2
- package/build/cjs/shortcuts/chars.d.ts +0 -2
- package/build/cjs/shortcuts/chars.js +0 -12
- package/build/esm/shortcuts/chars.d.ts +0 -2
- package/build/esm/shortcuts/chars.js +0 -9
|
@@ -14,7 +14,8 @@ function useMarkdownEditor(props, deps = []) {
|
|
|
14
14
|
const breaks = (_a = md.breaks) !== null && _a !== void 0 ? _a : props.breaks;
|
|
15
15
|
const preset = (_b = props.preset) !== null && _b !== void 0 ? _b : 'full';
|
|
16
16
|
const renderStorage = new extensions_1.ReactRenderStorage();
|
|
17
|
-
const
|
|
17
|
+
const uploadFile = (_c = handlers.uploadFile) !== null && _c !== void 0 ? _c : props.fileUploadHandler;
|
|
18
|
+
const needToSetDimensionsForUploadedImages = (_d = experimental.needToSetDimensionsForUploadedImages) !== null && _d !== void 0 ? _d : props.needToSetDimensionsForUploadedImages;
|
|
18
19
|
const extensions = (builder) => {
|
|
19
20
|
var _a;
|
|
20
21
|
const extensionOptions = (_a = wysiwygConfig.extensionOptions) !== null && _a !== void 0 ? _a : props.extensionOptions;
|
|
@@ -24,7 +25,7 @@ function useMarkdownEditor(props, deps = []) {
|
|
|
24
25
|
}, onSubmit: () => {
|
|
25
26
|
editor.emit('submit', null);
|
|
26
27
|
return true;
|
|
27
|
-
}, mdBreaks: breaks, fileUploadHandler:
|
|
28
|
+
}, mdBreaks: breaks, fileUploadHandler: uploadFile, needToSetDimensionsForUploadedImages }));
|
|
28
29
|
{
|
|
29
30
|
const extraExtensions = wysiwygConfig.extensions || props.extraExtensions;
|
|
30
31
|
if (extraExtensions) {
|
|
@@ -33,7 +34,7 @@ function useMarkdownEditor(props, deps = []) {
|
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
return new Editor_1.EditorImpl(Object.assign(Object.assign({}, props), { preset,
|
|
36
|
-
renderStorage, md: Object.assign(Object.assign({}, md), { breaks, html: (
|
|
37
|
+
renderStorage, md: Object.assign(Object.assign({}, md), { breaks, html: (_e = md.html) !== null && _e !== void 0 ? _e : props.allowHTML, linkify: (_f = md.linkify) !== null && _f !== void 0 ? _f : props.linkify, linkifyTlds: (_g = md.linkifyTlds) !== null && _g !== void 0 ? _g : props.linkifyTlds }), initial: Object.assign(Object.assign({}, initial), { markup: (_h = initial.markup) !== null && _h !== void 0 ? _h : props.initialMarkup, mode: (_j = initial.mode) !== null && _j !== void 0 ? _j : props.initialEditorMode, toolbarVisible: (_k = initial.toolbarVisible) !== null && _k !== void 0 ? _k : props.initialToolbarVisible, splitModeEnabled: (_l = initial.splitModeEnabled) !== null && _l !== void 0 ? _l : props.initialSplitModeEnabled }), handlers: Object.assign(Object.assign({}, handlers), { uploadFile }), experimental: Object.assign(Object.assign({}, experimental), { needToSetDimensionsForUploadedImages, prepareRawMarkup: (_m = experimental.prepareRawMarkup) !== null && _m !== void 0 ? _m : props.prepareRawMarkup, beforeEditorModeChange: (_o = experimental.beforeEditorModeChange) !== null && _o !== void 0 ? _o : props.experimental_beforeEditorModeChange }), markupConfig: Object.assign(Object.assign({}, markupConfig), { splitMode: (_p = markupConfig.splitMode) !== null && _p !== void 0 ? _p : props.splitMode, renderPreview: (_q = markupConfig.renderPreview) !== null && _q !== void 0 ? _q : props.renderPreview, extensions: (_r = markupConfig.extensions) !== null && _r !== void 0 ? _r : props.extraMarkupExtensions }), wysiwygConfig: Object.assign(Object.assign({}, wysiwygConfig), { extensions, escapeConfig: (_s = wysiwygConfig.escapeConfig) !== null && _s !== void 0 ? _s : props.escapeConfig }) }));
|
|
37
38
|
}, deps);
|
|
38
39
|
(0, react_1.useLayoutEffect)(() => {
|
|
39
40
|
function onToolbarAction({ editorMode, id }) {
|
|
@@ -313,7 +313,7 @@ class MarkdownSerializerState {
|
|
|
313
313
|
// have special meaning only at the start of the line.
|
|
314
314
|
esc(str, startOfLine) {
|
|
315
315
|
var _a, _b;
|
|
316
|
-
const escRegexp = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.commonEscape) || /[`\^+*\\\|~\[\]\{\}<>\$]/g;
|
|
316
|
+
const escRegexp = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.commonEscape) || /[`\^+*\\\|~\[\]\{\}<>\$_]/g;
|
|
317
317
|
const startOfLineEscRegexp = ((_b = this.options) === null || _b === void 0 ? void 0 : _b.startOfLineEscape) || /^[:#\-*+>]/;
|
|
318
318
|
str = str.replace(escRegexp, '\\$&');
|
|
319
319
|
if (startOfLine)
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
exports.formatter = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const platform_1 = require("../utils/platform");
|
|
7
|
-
const chars_1 = require("./chars");
|
|
8
7
|
const const_1 = require("./const");
|
|
9
8
|
class ShortCutFormatter {
|
|
10
9
|
constructor() {
|
|
@@ -32,10 +31,7 @@ class ShortCutFormatter {
|
|
|
32
31
|
const defs = tslib_1.__classPrivateFieldGet(this, _ShortCutFormatter_map, "f").get(name);
|
|
33
32
|
if (!defs)
|
|
34
33
|
return null;
|
|
35
|
-
return defs
|
|
36
|
-
.map((str) => { var _a; return (_a = chars_1.cmChars[str]) !== null && _a !== void 0 ? _a : str; })
|
|
37
|
-
.sort((a) => (a === const_1.ModKey.Shift ? -1 : 0))
|
|
38
|
-
.join('-');
|
|
34
|
+
return defs.sort((a) => (a === const_1.ModKey.Shift ? -1 : 0)).join('-');
|
|
39
35
|
}
|
|
40
36
|
toView(name) {
|
|
41
37
|
const defs = tslib_1.__classPrivateFieldGet(this, _ShortCutFormatter_map, "f").get(name);
|
package/build/cjs/version.js
CHANGED
|
@@ -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.0.
|
|
5
|
+
exports.VERSION = typeof '14.0.3' !== 'undefined' ? '14.0.3' : 'unknown';
|
|
@@ -11,7 +11,8 @@ export function useMarkdownEditor(props, deps = []) {
|
|
|
11
11
|
const breaks = (_a = md.breaks) !== null && _a !== void 0 ? _a : props.breaks;
|
|
12
12
|
const preset = (_b = props.preset) !== null && _b !== void 0 ? _b : 'full';
|
|
13
13
|
const renderStorage = new ReactRenderStorage();
|
|
14
|
-
const
|
|
14
|
+
const uploadFile = (_c = handlers.uploadFile) !== null && _c !== void 0 ? _c : props.fileUploadHandler;
|
|
15
|
+
const needToSetDimensionsForUploadedImages = (_d = experimental.needToSetDimensionsForUploadedImages) !== null && _d !== void 0 ? _d : props.needToSetDimensionsForUploadedImages;
|
|
15
16
|
const extensions = (builder) => {
|
|
16
17
|
var _a;
|
|
17
18
|
const extensionOptions = (_a = wysiwygConfig.extensionOptions) !== null && _a !== void 0 ? _a : props.extensionOptions;
|
|
@@ -21,7 +22,7 @@ export function useMarkdownEditor(props, deps = []) {
|
|
|
21
22
|
}, onSubmit: () => {
|
|
22
23
|
editor.emit('submit', null);
|
|
23
24
|
return true;
|
|
24
|
-
}, mdBreaks: breaks, fileUploadHandler:
|
|
25
|
+
}, mdBreaks: breaks, fileUploadHandler: uploadFile, needToSetDimensionsForUploadedImages }));
|
|
25
26
|
{
|
|
26
27
|
const extraExtensions = wysiwygConfig.extensions || props.extraExtensions;
|
|
27
28
|
if (extraExtensions) {
|
|
@@ -30,7 +31,7 @@ export function useMarkdownEditor(props, deps = []) {
|
|
|
30
31
|
}
|
|
31
32
|
};
|
|
32
33
|
return new EditorImpl(Object.assign(Object.assign({}, props), { preset,
|
|
33
|
-
renderStorage, md: Object.assign(Object.assign({}, md), { breaks, html: (
|
|
34
|
+
renderStorage, md: Object.assign(Object.assign({}, md), { breaks, html: (_e = md.html) !== null && _e !== void 0 ? _e : props.allowHTML, linkify: (_f = md.linkify) !== null && _f !== void 0 ? _f : props.linkify, linkifyTlds: (_g = md.linkifyTlds) !== null && _g !== void 0 ? _g : props.linkifyTlds }), initial: Object.assign(Object.assign({}, initial), { markup: (_h = initial.markup) !== null && _h !== void 0 ? _h : props.initialMarkup, mode: (_j = initial.mode) !== null && _j !== void 0 ? _j : props.initialEditorMode, toolbarVisible: (_k = initial.toolbarVisible) !== null && _k !== void 0 ? _k : props.initialToolbarVisible, splitModeEnabled: (_l = initial.splitModeEnabled) !== null && _l !== void 0 ? _l : props.initialSplitModeEnabled }), handlers: Object.assign(Object.assign({}, handlers), { uploadFile }), experimental: Object.assign(Object.assign({}, experimental), { needToSetDimensionsForUploadedImages, prepareRawMarkup: (_m = experimental.prepareRawMarkup) !== null && _m !== void 0 ? _m : props.prepareRawMarkup, beforeEditorModeChange: (_o = experimental.beforeEditorModeChange) !== null && _o !== void 0 ? _o : props.experimental_beforeEditorModeChange }), markupConfig: Object.assign(Object.assign({}, markupConfig), { splitMode: (_p = markupConfig.splitMode) !== null && _p !== void 0 ? _p : props.splitMode, renderPreview: (_q = markupConfig.renderPreview) !== null && _q !== void 0 ? _q : props.renderPreview, extensions: (_r = markupConfig.extensions) !== null && _r !== void 0 ? _r : props.extraMarkupExtensions }), wysiwygConfig: Object.assign(Object.assign({}, wysiwygConfig), { extensions, escapeConfig: (_s = wysiwygConfig.escapeConfig) !== null && _s !== void 0 ? _s : props.escapeConfig }) }));
|
|
34
35
|
}, deps);
|
|
35
36
|
useLayoutEffect(() => {
|
|
36
37
|
function onToolbarAction({ editorMode, id }) {
|
|
@@ -309,7 +309,7 @@ export class MarkdownSerializerState {
|
|
|
309
309
|
// have special meaning only at the start of the line.
|
|
310
310
|
esc(str, startOfLine) {
|
|
311
311
|
var _a, _b;
|
|
312
|
-
const escRegexp = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.commonEscape) || /[`\^+*\\\|~\[\]\{\}<>\$]/g;
|
|
312
|
+
const escRegexp = ((_a = this.options) === null || _a === void 0 ? void 0 : _a.commonEscape) || /[`\^+*\\\|~\[\]\{\}<>\$_]/g;
|
|
313
313
|
const startOfLineEscRegexp = ((_b = this.options) === null || _b === void 0 ? void 0 : _b.startOfLineEscape) || /^[:#\-*+>]/;
|
|
314
314
|
str = str.replace(escRegexp, '\\$&');
|
|
315
315
|
if (startOfLine)
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
var _ShortCutFormatter_map;
|
|
2
2
|
import { __classPrivateFieldGet } from "tslib";
|
|
3
3
|
import { isMac } from '../utils/platform';
|
|
4
|
-
import { cmChars } from './chars';
|
|
5
4
|
import { ModKey as MK } from './const';
|
|
6
5
|
class ShortCutFormatter {
|
|
7
6
|
constructor() {
|
|
@@ -29,10 +28,7 @@ class ShortCutFormatter {
|
|
|
29
28
|
const defs = __classPrivateFieldGet(this, _ShortCutFormatter_map, "f").get(name);
|
|
30
29
|
if (!defs)
|
|
31
30
|
return null;
|
|
32
|
-
return defs
|
|
33
|
-
.map((str) => { var _a; return (_a = cmChars[str]) !== null && _a !== void 0 ? _a : str; })
|
|
34
|
-
.sort((a) => (a === MK.Shift ? -1 : 0))
|
|
35
|
-
.join('-');
|
|
31
|
+
return defs.sort((a) => (a === MK.Shift ? -1 : 0)).join('-');
|
|
36
32
|
}
|
|
37
33
|
toView(name) {
|
|
38
34
|
const defs = __classPrivateFieldGet(this, _ShortCutFormatter_map, "f").get(name);
|
package/build/esm/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** During build process, the current version will be injected here */
|
|
2
|
-
export const VERSION = typeof '14.0.
|
|
2
|
+
export const VERSION = typeof '14.0.3' !== 'undefined' ? '14.0.3' : 'unknown';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/markdown-editor",
|
|
3
|
-
"version": "14.0.
|
|
3
|
+
"version": "14.0.3",
|
|
4
4
|
"description": "Markdown wysiwyg and markup editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
"@types/markdown-it": "^12.2.3",
|
|
175
175
|
"base64-arraybuffer": "1.0.2",
|
|
176
176
|
"is-number": "^7.0.0",
|
|
177
|
-
"markdown-it-attrs": "4.
|
|
177
|
+
"markdown-it-attrs": "^4.2.0",
|
|
178
178
|
"markdown-it-color": "^2.1.1",
|
|
179
179
|
"markdown-it-emoji": "2.0.2",
|
|
180
180
|
"markdown-it-ins": "^3.0.1",
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cmChars = void 0;
|
|
4
|
-
const platform_1 = require("../utils/platform");
|
|
5
|
-
const const_1 = require("./const");
|
|
6
|
-
const cmMac = {
|
|
7
|
-
[const_1.ModKey.Mod]: 'cmd',
|
|
8
|
-
};
|
|
9
|
-
const cmPC = {
|
|
10
|
-
[const_1.ModKey.Mod]: 'ctrl',
|
|
11
|
-
};
|
|
12
|
-
exports.cmChars = Object.assign({ [const_1.Key.Esc]: 'Esc' }, ((0, platform_1.isMac)() ? cmMac : cmPC));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { isMac } from '../utils/platform';
|
|
2
|
-
import { Key as K, ModKey as MK } from './const';
|
|
3
|
-
const cmMac = {
|
|
4
|
-
[MK.Mod]: 'cmd',
|
|
5
|
-
};
|
|
6
|
-
const cmPC = {
|
|
7
|
-
[MK.Mod]: 'ctrl',
|
|
8
|
-
};
|
|
9
|
-
export const cmChars = Object.assign({ [K.Esc]: 'Esc' }, (isMac() ? cmMac : cmPC));
|