@gravity-ui/markdown-editor 14.12.4 → 14.12.5
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.
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createDynamicModifiers = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const ts_dedent_1 = tslib_1.__importDefault(require("ts-dedent"));
|
|
4
6
|
const uuid_1 = require("uuid");
|
|
5
7
|
const YFM_TABLE_TOKEN_ATTR = 'data-token-id';
|
|
6
8
|
const YFM_TABLE_NODE_ATTR = 'data-node-id';
|
|
7
|
-
const PARENTS_WITH_AFFECT = ['blockquote', 'yfm_tabs'];
|
|
8
9
|
function createDynamicModifiers(markupManager) {
|
|
9
10
|
return [
|
|
10
11
|
{
|
|
@@ -17,10 +18,12 @@ function createDynamicModifiers(markupManager) {
|
|
|
17
18
|
process: (token, _, rawMarkup) => {
|
|
18
19
|
const { map } = token;
|
|
19
20
|
if (map) {
|
|
20
|
-
const content = rawMarkup.split('\n').slice(map[0], map[1]).join('\n');
|
|
21
|
+
const content = rawMarkup.split('\n').slice(map[0], map[1]).join('\n').trim();
|
|
21
22
|
const tokenId = (0, uuid_1.v5)(content, markupManager.getNamespace());
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
if (/^\s*#\|/.test(content)) {
|
|
24
|
+
token.attrSet(YFM_TABLE_TOKEN_ATTR, tokenId);
|
|
25
|
+
markupManager.setMarkup(tokenId, (0, ts_dedent_1.default)(content));
|
|
26
|
+
}
|
|
24
27
|
}
|
|
25
28
|
return token;
|
|
26
29
|
},
|
|
@@ -53,11 +56,15 @@ function createDynamicModifiers(markupManager) {
|
|
|
53
56
|
* - Falls back to schema-based rendering if the node structure, attributes, or parent elements affect it.
|
|
54
57
|
*/
|
|
55
58
|
process: (state, node, parent, index, callback) => {
|
|
56
|
-
var _a;
|
|
57
59
|
const nodeId = node.attrs[YFM_TABLE_NODE_ATTR];
|
|
58
60
|
const savedNode = markupManager.getNode(nodeId);
|
|
59
|
-
if (
|
|
60
|
-
|
|
61
|
+
if (savedNode === null || savedNode === void 0 ? void 0 : savedNode.eq(node)) {
|
|
62
|
+
const content = markupManager.getMarkup(nodeId) || '';
|
|
63
|
+
state.ensureNewLine();
|
|
64
|
+
state.text(content, false);
|
|
65
|
+
state.ensureNewLine();
|
|
66
|
+
state.closeBlock();
|
|
67
|
+
state.write('\n');
|
|
61
68
|
return;
|
|
62
69
|
}
|
|
63
70
|
callback === null || callback === void 0 ? void 0 : callback(state, node, parent, index);
|
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.12.
|
|
5
|
+
exports.VERSION = typeof '14.12.5' !== 'undefined' ? '14.12.5' : 'unknown';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import dedent from 'ts-dedent';
|
|
1
2
|
import { v5 } from 'uuid';
|
|
2
3
|
const YFM_TABLE_TOKEN_ATTR = 'data-token-id';
|
|
3
4
|
const YFM_TABLE_NODE_ATTR = 'data-node-id';
|
|
4
|
-
const PARENTS_WITH_AFFECT = ['blockquote', 'yfm_tabs'];
|
|
5
5
|
export function createDynamicModifiers(markupManager) {
|
|
6
6
|
return [
|
|
7
7
|
{
|
|
@@ -14,10 +14,12 @@ export function createDynamicModifiers(markupManager) {
|
|
|
14
14
|
process: (token, _, rawMarkup) => {
|
|
15
15
|
const { map } = token;
|
|
16
16
|
if (map) {
|
|
17
|
-
const content = rawMarkup.split('\n').slice(map[0], map[1]).join('\n');
|
|
17
|
+
const content = rawMarkup.split('\n').slice(map[0], map[1]).join('\n').trim();
|
|
18
18
|
const tokenId = v5(content, markupManager.getNamespace());
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
if (/^\s*#\|/.test(content)) {
|
|
20
|
+
token.attrSet(YFM_TABLE_TOKEN_ATTR, tokenId);
|
|
21
|
+
markupManager.setMarkup(tokenId, dedent(content));
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
return token;
|
|
23
25
|
},
|
|
@@ -50,11 +52,15 @@ export function createDynamicModifiers(markupManager) {
|
|
|
50
52
|
* - Falls back to schema-based rendering if the node structure, attributes, or parent elements affect it.
|
|
51
53
|
*/
|
|
52
54
|
process: (state, node, parent, index, callback) => {
|
|
53
|
-
var _a;
|
|
54
55
|
const nodeId = node.attrs[YFM_TABLE_NODE_ATTR];
|
|
55
56
|
const savedNode = markupManager.getNode(nodeId);
|
|
56
|
-
if (
|
|
57
|
-
|
|
57
|
+
if (savedNode === null || savedNode === void 0 ? void 0 : savedNode.eq(node)) {
|
|
58
|
+
const content = markupManager.getMarkup(nodeId) || '';
|
|
59
|
+
state.ensureNewLine();
|
|
60
|
+
state.text(content, false);
|
|
61
|
+
state.ensureNewLine();
|
|
62
|
+
state.closeBlock();
|
|
63
|
+
state.write('\n');
|
|
58
64
|
return;
|
|
59
65
|
}
|
|
60
66
|
callback === null || callback === void 0 ? void 0 : callback(state, node, parent, index);
|
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.12.
|
|
2
|
+
export const VERSION = typeof '14.12.5' !== 'undefined' ? '14.12.5' : 'unknown';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gravity-ui/markdown-editor",
|
|
3
|
-
"version": "14.12.
|
|
3
|
+
"version": "14.12.5",
|
|
4
4
|
"description": "Markdown wysiwyg and markup editor",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -199,6 +199,7 @@
|
|
|
199
199
|
"react-error-boundary": "^3.1.4",
|
|
200
200
|
"react-hotkeys-hook": "4.5.0",
|
|
201
201
|
"react-use": "^17.3.2",
|
|
202
|
+
"ts-dedent": "2.2.0",
|
|
202
203
|
"tslib": "^2.3.1",
|
|
203
204
|
"uuid": "11.0.5"
|
|
204
205
|
},
|
|
@@ -264,7 +265,6 @@
|
|
|
264
265
|
"sass": "^1.64.1",
|
|
265
266
|
"sass-loader": "^13.3.2",
|
|
266
267
|
"stylelint": "15.11.0",
|
|
267
|
-
"ts-dedent": "2.2.0",
|
|
268
268
|
"ts-jest": "^27.0.7",
|
|
269
269
|
"typescript": "^4.5.2"
|
|
270
270
|
},
|