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,20 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
class MarkdownPreview extends _react.default.Component {
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { WidgetPreviewContainer } from 'decap-cms-ui-default';
|
|
4
|
+
import DOMPurify from 'dompurify';
|
|
5
|
+
import { markdownToHtml } from './serializers';
|
|
6
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
7
|
+
class MarkdownPreview extends React.Component {
|
|
8
|
+
static propTypes = {
|
|
9
|
+
getAsset: PropTypes.func.isRequired,
|
|
10
|
+
resolveWidget: PropTypes.func.isRequired,
|
|
11
|
+
value: PropTypes.string
|
|
12
|
+
};
|
|
13
|
+
componentDidMount() {
|
|
14
|
+
// Manually validate PropTypes - React 19 breaking change
|
|
15
|
+
PropTypes.checkPropTypes(MarkdownPreview.propTypes, this.props, 'prop', 'MarkdownPreview');
|
|
16
|
+
}
|
|
18
17
|
render() {
|
|
19
18
|
const {
|
|
20
19
|
value,
|
|
@@ -26,21 +25,16 @@ class MarkdownPreview extends _react.default.Component {
|
|
|
26
25
|
if (value === null) {
|
|
27
26
|
return null;
|
|
28
27
|
}
|
|
29
|
-
const html =
|
|
28
|
+
const html = markdownToHtml(value, {
|
|
30
29
|
getAsset,
|
|
31
30
|
resolveWidget
|
|
32
|
-
}, getRemarkPlugins
|
|
33
|
-
const toRender = field
|
|
34
|
-
return (
|
|
31
|
+
}, getRemarkPlugins?.());
|
|
32
|
+
const toRender = field?.get('sanitize_preview', false) ? DOMPurify.sanitize(html) : html;
|
|
33
|
+
return ___EmotionJSX(WidgetPreviewContainer, {
|
|
35
34
|
dangerouslySetInnerHTML: {
|
|
36
35
|
__html: toRender
|
|
37
36
|
}
|
|
38
37
|
});
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
|
-
|
|
42
|
-
getAsset: _propTypes.default.func.isRequired,
|
|
43
|
-
resolveWidget: _propTypes.default.func.isRequired,
|
|
44
|
-
value: _propTypes.default.string
|
|
45
|
-
});
|
|
46
|
-
var _default = exports.default = MarkdownPreview;
|
|
40
|
+
export default MarkdownPreview;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.DecapCmsWidgetMarkdown = void 0;
|
|
7
|
-
var _MarkdownControl = _interopRequireDefault(require("./MarkdownControl"));
|
|
8
|
-
var _MarkdownPreview = _interopRequireDefault(require("./MarkdownPreview"));
|
|
9
|
-
var _schema = _interopRequireDefault(require("./schema"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
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; }
|
|
12
|
-
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; }
|
|
13
|
-
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; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
15
|
-
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); }
|
|
1
|
+
import controlComponent from './MarkdownControl';
|
|
2
|
+
import previewComponent from './MarkdownPreview';
|
|
3
|
+
import schema from './schema';
|
|
16
4
|
function Widget(opts = {}) {
|
|
17
|
-
return
|
|
5
|
+
return {
|
|
18
6
|
name: 'markdown',
|
|
19
|
-
controlComponent
|
|
20
|
-
previewComponent
|
|
21
|
-
schema
|
|
22
|
-
|
|
7
|
+
controlComponent,
|
|
8
|
+
previewComponent,
|
|
9
|
+
schema,
|
|
10
|
+
...opts
|
|
11
|
+
};
|
|
23
12
|
}
|
|
24
|
-
const DecapCmsWidgetMarkdown =
|
|
13
|
+
export const DecapCmsWidgetMarkdown = {
|
|
25
14
|
Widget,
|
|
26
|
-
controlComponent
|
|
27
|
-
previewComponent
|
|
15
|
+
controlComponent,
|
|
16
|
+
previewComponent
|
|
28
17
|
};
|
|
29
|
-
|
|
18
|
+
export default DecapCmsWidgetMarkdown;
|
package/dist/esm/regexHelper.js
CHANGED
|
@@ -1,18 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import last from 'lodash/last';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.combinePatterns = combinePatterns;
|
|
7
|
-
exports.joinPatternSegments = joinPatternSegments;
|
|
8
|
-
exports.replaceWhen = replaceWhen;
|
|
9
|
-
var _last2 = _interopRequireDefault(require("lodash/last"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
3
|
/**
|
|
12
4
|
* Joins an array of regular expressions into a single expression, without
|
|
13
5
|
* altering the received expressions.
|
|
14
6
|
*/
|
|
15
|
-
function joinPatternSegments(patterns) {
|
|
7
|
+
export function joinPatternSegments(patterns) {
|
|
16
8
|
return patterns.map(p => p.source).join('');
|
|
17
9
|
}
|
|
18
10
|
|
|
@@ -21,7 +13,7 @@ function joinPatternSegments(patterns) {
|
|
|
21
13
|
* each in a non-capturing group and interposing alternation characters (|) so
|
|
22
14
|
* that each expression is executed separately.
|
|
23
15
|
*/
|
|
24
|
-
function combinePatterns(patterns) {
|
|
16
|
+
export function combinePatterns(patterns) {
|
|
25
17
|
return patterns.map(p => `(?:${p.source})`).join('|');
|
|
26
18
|
}
|
|
27
19
|
|
|
@@ -37,7 +29,7 @@ function combinePatterns(patterns) {
|
|
|
37
29
|
* invertMatchPattern - boolean - if true, non-matching substrings are modified
|
|
38
30
|
* instead of matching substrings
|
|
39
31
|
*/
|
|
40
|
-
function replaceWhen(matchPattern, replaceFn, text, invertMatchPattern) {
|
|
32
|
+
export function replaceWhen(matchPattern, replaceFn, text, invertMatchPattern) {
|
|
41
33
|
/**
|
|
42
34
|
* Splits the string into an array of objects with the following shape:
|
|
43
35
|
*
|
|
@@ -56,7 +48,7 @@ function replaceWhen(matchPattern, replaceFn, text, invertMatchPattern) {
|
|
|
56
48
|
* string.
|
|
57
49
|
*/
|
|
58
50
|
const match = exp.exec(text);
|
|
59
|
-
const lastEntry = (
|
|
51
|
+
const lastEntry = last(acc);
|
|
60
52
|
|
|
61
53
|
/**
|
|
62
54
|
* `match` will be null if there are no matches.
|
|
@@ -124,7 +116,7 @@ function replaceWhen(matchPattern, replaceFn, text, invertMatchPattern) {
|
|
|
124
116
|
/**
|
|
125
117
|
* Process the trailing substring after the final match, if one exists.
|
|
126
118
|
*/
|
|
127
|
-
const lastEntry = (
|
|
119
|
+
const lastEntry = last(acc);
|
|
128
120
|
if (!lastEntry) return replaceFn(text);
|
|
129
121
|
const nextIndex = lastEntry.index + lastEntry.text.length;
|
|
130
122
|
if (text.length > nextIndex) {
|
package/dist/esm/schema.js
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
import trimEnd from 'lodash/trimEnd';
|
|
2
|
+
import unified from 'unified';
|
|
3
|
+
import u from 'unist-builder';
|
|
4
|
+
import markdownToRemarkPlugin from 'remark-parse';
|
|
5
|
+
import remarkToMarkdownPlugin from 'remark-stringify';
|
|
6
|
+
import remarkToRehype from 'remark-rehype';
|
|
7
|
+
import rehypeToHtml from 'rehype-stringify';
|
|
8
|
+
import htmlToRehype from 'rehype-parse';
|
|
9
|
+
import rehypeToRemark from 'rehype-remark';
|
|
10
|
+
import remarkToRehypeShortcodes from './remarkRehypeShortcodes';
|
|
11
|
+
import rehypePaperEmoji from './rehypePaperEmoji';
|
|
12
|
+
import remarkAssertParents from './remarkAssertParents';
|
|
13
|
+
import remarkPaddedLinks from './remarkPaddedLinks';
|
|
14
|
+
import remarkWrapHtml from './remarkWrapHtml';
|
|
15
|
+
import remarkToSlate from './remarkSlate';
|
|
16
|
+
import remarkSquashReferences from './remarkSquashReferences';
|
|
17
|
+
import { remarkParseShortcodes, createRemarkShortcodeStringifier } from './remarkShortcodes';
|
|
18
|
+
import remarkEscapeMarkdownEntities from './remarkEscapeMarkdownEntities';
|
|
19
|
+
import remarkStripTrailingBreaks from './remarkStripTrailingBreaks';
|
|
20
|
+
import remarkAllowHtmlEntities from './remarkAllowHtmlEntities';
|
|
21
|
+
import slateToRemark from './slateRemark';
|
|
22
|
+
import { getEditorComponents } from '../MarkdownControl';
|
|
2
23
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.htmlToSlate = htmlToSlate;
|
|
7
|
-
exports.markdownToHtml = markdownToHtml;
|
|
8
|
-
exports.markdownToRemark = markdownToRemark;
|
|
9
|
-
exports.markdownToSlate = markdownToSlate;
|
|
10
|
-
exports.remarkToMarkdown = remarkToMarkdown;
|
|
11
|
-
exports.slateToMarkdown = slateToMarkdown;
|
|
12
|
-
var _trimEnd2 = _interopRequireDefault(require("lodash/trimEnd"));
|
|
13
|
-
var _unified = _interopRequireDefault(require("unified"));
|
|
14
|
-
var _unistBuilder = _interopRequireDefault(require("unist-builder"));
|
|
15
|
-
var _remarkParse = _interopRequireDefault(require("remark-parse"));
|
|
16
|
-
var _remarkStringify = _interopRequireDefault(require("remark-stringify"));
|
|
17
|
-
var _remarkRehype = _interopRequireDefault(require("remark-rehype"));
|
|
18
|
-
var _rehypeStringify = _interopRequireDefault(require("rehype-stringify"));
|
|
19
|
-
var _rehypeParse = _interopRequireDefault(require("rehype-parse"));
|
|
20
|
-
var _rehypeRemark = _interopRequireDefault(require("rehype-remark"));
|
|
21
|
-
var _remarkRehypeShortcodes = _interopRequireDefault(require("./remarkRehypeShortcodes"));
|
|
22
|
-
var _rehypePaperEmoji = _interopRequireDefault(require("./rehypePaperEmoji"));
|
|
23
|
-
var _remarkAssertParents = _interopRequireDefault(require("./remarkAssertParents"));
|
|
24
|
-
var _remarkPaddedLinks = _interopRequireDefault(require("./remarkPaddedLinks"));
|
|
25
|
-
var _remarkWrapHtml = _interopRequireDefault(require("./remarkWrapHtml"));
|
|
26
|
-
var _remarkSlate = _interopRequireDefault(require("./remarkSlate"));
|
|
27
|
-
var _remarkSquashReferences = _interopRequireDefault(require("./remarkSquashReferences"));
|
|
28
|
-
var _remarkShortcodes = require("./remarkShortcodes");
|
|
29
|
-
var _remarkEscapeMarkdownEntities = _interopRequireDefault(require("./remarkEscapeMarkdownEntities"));
|
|
30
|
-
var _remarkStripTrailingBreaks = _interopRequireDefault(require("./remarkStripTrailingBreaks"));
|
|
31
|
-
var _remarkAllowHtmlEntities = _interopRequireDefault(require("./remarkAllowHtmlEntities"));
|
|
32
|
-
var _slateRemark = _interopRequireDefault(require("./slateRemark"));
|
|
33
|
-
var _MarkdownControl = require("../MarkdownControl");
|
|
34
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
24
|
/**
|
|
36
25
|
* This module contains all serializers for the Markdown widget.
|
|
37
26
|
*
|
|
@@ -69,15 +58,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
69
58
|
/**
|
|
70
59
|
* Deserialize a Markdown string to an MDAST.
|
|
71
60
|
*/
|
|
72
|
-
function markdownToRemark(markdown, remarkPlugins) {
|
|
73
|
-
const processor = (
|
|
61
|
+
export function markdownToRemark(markdown, remarkPlugins) {
|
|
62
|
+
const processor = unified().use(markdownToRemarkPlugin, {
|
|
74
63
|
fences: true,
|
|
75
64
|
commonmark: true
|
|
76
65
|
}).use(markdownToRemarkRemoveTokenizers, {
|
|
77
66
|
inlineTokenizers: ['url']
|
|
78
|
-
}).use(
|
|
79
|
-
plugins:
|
|
80
|
-
}).use(
|
|
67
|
+
}).use(remarkParseShortcodes, {
|
|
68
|
+
plugins: getEditorComponents()
|
|
69
|
+
}).use(remarkAllowHtmlEntities).use(remarkSquashReferences).use(remarkPlugins);
|
|
81
70
|
|
|
82
71
|
/**
|
|
83
72
|
* Parse the Markdown string input to an MDAST.
|
|
@@ -105,7 +94,7 @@ function markdownToRemarkRemoveTokenizers({
|
|
|
105
94
|
/**
|
|
106
95
|
* Serialize an MDAST to a Markdown string.
|
|
107
96
|
*/
|
|
108
|
-
function remarkToMarkdown(obj, remarkPlugins) {
|
|
97
|
+
export function remarkToMarkdown(obj, remarkPlugins) {
|
|
109
98
|
/**
|
|
110
99
|
* Rewrite the remark-stringify text visitor to simply return the text value,
|
|
111
100
|
* without encoding or escaping any characters. This means we're completely
|
|
@@ -120,7 +109,7 @@ function remarkToMarkdown(obj, remarkPlugins) {
|
|
|
120
109
|
/**
|
|
121
110
|
* Provide an empty MDAST if no value is provided.
|
|
122
111
|
*/
|
|
123
|
-
const mdast = obj || (
|
|
112
|
+
const mdast = obj || u('root', [u('paragraph', [u('text', '')])]);
|
|
124
113
|
const remarkToMarkdownPluginOpts = {
|
|
125
114
|
commonmark: true,
|
|
126
115
|
fences: true,
|
|
@@ -134,10 +123,10 @@ function remarkToMarkdown(obj, remarkPlugins) {
|
|
|
134
123
|
strong: '*',
|
|
135
124
|
rule: '-'
|
|
136
125
|
};
|
|
137
|
-
const processor = (
|
|
126
|
+
const processor = unified().use({
|
|
138
127
|
settings: remarkToMarkdownPluginOpts
|
|
139
|
-
}).use(
|
|
140
|
-
plugins:
|
|
128
|
+
}).use(remarkEscapeMarkdownEntities).use(remarkStripTrailingBreaks).use(remarkToMarkdownPlugin).use(remarkAllowAllText).use(createRemarkShortcodeStringifier({
|
|
129
|
+
plugins: getEditorComponents()
|
|
141
130
|
})).use(remarkPlugins);
|
|
142
131
|
|
|
143
132
|
/**
|
|
@@ -153,26 +142,26 @@ function remarkToMarkdown(obj, remarkPlugins) {
|
|
|
153
142
|
/**
|
|
154
143
|
* Return markdown with trailing whitespace removed.
|
|
155
144
|
*/
|
|
156
|
-
return (
|
|
145
|
+
return trimEnd(markdown);
|
|
157
146
|
}
|
|
158
147
|
|
|
159
148
|
/**
|
|
160
149
|
* Convert Markdown to HTML.
|
|
161
150
|
*/
|
|
162
|
-
function markdownToHtml(markdown, {
|
|
151
|
+
export function markdownToHtml(markdown, {
|
|
163
152
|
getAsset,
|
|
164
153
|
resolveWidget,
|
|
165
154
|
remarkPlugins = []
|
|
166
155
|
} = {}) {
|
|
167
156
|
const mdast = markdownToRemark(markdown, remarkPlugins);
|
|
168
|
-
const hast = (
|
|
169
|
-
plugins:
|
|
157
|
+
const hast = unified().use(remarkToRehypeShortcodes, {
|
|
158
|
+
plugins: getEditorComponents(),
|
|
170
159
|
getAsset,
|
|
171
160
|
resolveWidget
|
|
172
|
-
}).use(
|
|
161
|
+
}).use(remarkToRehype, {
|
|
173
162
|
allowDangerousHTML: true
|
|
174
163
|
}).runSync(mdast);
|
|
175
|
-
const html = (
|
|
164
|
+
const html = unified().use(rehypeToHtml, {
|
|
176
165
|
allowDangerousHtml: true,
|
|
177
166
|
allowDangerousCharacters: true,
|
|
178
167
|
closeSelfClosing: true,
|
|
@@ -187,26 +176,26 @@ function markdownToHtml(markdown, {
|
|
|
187
176
|
* Deserialize an HTML string to Slate's Raw AST. Currently used for HTML
|
|
188
177
|
* pastes.
|
|
189
178
|
*/
|
|
190
|
-
function htmlToSlate(html) {
|
|
191
|
-
const hast = (
|
|
179
|
+
export function htmlToSlate(html) {
|
|
180
|
+
const hast = unified().use(htmlToRehype, {
|
|
192
181
|
fragment: true
|
|
193
182
|
}).parse(html);
|
|
194
|
-
const mdast = (
|
|
183
|
+
const mdast = unified().use(rehypePaperEmoji).use(rehypeToRemark, {
|
|
195
184
|
minify: false
|
|
196
185
|
}).runSync(hast);
|
|
197
|
-
const slateRaw = (
|
|
186
|
+
const slateRaw = unified().use(remarkAssertParents).use(remarkPaddedLinks).use(remarkWrapHtml).use(remarkToSlate).runSync(mdast);
|
|
198
187
|
return slateRaw;
|
|
199
188
|
}
|
|
200
189
|
|
|
201
190
|
/**
|
|
202
191
|
* Convert Markdown to Slate's Raw AST.
|
|
203
192
|
*/
|
|
204
|
-
function markdownToSlate(markdown, {
|
|
193
|
+
export function markdownToSlate(markdown, {
|
|
205
194
|
voidCodeBlock,
|
|
206
195
|
remarkPlugins = []
|
|
207
196
|
} = {}) {
|
|
208
197
|
const mdast = markdownToRemark(markdown, remarkPlugins);
|
|
209
|
-
const slateRaw = (
|
|
198
|
+
const slateRaw = unified().use(remarkWrapHtml).use(remarkToSlate, {
|
|
210
199
|
voidCodeBlock
|
|
211
200
|
}).runSync(mdast);
|
|
212
201
|
return slateRaw.children;
|
|
@@ -221,11 +210,11 @@ function markdownToSlate(markdown, {
|
|
|
221
210
|
* MDAST. The conversion is manual because Unified can only operate on Unist
|
|
222
211
|
* trees.
|
|
223
212
|
*/
|
|
224
|
-
function slateToMarkdown(raw, {
|
|
213
|
+
export function slateToMarkdown(raw, {
|
|
225
214
|
voidCodeBlock,
|
|
226
215
|
remarkPlugins = []
|
|
227
216
|
} = {}) {
|
|
228
|
-
const mdast = (
|
|
217
|
+
const mdast = slateToRemark(raw, {
|
|
229
218
|
voidCodeBlock
|
|
230
219
|
});
|
|
231
220
|
const markdown = remarkToMarkdown(mdast, remarkPlugins);
|
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = rehypePaperEmoji;
|
|
7
1
|
/**
|
|
8
2
|
* Dropbox Paper outputs emoji characters as images, and stores the actual
|
|
9
3
|
* emoji character in a `data-emoji-ch` attribute on the image. This plugin
|
|
10
4
|
* replaces the images with the emoji characters.
|
|
11
5
|
*/
|
|
12
|
-
function rehypePaperEmoji() {
|
|
6
|
+
export default function rehypePaperEmoji() {
|
|
13
7
|
function transform(node) {
|
|
14
8
|
if (node.tagName === 'img' && node.properties.dataEmojiCh) {
|
|
15
9
|
return {
|
|
@@ -1,10 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remarkAllowHtmlEntities;
|
|
7
|
-
function remarkAllowHtmlEntities() {
|
|
1
|
+
export default function remarkAllowHtmlEntities() {
|
|
8
2
|
this.Parser.prototype.inlineTokenizers.text = text;
|
|
9
3
|
|
|
10
4
|
/**
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import concat from 'lodash/concat';
|
|
2
|
+
import last from 'lodash/last';
|
|
3
|
+
import nth from 'lodash/nth';
|
|
4
|
+
import isEmpty from 'lodash/isEmpty';
|
|
5
|
+
import visitParents from 'unist-util-visit-parents';
|
|
2
6
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remarkUnwrapInvalidNest;
|
|
7
|
-
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
8
|
-
var _nth2 = _interopRequireDefault(require("lodash/nth"));
|
|
9
|
-
var _last2 = _interopRequireDefault(require("lodash/last"));
|
|
10
|
-
var _concat2 = _interopRequireDefault(require("lodash/concat"));
|
|
11
|
-
var _unistUtilVisitParents = _interopRequireDefault(require("unist-util-visit-parents"));
|
|
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
|
* remarkUnwrapInvalidNest
|
|
20
9
|
*
|
|
@@ -29,7 +18,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
29
18
|
* validly nested nodes retain their ancestry. Nodes that are emptied as a
|
|
30
19
|
* result of unnesting nodes are removed from the tree.
|
|
31
20
|
*/
|
|
32
|
-
function remarkUnwrapInvalidNest() {
|
|
21
|
+
export default function remarkUnwrapInvalidNest() {
|
|
33
22
|
return transform;
|
|
34
23
|
function transform(tree) {
|
|
35
24
|
const invalidNest = findInvalidNest(tree);
|
|
@@ -55,35 +44,37 @@ function remarkUnwrapInvalidNest() {
|
|
|
55
44
|
*/
|
|
56
45
|
const canContainBlocks = ['root', 'blockquote', 'listItem', 'tableCell'];
|
|
57
46
|
let invalidNest;
|
|
58
|
-
(
|
|
59
|
-
const parentType = !(
|
|
47
|
+
visitParents(tree, (node, parents) => {
|
|
48
|
+
const parentType = !isEmpty(parents) && last(parents).type;
|
|
60
49
|
const isInvalidNest = blocks.includes(node.type) && !canContainBlocks.includes(parentType);
|
|
61
50
|
if (isInvalidNest) {
|
|
62
|
-
invalidNest = (
|
|
51
|
+
invalidNest = concat(parents, node);
|
|
63
52
|
return false;
|
|
64
53
|
}
|
|
65
54
|
});
|
|
66
55
|
return invalidNest;
|
|
67
56
|
}
|
|
68
57
|
function splitTreeAtNest(tree, nest) {
|
|
69
|
-
const grandparent = (
|
|
70
|
-
const parent = (
|
|
71
|
-
const node = (
|
|
58
|
+
const grandparent = nth(nest, -3) || tree;
|
|
59
|
+
const parent = nth(nest, -2);
|
|
60
|
+
const node = last(nest);
|
|
72
61
|
const splitIndex = grandparent.children.indexOf(parent);
|
|
73
62
|
const splitChildren = grandparent.children;
|
|
74
63
|
const splitChildIndex = parent.children.indexOf(node);
|
|
75
64
|
const childrenBefore = parent.children.slice(0, splitChildIndex);
|
|
76
65
|
const childrenAfter = parent.children.slice(splitChildIndex + 1);
|
|
77
|
-
const nodeBefore = !(
|
|
66
|
+
const nodeBefore = !isEmpty(childrenBefore) && {
|
|
67
|
+
...parent,
|
|
78
68
|
children: childrenBefore
|
|
79
|
-
}
|
|
80
|
-
const nodeAfter = !(
|
|
69
|
+
};
|
|
70
|
+
const nodeAfter = !isEmpty(childrenAfter) && {
|
|
71
|
+
...parent,
|
|
81
72
|
children: childrenAfter
|
|
82
|
-
}
|
|
83
|
-
const childrenToInsert = [nodeBefore, node, nodeAfter].filter(val => !(
|
|
73
|
+
};
|
|
74
|
+
const childrenToInsert = [nodeBefore, node, nodeAfter].filter(val => !isEmpty(val));
|
|
84
75
|
const beforeChildren = splitChildren.slice(0, splitIndex);
|
|
85
76
|
const afterChildren = splitChildren.slice(splitIndex + 1);
|
|
86
|
-
const newChildren = (
|
|
77
|
+
const newChildren = concat(beforeChildren, childrenToInsert, afterChildren);
|
|
87
78
|
grandparent.children = newChildren;
|
|
88
79
|
}
|
|
89
80
|
}
|
|
@@ -1,20 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import has from 'lodash/has';
|
|
2
|
+
import flow from 'lodash/flow';
|
|
3
|
+
import partial from 'lodash/partial';
|
|
4
|
+
import map from 'lodash/map';
|
|
5
|
+
import { joinPatternSegments, combinePatterns, replaceWhen } from '../regexHelper';
|
|
2
6
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remarkEscapeMarkdownEntities;
|
|
7
|
-
var _map2 = _interopRequireDefault(require("lodash/map"));
|
|
8
|
-
var _partial2 = _interopRequireDefault(require("lodash/partial"));
|
|
9
|
-
var _flow2 = _interopRequireDefault(require("lodash/flow"));
|
|
10
|
-
var _has2 = _interopRequireDefault(require("lodash/has"));
|
|
11
|
-
var _regexHelper = require("../regexHelper");
|
|
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
|
* Reusable regular expressions segments.
|
|
20
9
|
*/
|
|
@@ -139,16 +128,16 @@ const escapePatterns = [
|
|
|
139
128
|
* Generate new non-escape expression. The non-escape expression matches
|
|
140
129
|
* substrings whose contents should not be processed for escaping.
|
|
141
130
|
*/
|
|
142
|
-
const joinedNonEscapePatterns = (
|
|
143
|
-
return new RegExp(
|
|
131
|
+
const joinedNonEscapePatterns = map(nonEscapePatterns, pattern => {
|
|
132
|
+
return new RegExp(joinPatternSegments(pattern));
|
|
144
133
|
});
|
|
145
|
-
const nonEscapePattern =
|
|
134
|
+
const nonEscapePattern = combinePatterns(joinedNonEscapePatterns);
|
|
146
135
|
|
|
147
136
|
/**
|
|
148
137
|
* Create chain of successive escape functions for various markdown entities.
|
|
149
138
|
*/
|
|
150
|
-
const escapeFunctions = escapePatterns.map(pattern => (
|
|
151
|
-
const escapeAll = (
|
|
139
|
+
const escapeFunctions = escapePatterns.map(pattern => partial(escapeDelimiters, pattern));
|
|
140
|
+
const escapeAll = flow(escapeFunctions);
|
|
152
141
|
|
|
153
142
|
/**
|
|
154
143
|
* Executes both the `escapeCommonChars` and `escapeLeadingChars` functions.
|
|
@@ -189,7 +178,7 @@ function escapeCommonChars(text) {
|
|
|
189
178
|
* Use `replaceWhen` to escape markdown entities only within substrings that
|
|
190
179
|
* are eligible for escaping.
|
|
191
180
|
*/
|
|
192
|
-
return
|
|
181
|
+
return replaceWhen(nonEscapeExpression, escapeAll, text, true);
|
|
193
182
|
}
|
|
194
183
|
|
|
195
184
|
/**
|
|
@@ -236,13 +225,13 @@ function escape(delim) {
|
|
|
236
225
|
* we need to escape them, otherwise they'll be interpreted during
|
|
237
226
|
* stringification.
|
|
238
227
|
*/
|
|
239
|
-
function remarkEscapeMarkdownEntities() {
|
|
228
|
+
export default function remarkEscapeMarkdownEntities() {
|
|
240
229
|
function transform(node, index) {
|
|
241
230
|
/**
|
|
242
231
|
* Shortcode nodes will intentionally inject markdown entities in text node
|
|
243
232
|
* children not be escaped.
|
|
244
233
|
*/
|
|
245
|
-
if ((
|
|
234
|
+
if (has(node.data, 'shortcode')) return node;
|
|
246
235
|
const children = node.children ? {
|
|
247
236
|
children: node.children.map(transform)
|
|
248
237
|
} : {};
|
|
@@ -257,15 +246,20 @@ function remarkEscapeMarkdownEntities() {
|
|
|
257
246
|
* common characters.
|
|
258
247
|
*/
|
|
259
248
|
const value = index === 0 ? escapeAllChars(node.value) : escapeCommonChars(node.value);
|
|
260
|
-
return
|
|
261
|
-
|
|
262
|
-
|
|
249
|
+
return {
|
|
250
|
+
...node,
|
|
251
|
+
value,
|
|
252
|
+
...children
|
|
253
|
+
};
|
|
263
254
|
}
|
|
264
255
|
|
|
265
256
|
/**
|
|
266
257
|
* Always return nodes with recursively mapped children.
|
|
267
258
|
*/
|
|
268
|
-
return
|
|
259
|
+
return {
|
|
260
|
+
...node,
|
|
261
|
+
...children
|
|
262
|
+
};
|
|
269
263
|
}
|
|
270
264
|
return transform;
|
|
271
265
|
}
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = remarkImagesToText;
|
|
7
|
-
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; }
|
|
8
|
-
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; }
|
|
9
|
-
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; }
|
|
10
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
11
|
-
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); }
|
|
12
1
|
/**
|
|
13
2
|
* Images must be parsed as shortcodes for asset proxying. This plugin converts
|
|
14
3
|
* MDAST image nodes back to text to allow shortcode pattern matching. Note that
|
|
@@ -16,7 +5,7 @@ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e =
|
|
|
16
5
|
* level paragraph - any other image is left alone and treated as an inline
|
|
17
6
|
* image.
|
|
18
7
|
*/
|
|
19
|
-
function remarkImagesToText() {
|
|
8
|
+
export default function remarkImagesToText() {
|
|
20
9
|
return transform;
|
|
21
10
|
function transform(node) {
|
|
22
11
|
const children = node.children.map(child => {
|
|
@@ -34,8 +23,9 @@ function remarkImagesToText() {
|
|
|
34
23
|
}
|
|
35
24
|
return child;
|
|
36
25
|
});
|
|
37
|
-
return
|
|
26
|
+
return {
|
|
27
|
+
...node,
|
|
38
28
|
children
|
|
39
|
-
}
|
|
29
|
+
};
|
|
40
30
|
}
|
|
41
31
|
}
|