@atlaskit/editor-plugin-block-type 1.0.3 → 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 +40 -0
- package/dist/cjs/i18n/cs.js +2 -3
- package/dist/cjs/i18n/da.js +2 -3
- package/dist/cjs/i18n/de.js +2 -3
- package/dist/cjs/i18n/en.js +2 -3
- package/dist/cjs/i18n/en_GB.js +2 -3
- package/dist/cjs/i18n/en_ZZ.js +2 -3
- package/dist/cjs/i18n/es.js +2 -3
- package/dist/cjs/i18n/fi.js +2 -3
- package/dist/cjs/i18n/fr.js +2 -3
- package/dist/cjs/i18n/hu.js +2 -3
- package/dist/cjs/i18n/it.js +2 -3
- package/dist/cjs/i18n/ja.js +2 -3
- package/dist/cjs/i18n/ko.js +2 -3
- package/dist/cjs/i18n/nb.js +2 -3
- package/dist/cjs/i18n/nl.js +8 -9
- package/dist/cjs/i18n/pl.js +2 -3
- package/dist/cjs/i18n/pt_BR.js +2 -3
- package/dist/cjs/i18n/ru.js +2 -3
- package/dist/cjs/i18n/sv.js +2 -3
- package/dist/cjs/i18n/th.js +2 -3
- package/dist/cjs/i18n/tr.js +2 -3
- package/dist/cjs/i18n/uk.js +2 -3
- package/dist/cjs/i18n/vi.js +2 -3
- package/dist/cjs/i18n/zh.js +2 -3
- package/dist/cjs/i18n/zh_TW.js +2 -3
- package/dist/cjs/plugin/block-types.js +29 -45
- package/dist/cjs/plugin/commands/block-type.js +95 -60
- package/dist/cjs/plugin/commands/delete-and-move-cursor.js +2 -3
- package/dist/cjs/plugin/commands/index.js +1 -8
- package/dist/cjs/plugin/consts.js +1 -2
- package/dist/cjs/plugin/index.js +26 -26
- package/dist/cjs/plugin/pm-plugins/input-rule.js +1 -2
- package/dist/cjs/plugin/pm-plugins/main.js +12 -12
- package/dist/cjs/plugin/styles.js +2 -3
- package/dist/cjs/plugin/ui/ToolbarBlockType/blocktype-button.js +5 -13
- package/dist/cjs/plugin/ui/ToolbarBlockType/index.js +2 -3
- package/dist/cjs/plugin/ui/ToolbarBlockType/styled.js +7 -14
- package/dist/cjs/plugin/utils.js +3 -6
- package/dist/es2019/i18n/nl.js +6 -6
- package/dist/es2019/plugin/block-types.js +1 -1
- 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 +18 -19
- package/dist/es2019/plugin/pm-plugins/main.js +10 -8
- package/dist/es2019/plugin/ui/ToolbarBlockType/blocktype-button.js +3 -9
- package/dist/es2019/plugin/ui/ToolbarBlockType/index.js +1 -1
- package/dist/esm/i18n/nl.js +6 -6
- package/dist/esm/plugin/block-types.js +1 -1
- 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 +20 -19
- package/dist/esm/plugin/pm-plugins/main.js +10 -8
- package/dist/esm/plugin/ui/ToolbarBlockType/blocktype-button.js +3 -9
- 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/blocktype-button.d.ts +0 -7
- 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/blocktype-button.d.ts +0 -7
- package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/index.d.ts +2 -1
- package/package.json +3 -4
- package/report.api.md +17 -1
- package/tmp/api-report-tmp.d.ts +7 -1
- package/dist/cjs/messages.js +0 -19
- package/dist/cjs/plugin/messages.js +0 -160
- package/dist/cjs/plugin/ui/ToolbarBlockType/toolbar-messages.js +0 -15
- package/dist/es2019/messages.js +0 -2
- package/dist/es2019/plugin/messages.js +0 -153
- package/dist/es2019/plugin/ui/ToolbarBlockType/toolbar-messages.js +0 -8
- package/dist/esm/messages.js +0 -2
- package/dist/esm/plugin/messages.js +0 -153
- package/dist/esm/plugin/ui/ToolbarBlockType/toolbar-messages.js +0 -8
- package/dist/types/messages.d.ts +0 -2
- package/dist/types/plugin/messages.d.ts +0 -152
- package/dist/types/plugin/ui/ToolbarBlockType/toolbar-messages.d.ts +0 -7
- package/dist/types-ts4.5/messages.d.ts +0 -2
- package/dist/types-ts4.5/plugin/messages.d.ts +0 -152
- package/dist/types-ts4.5/plugin/ui/ToolbarBlockType/toolbar-messages.d.ts +0 -7
- package/messages/package.json +0 -15
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) {
|
|
@@ -1,8 +1,3 @@
|
|
|
1
1
|
export { cleanUpAtTheStartOfDocument, insertBlockQuoteWithAnalytics, setBlockType, setBlockTypeWithAnalytics, setHeadingWithAnalytics, setNormalText, setNormalTextWithAnalytics } from './block-type';
|
|
2
2
|
export { deleteAndMoveCursor } from './delete-and-move-cursor';
|
|
3
|
-
export { deleteBlockContent } from './delete-block-content';
|
|
4
|
-
/**
|
|
5
|
-
* @private
|
|
6
|
-
* @deprecated use import from @atlaskit/editor-common/commands
|
|
7
|
-
*/
|
|
8
|
-
export { setHeading } from '@atlaskit/editor-common/commands';
|
|
3
|
+
export { deleteBlockContent } from './delete-block-content';
|
|
@@ -2,12 +2,12 @@ import React from 'react';
|
|
|
2
2
|
import { blockquote, hardBreak, heading } from '@atlaskit/adf-schema';
|
|
3
3
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
4
|
import { keymap, toggleBlockQuote, tooltip } from '@atlaskit/editor-common/keymaps';
|
|
5
|
+
import { blockTypeMessages as messages } from '@atlaskit/editor-common/messages';
|
|
5
6
|
import { IconHeading, IconQuote } from '@atlaskit/editor-common/quick-insert';
|
|
6
7
|
import { ToolbarSize } from '@atlaskit/editor-common/types';
|
|
7
8
|
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
8
9
|
import { setBlockTypeWithAnalytics } from './commands';
|
|
9
10
|
import { insertBlockQuoteWithAnalytics } from './commands/block-type';
|
|
10
|
-
import { messages } from './messages';
|
|
11
11
|
import inputRulePlugin from './pm-plugins/input-rule';
|
|
12
12
|
import keymapPlugin from './pm-plugins/keymap';
|
|
13
13
|
import { createPlugin, pluginKey } from './pm-plugins/main';
|
|
@@ -112,18 +112,15 @@ const blockTypePlugin = ({
|
|
|
112
112
|
name: 'blockType',
|
|
113
113
|
plugin: ({
|
|
114
114
|
dispatch
|
|
115
|
-
}) =>
|
|
116
|
-
var _api$analytics;
|
|
117
|
-
return createPlugin(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, dispatch, options && options.lastNodeMustBeParagraph);
|
|
118
|
-
}
|
|
115
|
+
}) => createPlugin(api, dispatch, options && options.lastNodeMustBeParagraph)
|
|
119
116
|
}, {
|
|
120
117
|
name: 'blockTypeInputRule',
|
|
121
118
|
plugin: ({
|
|
122
119
|
schema,
|
|
123
120
|
featureFlags
|
|
124
121
|
}) => {
|
|
125
|
-
var _api$
|
|
126
|
-
return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$
|
|
122
|
+
var _api$analytics;
|
|
123
|
+
return inputRulePlugin(api === null || api === void 0 ? void 0 : (_api$analytics = api.analytics) === null || _api$analytics === void 0 ? void 0 : _api$analytics.actions, schema, featureFlags);
|
|
127
124
|
}
|
|
128
125
|
},
|
|
129
126
|
// Needs to be lower priority than editor-tables.tableEditing
|
|
@@ -134,19 +131,21 @@ const blockTypePlugin = ({
|
|
|
134
131
|
schema,
|
|
135
132
|
featureFlags
|
|
136
133
|
}) => {
|
|
137
|
-
var _api$
|
|
138
|
-
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$
|
|
134
|
+
var _api$analytics2;
|
|
135
|
+
return keymapPlugin(api === null || api === void 0 ? void 0 : (_api$analytics2 = api.analytics) === null || _api$analytics2 === void 0 ? void 0 : _api$analytics2.actions, schema, featureFlags);
|
|
139
136
|
}
|
|
140
137
|
}];
|
|
141
138
|
},
|
|
142
139
|
actions: {
|
|
143
140
|
insertBlockQuote(inputMethod) {
|
|
141
|
+
var _api$analytics3;
|
|
142
|
+
return insertBlockQuoteWithAnalytics(inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics3 = api.analytics) === null || _api$analytics3 === void 0 ? void 0 : _api$analytics3.actions);
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
commands: {
|
|
146
|
+
setTextLevel(level, inputMethod) {
|
|
144
147
|
var _api$analytics4;
|
|
145
|
-
return
|
|
146
|
-
},
|
|
147
|
-
setBlockType(name, inputMethod) {
|
|
148
|
-
var _api$analytics5;
|
|
149
|
-
return setBlockTypeWithAnalytics(name, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions);
|
|
148
|
+
return setBlockTypeWithAnalytics(level, inputMethod, api === null || api === void 0 ? void 0 : (_api$analytics4 = api.analytics) === null || _api$analytics4 === void 0 ? void 0 : _api$analytics4.actions);
|
|
150
149
|
}
|
|
151
150
|
},
|
|
152
151
|
getSharedState(editorState) {
|
|
@@ -167,8 +166,8 @@ const blockTypePlugin = ({
|
|
|
167
166
|
}) {
|
|
168
167
|
const isSmall = options && options.isUndoRedoButtonsEnabled ? toolbarSize < ToolbarSize.XXL : toolbarSize < ToolbarSize.XL;
|
|
169
168
|
const boundSetBlockType = name => {
|
|
170
|
-
var _api$
|
|
171
|
-
|
|
169
|
+
var _api$analytics5;
|
|
170
|
+
api === null || api === void 0 ? void 0 : api.core.actions.execute(setBlockTypeWithAnalytics(name, INPUT_METHOD.TOOLBAR, api === null || api === void 0 ? void 0 : (_api$analytics5 = api.analytics) === null || _api$analytics5 === void 0 ? void 0 : _api$analytics5.actions));
|
|
172
171
|
};
|
|
173
172
|
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
174
173
|
editorView: editorView,
|
|
@@ -183,7 +182,7 @@ const blockTypePlugin = ({
|
|
|
183
182
|
isSmall: isSmall,
|
|
184
183
|
isDisabled: disabled,
|
|
185
184
|
isReducedSpacing: isToolbarReducedSpacing,
|
|
186
|
-
|
|
185
|
+
setTextLevel: boundSetBlockType,
|
|
187
186
|
pluginState: pluginState,
|
|
188
187
|
popupsMountPoint: popupsMountPoint,
|
|
189
188
|
popupsBoundariesElement: popupsBoundariesElement,
|
|
@@ -194,9 +193,9 @@ const blockTypePlugin = ({
|
|
|
194
193
|
},
|
|
195
194
|
pluginsOptions: {
|
|
196
195
|
quickInsert: intl => {
|
|
197
|
-
var _api$
|
|
196
|
+
var _api$analytics6, _api$analytics7;
|
|
198
197
|
const exclude = options && options.allowBlockType && options.allowBlockType.exclude ? options.allowBlockType.exclude : [];
|
|
199
|
-
return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$
|
|
198
|
+
return [...blockquotePluginOptions(intl, exclude.indexOf('blockquote') === -1, api === null || api === void 0 ? void 0 : (_api$analytics6 = api.analytics) === null || _api$analytics6 === void 0 ? void 0 : _api$analytics6.actions), ...headingPluginOptions(intl, exclude.indexOf('heading') === -1, api === null || api === void 0 ? void 0 : (_api$analytics7 = api.analytics) === null || _api$analytics7 === void 0 ? void 0 : _api$analytics7.actions)];
|
|
200
199
|
}
|
|
201
200
|
}
|
|
202
201
|
});
|
|
@@ -59,16 +59,16 @@ const detectBlockType = (availableBlockTypes, state) => {
|
|
|
59
59
|
});
|
|
60
60
|
return blockType || OTHER;
|
|
61
61
|
};
|
|
62
|
-
const autoformatHeading = (headingLevel,
|
|
62
|
+
const autoformatHeading = (headingLevel, editorAnalyticsApi) => {
|
|
63
63
|
if (headingLevel === 0) {
|
|
64
|
-
setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING, editorAnalyticsApi)
|
|
65
|
-
} else {
|
|
66
|
-
setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
|
|
64
|
+
return setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING, editorAnalyticsApi);
|
|
67
65
|
}
|
|
68
|
-
return
|
|
66
|
+
return setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING, editorAnalyticsApi);
|
|
69
67
|
};
|
|
70
68
|
export const pluginKey = new PluginKey('blockTypePlugin');
|
|
71
|
-
export const createPlugin = (
|
|
69
|
+
export const createPlugin = (editorAPI, dispatch, lastNodeMustBeParagraph) => {
|
|
70
|
+
var _editorAPI$analytics;
|
|
71
|
+
const editorAnalyticsApi = editorAPI === null || editorAPI === void 0 ? void 0 : (_editorAPI$analytics = editorAPI.analytics) === null || _editorAPI$analytics === void 0 ? void 0 : _editorAPI$analytics.actions;
|
|
72
72
|
let altKeyLocation = 0;
|
|
73
73
|
return new SafePlugin({
|
|
74
74
|
appendTransaction(_transactions, _oldState, newState) {
|
|
@@ -118,9 +118,11 @@ export const createPlugin = (editorAnalyticsApi, dispatch, lastNodeMustBeParagra
|
|
|
118
118
|
const headingLevel = HEADING_KEYS.indexOf(event.keyCode);
|
|
119
119
|
if (headingLevel > -1 && event.altKey) {
|
|
120
120
|
if (browser.mac && event.metaKey) {
|
|
121
|
-
|
|
121
|
+
var _editorAPI$core$actio;
|
|
122
|
+
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;
|
|
122
123
|
} else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
|
|
123
|
-
|
|
124
|
+
var _editorAPI$core$actio2;
|
|
125
|
+
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;
|
|
124
126
|
}
|
|
125
127
|
} else if (event.key === 'Alt') {
|
|
126
128
|
// event.location is for the current key only; when a user hits Ctrl-Alt-1 the
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { jsx } from '@emotion/react';
|
|
4
|
-
import {
|
|
4
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
5
|
+
import { toolbarMessages } from '@atlaskit/editor-common/messages';
|
|
5
6
|
import { wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
6
7
|
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
7
8
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
8
9
|
import TextStyleIcon from '@atlaskit/icon/glyph/editor/text-style';
|
|
9
10
|
import { NORMAL_TEXT } from '../../block-types';
|
|
10
11
|
import { buttonContentReducedSpacingStyle, buttonContentStyle, expandIconWrapperStyle, wrapperSmallStyle } from './styled';
|
|
11
|
-
export const messages = defineMessages({
|
|
12
|
-
textStyles: {
|
|
13
|
-
id: 'fabric.editor.textStyles',
|
|
14
|
-
defaultMessage: 'Text styles',
|
|
15
|
-
description: 'Menu provides access to various heading styles or normal text'
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
12
|
export const BlockTypeButton = props => {
|
|
19
|
-
const labelTextStyles = props.formatMessage(
|
|
13
|
+
const labelTextStyles = props.formatMessage(toolbarMessages.textStyles);
|
|
20
14
|
return jsx(ToolbarButton, {
|
|
21
15
|
spacing: props.isReducedSpacing ? 'none' : 'default',
|
|
22
16
|
selected: props.selected,
|
|
@@ -83,7 +83,7 @@ class ToolbarBlockType extends React.PureComponent {
|
|
|
83
83
|
shouldCloseMenu = true
|
|
84
84
|
}) => {
|
|
85
85
|
const blockType = item.value;
|
|
86
|
-
this.props.
|
|
86
|
+
this.props.setTextLevel(blockType.name);
|
|
87
87
|
if (shouldCloseMenu) {
|
|
88
88
|
this.setState({
|
|
89
89
|
...this.state,
|
package/dist/esm/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',
|
|
@@ -2,61 +2,84 @@ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol
|
|
|
2
2
|
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); }
|
|
3
3
|
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; }
|
|
4
4
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
5
|
-
import { setHeading } from '@atlaskit/editor-common/commands';
|
|
6
5
|
import { withAnalytics } from '@atlaskit/editor-common/editor-analytics';
|
|
7
6
|
import { filterChildrenBetween, wrapSelectionIn } from '@atlaskit/editor-common/utils';
|
|
8
7
|
import { CellSelection } from '@atlaskit/editor-tables';
|
|
9
8
|
import { HEADINGS_BY_NAME, NORMAL_TEXT } from '../block-types';
|
|
10
9
|
export function setBlockType(name) {
|
|
11
|
-
return function (
|
|
12
|
-
var
|
|
10
|
+
return function (_ref) {
|
|
11
|
+
var tr = _ref.tr;
|
|
12
|
+
var nodes = tr.doc.type.schema.nodes;
|
|
13
13
|
if (name === NORMAL_TEXT.name && nodes.paragraph) {
|
|
14
|
-
return setNormalText()(
|
|
14
|
+
return setNormalText()({
|
|
15
|
+
tr: tr
|
|
16
|
+
});
|
|
15
17
|
}
|
|
16
18
|
var headingBlockType = HEADINGS_BY_NAME[name];
|
|
17
19
|
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
18
|
-
return setHeading(headingBlockType.level)(
|
|
20
|
+
return setHeading(headingBlockType.level)({
|
|
21
|
+
tr: tr
|
|
22
|
+
});
|
|
19
23
|
}
|
|
20
|
-
return
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function setHeading(level) {
|
|
28
|
+
return function (_ref2) {
|
|
29
|
+
var tr = _ref2.tr;
|
|
30
|
+
var selection = tr.selection,
|
|
31
|
+
schema = tr.doc.type.schema;
|
|
32
|
+
var ranges = selection instanceof CellSelection ? selection.ranges : [selection];
|
|
33
|
+
ranges.forEach(function (_ref3) {
|
|
34
|
+
var $from = _ref3.$from,
|
|
35
|
+
$to = _ref3.$to;
|
|
36
|
+
tr.setBlockType($from.pos, $to.pos, schema.nodes.heading, {
|
|
37
|
+
level: level
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
return tr;
|
|
21
41
|
};
|
|
22
42
|
}
|
|
23
43
|
export function setBlockTypeWithAnalytics(name, inputMethod, editorAnalyticsApi) {
|
|
24
|
-
return function (
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
44
|
+
return function (_ref4) {
|
|
45
|
+
var tr = _ref4.tr;
|
|
46
|
+
var nodes = tr.doc.type.schema.nodes;
|
|
47
|
+
if (name === 'normal' && nodes.paragraph) {
|
|
48
|
+
return setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi)({
|
|
49
|
+
tr: tr
|
|
50
|
+
});
|
|
28
51
|
}
|
|
29
52
|
var headingBlockType = HEADINGS_BY_NAME[name];
|
|
30
53
|
if (headingBlockType && nodes.heading && headingBlockType.level) {
|
|
31
|
-
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)(
|
|
54
|
+
return setHeadingWithAnalytics(headingBlockType.level, inputMethod, editorAnalyticsApi)({
|
|
55
|
+
tr: tr
|
|
56
|
+
});
|
|
32
57
|
}
|
|
33
|
-
return
|
|
58
|
+
return null;
|
|
34
59
|
};
|
|
35
60
|
}
|
|
36
61
|
export function setNormalText() {
|
|
37
|
-
return function (
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
62
|
+
return function (_ref5) {
|
|
63
|
+
var tr = _ref5.tr;
|
|
64
|
+
var selection = tr.selection,
|
|
65
|
+
schema = tr.doc.type.schema;
|
|
41
66
|
var ranges = selection instanceof CellSelection ? selection.ranges : [selection];
|
|
42
|
-
ranges.forEach(function (
|
|
43
|
-
var $from =
|
|
44
|
-
$to =
|
|
67
|
+
ranges.forEach(function (_ref6) {
|
|
68
|
+
var $from = _ref6.$from,
|
|
69
|
+
$to = _ref6.$to;
|
|
45
70
|
tr.setBlockType($from.pos, $to.pos, schema.nodes.paragraph);
|
|
46
71
|
});
|
|
47
|
-
|
|
48
|
-
dispatch(tr);
|
|
49
|
-
}
|
|
50
|
-
return true;
|
|
72
|
+
return tr;
|
|
51
73
|
};
|
|
52
74
|
}
|
|
53
75
|
function withCurrentHeadingLevel(fn) {
|
|
54
|
-
return function (
|
|
76
|
+
return function (_ref7) {
|
|
77
|
+
var tr = _ref7.tr;
|
|
55
78
|
// Find all headings and paragraphs of text
|
|
56
|
-
var
|
|
57
|
-
heading =
|
|
58
|
-
paragraph =
|
|
59
|
-
var nodes = filterChildrenBetween(
|
|
79
|
+
var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
|
|
80
|
+
heading = _tr$doc$type$schema$n.heading,
|
|
81
|
+
paragraph = _tr$doc$type$schema$n.paragraph;
|
|
82
|
+
var nodes = filterChildrenBetween(tr.doc, tr.selection.from, tr.selection.to, function (node) {
|
|
60
83
|
return node.type === heading || node.type === paragraph;
|
|
61
84
|
});
|
|
62
85
|
|
|
@@ -81,37 +104,51 @@ function withCurrentHeadingLevel(fn) {
|
|
|
81
104
|
} finally {
|
|
82
105
|
_iterator.f();
|
|
83
106
|
}
|
|
84
|
-
return fn(level)(
|
|
107
|
+
return fn(level)({
|
|
108
|
+
tr: tr
|
|
109
|
+
});
|
|
85
110
|
};
|
|
86
111
|
}
|
|
87
112
|
export function setNormalTextWithAnalytics(inputMethod, editorAnalyticsApi) {
|
|
88
113
|
return withCurrentHeadingLevel(function (previousHeadingLevel) {
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
114
|
+
return function (_ref8) {
|
|
115
|
+
var tr = _ref8.tr;
|
|
116
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
117
|
+
action: ACTION.FORMATTED,
|
|
118
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
119
|
+
eventType: EVENT_TYPE.TRACK,
|
|
120
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
|
|
121
|
+
attributes: {
|
|
122
|
+
inputMethod: inputMethod,
|
|
123
|
+
newHeadingLevel: 0,
|
|
124
|
+
previousHeadingLevel: previousHeadingLevel
|
|
125
|
+
}
|
|
126
|
+
})(tr);
|
|
127
|
+
return setNormalText()({
|
|
128
|
+
tr: tr
|
|
129
|
+
});
|
|
130
|
+
};
|
|
100
131
|
});
|
|
101
132
|
}
|
|
102
133
|
export var setHeadingWithAnalytics = function setHeadingWithAnalytics(newHeadingLevel, inputMethod, editorAnalyticsApi) {
|
|
103
134
|
return withCurrentHeadingLevel(function (previousHeadingLevel) {
|
|
104
|
-
return
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
135
|
+
return function (_ref9) {
|
|
136
|
+
var tr = _ref9.tr;
|
|
137
|
+
editorAnalyticsApi === null || editorAnalyticsApi === void 0 || editorAnalyticsApi.attachAnalyticsEvent({
|
|
138
|
+
action: ACTION.FORMATTED,
|
|
139
|
+
actionSubject: ACTION_SUBJECT.TEXT,
|
|
140
|
+
eventType: EVENT_TYPE.TRACK,
|
|
141
|
+
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_HEADING,
|
|
142
|
+
attributes: {
|
|
143
|
+
inputMethod: inputMethod,
|
|
144
|
+
newHeadingLevel: newHeadingLevel,
|
|
145
|
+
previousHeadingLevel: previousHeadingLevel
|
|
146
|
+
}
|
|
147
|
+
})(tr);
|
|
148
|
+
return setHeading(newHeadingLevel)({
|
|
149
|
+
tr: tr
|
|
150
|
+
});
|
|
151
|
+
};
|
|
115
152
|
});
|
|
116
153
|
};
|
|
117
154
|
function insertBlockQuote() {
|
|
@@ -144,8 +181,8 @@ export var insertBlockQuoteWithAnalytics = function insertBlockQuoteWithAnalytic
|
|
|
144
181
|
})(insertBlockQuote());
|
|
145
182
|
};
|
|
146
183
|
export var cleanUpAtTheStartOfDocument = function cleanUpAtTheStartOfDocument(state, dispatch) {
|
|
147
|
-
var
|
|
148
|
-
$cursor =
|
|
184
|
+
var _ref10 = state.selection,
|
|
185
|
+
$cursor = _ref10.$cursor;
|
|
149
186
|
if ($cursor && !$cursor.nodeBefore && !$cursor.nodeAfter && $cursor.pos === 1) {
|
|
150
187
|
var tr = state.tr,
|
|
151
188
|
schema = state.schema;
|