@atlaskit/editor-plugin-block-type 2.0.0 → 3.0.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 +30 -0
- package/dist/cjs/i18n/nl.js +6 -6
- package/dist/cjs/plugin/commands/block-type.js +91 -53
- package/dist/cjs/plugin/commands/index.js +1 -8
- package/dist/cjs/plugin/index.js +17 -16
- package/dist/cjs/plugin/pm-plugins/main.js +10 -8
- package/dist/cjs/plugin/ui/ToolbarBlockType/index.js +1 -1
- package/dist/es2019/i18n/nl.js +6 -6
- package/dist/es2019/plugin/commands/block-type.js +101 -46
- package/dist/es2019/plugin/commands/index.js +1 -6
- package/dist/es2019/plugin/index.js +17 -18
- package/dist/es2019/plugin/pm-plugins/main.js +10 -8
- package/dist/es2019/plugin/ui/ToolbarBlockType/index.js +1 -1
- package/dist/esm/i18n/nl.js +6 -6
- package/dist/esm/plugin/commands/block-type.js +90 -53
- package/dist/esm/plugin/commands/index.js +1 -6
- package/dist/esm/plugin/index.js +17 -16
- package/dist/esm/plugin/pm-plugins/main.js +10 -8
- package/dist/esm/plugin/ui/ToolbarBlockType/index.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/plugin/block-types.d.ts +1 -0
- package/dist/types/plugin/commands/block-type.d.ts +8 -6
- package/dist/types/plugin/commands/index.d.ts +0 -5
- package/dist/types/plugin/index.d.ts +5 -2
- package/dist/types/plugin/pm-plugins/main.d.ts +3 -2
- package/dist/types/plugin/ui/ToolbarBlockType/index.d.ts +2 -1
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/plugin/block-types.d.ts +1 -0
- package/dist/types-ts4.5/plugin/commands/block-type.d.ts +8 -6
- package/dist/types-ts4.5/plugin/commands/index.d.ts +0 -5
- package/dist/types-ts4.5/plugin/index.d.ts +5 -2
- package/dist/types-ts4.5/plugin/pm-plugins/main.d.ts +3 -2
- package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/index.d.ts +2 -1
- package/package.json +3 -3
- package/report.api.md +17 -1
- package/tmp/api-report-tmp.d.ts +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @atlaskit/editor-plugin-block-type
|
|
2
2
|
|
|
3
|
+
## 3.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [#42090](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/42090) [`dfea93d39c9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dfea93d39c9) - Replacing setBlockType action on `editor-plugin-block-type` with setTextLevel
|
|
8
|
+
command.
|
|
9
|
+
|
|
10
|
+
WHAT/WHY?: setBlockType is only for headings/text so the naming is not clear,
|
|
11
|
+
it is also an action which makes it difficult to use by external consumers.
|
|
12
|
+
|
|
13
|
+
This replacement can be easily used by external consumers (ie. for custom toolbars)
|
|
14
|
+
and also has more type safety (for setBlockType the name parameter is any string but
|
|
15
|
+
setTextLevel only accepts valid values including "normal", "heading1",
|
|
16
|
+
"heading2" etc.)
|
|
17
|
+
|
|
18
|
+
HOW?: This API at this stage should be unused by consumers to the best of our
|
|
19
|
+
knowledge. However if you are using it you should change as so:
|
|
20
|
+
|
|
21
|
+
Before:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
api?.blockType.actions.setBlockType(blockType, inputMethod)(state, dispatch);
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
api?.core.actions.execute(
|
|
29
|
+
api?.blockType.commands.setTextLevel(blockType, inputMethod),
|
|
30
|
+
);
|
|
31
|
+
```
|
|
32
|
+
|
|
3
33
|
## 2.0.0
|
|
4
34
|
|
|
5
35
|
### Major Changes
|
package/dist/cjs/i18n/nl.js
CHANGED
|
@@ -22,17 +22,17 @@ var _default = exports.default = {
|
|
|
22
22
|
'fabric.editor.errorPanel': 'Foutpaneel',
|
|
23
23
|
'fabric.editor.errorPanel.description': 'Bijschrift voor fouten maken in een gekleurd paneel',
|
|
24
24
|
'fabric.editor.heading1': 'Koptekst 1',
|
|
25
|
-
'fabric.editor.heading1Description': '
|
|
25
|
+
'fabric.editor.heading1Description': 'Gebruik dit voor een kop op het hoogste niveau',
|
|
26
26
|
'fabric.editor.heading2': 'Koptekst 2',
|
|
27
|
-
'fabric.editor.heading2Description': '
|
|
27
|
+
'fabric.editor.heading2Description': 'Gebruik dit voor belangrijke gedeelten',
|
|
28
28
|
'fabric.editor.heading3': 'Koptekst 3',
|
|
29
|
-
'fabric.editor.heading3Description': '
|
|
29
|
+
'fabric.editor.heading3Description': 'Gebruik dit voor subsecties en groepskoppen',
|
|
30
30
|
'fabric.editor.heading4': 'Koptekst 4',
|
|
31
|
-
'fabric.editor.heading4Description': '
|
|
31
|
+
'fabric.editor.heading4Description': 'Gebruik dit voor diepe koppen',
|
|
32
32
|
'fabric.editor.heading5': 'Koptekst 5',
|
|
33
|
-
'fabric.editor.heading5Description': '
|
|
33
|
+
'fabric.editor.heading5Description': 'Gebruik dit voor het groeperen van lijstitems',
|
|
34
34
|
'fabric.editor.heading6': 'Koptekst 6',
|
|
35
|
-
'fabric.editor.heading6Description': '
|
|
35
|
+
'fabric.editor.heading6Description': 'Gebruik dit voor koppen op laag niveau',
|
|
36
36
|
'fabric.editor.infoPanel': 'Infopaneel',
|
|
37
37
|
'fabric.editor.infoPanel.description': 'Informatie markeren in een gekleurd paneel',
|
|
38
38
|
'fabric.editor.normal': 'Normale tekst',
|
|
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.insertBlockQuoteWithAnalytics = exports.cleanUpAtTheStartOfDocument = void 0;
|
|
7
7
|
exports.setBlockType = setBlockType;
|
|
8
8
|
exports.setBlockTypeWithAnalytics = setBlockTypeWithAnalytics;
|
|
9
|
+
exports.setHeading = setHeading;
|
|
9
10
|
exports.setHeadingWithAnalytics = void 0;
|
|
10
11
|
exports.setNormalText = setNormalText;
|
|
11
12
|
exports.setNormalTextWithAnalytics = setNormalTextWithAnalytics;
|
|
12
13
|
var _analytics = require("@atlaskit/editor-common/analytics");
|
|
13
|
-
var _commands = require("@atlaskit/editor-common/commands");
|
|
14
14
|
var _editorAnalytics = require("@atlaskit/editor-common/editor-analytics");
|
|
15
15
|
var _utils = require("@atlaskit/editor-common/utils");
|
|
16
16
|
var _editorTables = require("@atlaskit/editor-tables");
|
|
@@ -19,55 +19,79 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
|
|
|
19
19
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
20
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
21
21
|
function setBlockType(name) {
|
|
22
|
-
return function (
|
|
23
|
-
var
|
|
22
|
+
return function (_ref) {
|
|
23
|
+
var tr = _ref.tr;
|
|
24
|
+
var nodes = tr.doc.type.schema.nodes;
|
|
24
25
|
if (name === _blockTypes.NORMAL_TEXT.name && nodes.paragraph) {
|
|
25
|
-
return setNormalText()(
|
|
26
|
+
return setNormalText()({
|
|
27
|
+
tr: tr
|
|
28
|
+
});
|
|
26
29
|
}
|
|
27
30
|
var headingBlockType = _blockTypes.HEADINGS_BY_NAME[name];
|
|
28
31
|
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
29
|
-
return
|
|
32
|
+
return setHeading(headingBlockType.level)({
|
|
33
|
+
tr: tr
|
|
34
|
+
});
|
|
30
35
|
}
|
|
31
|
-
return
|
|
36
|
+
return null;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function setHeading(level) {
|
|
40
|
+
return function (_ref2) {
|
|
41
|
+
var tr = _ref2.tr;
|
|
42
|
+
var selection = tr.selection,
|
|
43
|
+
schema = tr.doc.type.schema;
|
|
44
|
+
var ranges = selection instanceof _editorTables.CellSelection ? selection.ranges : [selection];
|
|
45
|
+
ranges.forEach(function (_ref3) {
|
|
46
|
+
var $from = _ref3.$from,
|
|
47
|
+
$to = _ref3.$to;
|
|
48
|
+
tr.setBlockType($from.pos, $to.pos, schema.nodes.heading, {
|
|
49
|
+
level: level
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return tr;
|
|
32
53
|
};
|
|
33
54
|
}
|
|
34
55
|
function setBlockTypeWithAnalytics(name, inputMethod, editorAnalyticsApi) {
|
|
35
|
-
return function (
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
56
|
+
return function (_ref4) {
|
|
57
|
+
var tr = _ref4.tr;
|
|
58
|
+
var nodes = tr.doc.type.schema.nodes;
|
|
59
|
+
if (name === 'normal' && nodes.paragraph) {
|
|
60
|
+
return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)({
|
|
61
|
+
tr: tr
|
|
62
|
+
});
|
|
39
63
|
}
|
|
40
64
|
var headingBlockType = _blockTypes.HEADINGS_BY_NAME[name];
|
|
41
65
|
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
42
|
-
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)(
|
|
66
|
+
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)({
|
|
67
|
+
tr: tr
|
|
68
|
+
});
|
|
43
69
|
}
|
|
44
|
-
return
|
|
70
|
+
return null;
|
|
45
71
|
};
|
|
46
72
|
}
|
|
47
73
|
function setNormalText() {
|
|
48
|
-
return function (
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
74
|
+
return function (_ref5) {
|
|
75
|
+
var tr = _ref5.tr;
|
|
76
|
+
var selection = tr.selection,
|
|
77
|
+
schema = tr.doc.type.schema;
|
|
52
78
|
var ranges = selection instanceof _editorTables.CellSelection ? selection.ranges : [selection];
|
|
53
|
-
ranges.forEach(function (
|
|
54
|
-
var $from =
|
|
55
|
-
$to =
|
|
79
|
+
ranges.forEach(function (_ref6) {
|
|
80
|
+
var $from = _ref6.$from,
|
|
81
|
+
$to = _ref6.$to;
|
|
56
82
|
tr.setBlockType($from.pos, $to.pos, schema.nodes.paragraph);
|
|
57
83
|
});
|
|
58
|
-
|
|
59
|
-
dispatch(tr);
|
|
60
|
-
}
|
|
61
|
-
return true;
|
|
84
|
+
return tr;
|
|
62
85
|
};
|
|
63
86
|
}
|
|
64
87
|
function withCurrentHeadingLevel(fn) {
|
|
65
|
-
return function (
|
|
88
|
+
return function (_ref7) {
|
|
89
|
+
var tr = _ref7.tr;
|
|
66
90
|
// Find all headings and paragraphs of text
|
|
67
|
-
var
|
|
68
|
-
heading =
|
|
69
|
-
paragraph =
|
|
70
|
-
var nodes = (0, _utils.filterChildrenBetween)(
|
|
91
|
+
var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
|
|
92
|
+
heading = _tr$doc$type$schema$n.heading,
|
|
93
|
+
paragraph = _tr$doc$type$schema$n.paragraph;
|
|
94
|
+
var nodes = (0, _utils.filterChildrenBetween)(tr.doc, tr.selection.from, tr.selection.to, function (node) {
|
|
71
95
|
return node.type === heading || node.type === paragraph;
|
|
72
96
|
});
|
|
73
97
|
|
|
@@ -92,37 +116,51 @@ function withCurrentHeadingLevel(fn) {
|
|
|
92
116
|
} finally {
|
|
93
117
|
_iterator.f();
|
|
94
118
|
}
|
|
95
|
-
return fn(level)(
|
|
119
|
+
return fn(level)({
|
|
120
|
+
tr: tr
|
|
121
|
+
});
|
|
96
122
|
};
|
|
97
123
|
}
|
|
98
124
|
function setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi) {
|
|
99
125
|
return withCurrentHeadingLevel(function (previousHeadingLevel) {
|
|
100
|
-
return (
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
126
|
+
return function (_ref8) {
|
|
127
|
+
var tr = _ref8.tr;
|
|
128
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
129
|
+
action: _analytics.ACTION.FORMATTED,
|
|
130
|
+
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
131
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
132
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_HEADING,
|
|
133
|
+
attributes: {
|
|
134
|
+
inputMethod: inputMethod,
|
|
135
|
+
newHeadingLevel: 0,
|
|
136
|
+
previousHeadingLevel: previousHeadingLevel
|
|
137
|
+
}
|
|
138
|
+
})(tr);
|
|
139
|
+
return setNormalText()({
|
|
140
|
+
tr: tr
|
|
141
|
+
});
|
|
142
|
+
};
|
|
111
143
|
});
|
|
112
144
|
}
|
|
113
145
|
var setHeadingWithAnalytics = exports.setHeadingWithAnalytics = function setHeadingWithAnalytics(newHeadingLevel, inputMethod, editorAnalyticsApi) {
|
|
114
146
|
return withCurrentHeadingLevel(function (previousHeadingLevel) {
|
|
115
|
-
return (
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
147
|
+
return function (_ref9) {
|
|
148
|
+
var tr = _ref9.tr;
|
|
149
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
150
|
+
action: _analytics.ACTION.FORMATTED,
|
|
151
|
+
actionSubject: _analytics.ACTION_SUBJECT.TEXT,
|
|
152
|
+
eventType: _analytics.EVENT_TYPE.TRACK,
|
|
153
|
+
actionSubjectId: _analytics.ACTION_SUBJECT_ID.FORMAT_HEADING,
|
|
154
|
+
attributes: {
|
|
155
|
+
inputMethod: inputMethod,
|
|
156
|
+
newHeadingLevel: newHeadingLevel,
|
|
157
|
+
previousHeadingLevel: previousHeadingLevel
|
|
158
|
+
}
|
|
159
|
+
})(tr);
|
|
160
|
+
return setHeading(newHeadingLevel)({
|
|
161
|
+
tr: tr
|
|
162
|
+
});
|
|
163
|
+
};
|
|
126
164
|
});
|
|
127
165
|
};
|
|
128
166
|
function insertBlockQuote() {
|
|
@@ -155,8 +193,8 @@ var insertBlockQuoteWithAnalytics = exports.insertBlockQuoteWithAnalytics = func
|
|
|
155
193
|
})(insertBlockQuote());
|
|
156
194
|
};
|
|
157
195
|
var cleanUpAtTheStartOfDocument = exports.cleanUpAtTheStartOfDocument = function cleanUpAtTheStartOfDocument(state, dispatch) {
|
|
158
|
-
var
|
|
159
|
-
$cursor =
|
|
196
|
+
var _ref10 = state.selection,
|
|
197
|
+
$cursor = _ref10.$cursor;
|
|
160
198
|
if ($cursor && !$cursor.nodeBefore && !$cursor.nodeAfter && $cursor.pos === 1) {
|
|
161
199
|
var tr = state.tr,
|
|
162
200
|
schema = state.schema;
|
|
@@ -39,12 +39,6 @@ Object.defineProperty(exports, "setBlockTypeWithAnalytics", {
|
|
|
39
39
|
return _blockType.setBlockTypeWithAnalytics;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(exports, "setHeading", {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function get() {
|
|
45
|
-
return _commands.setHeading;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
42
|
Object.defineProperty(exports, "setHeadingWithAnalytics", {
|
|
49
43
|
enumerable: true,
|
|
50
44
|
get: function get() {
|
|
@@ -65,5 +59,4 @@ Object.defineProperty(exports, "setNormalTextWithAnalytics", {
|
|
|
65
59
|
});
|
|
66
60
|
var _blockType = require("./block-type");
|
|
67
61
|
var _deleteAndMoveCursor = require("./delete-and-move-cursor");
|
|
68
|
-
var _deleteBlockContent = require("./delete-block-content");
|
|
69
|
-
var _commands = require("@atlaskit/editor-common/commands");
|
|
62
|
+
var _deleteBlockContent = require("./delete-block-content");
|
package/dist/cjs/plugin/index.js
CHANGED
|
@@ -129,17 +129,16 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
|
|
|
129
129
|
return [{
|
|
130
130
|
name: 'blockType',
|
|
131
131
|
plugin: function plugin(_ref4) {
|
|
132
|
-
var _api$analytics;
|
|
133
132
|
var dispatch = _ref4.dispatch;
|
|
134
|
-
return (0, _main.createPlugin)(api
|
|
133
|
+
return (0, _main.createPlugin)(api, dispatch, options && options.lastNodeMustBeParagraph);
|
|
135
134
|
}
|
|
136
135
|
}, {
|
|
137
136
|
name: 'blockTypeInputRule',
|
|
138
137
|
plugin: function plugin(_ref5) {
|
|
139
|
-
var _api$
|
|
138
|
+
var _api$analytics;
|
|
140
139
|
var schema = _ref5.schema,
|
|
141
140
|
featureFlags = _ref5.featureFlags;
|
|
142
|
-
return (0, _inputRule.default)(api === null || api === void 0 || (_api$
|
|
141
|
+
return (0, _inputRule.default)(api === null || api === void 0 || (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
|
|
143
142
|
}
|
|
144
143
|
},
|
|
145
144
|
// Needs to be lower priority than editor-tables.tableEditing
|
|
@@ -147,21 +146,23 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
|
|
|
147
146
|
{
|
|
148
147
|
name: 'blockTypeKeyMap',
|
|
149
148
|
plugin: function plugin(_ref6) {
|
|
150
|
-
var _api$
|
|
149
|
+
var _api$analytics2;
|
|
151
150
|
var schema = _ref6.schema,
|
|
152
151
|
featureFlags = _ref6.featureFlags;
|
|
153
|
-
return (0, _keymap.default)(api === null || api === void 0 || (_api$
|
|
152
|
+
return (0, _keymap.default)(api === null || api === void 0 || (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
|
|
154
153
|
}
|
|
155
154
|
}];
|
|
156
155
|
},
|
|
157
156
|
actions: {
|
|
158
157
|
insertBlockQuote: function insertBlockQuote(inputMethod) {
|
|
158
|
+
var _api$analytics3;
|
|
159
|
+
return (0, _blockType.insertBlockQuoteWithAnalytics)(inputMethod, api === null || api === void 0 || (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
commands: {
|
|
163
|
+
setTextLevel: function setTextLevel(level, inputMethod) {
|
|
159
164
|
var _api$analytics4;
|
|
160
|
-
return (0,
|
|
161
|
-
},
|
|
162
|
-
setBlockType: function setBlockType(name, inputMethod) {
|
|
163
|
-
var _api$analytics5;
|
|
164
|
-
return (0, _commands.setBlockTypeWithAnalytics)(name, inputMethod, api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions);
|
|
165
|
+
return (0, _commands.setBlockTypeWithAnalytics)(level, inputMethod, api === null || api === void 0 || (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
|
|
165
166
|
}
|
|
166
167
|
},
|
|
167
168
|
getSharedState: function getSharedState(editorState) {
|
|
@@ -181,8 +182,8 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
|
|
|
181
182
|
eventDispatcher = _ref7.eventDispatcher;
|
|
182
183
|
var isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < _types.ToolbarSize.XXL : toolbarSize < _types.ToolbarSize.XL;
|
|
183
184
|
var boundSetBlockType = function boundSetBlockType(name) {
|
|
184
|
-
var _api$
|
|
185
|
-
|
|
185
|
+
var _api$analytics5;
|
|
186
|
+
api === null || api === void 0 || api.core.actions.execute((0, _commands.setBlockTypeWithAnalytics)(name, _analytics.INPUT_METHOD.TOOLBAR, api === null || api === void 0 || (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions));
|
|
186
187
|
};
|
|
187
188
|
return /*#__PURE__*/_react.default.createElement(_withPluginState.WithPluginState, {
|
|
188
189
|
editorView: editorView,
|
|
@@ -196,7 +197,7 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
|
|
|
196
197
|
isSmall: isSmall,
|
|
197
198
|
isDisabled: disabled,
|
|
198
199
|
isReducedSpacing: isToolbarReducedSpacing,
|
|
199
|
-
|
|
200
|
+
setTextLevel: boundSetBlockType,
|
|
200
201
|
pluginState: pluginState,
|
|
201
202
|
popupsMountPoint: popupsMountPoint,
|
|
202
203
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
@@ -207,9 +208,9 @@ var blockTypePlugin = exports.blockTypePlugin = function blockTypePlugin(_ref3)
|
|
|
207
208
|
},
|
|
208
209
|
pluginsOptions: {
|
|
209
210
|
quickInsert: function quickInsert(intl) {
|
|
210
|
-
var _api$
|
|
211
|
+
var _api$analytics6, _api$analytics7;
|
|
211
212
|
var exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
|
|
212
|
-
return [].concat((0, _toConsumableArray2.default)(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 || (_api$
|
|
213
|
+
return [].concat((0, _toConsumableArray2.default)(blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 || (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions)), (0, _toConsumableArray2.default)(headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 || (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions)));
|
|
213
214
|
}
|
|
214
215
|
}
|
|
215
216
|
};
|
|
@@ -70,16 +70,16 @@ var detectBlockType = function detectBlockType(availableBlockTypes, state) {
|
|
|
70
70
|
});
|
|
71
71
|
return blockType || _blockTypes.OTHER;
|
|
72
72
|
};
|
|
73
|
-
var autoformatHeading = function autoformatHeading(headingLevel,
|
|
73
|
+
var autoformatHeading = function autoformatHeading(headingLevel, editorAnalyticsApi) {
|
|
74
74
|
if (headingLevel === 0) {
|
|
75
|
-
(0, _commands.setNormalTextWithAnalytics)(_analytics.INPUT_METHOD.FORMATTING, editorAnalyticsApi)
|
|
76
|
-
} else {
|
|
77
|
-
(0, _commands.setHeadingWithAnalytics)(headingLevel, _analytics.INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
|
|
75
|
+
return (0, _commands.setNormalTextWithAnalytics)(_analytics.INPUT_METHOD.FORMATTING, editorAnalyticsApi);
|
|
78
76
|
}
|
|
79
|
-
return
|
|
77
|
+
return (0, _commands.setHeadingWithAnalytics)(headingLevel, _analytics.INPUT_METHOD.FORMATTING, editorAnalyticsApi);
|
|
80
78
|
};
|
|
81
79
|
var pluginKey = exports.pluginKey = new _state.PluginKey('blockTypePlugin');
|
|
82
|
-
var createPlugin = exports.createPlugin = function createPlugin(
|
|
80
|
+
var createPlugin = exports.createPlugin = function createPlugin(editorAPI, dispatch, lastNodeMustBeParagraph) {
|
|
81
|
+
var _editorAPI$analytics;
|
|
82
|
+
var editorAnalyticsApi = editorAPI === null || editorAPI === void 0 || (_editorAPI$analytics = editorAPI.analytics) === null || _editorAPI$analytics === void 0 ? void 0 : _editorAPI$analytics.actions;
|
|
83
83
|
var altKeyLocation = 0;
|
|
84
84
|
return new _safePlugin.SafePlugin({
|
|
85
85
|
appendTransaction: function appendTransaction(_transactions, _oldState, newState) {
|
|
@@ -130,9 +130,11 @@ var createPlugin = exports.createPlugin = function createPlugin(editorAnalyticsA
|
|
|
130
130
|
var headingLevel = _consts.HEADING_KEYS.indexOf(event.keyCode);
|
|
131
131
|
if (headingLevel > -1 && event.altKey) {
|
|
132
132
|
if (_utils.browser.mac && event.metaKey) {
|
|
133
|
-
|
|
133
|
+
var _editorAPI$core$actio;
|
|
134
|
+
return (_editorAPI$core$actio = editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio !== void 0 ? _editorAPI$core$actio : false;
|
|
134
135
|
} else if (!_utils.browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
|
|
135
|
-
|
|
136
|
+
var _editorAPI$core$actio2;
|
|
137
|
+
return (_editorAPI$core$actio2 = editorAPI === null || editorAPI === void 0 ? void 0 : editorAPI.core.actions.execute(autoformatHeading(headingLevel, editorAnalyticsApi))) !== null && _editorAPI$core$actio2 !== void 0 ? _editorAPI$core$actio2 : false;
|
|
136
138
|
}
|
|
137
139
|
} else if (event.key === 'Alt') {
|
|
138
140
|
// event.location is for the current key only; when a user hits Ctrl-Alt-1 the
|
|
@@ -100,7 +100,7 @@ var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
100
100
|
_ref$shouldCloseMenu = _ref.shouldCloseMenu,
|
|
101
101
|
shouldCloseMenu = _ref$shouldCloseMenu === void 0 ? true : _ref$shouldCloseMenu;
|
|
102
102
|
var blockType = item.value;
|
|
103
|
-
_this.props.
|
|
103
|
+
_this.props.setTextLevel(blockType.name);
|
|
104
104
|
if (shouldCloseMenu) {
|
|
105
105
|
_this.setState(_objectSpread(_objectSpread({}, _this.state), {}, {
|
|
106
106
|
active: false
|
package/dist/es2019/i18n/nl.js
CHANGED
|
@@ -16,17 +16,17 @@ export default {
|
|
|
16
16
|
'fabric.editor.errorPanel': 'Foutpaneel',
|
|
17
17
|
'fabric.editor.errorPanel.description': 'Bijschrift voor fouten maken in een gekleurd paneel',
|
|
18
18
|
'fabric.editor.heading1': 'Koptekst 1',
|
|
19
|
-
'fabric.editor.heading1Description': '
|
|
19
|
+
'fabric.editor.heading1Description': 'Gebruik dit voor een kop op het hoogste niveau',
|
|
20
20
|
'fabric.editor.heading2': 'Koptekst 2',
|
|
21
|
-
'fabric.editor.heading2Description': '
|
|
21
|
+
'fabric.editor.heading2Description': 'Gebruik dit voor belangrijke gedeelten',
|
|
22
22
|
'fabric.editor.heading3': 'Koptekst 3',
|
|
23
|
-
'fabric.editor.heading3Description': '
|
|
23
|
+
'fabric.editor.heading3Description': 'Gebruik dit voor subsecties en groepskoppen',
|
|
24
24
|
'fabric.editor.heading4': 'Koptekst 4',
|
|
25
|
-
'fabric.editor.heading4Description': '
|
|
25
|
+
'fabric.editor.heading4Description': 'Gebruik dit voor diepe koppen',
|
|
26
26
|
'fabric.editor.heading5': 'Koptekst 5',
|
|
27
|
-
'fabric.editor.heading5Description': '
|
|
27
|
+
'fabric.editor.heading5Description': 'Gebruik dit voor het groeperen van lijstitems',
|
|
28
28
|
'fabric.editor.heading6': 'Koptekst 6',
|
|
29
|
-
'fabric.editor.heading6Description': '
|
|
29
|
+
'fabric.editor.heading6Description': 'Gebruik dit voor koppen op laag niveau',
|
|
30
30
|
'fabric.editor.infoPanel': 'Infopaneel',
|
|
31
31
|
'fabric.editor.infoPanel.description': 'Informatie markeren in een gekleurd paneel',
|
|
32
32
|
'fabric.editor.normal': 'Normale tekst',
|
|
@@ -1,46 +1,86 @@
|
|
|
1
1
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
2
|
-
import { setHeading } from '@atlaskit/editor-common/commands';
|
|
3
2
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
4
3
|
import { filterChildrenBetween, wrapSelectionIn } from '@atlaskit/editor-common/utils';
|
|
5
4
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
6
5
|
import { HEADINGS_BY_NAME, NORMAL_TEXT } from '../block-types';
|
|
7
6
|
export function setBlockType(name) {
|
|
8
|
-
return (
|
|
7
|
+
return ({
|
|
8
|
+
tr
|
|
9
|
+
}) => {
|
|
9
10
|
const {
|
|
10
11
|
nodes
|
|
11
|
-
} =
|
|
12
|
+
} = tr.doc.type.schema;
|
|
12
13
|
if (name === NORMAL_TEXT.name && nodes.paragraph) {
|
|
13
|
-
return setNormalText()(
|
|
14
|
+
return setNormalText()({
|
|
15
|
+
tr
|
|
16
|
+
});
|
|
14
17
|
}
|
|
15
18
|
const headingBlockType = HEADINGS_BY_NAME[name];
|
|
16
19
|
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
17
|
-
return setHeading(headingBlockType.level)(
|
|
20
|
+
return setHeading(headingBlockType.level)({
|
|
21
|
+
tr
|
|
22
|
+
});
|
|
18
23
|
}
|
|
19
|
-
return
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function setHeading(level) {
|
|
28
|
+
return function ({
|
|
29
|
+
tr
|
|
30
|
+
}) {
|
|
31
|
+
const {
|
|
32
|
+
selection,
|
|
33
|
+
doc: {
|
|
34
|
+
type: {
|
|
35
|
+
schema
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
} = tr;
|
|
39
|
+
const ranges = selection instanceof CellSelection ? selection.ranges : [selection];
|
|
40
|
+
ranges.forEach(({
|
|
41
|
+
$from,
|
|
42
|
+
$to
|
|
43
|
+
}) => {
|
|
44
|
+
tr.setBlockType($from.pos, $to.pos, schema.nodes.heading, {
|
|
45
|
+
level
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return tr;
|
|
20
49
|
};
|
|
21
50
|
}
|
|
22
51
|
export function setBlockTypeWithAnalytics(name, inputMethod, editorAnalyticsApi) {
|
|
23
|
-
return (
|
|
52
|
+
return ({
|
|
53
|
+
tr
|
|
54
|
+
}) => {
|
|
24
55
|
const {
|
|
25
56
|
nodes
|
|
26
|
-
} =
|
|
27
|
-
if (name ===
|
|
28
|
-
return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)(
|
|
57
|
+
} = tr.doc.type.schema;
|
|
58
|
+
if (name === 'normal' && nodes.paragraph) {
|
|
59
|
+
return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)({
|
|
60
|
+
tr
|
|
61
|
+
});
|
|
29
62
|
}
|
|
30
63
|
const headingBlockType = HEADINGS_BY_NAME[name];
|
|
31
64
|
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
32
|
-
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)(
|
|
65
|
+
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)({
|
|
66
|
+
tr
|
|
67
|
+
});
|
|
33
68
|
}
|
|
34
|
-
return
|
|
69
|
+
return null;
|
|
35
70
|
};
|
|
36
71
|
}
|
|
37
72
|
export function setNormalText() {
|
|
38
|
-
return function (
|
|
73
|
+
return function ({
|
|
74
|
+
tr
|
|
75
|
+
}) {
|
|
39
76
|
const {
|
|
40
77
|
selection,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
78
|
+
doc: {
|
|
79
|
+
type: {
|
|
80
|
+
schema
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
} = tr;
|
|
44
84
|
const ranges = selection instanceof CellSelection ? selection.ranges : [selection];
|
|
45
85
|
ranges.forEach(({
|
|
46
86
|
$from,
|
|
@@ -48,20 +88,19 @@ export function setNormalText() {
|
|
|
48
88
|
}) => {
|
|
49
89
|
tr.setBlockType($from.pos, $to.pos, schema.nodes.paragraph);
|
|
50
90
|
});
|
|
51
|
-
|
|
52
|
-
dispatch(tr);
|
|
53
|
-
}
|
|
54
|
-
return true;
|
|
91
|
+
return tr;
|
|
55
92
|
};
|
|
56
93
|
}
|
|
57
94
|
function withCurrentHeadingLevel(fn) {
|
|
58
|
-
return (
|
|
95
|
+
return ({
|
|
96
|
+
tr
|
|
97
|
+
}) => {
|
|
59
98
|
// Find all headings and paragraphs of text
|
|
60
99
|
const {
|
|
61
100
|
heading,
|
|
62
101
|
paragraph
|
|
63
|
-
} =
|
|
64
|
-
const nodes = filterChildrenBetween(
|
|
102
|
+
} = tr.doc.type.schema.nodes;
|
|
103
|
+
const nodes = filterChildrenBetween(tr.doc, tr.selection.from, tr.selection.to, node => {
|
|
65
104
|
return node.type === heading || node.type === paragraph;
|
|
66
105
|
});
|
|
67
106
|
|
|
@@ -77,34 +116,50 @@ function withCurrentHeadingLevel(fn) {
|
|
|
77
116
|
break;
|
|
78
117
|
}
|
|
79
118
|
}
|
|
80
|
-
return fn(level)(
|
|
119
|
+
return fn(level)({
|
|
120
|
+
tr
|
|
121
|
+
});
|
|
81
122
|
};
|
|
82
123
|
}
|
|
83
124
|
export function setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi) {
|
|
84
|
-
return withCurrentHeadingLevel(previousHeadingLevel =>
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
125
|
+
return withCurrentHeadingLevel(previousHeadingLevel => ({
|
|
126
|
+
tr
|
|
127
|
+
}) => {
|
|
128
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
|
|
129
|
+
action: ACTION.FORMATTED,
|
|
130
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
131
|
+
eventType: EVENT_TYPE.TRACK,
|
|
132
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
|
|
133
|
+
attributes: {
|
|
134
|
+
inputMethod,
|
|
135
|
+
newHeadingLevel: 0,
|
|
136
|
+
previousHeadingLevel
|
|
137
|
+
}
|
|
138
|
+
})(tr);
|
|
139
|
+
return setNormalText()({
|
|
140
|
+
tr
|
|
141
|
+
});
|
|
142
|
+
});
|
|
95
143
|
}
|
|
96
144
|
export const setHeadingWithAnalytics = (newHeadingLevel, inputMethod, editorAnalyticsApi) => {
|
|
97
|
-
return withCurrentHeadingLevel(previousHeadingLevel =>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
145
|
+
return withCurrentHeadingLevel(previousHeadingLevel => ({
|
|
146
|
+
tr
|
|
147
|
+
}) => {
|
|
148
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 ? void 0 : editorAnalyticsApi.attachAnalyticsEvent({
|
|
149
|
+
action: ACTION.FORMATTED,
|
|
150
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
151
|
+
eventType: EVENT_TYPE.TRACK,
|
|
152
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
|
|
153
|
+
attributes: {
|
|
154
|
+
inputMethod,
|
|
155
|
+
newHeadingLevel,
|
|
156
|
+
previousHeadingLevel
|
|
157
|
+
}
|
|
158
|
+
})(tr);
|
|
159
|
+
return setHeading(newHeadingLevel)({
|
|
160
|
+
tr
|
|
161
|
+
});
|
|
162
|
+
});
|
|
108
163
|
};
|
|
109
164
|
function insertBlockQuote() {
|
|
110
165
|
return function (state, dispatch) {
|