@atlaskit/editor-slack-transformer 3.7.2 → 3.7.4
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 +79 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/serializer.js +59 -10
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/serializer.js +48 -4
- package/dist/esm/index.js +1 -0
- package/dist/esm/serializer.js +59 -10
- package/dist/types/serializer.d.ts +26 -4
- package/dist/types-ts4.5/serializer.d.ts +26 -4
- package/example-helpers/ToolsDrawer.tsx +2 -2
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,84 @@
|
|
|
1
1
|
# @atlaskit/editor-slack-transformer
|
|
2
2
|
|
|
3
|
+
## 3.7.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#147003](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147003)
|
|
8
|
+
[`f4f413727e260`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f4f413727e260) -
|
|
9
|
+
[EDF-1041] Remove platform typings prosemirror-markdown from project
|
|
10
|
+
|
|
11
|
+
## 3.7.3
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#146378](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/146378)
|
|
16
|
+
[`134a849673ebd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/134a849673ebd) -
|
|
17
|
+
This change removes the following public API from the @atlaskit/editor-core entry-point.
|
|
18
|
+
|
|
19
|
+
### WHY?
|
|
20
|
+
|
|
21
|
+
We are making the editor-core package smaller to reduce bundle size and make it easier to scale as
|
|
22
|
+
its functionality grows.
|
|
23
|
+
|
|
24
|
+
The long term goal is that the core editor is lightweight and its feature set is enriched by the
|
|
25
|
+
powerful plugin system developed (and used via the `ComposableEditor`).
|
|
26
|
+
|
|
27
|
+
This change is made to reduce how the core editor is coupled to its functionality by removing
|
|
28
|
+
exports that can be imported from other packages and cleanup up props that are unused internally.
|
|
29
|
+
|
|
30
|
+
### WHAT/HOW?
|
|
31
|
+
|
|
32
|
+
The following lists the exports removed as well as where they can now be found if required.
|
|
33
|
+
|
|
34
|
+
Exports removed:
|
|
35
|
+
|
|
36
|
+
- ToolbarFeedback (removed)
|
|
37
|
+
- EmojiResource (moved to -> @atlaskit/emoji/resource)
|
|
38
|
+
- MentionResource (moved to -> @atlaskit/mention/resource)
|
|
39
|
+
- MentionProvider (moved to -> @atlaskit/mention/resource)
|
|
40
|
+
- PresenceProvider (moved to -> @atlaskit/mention/resource)
|
|
41
|
+
- TeamMentionProvider (moved to -> @atlaskit/mention/team-resource)
|
|
42
|
+
- AnnotationUpdateEmitter (moved to -> @atlaskit/editor-common/annotation)
|
|
43
|
+
- UpdateEvent (moved to -> @atlaskit/editor-common/annotation)
|
|
44
|
+
- AnnotationProviders (moved to -> @atlaskit/editor-plugins/annotation)
|
|
45
|
+
- InlineCommentAnnotationProvider (moved to -> @atlaskit/editor-plugins/annotation)
|
|
46
|
+
- InlineCommentCreateComponentProps (moved to -> @atlaskit/editor-plugins/annotation)
|
|
47
|
+
- InlineCommentViewComponentProps (moved to -> @atlaskit/editor-plugins/annotation)
|
|
48
|
+
- AnnotationInfo (moved to -> @atlaskit/editor-plugins/annotation)
|
|
49
|
+
- AnnotationState (moved to -> @atlaskit/editor-plugins/annotation)
|
|
50
|
+
- AnnotationTypeProvider (moved to -> @atlaskit/editor-plugins/annotation)
|
|
51
|
+
- InlineCommentState (moved to -> @atlaskit/editor-plugins/annotation)
|
|
52
|
+
- TypeAheadItem (moved to -> @atlaskit/editor-common/provider-factory)
|
|
53
|
+
- INPUT_METHOD (moved to -> @atlaskit/editor-common/analytics)
|
|
54
|
+
- ACTION (moved to -> @atlaskit/editor-common/analytics)
|
|
55
|
+
- ACTION_SUBJECT (moved to -> @atlaskit/editor-common/analytics)
|
|
56
|
+
- ACTION_SUBJECT_ID (moved to -> @atlaskit/editor-common/analytics)
|
|
57
|
+
- EVENT_TYPE (moved to -> @atlaskit/editor-common/analytics)
|
|
58
|
+
- MacroProvider (moved to -> @atlaskit/editor-common/provider-factory) (except proforma-dc)
|
|
59
|
+
- MacroAttributes (moved to -> @atlaskit/editor-common/provider-factory) (except proforma-dc)
|
|
60
|
+
- ExtensionType (moved to -> @atlaskit/editor-common/provider-factory)
|
|
61
|
+
- CardProvider (moved to -> @atlaskit/editor-common/provider-factory)
|
|
62
|
+
- MediaProvider (moved to -> @atlaskit/editor-common/provider-factory)
|
|
63
|
+
- MediaOptions (moved to -> @atlaskit/editor-plugins/media/types)
|
|
64
|
+
- QuickInsertItem (moved to -> @atlaskit/editor-common/provider-factory)
|
|
65
|
+
- QuickInsertProvider (moved to -> @atlaskit/editor-common/provider-factory)
|
|
66
|
+
|
|
67
|
+
The following lists the editor props removed. Generally these are not used by the editor at all
|
|
68
|
+
and can be safely removed without any change in functionality
|
|
69
|
+
|
|
70
|
+
EditorProps removed:
|
|
71
|
+
|
|
72
|
+
- trackValidTransactions (unused internally, please remove)
|
|
73
|
+
- hideAvatarGroup (unused internally, please remove)
|
|
74
|
+
- placeholder (unused internally for `ComposableEditor` - please pass to the `placeholderPlugin`
|
|
75
|
+
options)
|
|
76
|
+
- placeholderBracketHint (unused internally for `ComposableEditor` - please pass to the
|
|
77
|
+
`placeholderPlugin` options)
|
|
78
|
+
- allowJiraIssue (unused internally, please remove)
|
|
79
|
+
- allowNewInsertionBehaviour (unused internally, please remove)
|
|
80
|
+
- UNSAFE_allowBorderMark (use `allowBorderMark` instead)
|
|
81
|
+
|
|
3
82
|
## 3.7.2
|
|
4
83
|
|
|
5
84
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,6 +12,7 @@ var _serializer = require("./serializer");
|
|
|
12
12
|
var SlackTransformer = exports.SlackTransformer = /*#__PURE__*/function () {
|
|
13
13
|
function SlackTransformer() {
|
|
14
14
|
(0, _classCallCheck2.default)(this, SlackTransformer);
|
|
15
|
+
// @ts-expect-error - Our node definitions are not compatible with prosemirror-markdown types
|
|
15
16
|
(0, _defineProperty2.default)(this, "serializer", new _serializer.MarkdownSerializer(_serializer.nodes, _serializer.marks));
|
|
16
17
|
}
|
|
17
18
|
(0, _createClass2.default)(SlackTransformer, [{
|
package/dist/cjs/serializer.js
CHANGED
|
@@ -5,12 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.nodes = exports.marks = exports.MarkdownSerializerState = exports.MarkdownSerializer = void 0;
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
11
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
12
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
13
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
15
|
var _markdown = require("@atlaskit/editor-prosemirror/markdown");
|
|
15
16
|
var _util = require("./util");
|
|
16
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; }
|
|
@@ -20,23 +21,71 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
|
|
|
20
21
|
var MarkdownSerializerState = exports.MarkdownSerializerState = /*#__PURE__*/function (_PMMarkdownSerializer) {
|
|
21
22
|
(0, _inherits2.default)(MarkdownSerializerState, _PMMarkdownSerializer);
|
|
22
23
|
var _super = _createSuper(MarkdownSerializerState);
|
|
23
|
-
function MarkdownSerializerState() {
|
|
24
|
+
function MarkdownSerializerState(nodes, marks) {
|
|
25
|
+
var _this;
|
|
24
26
|
(0, _classCallCheck2.default)(this, MarkdownSerializerState);
|
|
25
|
-
|
|
27
|
+
// @ts-ignore-next-line
|
|
28
|
+
_this = _super.call(this, nodes, marks, {});
|
|
29
|
+
/**
|
|
30
|
+
* Defines the internal variables used in the markdown serializer
|
|
31
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L172
|
|
32
|
+
*/
|
|
33
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "delim", '');
|
|
34
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "out", '');
|
|
35
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "closed", null);
|
|
36
|
+
_this.nodes = nodes;
|
|
37
|
+
_this.marks = marks;
|
|
38
|
+
return _this;
|
|
26
39
|
}
|
|
27
40
|
(0, _createClass2.default)(MarkdownSerializerState, [{
|
|
41
|
+
key: "atBlank",
|
|
42
|
+
value:
|
|
43
|
+
/**
|
|
44
|
+
* Defines the internal atBlank method used in the markdown serializer
|
|
45
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L241
|
|
46
|
+
*/
|
|
47
|
+
function atBlank() {
|
|
48
|
+
return /(^|\n)$/.test(this.out);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Defines the internal flushClose method used in the markdown serializer
|
|
53
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L202
|
|
54
|
+
*/
|
|
55
|
+
}, {
|
|
56
|
+
key: "flushClose",
|
|
57
|
+
value: function flushClose() {
|
|
58
|
+
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2;
|
|
59
|
+
if (this.closed) {
|
|
60
|
+
if (!this.atBlank()) {
|
|
61
|
+
this.out += '\n';
|
|
62
|
+
}
|
|
63
|
+
if (size > 1) {
|
|
64
|
+
var delimMin = this.delim;
|
|
65
|
+
var trim = /\s+$/.exec(delimMin);
|
|
66
|
+
if (trim) {
|
|
67
|
+
delimMin = delimMin.slice(0, delimMin.length - trim[0].length);
|
|
68
|
+
}
|
|
69
|
+
for (var i = 1; i < size; i++) {
|
|
70
|
+
this.out += delimMin + '\n';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
this.closed = null;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}, {
|
|
28
77
|
key: "renderContent",
|
|
29
78
|
value: function renderContent(parent) {
|
|
30
|
-
var
|
|
79
|
+
var _this2 = this;
|
|
31
80
|
parent.forEach(function (child, _offset, index) {
|
|
32
81
|
if (
|
|
33
82
|
// If child is an empty Textblock we need to insert a zwnj-character in order to preserve that line in markdown
|
|
34
83
|
child.isTextblock && !child.textContent &&
|
|
35
84
|
// If child is a Codeblock we need to handle this separately as we want to preserve empty code blocks
|
|
36
85
|
!(child.type.name === 'codeBlock') && !(child.content && child.content.size > 0)) {
|
|
37
|
-
return nodes.empty_line(
|
|
86
|
+
return nodes.empty_line(_this2, child);
|
|
38
87
|
}
|
|
39
|
-
return
|
|
88
|
+
return _this2.render(child, parent, index);
|
|
40
89
|
});
|
|
41
90
|
}
|
|
42
91
|
}]);
|
|
@@ -51,8 +100,8 @@ var MarkdownSerializer = exports.MarkdownSerializer = /*#__PURE__*/function (_PM
|
|
|
51
100
|
}
|
|
52
101
|
(0, _createClass2.default)(MarkdownSerializer, [{
|
|
53
102
|
key: "serialize",
|
|
54
|
-
value: function serialize(content
|
|
55
|
-
var state = new MarkdownSerializerState(this.nodes, this.marks
|
|
103
|
+
value: function serialize(content) {
|
|
104
|
+
var state = new MarkdownSerializerState(this.nodes, this.marks);
|
|
56
105
|
state.renderContent(content);
|
|
57
106
|
return state.out === "\u200C" ? '' : state.out; // Return empty string if editor only contains a zero-non-width character
|
|
58
107
|
}
|
|
@@ -125,7 +174,7 @@ var unsupportedNodes = {
|
|
|
125
174
|
};
|
|
126
175
|
var nodes = exports.nodes = _objectSpread({
|
|
127
176
|
blockquote: function blockquote(state, node) {
|
|
128
|
-
state.wrapBlock('> ',
|
|
177
|
+
state.wrapBlock('> ', null, node, function () {
|
|
129
178
|
return state.renderContent(node);
|
|
130
179
|
});
|
|
131
180
|
},
|
|
@@ -168,7 +217,7 @@ var nodes = exports.nodes = _objectSpread({
|
|
|
168
217
|
return state.render(child, parent, i);
|
|
169
218
|
});
|
|
170
219
|
} else {
|
|
171
|
-
state.wrapBlock(' ',
|
|
220
|
+
state.wrapBlock(' ', null, node, function () {
|
|
172
221
|
return state.render(child, parent, i);
|
|
173
222
|
});
|
|
174
223
|
}
|
package/dist/es2019/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
import { MarkdownSerializer, marks, nodes } from './serializer';
|
|
3
3
|
export class SlackTransformer {
|
|
4
4
|
constructor() {
|
|
5
|
+
// @ts-expect-error - Our node definitions are not compatible with prosemirror-markdown types
|
|
5
6
|
_defineProperty(this, "serializer", new MarkdownSerializer(nodes, marks));
|
|
6
7
|
}
|
|
7
8
|
encode(node) {
|
|
@@ -1,6 +1,50 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import { MarkdownSerializer as PMMarkdownSerializer, MarkdownSerializerState as PMMarkdownSerializerState } from '@atlaskit/editor-prosemirror/markdown';
|
|
2
3
|
import { escapeMarkdown } from './util';
|
|
3
4
|
export class MarkdownSerializerState extends PMMarkdownSerializerState {
|
|
5
|
+
/**
|
|
6
|
+
* Defines the internal atBlank method used in the markdown serializer
|
|
7
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L241
|
|
8
|
+
*/
|
|
9
|
+
atBlank() {
|
|
10
|
+
return /(^|\n)$/.test(this.out);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Defines the internal flushClose method used in the markdown serializer
|
|
15
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L202
|
|
16
|
+
*/
|
|
17
|
+
flushClose(size = 2) {
|
|
18
|
+
if (this.closed) {
|
|
19
|
+
if (!this.atBlank()) {
|
|
20
|
+
this.out += '\n';
|
|
21
|
+
}
|
|
22
|
+
if (size > 1) {
|
|
23
|
+
let delimMin = this.delim;
|
|
24
|
+
let trim = /\s+$/.exec(delimMin);
|
|
25
|
+
if (trim) {
|
|
26
|
+
delimMin = delimMin.slice(0, delimMin.length - trim[0].length);
|
|
27
|
+
}
|
|
28
|
+
for (let i = 1; i < size; i++) {
|
|
29
|
+
this.out += delimMin + '\n';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
this.closed = null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
constructor(nodes, marks) {
|
|
36
|
+
// @ts-ignore-next-line
|
|
37
|
+
super(nodes, marks, {});
|
|
38
|
+
/**
|
|
39
|
+
* Defines the internal variables used in the markdown serializer
|
|
40
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L172
|
|
41
|
+
*/
|
|
42
|
+
_defineProperty(this, "delim", '');
|
|
43
|
+
_defineProperty(this, "out", '');
|
|
44
|
+
_defineProperty(this, "closed", null);
|
|
45
|
+
this.nodes = nodes;
|
|
46
|
+
this.marks = marks;
|
|
47
|
+
}
|
|
4
48
|
renderContent(parent) {
|
|
5
49
|
parent.forEach((child, _offset, index) => {
|
|
6
50
|
if (
|
|
@@ -15,8 +59,8 @@ export class MarkdownSerializerState extends PMMarkdownSerializerState {
|
|
|
15
59
|
}
|
|
16
60
|
}
|
|
17
61
|
export class MarkdownSerializer extends PMMarkdownSerializer {
|
|
18
|
-
serialize(content
|
|
19
|
-
const state = new MarkdownSerializerState(this.nodes, this.marks
|
|
62
|
+
serialize(content) {
|
|
63
|
+
const state = new MarkdownSerializerState(this.nodes, this.marks);
|
|
20
64
|
state.renderContent(content);
|
|
21
65
|
return state.out === '\u200c' ? '' : state.out; // Return empty string if editor only contains a zero-non-width character
|
|
22
66
|
}
|
|
@@ -88,7 +132,7 @@ const unsupportedNodes = {
|
|
|
88
132
|
};
|
|
89
133
|
export const nodes = {
|
|
90
134
|
blockquote(state, node) {
|
|
91
|
-
state.wrapBlock('> ',
|
|
135
|
+
state.wrapBlock('> ', null, node, () => state.renderContent(node));
|
|
92
136
|
},
|
|
93
137
|
codeBlock(state, node) {
|
|
94
138
|
state.write('```');
|
|
@@ -127,7 +171,7 @@ export const nodes = {
|
|
|
127
171
|
if (i === 0) {
|
|
128
172
|
state.wrapBlock(' ', delimiter, node, () => state.render(child, parent, i));
|
|
129
173
|
} else {
|
|
130
|
-
state.wrapBlock(' ',
|
|
174
|
+
state.wrapBlock(' ', null, node, () => state.render(child, parent, i));
|
|
131
175
|
}
|
|
132
176
|
if (child.type.name === 'paragraph' && i > 0) {
|
|
133
177
|
state.write('\n');
|
package/dist/esm/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import { MarkdownSerializer, marks, nodes } from './serializer';
|
|
|
5
5
|
export var SlackTransformer = /*#__PURE__*/function () {
|
|
6
6
|
function SlackTransformer() {
|
|
7
7
|
_classCallCheck(this, SlackTransformer);
|
|
8
|
+
// @ts-expect-error - Our node definitions are not compatible with prosemirror-markdown types
|
|
8
9
|
_defineProperty(this, "serializer", new MarkdownSerializer(nodes, marks));
|
|
9
10
|
}
|
|
10
11
|
_createClass(SlackTransformer, [{
|
package/dist/esm/serializer.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
3
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
+
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
4
|
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
5
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
6
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
8
|
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
9
|
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
10
|
function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
|
|
@@ -13,23 +14,71 @@ import { escapeMarkdown } from './util';
|
|
|
13
14
|
export var MarkdownSerializerState = /*#__PURE__*/function (_PMMarkdownSerializer) {
|
|
14
15
|
_inherits(MarkdownSerializerState, _PMMarkdownSerializer);
|
|
15
16
|
var _super = _createSuper(MarkdownSerializerState);
|
|
16
|
-
function MarkdownSerializerState() {
|
|
17
|
+
function MarkdownSerializerState(nodes, marks) {
|
|
18
|
+
var _this;
|
|
17
19
|
_classCallCheck(this, MarkdownSerializerState);
|
|
18
|
-
|
|
20
|
+
// @ts-ignore-next-line
|
|
21
|
+
_this = _super.call(this, nodes, marks, {});
|
|
22
|
+
/**
|
|
23
|
+
* Defines the internal variables used in the markdown serializer
|
|
24
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L172
|
|
25
|
+
*/
|
|
26
|
+
_defineProperty(_assertThisInitialized(_this), "delim", '');
|
|
27
|
+
_defineProperty(_assertThisInitialized(_this), "out", '');
|
|
28
|
+
_defineProperty(_assertThisInitialized(_this), "closed", null);
|
|
29
|
+
_this.nodes = nodes;
|
|
30
|
+
_this.marks = marks;
|
|
31
|
+
return _this;
|
|
19
32
|
}
|
|
20
33
|
_createClass(MarkdownSerializerState, [{
|
|
34
|
+
key: "atBlank",
|
|
35
|
+
value:
|
|
36
|
+
/**
|
|
37
|
+
* Defines the internal atBlank method used in the markdown serializer
|
|
38
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L241
|
|
39
|
+
*/
|
|
40
|
+
function atBlank() {
|
|
41
|
+
return /(^|\n)$/.test(this.out);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Defines the internal flushClose method used in the markdown serializer
|
|
46
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L202
|
|
47
|
+
*/
|
|
48
|
+
}, {
|
|
49
|
+
key: "flushClose",
|
|
50
|
+
value: function flushClose() {
|
|
51
|
+
var size = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2;
|
|
52
|
+
if (this.closed) {
|
|
53
|
+
if (!this.atBlank()) {
|
|
54
|
+
this.out += '\n';
|
|
55
|
+
}
|
|
56
|
+
if (size > 1) {
|
|
57
|
+
var delimMin = this.delim;
|
|
58
|
+
var trim = /\s+$/.exec(delimMin);
|
|
59
|
+
if (trim) {
|
|
60
|
+
delimMin = delimMin.slice(0, delimMin.length - trim[0].length);
|
|
61
|
+
}
|
|
62
|
+
for (var i = 1; i < size; i++) {
|
|
63
|
+
this.out += delimMin + '\n';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
this.closed = null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}, {
|
|
21
70
|
key: "renderContent",
|
|
22
71
|
value: function renderContent(parent) {
|
|
23
|
-
var
|
|
72
|
+
var _this2 = this;
|
|
24
73
|
parent.forEach(function (child, _offset, index) {
|
|
25
74
|
if (
|
|
26
75
|
// If child is an empty Textblock we need to insert a zwnj-character in order to preserve that line in markdown
|
|
27
76
|
child.isTextblock && !child.textContent &&
|
|
28
77
|
// If child is a Codeblock we need to handle this separately as we want to preserve empty code blocks
|
|
29
78
|
!(child.type.name === 'codeBlock') && !(child.content && child.content.size > 0)) {
|
|
30
|
-
return nodes.empty_line(
|
|
79
|
+
return nodes.empty_line(_this2, child);
|
|
31
80
|
}
|
|
32
|
-
return
|
|
81
|
+
return _this2.render(child, parent, index);
|
|
33
82
|
});
|
|
34
83
|
}
|
|
35
84
|
}]);
|
|
@@ -44,8 +93,8 @@ export var MarkdownSerializer = /*#__PURE__*/function (_PMMarkdownSerializer2) {
|
|
|
44
93
|
}
|
|
45
94
|
_createClass(MarkdownSerializer, [{
|
|
46
95
|
key: "serialize",
|
|
47
|
-
value: function serialize(content
|
|
48
|
-
var state = new MarkdownSerializerState(this.nodes, this.marks
|
|
96
|
+
value: function serialize(content) {
|
|
97
|
+
var state = new MarkdownSerializerState(this.nodes, this.marks);
|
|
49
98
|
state.renderContent(content);
|
|
50
99
|
return state.out === "\u200C" ? '' : state.out; // Return empty string if editor only contains a zero-non-width character
|
|
51
100
|
}
|
|
@@ -119,7 +168,7 @@ var unsupportedNodes = {
|
|
|
119
168
|
};
|
|
120
169
|
export var nodes = _objectSpread({
|
|
121
170
|
blockquote: function blockquote(state, node) {
|
|
122
|
-
state.wrapBlock('> ',
|
|
171
|
+
state.wrapBlock('> ', null, node, function () {
|
|
123
172
|
return state.renderContent(node);
|
|
124
173
|
});
|
|
125
174
|
},
|
|
@@ -162,7 +211,7 @@ export var nodes = _objectSpread({
|
|
|
162
211
|
return state.render(child, parent, i);
|
|
163
212
|
});
|
|
164
213
|
} else {
|
|
165
|
-
state.wrapBlock(' ',
|
|
214
|
+
state.wrapBlock(' ', null, node, function () {
|
|
166
215
|
return state.render(child, parent, i);
|
|
167
216
|
});
|
|
168
217
|
}
|
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
import { MarkdownSerializer as PMMarkdownSerializer, MarkdownSerializerState as PMMarkdownSerializerState } from '@atlaskit/editor-prosemirror/markdown';
|
|
1
|
+
import { MarkdownSerializer as PMMarkdownSerializer, MarkdownSerializerState as PMMarkdownSerializerState, type NodeSerializerSpec, type MarkSerializerSpec } from '@atlaskit/editor-prosemirror/markdown';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
export declare class MarkdownSerializerState extends PMMarkdownSerializerState {
|
|
4
|
+
nodes: NodeSerializerSpec;
|
|
5
|
+
marks: {
|
|
6
|
+
[mark: string]: MarkSerializerSpec;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Defines the internal variables used in the markdown serializer
|
|
10
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L172
|
|
11
|
+
*/
|
|
12
|
+
delim: string;
|
|
13
|
+
out: string;
|
|
14
|
+
closed: Node | null;
|
|
15
|
+
/**
|
|
16
|
+
* Defines the internal atBlank method used in the markdown serializer
|
|
17
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L241
|
|
18
|
+
*/
|
|
19
|
+
atBlank(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Defines the internal flushClose method used in the markdown serializer
|
|
22
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L202
|
|
23
|
+
*/
|
|
24
|
+
flushClose(size?: number): void;
|
|
25
|
+
constructor(nodes: NodeSerializerSpec, marks: {
|
|
26
|
+
[mark: string]: MarkSerializerSpec;
|
|
27
|
+
});
|
|
4
28
|
renderContent(parent: PMNode): void;
|
|
5
29
|
}
|
|
6
30
|
export declare class MarkdownSerializer extends PMMarkdownSerializer {
|
|
7
|
-
serialize(content: PMNode
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}): string;
|
|
31
|
+
serialize(content: PMNode): string;
|
|
10
32
|
}
|
|
11
33
|
export declare const nodes: {
|
|
12
34
|
table(state: MarkdownSerializerState, node: PMNode): void;
|
|
@@ -1,12 +1,34 @@
|
|
|
1
|
-
import { MarkdownSerializer as PMMarkdownSerializer, MarkdownSerializerState as PMMarkdownSerializerState } from '@atlaskit/editor-prosemirror/markdown';
|
|
1
|
+
import { MarkdownSerializer as PMMarkdownSerializer, MarkdownSerializerState as PMMarkdownSerializerState, type NodeSerializerSpec, type MarkSerializerSpec } from '@atlaskit/editor-prosemirror/markdown';
|
|
2
2
|
import type { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
|
|
3
3
|
export declare class MarkdownSerializerState extends PMMarkdownSerializerState {
|
|
4
|
+
nodes: NodeSerializerSpec;
|
|
5
|
+
marks: {
|
|
6
|
+
[mark: string]: MarkSerializerSpec;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Defines the internal variables used in the markdown serializer
|
|
10
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L172
|
|
11
|
+
*/
|
|
12
|
+
delim: string;
|
|
13
|
+
out: string;
|
|
14
|
+
closed: Node | null;
|
|
15
|
+
/**
|
|
16
|
+
* Defines the internal atBlank method used in the markdown serializer
|
|
17
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L241
|
|
18
|
+
*/
|
|
19
|
+
atBlank(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Defines the internal flushClose method used in the markdown serializer
|
|
22
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L202
|
|
23
|
+
*/
|
|
24
|
+
flushClose(size?: number): void;
|
|
25
|
+
constructor(nodes: NodeSerializerSpec, marks: {
|
|
26
|
+
[mark: string]: MarkSerializerSpec;
|
|
27
|
+
});
|
|
4
28
|
renderContent(parent: PMNode): void;
|
|
5
29
|
}
|
|
6
30
|
export declare class MarkdownSerializer extends PMMarkdownSerializer {
|
|
7
|
-
serialize(content: PMNode
|
|
8
|
-
[key: string]: any;
|
|
9
|
-
}): string;
|
|
31
|
+
serialize(content: PMNode): string;
|
|
10
32
|
}
|
|
11
33
|
export declare const nodes: {
|
|
12
34
|
table(state: MarkdownSerializerState, node: PMNode): void;
|
|
@@ -11,8 +11,8 @@ import type { EditorView } from '@atlaskit/editor-prosemirror/view';
|
|
|
11
11
|
import type { ActivityProvider } from '@atlaskit/activity';
|
|
12
12
|
// eslint-disable-next-line no-restricted-imports -- Legacy package outside of AFM lacks entry points
|
|
13
13
|
import { MockActivityResource } from '@atlaskit/activity/dist/es5/support';
|
|
14
|
-
import type { MentionProvider } from '@atlaskit/
|
|
15
|
-
import { MentionResource } from '@atlaskit/
|
|
14
|
+
import type { MentionProvider } from '@atlaskit/mention/resource';
|
|
15
|
+
import { MentionResource } from '@atlaskit/mention/resource';
|
|
16
16
|
import type { EmojiProvider } from '@atlaskit/emoji';
|
|
17
17
|
import { getEmojiResource } from '@atlaskit/util-data-test/get-emoji-resource';
|
|
18
18
|
import { mentionResourceProvider } from '@atlaskit/util-data-test/mention-story-data';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-slack-transformer",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.4",
|
|
4
4
|
"description": "Editor Slack transformer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -38,11 +38,12 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@atlaskit/activity": "^1.0.1",
|
|
41
|
-
"@atlaskit/editor-core": "^
|
|
42
|
-
"@atlaskit/editor-test-helpers": "^
|
|
43
|
-
"@atlaskit/emoji": "^67.
|
|
41
|
+
"@atlaskit/editor-core": "^198.2.0",
|
|
42
|
+
"@atlaskit/editor-test-helpers": "^19.0.0",
|
|
43
|
+
"@atlaskit/emoji": "^67.8.0",
|
|
44
|
+
"@atlaskit/mention": "^23.3.0",
|
|
44
45
|
"@atlaskit/theme": "^13.0.0",
|
|
45
|
-
"@atlaskit/tokens": "^
|
|
46
|
+
"@atlaskit/tokens": "^2.0.0",
|
|
46
47
|
"@atlaskit/util-data-test": "^17.9.0",
|
|
47
48
|
"@emotion/react": "^11.7.1",
|
|
48
49
|
"typescript": "~5.4.2"
|