@atlaskit/editor-core 187.14.8 → 187.14.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.
- package/CHANGELOG.md +7 -0
- package/dist/cjs/commands/index.js +35 -120
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/commands/index.js +1 -115
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/commands/index.js +1 -113
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/commands/index.d.ts +1 -17
- package/dist/types-ts4.5/commands/index.d.ts +1 -17
- package/package.json +2 -2
- package/report.api.md +2 -2
- package/tmp/api-report-tmp.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 187.14.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`021d5f488ec`](https://bitbucket.org/atlassian/atlassian-frontend/commits/021d5f488ec) - [ED-16733] Media Plugin Extractation - Move core commands to common entrypoint
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 187.14.8
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -1,127 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
var _state = require("@atlaskit/editor-prosemirror/state");
|
|
13
|
-
var _cellSelection = require("@atlaskit/editor-tables/cell-selection");
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
-
function addParagraphAtEnd(tr) {
|
|
17
|
-
var paragraph = tr.doc.type.schema.nodes.paragraph,
|
|
18
|
-
doc = tr.doc;
|
|
19
|
-
if (doc.lastChild && !(doc.lastChild.type === paragraph && doc.lastChild.content.size === 0)) {
|
|
20
|
-
if (paragraph) {
|
|
21
|
-
tr.insert(doc.content.size, paragraph.createAndFill());
|
|
22
|
-
}
|
|
6
|
+
Object.defineProperty(exports, "addParagraphAtEnd", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _commands.addParagraphAtEnd;
|
|
23
10
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
to = _state$selection.to;
|
|
42
|
-
var tr = state.tr;
|
|
43
|
-
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
44
|
-
if (node.type === state.schema.nodes.mediaSingle) {
|
|
45
|
-
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
46
|
-
layout: align === 'center' ? 'center' : "align-".concat(align)
|
|
47
|
-
}));
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
if (tr.docChanged && dispatch) {
|
|
51
|
-
dispatch(tr.scrollIntoView());
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
exports.changeImageAlignment = changeImageAlignment;
|
|
58
|
-
var createToggleBlockMarkOnRange = function createToggleBlockMarkOnRange(markType, getAttrs, allowedBlocks) {
|
|
59
|
-
return function (from, to, tr, state) {
|
|
60
|
-
var markApplied = false;
|
|
61
|
-
state.doc.nodesBetween(from, to, function (node, pos, parent) {
|
|
62
|
-
if (!node.type.isBlock) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
if ((!allowedBlocks || (Array.isArray(allowedBlocks) ? allowedBlocks.indexOf(node.type) > -1 : allowedBlocks(state.schema, node, parent))) && parent !== null && parent !== void 0 && parent.type.allowsMarkType(markType)) {
|
|
66
|
-
var oldMarks = node.marks.filter(function (mark) {
|
|
67
|
-
return mark.type === markType;
|
|
68
|
-
});
|
|
69
|
-
var _prevAttrs = oldMarks.length ? oldMarks[0].attrs : undefined;
|
|
70
|
-
var newAttrs = getAttrs(_prevAttrs, node);
|
|
71
|
-
if (newAttrs !== undefined) {
|
|
72
|
-
tr.setNodeMarkup(pos, node.type, node.attrs, node.marks.filter(function (mark) {
|
|
73
|
-
return !markType.excludes(mark.type);
|
|
74
|
-
}).concat(newAttrs === false ? [] : markType.create(newAttrs)));
|
|
75
|
-
markApplied = true;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return;
|
|
79
|
-
});
|
|
80
|
-
return markApplied;
|
|
81
|
-
};
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Toggles block mark based on the return type of `getAttrs`.
|
|
86
|
-
* This is similar to ProseMirror's `getAttrs` from `AttributeSpec`
|
|
87
|
-
* return `false` to remove the mark.
|
|
88
|
-
* return `undefined for no-op.
|
|
89
|
-
* return an `object` to update the mark.
|
|
90
|
-
*/
|
|
91
|
-
exports.createToggleBlockMarkOnRange = createToggleBlockMarkOnRange;
|
|
92
|
-
var toggleBlockMark = function toggleBlockMark(markType, getAttrs, allowedBlocks) {
|
|
93
|
-
return function (state, dispatch) {
|
|
94
|
-
var markApplied = false;
|
|
95
|
-
var tr = state.tr;
|
|
96
|
-
var toggleBlockMarkOnRange = createToggleBlockMarkOnRange(markType, getAttrs, allowedBlocks);
|
|
97
|
-
if (state.selection instanceof _cellSelection.CellSelection) {
|
|
98
|
-
state.selection.forEachCell(function (cell, pos) {
|
|
99
|
-
markApplied = toggleBlockMarkOnRange(pos, pos + cell.nodeSize, tr, state);
|
|
100
|
-
});
|
|
101
|
-
} else {
|
|
102
|
-
var _state$selection2 = state.selection,
|
|
103
|
-
from = _state$selection2.from,
|
|
104
|
-
to = _state$selection2.to;
|
|
105
|
-
markApplied = toggleBlockMarkOnRange(from, to, tr, state);
|
|
106
|
-
}
|
|
107
|
-
if (markApplied && tr.docChanged) {
|
|
108
|
-
if (dispatch) {
|
|
109
|
-
dispatch(tr.scrollIntoView());
|
|
110
|
-
}
|
|
111
|
-
return true;
|
|
112
|
-
}
|
|
113
|
-
return false;
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
exports.toggleBlockMark = toggleBlockMark;
|
|
117
|
-
var clearEditorContent = function clearEditorContent(state, dispatch) {
|
|
118
|
-
var tr = state.tr;
|
|
119
|
-
tr.replace(0, state.doc.nodeSize - 2);
|
|
120
|
-
tr.setSelection(_state.Selection.atStart(tr.doc));
|
|
121
|
-
if (dispatch) {
|
|
122
|
-
dispatch(tr);
|
|
123
|
-
return true;
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "changeImageAlignment", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _commands.changeImageAlignment;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "clearEditorContent", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _commands.clearEditorContent;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "createParagraphAtEnd", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function get() {
|
|
27
|
+
return _commands.createParagraphAtEnd;
|
|
124
28
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "createToggleBlockMarkOnRange", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function get() {
|
|
33
|
+
return _commands.createToggleBlockMarkOnRange;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "toggleBlockMark", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function get() {
|
|
39
|
+
return _commands.toggleBlockMark;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var _commands = require("@atlaskit/editor-common/commands");
|
|
@@ -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 = "187.14.
|
|
9
|
+
var version = "187.14.9";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,115 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
3
|
-
export function addParagraphAtEnd(tr) {
|
|
4
|
-
const {
|
|
5
|
-
doc: {
|
|
6
|
-
type: {
|
|
7
|
-
schema: {
|
|
8
|
-
nodes: {
|
|
9
|
-
paragraph
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
doc
|
|
15
|
-
} = tr;
|
|
16
|
-
if (doc.lastChild && !(doc.lastChild.type === paragraph && doc.lastChild.content.size === 0)) {
|
|
17
|
-
if (paragraph) {
|
|
18
|
-
tr.insert(doc.content.size, paragraph.createAndFill());
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
tr.setSelection(TextSelection.create(tr.doc, tr.doc.content.size - 1));
|
|
22
|
-
tr.scrollIntoView();
|
|
23
|
-
}
|
|
24
|
-
export function createParagraphAtEnd() {
|
|
25
|
-
return function (state, dispatch) {
|
|
26
|
-
const {
|
|
27
|
-
tr
|
|
28
|
-
} = state;
|
|
29
|
-
addParagraphAtEnd(tr);
|
|
30
|
-
if (dispatch) {
|
|
31
|
-
dispatch(tr);
|
|
32
|
-
}
|
|
33
|
-
return true;
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export const changeImageAlignment = align => (state, dispatch) => {
|
|
37
|
-
const {
|
|
38
|
-
from,
|
|
39
|
-
to
|
|
40
|
-
} = state.selection;
|
|
41
|
-
const tr = state.tr;
|
|
42
|
-
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
43
|
-
if (node.type === state.schema.nodes.mediaSingle) {
|
|
44
|
-
tr.setNodeMarkup(pos, undefined, {
|
|
45
|
-
...node.attrs,
|
|
46
|
-
layout: align === 'center' ? 'center' : `align-${align}`
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
if (tr.docChanged && dispatch) {
|
|
51
|
-
dispatch(tr.scrollIntoView());
|
|
52
|
-
return true;
|
|
53
|
-
}
|
|
54
|
-
return false;
|
|
55
|
-
};
|
|
56
|
-
export const createToggleBlockMarkOnRange = (markType, getAttrs, allowedBlocks) => (from, to, tr, state) => {
|
|
57
|
-
let markApplied = false;
|
|
58
|
-
state.doc.nodesBetween(from, to, (node, pos, parent) => {
|
|
59
|
-
if (!node.type.isBlock) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
if ((!allowedBlocks || (Array.isArray(allowedBlocks) ? allowedBlocks.indexOf(node.type) > -1 : allowedBlocks(state.schema, node, parent))) && parent !== null && parent !== void 0 && parent.type.allowsMarkType(markType)) {
|
|
63
|
-
const oldMarks = node.marks.filter(mark => mark.type === markType);
|
|
64
|
-
const prevAttrs = oldMarks.length ? oldMarks[0].attrs : undefined;
|
|
65
|
-
const newAttrs = getAttrs(prevAttrs, node);
|
|
66
|
-
if (newAttrs !== undefined) {
|
|
67
|
-
tr.setNodeMarkup(pos, node.type, node.attrs, node.marks.filter(mark => !markType.excludes(mark.type)).concat(newAttrs === false ? [] : markType.create(newAttrs)));
|
|
68
|
-
markApplied = true;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return;
|
|
72
|
-
});
|
|
73
|
-
return markApplied;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Toggles block mark based on the return type of `getAttrs`.
|
|
78
|
-
* This is similar to ProseMirror's `getAttrs` from `AttributeSpec`
|
|
79
|
-
* return `false` to remove the mark.
|
|
80
|
-
* return `undefined for no-op.
|
|
81
|
-
* return an `object` to update the mark.
|
|
82
|
-
*/
|
|
83
|
-
export const toggleBlockMark = (markType, getAttrs, allowedBlocks) => (state, dispatch) => {
|
|
84
|
-
let markApplied = false;
|
|
85
|
-
const tr = state.tr;
|
|
86
|
-
const toggleBlockMarkOnRange = createToggleBlockMarkOnRange(markType, getAttrs, allowedBlocks);
|
|
87
|
-
if (state.selection instanceof CellSelection) {
|
|
88
|
-
state.selection.forEachCell((cell, pos) => {
|
|
89
|
-
markApplied = toggleBlockMarkOnRange(pos, pos + cell.nodeSize, tr, state);
|
|
90
|
-
});
|
|
91
|
-
} else {
|
|
92
|
-
const {
|
|
93
|
-
from,
|
|
94
|
-
to
|
|
95
|
-
} = state.selection;
|
|
96
|
-
markApplied = toggleBlockMarkOnRange(from, to, tr, state);
|
|
97
|
-
}
|
|
98
|
-
if (markApplied && tr.docChanged) {
|
|
99
|
-
if (dispatch) {
|
|
100
|
-
dispatch(tr.scrollIntoView());
|
|
101
|
-
}
|
|
102
|
-
return true;
|
|
103
|
-
}
|
|
104
|
-
return false;
|
|
105
|
-
};
|
|
106
|
-
export const clearEditorContent = (state, dispatch) => {
|
|
107
|
-
const tr = state.tr;
|
|
108
|
-
tr.replace(0, state.doc.nodeSize - 2);
|
|
109
|
-
tr.setSelection(Selection.atStart(tr.doc));
|
|
110
|
-
if (dispatch) {
|
|
111
|
-
dispatch(tr);
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
return false;
|
|
115
|
-
};
|
|
1
|
+
export { addParagraphAtEnd, createParagraphAtEnd, changeImageAlignment, createToggleBlockMarkOnRange, toggleBlockMark, clearEditorContent } from '@atlaskit/editor-common/commands';
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,113 +1 @@
|
|
|
1
|
-
|
|
2
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
import { Selection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
6
|
-
export function addParagraphAtEnd(tr) {
|
|
7
|
-
var paragraph = tr.doc.type.schema.nodes.paragraph,
|
|
8
|
-
doc = tr.doc;
|
|
9
|
-
if (doc.lastChild && !(doc.lastChild.type === paragraph && doc.lastChild.content.size === 0)) {
|
|
10
|
-
if (paragraph) {
|
|
11
|
-
tr.insert(doc.content.size, paragraph.createAndFill());
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
tr.setSelection(TextSelection.create(tr.doc, tr.doc.content.size - 1));
|
|
15
|
-
tr.scrollIntoView();
|
|
16
|
-
}
|
|
17
|
-
export function createParagraphAtEnd() {
|
|
18
|
-
return function (state, dispatch) {
|
|
19
|
-
var tr = state.tr;
|
|
20
|
-
addParagraphAtEnd(tr);
|
|
21
|
-
if (dispatch) {
|
|
22
|
-
dispatch(tr);
|
|
23
|
-
}
|
|
24
|
-
return true;
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export var changeImageAlignment = function changeImageAlignment(align) {
|
|
28
|
-
return function (state, dispatch) {
|
|
29
|
-
var _state$selection = state.selection,
|
|
30
|
-
from = _state$selection.from,
|
|
31
|
-
to = _state$selection.to;
|
|
32
|
-
var tr = state.tr;
|
|
33
|
-
state.doc.nodesBetween(from, to, function (node, pos) {
|
|
34
|
-
if (node.type === state.schema.nodes.mediaSingle) {
|
|
35
|
-
tr.setNodeMarkup(pos, undefined, _objectSpread(_objectSpread({}, node.attrs), {}, {
|
|
36
|
-
layout: align === 'center' ? 'center' : "align-".concat(align)
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
if (tr.docChanged && dispatch) {
|
|
41
|
-
dispatch(tr.scrollIntoView());
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
return false;
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
export var createToggleBlockMarkOnRange = function createToggleBlockMarkOnRange(markType, getAttrs, allowedBlocks) {
|
|
48
|
-
return function (from, to, tr, state) {
|
|
49
|
-
var markApplied = false;
|
|
50
|
-
state.doc.nodesBetween(from, to, function (node, pos, parent) {
|
|
51
|
-
if (!node.type.isBlock) {
|
|
52
|
-
return false;
|
|
53
|
-
}
|
|
54
|
-
if ((!allowedBlocks || (Array.isArray(allowedBlocks) ? allowedBlocks.indexOf(node.type) > -1 : allowedBlocks(state.schema, node, parent))) && parent !== null && parent !== void 0 && parent.type.allowsMarkType(markType)) {
|
|
55
|
-
var oldMarks = node.marks.filter(function (mark) {
|
|
56
|
-
return mark.type === markType;
|
|
57
|
-
});
|
|
58
|
-
var _prevAttrs = oldMarks.length ? oldMarks[0].attrs : undefined;
|
|
59
|
-
var newAttrs = getAttrs(_prevAttrs, node);
|
|
60
|
-
if (newAttrs !== undefined) {
|
|
61
|
-
tr.setNodeMarkup(pos, node.type, node.attrs, node.marks.filter(function (mark) {
|
|
62
|
-
return !markType.excludes(mark.type);
|
|
63
|
-
}).concat(newAttrs === false ? [] : markType.create(newAttrs)));
|
|
64
|
-
markApplied = true;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return;
|
|
68
|
-
});
|
|
69
|
-
return markApplied;
|
|
70
|
-
};
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Toggles block mark based on the return type of `getAttrs`.
|
|
75
|
-
* This is similar to ProseMirror's `getAttrs` from `AttributeSpec`
|
|
76
|
-
* return `false` to remove the mark.
|
|
77
|
-
* return `undefined for no-op.
|
|
78
|
-
* return an `object` to update the mark.
|
|
79
|
-
*/
|
|
80
|
-
export var toggleBlockMark = function toggleBlockMark(markType, getAttrs, allowedBlocks) {
|
|
81
|
-
return function (state, dispatch) {
|
|
82
|
-
var markApplied = false;
|
|
83
|
-
var tr = state.tr;
|
|
84
|
-
var toggleBlockMarkOnRange = createToggleBlockMarkOnRange(markType, getAttrs, allowedBlocks);
|
|
85
|
-
if (state.selection instanceof CellSelection) {
|
|
86
|
-
state.selection.forEachCell(function (cell, pos) {
|
|
87
|
-
markApplied = toggleBlockMarkOnRange(pos, pos + cell.nodeSize, tr, state);
|
|
88
|
-
});
|
|
89
|
-
} else {
|
|
90
|
-
var _state$selection2 = state.selection,
|
|
91
|
-
from = _state$selection2.from,
|
|
92
|
-
to = _state$selection2.to;
|
|
93
|
-
markApplied = toggleBlockMarkOnRange(from, to, tr, state);
|
|
94
|
-
}
|
|
95
|
-
if (markApplied && tr.docChanged) {
|
|
96
|
-
if (dispatch) {
|
|
97
|
-
dispatch(tr.scrollIntoView());
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
return false;
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
export var clearEditorContent = function clearEditorContent(state, dispatch) {
|
|
105
|
-
var tr = state.tr;
|
|
106
|
-
tr.replace(0, state.doc.nodeSize - 2);
|
|
107
|
-
tr.setSelection(Selection.atStart(tr.doc));
|
|
108
|
-
if (dispatch) {
|
|
109
|
-
dispatch(tr);
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
return false;
|
|
113
|
-
};
|
|
1
|
+
export { addParagraphAtEnd, createParagraphAtEnd, changeImageAlignment, createToggleBlockMarkOnRange, toggleBlockMark, clearEditorContent } from '@atlaskit/editor-common/commands';
|
package/dist/esm/version.json
CHANGED
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { AlignmentState } from '../plugins/alignment/pm-plugins/types';
|
|
4
|
-
import type { Command } from '../types';
|
|
5
|
-
export declare function addParagraphAtEnd(tr: Transaction): void;
|
|
6
|
-
export declare function createParagraphAtEnd(): Command;
|
|
7
|
-
export declare const changeImageAlignment: (align?: AlignmentState) => Command;
|
|
8
|
-
export declare const createToggleBlockMarkOnRange: <T extends {} = object>(markType: MarkType, getAttrs: (prevAttrs?: T | undefined, node?: PMNode) => false | T | undefined, allowedBlocks?: NodeType[] | ((schema: Schema, node: PMNode, parent: PMNode | null) => boolean) | undefined) => (from: number, to: number, tr: Transaction, state: EditorState) => boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Toggles block mark based on the return type of `getAttrs`.
|
|
11
|
-
* This is similar to ProseMirror's `getAttrs` from `AttributeSpec`
|
|
12
|
-
* return `false` to remove the mark.
|
|
13
|
-
* return `undefined for no-op.
|
|
14
|
-
* return an `object` to update the mark.
|
|
15
|
-
*/
|
|
16
|
-
export declare const toggleBlockMark: <T extends {} = object>(markType: MarkType, getAttrs: (prevAttrs?: T | undefined, node?: PMNode) => false | T | undefined, allowedBlocks?: NodeType[] | ((schema: Schema, node: PMNode, parent: PMNode | null) => boolean) | undefined) => Command;
|
|
17
|
-
export declare const clearEditorContent: Command;
|
|
1
|
+
export { addParagraphAtEnd, createParagraphAtEnd, changeImageAlignment, createToggleBlockMarkOnRange, toggleBlockMark, clearEditorContent, } from '@atlaskit/editor-common/commands';
|
|
@@ -1,17 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { AlignmentState } from '../plugins/alignment/pm-plugins/types';
|
|
4
|
-
import type { Command } from '../types';
|
|
5
|
-
export declare function addParagraphAtEnd(tr: Transaction): void;
|
|
6
|
-
export declare function createParagraphAtEnd(): Command;
|
|
7
|
-
export declare const changeImageAlignment: (align?: AlignmentState) => Command;
|
|
8
|
-
export declare const createToggleBlockMarkOnRange: <T extends {} = object>(markType: MarkType, getAttrs: (prevAttrs?: T | undefined, node?: PMNode) => false | T | undefined, allowedBlocks?: NodeType[] | ((schema: Schema, node: PMNode, parent: PMNode | null) => boolean) | undefined) => (from: number, to: number, tr: Transaction, state: EditorState) => boolean;
|
|
9
|
-
/**
|
|
10
|
-
* Toggles block mark based on the return type of `getAttrs`.
|
|
11
|
-
* This is similar to ProseMirror's `getAttrs` from `AttributeSpec`
|
|
12
|
-
* return `false` to remove the mark.
|
|
13
|
-
* return `undefined for no-op.
|
|
14
|
-
* return an `object` to update the mark.
|
|
15
|
-
*/
|
|
16
|
-
export declare const toggleBlockMark: <T extends {} = object>(markType: MarkType, getAttrs: (prevAttrs?: T | undefined, node?: PMNode) => false | T | undefined, allowedBlocks?: NodeType[] | ((schema: Schema, node: PMNode, parent: PMNode | null) => boolean) | undefined) => Command;
|
|
17
|
-
export declare const clearEditorContent: Command;
|
|
1
|
+
export { addParagraphAtEnd, createParagraphAtEnd, changeImageAlignment, createToggleBlockMarkOnRange, toggleBlockMark, clearEditorContent, } from '@atlaskit/editor-common/commands';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/editor-core",
|
|
3
|
-
"version": "187.14.
|
|
3
|
+
"version": "187.14.9",
|
|
4
4
|
"description": "A package contains Atlassian editor core functionality",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"@atlaskit/code": "^14.6.0",
|
|
56
56
|
"@atlaskit/date": "^0.10.0",
|
|
57
57
|
"@atlaskit/datetime-picker": "^12.7.0",
|
|
58
|
-
"@atlaskit/editor-common": "^74.
|
|
58
|
+
"@atlaskit/editor-common": "^74.39.0",
|
|
59
59
|
"@atlaskit/editor-json-transformer": "^8.10.0",
|
|
60
60
|
"@atlaskit/editor-markdown-transformer": "^5.2.5",
|
|
61
61
|
"@atlaskit/editor-palette": "1.5.1",
|
package/report.api.md
CHANGED
|
@@ -32,6 +32,7 @@ import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
|
32
32
|
import { BrowserFreezetracking } from '@atlaskit/editor-common/types';
|
|
33
33
|
import { CardOptions } from '@atlaskit/editor-common/card';
|
|
34
34
|
import { CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
35
|
+
import { clearEditorContent } from '@atlaskit/editor-common/commands';
|
|
35
36
|
import type { CollabEditOptions } from '@atlaskit/editor-common/collab';
|
|
36
37
|
import { Color } from '@atlaskit/status/element';
|
|
37
38
|
import { Command as Command_2 } from '@atlaskit/editor-common/types';
|
|
@@ -340,8 +341,7 @@ interface CellSelectionData {
|
|
|
340
341
|
// @public (undocumented)
|
|
341
342
|
export const changeColor: (color: string) => Command;
|
|
342
343
|
|
|
343
|
-
|
|
344
|
-
export const clearEditorContent: Command;
|
|
344
|
+
export { clearEditorContent };
|
|
345
345
|
|
|
346
346
|
// @public (undocumented)
|
|
347
347
|
type CloseOptions = {
|
package/tmp/api-report-tmp.d.ts
CHANGED
|
@@ -21,6 +21,7 @@ import { AnnotationTypes } from '@atlaskit/adf-schema';
|
|
|
21
21
|
import { BrowserFreezetracking } from '@atlaskit/editor-common/types';
|
|
22
22
|
import { CardOptions } from '@atlaskit/editor-common/card';
|
|
23
23
|
import { CardProvider } from '@atlaskit/editor-common/provider-factory';
|
|
24
|
+
import { clearEditorContent } from '@atlaskit/editor-common/commands';
|
|
24
25
|
import type { CollabEditOptions } from '@atlaskit/editor-common/collab';
|
|
25
26
|
import { Color } from '@atlaskit/status/element';
|
|
26
27
|
import { Command as Command_2 } from '@atlaskit/editor-common/types';
|
|
@@ -323,8 +324,7 @@ interface CellSelectionData {
|
|
|
323
324
|
// @public (undocumented)
|
|
324
325
|
export const changeColor: (color: string) => Command;
|
|
325
326
|
|
|
326
|
-
|
|
327
|
-
export const clearEditorContent: Command;
|
|
327
|
+
export { clearEditorContent }
|
|
328
328
|
|
|
329
329
|
// @public (undocumented)
|
|
330
330
|
type CloseOptions = {
|