fit-ui 3.4.1 → 3.4.3

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/dist/Fit.UI.js CHANGED
@@ -682,7 +682,7 @@ Fit._internal =
682
682
  {
683
683
  Core:
684
684
  {
685
- VersionInfo: { Major: 3, Minor: 4, Patch: 1 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
685
+ VersionInfo: { Major: 3, Minor: 4, Patch: 3 } // Do NOT modify format - version numbers are programmatically changed when releasing new versions - MUST be on a separate line!
686
686
  }
687
687
  };
688
688
 
@@ -26755,14 +26755,30 @@ Fit.Controls.Input = function(ctlId)
26755
26755
  if (designEditorMustDisposeWhenReady === true)
26756
26756
  {
26757
26757
  Fit.Browser.Debug("WARNING: Input control '" + me.GetId() + "' was disposed while initializing DesignMode - now resuming disposal");
26758
- me.Dispose();
26758
+ setTimeout(function() // Postpone - plugins (e.g. ColorButton) might register an instanceReady handler and expect the instance to still exist - postponing is fine, instanceReady and designEditorMustDisposeWhenReady already makes the operation async.
26759
+ {
26760
+ if (me === null)
26761
+ {
26762
+ return;
26763
+ }
26764
+
26765
+ me.Dispose();
26766
+ }, 0);
26759
26767
  return;
26760
26768
  }
26761
26769
 
26762
26770
  if (designEditorMustReloadWhenReady === true)
26763
26771
  {
26764
26772
  Fit.Browser.Debug("WARNING: Editor for Input control '" + me.GetId() + "' finished loading, but properties affecting editor has changed while initializing - reloading to adjust to changes");
26765
- reloadEditor(true);
26773
+ setTimeout(function() // Postpone - plugins (e.g. ColorButton) might register an instanceReady handler and expect the instance to still exist - postponing is fine, instanceReady and designEditorMustReloadWhenReady already makes the operation async.
26774
+ {
26775
+ if (me === null)
26776
+ {
26777
+ return;
26778
+ }
26779
+
26780
+ reloadEditor(true);
26781
+ }, 0);
26766
26782
  return;
26767
26783
  }
26768
26784
 
@@ -26914,76 +26930,47 @@ Fit.Controls.Input = function(ctlId)
26914
26930
  }
26915
26931
  }
26916
26932
 
26917
- // Register necessary events with emoji panel when opened
26918
-
26919
- var emojiButton = designEditor.container.$.querySelector("a.cke_button__emojipanel");
26933
+ // Register necessary events with color panel when opened
26920
26934
 
