@textbus/xnote 0.2.2 → 0.2.4

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.
@@ -2613,7 +2613,7 @@ class TableComponent extends Component {
2613
2613
  };
2614
2614
  const start = getSelfSlot(this.selection.startSlot);
2615
2615
  const end = getSelfSlot(this.selection.endSlot);
2616
- if (start && end && start !== end) {
2616
+ if (start && end) {
2617
2617
  return this.getMaxRectangle(start, end);
2618
2618
  }
2619
2619
  return null;
@@ -4984,6 +4984,10 @@ function UndoTool() {
4984
4984
  }
4985
4985
 
4986
4986
  const cellAlignAttr = new Attribute('cellAlign', {
4987
+ onlySelf: true,
4988
+ checkHost(host) {
4989
+ return host.parent instanceof TableComponent;
4990
+ },
4987
4991
  render(node, formatValue) {
4988
4992
  node.styles.set('verticalAlign', formatValue);
4989
4993
  }
@@ -5112,6 +5116,10 @@ function CellAlignTool() {
5112
5116
  }
5113
5117
 
5114
5118
  const cellBackgroundAttr = new Attribute('cellBackground', {
5119
+ onlySelf: true,
5120
+ checkHost(host) {
5121
+ return host.parent instanceof TableComponent;
5122
+ },
5115
5123
  render(node, formatValue) {
5116
5124
  const rgba = parseCss(formatValue);
5117
5125
  if (rgba) {
@@ -5158,7 +5166,9 @@ function CellBackgroundTool() {
5158
5166
  }).flat().forEach(slot => {
5159
5167
  const rgba = picker.rgba;
5160
5168
  if (rgba) {
5161
- slot.setAttribute(cellBackgroundAttr, `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`);
5169
+ slot.setAttribute(cellBackgroundAttr, `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`, s => {
5170
+ return slot === s;
5171
+ });
5162
5172
  }
5163
5173
  else {
5164
5174
  slot.removeAttribute(cellBackgroundAttr);
@@ -6783,8 +6793,10 @@ function SelectionMask(props) {
6783
6793
  watch(props.component.tableSelection, update);
6784
6794
  function update() {
6785
6795
  const selection = props.component.tableSelection();
6796
+ const selectedSlots = props.component.getSelectedNormalizedSlots();
6797
+ const slotCount = selectedSlots ? selectedSlots.map(i => i.cells.filter(i => i.visible)).flat().length : 0;
6786
6798
  const state = props.component.state;
6787
- if (selection) {
6799
+ if (selection && slotCount > 1) {
6788
6800
  let topCompensation = 0.5;
6789
6801
  let heightCompensation = -1;
6790
6802
  if (selection.startRow === 0) {
@@ -6984,10 +6996,12 @@ const TableComponentView = withAnnotation({
6984
6996
  }) }, rowMapping.get(row.row)));
6985
6997
  }) })] }) }) }) }));
6986
6998
  }
