decap-cms-widget-markdown 3.12.0 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/decap-cms-widget-markdown.js +6 -6
  3. package/dist/decap-cms-widget-markdown.js.map +1 -1
  4. package/dist/esm/MarkdownControl/Toolbar.js +6 -6
  5. package/dist/esm/MarkdownControl/VisualEditor.js +7 -3
  6. package/dist/esm/MarkdownControl/components/InlineShortcode.js +67 -0
  7. package/dist/esm/MarkdownControl/index.js +2 -2
  8. package/dist/esm/MarkdownControl/plugins/shortcodes/insertShortcode.js +53 -4
  9. package/dist/esm/MarkdownControl/plugins/shortcodes/withShortcodes.js +11 -1
  10. package/dist/esm/MarkdownControl/renderers.js +21 -16
  11. package/dist/esm/MarkdownPreview.js +37 -3
  12. package/dist/esm/serializers/remarkRehypeShortcodes.js +18 -15
  13. package/dist/esm/serializers/remarkShortcodes.js +118 -12
  14. package/dist/esm/serializers/remarkSlate.js +14 -1
  15. package/dist/esm/serializers/slateRemark.js +18 -2
  16. package/package.json +23 -13
  17. package/src/MarkdownControl/Toolbar.js +2 -2
  18. package/src/MarkdownControl/VisualEditor.js +5 -1
  19. package/src/MarkdownControl/components/InlineShortcode.js +77 -0
  20. package/src/MarkdownControl/components/__tests__/InlineShortcode.spec.js +81 -0
  21. package/src/MarkdownControl/index.js +2 -2
  22. package/src/MarkdownControl/plugins/shortcodes/__tests__/insertShortcode.spec.js +106 -0
  23. package/src/MarkdownControl/plugins/shortcodes/insertShortcode.js +59 -6
  24. package/src/MarkdownControl/plugins/shortcodes/withShortcodes.js +12 -2
  25. package/src/MarkdownControl/renderers.js +3 -0
  26. package/src/MarkdownPreview.js +38 -3
  27. package/src/__tests__/renderer.spec.js +68 -0
  28. package/src/serializers/__tests__/remarkShortcodes.spec.js +210 -1
  29. package/src/serializers/__tests__/slate.spec.js +80 -0
  30. package/src/serializers/remarkRehypeShortcodes.js +19 -9
  31. package/src/serializers/remarkShortcodes.js +140 -12
  32. package/src/serializers/remarkSlate.js +7 -0
  33. package/src/serializers/slateRemark.js +13 -2
  34. package/LICENSE +0 -22
  35. package/dist/esm/MarkdownControl/plugins/BreakToDefaultBlock.js +0 -26
  36. package/dist/esm/MarkdownControl/plugins/CloseBlock.js +0 -28
  37. package/dist/esm/MarkdownControl/plugins/CommandsAndQueries.js +0 -180
  38. package/dist/esm/MarkdownControl/plugins/ForceInsert.js +0 -42
  39. package/dist/esm/MarkdownControl/plugins/Hotkey.js +0 -26
  40. package/dist/esm/MarkdownControl/plugins/LineBreak.js +0 -13
  41. package/dist/esm/MarkdownControl/plugins/Link.js +0 -49
  42. package/dist/esm/MarkdownControl/plugins/lists/locations/isCursorInItemContainingNestedList.js +0 -6
  43. package/dist/esm/MarkdownControl/plugins/util.js +0 -11
  44. package/dist/esm/serializers/remarkImagesToText.js +0 -31
  45. package/dist/esm/types.js +0 -2
@@ -1,49 +0,0 @@
1
- function Link({
2
- type
3
- }) {
4
- return {
5
- commands: {
6
- toggleLink(editor, getUrl) {
7
- const selection = editor.value.selection;
8
- const isCollapsed = selection && selection.isCollapsed;
9
- if (editor.hasInline(type)) {
10
- const inlines = editor.value.inlines.toJSON();
11
- const link = inlines.find(item => item.type === type);
12
- const url = getUrl(link.data.url);
13
- if (url) {
14
- // replace the old link
15
- return editor.setInlines({
16
- data: {
17
- url
18
- }
19
- });
20
- } else {
21
- // remove url if it was removed by the user
22
- return editor.unwrapInline(type);
23
- }
24
- } else {
25
- const url = getUrl();
26
- if (!url) {
27
- return;
28
- }
29
- return isCollapsed ? editor.insertInline({
30
- type,
31
- data: {
32
- url
33
- },
34
- nodes: [{
35
- object: 'text',
36
- text: url
37
- }]
38
- }) : editor.wrapInline({
39
- type,
40
- data: {
41
- url
42
- }
43
- }).moveToEnd();
44
- }
45
- }
46
- }
47
- };
48
- }
49
- export default Link;
@@ -1,6 +0,0 @@
1
- import getListContainedInListItem from '../selectors/getListContainedInListItem';
2
- function isCursorInItemContainingNestedList(editor) {
3
- const nestedList = getListContainedInListItem(editor);
4
- return !!nestedList && `${nestedList[0].type}`.endsWith('-list');
5
- }
6
- export default isCursorInItemContainingNestedList;
@@ -1,11 +0,0 @@
1
- import castArray from 'lodash/castArray';
2
- import isArray from 'lodash/isArray';
3
- export function assertType(nodes, type) {
4
- const nodesArray = castArray(nodes);
5
- const validate = isArray(type) ? node => type.includes(node.type) : node => type === node.type;
6
- const invalidNode = nodesArray.find(node => !validate(node));
7
- if (invalidNode) {
8
- throw Error(`Expected node of type "${type}", received "${invalidNode.type}".`);
9
- }
10
- return true;
11
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * Images must be parsed as shortcodes for asset proxying. This plugin converts
3
- * MDAST image nodes back to text to allow shortcode pattern matching. Note that
4
- * this transformation only occurs for images that are the sole child of a top
5
- * level paragraph - any other image is left alone and treated as an inline
6
- * image.
7
- */
8
- export default function remarkImagesToText() {
9
- return transform;
10
- function transform(node) {
11
- const children = node.children.map(child => {
12
- if (child.type === 'paragraph' && child.children.length === 1 && child.children[0].type === 'image') {
13
- const {
14
- alt,
15
- url,
16
- title
17
- } = child.children[0];
18
- const value = `![${alt || ''}](${url || ''}${title ? ` "${title}"` : ''})`;
19
- child.children = [{
20
- type: 'text',
21
- value
22
- }];
23
- }
24
- return child;
25
- });
26
- return {
27
- ...node,
28
- children
29
- };
30
- }
31
- }
package/dist/esm/types.js DELETED
@@ -1,2 +0,0 @@
1
- export const SLATE_DEFAULT_BLOCK_TYPE = 'paragraph';
2
- export const SLATE_BLOCK_PARENT_TYPES = ['list-item', 'quote'];