@atlaskit/editor-plugin-tasks-and-decisions 5.0.3 → 5.0.5

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 CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/editor-plugin-tasks-and-decisions
2
2
 
3
+ ## 5.0.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#135686](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/135686)
8
+ [`fad3e236fffd3`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fad3e236fffd3) -
9
+ migrate decision item node to vanillajs
10
+ - Updated dependencies
11
+
12
+ ## 5.0.4
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 5.0.3
4
19
 
5
20
  ### Patch Changes
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.DecisionItemVanilla = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ var _monitoring = require("@atlaskit/editor-common/monitoring");
12
+ var _model = require("@atlaskit/editor-prosemirror/model");
13
+ var _decisionItemNodeSpec = require("./decisionItemNodeSpec");
14
+ var DecisionItemVanilla = exports.DecisionItemVanilla = /*#__PURE__*/function () {
15
+ function DecisionItemVanilla(node, intl) {
16
+ (0, _classCallCheck2.default)(this, DecisionItemVanilla);
17
+ (0, _defineProperty2.default)(this, "dom", document.createElement('div'));
18
+ (0, _defineProperty2.default)(this, "hasChildren", undefined);
19
+ try {
20
+ var spec = (0, _decisionItemNodeSpec.decisionItemToDOM)(node, intl);
21
+ var _DOMSerializer$render = _model.DOMSerializer.renderSpec(document, spec),
22
+ dom = _DOMSerializer$render.dom,
23
+ contentDOM = _DOMSerializer$render.contentDOM;
24
+ if (!(dom instanceof HTMLElement)) {
25
+ throw new Error('DOMSerializer did not return an HTMLElement');
26
+ }
27
+ this.dom = dom;
28
+ this.contentDOM = contentDOM;
29
+ this.updateHasChildren(node);
30
+ } catch (caughtError) {
31
+ var error = caughtError instanceof Error ? caughtError : new Error('Unknown error on DecisionItemVanilla Node View constructor - ' + String(caughtError));
32
+ this.logError(error);
33
+ this.renderFallback();
34
+ }
35
+ }
36
+ return (0, _createClass2.default)(DecisionItemVanilla, [{
37
+ key: "logError",
38
+ value: function logError(error) {
39
+ void (0, _monitoring.logException)(error, {
40
+ location: 'editor-plugin-tasks-and-decisions/DecisionItemVanilla'
41
+ });
42
+ }
43
+ }, {
44
+ key: "updateHasChildren",
45
+ value: function updateHasChildren(node) {
46
+ var currentlyHasChildren = node.childCount > 0;
47
+ if (currentlyHasChildren !== this.hasChildren) {
48
+ var _this$contentDOM;
49
+ this.hasChildren = currentlyHasChildren;
50
+ (_this$contentDOM = this.contentDOM) === null || _this$contentDOM === void 0 || _this$contentDOM.toggleAttribute('data-empty', !currentlyHasChildren);
51
+ }
52
+ return this.hasChildren;
53
+ }
54
+ }, {
55
+ key: "update",
56
+ value: function update(node) {
57
+ this.updateHasChildren(node);
58
+ return true;
59
+ }
60
+ }, {
61
+ key: "renderFallback",
62
+ value: function renderFallback() {
63
+ var fallback = document.createElement('div');
64
+ fallback.setAttribute('data-decision-item-fallback', 'true');
65
+ this.dom.appendChild(fallback);
66
+ this.contentDOM = fallback;
67
+ }
68
+ }]);
69
+ }();
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.decisionItemToDOM = void 0;
7
+ var _messages = require("@atlaskit/editor-common/messages");
8
+ // This value can be a fixed constant as it doesn't depend on runtime values or arguments.
9
+ var iconDOM = ['span', {
10
+ contentEditable: false,
11
+ 'data-component': 'icon'
12
+ }, ['span', {
13
+ role: 'img',
14
+ 'aria-label': 'Decision'
15
+ }, ['http://www.w3.org/2000/svg svg', {
16
+ viewBox: "0 0 24 24",
17
+ role: 'presentation',
18
+ width: '24',
19
+ height: '24',
20
+ 'data-icon-source': 'legacy'
21
+ }, ['http://www.w3.org/2000/svg path', {
22
+ fill: 'currentcolor',
23
+ 'fill-rule': 'evenodd',
24
+ d: 'm9.414 8 3.293 3.293c.187.187.293.442.293.707v5a1 1 0 0 1-2 0v-4.586l-3-3V10.5a1 1 0 0 1-2 0V7a1 1 0 0 1 1-1h3.5a1 1 0 0 1 0 2zm8.293-1.707a1 1 0 0 1 0 1.414l-2.5 2.5a.997.997 0 0 1-1.414 0 1 1 0 0 1 0-1.414l2.5-2.5a1 1 0 0 1 1.414 0'
25
+ }]], ['http://www.w3.org/2000/svg svg', {
26
+ viewBox: "-4 -4 24 24",
27
+ fill: 'none',
28
+ role: 'presentation',
29
+ width: '24',
30
+ height: '24',
31
+ 'data-icon-source': 'refreshed'
32
+ }, ['http://www.w3.org/2000/svg path', {
33
+ fill: 'currentcolor',
34
+ 'fill-rule': 'evenodd',
35
+ d: 'm13.97.97-4.5 4.5 1.06 1.06 4.5-4.5zM3.56 2.5H8V1H1.75a.75.75 0 0 0-.75.75V8h1.5V3.56l4.604 4.604a.5.5 0 0 1 .146.354V15h1.5V8.518a2 2 0 0 0-.586-1.414z'
36
+ }]]]];
37
+
38
+ // This value can be a fixed constant as it doesn't depend on runtime values or arguments.
39
+ var contentDOM = ['div', {
40
+ 'data-component': 'content'
41
+ }, ['div', {
42
+ class: 'decision-item'
43
+ }, 0]];
44
+ var decisionItemToDOM = exports.decisionItemToDOM = function decisionItemToDOM(node, intl) {
45
+ return ['li', {
46
+ 'data-decision-local-id': node.attrs.localId || 'local-decision',
47
+ 'data-decision-state': node.attrs.state,
48
+ 'data-prosemirror-node-view-type': 'vanilla',
49
+ 'data-prosemirror-node-name': 'decisionItem',
50
+ class: 'decisionItemView-content-wrap'
51
+ }, ['div', {
52
+ 'data-testid': 'elements-decision-item',
53
+ 'data-decision-wrapper': true
54
+ }, iconDOM,
55
+ // renderPlaceholder
56
+ ['span', {
57
+ 'data-testid': 'task-decision-item-placeholder',
58
+ 'data-component': 'placeholder',
59
+ contentEditable: false
60
+ }, intl.formatMessage(_messages.tasksAndDecisionsMessages.decisionPlaceholder)], contentDOM]];
61
+ };
@@ -14,7 +14,9 @@ var _selection = require("@atlaskit/editor-common/selection");
14
14
  var _utils = require("@atlaskit/editor-common/utils");
