decap-cms-widget-markdown 3.2.0 → 3.4.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.
- package/CHANGELOG.md +16 -0
- package/dist/decap-cms-widget-markdown.js +5 -5
- package/dist/decap-cms-widget-markdown.js.LICENSE.txt +5 -5
- package/dist/decap-cms-widget-markdown.js.map +1 -1
- package/dist/esm/MarkdownControl/RawEditor.js +36 -44
- package/dist/esm/MarkdownControl/Toolbar.js +75 -86
- package/dist/esm/MarkdownControl/ToolbarButton.js +16 -23
- package/dist/esm/MarkdownControl/VisualEditor.js +87 -96
- package/dist/esm/MarkdownControl/components/Shortcode.js +28 -40
- package/dist/esm/MarkdownControl/components/VoidBlock.js +18 -23
- package/dist/esm/MarkdownControl/index.js +54 -59
- package/dist/esm/MarkdownControl/plugins/BreakToDefaultBlock.js +3 -10
- package/dist/esm/MarkdownControl/plugins/CloseBlock.js +3 -10
- package/dist/esm/MarkdownControl/plugins/CommandsAndQueries.js +9 -16
- package/dist/esm/MarkdownControl/plugins/ForceInsert.js +1 -7
- package/dist/esm/MarkdownControl/plugins/Hotkey.js +4 -11
- package/dist/esm/MarkdownControl/plugins/LineBreak.js +3 -10
- package/dist/esm/MarkdownControl/plugins/Link.js +1 -7
- package/dist/esm/MarkdownControl/plugins/blocks/defaultEmptyBlock.js +1 -7
- package/dist/esm/MarkdownControl/plugins/blocks/events/keyDown.js +18 -25
- package/dist/esm/MarkdownControl/plugins/blocks/events/keyDownBackspace.js +11 -18
- package/dist/esm/MarkdownControl/plugins/blocks/events/keyDownEnter.js +9 -16
- package/dist/esm/MarkdownControl/plugins/blocks/events/toggleBlock.js +11 -18
- package/dist/esm/MarkdownControl/plugins/blocks/locations/areCurrentAndPreviousBlocksOfType.js +5 -12
- package/dist/esm/MarkdownControl/plugins/blocks/locations/getListTypeAtCursor.js +4 -11
- package/dist/esm/MarkdownControl/plugins/blocks/locations/isCursorAtEndOfParagraph.js +5 -12
- package/dist/esm/MarkdownControl/plugins/blocks/locations/isCursorAtStartOfBlockType.js +5 -12
- package/dist/esm/MarkdownControl/plugins/blocks/locations/isCursorAtStartOfNonEmptyHeading.js +5 -11
- package/dist/esm/MarkdownControl/plugins/blocks/locations/isCursorCollapsedAfterSoftBreak.js +4 -10
- package/dist/esm/MarkdownControl/plugins/blocks/locations/isCursorInBlockType.js +4 -10
- package/dist/esm/MarkdownControl/plugins/blocks/locations/isCursorInNonDefaultBlock.js +5 -11
- package/dist/esm/MarkdownControl/plugins/blocks/transforms/splitIntoParagraph.js +6 -12
- package/dist/esm/MarkdownControl/plugins/blocks/transforms/unwrapIfCursorAtStart.js +12 -19
- package/dist/esm/MarkdownControl/plugins/blocks/transforms/wrapListItemsInBlock.js +7 -13
- package/dist/esm/MarkdownControl/plugins/blocks/withBlocks.js +5 -12
- package/dist/esm/MarkdownControl/plugins/html/withHtml.js +29 -14
- package/dist/esm/MarkdownControl/plugins/inlines/events/keyDown.js +11 -18
- package/dist/esm/MarkdownControl/plugins/inlines/events/keyDownShiftEnter.js +5 -11
- package/dist/esm/MarkdownControl/plugins/inlines/events/toggleLink.js +8 -16
- package/dist/esm/MarkdownControl/plugins/inlines/events/toggleMark.js +6 -13
- package/dist/esm/MarkdownControl/plugins/inlines/locations/isMarkActive.js +3 -9
- package/dist/esm/MarkdownControl/plugins/inlines/selectors/getActiveLink.js +4 -11
- package/dist/esm/MarkdownControl/plugins/inlines/transforms/unwrapLink.js +4 -11
- package/dist/esm/MarkdownControl/plugins/inlines/transforms/wrapLink.js +11 -18
- package/dist/esm/MarkdownControl/plugins/inlines/withInlines.js +3 -10
- package/dist/esm/MarkdownControl/plugins/lists/events/keyDown.js +14 -21
- package/dist/esm/MarkdownControl/plugins/lists/events/keyDownBackspace.js +11 -18
- package/dist/esm/MarkdownControl/plugins/lists/events/keyDownEnter.js +18 -25
- package/dist/esm/MarkdownControl/plugins/lists/events/keyDownShiftTab.js +13 -23
- package/dist/esm/MarkdownControl/plugins/lists/events/keyDownTab.js +15 -26
- package/dist/esm/MarkdownControl/plugins/lists/events/toggleListType.js +11 -18
- package/dist/esm/MarkdownControl/plugins/lists/locations/isCursorAtListItemStart.js +3 -9
- package/dist/esm/MarkdownControl/plugins/lists/locations/isCursorAtNoninitialParagraphStart.js +3 -9
- package/dist/esm/MarkdownControl/plugins/lists/locations/isCursorInItemContainingNestedList.js +3 -10
- package/dist/esm/MarkdownControl/plugins/lists/locations/isCursorInListItem.js +4 -10
- package/dist/esm/MarkdownControl/plugins/lists/locations/isSelectionWithinNoninitialListItem.js +4 -10
- package/dist/esm/MarkdownControl/plugins/lists/selectors/getListContainedInListItem.js +5 -12
- package/dist/esm/MarkdownControl/plugins/lists/selectors/getLowestAncestorList.js +4 -11
- package/dist/esm/MarkdownControl/plugins/lists/selectors/getLowestAncestorQuote.js +4 -11
- package/dist/esm/MarkdownControl/plugins/lists/transforms/changeListType.js +8 -15
- package/dist/esm/MarkdownControl/plugins/lists/transforms/convertParagraphToListItem.js +8 -15
- package/dist/esm/MarkdownControl/plugins/lists/transforms/liftFirstMatchedParent.js +6 -16
- package/dist/esm/MarkdownControl/plugins/lists/transforms/liftListItem.js +13 -20
- package/dist/esm/MarkdownControl/plugins/lists/transforms/mergeWithPreviousListItem.js +6 -13
- package/dist/esm/MarkdownControl/plugins/lists/transforms/moveListToListItem.js +3 -9
- package/dist/esm/MarkdownControl/plugins/lists/transforms/splitListItem.js +12 -19
- package/dist/esm/MarkdownControl/plugins/lists/transforms/splitToNestedList.js +11 -18
- package/dist/esm/MarkdownControl/plugins/lists/transforms/unwrapFirstMatchedParent.js +4 -11
- package/dist/esm/MarkdownControl/plugins/lists/transforms/unwrapSelectionFromList.js +9 -20
- package/dist/esm/MarkdownControl/plugins/lists/transforms/wrapFirstMatchedParent.js +4 -11
- package/dist/esm/MarkdownControl/plugins/lists/transforms/wrapSelectionInList.js +8 -15
- package/dist/esm/MarkdownControl/plugins/lists/withLists.js +19 -26
- package/dist/esm/MarkdownControl/plugins/matchers/lowestMatchedAncestor.js +3 -10
- package/dist/esm/MarkdownControl/plugins/matchers/matchLink.js +3 -9
- package/dist/esm/MarkdownControl/plugins/matchers/matchedAncestors.js +3 -9
- package/dist/esm/MarkdownControl/plugins/shortcodes/insertShortcode.js +6 -13
- package/dist/esm/MarkdownControl/plugins/shortcodes/locations/isCursorInEmptyParagraph.js +5 -11
- package/dist/esm/MarkdownControl/plugins/shortcodes/withShortcodes.js +5 -12
- package/dist/esm/MarkdownControl/plugins/util.js +5 -12
- package/dist/esm/MarkdownControl/renderers.js +90 -102
- package/dist/esm/MarkdownPreview.js +21 -27
- package/dist/esm/index.js +13 -24
- package/dist/esm/regexHelper.js +6 -14
- package/dist/esm/schema.js +1 -7
- package/dist/esm/serializers/index.js +46 -57
- package/dist/esm/serializers/rehypePaperEmoji.js +1 -7
- package/dist/esm/serializers/remarkAllowHtmlEntities.js +1 -7
- package/dist/esm/serializers/remarkAssertParents.js +20 -29
- package/dist/esm/serializers/remarkEscapeMarkdownEntities.js +22 -28
- package/dist/esm/serializers/remarkImagesToText.js +4 -14
- package/dist/esm/serializers/remarkPaddedLinks.js +22 -32
- package/dist/esm/serializers/remarkRehypeShortcodes.js +17 -26
- package/dist/esm/serializers/remarkShortcodes.js +3 -11
- package/dist/esm/serializers/remarkSlate.js +65 -64
- package/dist/esm/serializers/remarkSquashReferences.js +15 -25
- package/dist/esm/serializers/remarkStripTrailingBreaks.js +3 -9
- package/dist/esm/serializers/remarkWrapHtml.js +3 -9
- package/dist/esm/serializers/slateRemark.js +69 -75
- package/dist/esm/styles.js +5 -12
- package/dist/esm/types.js +2 -8
- package/package.json +6 -6
- package/src/MarkdownControl/RawEditor.js +2 -1
- package/src/MarkdownControl/Toolbar.js +5 -0
- package/src/MarkdownControl/VisualEditor.js +3 -2
- package/src/MarkdownControl/components/Shortcode.js +1 -1
- package/src/MarkdownControl/index.js +9 -0
- package/src/MarkdownControl/plugins/CommandsAndQueries.js +3 -1
- package/src/MarkdownControl/plugins/html/withHtml.js +19 -0
- package/src/MarkdownControl/plugins/util.js +2 -1
- package/src/MarkdownPreview.js +5 -0
- package/src/__tests__/renderer.spec.js +84 -117
- package/src/regexHelper.js +1 -1
- package/src/serializers/__tests__/commonmark.spec.js +1 -1
- package/src/serializers/__tests__/slate.spec.js +1 -1
- package/src/serializers/index.js +1 -1
- package/src/serializers/remarkAssertParents.js +4 -1
- package/src/serializers/remarkEscapeMarkdownEntities.js +4 -1
- package/src/serializers/remarkPaddedLinks.js +7 -1
- package/src/serializers/remarkRehypeShortcodes.js +2 -1
- package/src/serializers/remarkSlate.js +6 -1
- package/src/serializers/remarkSquashReferences.js +2 -1
- package/src/serializers/slateRemark.js +6 -1
- package/src/__tests__/__snapshots__/renderer.spec.js.snap +0 -239
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import find from 'lodash/find';
|
|
2
|
+
import findLast from 'lodash/findLast';
|
|
3
|
+
import startsWith from 'lodash/startsWith';
|
|
4
|
+
import endsWith from 'lodash/endsWith';
|
|
5
|
+
import trimStart from 'lodash/trimStart';
|
|
6
|
+
import trimEnd from 'lodash/trimEnd';
|
|
7
|
+
import flatMap from 'lodash/flatMap';
|
|
8
|
+
import u from 'unist-builder';
|
|
9
|
+
import toString from 'mdast-util-to-string';
|
|
2
10
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remarkPaddedLinks;
|
|
7
|
-
var _flatMap2 = _interopRequireDefault(require("lodash/flatMap"));
|
|
8
|
-
var _trimEnd2 = _interopRequireDefault(require("lodash/trimEnd"));
|
|
9
|
-
var _trimStart2 = _interopRequireDefault(require("lodash/trimStart"));
|
|
10
|
-
var _endsWith2 = _interopRequireDefault(require("lodash/endsWith"));
|
|
11
|
-
var _startsWith2 = _interopRequireDefault(require("lodash/startsWith"));
|
|
12
|
-
var _findLast2 = _interopRequireDefault(require("lodash/findLast"));
|
|
13
|
-
var _find2 = _interopRequireDefault(require("lodash/find"));
|
|
14
|
-
var _unistBuilder = _interopRequireDefault(require("unist-builder"));
|
|
15
|
-
var _mdastUtilToString = _interopRequireDefault(require("mdast-util-to-string"));
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
18
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
19
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
20
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
21
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
22
11
|
/**
|
|
23
12
|
* Convert leading and trailing spaces in a link to single spaces outside of the
|
|
24
13
|
* link. MDASTs derived from pasted Google Docs HTML require this treatment.
|
|
@@ -28,7 +17,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
28
17
|
* parent (link) node and its children at once, rather than just processing
|
|
29
18
|
* children one at a time.
|
|
30
19
|
*/
|
|
31
|
-
function remarkPaddedLinks() {
|
|
20
|
+
export default function remarkPaddedLinks() {
|
|
32
21
|
function transform(node) {
|
|
33
22
|
/**
|
|
34
23
|
* Because we're operating on link nodes and their children at once, we can
|
|
@@ -47,15 +36,16 @@ function remarkPaddedLinks() {
|
|
|
47
36
|
* this seems unlikely to produce a noticeable perf gain.
|
|
48
37
|
*/
|
|
49
38
|
const hasLinkChild = node.children.some(child => child.type === 'link');
|
|
50
|
-
const processedChildren = hasLinkChild ? (
|
|
39
|
+
const processedChildren = hasLinkChild ? flatMap(node.children, transformChildren) : node.children;
|
|
51
40
|
|
|
52
41
|
/**
|
|
53
42
|
* Run all children through the transform recursively.
|
|
54
43
|
*/
|
|
55
44
|
const children = processedChildren.map(transform);
|
|
56
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
...node,
|
|
57
47
|
children
|
|
58
|
-
}
|
|
48
|
+
};
|
|
59
49
|
}
|
|
60
50
|
function transformChildren(node) {
|
|
61
51
|
if (node.type !== 'link') return node;
|
|
@@ -64,9 +54,9 @@ function remarkPaddedLinks() {
|
|
|
64
54
|
* Get the node's complete string value, check for leading and trailing
|
|
65
55
|
* whitespace, and get nodes from each edge where whitespace is found.
|
|
66
56
|
*/
|
|
67
|
-
const text = (
|
|
68
|
-
const leadingWhitespaceNode = (
|
|
69
|
-
const trailingWhitespaceNode = (
|
|
57
|
+
const text = toString(node);
|
|
58
|
+
const leadingWhitespaceNode = startsWith(text, ' ') && getEdgeTextChild(node);
|
|
59
|
+
const trailingWhitespaceNode = endsWith(text, ' ') && getEdgeTextChild(node, true);
|
|
70
60
|
if (!leadingWhitespaceNode && !trailingWhitespaceNode) return node;
|
|
71
61
|
|
|
72
62
|
/**
|
|
@@ -75,17 +65,17 @@ function remarkPaddedLinks() {
|
|
|
75
65
|
* ASTs.
|
|
76
66
|
*/
|
|
77
67
|
if (leadingWhitespaceNode) {
|
|
78
|
-
leadingWhitespaceNode.value = (
|
|
68
|
+
leadingWhitespaceNode.value = trimStart(leadingWhitespaceNode.value);
|
|
79
69
|
}
|
|
80
70
|
if (trailingWhitespaceNode) {
|
|
81
|
-
trailingWhitespaceNode.value = (
|
|
71
|
+
trailingWhitespaceNode.value = trimEnd(trailingWhitespaceNode.value);
|
|
82
72
|
}
|
|
83
73
|
|
|
84
74
|
/**
|
|
85
75
|
* Create an array of nodes. The first and last child will either be `false`
|
|
86
76
|
* or a text node. We filter out the false values before returning.
|
|
87
77
|
*/
|
|
88
|
-
const nodes = [leadingWhitespaceNode && (
|
|
78
|
+
const nodes = [leadingWhitespaceNode && u('text', ' '), node, trailingWhitespaceNode && u('text', ' ')];
|
|
89
79
|
return nodes.filter(val => val);
|
|
90
80
|
}
|
|
91
81
|
|
|
@@ -102,9 +92,9 @@ function remarkPaddedLinks() {
|
|
|
102
92
|
*/
|
|
103
93
|
let findFn;
|
|
104
94
|
if (end) {
|
|
105
|
-
findFn =
|
|
95
|
+
findFn = findLast;
|
|
106
96
|
} else {
|
|
107
|
-
findFn =
|
|
97
|
+
findFn = find;
|
|
108
98
|
}
|
|
109
99
|
let edgeChildWithValue;
|
|
110
100
|
setEdgeChildWithValue(node);
|
|
@@ -1,37 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import map from 'lodash/map';
|
|
3
|
+
import has from 'lodash/has';
|
|
4
|
+
import { renderToString } from 'react-dom/server';
|
|
5
|
+
import u from 'unist-builder';
|
|
2
6
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remarkToRehypeShortcodes;
|
|
7
|
-
var _has2 = _interopRequireDefault(require("lodash/has"));
|
|
8
|
-
var _map2 = _interopRequireDefault(require("lodash/map"));
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _server = require("react-dom/server");
|
|
11
|
-
var _unistBuilder = _interopRequireDefault(require("unist-builder"));
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
14
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
15
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
17
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
18
7
|
/**
|
|
19
8
|
* This plugin doesn't actually transform Remark (MDAST) nodes to Rehype
|
|
20
9
|
* (HAST) nodes, but rather, it prepares an MDAST shortcode node for HAST
|
|
21
10
|
* conversion by replacing the shortcode text with stringified HTML for
|
|
22
11
|
* previewing the shortcode output.
|
|
23
12
|
*/
|
|
24
|
-
function remarkToRehypeShortcodes({
|
|
13
|
+
export default function remarkToRehypeShortcodes({
|
|
25
14
|
plugins,
|
|
26
15
|
getAsset,
|
|
27
16
|
resolveWidget
|
|
28
17
|
}) {
|
|
29
18
|
return transform;
|
|
30
19
|
function transform(root) {
|
|
31
|
-
const transformedChildren = (
|
|
32
|
-
return
|
|
20
|
+
const transformedChildren = map(root.children, processShortcodes);
|
|
21
|
+
return {
|
|
22
|
+
...root,
|
|
33
23
|
children: transformedChildren
|
|
34
|
-
}
|
|
24
|
+
};
|
|
35
25
|
}
|
|
36
26
|
|
|
37
27
|
/**
|
|
@@ -41,7 +31,7 @@ function remarkToRehypeShortcodes({
|
|
|
41
31
|
/**
|
|
42
32
|
* If the node doesn't contain shortcode data, return the original node.
|
|
43
33
|
*/
|
|
44
|
-
if (!(
|
|
34
|
+
if (!has(node, ['data', 'shortcode'])) return node;
|
|
45
35
|
|
|
46
36
|
/**
|
|
47
37
|
* Get shortcode data from the node, and retrieve the matching plugin by
|
|
@@ -59,16 +49,17 @@ function remarkToRehypeShortcodes({
|
|
|
59
49
|
* render it to an HTML string.
|
|
60
50
|
*/
|
|
61
51
|
const value = getPreview(plugin, shortcodeData);
|
|
62
|
-
const valueHtml = typeof value === 'string' ? value :
|
|
52
|
+
const valueHtml = typeof value === 'string' ? value : renderToString(value);
|
|
63
53
|
|
|
64
54
|
/**
|
|
65
55
|
* Return a new 'html' type node containing the shortcode preview markup.
|
|
66
56
|
*/
|
|
67
|
-
const textNode = (
|
|
57
|
+
const textNode = u('html', valueHtml);
|
|
68
58
|
const children = [textNode];
|
|
69
|
-
return
|
|
59
|
+
return {
|
|
60
|
+
...node,
|
|
70
61
|
children
|
|
71
|
-
}
|
|
62
|
+
};
|
|
72
63
|
}
|
|
73
64
|
|
|
74
65
|
/**
|
|
@@ -84,7 +75,7 @@ function remarkToRehypeShortcodes({
|
|
|
84
75
|
return toPreview(shortcodeData, getAsset, fields);
|
|
85
76
|
}
|
|
86
77
|
const preview = resolveWidget(widget);
|
|
87
|
-
return /*#__PURE__*/
|
|
78
|
+
return /*#__PURE__*/React.createElement(preview.preview, {
|
|
88
79
|
value: shortcodeData,
|
|
89
80
|
field: plugin,
|
|
90
81
|
getAsset
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createRemarkShortcodeStringifier = createRemarkShortcodeStringifier;
|
|
7
|
-
exports.getLinesWithOffsets = getLinesWithOffsets;
|
|
8
|
-
exports.remarkParseShortcodes = remarkParseShortcodes;
|
|
9
|
-
function remarkParseShortcodes({
|
|
1
|
+
export function remarkParseShortcodes({
|
|
10
2
|
plugins
|
|
11
3
|
}) {
|
|
12
4
|
const Parser = this.Parser;
|
|
@@ -17,7 +9,7 @@ function remarkParseShortcodes({
|
|
|
17
9
|
});
|
|
18
10
|
methods.unshift('shortcode');
|
|
19
11
|
}
|
|
20
|
-
function getLinesWithOffsets(value) {
|
|
12
|
+
export function getLinesWithOffsets(value) {
|
|
21
13
|
const SEPARATOR = '\n\n';
|
|
22
14
|
const splitted = value.split(SEPARATOR);
|
|
23
15
|
const trimmedLines = splitted.reduce((acc, line) => {
|
|
@@ -105,7 +97,7 @@ function createShortcodeTokenizer({
|
|
|
105
97
|
}
|
|
106
98
|
};
|
|
107
99
|
}
|
|
108
|
-
function createRemarkShortcodeStringifier({
|
|
100
|
+
export function createRemarkShortcodeStringifier({
|
|
109
101
|
plugins
|
|
110
102
|
}) {
|
|
111
103
|
return function remarkStringifyShortcodes() {
|
|
@@ -1,22 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import isEmpty from 'lodash/isEmpty';
|
|
2
|
+
import isArray from 'lodash/isArray';
|
|
3
|
+
import flatMap from 'lodash/flatMap';
|
|
4
|
+
import map from 'lodash/map';
|
|
5
|
+
import flatten from 'lodash/flatten';
|
|
6
|
+
import isEqual from 'lodash/isEqual';
|
|
2
7
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remarkToSlate;
|
|
7
|
-
exports.mergeAdjacentTexts = mergeAdjacentTexts;
|
|
8
|
-
var _isEqual2 = _interopRequireDefault(require("lodash/isEqual"));
|
|
9
|
-
var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
|
|
10
|
-
var _map2 = _interopRequireDefault(require("lodash/map"));
|
|
11
|
-
var _flatMap2 = _interopRequireDefault(require("lodash/flatMap"));
|
|
12
|
-
var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
|
|
13
|
-
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
19
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
20
8
|
/**
|
|
21
9
|
* Map of MDAST node types to Slate node types.
|
|
22
10
|
*/
|
|
@@ -48,9 +36,9 @@ function isText(node) {
|
|
|
48
36
|
return !!node.text;
|
|
49
37
|
}
|
|
50
38
|
function isMarksEqual(node1, node2) {
|
|
51
|
-
return (
|
|
39
|
+
return isEqual(node1.marks, node2.marks);
|
|
52
40
|
}
|
|
53
|
-
function mergeAdjacentTexts(children) {
|
|
41
|
+
export function mergeAdjacentTexts(children) {
|
|
54
42
|
if (children.length <= 0) {
|
|
55
43
|
return children;
|
|
56
44
|
}
|
|
@@ -64,9 +52,10 @@ function mergeAdjacentTexts(children) {
|
|
|
64
52
|
const next = children[i + 1];
|
|
65
53
|
if (isText(current) && isText(next) && isMarksEqual(current, next)) {
|
|
66
54
|
isMerging = true;
|
|
67
|
-
current =
|
|
55
|
+
current = {
|
|
56
|
+
...current,
|
|
68
57
|
text: `${current.text}${next.text}`
|
|
69
|
-
}
|
|
58
|
+
};
|
|
70
59
|
} else {
|
|
71
60
|
mergedChildren.push(current);
|
|
72
61
|
isMerging = false;
|
|
@@ -84,7 +73,7 @@ function mergeAdjacentTexts(children) {
|
|
|
84
73
|
* A Remark plugin for converting an MDAST to Slate Raw AST. Remark plugins
|
|
85
74
|
* return a `transformNode` function that receives the MDAST as it's first argument.
|
|
86
75
|
*/
|
|
87
|
-
function remarkToSlate({
|
|
76
|
+
export default function remarkToSlate({
|
|
88
77
|
voidCodeBlock
|
|
89
78
|
} = {}) {
|
|
90
79
|
return transformNode;
|
|
@@ -96,7 +85,7 @@ function remarkToSlate({
|
|
|
96
85
|
* translate from MDAST to Slate, such as definitions for link/image
|
|
97
86
|
* references or footnotes.
|
|
98
87
|
*/
|
|
99
|
-
let children = !['strong', 'emphasis', 'delete'].includes(node.type) && !(
|
|
88
|
+
let children = !['strong', 'emphasis', 'delete'].includes(node.type) && !isEmpty(node.children) && flatMap(node.children, transformNode).filter(val => val);
|
|
100
89
|
if (Array.isArray(children)) {
|
|
101
90
|
// Merge adjacent text nodes with the same marks to conform to slate schema
|
|
102
91
|
children = mergeAdjacentTexts(children);
|
|
@@ -113,25 +102,27 @@ function remarkToSlate({
|
|
|
113
102
|
* Add nodes to a parent node only if `nodes` is truthy.
|
|
114
103
|
*/
|
|
115
104
|
function addNodes(parent, nodes) {
|
|
116
|
-
return nodes ?
|
|
105
|
+
return nodes ? {
|
|
106
|
+
...parent,
|
|
117
107
|
children: nodes
|
|
118
|
-
}
|
|
108
|
+
} : parent;
|
|
119
109
|
}
|
|
120
110
|
|
|
121
111
|
/**
|
|
122
112
|
* Create a Slate Block node.
|
|
123
113
|
*/
|
|
124
114
|
function createBlock(type, nodes, props = {}) {
|
|
125
|
-
if (!(
|
|
115
|
+
if (!isArray(nodes)) {
|
|
126
116
|
props = nodes;
|
|
127
117
|
nodes = undefined;
|
|
128
118
|
}
|
|
129
119
|
|
|
130
120
|
// Ensure block nodes have at least one text child to conform to slate schema
|
|
131
|
-
const children = (
|
|
132
|
-
const node =
|
|
133
|
-
type
|
|
134
|
-
|
|
121
|
+
const children = isEmpty(nodes) ? [createText('')] : nodes;
|
|
122
|
+
const node = {
|
|
123
|
+
type,
|
|
124
|
+
...props
|
|
125
|
+
};
|
|
135
126
|
return addNodes(node, children);
|
|
136
127
|
}
|
|
137
128
|
|
|
@@ -139,12 +130,13 @@ function remarkToSlate({
|
|
|
139
130
|
* Create a Slate Inline node.
|
|
140
131
|
*/
|
|
141
132
|
function createInline(type, props = {}, nodes) {
|
|
142
|
-
const node =
|
|
143
|
-
type
|
|
144
|
-
|
|
133
|
+
const node = {
|
|
134
|
+
type,
|
|
135
|
+
...props
|
|
136
|
+
};
|
|
145
137
|
|
|
146
138
|
// Ensure inline nodes have at least one text child to conform to slate schema
|
|
147
|
-
const children = (
|
|
139
|
+
const children = isEmpty(nodes) ? [createText('')] : nodes;
|
|
148
140
|
return addNodes(node, children);
|
|
149
141
|
}
|
|
150
142
|
|
|
@@ -154,18 +146,20 @@ function remarkToSlate({
|
|
|
154
146
|
function createText(node) {
|
|
155
147
|
const newNode = {};
|
|
156
148
|
if (typeof node === 'string') {
|
|
157
|
-
return
|
|
149
|
+
return {
|
|
150
|
+
...newNode,
|
|
158
151
|
text: node
|
|
159
|
-
}
|
|
152
|
+
};
|
|
160
153
|
}
|
|
161
154
|
const {
|
|
162
155
|
text,
|
|
163
156
|
marks
|
|
164
157
|
} = node;
|
|
165
|
-
return normalizeMarks(
|
|
158
|
+
return normalizeMarks({
|
|
159
|
+
...newNode,
|
|
166
160
|
text,
|
|
167
161
|
marks
|
|
168
|
-
})
|
|
162
|
+
});
|
|
169
163
|
}
|
|
170
164
|
function processMarkChild(childNode, marks) {
|
|
171
165
|
switch (childNode.type) {
|
|
@@ -176,9 +170,10 @@ function remarkToSlate({
|
|
|
176
170
|
*/
|
|
177
171
|
case 'html':
|
|
178
172
|
case 'text':
|
|
179
|
-
return
|
|
173
|
+
return {
|
|
174
|
+
...convertNode(childNode),
|
|
180
175
|
marks
|
|
181
|
-
}
|
|
176
|
+
};
|
|
182
177
|
|
|
183
178
|
/**
|
|
184
179
|
* MDAST inline code nodes don't have children, just a text value, similar
|
|
@@ -187,11 +182,12 @@ function remarkToSlate({
|
|
|
187
182
|
*/
|
|
188
183
|
case 'inlineCode':
|
|
189
184
|
{
|
|
190
|
-
return
|
|
185
|
+
return {
|
|
186
|
+
...convertNode(childNode),
|
|
191
187
|
marks: [...marks, {
|
|
192
188
|
type: 'code'
|
|
193
189
|
}]
|
|
194
|
-
}
|
|
190
|
+
};
|
|
195
191
|
}
|
|
196
192
|
|
|
197
193
|
/**
|
|
@@ -206,8 +202,8 @@ function remarkToSlate({
|
|
|
206
202
|
return processMarkNode(childNode, marks);
|
|
207
203
|
case 'link':
|
|
208
204
|
{
|
|
209
|
-
const nodes = (
|
|
210
|
-
const result = convertNode(childNode, (
|
|
205
|
+
const nodes = map(childNode.children, child => normalizeMarks(processMarkChild(child, marks)));
|
|
206
|
+
const result = convertNode(childNode, flatten(nodes));
|
|
211
207
|
return result;
|
|
212
208
|
}
|
|
213
209
|
|
|
@@ -216,11 +212,13 @@ function remarkToSlate({
|
|
|
216
212
|
* added into the cumulative children array.
|
|
217
213
|
*/
|
|
218
214
|
default:
|
|
219
|
-
return transformNode(
|
|
220
|
-
|
|
215
|
+
return transformNode({
|
|
216
|
+
...childNode,
|
|
217
|
+
data: {
|
|
218
|
+
...childNode.data,
|
|
221
219
|
marks
|
|
222
|
-
}
|
|
223
|
-
})
|
|
220
|
+
}
|
|
221
|
+
});
|
|
224
222
|
}
|
|
225
223
|
}
|
|
226
224
|
function processMarkNode(node, parentMarks = []) {
|
|
@@ -234,7 +232,7 @@ function remarkToSlate({
|
|
|
234
232
|
}) => type !== markType), {
|
|
235
233
|
type: markType
|
|
236
234
|
}] : parentMarks;
|
|
237
|
-
const children = (
|
|
235
|
+
const children = flatMap(node.children, child => normalizeMarks(processMarkChild(child, marks)));
|
|
238
236
|
return children;
|
|
239
237
|
}
|
|
240
238
|
function normalizeMarks(node) {
|
|
@@ -273,7 +271,7 @@ function remarkToSlate({
|
|
|
273
271
|
*/
|
|
274
272
|
case 'root':
|
|
275
273
|
{
|
|
276
|
-
const children = (
|
|
274
|
+
const children = isEmpty(nodes) ? [createBlock('paragraph')] : nodes;
|
|
277
275
|
return createBlock(typeMap[node.type], children);
|
|
278
276
|
}
|
|
279
277
|
|
|
@@ -285,7 +283,7 @@ function remarkToSlate({
|
|
|
285
283
|
*/
|
|
286
284
|
case 'listItem':
|
|
287
285
|
{
|
|
288
|
-
const children = (
|
|
286
|
+
const children = isEmpty(nodes) ? [createBlock('paragraph')] : nodes;
|
|
289
287
|
return createBlock(typeMap[node.type], children);
|
|
290
288
|
}
|
|
291
289
|
|
|
@@ -299,10 +297,11 @@ function remarkToSlate({
|
|
|
299
297
|
case 'shortcode':
|
|
300
298
|
{
|
|
301
299
|
const nodes = [createText('')];
|
|
302
|
-
const data =
|
|
300
|
+
const data = {
|
|
301
|
+
...node.data,
|
|
303
302
|
id: node.data.shortcode,
|
|
304
303
|
shortcodeNew: true
|
|
305
|
-
}
|
|
304
|
+
};
|
|
306
305
|
return createBlock(typeMap[node.type], nodes, {
|
|
307
306
|
data
|
|
308
307
|
});
|
|
@@ -395,17 +394,17 @@ function remarkToSlate({
|
|
|
395
394
|
*/
|
|
396
395
|
case 'code':
|
|
397
396
|
{
|
|
398
|
-
const data =
|
|
399
|
-
lang: node.lang
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
397
|
+
const data = {
|
|
398
|
+
lang: node.lang,
|
|
399
|
+
...(voidCodeBlock ? {
|
|
400
|
+
code: node.value
|
|
401
|
+
} : {}),
|
|
403
402
|
shortcode: 'code-block',
|
|
404
403
|
shortcodeData: {
|
|
405
404
|
code: node.value,
|
|
406
405
|
lang: node.lang
|
|
407
406
|
}
|
|
408
|
-
}
|
|
407
|
+
};
|
|
409
408
|
const text = createText(voidCodeBlock ? '' : node.value);
|
|
410
409
|
const nodes = [text];
|
|
411
410
|
const block = createBlock('shortcode', nodes, {
|
|
@@ -473,10 +472,11 @@ function remarkToSlate({
|
|
|
473
472
|
url,
|
|
474
473
|
data
|
|
475
474
|
} = node;
|
|
476
|
-
const newData =
|
|
475
|
+
const newData = {
|
|
476
|
+
...data,
|
|
477
477
|
title,
|
|
478
478
|
url
|
|
479
|
-
}
|
|
479
|
+
};
|
|
480
480
|
return createInline(typeMap[node.type], {
|
|
481
481
|
data: newData
|
|
482
482
|
}, nodes);
|
|
@@ -497,11 +497,12 @@ function remarkToSlate({
|
|
|
497
497
|
alt,
|
|
498
498
|
data
|
|
499
499
|
} = node;
|
|
500
|
-
const newData =
|
|
500
|
+
const newData = {
|
|
501
|
+
...data,
|
|
501
502
|
title,
|
|
502
503
|
alt,
|
|
503
504
|
url
|
|
504
|
-
}
|
|
505
|
+
};
|
|
505
506
|
return createInline(typeMap[node.type], {
|
|
506
507
|
data: newData
|
|
507
508
|
});
|
|
@@ -1,19 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import without from 'lodash/without';
|
|
2
|
+
import flatten from 'lodash/flatten';
|
|
3
|
+
import u from 'unist-builder';
|
|
4
|
+
import mdastDefinitions from 'mdast-util-definitions';
|
|
2
5
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remarkSquashReferences;
|
|
7
|
-
var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
|
|
8
|
-
var _without2 = _interopRequireDefault(require("lodash/without"));
|
|
9
|
-
var _unistBuilder = _interopRequireDefault(require("unist-builder"));
|
|
10
|
-
var _mdastUtilDefinitions = _interopRequireDefault(require("mdast-util-definitions"));
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
16
|
-
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
6
|
/**
|
|
18
7
|
* Raw markdown may contain image references or link references. Because there
|
|
19
8
|
* is no way to maintain these references within the Slate AST, we convert image
|
|
@@ -35,10 +24,10 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
35
24
|
* ```
|
|
36
25
|
*
|
|
37
26
|
*/
|
|
38
|
-
function remarkSquashReferences() {
|
|
27
|
+
export default function remarkSquashReferences() {
|
|
39
28
|
return getTransform;
|
|
40
29
|
function getTransform(node) {
|
|
41
|
-
const getDefinition = (
|
|
30
|
+
const getDefinition = mdastDefinitions(node);
|
|
42
31
|
return transform.call(null, getDefinition, node);
|
|
43
32
|
}
|
|
44
33
|
function transform(getDefinition, node) {
|
|
@@ -61,15 +50,15 @@ function remarkSquashReferences() {
|
|
|
61
50
|
title,
|
|
62
51
|
url
|
|
63
52
|
} = definition;
|
|
64
|
-
return (
|
|
53
|
+
return u(type, {
|
|
65
54
|
title,
|
|
66
55
|
url,
|
|
67
56
|
alt: node.alt
|
|
68
57
|
}, children);
|
|
69
58
|
}
|
|
70
|
-
const pre = (
|
|
71
|
-
const post = (
|
|
72
|
-
const nodes = children || [(
|
|
59
|
+
const pre = u('text', node.type === 'imageReference' ? '![' : '[');
|
|
60
|
+
const post = u('text', ']');
|
|
61
|
+
const nodes = children || [u('text', node.alt)];
|
|
73
62
|
return [pre, ...nodes, post];
|
|
74
63
|
}
|
|
75
64
|
|
|
@@ -80,9 +69,10 @@ function remarkSquashReferences() {
|
|
|
80
69
|
if (node.type === 'definition') {
|
|
81
70
|
return null;
|
|
82
71
|
}
|
|
83
|
-
const filteredChildren = (
|
|
84
|
-
return
|
|
85
|
-
|
|
86
|
-
|
|
72
|
+
const filteredChildren = without(children, null);
|
|
73
|
+
return {
|
|
74
|
+
...node,
|
|
75
|
+
children: flatten(filteredChildren)
|
|
76
|
+
};
|
|
87
77
|
}
|
|
88
78
|
}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import mdastToString from 'mdast-util-to-string';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remarkStripTrailingBreaks;
|
|
7
|
-
var _mdastUtilToString = _interopRequireDefault(require("mdast-util-to-string"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
3
|
/**
|
|
10
4
|
* Removes break nodes that are at the end of a block.
|
|
11
5
|
*
|
|
@@ -15,7 +9,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
15
9
|
* however, may have such entities, and users of visual editors shouldn't see
|
|
16
10
|
* these artifacts in resulting markdown.
|
|
17
11
|
*/
|
|
18
|
-
function remarkStripTrailingBreaks() {
|
|
12
|
+
export default function remarkStripTrailingBreaks() {
|
|
19
13
|
function transform(node) {
|
|
20
14
|
if (node.children) {
|
|
21
15
|
node.children = node.children.map((child, idx, children) => {
|
|
@@ -36,7 +30,7 @@ function remarkStripTrailingBreaks() {
|
|
|
36
30
|
type: 'root',
|
|
37
31
|
children: subsequentNodes
|
|
38
32
|
};
|
|
39
|
-
const subsequentText = (
|
|
33
|
+
const subsequentText = mdastToString(fragment);
|
|
40
34
|
return subsequentText.trim() ? child : null;
|
|
41
35
|
}
|
|
42
36
|
|
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import u from 'unist-builder';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remarkWrapHtml;
|
|
7
|
-
var _unistBuilder = _interopRequireDefault(require("unist-builder"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
3
|
/**
|
|
10
4
|
* Ensure that top level 'html' type nodes are wrapped in paragraphs. Html nodes
|
|
11
5
|
* are used for text nodes that we don't want Remark or Rehype to parse.
|
|
12
6
|
*/
|
|
13
|
-
function remarkWrapHtml() {
|
|
7
|
+
export default function remarkWrapHtml() {
|
|
14
8
|
function transform(tree) {
|
|
15
9
|
tree.children = tree.children.map(node => {
|
|
16
10
|
if (node.type === 'html') {
|
|
17
|
-
return (
|
|
11
|
+
return u('paragraph', [node]);
|
|
18
12
|
}
|
|
19
13
|
return node;
|
|
20
14
|
});
|