@opentiny/fluent-editor 3.18.2 → 3.18.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/index.es.js CHANGED
@@ -14939,8 +14939,9 @@ class TableCellLine extends Block$1 {
14939
14939
  const identityMaker = key === "row" ? rowId : cellId;
14940
14940
  node.setAttribute(`data-${key}`, value[key] || identityMaker());
14941
14941
  });
14942
- CELL_ATTRIBUTES.forEach((attrName) => {
14943
- node.setAttribute(`data-${attrName}`, value[attrName] || CELL_DEFAULT[attrName]);
14942
+ [...CELL_ATTRIBUTES, "cell-bg"].forEach((attrName) => {
14943
+ const keyValue = value[attrName] || CELL_DEFAULT[attrName];
14944
+ keyValue && node.setAttribute(`data-${attrName}`, keyValue);
14944
14945
  });
14945
14946
  if (value.height) {
14946
14947
  node.setAttribute("height", value.height);
@@ -14952,7 +14953,7 @@ class TableCellLine extends Block$1 {
14952
14953
  if (formats["list"]) {
14953
14954
  formats["list"] = domNode.classList.item(0);
14954
14955
  }
14955
- return reduceFormats(domNode, formats);
14956
+ return reduceFormats(domNode, formats, ["cell-bg"]);
14956
14957
  }
14957
14958
  toggleAttribute(name, value) {
14958
14959
  if (value) {
@@ -14999,22 +15000,22 @@ class TableCellLine extends Block$1 {
14999
15000
  switch (true) {
15000
15001
  case name === "cell-bg": {
15001
15002
  this.toggleAttribute("data-cell-bg", value);
15002
- this.formatChildren(name, value);
15003
15003
  }
15004
15004
  }
15005
15005
  }
15006
15006
  optimize(context) {
15007
15007
  super.optimize(context);
15008
- const { row, cell, rowspan, colspan } = this.domNode.dataset;
15008
+ const { row, cell, rowspan, colspan, cellBg } = this.domNode.dataset;
15009
15009
  const formats = TableCellLine.formats(this.domNode);
15010
15010
  const parentFormats = this.parent.formats();
15011
15011
  if (this.statics.requiredContainer && !(this.parent instanceof this.statics.requiredContainer)) {
15012
- this.wrap(this.statics.requiredContainer.blotName, { row, cell, rowspan, colspan });
15012
+ this.wrap(this.statics.requiredContainer.blotName, { row, cell, rowspan, colspan, cellBg });
15013
15013
  } else if (!compare(formats, parentFormats)) {
15014
15014
  this.parent.format("row", formats.row);
15015
15015
  this.parent.format("cell", formats.cell);
15016
15016
  this.parent.format("rowspan", formats.rowspan);
15017
15017
  this.parent.format("colspan", formats.colspan);
15018
+ formats["cell-bg"] && this.parent.setCellBg(formats["cell-bg"]);
15018
15019
  }
15019
15020
  const parentHeight = this.domNode.getAttribute("height");
15020
15021
  if (parentHeight) {
@@ -15108,6 +15109,13 @@ class TableCell extends Container {
15108
15109
  child.format(name, value);
15109
15110
  });
15110
15111
  }
15112
+ setCellBg(value) {
15113
+ if (value) {
15114
+ this.domNode.style.backgroundColor = value;
15115
+ } else {
15116
+ this.domNode.style.backgroundColor = "initial";
15117
+ }
15118
+ }
15111
15119
  format(name, value) {
15112
15120
  const quill = Quill.find(this.scroll.domNode.parentNode);
15113
15121
  switch (true) {
@@ -15137,11 +15145,7 @@ class TableCell extends Container {
15137
15145
  this.toggleAttribute("data-cell-bg", value);
15138
15146
  this.toggleAttribute("data-parent-bg", value);
15139
15147
  this.formatChildren(name, value);
15140
- if (value) {
15141
- this.domNode.style.backgroundColor = value;
15142
- } else {
15143
- this.domNode.style.backgroundColor = "initial";
15144
- }
15148
+ this.setCellBg(value);
15145
15149
  }
15146
15150
  }
15147
15151
  }
@@ -15855,8 +15859,8 @@ function cellId() {
15855
15859
  const id = Math.random().toString(36).slice(2, 6);
15856
15860
  return `cell-${id}`;
15857
15861
  }
15858
- function reduceFormats(domNode, formats) {
15859
- return CELL_ATTRIBUTES.concat(CELL_IDENTITY_KEYS).reduce((tableFormats, attribute) => {
15862
+ function reduceFormats(domNode, formats, extraFormat = []) {
15863
+ return [...CELL_ATTRIBUTES, ...CELL_IDENTITY_KEYS, ...extraFormat].reduce((tableFormats, attribute) => {
15860
15864
  if (domNode.hasAttribute(`data-${attribute}`)) {
15861
15865
  tableFormats[attribute] = domNode.getAttribute(`data-${attribute}`) || void 0;
15862
15866
  }