15
15
  var _state = require("@atlaskit/editor-prosemirror/state");
16
16
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
17
18
  var _decisionLazyNodeView = require("../nodeviews/decision-lazy-node-view");
19
+ var _DecisionItemVanilla = require("../nodeviews/DecisionItemVanilla");
18
20
  var _taskLazyNodeView = require("../nodeviews/task-lazy-node-view");
19
21
  var _actions = require("./actions");
20
22
  var _helpers = require("./helpers");
@@ -31,17 +33,24 @@ function nodesBetweenChanged(tr, f, startPos) {
31
33
  }
32
34
  tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
33
35
  }
34
- function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api) {
35
- var useLongPressSelection = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
36
- var hasEditPermission = arguments.length > 6 ? arguments[6] : undefined;
37
- var hasRequestedEditPermission = arguments.length > 7 ? arguments[7] : undefined;
38
- var requestToEditContent = arguments.length > 8 ? arguments[8] : undefined;
39
- var taskPlaceholder = arguments.length > 9 ? arguments[9] : undefined;
36
+ function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, getIntl) {
37
+ var useLongPressSelection = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
38
+ var hasEditPermission = arguments.length > 7 ? arguments[7] : undefined;
39
+ var hasRequestedEditPermission = arguments.length > 8 ? arguments[8] : undefined;
40
+ var requestToEditContent = arguments.length > 9 ? arguments[9] : undefined;
41
+ var taskPlaceholder = arguments.length > 10 ? arguments[10] : undefined;
40
42
  return new _safePlugin.SafePlugin({
41
43
  props: {
42
44
  nodeViews: {
43
45
  taskItem: (0, _taskLazyNodeView.lazyTaskView)(portalProviderAPI, eventDispatcher, providerFactory, api, taskPlaceholder),
44
- decisionItem: (0, _decisionLazyNodeView.lazyDecisionView)(portalProviderAPI, eventDispatcher, api)
46
+ decisionItem: function (node, view, getPos, decorations, innerDecorations) {
47
+ if ((0, _experiments.editorExperiment)('platform_editor_vanilla_dom', true, {
48
+ exposure: true
49
+ })) {
50
+ return new _DecisionItemVanilla.DecisionItemVanilla(node, getIntl());
51
+ }
52
+ return (0, _decisionLazyNodeView.lazyDecisionView)(portalProviderAPI, eventDispatcher, api)(node, view, getPos, decorations, innerDecorations);
53
+ }
45
54
  },
46
55
  handleTextInput: function handleTextInput(view, from, to, text) {
47
56
  // When a decision item is selected and the user starts typing, the entire node
@@ -243,8 +243,9 @@ var tasksAndDecisionsPlugin = exports.tasksAndDecisionsPlugin = function tasksAn
243
243
  var portalProviderAPI = _ref7.portalProviderAPI,
244
244
  providerFactory = _ref7.providerFactory,
245
245
  eventDispatcher = _ref7.eventDispatcher,
246
- dispatch = _ref7.dispatch;
247
- return (0, _main.createPlugin)(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection, hasEditPermission, hasRequestedEditPermission, requestToEditContent, taskPlaceholder);
246
+ dispatch = _ref7.dispatch,
247
+ getIntl = _ref7.getIntl;
248
+ return (0, _main.createPlugin)(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, getIntl, useLongPressSelection, hasEditPermission, hasRequestedEditPermission, requestToEditContent, taskPlaceholder);
248
249
  }
249
250
  }, {
250
251
  name: 'tasksAndDecisionsInputRule',
@@ -0,0 +1,51 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ import { logException } from '@atlaskit/editor-common/monitoring';
3
+ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
4
+ import { decisionItemToDOM } from './decisionItemNodeSpec';
5
+ export class DecisionItemVanilla {
6
+ logError(error) {
7
+ void logException(error, {
8
+ location: 'editor-plugin-tasks-and-decisions/DecisionItemVanilla'
9
+ });
10
+ }
11
+ updateHasChildren(node) {
12
+ const currentlyHasChildren = node.childCount > 0;
13
+ if (currentlyHasChildren !== this.hasChildren) {
14
+ var _this$contentDOM;
15
+ this.hasChildren = currentlyHasChildren;
16
+ (_this$contentDOM = this.contentDOM) === null || _this$contentDOM === void 0 ? void 0 : _this$contentDOM.toggleAttribute('data-empty', !currentlyHasChildren);
17
+ }
18
+ return this.hasChildren;
19
+ }
20
+ constructor(node, intl) {
21
+ _defineProperty(this, "dom", document.createElement('div'));
22
+ _defineProperty(this, "hasChildren", undefined);
23
+ try {
24
+ const spec = decisionItemToDOM(node, intl);
25
+ const {
26
+ dom,
27
+ contentDOM
28
+ } = DOMSerializer.renderSpec(document, spec);
29
+ if (!(dom instanceof HTMLElement)) {
30
+ throw new Error('DOMSerializer did not return an HTMLElement');
31
+ }
32
+ this.dom = dom;
33
+ this.contentDOM = contentDOM;
34
+ this.updateHasChildren(node);
35
+ } catch (caughtError) {
36
+ const error = caughtError instanceof Error ? caughtError : new Error('Unknown error on DecisionItemVanilla Node View constructor - ' + String(caughtError));
37
+ this.logError(error);
38
+ this.renderFallback();
39
+ }
40
+ }
41
+ update(node) {
42
+ this.updateHasChildren(node);
43
+ return true;
44
+ }
45
+ renderFallback() {
46
+ const fallback = document.createElement('div');
47
+ fallback.setAttribute('data-decision-item-fallback', 'true');
48
+ this.dom.appendChild(fallback);
49
+ this.contentDOM = fallback;
50
+ }
51
+ }
@@ -0,0 +1,55 @@
1
+ import { tasksAndDecisionsMessages } from '@atlaskit/editor-common/messages';
2
+ // This value can be a fixed constant as it doesn't depend on runtime values or arguments.
3
+ const iconDOM = ['span', {
4
+ contentEditable: false,
5
+ 'data-component': 'icon'
6
+ }, ['span', {
7
+ role: 'img',
8
+ 'aria-label': 'Decision'
9
+ }, ['http://www.w3.org/2000/svg svg', {
10
+ viewBox: `0 0 24 24`,
11
+ role: 'presentation',
12
+ width: '24',
13
+ height: '24',
14
+ 'data-icon-source': 'legacy'
15
+ }, ['http://www.w3.org/2000/svg path', {
16
+ fill: 'currentcolor',
17
+ 'fill-rule': 'evenodd',
18
+ d: 'm9.414 8 3.293 3.293c.187.187.293.442.293.707v5a1 1 0 0 1-2 0v-4.586l-3-3V10.5a1 1 0 0 1-2 0V7a1 1 0 0 1 1-1h3.5a1 1 0 0 1 0 2zm8.293-1.707a1 1 0 0 1 0 1.414l-2.5 2.5a.997.997 0 0 1-1.414 0 1 1 0 0 1 0-1.414l2.5-2.5a1 1 0 0 1 1.414 0'
19
+ }]], ['http://www.w3.org/2000/svg svg', {
20
+ viewBox: `-4 -4 24 24`,
21
+ fill: 'none',
22
+ role: 'presentation',
23
+ width: '24',
24
+ height: '24',
25
+ 'data-icon-source': 'refreshed'
26
+ }, ['http://www.w3.org/2000/svg path', {
27
+ fill: 'currentcolor',
28
+ 'fill-rule': 'evenodd',
29
+ d: 'm13.97.97-4.5 4.5 1.06 1.06 4.5-4.5zM3.56 2.5H8V1H1.75a.75.75 0 0 0-.75.75V8h1.5V3.56l4.604 4.604a.5.5 0 0 1 .146.354V15h1.5V8.518a2 2 0 0 0-.586-1.414z'
30
+ }]]]];
31
+
32
+ // This value can be a fixed constant as it doesn't depend on runtime values or arguments.
33
+ const contentDOM = ['div', {
34
+ 'data-component': 'content'
35
+ }, ['div', {
36
+ class: 'decision-item'
37
+ }, 0]];
38
+ export const decisionItemToDOM = (node, intl) => {
39
+ return ['li', {
40
+ 'data-decision-local-id': node.attrs.localId || 'local-decision',
41
+ 'data-decision-state': node.attrs.state,
42
+ 'data-prosemirror-node-view-type': 'vanilla',
43
+ 'data-prosemirror-node-name': 'decisionItem',
44
+ class: 'decisionItemView-content-wrap'
45
+ }, ['div', {
46
+ 'data-testid': 'elements-decision-item',
47
+ 'data-decision-wrapper': true
48
+ }, iconDOM,
49
+ // renderPlaceholder
50
+ ['span', {
51
+ 'data-testid': 'task-decision-item-placeholder',
52
+ 'data-component': 'placeholder',
53
+ contentEditable: false
54
+ }, intl.formatMessage(tasksAndDecisionsMessages.decisionPlaceholder)], contentDOM]];
55
+ };
@@ -5,7 +5,9 @@ import { createSelectionClickHandler, GapCursorSelection } from '@atlaskit/edito
5
5
  import { getStepRange } from '@atlaskit/editor-common/utils';
6
6
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
7
7
  import { fg } from '@atlaskit/platform-feature-flags';
8
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
9
  import { lazyDecisionView } from '../nodeviews/decision-lazy-node-view';
10
+ import { DecisionItemVanilla } from '../nodeviews/DecisionItemVanilla';
9
11
  import { lazyTaskView } from '../nodeviews/task-lazy-node-view';
10
12
  import { focusTaskDecision, setProvider } from './actions';
11
13
  import { focusCheckboxAndUpdateSelection, getTaskItemDataAtPos, getTaskItemDataToFocus, removeCheckboxFocus } from './helpers';
@@ -19,12 +21,19 @@ function nodesBetweenChanged(tr, f, startPos) {
19
21
  }
20
22
  tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
21
23
  }
22
- export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection = false, hasEditPermission, hasRequestedEditPermission, requestToEditContent, taskPlaceholder) {
24
+ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, getIntl, useLongPressSelection = false, hasEditPermission, hasRequestedEditPermission, requestToEditContent, taskPlaceholder) {
23
25
  return new SafePlugin({
24
26
  props: {
25
27
  nodeViews: {
26
28
  taskItem: lazyTaskView(portalProviderAPI, eventDispatcher, providerFactory, api, taskPlaceholder),
27
- decisionItem: lazyDecisionView(portalProviderAPI, eventDispatcher, api)
29
+ decisionItem: (node, view, getPos, decorations, innerDecorations) => {
30
+ if (editorExperiment('platform_editor_vanilla_dom', true, {
31
+ exposure: true
32
+ })) {
33
+ return new DecisionItemVanilla(node, getIntl());
34
+ }
35
+ return lazyDecisionView(portalProviderAPI, eventDispatcher, api)(node, view, getPos, decorations, innerDecorations);
36
+ }
28
37
  },
29
38
  handleTextInput(view, from, to, text) {
30
39
  // When a decision item is selected and the user starts typing, the entire node
@@ -203,9 +203,10 @@ export const tasksAndDecisionsPlugin = ({
203
203
  portalProviderAPI,
204
204
  providerFactory,
205
205
  eventDispatcher,
206
- dispatch
206
+ dispatch,
207
+ getIntl
207
208
  }) => {
208
- return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection, hasEditPermission, hasRequestedEditPermission, requestToEditContent, taskPlaceholder);
209
+ return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, getIntl, useLongPressSelection, hasEditPermission, hasRequestedEditPermission, requestToEditContent, taskPlaceholder);
209
210
  }
210
211
  }, {
211
212
  name: 'tasksAndDecisionsInputRule',
@@ -0,0 +1,62 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
+ import { logException } from '@atlaskit/editor-common/monitoring';
5
+ import { DOMSerializer } from '@atlaskit/editor-prosemirror/model';
6
+ import { decisionItemToDOM } from './decisionItemNodeSpec';
7
+ export var DecisionItemVanilla = /*#__PURE__*/function () {
8
+ function DecisionItemVanilla(node, intl) {
9
+ _classCallCheck(this, DecisionItemVanilla);
10
+ _defineProperty(this, "dom", document.createElement('div'));
11
+ _defineProperty(this, "hasChildren", undefined);
12
+ try {
13
+ var spec = decisionItemToDOM(node, intl);
14
+ var _DOMSerializer$render = DOMSerializer.renderSpec(document, spec),
15
+ dom = _DOMSerializer$render.dom,
16
+ contentDOM = _DOMSerializer$render.contentDOM;
17
+ if (!(dom instanceof HTMLElement)) {
18
+ throw new Error('DOMSerializer did not return an HTMLElement');
19
+ }
20
+ this.dom = dom;
21
+ this.contentDOM = contentDOM;
22
+ this.updateHasChildren(node);
23
+ } catch (caughtError) {
24
+ var error = caughtError instanceof Error ? caughtError : new Error('Unknown error on DecisionItemVanilla Node View constructor - ' + String(caughtError));
25
+ this.logError(error);
26
+ this.renderFallback();
27
+ }
28
+ }
29
+ return _createClass(DecisionItemVanilla, [{
30
+ key: "logError",
31
+ value: function logError(error) {
32
+ void logException(error, {
33
+ location: 'editor-plugin-tasks-and-decisions/DecisionItemVanilla'
34
+ });
35
+ }
36
+ }, {
37
+ key: "updateHasChildren",
38
+ value: function updateHasChildren(node) {
39
+ var currentlyHasChildren = node.childCount > 0;
40
+ if (currentlyHasChildren !== this.hasChildren) {
41
+ var _this$contentDOM;
42
+ this.hasChildren = currentlyHasChildren;
43
+ (_this$contentDOM = this.contentDOM) === null || _this$contentDOM === void 0 || _this$contentDOM.toggleAttribute('data-empty', !currentlyHasChildren);
44
+ }
45
+ return this.hasChildren;
46
+ }
47
+ }, {
48
+ key: "update",
49
+ value: function update(node) {
50
+ this.updateHasChildren(node);
51
+ return true;
52
+ }
53
+ }, {
54
+ key: "renderFallback",
55
+ value: function renderFallback() {
56
+ var fallback = document.createElement('div');
57
+ fallback.setAttribute('data-decision-item-fallback', 'true');
58
+ this.dom.appendChild(fallback);
59
+ this.contentDOM = fallback;
60
+ }
61
+ }]);
62
+ }();
@@ -0,0 +1,55 @@
1
+ import { tasksAndDecisionsMessages } from '@atlaskit/editor-common/messages';
2
+ // This value can be a fixed constant as it doesn't depend on runtime values or arguments.
3
+ var iconDOM = ['span', {
4
+ contentEditable: false,
5
+ 'data-component': 'icon'
6
+ }, ['span', {
7
+ role: 'img',
8
+ 'aria-label': 'Decision'
9
+ }, ['http://www.w3.org/2000/svg svg', {
10
+ viewBox: "0 0 24 24",
11
+ role: 'presentation',
12
+ width: '24',
13
+ height: '24',
14
+ 'data-icon-source': 'legacy'
15
+ }, ['http://www.w3.org/2000/svg path', {
16
+ fill: 'currentcolor',
17
+ 'fill-rule': 'evenodd',
18
+ d: 'm9.414 8 3.293 3.293c.187.187.293.442.293.707v5a1 1 0 0 1-2 0v-4.586l-3-3V10.5a1 1 0 0 1-2 0V7a1 1 0 0 1 1-1h3.5a1 1 0 0 1 0 2zm8.293-1.707a1 1 0 0 1 0 1.414l-2.5 2.5a.997.997 0 0 1-1.414 0 1 1 0 0 1 0-1.414l2.5-2.5a1 1 0 0 1 1.414 0'
19
+ }]], ['http://www.w3.org/2000/svg svg', {
20
+ viewBox: "-4 -4 24 24",
21
+ fill: 'none',
22
+ role: 'presentation',
23
+ width: '24',
24
+ height: '24',
25
+ 'data-icon-source': 'refreshed'
26
+ }, ['http://www.w3.org/2000/svg path', {
27
+ fill: 'currentcolor',
28
+ 'fill-rule': 'evenodd',
29
+ d: 'm13.97.97-4.5 4.5 1.06 1.06 4.5-4.5zM3.56 2.5H8V1H1.75a.75.75 0 0 0-.75.75V8h1.5V3.56l4.604 4.604a.5.5 0 0 1 .146.354V15h1.5V8.518a2 2 0 0 0-.586-1.414z'
30
+ }]]]];
31
+
32
+ // This value can be a fixed constant as it doesn't depend on runtime values or arguments.
33
+ var contentDOM = ['div', {
34
+ 'data-component': 'content'
35
+ }, ['div', {
36
+ class: 'decision-item'
37
+ }, 0]];
38
+ export var decisionItemToDOM = function decisionItemToDOM(node, intl) {
39
+ return ['li', {
40
+ 'data-decision-local-id': node.attrs.localId || 'local-decision',
41
+ 'data-decision-state': node.attrs.state,
42
+ 'data-prosemirror-node-view-type': 'vanilla',
43
+ 'data-prosemirror-node-name': 'decisionItem',
44
+ class: 'decisionItemView-content-wrap'
45
+ }, ['div', {
46
+ 'data-testid': 'elements-decision-item',
47
+ 'data-decision-wrapper': true
48
+ }, iconDOM,
49
+ // renderPlaceholder
50
+ ['span', {
51
+ 'data-testid': 'task-decision-item-placeholder',
52
+ 'data-component': 'placeholder',
53
+ contentEditable: false
54
+ }, intl.formatMessage(tasksAndDecisionsMessages.decisionPlaceholder)], contentDOM]];
55
+ };
@@ -10,7 +10,9 @@ import { createSelectionClickHandler, GapCursorSelection } from '@atlaskit/edito
10
10
  import { getStepRange } from '@atlaskit/editor-common/utils';
11
11
  import { NodeSelection } from '@atlaskit/editor-prosemirror/state';
12
12
  import { fg } from '@atlaskit/platform-feature-flags';
13
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
13
14
  import { lazyDecisionView } from '../nodeviews/decision-lazy-node-view';
15
+ import { DecisionItemVanilla } from '../nodeviews/DecisionItemVanilla';
14
16
  import { lazyTaskView } from '../nodeviews/task-lazy-node-view';
15
17
  import { focusTaskDecision, setProvider } from './actions';
16
18
  import { focusCheckboxAndUpdateSelection, getTaskItemDataAtPos, getTaskItemDataToFocus, removeCheckboxFocus } from './helpers';
@@ -24,17 +26,24 @@ function nodesBetweenChanged(tr, f, startPos) {
24
26
  }
25
27
  tr.doc.nodesBetween(stepRange.from, stepRange.to, f, startPos);
26
28
  }
27
- export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api) {
28
- var useLongPressSelection = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
29
- var hasEditPermission = arguments.length > 6 ? arguments[6] : undefined;
30
- var hasRequestedEditPermission = arguments.length > 7 ? arguments[7] : undefined;
31
- var requestToEditContent = arguments.length > 8 ? arguments[8] : undefined;
32
- var taskPlaceholder = arguments.length > 9 ? arguments[9] : undefined;
29
+ export function createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, getIntl) {
30
+ var useLongPressSelection = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;
31
+ var hasEditPermission = arguments.length > 7 ? arguments[7] : undefined;
32
+ var hasRequestedEditPermission = arguments.length > 8 ? arguments[8] : undefined;
33
+ var requestToEditContent = arguments.length > 9 ? arguments[9] : undefined;
34
+ var taskPlaceholder = arguments.length > 10 ? arguments[10] : undefined;
33
35
  return new SafePlugin({
34
36
  props: {
35
37
  nodeViews: {
36
38
  taskItem: lazyTaskView(portalProviderAPI, eventDispatcher, providerFactory, api, taskPlaceholder),
37
- decisionItem: lazyDecisionView(portalProviderAPI, eventDispatcher, api)
39
+ decisionItem: function (node, view, getPos, decorations, innerDecorations) {
40
+ if (editorExperiment('platform_editor_vanilla_dom', true, {
41
+ exposure: true
42
+ })) {
43
+ return new DecisionItemVanilla(node, getIntl());
44
+ }
45
+ return lazyDecisionView(portalProviderAPI, eventDispatcher, api)(node, view, getPos, decorations, innerDecorations);
46
+ }
38
47
  },
39
48
  handleTextInput: function handleTextInput(view, from, to, text) {
40
49
  // When a decision item is selected and the user starts typing, the entire node
@@ -234,8 +234,9 @@ export var tasksAndDecisionsPlugin = function tasksAndDecisionsPlugin(_ref2) {
234
234
  var portalProviderAPI = _ref7.portalProviderAPI,
235
235
  providerFactory = _ref7.providerFactory,
236
236
  eventDispatcher = _ref7.eventDispatcher,
237
- dispatch = _ref7.dispatch;
238
- return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, useLongPressSelection, hasEditPermission, hasRequestedEditPermission, requestToEditContent, taskPlaceholder);
237
+ dispatch = _ref7.dispatch,
238
+ getIntl = _ref7.getIntl;
239
+ return createPlugin(portalProviderAPI, eventDispatcher, providerFactory, dispatch, api, getIntl, useLongPressSelection, hasEditPermission, hasRequestedEditPermission, requestToEditContent, taskPlaceholder);
239
240
  }
240
241
  }, {
241
242
  name: 'tasksAndDecisionsInputRule',
@@ -0,0 +1,13 @@
1
+ import { IntlShape } from 'react-intl-next';
2
+ import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import { NodeView } from '@atlaskit/editor-prosemirror/view';
4
+ export declare class DecisionItemVanilla implements NodeView {
5
+ dom: HTMLElement;
6
+ contentDOM?: HTMLElement;
7
+ private hasChildren;
8
+ private logError;
9
+ private updateHasChildren;
10
+ constructor(node: PMNode, intl: IntlShape);
11
+ update(node: PMNode): boolean;
12
+ private renderFallback;
13
+ }
@@ -0,0 +1,47 @@
1
+ import { IntlShape } from 'react-intl-next';
2
+ import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ export declare const decisionItemToDOM: (node: PMNode, intl: IntlShape) => [string, {
4
+ 'data-decision-local-id': any;
5
+ 'data-decision-state': any;
6
+ 'data-prosemirror-node-view-type': string;
7
+ 'data-prosemirror-node-name': string;
8
+ class: string;
9
+ }, (string | [string, {
10
+ contentEditable: boolean;
11
+ 'data-component': string;
12
+ }, (string | {
13
+ role: string;
14
+ 'aria-label': string;
15
+ } | (string | {
16
+ viewBox: string;
17
+ role: string;
18
+ width: string;
19
+ height: string;
20
+ 'data-icon-source': string;
21
+ } | (string | {
22
+ fill: string;
23
+ 'fill-rule': string;
24
+ d: string;
25
+ })[])[] | (string | {
26
+ viewBox: string;
27
+ fill: string;
28
+ role: string;
29
+ width: string;
30
+ height: string;
31
+ 'data-icon-source': string;
32
+ } | (string | {
33
+ fill: string;
34
+ 'fill-rule': string;
35
+ d: string;
36
+ })[])[])[]] | [string, {
37
+ 'data-component': string;
38
+ }, (string | number | {
39
+ class: string;
40
+ })[]] | {
41
+ 'data-testid': string;
42
+ 'data-decision-wrapper': boolean;
43
+ } | (string | {
44
+ 'data-testid': string;
45
+ 'data-component': string;
46
+ contentEditable: boolean;
47
+ })[])[]];
@@ -1,3 +1,4 @@
1
+ import { IntlShape } from 'react-intl-next';
1
2
  import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
3
  import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
4
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
@@ -5,4 +6,4 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
6
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
7
  import type { TasksAndDecisionsPlugin } from '../tasksAndDecisionsPluginType';
7
8
  import type { TaskDecisionPluginState } from '../types';
8
- export declare function createPlugin(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined, useLongPressSelection?: boolean, hasEditPermission?: boolean, hasRequestedEditPermission?: boolean, requestToEditContent?: () => void, taskPlaceholder?: string): SafePlugin<TaskDecisionPluginState>;
9
+ export declare function createPlugin(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined, getIntl: () => IntlShape, useLongPressSelection?: boolean, hasEditPermission?: boolean, hasRequestedEditPermission?: boolean, requestToEditContent?: () => void, taskPlaceholder?: string): SafePlugin<TaskDecisionPluginState>;
@@ -0,0 +1,13 @@
1
+ import { IntlShape } from 'react-intl-next';
2
+ import { type Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ import { NodeView } from '@atlaskit/editor-prosemirror/view';
4
+ export declare class DecisionItemVanilla implements NodeView {
5
+ dom: HTMLElement;
6
+ contentDOM?: HTMLElement;
7
+ private hasChildren;
8
+ private logError;
9
+ private updateHasChildren;
10
+ constructor(node: PMNode, intl: IntlShape);
11
+ update(node: PMNode): boolean;
12
+ private renderFallback;
13
+ }
@@ -0,0 +1,59 @@
1
+ import { IntlShape } from 'react-intl-next';
2
+ import { Node as PMNode } from '@atlaskit/editor-prosemirror/model';
3
+ export declare const decisionItemToDOM: (node: PMNode, intl: IntlShape) => [
4
+ string,
5
+ {
6
+ 'data-decision-local-id': any;
7
+ 'data-decision-state': any;
8
+ 'data-prosemirror-node-view-type': string;
9
+ 'data-prosemirror-node-name': string;
10
+ class: string;
11
+ },
12
+ (string | [
13
+ string,
14
+ {
15
+ contentEditable: boolean;
16
+ 'data-component': string;
17
+ },
18
+ (string | {
19
+ role: string;
20
+ 'aria-label': string;
21
+ } | (string | {
22
+ viewBox: string;
23
+ role: string;
24
+ width: string;
25
+ height: string;
26
+ 'data-icon-source': string;
27
+ } | (string | {
28
+ fill: string;
29
+ 'fill-rule': string;
30
+ d: string;
31
+ })[])[] | (string | {
32
+ viewBox: string;
33
+ fill: string;
34
+ role: string;
35
+ width: string;
36
+ height: string;
37
+ 'data-icon-source': string;
38
+ } | (string | {
39
+ fill: string;
40
+ 'fill-rule': string;
41
+ d: string;
42
+ })[])[])[]
43
+ ] | [
44
+ string,
45
+ {
46
+ 'data-component': string;
47
+ },
48
+ (string | number | {
49
+ class: string;
50
+ })[]
51
+ ] | {
52
+ 'data-testid': string;
53
+ 'data-decision-wrapper': boolean;
54
+ } | (string | {
55
+ 'data-testid': string;
56
+ 'data-component': string;
57
+ contentEditable: boolean;
58
+ })[])[]
59
+ ];
@@ -1,3 +1,4 @@
1
+ import { IntlShape } from 'react-intl-next';
1
2
  import type { Dispatch, EventDispatcher } from '@atlaskit/editor-common/event-dispatcher';
2
3
  import { type PortalProviderAPI } from '@atlaskit/editor-common/portal';
3
4
  import type { ProviderFactory } from '@atlaskit/editor-common/provider-factory';
@@ -5,4 +6,4 @@ import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
5
6
  import type { ExtractInjectionAPI } from '@atlaskit/editor-common/types';
6
7
  import type { TasksAndDecisionsPlugin } from '../tasksAndDecisionsPluginType';
7
8
  import type { TaskDecisionPluginState } from '../types';
8
- export declare function createPlugin(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined, useLongPressSelection?: boolean, hasEditPermission?: boolean, hasRequestedEditPermission?: boolean, requestToEditContent?: () => void, taskPlaceholder?: string): SafePlugin<TaskDecisionPluginState>;
9
+ export declare function createPlugin(portalProviderAPI: PortalProviderAPI, eventDispatcher: EventDispatcher, providerFactory: ProviderFactory, dispatch: Dispatch, api: ExtractInjectionAPI<TasksAndDecisionsPlugin> | undefined, getIntl: () => IntlShape, useLongPressSelection?: boolean, hasEditPermission?: boolean, hasRequestedEditPermission?: boolean, requestToEditContent?: () => void, taskPlaceholder?: string): SafePlugin<TaskDecisionPluginState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-tasks-and-decisions",
3
- "version": "5.0.3",
3
+ "version": "5.0.5",
4
4
  "description": "Tasks and decisions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -37,17 +37,17 @@
37
37
  "@atlaskit/analytics-namespaced-context": "^7.0.0",
38
38
  "@atlaskit/analytics-next": "^11.0.0",
39
39
  "@atlaskit/css": "^0.10.0",
40
- "@atlaskit/editor-common": "^103.0.0",
40
+ "@atlaskit/editor-common": "^103.1.0",
41
41
  "@atlaskit/editor-plugin-analytics": "^2.2.0",
42
42
  "@atlaskit/editor-plugin-context-identifier": "^2.0.0",
43
43
  "@atlaskit/editor-plugin-editor-viewmode": "^3.0.0",
44
44
  "@atlaskit/editor-plugin-type-ahead": "^2.3.0",
45
45
  "@atlaskit/editor-prosemirror": "7.0.0",
46
- "@atlaskit/heading": "^5.1.0",
46
+ "@atlaskit/heading": "^5.2.0",
47
47
  "@atlaskit/icon": "^25.5.0",
48
48
  "@atlaskit/platform-feature-flags": "^1.1.0",
49
- "@atlaskit/popup": "^3.0.0",
50
- "@atlaskit/primitives": "^14.3.0",
49
+ "@atlaskit/popup": "^4.0.0",
50
+ "@atlaskit/primitives": "^14.4.0",
51
51
  "@atlaskit/prosemirror-input-rules": "^3.3.0",
52
52
  "@atlaskit/task-decision": "^19.1.0",
53
53
  "@atlaskit/tmp-editor-statsig": "^4.6.0",