@atlaskit/editor-core 187.9.2 → 187.10.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 +10 -0
- package/dist/cjs/commands/index.js +8 -134
- package/dist/cjs/plugins/base/index.js +2 -2
- package/dist/cjs/plugins/block-type/commands/block-type.js +34 -36
- package/dist/cjs/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/cjs/plugins/block-type/index.js +16 -13
- package/dist/cjs/plugins/block-type/pm-plugins/input-rule.js +19 -18
- package/dist/cjs/plugins/block-type/pm-plugins/keymap.js +12 -14
- package/dist/cjs/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +7 -7
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/index.js +3 -4
- package/dist/cjs/plugins/block-type/ui/ToolbarBlockType/styled.js +13 -5
- package/dist/cjs/plugins/block-type/utils.js +73 -2
- package/dist/cjs/plugins/caption/pm-plugins/keymap.js +2 -2
- package/dist/cjs/plugins/media/utils/media-common.js +5 -5
- package/dist/cjs/plugins/undo-redo/pm-plugins/keymaps.js +2 -2
- package/dist/cjs/ui/styles.js +4 -11
- package/dist/cjs/utils/index.js +4 -80
- package/dist/cjs/utils/input-rules.js +6 -66
- package/dist/cjs/utils/mark.js +2 -38
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/commands/index.js +1 -128
- package/dist/es2019/plugins/base/index.js +1 -1
- package/dist/es2019/plugins/block-type/commands/block-type.js +11 -13
- package/dist/es2019/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/es2019/plugins/block-type/index.js +21 -12
- package/dist/es2019/plugins/block-type/pm-plugins/input-rule.js +18 -18
- package/dist/es2019/plugins/block-type/pm-plugins/keymap.js +8 -9
- package/dist/es2019/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
- package/dist/es2019/plugins/block-type/ui/ToolbarBlockType/styled.js +21 -2
- package/dist/es2019/plugins/block-type/utils.js +70 -1
- package/dist/es2019/plugins/caption/pm-plugins/keymap.js +1 -1
- package/dist/es2019/plugins/media/utils/media-common.js +1 -1
- package/dist/es2019/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
- package/dist/es2019/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
- package/dist/es2019/ui/styles.js +0 -16
- package/dist/es2019/utils/index.js +0 -80
- package/dist/es2019/utils/input-rules.js +4 -61
- package/dist/es2019/utils/mark.js +0 -33
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/commands/index.js +7 -125
- package/dist/esm/plugins/base/index.js +1 -1
- package/dist/esm/plugins/block-type/commands/block-type.js +11 -13
- package/dist/esm/plugins/block-type/commands/transform-to-code-block.js +1 -2
- package/dist/esm/plugins/block-type/index.js +15 -12
- package/dist/esm/plugins/block-type/pm-plugins/input-rule.js +18 -18
- package/dist/esm/plugins/block-type/pm-plugins/keymap.js +8 -9
- package/dist/esm/plugins/block-type/pm-plugins/main.js +9 -9
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/blocktype-button.js +2 -2
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/index.js +2 -3
- package/dist/esm/plugins/block-type/ui/ToolbarBlockType/styled.js +8 -4
- package/dist/esm/plugins/block-type/utils.js +69 -1
- package/dist/esm/plugins/caption/pm-plugins/keymap.js +1 -1
- package/dist/esm/plugins/media/utils/media-common.js +1 -1
- package/dist/esm/plugins/tasks-and-decisions/pm-plugins/keymaps.js +1 -1
- package/dist/esm/plugins/undo-redo/pm-plugins/keymaps.js +1 -1
- package/dist/esm/ui/styles.js +3 -6
- package/dist/esm/utils/index.js +3 -77
- package/dist/esm/utils/input-rules.js +4 -61
- package/dist/esm/utils/mark.js +0 -35
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/commands/index.d.ts +0 -6
- package/dist/types/plugins/block-type/commands/block-type.d.ts +5 -6
- package/dist/types/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types/plugins/block-type/commands/delete-block-content.d.ts +1 -1
- package/dist/types/plugins/block-type/index.d.ts +1 -1
- package/dist/types/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
- package/dist/types/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
- package/dist/types/plugins/block-type/pm-plugins/main.d.ts +2 -1
- package/dist/types/plugins/block-type/styles.d.ts +1 -1
- package/dist/types/plugins/block-type/types.d.ts +2 -3
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
- package/dist/types/plugins/block-type/utils.d.ts +15 -1
- package/dist/types/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types/ui/styles.d.ts +0 -3
- package/dist/types/utils/index.d.ts +0 -6
- package/dist/types/utils/input-rules.d.ts +4 -16
- package/dist/types/utils/mark.d.ts +0 -1
- package/dist/types-ts4.5/commands/index.d.ts +0 -6
- package/dist/types-ts4.5/plugins/block-type/commands/block-type.d.ts +5 -6
- package/dist/types-ts4.5/plugins/block-type/commands/delete-and-move-cursor.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/commands/delete-block-content.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/index.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/input-rule.d.ts +3 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/keymap.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/pm-plugins/main.d.ts +2 -1
- package/dist/types-ts4.5/plugins/block-type/styles.d.ts +1 -1
- package/dist/types-ts4.5/plugins/block-type/types.d.ts +2 -3
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/blocktype-button.d.ts +1 -2
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/index.d.ts +2 -2
- package/dist/types-ts4.5/plugins/block-type/ui/ToolbarBlockType/styled.d.ts +5 -1
- package/dist/types-ts4.5/plugins/block-type/utils.d.ts +15 -1
- package/dist/types-ts4.5/plugins/undo-redo/pm-plugins/keymaps.d.ts +1 -1
- package/dist/types-ts4.5/types/index.d.ts +1 -1
- package/dist/types-ts4.5/ui/Appearance/FullPage/StyledComponents.d.ts +1 -1
- package/dist/types-ts4.5/ui/ContentStyles/index.d.ts +2 -2
- package/dist/types-ts4.5/ui/styles.d.ts +0 -3
- package/dist/types-ts4.5/utils/index.d.ts +0 -6
- package/dist/types-ts4.5/utils/input-rules.d.ts +4 -16
- package/dist/types-ts4.5/utils/mark.d.ts +0 -1
- package/package.json +4 -4
- package/report.api.md +6 -16
- package/tmp/api-report-tmp.d.ts +5 -16
- package/dist/cjs/types/allowed-block-types.js +0 -5
- package/dist/cjs/utils/keymap.js +0 -38
- package/dist/es2019/types/allowed-block-types.js +0 -1
- package/dist/es2019/utils/keymap.js +0 -33
- package/dist/esm/types/allowed-block-types.js +0 -1
- package/dist/esm/utils/keymap.js +0 -33
- package/dist/types/types/allowed-block-types.d.ts +0 -1
- package/dist/types/utils/keymap.d.ts +0 -11
- package/dist/types-ts4.5/types/allowed-block-types.d.ts +0 -1
- package/dist/types-ts4.5/utils/keymap.d.ts +0 -11
- /package/dist/cjs/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/es2019/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/esm/{keymaps → plugins/block-type}/consts.js +0 -0
- /package/dist/types/{keymaps → plugins/block-type}/consts.d.ts +0 -0
- /package/dist/types-ts4.5/{keymaps → plugins/block-type}/consts.d.ts +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
-
import { createJoinNodesRule, createWrappingTextBlockRule, ruleWithAnalytics } from '../../../utils/input-rules';
|
|
3
|
-
import { createRule, createPlugin } from '@atlaskit/prosemirror-input-rules';
|
|
4
|
-
import { leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
5
|
-
import { isConvertableToCodeBlock, transformToCodeBlockAction } from '../commands/transform-to-code-block';
|
|
6
|
-
import { insertBlock } from '../commands/insert-block';
|
|
7
2
|
import { safeInsert } from '@atlaskit/editor-prosemirror/utils';
|
|
3
|
+
import { createRule, createPlugin, leafNodeReplacementCharacter } from '@atlaskit/prosemirror-input-rules';
|
|
8
4
|
import { INPUT_METHOD, ACTION, ACTION_SUBJECT, EVENT_TYPE, ACTION_SUBJECT_ID } from '@atlaskit/editor-common/analytics';
|
|
5
|
+
import { inputRuleWithAnalytics } from '@atlaskit/editor-common/utils';
|
|
6
|
+
import { isConvertableToCodeBlock, transformToCodeBlockAction } from '../commands/transform-to-code-block';
|
|
7
|
+
import { insertBlock } from '../commands/insert-block';
|
|
8
|
+
import { createJoinNodesRule, createWrappingTextBlockRule } from '../utils';
|
|
9
9
|
var MAX_HEADING_LEVEL = 6;
|
|
10
10
|
function getHeadingLevel(match) {
|
|
11
11
|
return {
|
|
@@ -29,7 +29,7 @@ function blockQuoteRule(nodeType) {
|
|
|
29
29
|
* @param {Schema} schema
|
|
30
30
|
* @returns {InputRuleWithHandler[]}
|
|
31
31
|
*/
|
|
32
|
-
function getHeadingRules(schema) {
|
|
32
|
+
function getHeadingRules(editorAnalyticsAPI, schema) {
|
|
33
33
|
// '# ' for h1, '## ' for h2 and etc
|
|
34
34
|
var hashRule = headingRule(schema.nodes.heading, MAX_HEADING_LEVEL);
|
|
35
35
|
var leftNodeReplacementHashRule = createRule(new RegExp("".concat(leafNodeReplacementCharacter, "(#{1,6})\\s$")), function (state, match, start, end) {
|
|
@@ -40,7 +40,7 @@ function getHeadingRules(schema) {
|
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
// New analytics handler
|
|
43
|
-
var ruleWithHeadingAnalytics =
|
|
43
|
+
var ruleWithHeadingAnalytics = inputRuleWithAnalytics(function (_state, matchResult) {
|
|
44
44
|
return {
|
|
45
45
|
action: ACTION.FORMATTED,
|
|
46
46
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
@@ -51,7 +51,7 @@ function getHeadingRules(schema) {
|
|
|
51
51
|
newHeadingLevel: getHeadingLevel(matchResult).level
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
});
|
|
54
|
+
}, editorAnalyticsAPI);
|
|
55
55
|
return [ruleWithHeadingAnalytics(hashRule), ruleWithHeadingAnalytics(leftNodeReplacementHashRule)];
|
|
56
56
|
}
|
|
57
57
|
|
|
@@ -61,7 +61,7 @@ function getHeadingRules(schema) {
|
|
|
61
61
|
* @param {Schema} schema
|
|
62
62
|
* @returns {InputRuleWithHandler[]}
|
|
63
63
|
*/
|
|
64
|
-
function getBlockQuoteRules(schema) {
|
|
64
|
+
function getBlockQuoteRules(editorAnalyticsAPI, schema) {
|
|
65
65
|
// '> ' for blockquote
|
|
66
66
|
var greatherThanRule = blockQuoteRule(schema.nodes.blockquote);
|
|
67
67
|
var leftNodeReplacementGreatherRule = createRule(new RegExp("".concat(leafNodeReplacementCharacter, "\\s*>\\s$")), function (state, _match, start, end) {
|
|
@@ -69,7 +69,7 @@ function getBlockQuoteRules(schema) {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
// Analytics V3 handler
|
|
72
|
-
var ruleWithBlockQuoteAnalytics =
|
|
72
|
+
var ruleWithBlockQuoteAnalytics = inputRuleWithAnalytics({
|
|
73
73
|
action: ACTION.FORMATTED,
|
|
74
74
|
actionSubject: ACTION_SUBJECT.TEXT,
|
|
75
75
|
eventType: EVENT_TYPE.TRACK,
|
|
@@ -77,7 +77,7 @@ function getBlockQuoteRules(schema) {
|
|
|
77
77
|
attributes: {
|
|
78
78
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
79
79
|
}
|
|
80
|
-
});
|
|
80
|
+
}, editorAnalyticsAPI);
|
|
81
81
|
return [ruleWithBlockQuoteAnalytics(greatherThanRule), ruleWithBlockQuoteAnalytics(leftNodeReplacementGreatherRule)];
|
|
82
82
|
}
|
|
83
83
|
|
|
@@ -87,8 +87,8 @@ function getBlockQuoteRules(schema) {
|
|
|
87
87
|
* @param {Schema} schema
|
|
88
88
|
* @returns {InputRuleWithHandler[]}
|
|
89
89
|
*/
|
|
90
|
-
function getCodeBlockRules(schema) {
|
|
91
|
-
var ruleAnalytics =
|
|
90
|
+
function getCodeBlockRules(editorAnalyticsAPI, schema) {
|
|
91
|
+
var ruleAnalytics = inputRuleWithAnalytics({
|
|
92
92
|
action: ACTION.INSERTED,
|
|
93
93
|
actionSubject: ACTION_SUBJECT.DOCUMENT,
|
|
94
94
|
actionSubjectId: ACTION_SUBJECT_ID.CODE_BLOCK,
|
|
@@ -96,7 +96,7 @@ function getCodeBlockRules(schema) {
|
|
|
96
96
|
inputMethod: INPUT_METHOD.FORMATTING
|
|
97
97
|
},
|
|
98
98
|
eventType: EVENT_TYPE.TRACK
|
|
99
|
-
});
|
|
99
|
+
}, editorAnalyticsAPI);
|
|
100
100
|
var validMatchLength = function validMatchLength(match) {
|
|
101
101
|
return match.length > 0 && match[0].length === 3;
|
|
102
102
|
};
|
|
@@ -130,16 +130,16 @@ function getCodeBlockRules(schema) {
|
|
|
130
130
|
});
|
|
131
131
|
return [ruleAnalytics(threeTildeRule), ruleAnalytics(leftNodeReplacementThreeTildeRule)];
|
|
132
132
|
}
|
|
133
|
-
function inputRulePlugin(schema, featureFlags) {
|
|
133
|
+
function inputRulePlugin(editorAnalyticsAPI, schema, featureFlags) {
|
|
134
134
|
var rules = [];
|
|
135
135
|
if (schema.nodes.heading) {
|
|
136
|
-
rules.push.apply(rules, _toConsumableArray(getHeadingRules(schema)));
|
|
136
|
+
rules.push.apply(rules, _toConsumableArray(getHeadingRules(editorAnalyticsAPI, schema)));
|
|
137
137
|
}
|
|
138
138
|
if (schema.nodes.blockquote) {
|
|
139
|
-
rules.push.apply(rules, _toConsumableArray(getBlockQuoteRules(schema)));
|
|
139
|
+
rules.push.apply(rules, _toConsumableArray(getBlockQuoteRules(editorAnalyticsAPI, schema)));
|
|
140
140
|
}
|
|
141
141
|
if (schema.nodes.codeBlock) {
|
|
142
|
-
rules.push.apply(rules, _toConsumableArray(getCodeBlockRules(schema)));
|
|
142
|
+
rules.push.apply(rules, _toConsumableArray(getCodeBlockRules(editorAnalyticsAPI, schema)));
|
|
143
143
|
}
|
|
144
144
|
if (rules.length !== 0) {
|
|
145
145
|
return createPlugin('block-type', rules, {
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import { redo, undo } from '@atlaskit/editor-prosemirror/history';
|
|
2
2
|
import { chainCommands } from '@atlaskit/editor-prosemirror/commands';
|
|
3
|
-
import
|
|
4
|
-
import * as
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
4
|
+
import * as keymaps from '@atlaskit/editor-common/keymaps';
|
|
5
|
+
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
6
|
+
import { insertNewLineWithAnalytics, createNewParagraphAbove, createNewParagraphBelow, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
5
7
|
import * as blockTypes from '../types';
|
|
6
|
-
import { keymap } from '../../../utils/keymap';
|
|
7
8
|
import { cleanUpAtTheStartOfDocument, deleteAndMoveCursor, deleteBlockContent, insertBlockTypesWithAnalytics } from '../commands';
|
|
8
|
-
import { deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
9
|
-
import { INPUT_METHOD } from '../../analytics';
|
|
10
9
|
import { isNodeAWrappingBlockNode } from '../utils';
|
|
11
10
|
var backspace = chainCommands(cleanUpAtTheStartOfDocument, deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
12
11
|
var del = chainCommands(deleteEmptyParagraphAndMoveBlockUp(isNodeAWrappingBlockNode), deleteBlockContent(isNodeAWrappingBlockNode), deleteAndMoveCursor);
|
|
13
|
-
export default function keymapPlugin(
|
|
12
|
+
export default function keymapPlugin(editorAnalyticsApi, schema, _featureFlags) {
|
|
14
13
|
var list = {};
|
|
15
|
-
keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common,
|
|
16
|
-
keymaps.bindKeymapWithCommand(keymaps.moveUp.common,
|
|
17
|
-
keymaps.bindKeymapWithCommand(keymaps.moveDown.common,
|
|
14
|
+
keymaps.bindKeymapWithCommand(keymaps.insertNewLine.common, insertNewLineWithAnalytics(editorAnalyticsApi), list);
|
|
15
|
+
keymaps.bindKeymapWithCommand(keymaps.moveUp.common, createNewParagraphAbove, list);
|
|
16
|
+
keymaps.bindKeymapWithCommand(keymaps.moveDown.common, createNewParagraphBelow, list);
|
|
18
17
|
keymaps.bindKeymapWithCommand(keymaps.findKeyMapForBrowser(keymaps.redo), redo, list);
|
|
19
18
|
keymaps.bindKeymapWithCommand(keymaps.undo.common, undo, list);
|
|
20
19
|
keymaps.bindKeymapWithCommand(keymaps.backspace.common, backspace, list);
|
|
@@ -4,11 +4,11 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
5
5
|
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
6
6
|
import { browser } from '@atlaskit/editor-common/utils';
|
|
7
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
|
|
7
8
|
import { NORMAL_TEXT, HEADING_1, HEADING_2, HEADING_3, HEADING_4, HEADING_5, HEADING_6, BLOCK_QUOTE, CODE_BLOCK, PANEL, OTHER, TEXT_BLOCK_TYPES, WRAPPER_BLOCK_TYPES, HEADINGS_BY_LEVEL } from '../types';
|
|
8
|
-
import {
|
|
9
|
+
import { HEADING_KEYS } from '../consts';
|
|
9
10
|
import { setHeadingWithAnalytics, setNormalTextWithAnalytics } from '../commands';
|
|
10
|
-
import {
|
|
11
|
-
import { HEADING_KEYS } from '../../../keymaps/consts';
|
|
11
|
+
import { areBlockTypesDisabled } from '../utils';
|
|
12
12
|
var blockTypeForNode = function blockTypeForNode(node, schema) {
|
|
13
13
|
if (node.type === schema.nodes.heading) {
|
|
14
14
|
var maybeNode = HEADINGS_BY_LEVEL[node.attrs['level']];
|
|
@@ -63,16 +63,16 @@ var detectBlockType = function detectBlockType(availableBlockTypes, state) {
|
|
|
63
63
|
});
|
|
64
64
|
return blockType || OTHER;
|
|
65
65
|
};
|
|
66
|
-
var autoformatHeading = function autoformatHeading(headingLevel, view) {
|
|
66
|
+
var autoformatHeading = function autoformatHeading(headingLevel, view, editorAnalyticsApi) {
|
|
67
67
|
if (headingLevel === 0) {
|
|
68
|
-
setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING)(view.state, view.dispatch);
|
|
68
|
+
setNormalTextWithAnalytics(INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
|
|
69
69
|
} else {
|
|
70
|
-
setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING)(view.state, view.dispatch);
|
|
70
|
+
setHeadingWithAnalytics(headingLevel, INPUT_METHOD.FORMATTING, editorAnalyticsApi)(view.state, view.dispatch);
|
|
71
71
|
}
|
|
72
72
|
return true;
|
|
73
73
|
};
|
|
74
74
|
export var pluginKey = new PluginKey('blockTypePlugin');
|
|
75
|
-
export var createPlugin = function createPlugin(dispatch, lastNodeMustBeParagraph) {
|
|
75
|
+
export var createPlugin = function createPlugin(editorAnalyticsApi, dispatch, lastNodeMustBeParagraph) {
|
|
76
76
|
var altKeyLocation = 0;
|
|
77
77
|
return new SafePlugin({
|
|
78
78
|
appendTransaction: function appendTransaction(_transactions, _oldState, newState) {
|
|
@@ -123,9 +123,9 @@ export var createPlugin = function createPlugin(dispatch, lastNodeMustBeParagrap
|
|
|
123
123
|
var headingLevel = HEADING_KEYS.indexOf(event.keyCode);
|
|
124
124
|
if (headingLevel > -1 && event.altKey) {
|
|
125
125
|
if (browser.mac && event.metaKey) {
|
|
126
|
-
return autoformatHeading(headingLevel, view);
|
|
126
|
+
return autoformatHeading(headingLevel, view, editorAnalyticsApi);
|
|
127
127
|
} else if (!browser.mac && event.ctrlKey && altKeyLocation !== event.DOM_KEY_LOCATION_RIGHT) {
|
|
128
|
-
return autoformatHeading(headingLevel, view);
|
|
128
|
+
return autoformatHeading(headingLevel, view, editorAnalyticsApi);
|
|
129
129
|
}
|
|
130
130
|
} else if (event.key === 'Alt') {
|
|
131
131
|
// event.location is for the current key only; when a user hits Ctrl-Alt-1 the
|
|
@@ -4,10 +4,10 @@ import { jsx } from '@emotion/react';
|
|
|
4
4
|
import { FormattedMessage, defineMessages } from 'react-intl-next';
|
|
5
5
|
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
6
6
|
import TextStyleIcon from '@atlaskit/icon/glyph/editor/text-style';
|
|
7
|
-
import ToolbarButton from '../../../../ui/ToolbarButton';
|
|
8
|
-
import { buttonContentStyle, buttonContentReducedSpacingStyle, wrapperSmallStyle, expandIconWrapperStyle } from '../../../../ui/styles';
|
|
9
7
|
import { wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
8
|
+
import { ToolbarButton } from '@atlaskit/editor-common/ui-menu';
|
|
10
9
|
import { NORMAL_TEXT } from '../../types';
|
|
10
|
+
import { buttonContentStyle, buttonContentReducedSpacingStyle, wrapperSmallStyle, expandIconWrapperStyle } from './styled';
|
|
11
11
|
export var messages = defineMessages({
|
|
12
12
|
textStyles: {
|
|
13
13
|
id: 'fabric.editor.textStyles',
|
|
@@ -14,12 +14,11 @@ import React from 'react';
|
|
|
14
14
|
import { jsx } from '@emotion/react';
|
|
15
15
|
import { injectIntl } from 'react-intl-next';
|
|
16
16
|
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
|
17
|
-
import {
|
|
17
|
+
import { getAriaKeyshortcuts, tooltip, findKeymapByDescription } from '@atlaskit/editor-common/keymaps';
|
|
18
18
|
import { separatorStyles, wrapperStyle } from '@atlaskit/editor-common/styles';
|
|
19
|
+
import { DropdownMenuWithKeyboardNavigation as DropdownMenu } from '@atlaskit/editor-common/ui-menu';
|
|
19
20
|
import { blockTypeMenuItemStyle, keyboardShortcut, keyboardShortcutSelect } from './styled';
|
|
20
|
-
import { tooltip, findKeymapByDescription } from '../../../../keymaps';
|
|
21
21
|
import { BlockTypeButton } from './blocktype-button';
|
|
22
|
-
import { getAriaKeyshortcuts } from '@atlaskit/editor-common/keymaps';
|
|
23
22
|
var ToolbarBlockType = /*#__PURE__*/function (_React$PureComponent) {
|
|
24
23
|
_inherits(ToolbarBlockType, _React$PureComponent);
|
|
25
24
|
var _super = _createSuper(ToolbarBlockType);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { css } from '@emotion/react';
|
|
5
5
|
import { N400 } from '@atlaskit/theme/colors';
|
|
6
6
|
import { headingsSharedStyles } from '@atlaskit/editor-common/styles';
|
|
7
|
-
import { shortcutStyle } from '
|
|
7
|
+
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
8
8
|
export var blockTypeMenuItemStyle = function blockTypeMenuItemStyle(tagName, selected) {
|
|
9
9
|
// TEMP FIX: See https://product-fabric.atlassian.net/browse/ED-13878
|
|
10
10
|
var selectedStyle = selected ? "".concat(tagName, " { color: ", "var(--ds-text, white)", " !important; }") : '';
|
|
@@ -12,5 +12,9 @@ export var blockTypeMenuItemStyle = function blockTypeMenuItemStyle(tagName, sel
|
|
|
12
12
|
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ";\n > {\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n margin-top: 0;\n }\n }\n ", ";\n "])), headingsSharedStyles(themeProps), selectedStyle);
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
export var keyboardShortcut = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n margin-left:
|
|
16
|
-
export var keyboardShortcutSelect = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n"])), "var(--ds-icon, ".concat(N400, ")"));
|
|
15
|
+
export var keyboardShortcut = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n margin-left: ", ";\n"])), shortcutStyle, "var(--ds-space-200, 16px)");
|
|
16
|
+
export var keyboardShortcutSelect = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n"])), "var(--ds-icon, ".concat(N400, ")"));
|
|
17
|
+
export var buttonContentStyle = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n min-width: 80px;\n align-items: center;\n overflow: hidden;\n justify-content: center;\n flex-direction: column;\n padding: ", ";\n"])), "var(--ds-space-075, 6px)");
|
|
18
|
+
export var buttonContentReducedSpacingStyle = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n padding: ", ";\n"])), "var(--ds-space-100, 8px)");
|
|
19
|
+
export var wrapperSmallStyle = css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n margin-left: ", ";\n min-width: 40px;\n"])), "var(--ds-space-050, 4px)");
|
|
20
|
+
export var expandIconWrapperStyle = css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n margin-left: -8px;\n"])));
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { createRule } from '@atlaskit/prosemirror-input-rules';
|
|
2
|
+
import { createWrappingJoinRule } from '@atlaskit/editor-common/utils';
|
|
1
3
|
import { WRAPPER_BLOCK_TYPES } from './types';
|
|
2
4
|
export var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
|
|
3
5
|
if (!node) {
|
|
@@ -6,4 +8,70 @@ export var isNodeAWrappingBlockNode = function isNodeAWrappingBlockNode(node) {
|
|
|
6
8
|
return WRAPPER_BLOCK_TYPES.some(function (blockNode) {
|
|
7
9
|
return blockNode.name === node.type.name;
|
|
8
10
|
});
|
|
9
|
-
};
|
|
11
|
+
};
|
|
12
|
+
export var createJoinNodesRule = function createJoinNodesRule(match, nodeType) {
|
|
13
|
+
return createWrappingJoinRule({
|
|
14
|
+
nodeType: nodeType,
|
|
15
|
+
match: match,
|
|
16
|
+
getAttrs: {},
|
|
17
|
+
joinPredicate: function joinPredicate(_, node) {
|
|
18
|
+
return node.type === nodeType;
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
export var createWrappingTextBlockRule = function createWrappingTextBlockRule(_ref) {
|
|
23
|
+
var match = _ref.match,
|
|
24
|
+
nodeType = _ref.nodeType,
|
|
25
|
+
getAttrs = _ref.getAttrs;
|
|
26
|
+
var handler = function handler(state, match, start, end) {
|
|
27
|
+
var fixedStart = Math.max(start, 1);
|
|
28
|
+
var $start = state.doc.resolve(fixedStart);
|
|
29
|
+
var attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
30
|
+
var nodeBefore = $start.node(-1);
|
|
31
|
+
if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
|
|
35
|
+
};
|
|
36
|
+
return createRule(match, handler);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Function will create a list of wrapper blocks present in a selection.
|
|
41
|
+
*/
|
|
42
|
+
function getSelectedWrapperNodes(state) {
|
|
43
|
+
var nodes = [];
|
|
44
|
+
if (state.selection) {
|
|
45
|
+
var _state$selection = state.selection,
|
|
46
|
+
$from = _state$selection.$from,
|
|
47
|
+
$to = _state$selection.$to;
|
|
48
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
49
|
+
blockquote = _state$schema$nodes.blockquote,
|
|
50
|
+
panel = _state$schema$nodes.panel,
|
|
51
|
+
orderedList = _state$schema$nodes.orderedList,
|
|
52
|
+
bulletList = _state$schema$nodes.bulletList,
|
|
53
|
+
listItem = _state$schema$nodes.listItem,
|
|
54
|
+
codeBlock = _state$schema$nodes.codeBlock,
|
|
55
|
+
decisionItem = _state$schema$nodes.decisionItem,
|
|
56
|
+
decisionList = _state$schema$nodes.decisionList,
|
|
57
|
+
taskItem = _state$schema$nodes.taskItem,
|
|
58
|
+
taskList = _state$schema$nodes.taskList;
|
|
59
|
+
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
60
|
+
if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
|
|
61
|
+
nodes.push(node.type);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return nodes;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
70
|
+
*/
|
|
71
|
+
export function areBlockTypesDisabled(state) {
|
|
72
|
+
var nodesTypes = getSelectedWrapperNodes(state);
|
|
73
|
+
var panel = state.schema.nodes.panel;
|
|
74
|
+
return nodesTypes.filter(function (type) {
|
|
75
|
+
return type !== panel;
|
|
76
|
+
}).length > 0;
|
|
77
|
+
}
|
|
@@ -2,7 +2,7 @@ import { keymap } from '@atlaskit/editor-prosemirror/keymap';
|
|
|
2
2
|
import { Selection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import * as keymaps from '../../../keymaps';
|
|
4
4
|
import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
5
|
-
import { createNewParagraphBelow } from '
|
|
5
|
+
import { createNewParagraphBelow } from '@atlaskit/editor-common/utils';
|
|
6
6
|
import { GapCursorSelection } from '../../selection/gap-cursor/selection';
|
|
7
7
|
export function captionKeymap() {
|
|
8
8
|
var list = {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { deleteSelection, splitBlock } from '@atlaskit/editor-prosemirror/commands';
|
|
2
2
|
import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import { findPositionOfNodeBefore } from '@atlaskit/editor-prosemirror/utils';
|
|
4
|
-
import { createParagraphNear, createNewParagraphBelow } from '
|
|
4
|
+
import { createParagraphNear, createNewParagraphBelow } from '@atlaskit/editor-common/utils';
|
|
5
5
|
import { isTemporary } from '../../../utils';
|
|
6
6
|
import { mapSlice } from '../../../utils/slice';
|
|
7
7
|
import { walkUpTreeUntil, removeNestedEmptyEls, unwrap } from '../../../utils/dom';
|
|
@@ -7,7 +7,7 @@ import { Fragment, Slice } from '@atlaskit/editor-prosemirror/model';
|
|
|
7
7
|
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
8
8
|
import { findParentNodeOfType, findParentNodeOfTypeClosestToPos } from '@atlaskit/editor-prosemirror/utils';
|
|
9
9
|
import { uuid } from '@atlaskit/adf-schema';
|
|
10
|
-
import { filterCommand as filter, isEmptySelectionAtStart,
|
|
10
|
+
import { filterCommand as filter, isEmptySelectionAtStart, isEmptySelectionAtEnd, deleteEmptyParagraphAndMoveBlockUp } from '@atlaskit/editor-common/utils';
|
|
11
11
|
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE, INDENT_DIRECTION, INDENT_TYPE, INPUT_METHOD, withAnalytics } from '../../analytics';
|
|
12
12
|
import { insertTaskDecisionWithAnalytics } from '../commands';
|
|
13
13
|
import { joinAtCut, liftSelection, wrapSelectionInTaskList } from './commands';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as keymaps from '../../../keymaps';
|
|
2
|
-
import { keymap } from '
|
|
2
|
+
import { keymap } from '@atlaskit/editor-common/keymaps';
|
|
3
3
|
import { redoFromKeyboard, undoFromKeyboard } from '../commands';
|
|
4
4
|
export function keymapPlugin() {
|
|
5
5
|
var list = {};
|
package/dist/esm/ui/styles.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2
|
|
2
|
+
var _templateObject, _templateObject2;
|
|
3
3
|
import { css } from '@emotion/react';
|
|
4
4
|
export { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
|
|
5
5
|
export { scrollbarStyles } from '@atlaskit/editor-shared-styles/scrollbar';
|
|
6
|
-
export var
|
|
7
|
-
export var
|
|
8
|
-
export var buttonContentStyle = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n min-width: 80px;\n align-items: center;\n overflow: hidden;\n justify-content: center;\n flex-direction: column;\n padding: ", ";\n"])), "var(--ds-space-075, 6px)");
|
|
9
|
-
export var buttonContentReducedSpacingStyle = css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: ", ";\n"])), "var(--ds-space-100, 8px)");
|
|
10
|
-
export var clickSelectWrapperStyle = css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n user-select: all;\n"])));
|
|
6
|
+
export var expandIconWrapperStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n margin-left: -8px;\n"])));
|
|
7
|
+
export var clickSelectWrapperStyle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n user-select: all;\n"])));
|
package/dist/esm/utils/index.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { toggleMark } from '@atlaskit/editor-prosemirror/commands';
|
|
2
|
-
import { NodeSelection, TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
3
2
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
4
3
|
import { FakeTextCursorSelection } from '../plugins/fake-text-cursor/cursor';
|
|
5
4
|
import { hasParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
|
|
6
5
|
import { isNodeEmpty } from './document';
|
|
7
|
-
import { atTheBeginningOfDoc, atTheEndOfDoc } from './prosemirror/position';
|
|
8
|
-
import { isMediaNode } from '@atlaskit/editor-common/utils';
|
|
9
6
|
export { insideTable } from '@atlaskit/editor-common/core-utils';
|
|
10
7
|
export { isNodeEmpty, findFarthestParentNode, isSelectionEndOfParagraph, nodesBetweenChanged, getNodesCount } from './document';
|
|
11
8
|
export { sanitiseMarksInSelection } from './mark';
|
|
@@ -18,37 +15,6 @@ function isMarkTypeCompatibleWithMark(markType, mark) {
|
|
|
18
15
|
function isMarkTypeAllowedInNode(markType, state) {
|
|
19
16
|
return toggleMark(markType)(state);
|
|
20
17
|
}
|
|
21
|
-
export function canMoveUp(state) {
|
|
22
|
-
var selection = state.selection;
|
|
23
|
-
/**
|
|
24
|
-
* If there's a media element on the selection it will use a gap cursor to move
|
|
25
|
-
*/
|
|
26
|
-
if (selection instanceof NodeSelection && isMediaNode(selection.node)) {
|
|
27
|
-
return true;
|
|
28
|
-
}
|
|
29
|
-
if (selection instanceof TextSelection) {
|
|
30
|
-
if (!selection.empty) {
|
|
31
|
-
return true;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return !atTheBeginningOfDoc(state);
|
|
35
|
-
}
|
|
36
|
-
export function canMoveDown(state) {
|
|
37
|
-
var selection = state.selection;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* If there's a media element on the selection it will use a gap cursor to move
|
|
41
|
-
*/
|
|
42
|
-
if (selection instanceof NodeSelection && isMediaNode(selection.node)) {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
if (selection instanceof TextSelection) {
|
|
46
|
-
if (!selection.empty) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return !atTheEndOfDoc(state);
|
|
51
|
-
}
|
|
52
18
|
export function isSelectionInsideLastNodeInDocument(selection) {
|
|
53
19
|
var docNode = selection.$anchor.node(0);
|
|
54
20
|
var rootNode = selection.$anchor.node(1);
|
|
@@ -173,46 +139,6 @@ export function whichTransitionEvent() {
|
|
|
173
139
|
}
|
|
174
140
|
return;
|
|
175
141
|
}
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* Function will create a list of wrapper blocks present in a selection.
|
|
179
|
-
*/
|
|
180
|
-
function getSelectedWrapperNodes(state) {
|
|
181
|
-
var nodes = [];
|
|
182
|
-
if (state.selection) {
|
|
183
|
-
var _state$selection = state.selection,
|
|
184
|
-
$from = _state$selection.$from,
|
|
185
|
-
$to = _state$selection.$to;
|
|
186
|
-
var _state$schema$nodes = state.schema.nodes,
|
|
187
|
-
blockquote = _state$schema$nodes.blockquote,
|
|
188
|
-
panel = _state$schema$nodes.panel,
|
|
189
|
-
orderedList = _state$schema$nodes.orderedList,
|
|
190
|
-
bulletList = _state$schema$nodes.bulletList,
|
|
191
|
-
listItem = _state$schema$nodes.listItem,
|
|
192
|
-
codeBlock = _state$schema$nodes.codeBlock,
|
|
193
|
-
decisionItem = _state$schema$nodes.decisionItem,
|
|
194
|
-
decisionList = _state$schema$nodes.decisionList,
|
|
195
|
-
taskItem = _state$schema$nodes.taskItem,
|
|
196
|
-
taskList = _state$schema$nodes.taskList;
|
|
197
|
-
state.doc.nodesBetween($from.pos, $to.pos, function (node) {
|
|
198
|
-
if (node.isBlock && [blockquote, panel, orderedList, bulletList, listItem, codeBlock, decisionItem, decisionList, taskItem, taskList].indexOf(node.type) >= 0) {
|
|
199
|
-
nodes.push(node.type);
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
return nodes;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
/**
|
|
207
|
-
* Function will check if changing block types: Paragraph, Heading is enabled.
|
|
208
|
-
*/
|
|
209
|
-
export function areBlockTypesDisabled(state) {
|
|
210
|
-
var nodesTypes = getSelectedWrapperNodes(state);
|
|
211
|
-
var panel = state.schema.nodes.panel;
|
|
212
|
-
return nodesTypes.filter(function (type) {
|
|
213
|
-
return type !== panel;
|
|
214
|
-
}).length > 0;
|
|
215
|
-
}
|
|
216
142
|
export var isTemporary = function isTemporary(id) {
|
|
217
143
|
return id.indexOf('temporary:') === 0;
|
|
218
144
|
};
|
|
@@ -269,9 +195,9 @@ export var isEmptyNode = function isEmptyNode(schema) {
|
|
|
269
195
|
return innerIsEmptyNode;
|
|
270
196
|
};
|
|
271
197
|
export var insideTableCell = function insideTableCell(state) {
|
|
272
|
-
var _state$schema$
|
|
273
|
-
tableCell = _state$schema$
|
|
274
|
-
tableHeader = _state$schema$
|
|
198
|
+
var _state$schema$nodes = state.schema.nodes,
|
|
199
|
+
tableCell = _state$schema$nodes.tableCell,
|
|
200
|
+
tableHeader = _state$schema$nodes.tableHeader;
|
|
275
201
|
return hasParentNodeOfType([tableCell, tableHeader])(state.selection);
|
|
276
202
|
};
|
|
277
203
|
export var isInListItem = function isInListItem(state) {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
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
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 { canJoin, findWrapping } from '@atlaskit/editor-prosemirror/transform';
|
|
5
|
-
import { createRule } from '@atlaskit/prosemirror-input-rules';
|
|
6
4
|
import { addAnalytics } from '../plugins/analytics';
|
|
7
|
-
|
|
5
|
+
/**
|
|
6
|
+
* @private
|
|
7
|
+
* @deprecated Use import {inputRuleWithAnalytics} from "@atlaskit/editor-common/utils"; instead
|
|
8
|
+
*/
|
|
8
9
|
export var ruleWithAnalytics = function ruleWithAnalytics(getPayload) {
|
|
9
10
|
return function (originalRule) {
|
|
10
11
|
var onHandlerApply = function onHandlerApply(state, tr, matchResult) {
|
|
@@ -18,62 +19,4 @@ export var ruleWithAnalytics = function ruleWithAnalytics(getPayload) {
|
|
|
18
19
|
onHandlerApply: onHandlerApply
|
|
19
20
|
});
|
|
20
21
|
};
|
|
21
|
-
};
|
|
22
|
-
export var createWrappingTextBlockRule = function createWrappingTextBlockRule(_ref) {
|
|
23
|
-
var match = _ref.match,
|
|
24
|
-
nodeType = _ref.nodeType,
|
|
25
|
-
getAttrs = _ref.getAttrs;
|
|
26
|
-
var handler = function handler(state, match, start, end) {
|
|
27
|
-
var fixedStart = Math.max(start, 1);
|
|
28
|
-
var $start = state.doc.resolve(fixedStart);
|
|
29
|
-
var attrs = getAttrs instanceof Function ? getAttrs(match) : getAttrs;
|
|
30
|
-
var nodeBefore = $start.node(-1);
|
|
31
|
-
if (nodeBefore && !nodeBefore.canReplaceWith($start.index(-1), $start.indexAfter(-1), nodeType)) {
|
|
32
|
-
return null;
|
|
33
|
-
}
|
|
34
|
-
return state.tr.delete(fixedStart, end).setBlockType(fixedStart, fixedStart, nodeType, attrs);
|
|
35
|
-
};
|
|
36
|
-
return createRule(match, handler);
|
|
37
|
-
};
|
|
38
|
-
export var createWrappingJoinRule = function createWrappingJoinRule(_ref2) {
|
|
39
|
-
var match = _ref2.match,
|
|
40
|
-
nodeType = _ref2.nodeType,
|
|
41
|
-
getAttrs = _ref2.getAttrs,
|
|
42
|
-
joinPredicate = _ref2.joinPredicate;
|
|
43
|
-
var handler = function handler(state, match, start, end) {
|
|
44
|
-
var attrs = (getAttrs instanceof Function ? getAttrs(match) : getAttrs) || {};
|
|
45
|
-
var tr = state.tr;
|
|
46
|
-
var fixedStart = Math.max(start, 1);
|
|
47
|
-
tr.delete(fixedStart, end);
|
|
48
|
-
var $start = tr.doc.resolve(fixedStart);
|
|
49
|
-
var range = $start.blockRange();
|
|
50
|
-
var wrapping = range && findWrapping(range, nodeType, attrs);
|
|
51
|
-
if (!wrapping || !range) {
|
|
52
|
-
return null;
|
|
53
|
-
}
|
|
54
|
-
var parentNodePosMapped = tr.mapping.map(range.start);
|
|
55
|
-
var parentNode = tr.doc.nodeAt(parentNodePosMapped);
|
|
56
|
-
var lastWrap = wrapping[wrapping.length - 1];
|
|
57
|
-
if (parentNode && lastWrap) {
|
|
58
|
-
var allowedMarks = lastWrap.type.allowedMarks(parentNode.marks) || [];
|
|
59
|
-
tr.setNodeMarkup(parentNodePosMapped, parentNode.type, parentNode.attrs, allowedMarks);
|
|
60
|
-
}
|
|
61
|
-
tr.wrap(range, wrapping);
|
|
62
|
-
var before = tr.doc.resolve(fixedStart - 1).nodeBefore;
|
|
63
|
-
if (before && before.type === nodeType && canJoin(tr.doc, fixedStart - 1) && (!joinPredicate || joinPredicate(match, before, JOIN_SCENARIOS_WHEN_TYPING_TO_INSERT_LIST.JOINED_TO_LIST_ABOVE))) {
|
|
64
|
-
tr.join(fixedStart - 1);
|
|
65
|
-
}
|
|
66
|
-
return tr;
|
|
67
|
-
};
|
|
68
|
-
return createRule(match, handler);
|
|
69
|
-
};
|
|
70
|
-
export var createJoinNodesRule = function createJoinNodesRule(match, nodeType) {
|
|
71
|
-
return createWrappingJoinRule({
|
|
72
|
-
nodeType: nodeType,
|
|
73
|
-
match: match,
|
|
74
|
-
getAttrs: {},
|
|
75
|
-
joinPredicate: function joinPredicate(_, node) {
|
|
76
|
-
return node.type === nodeType;
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
22
|
};
|
package/dist/esm/utils/mark.js
CHANGED
|
@@ -32,41 +32,6 @@ export var isMarkExcluded = function isMarkExcluded(type, marks) {
|
|
|
32
32
|
}
|
|
33
33
|
return false;
|
|
34
34
|
};
|
|
35
|
-
var not = function not(fn) {
|
|
36
|
-
return function (arg) {
|
|
37
|
-
return !fn(arg);
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
export var removeBlockMarks = function removeBlockMarks(state, marks) {
|
|
41
|
-
var selection = state.selection,
|
|
42
|
-
schema = state.schema;
|
|
43
|
-
var tr = state.tr;
|
|
44
|
-
|
|
45
|
-
// Marks might not exist in Schema
|
|
46
|
-
var marksToRemove = marks.filter(Boolean);
|
|
47
|
-
if (marksToRemove.length === 0) {
|
|
48
|
-
return undefined;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/** Saves an extra dispatch */
|
|
52
|
-
var blockMarksExists = false;
|
|
53
|
-
var hasMark = function hasMark(mark) {
|
|
54
|
-
return marksToRemove.indexOf(mark.type) > -1;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* When you need to toggle the selection
|
|
58
|
-
* when another type which does not allow alignment is applied
|
|
59
|
-
*/
|
|
60
|
-
state.doc.nodesBetween(selection.from, selection.to, function (node, pos) {
|
|
61
|
-
if (node.type === schema.nodes.paragraph && node.marks.some(hasMark)) {
|
|
62
|
-
blockMarksExists = true;
|
|
63
|
-
var resolvedPos = state.doc.resolve(pos);
|
|
64
|
-
var withoutBlockMarks = node.marks.filter(not(hasMark));
|
|
65
|
-
tr = tr.setNodeMarkup(resolvedPos.pos, undefined, node.attrs, withoutBlockMarks);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return blockMarksExists ? tr : undefined;
|
|
69
|
-
};
|
|
70
35
|
|
|
71
36
|
/**
|
|
72
37
|
* Removes marks from nodes in the current selection that are not supported
|
package/dist/esm/version.json
CHANGED
|
@@ -2,12 +2,6 @@ import type { MarkType, NodeType, Node as PMNode, Schema } from '@atlaskit/edito
|
|
|
2
2
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
3
|
import type { AlignmentState } from '../plugins/alignment/pm-plugins/types';
|
|
4
4
|
import type { Command } from '../types';
|
|
5
|
-
export declare function preventDefault(): Command;
|
|
6
|
-
export declare function insertNewLine(): Command;
|
|
7
|
-
export declare const insertNewLineWithAnalytics: Command;
|
|
8
|
-
export declare const createNewParagraphAbove: Command;
|
|
9
|
-
export declare const createNewParagraphBelow: Command;
|
|
10
|
-
export declare function createParagraphNear(append?: boolean): Command;
|
|
11
5
|
export declare function addParagraphAtEnd(tr: Transaction): void;
|
|
12
6
|
export declare function createParagraphAtEnd(): Command;
|
|
13
7
|
export declare const changeImageAlignment: (align?: AlignmentState) => Command;
|