@ckeditor/ckeditor5-ui 46.1.1-alpha.3 → 47.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -717,7 +717,8 @@ const xhtmlNs = 'http://www.w3.org/1999/xhtml';
717
717
  * ```ts
718
718
  * attributes: {
719
719
  * style: {
720
- * color: 'red'
720
+ * color: 'red',
721
+ * '--color': 'red'
721
722
  * }
722
723
  * }
723
724
  * ```
@@ -727,7 +728,8 @@ const xhtmlNs = 'http://www.w3.org/1999/xhtml';
727
728
  * ```ts
728
729
  * attributes: {
729
730
  * style: {
730
- * color: bind.to( ... )
731
+ * color: bind.to( ... ),
732
+ * '--color': bind.to( ... )
731
733
  * }
732
734
  * }
733
735
  * ```
@@ -755,6 +757,8 @@ const xhtmlNs = 'http://www.w3.org/1999/xhtml';
755
757
  updater: getStyleUpdater(node, styleName),
756
758
  data
757
759
  });
760
+ } else if (isCssVariable(styleName)) {
761
+ node.style.setProperty(styleName, styleValue);
758
762
  } else {
759
763
  node.style[styleName] = styleValue;
760
764
  }
@@ -1040,6 +1044,19 @@ const xhtmlNs = 'http://www.w3.org/1999/xhtml';
1040
1044
  }
1041
1045
  return false;
1042
1046
  }
1047
+ /**
1048
+ * Checks whether the given name is a valid CSS variable name.
1049
+ *
1050
+ * A valid CSS variable name starts with two dashes (`--`), followed by a letter, underscore (`_`),
1051
+ * or dash (`-`), and can be followed by any combination of letters, digits, underscores, dashes,
1052
+ * or additional dashes.
1053
+ *
1054
+ * @param name The name to validate as a CSS variable.
1055
+ * @returns True if the name is a valid CSS variable, false otherwise.
1056
+ */ function isCssVariable(name) {
1057
+ const regex = /^--[a-zA-Z_-][\w-]*$/;
1058
+ return regex.test(name);
1059
+ }
1043
1060
  /**
1044
1061
  * Assembles the value using {@link module:ui/template~TemplateValueSchema} and stores it in a form of
1045
1062
  * an Array. Each entry of the Array corresponds to one of {@link module:ui/template~TemplateValueSchema}
@@ -1124,10 +1141,18 @@ const xhtmlNs = 'http://www.w3.org/1999/xhtml';
1124
1141
  */ function getStyleUpdater(el, styleName) {
1125
1142
  return {
1126
1143
  set (value) {
1127
- el.style[styleName] = value;
1144
+ if (isCssVariable(styleName)) {
1145
+ el.style.setProperty(styleName, value);
1146
+ } else {
1147
+ el.style[styleName] = value;
1148
+ }
1128
1149
  },
1129
1150
  remove () {
1130
- el.style[styleName] = null;
1151
+ if (isCssVariable(styleName)) {
1152
+ el.style.removeProperty(styleName);
1153
+ } else {
1154
+ el.style[styleName] = null;
1155
+ }
1131
1156
  }
1132
1157
  };
1133
1158
  }
@@ -3865,6 +3890,13 @@ const toPx$6 = /* #__PURE__ */ toUnit('px');
3865
3890
  }
3866
3891
  const defaultOffset = DialogView.defaultOffset;
3867
3892
  const dialogRect = this._getDialogRect();
3893
+ if (this.position == null) {
3894
+ return;
3895
+ } else if (typeof this.position == 'function') {
3896
+ const coords = this.position(dialogRect, domRootRect);
3897
+ this._moveTo(coords.left, coords.top);
3898
+ return;
3899
+ }
3868
3900
  // @if CK_DEBUG_DIALOG // RectDrawer.clear();
3869
3901
  // @if CK_DEBUG_DIALOG // RectDrawer.draw( viewportRect, { outlineColor: 'blue' }, 'Viewport' );
3870
3902
  switch(configuredPosition){
@@ -10406,7 +10438,7 @@ function addMenuToOpenDropdown(dropdownView, options) {
10406
10438
  const listItemView = new ListItemView(locale);
10407
10439
  let buttonView;
10408
10440
  if (def.type === 'button') {
10409
- buttonView = new ListItemButtonView(locale);
10441
+ buttonView = new ListItemButtonView(locale, def.labelView);
10410
10442
  buttonView.set({
10411
10443
  isToggleable
10412
10444
  });