26921
- if (emojiButton !== null) // Better safe than sorry
26935
+ Fit.Array.ForEach(designEditor.container.$.querySelectorAll("a.cke_button__textcolor, a.cke_button__bgcolor"), function(button)
26922
26936
  {
26923
- Fit.Events.AddHandler(emojiButton, "click", function(e)
26937
+ lockDesignEditorDialogButtonToFocusState(button, function() // Callback invoked to get panel associated with button
26924
26938
  {
26925
- // Make sure OnFocus fires before locking focus state
26939
+ var panel = null;
26926
26940
 
26927
- if (me.Focused() === false)
26941
+ // Color panel has no color plugin identifier, so we need to inspect all panel iframes to look for a plugin identifier inside
26942
+ Fit.Array.ForEach(document.querySelectorAll("div.cke_panel > iframe"), function(iframe)
26928
26943
  {
26929
- // Control not focused - make sure OnFocus fires when emoji button is clicked,
26930
- // and make sure ControlBase internally considers itself focused, so there is
26931
- // no risk of OnFocus being fired twice without OnBlur firing in between,
26932
- // when focus state is unlocked, and focus is perhaps re-assigned to another
26933
- // DOM element within the control, which will be the case if the design editor
26934
- // is switched back to an ordinary input field (e.g. using DesignMode(false)).
26935
- me.Focused(true);
26936
- }
26937
-
26938
- // Prevent control from firing OnBlur when emoji dialog is opened.
26939
- // Notice that locking the focus state will also prevent OnFocus
26940
- // from being fired automatically.
26941
- me._internal.FocusStateLocked(true);
26942
-
26943
- setTimeout(function() // Postpone - emoji panel is made visible after click event
26944
- {
26945
- // Allow light dismissable panels/callouts to prevent close/dismiss
26946
- // when interacting with emoji widget hosted outside of panels/callouts,
26947
- // by detecting the presence of a data-disable-light-dismiss="true" attribute.
26948
- var emojiPanel = document.querySelector("div.cke_emoji-panel"); // Shared among instances
26949
-
26950
- if (emojiPanel !== null) // Better safe than sorry
26944
+ if (iframe.contentDocument !== null) // Null if hosted on foreign domain
26951
26945
  {
26952
- Fit.Dom.Data(emojiPanel, "disable-light-dismiss", "true");
26953
-
26954
- emojiPanel._associatedFitUiControl = me;
26946
+ var colorBlock = iframe.contentDocument.querySelector("div.cke_colorblock");
26955
26947
 
26956
- designEditorActiveToolbarPanel =
26948
+ if (colorBlock !== null)
26957
26949
  {
26958
- DomElement: emojiPanel,
26959
- UnlockFocusStateIfEmojiPanelIsClosed: function() // Function called regularly via interval timer while emoji panel is open to make sure focus state is unlocked when emoji panel is closed, e.g. by pressing ESC, clicking outside of emoji panel, or by choosing an emoji
26960
- {
26961
- if (designModeEnabledAndReady() === false /* No longer in DesignMode */ || Fit.Dom.IsVisible(emojiPanel) === false /* Emoji panel closed */ || emojiPanel._associatedFitUiControl !== me /* Emoji panel now opened from another editor */)
26962
- {
26963
- designEditorActiveToolbarPanel = null;
26964
-
26965
- // Disable focus lock - let ControlBase handle OnFocus and OnBlur automatically again
26966
- me._internal.FocusStateLocked(false);
26967
-
26968
- // Fire OnBlur in case user changed focus while emoji panel was open.
26969
- // OnBlur does not fire automatically when focus state is locked.
26970
- if (me.Focused() === false)
26971
- {
26972
- me._internal.FireOnBlur();
26973
- }
26974
- }
26975
- },
26976
- CloseEmojiPanel: function()
26977
- {
26978
- if (emojiPanel._associatedFitUiControl === me && Fit.Dom.IsVisible(emojiPanel) === true && Fit.Dom.Contained(emojiPanel, Fit.Dom.GetFocused()) === true)
26979
- {
26980
- designEditor.focus();
26981
- designEditorActiveToolbarPanel.UnlockFocusStateIfEmojiPanelIsClosed();
26982
- }
26983
- }
26950
+ // Color panel found. Panel is shared between instances and used for both the
26951
+ // text color and back color. We know parentElement exists because of the query selector.
26952
+ panel = iframe.parentElement;
26953
+ return false; // Break loop
26984
26954
  }
26985
26955
  }
26956
+ });
26957
+
26958
+ return panel;
26959
+ });
26960
+ });
26961
+
26962
+ // Register necessary events with emoji panel when opened
26963
+
26964
+ var emojiButton = designEditor.container.$.querySelector("a.cke_button__emojipanel");
26965
+
26966
+ if (emojiButton !== null) // Button might not be enabled
26967
+ {
26968
+ lockDesignEditorDialogButtonToFocusState(emojiButton, function() // Callback invoked to get panel associated with button
26969
+ {
26970
+ var emojiPanel = document.querySelector("div.cke_emoji-panel"); // Shared among instances
26986
26971
 
26972
+ if (emojiPanel !== null) // Better safe than sorry
26973
+ {
26987
26974
  // Hide status bar in emoji dialog
26988
26975
  var emojiFrame = emojiPanel.querySelector("iframe");
26989
26976
  var emojiContent = emojiFrame && emojiFrame.contentDocument;
@@ -26991,31 +26978,9 @@ Fit.Controls.Input = function(ctlId)
26991
26978
  var emojiContentStatus = emojiContent && emojiContent.querySelector(".cke_emoji-status_bar");
26992
26979
  emojiContentBlock && (emojiContentBlock.style.height = "220px");
26993
26980
  emojiContentStatus && (emojiContentStatus.style.display = "none");
26981
+ }
26994
26982
 
26995
- var checkClosedId = setInterval(function()
26996
- {
26997
- // Invoke cleanup function regularly to make sure
26998
- // focus lock is relased when emoji panel is closed,
26999
- // and to fire OnBlur if another control was focused
27000
- // while emoji panel was open.
27001
-
27002
- if (me === null)
27003
- {
27004
- clearInterval(checkClosedId);
27005
- return;
27006
- }
27007
-
27008
- if (designEditorActiveToolbarPanel !== null)
27009
- {
27010
- designEditorActiveToolbarPanel.UnlockFocusStateIfEmojiPanelIsClosed(); // Nullfies designEditorActiveToolbarPanel if emoji panel is closed
27011
- }
27012
-
27013
- if (designEditorActiveToolbarPanel === null)
27014
- {
27015
- clearInterval(checkClosedId);
27016
- }
27017
- }, 250);
27018
- }, 0);
26983
+ return emojiPanel;
27019
26984
  });
27020
26985
  }
27021
26986
 
@@ -27484,7 +27449,105 @@ Fit.Controls.Input = function(ctlId)
27484
27449
 
27485
27450
  designEditorRestoreButtonState = null;
