@atlaskit/editor-core 189.0.9 → 189.0.11
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 +13 -0
- package/dist/cjs/plugins/index.js +0 -7
- package/dist/cjs/plugins/tasks-and-decisions/index.js +15 -5
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -5
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +40 -0
- package/dist/cjs/plugins/tasks-and-decisions/nodeviews/taskItem.js +31 -31
- package/dist/cjs/presets/universal.js +2 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/plugins/index.js +0 -1
- package/dist/es2019/plugins/tasks-and-decisions/index.js +11 -1
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -6
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +36 -0
- package/dist/es2019/plugins/tasks-and-decisions/nodeviews/taskItem.js +29 -30
- package/dist/es2019/presets/universal.js +2 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/plugins/index.js +0 -1
- package/dist/esm/plugins/tasks-and-decisions/index.js +11 -1
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/decisionItem.js +16 -5
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.js +34 -0
- package/dist/esm/plugins/tasks-and-decisions/nodeviews/taskItem.js +31 -32
- package/dist/esm/presets/universal.js +2 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/plugins/index.d.ts +0 -1
- package/dist/types/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +11 -0
- package/dist/types/plugins/tasks-and-decisions/types.d.ts +4 -0
- package/dist/types/types/editor-props.d.ts +1 -1
- package/dist/types-ts4.5/plugins/index.d.ts +0 -1
- package/dist/types-ts4.5/plugins/tasks-and-decisions/nodeviews/hooks/use-show-placeholder.d.ts +11 -0
- package/dist/types-ts4.5/plugins/tasks-and-decisions/types.d.ts +4 -0
- package/dist/types-ts4.5/types/editor-props.d.ts +1 -1
- package/package.json +3 -2
- package/report.api.md +1 -12
- package/tmp/api-report-tmp.d.ts +1 -12
- package/dist/cjs/plugins/text-color/commands/change-color.js +0 -61
- package/dist/cjs/plugins/text-color/commands/remove-color.js +0 -59
- package/dist/cjs/plugins/text-color/commands/toggle-color.js +0 -36
- package/dist/cjs/plugins/text-color/index.js +0 -75
- package/dist/cjs/plugins/text-color/pm-plugins/main.js +0 -88
- package/dist/cjs/plugins/text-color/types.js +0 -5
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -29
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/index.js +0 -285
- package/dist/cjs/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -38
- package/dist/cjs/plugins/text-color/utils/color.js +0 -54
- package/dist/cjs/plugins/text-color/utils/disabled.js +0 -32
- package/dist/es2019/plugins/text-color/commands/change-color.js +0 -54
- package/dist/es2019/plugins/text-color/commands/remove-color.js +0 -57
- package/dist/es2019/plugins/text-color/commands/toggle-color.js +0 -30
- package/dist/es2019/plugins/text-color/index.js +0 -63
- package/dist/es2019/plugins/text-color/pm-plugins/main.js +0 -75
- package/dist/es2019/plugins/text-color/types.js +0 -1
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -20
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/index.js +0 -265
- package/dist/es2019/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -48
- package/dist/es2019/plugins/text-color/utils/color.js +0 -48
- package/dist/es2019/plugins/text-color/utils/disabled.js +0 -39
- package/dist/esm/plugins/text-color/commands/change-color.js +0 -56
- package/dist/esm/plugins/text-color/commands/remove-color.js +0 -53
- package/dist/esm/plugins/text-color/commands/toggle-color.js +0 -30
- package/dist/esm/plugins/text-color/index.js +0 -63
- package/dist/esm/plugins/text-color/pm-plugins/main.js +0 -75
- package/dist/esm/plugins/text-color/types.js +0 -1
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/icon.js +0 -22
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/index.js +0 -282
- package/dist/esm/plugins/text-color/ui/ToolbarTextColor/styles.js +0 -28
- package/dist/esm/plugins/text-color/utils/color.js +0 -48
- package/dist/esm/plugins/text-color/utils/disabled.js +0 -26
- package/dist/types/plugins/text-color/commands/change-color.d.ts +0 -3
- package/dist/types/plugins/text-color/commands/remove-color.d.ts +0 -2
- package/dist/types/plugins/text-color/commands/toggle-color.d.ts +0 -2
- package/dist/types/plugins/text-color/index.d.ts +0 -7
- package/dist/types/plugins/text-color/pm-plugins/main.d.ts +0 -25
- package/dist/types/plugins/text-color/types.d.ts +0 -10
- package/dist/types/plugins/text-color/ui/ToolbarTextColor/icon.d.ts +0 -2
- package/dist/types/plugins/text-color/ui/ToolbarTextColor/index.d.ts +0 -53
- package/dist/types/plugins/text-color/ui/ToolbarTextColor/styles.d.ts +0 -3
- package/dist/types/plugins/text-color/utils/color.d.ts +0 -6
- package/dist/types/plugins/text-color/utils/disabled.d.ts +0 -2
- package/dist/types-ts4.5/plugins/text-color/commands/change-color.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-color/commands/remove-color.d.ts +0 -2
- package/dist/types-ts4.5/plugins/text-color/commands/toggle-color.d.ts +0 -2
- package/dist/types-ts4.5/plugins/text-color/index.d.ts +0 -7
- package/dist/types-ts4.5/plugins/text-color/pm-plugins/main.d.ts +0 -25
- package/dist/types-ts4.5/plugins/text-color/types.d.ts +0 -12
- package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/icon.d.ts +0 -2
- package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/index.d.ts +0 -53
- package/dist/types-ts4.5/plugins/text-color/ui/ToolbarTextColor/styles.d.ts +0 -3
- package/dist/types-ts4.5/plugins/text-color/utils/color.d.ts +0 -6
- package/dist/types-ts4.5/plugins/text-color/utils/disabled.d.ts +0 -2
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { TextSelection } from '@atlaskit/editor-prosemirror/state';
|
|
2
|
-
import { CellSelection } from '@atlaskit/editor-tables/cell-selection';
|
|
3
|
-
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
4
|
-
export var removeColor = function removeColor() {
|
|
5
|
-
return function (state, dispatch) {
|
|
6
|
-
var schema = state.schema,
|
|
7
|
-
selection = state.selection;
|
|
8
|
-
var textColor = schema.marks.textColor;
|
|
9
|
-
var tr = state.tr;
|
|
10
|
-
if (selection instanceof TextSelection) {
|
|
11
|
-
var from = selection.from,
|
|
12
|
-
to = selection.to,
|
|
13
|
-
$cursor = selection.$cursor;
|
|
14
|
-
if ($cursor) {
|
|
15
|
-
tr = state.tr.removeStoredMark(textColor);
|
|
16
|
-
} else {
|
|
17
|
-
tr = state.tr.removeMark(from, to, textColor);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
if (selection instanceof CellSelection) {
|
|
21
|
-
/**
|
|
22
|
-
* This is a slight abstraction from `src/utils/commands.ts`
|
|
23
|
-
* The main difference is we can't toggle the default from another (since they are different marks),
|
|
24
|
-
* we want to remove all text color marks on the selection, so we slightly modify the cell selection
|
|
25
|
-
* part here.
|
|
26
|
-
*/
|
|
27
|
-
selection.forEachCell(function (cell, cellPos) {
|
|
28
|
-
var from = cellPos;
|
|
29
|
-
var to = cellPos + cell.nodeSize;
|
|
30
|
-
tr.doc.nodesBetween(tr.mapping.map(from), tr.mapping.map(to), function (node, pos) {
|
|
31
|
-
if (!node.isText) {
|
|
32
|
-
return true;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// This is an issue when the user selects some text.
|
|
36
|
-
// We need to check if the current node position is less than the range selection from.
|
|
37
|
-
// If it’s true, that means we should apply the mark using the range selection,
|
|
38
|
-
// not the current node position.
|
|
39
|
-
var nodeBetweenFrom = Math.max(pos, tr.mapping.map(from));
|
|
40
|
-
var nodeBetweenTo = Math.min(pos + node.nodeSize, tr.mapping.map(to));
|
|
41
|
-
tr.removeMark(nodeBetweenFrom, nodeBetweenTo, textColor);
|
|
42
|
-
return true;
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
if (dispatch) {
|
|
47
|
-
dispatch(tr.setMeta(pluginKey, {
|
|
48
|
-
action: ACTIONS.RESET_COLOR
|
|
49
|
-
}));
|
|
50
|
-
}
|
|
51
|
-
return true;
|
|
52
|
-
};
|
|
53
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { toggleMark } from '@atlaskit/editor-common/mark';
|
|
2
|
-
import { editorCommandToPMCommand } from '@atlaskit/editor-common/preset';
|
|
3
|
-
import { ACTIONS, pluginKey } from '../pm-plugins/main';
|
|
4
|
-
import { getDisabledState } from '../utils/disabled';
|
|
5
|
-
export var toggleColor = function toggleColor(color) {
|
|
6
|
-
return function (state, dispatch) {
|
|
7
|
-
var textColor = state.schema.marks.textColor;
|
|
8
|
-
var tr = state.tr;
|
|
9
|
-
var disabledState = getDisabledState(state);
|
|
10
|
-
if (disabledState) {
|
|
11
|
-
if (dispatch) {
|
|
12
|
-
dispatch(tr.setMeta(pluginKey, {
|
|
13
|
-
action: ACTIONS.DISABLE
|
|
14
|
-
}));
|
|
15
|
-
}
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
if (dispatch) {
|
|
19
|
-
state.tr.setMeta(pluginKey, {
|
|
20
|
-
action: ACTIONS.SET_COLOR,
|
|
21
|
-
color: color
|
|
22
|
-
});
|
|
23
|
-
state.tr.scrollIntoView();
|
|
24
|
-
editorCommandToPMCommand(toggleMark(textColor, {
|
|
25
|
-
color: color
|
|
26
|
-
}))(state, dispatch);
|
|
27
|
-
}
|
|
28
|
-
return true;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { textColor } from '@atlaskit/adf-schema';
|
|
3
|
-
import { WithPluginState } from '@atlaskit/editor-common/with-plugin-state';
|
|
4
|
-
import { createPlugin, pluginKey as textColorPluginKey } from './pm-plugins/main';
|
|
5
|
-
import ToolbarTextColor from './ui/ToolbarTextColor';
|
|
6
|
-
var pluginConfig = function pluginConfig(textColorConfig) {
|
|
7
|
-
if (!textColorConfig || typeof textColorConfig === 'boolean') {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
return textColorConfig;
|
|
11
|
-
};
|
|
12
|
-
var textColorPlugin = function textColorPlugin(_ref) {
|
|
13
|
-
var textColorConfig = _ref.config,
|
|
14
|
-
api = _ref.api;
|
|
15
|
-
return {
|
|
16
|
-
name: 'textColor',
|
|
17
|
-
marks: function marks() {
|
|
18
|
-
return [{
|
|
19
|
-
name: 'textColor',
|
|
20
|
-
mark: textColor
|
|
21
|
-
}];
|
|
22
|
-
},
|
|
23
|
-
pmPlugins: function pmPlugins() {
|
|
24
|
-
return [{
|
|
25
|
-
name: 'textColor',
|
|
26
|
-
plugin: function plugin(_ref2) {
|
|
27
|
-
var dispatch = _ref2.dispatch;
|
|
28
|
-
return createPlugin(dispatch, pluginConfig(textColorConfig));
|
|
29
|
-
}
|
|
30
|
-
}];
|
|
31
|
-
},
|
|
32
|
-
primaryToolbarComponent: function primaryToolbarComponent(_ref3) {
|
|
33
|
-
var editorView = _ref3.editorView,
|
|
34
|
-
popupsMountPoint = _ref3.popupsMountPoint,
|
|
35
|
-
popupsBoundariesElement = _ref3.popupsBoundariesElement,
|
|
36
|
-
popupsScrollableElement = _ref3.popupsScrollableElement,
|
|
37
|
-
isToolbarReducedSpacing = _ref3.isToolbarReducedSpacing,
|
|
38
|
-
dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent,
|
|
39
|
-
disabled = _ref3.disabled;
|
|
40
|
-
return /*#__PURE__*/React.createElement(WithPluginState, {
|
|
41
|
-
plugins: {
|
|
42
|
-
textColor: textColorPluginKey
|
|
43
|
-
},
|
|
44
|
-
render: function render(_ref4) {
|
|
45
|
-
var textColor = _ref4.textColor;
|
|
46
|
-
return /*#__PURE__*/React.createElement(ToolbarTextColor, {
|
|
47
|
-
pluginState: textColor,
|
|
48
|
-
isReducedSpacing: isToolbarReducedSpacing,
|
|
49
|
-
editorView: editorView,
|
|
50
|
-
popupsMountPoint: popupsMountPoint,
|
|
51
|
-
popupsBoundariesElement: popupsBoundariesElement,
|
|
52
|
-
popupsScrollableElement: popupsScrollableElement,
|
|
53
|
-
dispatchAnalyticsEvent: dispatchAnalyticsEvent,
|
|
54
|
-
disabled: disabled,
|
|
55
|
-
pluginInjectionApi: api
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
export { textColorPluginKey };
|
|
63
|
-
export default textColorPlugin;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
|
|
6
|
-
import { PluginKey } from '@atlaskit/editor-prosemirror/state';
|
|
7
|
-
import { textColorPalette } from '@atlaskit/editor-common/ui-color';
|
|
8
|
-
import { DEFAULT_BORDER_COLOR } from '@atlaskit/editor-common/ui-color';
|
|
9
|
-
import { DEFAULT_COLOR, getActiveColor } from '../utils/color';
|
|
10
|
-
import { getDisabledState } from '../utils/disabled';
|
|
11
|
-
export { DEFAULT_COLOR } from '../utils/color';
|
|
12
|
-
function createInitialPluginState(editorState, pluginConfig) {
|
|
13
|
-
var defaultColor = (pluginConfig === null || pluginConfig === void 0 ? void 0 : pluginConfig.defaultColor) || DEFAULT_COLOR;
|
|
14
|
-
var palette = [{
|
|
15
|
-
value: defaultColor.color,
|
|
16
|
-
label: defaultColor.label,
|
|
17
|
-
border: DEFAULT_BORDER_COLOR
|
|
18
|
-
}].concat(_toConsumableArray(textColorPalette));
|
|
19
|
-
var state = {
|
|
20
|
-
color: getActiveColor(editorState),
|
|
21
|
-
disabled: getDisabledState(editorState),
|
|
22
|
-
palette: palette,
|
|
23
|
-
defaultColor: defaultColor.color
|
|
24
|
-
};
|
|
25
|
-
return state;
|
|
26
|
-
}
|
|
27
|
-
export var ACTIONS = /*#__PURE__*/function (ACTIONS) {
|
|
28
|
-
ACTIONS[ACTIONS["RESET_COLOR"] = 0] = "RESET_COLOR";
|
|
29
|
-
ACTIONS[ACTIONS["SET_COLOR"] = 1] = "SET_COLOR";
|
|
30
|
-
ACTIONS[ACTIONS["DISABLE"] = 2] = "DISABLE";
|
|
31
|
-
return ACTIONS;
|
|
32
|
-
}({});
|
|
33
|
-
export var pluginKey = new PluginKey('textColorPlugin');
|
|
34
|
-
export function createPlugin(dispatch, pluginConfig) {
|
|
35
|
-
return new SafePlugin({
|
|
36
|
-
key: pluginKey,
|
|
37
|
-
state: {
|
|
38
|
-
init: function init(_config, editorState) {
|
|
39
|
-
return createInitialPluginState(editorState, pluginConfig);
|
|
40
|
-
},
|
|
41
|
-
apply: function apply(tr, pluginState, _, newState) {
|
|
42
|
-
var meta = tr.getMeta(pluginKey) || {};
|
|
43
|
-
var nextState;
|
|
44
|
-
switch (meta.action) {
|
|
45
|
-
case ACTIONS.RESET_COLOR:
|
|
46
|
-
nextState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
47
|
-
color: pluginState.defaultColor
|
|
48
|
-
});
|
|
49
|
-
break;
|
|
50
|
-
case ACTIONS.SET_COLOR:
|
|
51
|
-
nextState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
52
|
-
color: meta.color,
|
|
53
|
-
disabled: false
|
|
54
|
-
});
|
|
55
|
-
break;
|
|
56
|
-
case ACTIONS.DISABLE:
|
|
57
|
-
nextState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
58
|
-
disabled: true
|
|
59
|
-
});
|
|
60
|
-
break;
|
|
61
|
-
default:
|
|
62
|
-
nextState = _objectSpread(_objectSpread({}, pluginState), {}, {
|
|
63
|
-
color: getActiveColor(newState),
|
|
64
|
-
disabled: getDisabledState(newState)
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
if (pluginState && pluginState.color !== nextState.color || pluginState && pluginState.disabled !== nextState.disabled) {
|
|
68
|
-
dispatch(pluginKey, nextState);
|
|
69
|
-
return nextState;
|
|
70
|
-
}
|
|
71
|
-
return pluginState;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
5
|
-
import Icon from '@atlaskit/icon/base';
|
|
6
|
-
var textColorGlyph = function textColorGlyph(props) {
|
|
7
|
-
return /*#__PURE__*/React.createElement("svg", _extends({}, props, {
|
|
8
|
-
width: "24",
|
|
9
|
-
height: "24",
|
|
10
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
11
|
-
}), /*#__PURE__*/React.createElement("path", {
|
|
12
|
-
d: "M14 12.5h-4l-.874 2.186A.5.5 0 0 1 8.66 15H7.273a.5.5 0 0 1-.456-.705l4.05-9A.5.5 0 0 1 11.323 5h1.354a.5.5 0 0 1 .456.295l4.05 9a.5.5 0 0 1-.456.705h-1.388a.5.5 0 0 1-.465-.314L14 12.5zm-.6-1.5L12 7.5 10.6 11h2.8z",
|
|
13
|
-
fill: "currentColor",
|
|
14
|
-
fillRule: "evenodd"
|
|
15
|
-
}));
|
|
16
|
-
};
|
|
17
|
-
export var EditorTextColorIcon = function EditorTextColorIcon() {
|
|
18
|
-
return /*#__PURE__*/React.createElement(Icon, {
|
|
19
|
-
glyph: textColorGlyph,
|
|
20
|
-
label: ""
|
|
21
|
-
});
|
|
22
|
-
};
|
|
@@ -1,282 +0,0 @@
|
|
|
1
|
-
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
2
|
-
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
|
-
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
|
|
4
|
-
import _inherits from "@babel/runtime/helpers/inherits";
|
|
5
|
-
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
6
|
-
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
7
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
8
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
11
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
/** @jsx jsx */
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { jsx } from '@emotion/react';
|
|
15
|
-
import { defineMessages, injectIntl } from 'react-intl-next';
|
|
16
|
-
import { getSelectedRowAndColumnFromPalette } from '@atlaskit/editor-common/ui-color';
|
|
17
|
-
import { ArrowKeyNavigationType } from '@atlaskit/editor-common/ui-menu';
|
|
18
|
-
import { ColorPalette, textPaletteTooltipMessages } from '@atlaskit/editor-common/ui-color';
|
|
19
|
-
import { wrapperStyle, separatorStyles, triggerWrapperStyles } from '@atlaskit/editor-common/styles';
|
|
20
|
-
import { DropdownContainer as Dropdown, ToolbarButton, TOOLBAR_BUTTON } from '@atlaskit/editor-common/ui-menu';
|
|
21
|
-
import { ACTION, ACTION_SUBJECT, ACTION_SUBJECT_ID, EVENT_TYPE } from '@atlaskit/editor-common/analytics';
|
|
22
|
-
import { hexToEditorTextPaletteColor } from '@atlaskit/editor-palette';
|
|
23
|
-
import { akEditorMenuZIndex } from '@atlaskit/editor-shared-styles';
|
|
24
|
-
import ExpandIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
25
|
-
import { expandIconWrapperStyle } from '@atlaskit/editor-common/styles';
|
|
26
|
-
import { changeColor as changeColorWithAnalytics } from '../../commands/change-color';
|
|
27
|
-
import { EditorTextColorIcon } from './icon';
|
|
28
|
-
import { backgroundDisabled, textColorIconBar, textColorIconWrapper } from './styles';
|
|
29
|
-
var EXPERIMENT_NAME = 'editor.toolbarTextColor.moreColors';
|
|
30
|
-
var EXPERIMENT_GROUP_CONTROL = 'control';
|
|
31
|
-
export var messages = defineMessages({
|
|
32
|
-
textColor: {
|
|
33
|
-
id: 'fabric.editor.textColor',
|
|
34
|
-
defaultMessage: 'Text color',
|
|
35
|
-
description: ''
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
export var ToolbarTextColor = /*#__PURE__*/function (_React$Component) {
|
|
39
|
-
_inherits(ToolbarTextColor, _React$Component);
|
|
40
|
-
var _super = _createSuper(ToolbarTextColor);
|
|
41
|
-
function ToolbarTextColor() {
|
|
42
|
-
var _this;
|
|
43
|
-
_classCallCheck(this, ToolbarTextColor);
|
|
44
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
45
|
-
args[_key] = arguments[_key];
|
|
46
|
-
}
|
|
47
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
48
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
49
|
-
isOpen: false,
|
|
50
|
-
isOpenedByKeyboard: false
|
|
51
|
-
});
|
|
52
|
-
_defineProperty(_assertThisInitialized(_this), "toolbarItemRef", /*#__PURE__*/React.createRef());
|
|
53
|
-
_defineProperty(_assertThisInitialized(_this), "changeColor", function (color, editorAnalyticsApi) {
|
|
54
|
-
return changeColorWithAnalytics(color, editorAnalyticsApi)(_this.props.editorView.state, _this.props.editorView.dispatch);
|
|
55
|
-
});
|
|
56
|
-
_defineProperty(_assertThisInitialized(_this), "onOpenChange", function (attrs) {
|
|
57
|
-
_this.handleOpenChange({
|
|
58
|
-
isOpen: attrs.isOpen,
|
|
59
|
-
logCloseEvent: true,
|
|
60
|
-
event: attrs.event
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
_defineProperty(_assertThisInitialized(_this), "changeTextColor", function (color, editorAnalyticsApi, disabled) {
|
|
64
|
-
if (!disabled) {
|
|
65
|
-
var _this$props$editorVie;
|
|
66
|
-
var palette = _this.props.pluginState.palette;
|
|
67
|
-
|
|
68
|
-
// we store color names in analytics
|
|
69
|
-
var swatch = palette.find(function (sw) {
|
|
70
|
-
return sw.value === color;
|
|
71
|
-
});
|
|
72
|
-
_this.dispatchAnalyticsEvent(_this.buildAnalyticsSelectColor({
|
|
73
|
-
color: (swatch ? swatch.label : color).toLowerCase()
|
|
74
|
-
}));
|
|
75
|
-
_this.handleOpenChange({
|
|
76
|
-
isOpen: false,
|
|
77
|
-
logCloseEvent: false
|
|
78
|
-
});
|
|
79
|
-
_this.changeColor(color, editorAnalyticsApi);
|
|
80
|
-
//To set the focus on the textcolor button when the menu is closed by 'Esc' only to meet aria guidelines
|
|
81
|
-
(_this$props$editorVie = _this.props.editorView) === null || _this$props$editorVie === void 0 || _this$props$editorVie.focus();
|
|
82
|
-
}
|
|
83
|
-
return false;
|
|
84
|
-
});
|
|
85
|
-
_defineProperty(_assertThisInitialized(_this), "toggleOpen", function () {
|
|
86
|
-
_this.handleOpenChange({
|
|
87
|
-
isOpen: !_this.state.isOpen,
|
|
88
|
-
logCloseEvent: true
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
_defineProperty(_assertThisInitialized(_this), "onKeyDown", function (event) {
|
|
92
|
-
if (event.key === 'Enter' || event.key === ' ') {
|
|
93
|
-
event.preventDefault();
|
|
94
|
-
_this.setState({
|
|
95
|
-
isOpenedByKeyboard: true
|
|
96
|
-
});
|
|
97
|
-
_this.toggleOpen();
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
_defineProperty(_assertThisInitialized(_this), "handleOpenChange", function (_ref) {
|
|
101
|
-
var isOpen = _ref.isOpen,
|
|
102
|
-
logCloseEvent = _ref.logCloseEvent,
|
|
103
|
-
event = _ref.event;
|
|
104
|
-
_this.setState({
|
|
105
|
-
isOpen: isOpen
|
|
106
|
-
});
|
|
107
|
-
if (!isOpen) {
|
|
108
|
-
_this.setState({
|
|
109
|
-
isOpenedByKeyboard: false
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
if (logCloseEvent) {
|
|
113
|
-
_this.dispatchAnalyticsEvent(_this.buildAnalyticsPalette(isOpen ? ACTION.OPENED : ACTION.CLOSED, {
|
|
114
|
-
noSelect: isOpen === false
|
|
115
|
-
}));
|
|
116
|
-
}
|
|
117
|
-
if (!isOpen && event instanceof KeyboardEvent && (event === null || event === void 0 ? void 0 : event.key) === 'Escape') {
|
|
118
|
-
var _this$toolbarItemRef;
|
|
119
|
-
(_this$toolbarItemRef = _this.toolbarItemRef) === null || _this$toolbarItemRef === void 0 || (_this$toolbarItemRef = _this$toolbarItemRef.current) === null || _this$toolbarItemRef === void 0 || _this$toolbarItemRef.focus();
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
_defineProperty(_assertThisInitialized(_this), "hide", function (e) {
|
|
123
|
-
var isOpen = _this.state.isOpen;
|
|
124
|
-
if (isOpen === true) {
|
|
125
|
-
_this.dispatchAnalyticsEvent(_this.buildAnalyticsPalette(ACTION.CLOSED, {
|
|
126
|
-
noSelect: true
|
|
127
|
-
}));
|
|
128
|
-
_this.setState({
|
|
129
|
-
isOpen: false
|
|
130
|
-
});
|
|
131
|
-
if (e instanceof KeyboardEvent && e.key === 'Escape') {
|
|
132
|
-
var _this$toolbarItemRef2;
|
|
133
|
-
(_this$toolbarItemRef2 = _this.toolbarItemRef) === null || _this$toolbarItemRef2 === void 0 || (_this$toolbarItemRef2 = _this$toolbarItemRef2.current) === null || _this$toolbarItemRef2 === void 0 || _this$toolbarItemRef2.focus();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
_defineProperty(_assertThisInitialized(_this), "hideonEsc", function (e) {
|
|
138
|
-
var _this$toolbarItemRef3;
|
|
139
|
-
_this.hide(e);
|
|
140
|
-
(_this$toolbarItemRef3 = _this.toolbarItemRef) === null || _this$toolbarItemRef3 === void 0 || (_this$toolbarItemRef3 = _this$toolbarItemRef3.current) === null || _this$toolbarItemRef3 === void 0 || _this$toolbarItemRef3.focus();
|
|
141
|
-
});
|
|
142
|
-
return _this;
|
|
143
|
-
}
|
|
144
|
-
_createClass(ToolbarTextColor, [{
|
|
145
|
-
key: "render",
|
|
146
|
-
value: function render() {
|
|
147
|
-
var _this2 = this;
|
|
148
|
-
var _this$state = this.state,
|
|
149
|
-
isOpen = _this$state.isOpen,
|
|
150
|
-
isOpenedByKeyboard = _this$state.isOpenedByKeyboard;
|
|
151
|
-
var _this$props = this.props,
|
|
152
|
-
popupsMountPoint = _this$props.popupsMountPoint,
|
|
153
|
-
popupsBoundariesElement = _this$props.popupsBoundariesElement,
|
|
154
|
-
popupsScrollableElement = _this$props.popupsScrollableElement,
|
|
155
|
-
isReducedSpacing = _this$props.isReducedSpacing,
|
|
156
|
-
pluginState = _this$props.pluginState,
|
|
157
|
-
formatMessage = _this$props.intl.formatMessage,
|
|
158
|
-
disabled = _this$props.disabled,
|
|
159
|
-
pluginInjectionApi = _this$props.pluginInjectionApi;
|
|
160
|
-
var labelTextColor = formatMessage(messages.textColor);
|
|
161
|
-
var palette = pluginState.palette;
|
|
162
|
-
var fitWidth;
|
|
163
|
-
if (document.body.clientWidth <= 740) {
|
|
164
|
-
// This was originally hard-coded, but moved here to a const
|
|
165
|
-
// My guess is it's based off (width of button * columns) + left/right padding
|
|
166
|
-
// 240 = (32 * 7) + (8 + 8)
|
|
167
|
-
// Not sure where the extra 2px comes from
|
|
168
|
-
fitWidth = 242;
|
|
169
|
-
}
|
|
170
|
-
var selectedColor = this.getSelectedColor(pluginState);
|
|
171
|
-
var _getSelectedRowAndCol = getSelectedRowAndColumnFromPalette(palette, pluginState.color),
|
|
172
|
-
selectedRowIndex = _getSelectedRowAndCol.selectedRowIndex,
|
|
173
|
-
selectedColumnIndex = _getSelectedRowAndCol.selectedColumnIndex;
|
|
174
|
-
return jsx("span", {
|
|
175
|
-
css: wrapperStyle
|
|
176
|
-
}, jsx(Dropdown, {
|
|
177
|
-
mountTo: popupsMountPoint,
|
|
178
|
-
boundariesElement: popupsBoundariesElement,
|
|
179
|
-
scrollableElement: popupsScrollableElement,
|
|
180
|
-
isOpen: isOpen && !pluginState.disabled,
|
|
181
|
-
handleClickOutside: this.hide,
|
|
182
|
-
handleEscapeKeydown: this.hideonEsc,
|
|
183
|
-
zIndex: akEditorMenuZIndex,
|
|
184
|
-
fitWidth: fitWidth,
|
|
185
|
-
onOpenChange: this.onOpenChange,
|
|
186
|
-
closeOnTab: true,
|
|
187
|
-
arrowKeyNavigationProviderOptions: {
|
|
188
|
-
type: ArrowKeyNavigationType.COLOR,
|
|
189
|
-
selectedRowIndex: selectedRowIndex,
|
|
190
|
-
selectedColumnIndex: selectedColumnIndex,
|
|
191
|
-
isOpenedByKeyboard: isOpenedByKeyboard,
|
|
192
|
-
isPopupPositioned: true
|
|
193
|
-
},
|
|
194
|
-
trigger: jsx(ToolbarButton, {
|
|
195
|
-
buttonId: TOOLBAR_BUTTON.TEXT_COLOR,
|
|
196
|
-
spacing: isReducedSpacing ? 'none' : 'default',
|
|
197
|
-
disabled: disabled || pluginState.disabled,
|
|
198
|
-
selected: isOpen,
|
|
199
|
-
"aria-label": labelTextColor,
|
|
200
|
-
"aria-expanded": isOpen,
|
|
201
|
-
"aria-haspopup": true,
|
|
202
|
-
title: labelTextColor,
|
|
203
|
-
onClick: this.toggleOpen,
|
|
204
|
-
onKeyDown: this.onKeyDown,
|
|
205
|
-
ref: this.toolbarItemRef,
|
|
206
|
-
iconBefore: jsx("div", {
|
|
207
|
-
css: triggerWrapperStyles
|
|
208
|
-
}, jsx("div", {
|
|
209
|
-
css: textColorIconWrapper
|
|
210
|
-
}, jsx(EditorTextColorIcon, null), jsx("div", {
|
|
211
|
-
css: [textColorIconBar, selectedColor ? "background: ".concat(selectedColor, ";") : pluginState.disabled && backgroundDisabled]
|
|
212
|
-
})), jsx("span", {
|
|
213
|
-
css: expandIconWrapperStyle
|
|
214
|
-
}, jsx(ExpandIcon, {
|
|
215
|
-
label: ""
|
|
216
|
-
})))
|
|
217
|
-
})
|
|
218
|
-
}, jsx("div", {
|
|
219
|
-
"data-testid": "text-color-palette"
|
|
220
|
-
}, jsx(ColorPalette, {
|
|
221
|
-
onClick: function onClick(color) {
|
|
222
|
-
var _pluginInjectionApi$a;
|
|
223
|
-
return _this2.changeTextColor(color, pluginInjectionApi === null || pluginInjectionApi === void 0 || (_pluginInjectionApi$a = pluginInjectionApi.analytics) === null || _pluginInjectionApi$a === void 0 ? void 0 : _pluginInjectionApi$a.actions, pluginState.disabled);
|
|
224
|
-
},
|
|
225
|
-
selectedColor: pluginState.color,
|
|
226
|
-
paletteOptions: {
|
|
227
|
-
palette: palette,
|
|
228
|
-
hexToPaletteColor: hexToEditorTextPaletteColor,
|
|
229
|
-
paletteColorTooltipMessages: textPaletteTooltipMessages
|
|
230
|
-
}
|
|
231
|
-
}))), jsx("span", {
|
|
232
|
-
css: separatorStyles
|
|
233
|
-
}));
|
|
234
|
-
}
|
|
235
|
-
}, {
|
|
236
|
-
key: "getSelectedColor",
|
|
237
|
-
value: function getSelectedColor(pluginState) {
|
|
238
|
-
var selectedColor = pluginState.color !== pluginState.defaultColor && (pluginState.color ? hexToEditorTextPaletteColor(pluginState.color) : pluginState.color);
|
|
239
|
-
return selectedColor;
|
|
240
|
-
}
|
|
241
|
-
}, {
|
|
242
|
-
key: "getCommonAnalyticsAttributes",
|
|
243
|
-
value: function getCommonAnalyticsAttributes() {
|
|
244
|
-
return {
|
|
245
|
-
experiment: EXPERIMENT_NAME,
|
|
246
|
-
experimentGroup: EXPERIMENT_GROUP_CONTROL
|
|
247
|
-
};
|
|
248
|
-
}
|
|
249
|
-
}, {
|
|
250
|
-
key: "buildAnalyticsPalette",
|
|
251
|
-
value: function buildAnalyticsPalette(action, data) {
|
|
252
|
-
return {
|
|
253
|
-
action: action,
|
|
254
|
-
actionSubject: ACTION_SUBJECT.TOOLBAR,
|
|
255
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
256
|
-
eventType: EVENT_TYPE.TRACK,
|
|
257
|
-
attributes: _objectSpread(_objectSpread({}, this.getCommonAnalyticsAttributes()), data)
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
}, {
|
|
261
|
-
key: "buildAnalyticsSelectColor",
|
|
262
|
-
value: function buildAnalyticsSelectColor(data) {
|
|
263
|
-
return {
|
|
264
|
-
action: ACTION.FORMATTED,
|
|
265
|
-
actionSubject: ACTION_SUBJECT.TEXT,
|
|
266
|
-
actionSubjectId: ACTION_SUBJECT_ID.FORMAT_COLOR,
|
|
267
|
-
eventType: EVENT_TYPE.TRACK,
|
|
268
|
-
attributes: _objectSpread(_objectSpread({}, this.getCommonAnalyticsAttributes()), data)
|
|
269
|
-
};
|
|
270
|
-
}
|
|
271
|
-
}, {
|
|
272
|
-
key: "dispatchAnalyticsEvent",
|
|
273
|
-
value: function dispatchAnalyticsEvent(payload) {
|
|
274
|
-
var dispatchAnalyticsEvent = this.props.dispatchAnalyticsEvent;
|
|
275
|
-
if (dispatchAnalyticsEvent) {
|
|
276
|
-
dispatchAnalyticsEvent(payload);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
}]);
|
|
280
|
-
return ToolbarTextColor;
|
|
281
|
-
}(React.Component);
|
|
282
|
-
export default injectIntl(ToolbarTextColor);
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
3
|
-
import { css } from '@emotion/react';
|
|
4
|
-
import { borderRadius } from '@atlaskit/theme/constants';
|
|
5
|
-
import * as colors from '@atlaskit/theme/colors';
|
|
6
|
-
var createSteppedRainbow = function createSteppedRainbow(colors) {
|
|
7
|
-
return "\n linear-gradient(\n to right,\n ".concat(colors.map(function (color, i) {
|
|
8
|
-
var inc = 100 / colors.length;
|
|
9
|
-
var pos = i + 1;
|
|
10
|
-
if (i === 0) {
|
|
11
|
-
return "".concat(color, " ").concat(pos * inc, "%,");
|
|
12
|
-
}
|
|
13
|
-
if (i === colors.length - 1) {
|
|
14
|
-
return "".concat(color, " ").concat((pos - 1) * inc, "%");
|
|
15
|
-
}
|
|
16
|
-
return "\n ".concat(color, " ").concat((pos - 1) * inc, "%,\n ").concat(color, " ").concat(pos * inc, "%,\n ");
|
|
17
|
-
}).join('\n'), "\n );\n ");
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// TODO: https://product-fabric.atlassian.net/browse/DSP-4137
|
|
21
|
-
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
22
|
-
var rainbow = createSteppedRainbow([colors.P300, colors.T300, colors.Y400, colors.R400]);
|
|
23
|
-
var disabledRainbow = createSteppedRainbow([colors.N80, colors.N60, colors.N40, colors.N60]);
|
|
24
|
-
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
25
|
-
|
|
26
|
-
export var textColorIconWrapper = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n"])));
|
|
27
|
-
export var textColorIconBar = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n left: 0;\n right: 0;\n top: 16px;\n margin: auto;\n width: 12px;\n height: 3px;\n border-radius: ", ";\n background: ", ";\n"])), borderRadius() + 'px', rainbow);
|
|
28
|
-
export var backgroundDisabled = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background: ", ";\n"])), disabledRainbow);
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { N800 } from '@atlaskit/theme/colors';
|
|
2
|
-
export var DEFAULT_COLOR = {
|
|
3
|
-
// TODO: https://product-fabric.atlassian.net/browse/DSP-4137
|
|
4
|
-
/* eslint-disable-next-line @atlaskit/design-system/ensure-design-token-usage */
|
|
5
|
-
color: N800.toLowerCase(),
|
|
6
|
-
label: 'Dark gray'
|
|
7
|
-
};
|
|
8
|
-
export var getActiveColor = function getActiveColor(state) {
|
|
9
|
-
var _ref = state.selection,
|
|
10
|
-
$from = _ref.$from,
|
|
11
|
-
$to = _ref.$to,
|
|
12
|
-
$cursor = _ref.$cursor;
|
|
13
|
-
var _ref2 = state.schema.marks,
|
|
14
|
-
textColor = _ref2.textColor;
|
|
15
|
-
|
|
16
|
-
// Filter out other marks
|
|
17
|
-
var marks = [];
|
|
18
|
-
if ($cursor) {
|
|
19
|
-
marks.push(textColor.isInSet(state.storedMarks || $cursor.marks()) || undefined);
|
|
20
|
-
} else {
|
|
21
|
-
state.doc.nodesBetween($from.pos, $to.pos, function (currentNode) {
|
|
22
|
-
if (currentNode.isLeaf) {
|
|
23
|
-
var mark = textColor.isInSet(currentNode.marks) || undefined;
|
|
24
|
-
marks.push(mark);
|
|
25
|
-
return !mark;
|
|
26
|
-
}
|
|
27
|
-
return true;
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Merge consecutive same color marks
|
|
32
|
-
var prevMark;
|
|
33
|
-
marks = marks.filter(function (mark) {
|
|
34
|
-
if (mark && prevMark && mark.attrs.color === prevMark.attrs.color) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
37
|
-
prevMark = mark;
|
|
38
|
-
return true;
|
|
39
|
-
});
|
|
40
|
-
var marksWithColor = marks.filter(function (mark) {
|
|
41
|
-
return !!mark;
|
|
42
|
-
});
|
|
43
|
-
// When multiple colors are selected revert back to default color
|
|
44
|
-
if (marksWithColor.length > 1 || marksWithColor.length === 1 && marks.length > 1) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return marksWithColor.length ? marksWithColor[0].attrs.color : DEFAULT_COLOR.color;
|
|
48
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { isMarkAllowedInRange, isMarkExcluded } from '@atlaskit/editor-common/mark';
|
|
2
|
-
var hasLinkMark = function hasLinkMark($pos) {
|
|
3
|
-
var linkMarkType = $pos.doc.type.schema.marks.link,
|
|
4
|
-
pos = $pos.pos;
|
|
5
|
-
if (!linkMarkType) {
|
|
6
|
-
return false;
|
|
7
|
-
}
|
|
8
|
-
return $pos.doc.rangeHasMark(pos, Math.min(pos + 1, $pos.doc.content.size), linkMarkType);
|
|
9
|
-
};
|
|
10
|
-
export var getDisabledState = function getDisabledState(state) {
|
|
11
|
-
var textColor = state.schema.marks.textColor;
|
|
12
|
-
if (textColor) {
|
|
13
|
-
var _ref = state.selection,
|
|
14
|
-
empty = _ref.empty,
|
|
15
|
-
ranges = _ref.ranges,
|
|
16
|
-
$cursor = _ref.$cursor;
|
|
17
|
-
if (empty && !$cursor || $cursor && hasLinkMark($cursor) || isMarkAllowedInRange(state.doc, ranges, textColor) === false) {
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
if (isMarkExcluded(textColor, state.storedMarks || $cursor && $cursor.marks())) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
return true;
|
|
26
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { TextColorPluginState } from './pm-plugins/main';
|
|
2
|
-
import { pluginKey as textColorPluginKey } from './pm-plugins/main';
|
|
3
|
-
import type { TextColorPlugin } from './types';
|
|
4
|
-
declare const textColorPlugin: TextColorPlugin;
|
|
5
|
-
export { textColorPluginKey };
|
|
6
|
-
export type { TextColorPluginState };
|
|
7
|
-
export default textColorPlugin;
|