6999
+ const selectedSlots = props.component.getSelectedNormalizedSlots();
7000
+ const slotCount = selectedSlots ? selectedSlots.map(i => i.cells.filter(i => i.visible)).flat().length : 0;
6987
7001
  return (jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": `[${state.columnsConfig.join(',')}]`, children: jsxs("div", { class: "xnote-table-inner", ref: props.rootRef, children: [jsx(TopBar, { isFocus: isFocus, layoutWidth: layoutWidth, component: props.component }), jsx(LeftBar, { tableRef: tableRef, isFocus: isFocus, component: props.component }), jsx(Scroll, { isFocus: isFocus, children: jsxs("div", { class: "xnote-table-container", children: [jsxs("table", { ref: tableRef, class: [
6988
7002
  'xnote-table-content',
6989
7003
  {
6990
- 'hide-selection': props.component.tableSelection()
7004
+ 'hide-selection': props.component.tableSelection() && slotCount > 1
6991
7005
  }
6992
7006
  ], children: [jsx("colgroup", { children: layoutWidth().map(w => {
6993
7007
  return jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
package/bundles/index.js CHANGED
@@ -2615,7 +2615,7 @@ class TableComponent extends core$1.Component {
2615
2615
  };
2616
2616
  const start = getSelfSlot(this.selection.startSlot);
2617
2617
  const end = getSelfSlot(this.selection.endSlot);
2618
- if (start && end && start !== end) {
2618
+ if (start && end) {
2619
2619
  return this.getMaxRectangle(start, end);
2620
2620
  }
2621
2621
  return null;
@@ -4986,6 +4986,10 @@ function UndoTool() {
4986
4986
  }
4987
4987
 
4988
4988
  const cellAlignAttr = new core$1.Attribute('cellAlign', {
4989
+ onlySelf: true,
4990
+ checkHost(host) {
4991
+ return host.parent instanceof TableComponent;
4992
+ },
4989
4993
  render(node, formatValue) {
4990
4994
  node.styles.set('verticalAlign', formatValue);
4991
4995
  }
@@ -5114,6 +5118,10 @@ function CellAlignTool() {
5114
5118
  }
5115
5119
 
5116
5120
  const cellBackgroundAttr = new core$1.Attribute('cellBackground', {
5121
+ onlySelf: true,
5122
+ checkHost(host) {
5123
+ return host.parent instanceof TableComponent;
5124
+ },
5117
5125
  render(node, formatValue) {
5118
5126
  const rgba = color.parseCss(formatValue);
5119
5127
  if (rgba) {
@@ -5160,7 +5168,9 @@ function CellBackgroundTool() {
5160
5168
  }).flat().forEach(slot => {
5161
5169
  const rgba = picker.rgba;
5162
5170
  if (rgba) {
5163
- slot.setAttribute(cellBackgroundAttr, `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`);
5171
+ slot.setAttribute(cellBackgroundAttr, `rgba(${rgba.r}, ${rgba.g}, ${rgba.b}, ${rgba.a})`, s => {
5172
+ return slot === s;
5173
+ });
5164
5174
  }
5165
5175
  else {
5166
5176
  slot.removeAttribute(cellBackgroundAttr);
@@ -6785,8 +6795,10 @@ function SelectionMask(props) {
6785
6795
  core.watch(props.component.tableSelection, update);
6786
6796
  function update() {
6787
6797
  const selection = props.component.tableSelection();
6798
+ const selectedSlots = props.component.getSelectedNormalizedSlots();
6799
+ const slotCount = selectedSlots ? selectedSlots.map(i => i.cells.filter(i => i.visible)).flat().length : 0;
6788
6800
  const state = props.component.state;
6789
- if (selection) {
6801
+ if (selection && slotCount > 1) {
6790
6802
  let topCompensation = 0.5;
6791
6803
  let heightCompensation = -1;
6792
6804
  if (selection.startRow === 0) {
@@ -6986,10 +6998,12 @@ const TableComponentView = core.withAnnotation({
6986
6998
  }) }, rowMapping.get(row.row)));
6987
6999
  }) })] }) }) }) }));
6988
7000
  }
7001
+ const selectedSlots = props.component.getSelectedNormalizedSlots();
7002
+ const slotCount = selectedSlots ? selectedSlots.map(i => i.cells.filter(i => i.visible)).flat().length : 0;
6989
7003
  return (jsxRuntime.jsx("div", { class: "xnote-table", "data-component": props.component.name, "data-layout-width": `[${state.columnsConfig.join(',')}]`, children: jsxRuntime.jsxs("div", { class: "xnote-table-inner", ref: props.rootRef, children: [jsxRuntime.jsx(TopBar, { isFocus: isFocus, layoutWidth: layoutWidth, component: props.component }), jsxRuntime.jsx(LeftBar, { tableRef: tableRef, isFocus: isFocus, component: props.component }), jsxRuntime.jsx(Scroll, { isFocus: isFocus, children: jsxRuntime.jsxs("div", { class: "xnote-table-container", children: [jsxRuntime.jsxs("table", { ref: tableRef, class: [
6990
7004
  'xnote-table-content',
6991
7005
  {
6992
- 'hide-selection': props.component.tableSelection()
7006
+ 'hide-selection': props.component.tableSelection() && slotCount > 1
6993
7007
  }
6994
7008
  ], children: [jsxRuntime.jsx("colgroup", { children: layoutWidth().map(w => {
6995
7009
  return jsxRuntime.jsx("col", { style: { width: w + 'px', minWidth: w + 'px' } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/xnote",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "A high-performance rich text editor that supports multiplayer online collaboration.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -27,10 +27,10 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@tanbo/color": "^0.1.1",
30
- "@textbus/adapter-viewfly": "^4.2.5",
31
- "@textbus/collaborate": "^4.2.4",
32
- "@textbus/core": "^4.2.4",
33
- "@textbus/platform-browser": "^4.2.5",
30
+ "@textbus/adapter-viewfly": "^4.3.0",
31
+ "@textbus/collaborate": "^4.3.0",
32
+ "@textbus/core": "^4.3.0",
33
+ "@textbus/platform-browser": "^4.3.0",
34
34
  "@viewfly/core": "^1.1.1",
35
35
  "@viewfly/hooks": "^1.1.1",
36
36
  "@viewfly/platform-browser": "^1.1.1",