@atlaskit/editor-core 183.0.8 → 183.0.9

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 (27) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/plugins/paste/md-plugins/ignore-list-heading-md-plugin.js +47 -0
  3. package/dist/cjs/plugins/paste/{linkify-md-plugin.js → md-plugins/linkify-md-plugin.js} +1 -1
  4. package/dist/cjs/plugins/paste/md.js +6 -4
  5. package/dist/cjs/version-wrapper.js +1 -1
  6. package/dist/cjs/version.json +1 -1
  7. package/dist/es2019/plugins/paste/md-plugins/ignore-list-heading-md-plugin.js +43 -0
  8. package/dist/es2019/plugins/paste/{linkify-md-plugin.js → md-plugins/linkify-md-plugin.js} +1 -1
  9. package/dist/es2019/plugins/paste/md.js +6 -4
  10. package/dist/es2019/version-wrapper.js +1 -1
  11. package/dist/es2019/version.json +1 -1
  12. package/dist/esm/plugins/paste/md-plugins/ignore-list-heading-md-plugin.js +41 -0
  13. package/dist/esm/plugins/paste/{linkify-md-plugin.js → md-plugins/linkify-md-plugin.js} +1 -1
  14. package/dist/esm/plugins/paste/md.js +6 -4
  15. package/dist/esm/version-wrapper.js +1 -1
  16. package/dist/esm/version.json +1 -1
  17. package/dist/types/plugins/paste/md-plugins/ignore-list-heading-md-plugin.d.ts +2 -0
  18. package/package.json +4 -4
  19. /package/dist/cjs/plugins/paste/{newline-md-plugin.js → md-plugins/newline-md-plugin.js} +0 -0
  20. /package/dist/cjs/plugins/paste/{paragraph-md-plugin.js → md-plugins/paragraph-md-plugin.js} +0 -0
  21. /package/dist/es2019/plugins/paste/{newline-md-plugin.js → md-plugins/newline-md-plugin.js} +0 -0
  22. /package/dist/es2019/plugins/paste/{paragraph-md-plugin.js → md-plugins/paragraph-md-plugin.js} +0 -0
  23. /package/dist/esm/plugins/paste/{newline-md-plugin.js → md-plugins/newline-md-plugin.js} +0 -0
  24. /package/dist/esm/plugins/paste/{paragraph-md-plugin.js → md-plugins/paragraph-md-plugin.js} +0 -0
  25. /package/dist/types/plugins/paste/{linkify-md-plugin.d.ts → md-plugins/linkify-md-plugin.d.ts} +0 -0
  26. /package/dist/types/plugins/paste/{newline-md-plugin.d.ts → md-plugins/newline-md-plugin.d.ts} +0 -0
  27. /package/dist/types/plugins/paste/{paragraph-md-plugin.d.ts → md-plugins/paragraph-md-plugin.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 183.0.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [`333fa827c25`](https://bitbucket.org/atlassian/atlassian-frontend/commits/333fa827c25) - ED-15646: Fix paste behaviour for markdown which contains headings inside list items. List items with headings will now be retained.
8
+
3
9
  ## 183.0.8
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = _default;
7
+ /*
8
+ * ED-15646
9
+ * Headings in list items are not supported in our schema.
10
+ * As the markdown transformer is used by the paste plugin,
11
+ * certain pastes will strip invalid lines as
12
+ * prosemirror-markdown cannot conform to the schema
13
+ */
14
+
15
+ function handleHeadingOpen(state, token, acc, index) {
16
+ var _state$tokens;
17
+ var isInListItem = ((_state$tokens = state.tokens[index - 1]) === null || _state$tokens === void 0 ? void 0 : _state$tokens.type) === 'list_item_open';
18
+ if (isInListItem) {
19
+ acc.push(new state.Token('paragraph_open', 'p', 1));
20
+ } else {
21
+ acc.push(token);
22
+ }
23
+ }
24
+ function handleHeadingClose(state, token, acc, index) {
25
+ var _state$tokens2;
26
+ var isInListItem = ((_state$tokens2 = state.tokens[index + 1]) === null || _state$tokens2 === void 0 ? void 0 : _state$tokens2.type) === 'list_item_close';
27
+ if (isInListItem) {
28
+ acc.push(new state.Token('paragraph_close', 'p', -1));
29
+ } else {
30
+ acc.push(token);
31
+ }
32
+ }
33
+ function _default(md) {
34
+ md.core.ruler.after('inline', 'ignore-list-heading-md-plugin', function (state) {
35
+ state.tokens = state.tokens.reduce(function (acc, token, index) {
36
+ var type = token.type;
37
+ if (type === 'heading_open') {
38
+ handleHeadingOpen(state, token, acc, index);
39
+ } else if (type === 'heading_close') {
40
+ handleHeadingClose(state, token, acc, index);
41
+ } else {
42
+ acc.push(token);
43
+ }
44
+ return acc;
45
+ }, []);
46
+ });
47
+ }
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _adfSchema = require("@atlaskit/adf-schema");
9
9
  var _linkifyIt = _interopRequireDefault(require("linkify-it"));
10
- var _utils = require("../hyperlink/utils");
10
+ var _utils = require("../../hyperlink/utils");
11
11
  // File has been copied to packages/editor/editor-plugin-ai/src/provider/markdown-transformer/md/linkify-md-plugin.ts
12
12
  // If changes are made to this file, please make the same update in the linked file.
13
13
 
@@ -6,9 +6,10 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.md = void 0;
8
8
  var _markdownIt = _interopRequireDefault(require("markdown-it"));
9
- var _linkifyMdPlugin = _interopRequireDefault(require("./linkify-md-plugin"));
10
- var _newlineMdPlugin = _interopRequireDefault(require("./newline-md-plugin"));
11
- var _paragraphMdPlugin = _interopRequireDefault(require("./paragraph-md-plugin"));
9
+ var _linkifyMdPlugin = _interopRequireDefault(require("./md-plugins/linkify-md-plugin"));
10
+ var _newlineMdPlugin = _interopRequireDefault(require("./md-plugins/newline-md-plugin"));
11
+ var _paragraphMdPlugin = _interopRequireDefault(require("./md-plugins/paragraph-md-plugin"));
12
+ var _ignoreListHeadingMdPlugin = _interopRequireDefault(require("./md-plugins/ignore-list-heading-md-plugin"));
12
13
  // File has been copied to packages/editor/editor-plugin-ai/src/provider/markdown-transformer/md/index.ts
13
14
  // If changes are made to this file, please make the same update in the linked file.
14
15
 
@@ -26,4 +27,5 @@ md.use(_paragraphMdPlugin.default);
26
27
  // enable modified version of linkify plugin
27
28
  // @see https://product-fabric.atlassian.net/browse/ED-3097
28
29
  md.use(_linkifyMdPlugin.default);
29
- md.use(_newlineMdPlugin.default);
30
+ md.use(_newlineMdPlugin.default);
31
+ md.use(_ignoreListHeadingMdPlugin.default);
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "183.0.8";
9
+ var version = "183.0.9";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "183.0.8",
3
+ "version": "183.0.9",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,43 @@
1
+ /*
2
+ * ED-15646
3
+ * Headings in list items are not supported in our schema.
4
+ * As the markdown transformer is used by the paste plugin,
5
+ * certain pastes will strip invalid lines as
6
+ * prosemirror-markdown cannot conform to the schema
7
+ */
8
+
9
+ function handleHeadingOpen(state, token, acc, index) {
10
+ var _state$tokens;
11
+ const isInListItem = ((_state$tokens = state.tokens[index - 1]) === null || _state$tokens === void 0 ? void 0 : _state$tokens.type) === 'list_item_open';
12
+ if (isInListItem) {
13
+ acc.push(new state.Token('paragraph_open', 'p', 1));
14
+ } else {
15
+ acc.push(token);
16
+ }
17
+ }
18
+ function handleHeadingClose(state, token, acc, index) {
19
+ var _state$tokens2;
20
+ const isInListItem = ((_state$tokens2 = state.tokens[index + 1]) === null || _state$tokens2 === void 0 ? void 0 : _state$tokens2.type) === 'list_item_close';
21
+ if (isInListItem) {
22
+ acc.push(new state.Token('paragraph_close', 'p', -1));
23
+ } else {
24
+ acc.push(token);
25
+ }
26
+ }
27
+ export default function (md) {
28
+ md.core.ruler.after('inline', 'ignore-list-heading-md-plugin', function (state) {
29
+ state.tokens = state.tokens.reduce((acc, token, index) => {
30
+ const {
31
+ type
32
+ } = token;
33
+ if (type === 'heading_open') {
34
+ handleHeadingOpen(state, token, acc, index);
35
+ } else if (type === 'heading_close') {
36
+ handleHeadingClose(state, token, acc, index);
37
+ } else {
38
+ acc.push(token);
39
+ }
40
+ return acc;
41
+ }, []);
42
+ });
43
+ }
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { linkifyMatch } from '@atlaskit/adf-schema';
5
5
  import LinkifyIt from 'linkify-it';
6
- import { findFilepaths, isLinkInMatches } from '../hyperlink/utils';
6
+ import { findFilepaths, isLinkInMatches } from '../../hyperlink/utils';
7
7
 
8
8
  // modified version of the original Linkify plugin
9
9
  // https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js
@@ -2,9 +2,10 @@
2
2
  // If changes are made to this file, please make the same update in the linked file.
3
3
 
4
4
  import MarkdownIt from 'markdown-it';
5
- import linkify from './linkify-md-plugin';
6
- import newline from './newline-md-plugin';
7
- import paragraph from './paragraph-md-plugin';
5
+ import linkify from './md-plugins/linkify-md-plugin';
6
+ import newline from './md-plugins/newline-md-plugin';
7
+ import paragraph from './md-plugins/paragraph-md-plugin';
8
+ import ignoreListHeading from './md-plugins/ignore-list-heading-md-plugin';
8
9
  export const md = MarkdownIt('zero', {
9
10
  html: false
10
11
  });
@@ -18,4 +19,5 @@ md.use(paragraph);
18
19
  // enable modified version of linkify plugin
19
20
  // @see https://product-fabric.atlassian.net/browse/ED-3097
20
21
  md.use(linkify);
21
- md.use(newline);
22
+ md.use(newline);
23
+ md.use(ignoreListHeading);
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "183.0.8";
2
+ export const version = "183.0.9";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "183.0.8",
3
+ "version": "183.0.9",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,41 @@
1
+ /*
2
+ * ED-15646
3
+ * Headings in list items are not supported in our schema.
4
+ * As the markdown transformer is used by the paste plugin,
5
+ * certain pastes will strip invalid lines as
6
+ * prosemirror-markdown cannot conform to the schema
7
+ */
8
+
9
+ function handleHeadingOpen(state, token, acc, index) {
10
+ var _state$tokens;
11
+ var isInListItem = ((_state$tokens = state.tokens[index - 1]) === null || _state$tokens === void 0 ? void 0 : _state$tokens.type) === 'list_item_open';
12
+ if (isInListItem) {
13
+ acc.push(new state.Token('paragraph_open', 'p', 1));
14
+ } else {
15
+ acc.push(token);
16
+ }
17
+ }
18
+ function handleHeadingClose(state, token, acc, index) {
19
+ var _state$tokens2;
20
+ var isInListItem = ((_state$tokens2 = state.tokens[index + 1]) === null || _state$tokens2 === void 0 ? void 0 : _state$tokens2.type) === 'list_item_close';
21
+ if (isInListItem) {
22
+ acc.push(new state.Token('paragraph_close', 'p', -1));
23
+ } else {
24
+ acc.push(token);
25
+ }
26
+ }
27
+ export default function (md) {
28
+ md.core.ruler.after('inline', 'ignore-list-heading-md-plugin', function (state) {
29
+ state.tokens = state.tokens.reduce(function (acc, token, index) {
30
+ var type = token.type;
31
+ if (type === 'heading_open') {
32
+ handleHeadingOpen(state, token, acc, index);
33
+ } else if (type === 'heading_close') {
34
+ handleHeadingClose(state, token, acc, index);
35
+ } else {
36
+ acc.push(token);
37
+ }
38
+ return acc;
39
+ }, []);
40
+ });
41
+ }
@@ -3,7 +3,7 @@
3
3
 
4
4
  import { linkifyMatch } from '@atlaskit/adf-schema';
5
5
  import LinkifyIt from 'linkify-it';
6
- import { findFilepaths, isLinkInMatches } from '../hyperlink/utils';
6
+ import { findFilepaths, isLinkInMatches } from '../../hyperlink/utils';
7
7
 
8
8
  // modified version of the original Linkify plugin
9
9
  // https://github.com/markdown-it/markdown-it/blob/master/lib/rules_core/linkify.js
@@ -2,9 +2,10 @@
2
2
  // If changes are made to this file, please make the same update in the linked file.
3
3
 
4
4
  import MarkdownIt from 'markdown-it';
5
- import linkify from './linkify-md-plugin';
6
- import newline from './newline-md-plugin';
7
- import paragraph from './paragraph-md-plugin';
5
+ import linkify from './md-plugins/linkify-md-plugin';
6
+ import newline from './md-plugins/newline-md-plugin';
7
+ import paragraph from './md-plugins/paragraph-md-plugin';
8
+ import ignoreListHeading from './md-plugins/ignore-list-heading-md-plugin';
8
9
  export var md = MarkdownIt('zero', {
9
10
  html: false
10
11
  });
@@ -18,4 +19,5 @@ md.use(paragraph);
18
19
  // enable modified version of linkify plugin
19
20
  // @see https://product-fabric.atlassian.net/browse/ED-3097
20
21
  md.use(linkify);
21
- md.use(newline);
22
+ md.use(newline);
23
+ md.use(ignoreListHeading);
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "183.0.8";
2
+ export var version = "183.0.9";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "183.0.8",
3
+ "version": "183.0.9",
4
4
  "sideEffects": false
5
5
  }
@@ -0,0 +1,2 @@
1
+ import type MarkdownIt from 'markdown-it';
2
+ export default function (md: MarkdownIt): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "183.0.8",
3
+ "version": "183.0.9",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -178,9 +178,9 @@
178
178
  "@atlaskit/visual-regression": "*",
179
179
  "@atlaskit/webdriver-runner": "*",
180
180
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
181
- "@atlassian/link-picker-atlassian-plugin": "^30.0.0",
182
- "@atlassian/link-picker-plugins": "^20.0.0",
183
- "@atlassian/search-provider": "2.4.1",
181
+ "@atlassian/link-picker-atlassian-plugin": "^30.1.0",
182
+ "@atlassian/link-picker-plugins": "^20.1.0",
183
+ "@atlassian/search-provider": "2.4.2",
184
184
  "@atlassian/ufo": "^0.2.0",
185
185
  "@emotion/jest": "^11.8.0",
186
186
  "@storybook/addon-knobs": "^5.3.18",