@atlaskit/editor-slack-transformer 3.7.3 → 3.8.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/cjs/index.js +2 -2
- package/dist/cjs/serializer.js +71 -21
- package/dist/cjs/util.js +2 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/serializer.js +54 -4
- package/dist/es2019/util.js +2 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/serializer.js +71 -21
- package/dist/esm/util.js +2 -0
- package/dist/types/serializer.d.ts +26 -4
- package/dist/types-ts4.5/serializer.d.ts +26 -4
- package/example-helpers/ToolsDrawer.tsx +2 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/editor-slack-transformer
|
|
2
2
|
|
|
3
|
+
## 3.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#105322](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/105322)
|
|
8
|
+
[`8876083532adc`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/8876083532adc) -
|
|
9
|
+
Bumped editor-prosemirror version to 7.0.0
|
|
10
|
+
|
|
11
|
+
## 3.7.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#147003](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147003)
|
|
16
|
+
[`f4f413727e260`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f4f413727e260) -
|
|
17
|
+
[EDF-1041] Remove platform typings prosemirror-markdown from project
|
|
18
|
+
|
|
3
19
|
## 3.7.3
|
|
4
20
|
|
|
5
21
|
### Patch Changes
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,9 +12,10 @@ 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
|
-
(0, _createClass2.default)(SlackTransformer, [{
|
|
18
|
+
return (0, _createClass2.default)(SlackTransformer, [{
|
|
18
19
|
key: "encode",
|
|
19
20
|
value: function encode(node) {
|
|
20
21
|
return this.serializer.serialize(node);
|
|
@@ -25,5 +26,4 @@ var SlackTransformer = exports.SlackTransformer = /*#__PURE__*/function () {
|
|
|
25
26
|
throw new Error('This is not implemented yet');
|
|
26
27
|
}
|
|
27
28
|
}]);
|
|
28
|
-
return SlackTransformer;
|
|
29
29
|
}();
|
package/dist/cjs/serializer.js
CHANGED
|
@@ -5,59 +5,107 @@ 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"));
|
|
11
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
12
10
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
13
11
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
12
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
14
14
|
var _markdown = require("@atlaskit/editor-prosemirror/markdown");
|
|
15
15
|
var _util = require("./util");
|
|
16
16
|
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; }
|
|
17
17
|
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) { (0, _defineProperty2.default)(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; }
|
|
18
|
-
function
|
|
18
|
+
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
|
|
19
19
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
20
20
|
var MarkdownSerializerState = exports.MarkdownSerializerState = /*#__PURE__*/function (_PMMarkdownSerializer) {
|
|
21
|
-
(
|
|
22
|
-
|
|
23
|
-
function MarkdownSerializerState() {
|
|
21
|
+
function MarkdownSerializerState(nodes, marks) {
|
|
22
|
+
var _this;
|
|
24
23
|
(0, _classCallCheck2.default)(this, MarkdownSerializerState);
|
|
25
|
-
|
|
24
|
+
// @ts-ignore-next-line
|
|
25
|
+
_this = _callSuper(this, MarkdownSerializerState, [nodes, marks, {}]);
|
|
26
|
+
/**
|
|
27
|
+
* Defines the internal variables used in the markdown serializer
|
|
28
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L172
|
|
29
|
+
*/
|
|
30
|
+
(0, _defineProperty2.default)(_this, "delim", '');
|
|
31
|
+
(0, _defineProperty2.default)(_this, "out", '');
|
|
32
|
+
(0, _defineProperty2.default)(_this, "closed", null);
|
|
33
|
+
_this.nodes = nodes;
|
|
34
|
+
_this.marks = marks;
|
|
35
|
+
return _this;
|
|
26
36
|
}
|
|
27
|
-
(0,
|
|
37
|
+
(0, _inherits2.default)(MarkdownSerializerState, _PMMarkdownSerializer);
|
|
38
|
+
return (0, _createClass2.default)(MarkdownSerializerState, [{
|
|
39
|
+
key: "atBlank",
|
|
40
|
+
value:
|
|
41
|
+
/**
|
|
42
|
+
* Defines the internal atBlank method used in the markdown serializer
|
|
43
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L241
|
|
44
|
+
*/
|
|
45
|
+
function atBlank() {
|
|
46
|
+
// Ignored via go/ees005
|
|
47
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
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
|
+
// Ignored via go/ees005
|
|
66
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
67
|
+
var trim = /\s+$/.exec(delimMin);
|
|
68
|
+
if (trim) {
|
|
69
|
+
delimMin = delimMin.slice(0, delimMin.length - trim[0].length);
|
|
70
|
+
}
|
|
71
|
+
for (var i = 1; i < size; i++) {
|
|
72
|
+
this.out += delimMin + '\n';
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
this.closed = null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
28
79
|
key: "renderContent",
|
|
29
80
|
value: function renderContent(parent) {
|
|
30
|
-
var
|
|
81
|
+
var _this2 = this;
|
|
31
82
|
parent.forEach(function (child, _offset, index) {
|
|
32
83
|
if (
|
|
33
84
|
// If child is an empty Textblock we need to insert a zwnj-character in order to preserve that line in markdown
|
|
34
85
|
child.isTextblock && !child.textContent &&
|
|
35
86
|
// If child is a Codeblock we need to handle this separately as we want to preserve empty code blocks
|
|
36
87
|
!(child.type.name === 'codeBlock') && !(child.content && child.content.size > 0)) {
|
|
37
|
-
return nodes.empty_line(
|
|
88
|
+
return nodes.empty_line(_this2, child);
|
|
38
89
|
}
|
|
39
|
-
return
|
|
90
|
+
return _this2.render(child, parent, index);
|
|
40
91
|
});
|
|
41
92
|
}
|
|
42
93
|
}]);
|
|
43
|
-
return MarkdownSerializerState;
|
|
44
94
|
}(_markdown.MarkdownSerializerState);
|
|
45
95
|
var MarkdownSerializer = exports.MarkdownSerializer = /*#__PURE__*/function (_PMMarkdownSerializer2) {
|
|
46
|
-
(0, _inherits2.default)(MarkdownSerializer, _PMMarkdownSerializer2);
|
|
47
|
-
var _super2 = _createSuper(MarkdownSerializer);
|
|
48
96
|
function MarkdownSerializer() {
|
|
49
97
|
(0, _classCallCheck2.default)(this, MarkdownSerializer);
|
|
50
|
-
return
|
|
98
|
+
return _callSuper(this, MarkdownSerializer, arguments);
|
|
51
99
|
}
|
|
52
|
-
(0,
|
|
100
|
+
(0, _inherits2.default)(MarkdownSerializer, _PMMarkdownSerializer2);
|
|
101
|
+
return (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
|
}
|
|
59
108
|
}]);
|
|
60
|
-
return MarkdownSerializer;
|
|
61
109
|
}(_markdown.MarkdownSerializer);
|
|
62
110
|
/**
|
|
63
111
|
* Stubs for unsupported nodes
|
|
@@ -125,7 +173,7 @@ var unsupportedNodes = {
|
|
|
125
173
|
};
|
|
126
174
|
var nodes = exports.nodes = _objectSpread({
|
|
127
175
|
blockquote: function blockquote(state, node) {
|
|
128
|
-
state.wrapBlock('> ',
|
|
176
|
+
state.wrapBlock('> ', null, node, function () {
|
|
129
177
|
return state.renderContent(node);
|
|
130
178
|
});
|
|
131
179
|
},
|
|
@@ -168,7 +216,7 @@ var nodes = exports.nodes = _objectSpread({
|
|
|
168
216
|
return state.render(child, parent, i);
|
|
169
217
|
});
|
|
170
218
|
} else {
|
|
171
|
-
state.wrapBlock(' ',
|
|
219
|
+
state.wrapBlock(' ', null, node, function () {
|
|
172
220
|
return state.render(child, parent, i);
|
|
173
221
|
});
|
|
174
222
|
}
|
|
@@ -348,6 +396,8 @@ var marks = exports.marks = _objectSpread({
|
|
|
348
396
|
expelEnclosingWhitespace: true
|
|
349
397
|
},
|
|
350
398
|
link: {
|
|
399
|
+
// Ignored via go/ees005
|
|
400
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
351
401
|
open: function open(_state, mark) {
|
|
352
402
|
return '<' + mark.attrs.href + '|';
|
|
353
403
|
},
|
package/dist/cjs/util.js
CHANGED
|
@@ -10,6 +10,8 @@ exports.escapeMarkdown = void 0;
|
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
var escapeMarkdown = exports.escapeMarkdown = function escapeMarkdown(str) {
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
13
15
|
return str.replace(/[`*_~&<>]/g, function (matched) {
|
|
14
16
|
switch (matched) {
|
|
15
17
|
case '&':
|
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,54 @@
|
|
|
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
|
+
// Ignored via go/ees005
|
|
11
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
12
|
+
return /(^|\n)$/.test(this.out);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Defines the internal flushClose method used in the markdown serializer
|
|
17
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L202
|
|
18
|
+
*/
|
|
19
|
+
flushClose(size = 2) {
|
|
20
|
+
if (this.closed) {
|
|
21
|
+
if (!this.atBlank()) {
|
|
22
|
+
this.out += '\n';
|
|
23
|
+
}
|
|
24
|
+
if (size > 1) {
|
|
25
|
+
let delimMin = this.delim;
|
|
26
|
+
// Ignored via go/ees005
|
|
27
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
28
|
+
const trim = /\s+$/.exec(delimMin);
|
|
29
|
+
if (trim) {
|
|
30
|
+
delimMin = delimMin.slice(0, delimMin.length - trim[0].length);
|
|
31
|
+
}
|
|
32
|
+
for (let i = 1; i < size; i++) {
|
|
33
|
+
this.out += delimMin + '\n';
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
this.closed = null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
constructor(nodes, marks) {
|
|
40
|
+
// @ts-ignore-next-line
|
|
41
|
+
super(nodes, marks, {});
|
|
42
|
+
/**
|
|
43
|
+
* Defines the internal variables used in the markdown serializer
|
|
44
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L172
|
|
45
|
+
*/
|
|
46
|
+
_defineProperty(this, "delim", '');
|
|
47
|
+
_defineProperty(this, "out", '');
|
|
48
|
+
_defineProperty(this, "closed", null);
|
|
49
|
+
this.nodes = nodes;
|
|
50
|
+
this.marks = marks;
|
|
51
|
+
}
|
|
4
52
|
renderContent(parent) {
|
|
5
53
|
parent.forEach((child, _offset, index) => {
|
|
6
54
|
if (
|
|
@@ -15,8 +63,8 @@ export class MarkdownSerializerState extends PMMarkdownSerializerState {
|
|
|
15
63
|
}
|
|
16
64
|
}
|
|
17
65
|
export class MarkdownSerializer extends PMMarkdownSerializer {
|
|
18
|
-
serialize(content
|
|
19
|
-
const state = new MarkdownSerializerState(this.nodes, this.marks
|
|
66
|
+
serialize(content) {
|
|
67
|
+
const state = new MarkdownSerializerState(this.nodes, this.marks);
|
|
20
68
|
state.renderContent(content);
|
|
21
69
|
return state.out === '\u200c' ? '' : state.out; // Return empty string if editor only contains a zero-non-width character
|
|
22
70
|
}
|
|
@@ -88,7 +136,7 @@ const unsupportedNodes = {
|
|
|
88
136
|
};
|
|
89
137
|
export const nodes = {
|
|
90
138
|
blockquote(state, node) {
|
|
91
|
-
state.wrapBlock('> ',
|
|
139
|
+
state.wrapBlock('> ', null, node, () => state.renderContent(node));
|
|
92
140
|
},
|
|
93
141
|
codeBlock(state, node) {
|
|
94
142
|
state.write('```');
|
|
@@ -127,7 +175,7 @@ export const nodes = {
|
|
|
127
175
|
if (i === 0) {
|
|
128
176
|
state.wrapBlock(' ', delimiter, node, () => state.render(child, parent, i));
|
|
129
177
|
} else {
|
|
130
|
-
state.wrapBlock(' ',
|
|
178
|
+
state.wrapBlock(' ', null, node, () => state.render(child, parent, i));
|
|
131
179
|
}
|
|
132
180
|
if (child.type.name === 'paragraph' && i > 0) {
|
|
133
181
|
state.write('\n');
|
|
@@ -303,6 +351,8 @@ export const marks = {
|
|
|
303
351
|
expelEnclosingWhitespace: true
|
|
304
352
|
},
|
|
305
353
|
link: {
|
|
354
|
+
// Ignored via go/ees005
|
|
355
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
306
356
|
open(_state, mark) {
|
|
307
357
|
return '<' + mark.attrs.href + '|';
|
|
308
358
|
},
|
package/dist/es2019/util.js
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -5,9 +5,10 @@ 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
|
-
_createClass(SlackTransformer, [{
|
|
11
|
+
return _createClass(SlackTransformer, [{
|
|
11
12
|
key: "encode",
|
|
12
13
|
value: function encode(node) {
|
|
13
14
|
return this.serializer.serialize(node);
|
|
@@ -18,5 +19,4 @@ export var SlackTransformer = /*#__PURE__*/function () {
|
|
|
18
19
|
throw new Error('This is not implemented yet');
|
|
19
20
|
}
|
|
20
21
|
}]);
|
|
21
|
-
return SlackTransformer;
|
|
22
22
|
}();
|
package/dist/esm/serializer.js
CHANGED
|
@@ -1,56 +1,104 @@
|
|
|
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";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
3
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
4
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
5
|
+
import _inherits from "@babel/runtime/helpers/inherits";
|
|
6
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
7
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
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
|
|
9
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
10
10
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
11
11
|
import { MarkdownSerializer as PMMarkdownSerializer, MarkdownSerializerState as PMMarkdownSerializerState } from '@atlaskit/editor-prosemirror/markdown';
|
|
12
12
|
import { escapeMarkdown } from './util';
|
|
13
13
|
export var MarkdownSerializerState = /*#__PURE__*/function (_PMMarkdownSerializer) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
function MarkdownSerializerState() {
|
|
14
|
+
function MarkdownSerializerState(nodes, marks) {
|
|
15
|
+
var _this;
|
|
17
16
|
_classCallCheck(this, MarkdownSerializerState);
|
|
18
|
-
|
|
17
|
+
// @ts-ignore-next-line
|
|
18
|
+
_this = _callSuper(this, MarkdownSerializerState, [nodes, marks, {}]);
|
|
19
|
+
/**
|
|
20
|
+
* Defines the internal variables used in the markdown serializer
|
|
21
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L172
|
|
22
|
+
*/
|
|
23
|
+
_defineProperty(_this, "delim", '');
|
|
24
|
+
_defineProperty(_this, "out", '');
|
|
25
|
+
_defineProperty(_this, "closed", null);
|
|
26
|
+
_this.nodes = nodes;
|
|
27
|
+
_this.marks = marks;
|
|
28
|
+
return _this;
|
|
19
29
|
}
|
|
20
|
-
|
|
30
|
+
_inherits(MarkdownSerializerState, _PMMarkdownSerializer);
|
|
31
|
+
return _createClass(MarkdownSerializerState, [{
|
|
32
|
+
key: "atBlank",
|
|
33
|
+
value:
|
|
34
|
+
/**
|
|
35
|
+
* Defines the internal atBlank method used in the markdown serializer
|
|
36
|
+
* @see https://github.com/ProseMirror/prosemirror-markdown/blob/master/src/to_markdown.ts#L241
|
|
37
|
+
*/
|
|
38
|
+
function atBlank() {
|
|
39
|
+
// Ignored via go/ees005
|
|
40
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
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
|
+
// Ignored via go/ees005
|
|
59
|
+
// eslint-disable-next-line require-unicode-regexp
|
|
60
|
+
var trim = /\s+$/.exec(delimMin);
|
|
61
|
+
if (trim) {
|
|
62
|
+
delimMin = delimMin.slice(0, delimMin.length - trim[0].length);
|
|
63
|
+
}
|
|
64
|
+
for (var i = 1; i < size; i++) {
|
|
65
|
+
this.out += delimMin + '\n';
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
this.closed = null;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
21
72
|
key: "renderContent",
|
|
22
73
|
value: function renderContent(parent) {
|
|
23
|
-
var
|
|
74
|
+
var _this2 = this;
|
|
24
75
|
parent.forEach(function (child, _offset, index) {
|
|
25
76
|
if (
|
|
26
77
|
// If child is an empty Textblock we need to insert a zwnj-character in order to preserve that line in markdown
|
|
27
78
|
child.isTextblock && !child.textContent &&
|
|
28
79
|
// If child is a Codeblock we need to handle this separately as we want to preserve empty code blocks
|
|
29
80
|
!(child.type.name === 'codeBlock') && !(child.content && child.content.size > 0)) {
|
|
30
|
-
return nodes.empty_line(
|
|
81
|
+
return nodes.empty_line(_this2, child);
|
|
31
82
|
}
|
|
32
|
-
return
|
|
83
|
+
return _this2.render(child, parent, index);
|
|
33
84
|
});
|
|
34
85
|
}
|
|
35
86
|
}]);
|
|
36
|
-
return MarkdownSerializerState;
|
|
37
87
|
}(PMMarkdownSerializerState);
|
|
38
88
|
export var MarkdownSerializer = /*#__PURE__*/function (_PMMarkdownSerializer2) {
|
|
39
|
-
_inherits(MarkdownSerializer, _PMMarkdownSerializer2);
|
|
40
|
-
var _super2 = _createSuper(MarkdownSerializer);
|
|
41
89
|
function MarkdownSerializer() {
|
|
42
90
|
_classCallCheck(this, MarkdownSerializer);
|
|
43
|
-
return
|
|
91
|
+
return _callSuper(this, MarkdownSerializer, arguments);
|
|
44
92
|
}
|
|
45
|
-
|
|
93
|
+
_inherits(MarkdownSerializer, _PMMarkdownSerializer2);
|
|
94
|
+
return _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
|
}
|
|
52
101
|
}]);
|
|
53
|
-
return MarkdownSerializer;
|
|
54
102
|
}(PMMarkdownSerializer);
|
|
55
103
|
|
|
56
104
|
/**
|
|
@@ -119,7 +167,7 @@ var unsupportedNodes = {
|
|
|
119
167
|
};
|
|
120
168
|
export var nodes = _objectSpread({
|
|
121
169
|
blockquote: function blockquote(state, node) {
|
|
122
|
-
state.wrapBlock('> ',
|
|
170
|
+
state.wrapBlock('> ', null, node, function () {
|
|
123
171
|
return state.renderContent(node);
|
|
124
172
|
});
|
|
125
173
|
},
|
|
@@ -162,7 +210,7 @@ export var nodes = _objectSpread({
|
|
|
162
210
|
return state.render(child, parent, i);
|
|
163
211
|
});
|
|
164
212
|
} else {
|
|
165
|
-
state.wrapBlock(' ',
|
|
213
|
+
state.wrapBlock(' ', null, node, function () {
|
|
166
214
|
return state.render(child, parent, i);
|
|
167
215
|
});
|
|
168
216
|
}
|
|
@@ -342,6 +390,8 @@ export var marks = _objectSpread({
|
|
|
342
390
|
expelEnclosingWhitespace: true
|
|
343
391
|
},
|
|
344
392
|
link: {
|
|
393
|
+
// Ignored via go/ees005
|
|
394
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
345
395
|
open: function open(_state, mark) {
|
|
346
396
|
return '<' + mark.attrs.href + '|';
|
|
347
397
|
},
|
package/dist/esm/util.js
CHANGED
|
@@ -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;
|
|
@@ -23,6 +23,8 @@ import { SlackTransformer } from '../src';
|
|
|
23
23
|
import { content } from './styles';
|
|
24
24
|
|
|
25
25
|
const rejectedPromise = Promise.reject(new Error('Simulated provider rejection'));
|
|
26
|
+
// Ignored via go/ees005
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
28
|
const pendingPromise = new Promise<any>(() => {});
|
|
27
29
|
|
|
28
30
|
const providers = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-slack-transformer",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Editor Slack transformer",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"runReact18": true
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@atlaskit/editor-prosemirror": "
|
|
33
|
+
"@atlaskit/editor-prosemirror": "7.0.0",
|
|
34
34
|
"@babel/runtime": "^7.0.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -38,13 +38,13 @@
|
|
|
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.
|
|
44
|
-
"@atlaskit/mention": "^23.
|
|
45
|
-
"@atlaskit/theme": "^
|
|
46
|
-
"@atlaskit/tokens": "^
|
|
47
|
-
"@atlaskit/util-data-test": "^
|
|
41
|
+
"@atlaskit/editor-core": "^203.16.0",
|
|
42
|
+
"@atlaskit/editor-test-helpers": "^21.3.0",
|
|
43
|
+
"@atlaskit/emoji": "^67.13.0",
|
|
44
|
+
"@atlaskit/mention": "^23.11.0",
|
|
45
|
+
"@atlaskit/theme": "^15.0.0",
|
|
46
|
+
"@atlaskit/tokens": "^3.3.0",
|
|
47
|
+
"@atlaskit/util-data-test": "^18.0.0",
|
|
48
48
|
"@emotion/react": "^11.7.1",
|
|
49
49
|
"typescript": "~5.4.2"
|
|
50
50
|
},
|