@atlaskit/editor-plugin-mentions 14.5.8 → 14.5.9

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,16 @@
1
1
  # @atlaskit/editor-plugin-mentions
2
2
 
3
+ ## 14.5.9
4
+
5
+ ### Patch Changes
6
+
7
+ - [`25b1301af566b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/25b1301af566b) -
8
+ [ux] Make Labs lozenge text capitalised
9
+ - [`d2f1039e54388`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d2f1039e54388) -
10
+ Defer typed agent mention nudges while focus remains in the active document but outside the
11
+ editor, such as when typeahead, date, or status picker UI is open.
12
+ - Updated dependencies
13
+
3
14
  ## 14.5.8
4
15
 
5
16
  ### Patch Changes
package/compass.yml CHANGED
@@ -24,6 +24,9 @@ customFields:
24
24
  - name: Department
25
25
  type: text
26
26
  value: Eng - Editor AI
27
+ - name: Trusted Reviewer Teams
28
+ type: text
29
+ value: ari:cloud:identity::team/cf6a670b-5252-4c68-a769-9207de366beb
27
30
  - name: Technical Owner
28
31
  type: user
29
32
  value: ari:cloud:identity::user/612646c53fe26c00694fbe6a # Chris Kimber
@@ -49,8 +49,9 @@ var getAgentMentionName = function getAgentMentionName(text, fallbackName) {
49
49
  };
50
50
  var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
51
51
  var AGENT_MENTION_INACTIVITY_MS = 3000;
52
+ var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
52
53
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
53
- var PACKAGE_VERSION = "14.5.7";
54
+ var PACKAGE_VERSION = "14.5.8";
54
55
  var setProvider = function setProvider(provider) {
55
56
  return function (state, dispatch) {
56
57
  if (dispatch) {
@@ -624,14 +625,47 @@ function createMentionPlugin(_ref2) {
624
625
  var isAgentMentionsEnabled = (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true);
625
626
  var pendingTypedAgentMentionTimer;
626
627
  var pendingTypedAgentMentionTimerKey = null;
628
+ var pendingTypedAgentMentionFocusDeferCount = 0;
629
+
630
+ /**
631
+ * Clears the currently scheduled pending typed-agent-mention timer.
632
+ *
633
+ * By default this also resets the focus defer count because a new pending mention,
634
+ * local edit reset, or cleanup should start a fresh escape-hatch window. Focus-based
635
+ * retries pass `preserveFocusDeferCount` so repeated defers for the same pending
636
+ * mention are counted toward the bounded retry cap.
637
+ */
627
638
  var clearPendingTypedAgentMentionTimer = function clearPendingTypedAgentMentionTimer() {
639
+ var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
640
+ _ref4$preserveFocusDe = _ref4.preserveFocusDeferCount,
641
+ preserveFocusDeferCount = _ref4$preserveFocusDe === void 0 ? false : _ref4$preserveFocusDe;
628
642
  if (pendingTypedAgentMentionTimer) {
629
643
  clearTimeout(pendingTypedAgentMentionTimer);
630
644
  pendingTypedAgentMentionTimer = undefined;
631
645
  }
632
646
  pendingTypedAgentMentionTimerKey = null;
647
+ if (!preserveFocusDeferCount) {
648
+ pendingTypedAgentMentionFocusDeferCount = 0;
649
+ }
650
+ };
651
+
652
+ /**
653
+ * Typed agent mentions intentionally wait before invoking the agent so content the
654
+ * user adds next can become context. That context can be authored through
655
+ * editor-adjacent UI, such as mention typeahead, date picker, or status picker,
656
+ * where focus leaves the ProseMirror editor but remains in the active document.
657
+ * Treat that as continued authoring activity by restarting the inactivity window.
658
+ * This only defers the inactivity timer path: existing selection-change handling can
659
+ * still publish or clear the pending mention sooner. After 20 focus defers (~1 minute),
660
+ * publish anyway so pathological focus states cannot keep the mention pending indefinitely.
661
+ */
662
+ var shouldDeferPendingTypedAgentMention = function shouldDeferPendingTypedAgentMention() {
663
+ return typeof document !== 'undefined' && document.hasFocus() && !editorView.hasFocus();
633
664
  };
634
- var schedulePendingTypedAgentMentionTimer = function schedulePendingTypedAgentMentionTimer(mentionPluginState) {
665
+ var _schedulePendingTypedAgentMentionTimer = function schedulePendingTypedAgentMentionTimer(mentionPluginState) {
666
+ var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
667
+ _ref5$preserveFocusDe = _ref5.preserveFocusDeferCount,
668
+ preserveFocusDeferCount = _ref5$preserveFocusDe === void 0 ? false : _ref5$preserveFocusDe;
635
669
  if (!isAgentMentionsEnabled) {
636
670
  clearPendingTypedAgentMentionTimer();
637
671
  return;
@@ -645,7 +679,9 @@ function createMentionPlugin(_ref2) {
645
679
  if (timerKey === pendingTypedAgentMentionTimerKey) {
646
680
  return;
647
681
  }
648
- clearPendingTypedAgentMentionTimer();
682
+ clearPendingTypedAgentMentionTimer({
683
+ preserveFocusDeferCount: preserveFocusDeferCount
684
+ });
649
685
  pendingTypedAgentMentionTimerKey = timerKey;
650
686
  pendingTypedAgentMentionTimer = setTimeout(function () {
651
687
  var _mentionPluginKey$get;
@@ -653,6 +689,15 @@ function createMentionPlugin(_ref2) {
653
689
  if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
654
690
  return;
655
691
  }
692
+ if (shouldDeferPendingTypedAgentMention() && pendingTypedAgentMentionFocusDeferCount < MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS) {
693
+ pendingTypedAgentMentionFocusDeferCount++;
694
+ pendingTypedAgentMentionTimerKey = null;
695
+ _schedulePendingTypedAgentMentionTimer(_key.mentionPluginKey.getState(editorView.state), {
696
+ preserveFocusDeferCount: true
697
+ });
698
+ return;
699
+ }
700
+ pendingTypedAgentMentionFocusDeferCount = 0;
656
701
  editorView.dispatch(editorView.state.tr.setMeta(_key.mentionPluginKey, {
657
702
  action: ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION,
658
703
  params: {
@@ -712,7 +757,7 @@ function createMentionPlugin(_ref2) {
712
757
  if (mentionPluginState === _key.mentionPluginKey.getState(prevState)) {
713
758
  return;
714
759
  }
715
- schedulePendingTypedAgentMentionTimer(mentionPluginState);
760
+ _schedulePendingTypedAgentMentionTimer(mentionPluginState);
716
761
  },
717
762
  destroy: function destroy() {
718
763
  clearPendingTypedAgentMentionTimer();
@@ -399,7 +399,7 @@ var createTypeAheadConfig = exports.createTypeAheadConfig = function createTypeA
399
399
  } : {}), (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) ? {
400
400
  lozenge: /*#__PURE__*/_react.default.createElement(_lozenge.default, {
401
401
  appearance: "new"
402
- }, intl.formatMessage(_messages.mentionMessages.typeAheadSectionAgentsLabs))
402
+ }, intl.formatMessage(_messages.mentionMessages.typeAheadSectionAgentsLabsLozengeLabel))
403
403
  } : {})];
404
404
  },
405
405
  onOpen: function onOpen() {
@@ -34,8 +34,9 @@ const getAgentMentionName = (text, fallbackName) => {
34
34
  };
35
35
  const AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
36
36
  const AGENT_MENTION_INACTIVITY_MS = 3000;
37
+ const MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
37
38
  const PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
38
- const PACKAGE_VERSION = "14.5.7";
39
+ const PACKAGE_VERSION = "14.5.8";
39
40
  const setProvider = provider => (state, dispatch) => {
40
41
  if (dispatch) {
41
42
  dispatch(state.tr.setMeta(mentionPluginKey, {
@@ -583,14 +584,43 @@ export function createMentionPlugin({
583
584
  const isAgentMentionsEnabled = editorExperiment('platform_editor_agent_mentions', true);
584
585
  let pendingTypedAgentMentionTimer;
585
586
  let pendingTypedAgentMentionTimerKey = null;
586
- const clearPendingTypedAgentMentionTimer = () => {
587
+ let pendingTypedAgentMentionFocusDeferCount = 0;
588
+
589
+ /**
590
+ * Clears the currently scheduled pending typed-agent-mention timer.
591
+ *
592
+ * By default this also resets the focus defer count because a new pending mention,
593
+ * local edit reset, or cleanup should start a fresh escape-hatch window. Focus-based
594
+ * retries pass `preserveFocusDeferCount` so repeated defers for the same pending
595
+ * mention are counted toward the bounded retry cap.
596
+ */
597
+ const clearPendingTypedAgentMentionTimer = ({
598
+ preserveFocusDeferCount = false
599
+ } = {}) => {
587
600
  if (pendingTypedAgentMentionTimer) {
588
601
  clearTimeout(pendingTypedAgentMentionTimer);
589
602
  pendingTypedAgentMentionTimer = undefined;
590
603
  }
591
604
  pendingTypedAgentMentionTimerKey = null;
605
+ if (!preserveFocusDeferCount) {
606
+ pendingTypedAgentMentionFocusDeferCount = 0;
607
+ }
592
608
  };
593
- const schedulePendingTypedAgentMentionTimer = mentionPluginState => {
609
+
610
+ /**
611
+ * Typed agent mentions intentionally wait before invoking the agent so content the
612
+ * user adds next can become context. That context can be authored through
613
+ * editor-adjacent UI, such as mention typeahead, date picker, or status picker,
614
+ * where focus leaves the ProseMirror editor but remains in the active document.
615
+ * Treat that as continued authoring activity by restarting the inactivity window.
616
+ * This only defers the inactivity timer path: existing selection-change handling can
617
+ * still publish or clear the pending mention sooner. After 20 focus defers (~1 minute),
618
+ * publish anyway so pathological focus states cannot keep the mention pending indefinitely.
619
+ */
620
+ const shouldDeferPendingTypedAgentMention = () => typeof document !== 'undefined' && document.hasFocus() && !editorView.hasFocus();
621
+ const schedulePendingTypedAgentMentionTimer = (mentionPluginState, {
622
+ preserveFocusDeferCount = false
623
+ } = {}) => {
594
624
  if (!isAgentMentionsEnabled) {
595
625
  clearPendingTypedAgentMentionTimer();
596
626
  return;
@@ -604,7 +634,9 @@ export function createMentionPlugin({
604
634
  if (timerKey === pendingTypedAgentMentionTimerKey) {
605
635
  return;
606
636
  }
607
- clearPendingTypedAgentMentionTimer();
637
+ clearPendingTypedAgentMentionTimer({
638
+ preserveFocusDeferCount
639
+ });
608
640
  pendingTypedAgentMentionTimerKey = timerKey;
609
641
  pendingTypedAgentMentionTimer = setTimeout(() => {
610
642
  var _mentionPluginKey$get;
@@ -612,6 +644,15 @@ export function createMentionPlugin({
612
644
  if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
613
645
  return;
614
646
  }
647
+ if (shouldDeferPendingTypedAgentMention() && pendingTypedAgentMentionFocusDeferCount < MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS) {
648
+ pendingTypedAgentMentionFocusDeferCount++;
649
+ pendingTypedAgentMentionTimerKey = null;
650
+ schedulePendingTypedAgentMentionTimer(mentionPluginKey.getState(editorView.state), {
651
+ preserveFocusDeferCount: true
652
+ });
653
+ return;
654
+ }
655
+ pendingTypedAgentMentionFocusDeferCount = 0;
615
656
  editorView.dispatch(editorView.state.tr.setMeta(mentionPluginKey, {
616
657
  action: ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION,
617
658
  params: {
@@ -373,7 +373,7 @@ export const createTypeAheadConfig = ({
373
373
  ...(expVal('platform_editor_agent_mentions', 'isEnabled', false) ? {
374
374
  lozenge: /*#__PURE__*/React.createElement(Lozenge, {
375
375
  appearance: "new"
376
- }, intl.formatMessage(mentionMessages.typeAheadSectionAgentsLabs))
376
+ }, intl.formatMessage(mentionMessages.typeAheadSectionAgentsLabsLozengeLabel))
377
377
  } : {})
378
378
  }];
379
379
  },
@@ -41,8 +41,9 @@ var getAgentMentionName = function getAgentMentionName(text, fallbackName) {
41
41
  };
42
42
  var AI_STREAMING_TRANSFORMATION_META_KEY = 'isAIStreamingTransformation';
43
43
  var AGENT_MENTION_INACTIVITY_MS = 3000;
44
+ var MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS = 20;
44
45
  var PACKAGE_NAME = "@atlaskit/editor-plugin-mentions";
45
- var PACKAGE_VERSION = "14.5.7";
46
+ var PACKAGE_VERSION = "14.5.8";
46
47
  var setProvider = function setProvider(provider) {
47
48
  return function (state, dispatch) {
48
49
  if (dispatch) {
@@ -616,14 +617,47 @@ export function createMentionPlugin(_ref2) {
616
617
  var isAgentMentionsEnabled = editorExperiment('platform_editor_agent_mentions', true);
617
618
  var pendingTypedAgentMentionTimer;
618
619
  var pendingTypedAgentMentionTimerKey = null;
620
+ var pendingTypedAgentMentionFocusDeferCount = 0;
621
+
622
+ /**
623
+ * Clears the currently scheduled pending typed-agent-mention timer.
624
+ *
625
+ * By default this also resets the focus defer count because a new pending mention,
626
+ * local edit reset, or cleanup should start a fresh escape-hatch window. Focus-based
627
+ * retries pass `preserveFocusDeferCount` so repeated defers for the same pending
628
+ * mention are counted toward the bounded retry cap.
629
+ */
619
630
  var clearPendingTypedAgentMentionTimer = function clearPendingTypedAgentMentionTimer() {
631
+ var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
632
+ _ref4$preserveFocusDe = _ref4.preserveFocusDeferCount,
633
+ preserveFocusDeferCount = _ref4$preserveFocusDe === void 0 ? false : _ref4$preserveFocusDe;
620
634
  if (pendingTypedAgentMentionTimer) {
621
635
  clearTimeout(pendingTypedAgentMentionTimer);
622
636
  pendingTypedAgentMentionTimer = undefined;
623
637
  }
624
638
  pendingTypedAgentMentionTimerKey = null;
639
+ if (!preserveFocusDeferCount) {
640
+ pendingTypedAgentMentionFocusDeferCount = 0;
641
+ }
642
+ };
643
+
644
+ /**
645
+ * Typed agent mentions intentionally wait before invoking the agent so content the
646
+ * user adds next can become context. That context can be authored through
647
+ * editor-adjacent UI, such as mention typeahead, date picker, or status picker,
648
+ * where focus leaves the ProseMirror editor but remains in the active document.
649
+ * Treat that as continued authoring activity by restarting the inactivity window.
650
+ * This only defers the inactivity timer path: existing selection-change handling can
651
+ * still publish or clear the pending mention sooner. After 20 focus defers (~1 minute),
652
+ * publish anyway so pathological focus states cannot keep the mention pending indefinitely.
653
+ */
654
+ var shouldDeferPendingTypedAgentMention = function shouldDeferPendingTypedAgentMention() {
655
+ return typeof document !== 'undefined' && document.hasFocus() && !editorView.hasFocus();
625
656
  };
626
- var schedulePendingTypedAgentMentionTimer = function schedulePendingTypedAgentMentionTimer(mentionPluginState) {
657
+ var _schedulePendingTypedAgentMentionTimer = function schedulePendingTypedAgentMentionTimer(mentionPluginState) {
658
+ var _ref5 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
659
+ _ref5$preserveFocusDe = _ref5.preserveFocusDeferCount,
660
+ preserveFocusDeferCount = _ref5$preserveFocusDe === void 0 ? false : _ref5$preserveFocusDe;
627
661
  if (!isAgentMentionsEnabled) {
628
662
  clearPendingTypedAgentMentionTimer();
629
663
  return;
@@ -637,7 +671,9 @@ export function createMentionPlugin(_ref2) {
637
671
  if (timerKey === pendingTypedAgentMentionTimerKey) {
638
672
  return;
639
673
  }
640
- clearPendingTypedAgentMentionTimer();
674
+ clearPendingTypedAgentMentionTimer({
675
+ preserveFocusDeferCount: preserveFocusDeferCount
676
+ });
641
677
  pendingTypedAgentMentionTimerKey = timerKey;
642
678
  pendingTypedAgentMentionTimer = setTimeout(function () {
643
679
  var _mentionPluginKey$get;
@@ -645,6 +681,15 @@ export function createMentionPlugin(_ref2) {
645
681
  if (!latestPendingTypedAgentMention || latestPendingTypedAgentMention.localId !== pendingTypedAgentMention.localId || latestPendingTypedAgentMention.resetCount !== pendingTypedAgentMention.resetCount) {
646
682
  return;
647
683
  }
684
+ if (shouldDeferPendingTypedAgentMention() && pendingTypedAgentMentionFocusDeferCount < MAX_PENDING_TYPED_AGENT_MENTION_FOCUS_DEFERS) {
685
+ pendingTypedAgentMentionFocusDeferCount++;
686
+ pendingTypedAgentMentionTimerKey = null;
687
+ _schedulePendingTypedAgentMentionTimer(mentionPluginKey.getState(editorView.state), {
688
+ preserveFocusDeferCount: true
689
+ });
690
+ return;
691
+ }
692
+ pendingTypedAgentMentionFocusDeferCount = 0;
648
693
  editorView.dispatch(editorView.state.tr.setMeta(mentionPluginKey, {
649
694
  action: ACTIONS.COMMIT_PENDING_TYPED_AGENT_MENTION,
650
695
  params: {
@@ -704,7 +749,7 @@ export function createMentionPlugin(_ref2) {
704
749
  if (mentionPluginState === mentionPluginKey.getState(prevState)) {
705
750
  return;
706
751
  }
707
- schedulePendingTypedAgentMentionTimer(mentionPluginState);
752
+ _schedulePendingTypedAgentMentionTimer(mentionPluginState);
708
753
  },
709
754
  destroy: function destroy() {
710
755
  clearPendingTypedAgentMentionTimer();
@@ -390,7 +390,7 @@ export var createTypeAheadConfig = function createTypeAheadConfig(_ref8) {
390
390
  } : {}), expVal('platform_editor_agent_mentions', 'isEnabled', false) ? {
391
391
  lozenge: /*#__PURE__*/React.createElement(Lozenge, {
392
392
  appearance: "new"
393
- }, intl.formatMessage(mentionMessages.typeAheadSectionAgentsLabs))
393
+ }, intl.formatMessage(mentionMessages.typeAheadSectionAgentsLabsLozengeLabel))
394
394
  } : {})];
395
395
  },
396
396
  onOpen: function onOpen() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-mentions",
3
- "version": "14.5.8",
3
+ "version": "14.5.9",
4
4
  "description": "Mentions plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -41,7 +41,7 @@
41
41
  "@atlaskit/profilecard": "^26.5.0",
42
42
  "@atlaskit/teams-app-config": "^2.1.0",
43
43
  "@atlaskit/theme": "^26.1.0",
44
- "@atlaskit/tmp-editor-statsig": "^119.0.0",
44
+ "@atlaskit/tmp-editor-statsig": "^119.2.0",
45
45
  "@atlaskit/tokens": "^15.3.0",
46
46
  "@atlaskit/tooltip": "^23.1.0",
47
47
  "@atlaskit/user-picker": "^13.4.0",