27486
27451
  }
27487
- };
27452
+ }
27453
+
27454
+ function lockDesignEditorDialogButtonToFocusState(button, getPanelCallback)
27455
+ {
27456
+ Fit.Validation.ExpectElement(button);
27457
+ Fit.Validation.ExpectFunction(getPanelCallback);
27458
+
27459
+ Fit.Events.AddHandler(button, "click", function(e)
27460
+ {
27461
+ // Make sure OnFocus fires before locking focus state
27462
+
27463
+ if (me.Focused() === false)
27464
+ {
27465
+ // Control not focused - make sure OnFocus fires when emoji button is clicked,
27466
+ // and make sure ControlBase internally considers itself focused, so there is
27467
+ // no risk of OnFocus being fired twice without OnBlur firing in between,
27468
+ // when focus state is unlocked, and focus is perhaps re-assigned to another
27469
+ // DOM element within the control, which will be the case if the design editor
27470
+ // is switched back to an ordinary input field (e.g. using DesignMode(false)).
27471
+ me.Focused(true);
27472
+ }
27473
+
27474
+ // Prevent control from firing OnBlur when emoji dialog is opened.
27475
+ // Notice that locking the focus state will also prevent OnFocus
27476
+ // from being fired automatically.
27477
+ me._internal.FocusStateLocked(true);
27478
+
27479
+ setTimeout(function() // Postpone - wait for dialog to be mounted in DOM
27480
+ {
27481
+ var panel = getPanelCallback(); // Panel is shared among instances
27482
+
27483
+ if (panel === null)
27484
+ {
27485
+ return;
27486
+ }
27487
+
27488
+ // Allow light dismissable panels/callouts to prevent close/dismiss
27489
+ // when interacting with emoji widget hosted outside of panels/callouts,
27490
+ // by detecting the presence of a data-disable-light-dismiss="true" attribute.
27491
+ Fit.Dom.Data(panel, "disable-light-dismiss", "true");
27492
+
27493
+ panel._associatedFitUiControl = me;
27494
+
27495
+ designEditorActiveToolbarPanel =
27496
+ {
27497
+ DomElement: panel,
27498
+ UnlockFocusStateIfEmojiPanelIsClosed: function() // Function called regularly via interval timer while emoji panel is open to make sure focus state is unlocked when emoji panel is closed, e.g. by pressing ESC, clicking outside of emoji panel, or by choosing an emoji
27499
+ {
27500
+ if (designModeEnabledAndReady() === false /* No longer in DesignMode */ || Fit.Dom.IsVisible(panel) === false /* Emoji panel closed */ || panel._associatedFitUiControl !== me /* Emoji panel now opened from another editor */)
27501
+ {
27502
+ designEditorActiveToolbarPanel = null;
27503
+
27504
+ // Disable focus lock - let ControlBase handle OnFocus and OnBlur automatically again
27505
+ me._internal.FocusStateLocked(false);
27506
+
27507
+ // Fire OnBlur in case user changed focus while emoji panel was open.
27508
+ // OnBlur does not fire automatically when focus state is locked.
27509
+ if (me.Focused() === false)
27510
+ {
27511
+ me._internal.FireOnBlur();
27512
+ }
27513
+ }
27514
+ },
27515
+ CloseEmojiPanel: function()
27516
+ {
27517
+ if (panel._associatedFitUiControl === me && Fit.Dom.IsVisible(panel) === true && Fit.Dom.Contained(panel, Fit.Dom.GetFocused()) === true)
27518
+ {
27519
+ designEditor.focus();
27520
+ designEditorActiveToolbarPanel.UnlockFocusStateIfEmojiPanelIsClosed();
27521
+ }
27522
+ }
27523
+ };
27524
+
27525
+ var checkClosedId = setInterval(function()
27526
+ {
27527
+ // Invoke cleanup function regularly to make sure
27528
+ // focus lock is relased when emoji panel is closed,
27529
+ // and to fire OnBlur if another control was focused
27530
+ // while emoji panel was open.
27531
+
27532
+ if (me === null)
27533
+ {
27534
+ clearInterval(checkClosedId);
27535
+ return;
27536
+ }
27537
+
27538
+ if (designEditorActiveToolbarPanel !== null)
27539
+ {
27540
+ designEditorActiveToolbarPanel.UnlockFocusStateIfEmojiPanelIsClosed(); // Nullfies designEditorActiveToolbarPanel if emoji panel is closed
27541
+ }
27542
+
27543
+ if (designEditorActiveToolbarPanel === null)
27544
+ {
27545
+ clearInterval(checkClosedId);
27546
+ }
27547
+ }, 250);
27548
+ }, 0);
27549
+ });
27550
+ }
27488
27551
 
27489
27552
  function updateDesignEditorSize()
27490
27553
  {