@textbus/xnote 0.0.9 → 0.0.11
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/bundles/index.esm.js +44 -25
- package/bundles/index.js +44 -25
- package/package.json +1 -1
package/bundles/index.esm.js
CHANGED
|
@@ -1834,11 +1834,18 @@ function findNonIntersectingRectangles(rectangles) {
|
|
|
1834
1834
|
function getMaxRectangle(start, rectangles) {
|
|
1835
1835
|
let merged = start;
|
|
1836
1836
|
const remaining = [...rectangles];
|
|
1837
|
+
const unMerged = [];
|
|
1837
1838
|
while (remaining.length > 0) {
|
|
1838
1839
|
const current = remaining.shift();
|
|
1839
1840
|
if (current.intersects(merged)) {
|
|
1840
1841
|
merged = current.merge(merged);
|
|
1841
1842
|
}
|
|
1843
|
+
else {
|
|
1844
|
+
unMerged.push(current);
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
if (unMerged.length && merged !== start) {
|
|
1848
|
+
return getMaxRectangle(merged, unMerged);
|
|
1842
1849
|
}
|
|
1843
1850
|
return merged;
|
|
1844
1851
|
}
|
|
@@ -2073,13 +2080,13 @@ class TableComponent extends Component {
|
|
|
2073
2080
|
endIndex: i.length
|
|
2074
2081
|
};
|
|
2075
2082
|
});
|
|
2076
|
-
this.selection.setSelectedRanges(slotRanges);
|
|
2077
2083
|
this.tableSelection.set({
|
|
2078
2084
|
startColumn: 0,
|
|
2079
2085
|
endColumn: this.state.columnsConfig.length,
|
|
2080
2086
|
startRow: startIndex,
|
|
2081
2087
|
endRow: endIndex,
|
|
2082
2088
|
});
|
|
2089
|
+
this.selection.setSelectedRanges(slotRanges);
|
|
2083
2090
|
this.focus.next(true);
|
|
2084
2091
|
if (slotRanges.length) {
|
|
2085
2092
|
setTimeout(() => {
|
|
@@ -2108,13 +2115,13 @@ class TableComponent extends Component {
|
|
|
2108
2115
|
endIndex: i.length
|
|
2109
2116
|
};
|
|
2110
2117
|
});
|
|
2111
|
-
this.selection.setSelectedRanges(slotRanges);
|
|
2112
2118
|
this.tableSelection.set({
|
|
2113
2119
|
startColumn: startIndex,
|
|
2114
2120
|
endColumn: endIndex,
|
|
2115
2121
|
startRow: 0,
|
|
2116
2122
|
endRow: this.state.rows.length,
|
|
2117
2123
|
});
|
|
2124
|
+
this.selection.setSelectedRanges(slotRanges);
|
|
2118
2125
|
this.focus.next(true);
|
|
2119
2126
|
this.selection.restore();
|
|
2120
2127
|
this.textbus.focus();
|
|
@@ -5557,16 +5564,17 @@ function TopBar(props) {
|
|
|
5557
5564
|
});
|
|
5558
5565
|
return () => sub.unsubscribe();
|
|
5559
5566
|
});
|
|
5560
|
-
const instance = getCurrentInstance()
|
|
5567
|
+
// const instance = getCurrentInstance()
|
|
5561
5568
|
const s = props.component.changeMarker.onChange.subscribe(() => {
|
|
5562
|
-
|
|
5569
|
+
const currentLayout = props.component.state.columnsConfig.slice();
|
|
5570
|
+
if (currentLayout.join(',') !== props.layoutWidth().join(',')) {
|
|
5571
|
+
props.layoutWidth.set(currentLayout);
|
|
5572
|
+
}
|
|
5573
|
+
// instance.markAsDirtied()
|
|
5563
5574
|
});
|
|
5564
5575
|
onUnmounted(() => {
|
|
5565
5576
|
s.unsubscribe();
|
|
5566
5577
|
});
|
|
5567
|
-
function refreshLayoutWidth() {
|
|
5568
|
-
props.layoutWidth.set(props.component.state.columnsConfig.slice());
|
|
5569
|
-
}
|
|
5570
5578
|
return withScopedCSS(scopedId$4, () => {
|
|
5571
5579
|
const { state, tableSelection } = props.component;
|
|
5572
5580
|
const position = tableSelection();
|
|
@@ -5585,7 +5593,6 @@ function TopBar(props) {
|
|
|
5585
5593
|
transform: 'translateX(-50%)'
|
|
5586
5594
|
}, visible: !!selectedColumnRange(), children: jsx(ToolbarItem, { children: jsx(Button, { onClick: () => {
|
|
5587
5595
|
props.component.deleteColumns();
|
|
5588
|
-
refreshLayoutWidth();
|
|
5589
5596
|
}, children: jsx("span", { class: "xnote-icon-bin" }) }) }) }), jsx("table", { style: {
|
|
5590
5597
|
transform: `translateX(${-leftDistance()}px)`
|
|
5591
5598
|
}, children: jsx("tbody", { children: jsx("tr", { children: props.layoutWidth().map((i, index) => {
|
|
@@ -5597,14 +5604,12 @@ function TopBar(props) {
|
|
|
5597
5604
|
left: '-10px'
|
|
5598
5605
|
}, onClick: () => {
|
|
5599
5606
|
props.component.insertColumn(0);
|
|
5600
|
-
refreshLayoutWidth();
|
|
5601
5607
|
}, children: jsx("button", { class: "insert-btn", type: "button", children: "+" }) })), jsx("span", { class: "insert-btn-wrap", onMouseenter: () => {
|
|
5602
5608
|
tableService.onInsertColumnBefore.next(index + 1);
|
|
5603
5609
|
}, onMouseleave: () => {
|
|
5604
5610
|
tableService.onInsertColumnBefore.next(null);
|
|
5605
5611
|
}, onClick: () => {
|
|
5606
5612
|
props.component.insertColumn(index + 1);
|
|
5607
|
-
refreshLayoutWidth();
|
|
5608
5613
|
}, children: jsx("button", { class: "insert-btn", type: "button", children: "+" }) })] }) }));
|
|
5609
5614
|
}) }) }) })] }), jsx("div", { class: ['action-bar', { active: props.isFocus() }], children: jsx("table", { style: {
|
|
5610
5615
|
transform: `translateX(${-leftDistance()}px)`
|
|
@@ -5681,8 +5686,8 @@ function LeftBar(props) {
|
|
|
5681
5686
|
const actionBarRows = actionBarRef.current.rows;
|
|
5682
5687
|
setTimeout(() => {
|
|
5683
5688
|
Array.from(props.tableRef.current.rows).forEach((tr, i) => {
|
|
5684
|
-
const height = tr.
|
|
5685
|
-
Math.min(...Array.from(tr.children).map(i => i.
|
|
5689
|
+
const height = tr.getBoundingClientRect().height ||
|
|
5690
|
+
Math.min(...Array.from(tr.children).map(i => i.getBoundingClientRect().height)) || 0;
|
|
5686
5691
|
insertBarRows.item(i).style.height = height + 'px';
|
|
5687
5692
|
actionBarRows.item(i).style.height = height + 'px';
|
|
5688
5693
|
});
|
|
@@ -6206,24 +6211,25 @@ let TableSelectionAwarenessDelegate = class TableSelectionAwarenessDelegate exte
|
|
|
6206
6211
|
return false;
|
|
6207
6212
|
}
|
|
6208
6213
|
const rect = data.data || commonAncestorComponent.getMaxRectangle(findFocusCell(commonAncestorComponent, startSlot), findFocusCell(commonAncestorComponent, endSlot));
|
|
6209
|
-
const renderer = this.domAdapter;
|
|
6210
6214
|
if (!rect) {
|
|
6211
6215
|
return false;
|
|
6212
6216
|
}
|
|
6213
|
-
const
|
|
6214
|
-
const
|
|
6215
|
-
|
|
6216
|
-
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6217
|
+
const dom = this.domAdapter.getNativeNodeByComponent(commonAncestorComponent);
|
|
6218
|
+
const content = dom.querySelector('.xnote-table-content');
|
|
6219
|
+
const trs = content.querySelectorAll('tr');
|
|
6220
|
+
const cols = content.querySelectorAll('col');
|
|
6221
|
+
const top = trs[rect.y1].getBoundingClientRect().top;
|
|
6222
|
+
const left = cols[rect.x1].getBoundingClientRect().left;
|
|
6223
|
+
let height = trs[rect.y2 - 1].getBoundingClientRect().bottom - top;
|
|
6224
|
+
if (height === 0) {
|
|
6225
|
+
height = trs[rect.y2 - 1].children.item(0).getBoundingClientRect().bottom - top;
|
|
6226
|
+
}
|
|
6227
|
+
const width = cols[rect.x2 - 1].getBoundingClientRect().right - left;
|
|
6222
6228
|
return [{
|
|
6223
6229
|
left,
|
|
6224
6230
|
top,
|
|
6225
|
-
width
|
|
6226
|
-
height
|
|
6231
|
+
width,
|
|
6232
|
+
height
|
|
6227
6233
|
}];
|
|
6228
6234
|
}
|
|
6229
6235
|
};
|
|
@@ -6351,9 +6357,22 @@ class XNoteMessageBug extends MessageBus {
|
|
|
6351
6357
|
get() {
|
|
6352
6358
|
const selection = this.selection;
|
|
6353
6359
|
const c = selection.commonAncestorComponent;
|
|
6354
|
-
|
|
6360
|
+
const msg = Object.assign(Object.assign({}, this.userinfo), { selection: selection.getPaths() });
|
|
6361
|
+
if (!selection.isCollapsed && c instanceof TableComponent) {
|
|
6362
|
+
const selection = c.tableSelection();
|
|
6363
|
+
if (selection) {
|
|
6364
|
+
msg.data = {
|
|
6365
|
+
x1: selection.startColumn,
|
|
6366
|
+
x2: selection.endColumn,
|
|
6367
|
+
y1: selection.startRow,
|
|
6368
|
+
y2: selection.endRow,
|
|
6369
|
+
};
|
|
6370
|
+
}
|
|
6371
|
+
}
|
|
6372
|
+
return msg;
|
|
6355
6373
|
}
|
|
6356
6374
|
consume(message) {
|
|
6375
|
+
message = message.filter(i => i.message);
|
|
6357
6376
|
this.messageChangeEvent.next([...message]);
|
|
6358
6377
|
this.collaborateCursor.draw(message.filter(item => {
|
|
6359
6378
|
return item.message.id !== this.userinfo.id;
|
package/bundles/index.js
CHANGED
|
@@ -1836,11 +1836,18 @@ function findNonIntersectingRectangles(rectangles) {
|
|
|
1836
1836
|
function getMaxRectangle(start, rectangles) {
|
|
1837
1837
|
let merged = start;
|
|
1838
1838
|
const remaining = [...rectangles];
|
|
1839
|
+
const unMerged = [];
|
|
1839
1840
|
while (remaining.length > 0) {
|
|
1840
1841
|
const current = remaining.shift();
|
|
1841
1842
|
if (current.intersects(merged)) {
|
|
1842
1843
|
merged = current.merge(merged);
|
|
1843
1844
|
}
|
|
1845
|
+
else {
|
|
1846
|
+
unMerged.push(current);
|
|
1847
|
+
}
|
|
1848
|
+
}
|
|
1849
|
+
if (unMerged.length && merged !== start) {
|
|
1850
|
+
return getMaxRectangle(merged, unMerged);
|
|
1844
1851
|
}
|
|
1845
1852
|
return merged;
|
|
1846
1853
|
}
|
|
@@ -2075,13 +2082,13 @@ class TableComponent extends core$1.Component {
|
|
|
2075
2082
|
endIndex: i.length
|
|
2076
2083
|
};
|
|
2077
2084
|
});
|
|
2078
|
-
this.selection.setSelectedRanges(slotRanges);
|
|
2079
2085
|
this.tableSelection.set({
|
|
2080
2086
|
startColumn: 0,
|
|
2081
2087
|
endColumn: this.state.columnsConfig.length,
|
|
2082
2088
|
startRow: startIndex,
|
|
2083
2089
|
endRow: endIndex,
|
|
2084
2090
|
});
|
|
2091
|
+
this.selection.setSelectedRanges(slotRanges);
|
|
2085
2092
|
this.focus.next(true);
|
|
2086
2093
|
if (slotRanges.length) {
|
|
2087
2094
|
setTimeout(() => {
|
|
@@ -2110,13 +2117,13 @@ class TableComponent extends core$1.Component {
|
|
|
2110
2117
|
endIndex: i.length
|
|
2111
2118
|
};
|
|
2112
2119
|
});
|
|
2113
|
-
this.selection.setSelectedRanges(slotRanges);
|
|
2114
2120
|
this.tableSelection.set({
|
|
2115
2121
|
startColumn: startIndex,
|
|
2116
2122
|
endColumn: endIndex,
|
|
2117
2123
|
startRow: 0,
|
|
2118
2124
|
endRow: this.state.rows.length,
|
|
2119
2125
|
});
|
|
2126
|
+
this.selection.setSelectedRanges(slotRanges);
|
|
2120
2127
|
this.focus.next(true);
|
|
2121
2128
|
this.selection.restore();
|
|
2122
2129
|
this.textbus.focus();
|
|
@@ -5559,16 +5566,17 @@ function TopBar(props) {
|
|
|
5559
5566
|
});
|
|
5560
5567
|
return () => sub.unsubscribe();
|
|
5561
5568
|
});
|
|
5562
|
-
const instance =
|
|
5569
|
+
// const instance = getCurrentInstance()
|
|
5563
5570
|
const s = props.component.changeMarker.onChange.subscribe(() => {
|
|
5564
|
-
|
|
5571
|
+
const currentLayout = props.component.state.columnsConfig.slice();
|
|
5572
|
+
if (currentLayout.join(',') !== props.layoutWidth().join(',')) {
|
|
5573
|
+
props.layoutWidth.set(currentLayout);
|
|
5574
|
+
}
|
|
5575
|
+
// instance.markAsDirtied()
|
|
5565
5576
|
});
|
|
5566
5577
|
core.onUnmounted(() => {
|
|
5567
5578
|
s.unsubscribe();
|
|
5568
5579
|
});
|
|
5569
|
-
function refreshLayoutWidth() {
|
|
5570
|
-
props.layoutWidth.set(props.component.state.columnsConfig.slice());
|
|
5571
|
-
}
|
|
5572
5580
|
return scopedCss.withScopedCSS(scopedId$4, () => {
|
|
5573
5581
|
const { state, tableSelection } = props.component;
|
|
5574
5582
|
const position = tableSelection();
|
|
@@ -5587,7 +5595,6 @@ function TopBar(props) {
|
|
|
5587
5595
|
transform: 'translateX(-50%)'
|
|
5588
5596
|
}, visible: !!selectedColumnRange(), children: jsxRuntime.jsx(ToolbarItem, { children: jsxRuntime.jsx(Button, { onClick: () => {
|
|
5589
5597
|
props.component.deleteColumns();
|
|
5590
|
-
refreshLayoutWidth();
|
|
5591
5598
|
}, children: jsxRuntime.jsx("span", { class: "xnote-icon-bin" }) }) }) }), jsxRuntime.jsx("table", { style: {
|
|
5592
5599
|
transform: `translateX(${-leftDistance()}px)`
|
|
5593
5600
|
}, children: jsxRuntime.jsx("tbody", { children: jsxRuntime.jsx("tr", { children: props.layoutWidth().map((i, index) => {
|
|
@@ -5599,14 +5606,12 @@ function TopBar(props) {
|
|
|
5599
5606
|
left: '-10px'
|
|
5600
5607
|
}, onClick: () => {
|
|
5601
5608
|
props.component.insertColumn(0);
|
|
5602
|
-
refreshLayoutWidth();
|
|
5603
5609
|
}, children: jsxRuntime.jsx("button", { class: "insert-btn", type: "button", children: "+" }) })), jsxRuntime.jsx("span", { class: "insert-btn-wrap", onMouseenter: () => {
|
|
5604
5610
|
tableService.onInsertColumnBefore.next(index + 1);
|
|
5605
5611
|
}, onMouseleave: () => {
|
|
5606
5612
|
tableService.onInsertColumnBefore.next(null);
|
|
5607
5613
|
}, onClick: () => {
|
|
5608
5614
|
props.component.insertColumn(index + 1);
|
|
5609
|
-
refreshLayoutWidth();
|
|
5610
5615
|
}, children: jsxRuntime.jsx("button", { class: "insert-btn", type: "button", children: "+" }) })] }) }));
|
|
5611
5616
|
}) }) }) })] }), jsxRuntime.jsx("div", { class: ['action-bar', { active: props.isFocus() }], children: jsxRuntime.jsx("table", { style: {
|
|
5612
5617
|
transform: `translateX(${-leftDistance()}px)`
|
|
@@ -5683,8 +5688,8 @@ function LeftBar(props) {
|
|
|
5683
5688
|
const actionBarRows = actionBarRef.current.rows;
|
|
5684
5689
|
setTimeout(() => {
|
|
5685
5690
|
Array.from(props.tableRef.current.rows).forEach((tr, i) => {
|
|
5686
|
-
const height = tr.
|
|
5687
|
-
Math.min(...Array.from(tr.children).map(i => i.
|
|
5691
|
+
const height = tr.getBoundingClientRect().height ||
|
|
5692
|
+
Math.min(...Array.from(tr.children).map(i => i.getBoundingClientRect().height)) || 0;
|
|
5688
5693
|
insertBarRows.item(i).style.height = height + 'px';
|
|
5689
5694
|
actionBarRows.item(i).style.height = height + 'px';
|
|
5690
5695
|
});
|
|
@@ -6208,24 +6213,25 @@ let TableSelectionAwarenessDelegate = class TableSelectionAwarenessDelegate exte
|
|
|
6208
6213
|
return false;
|
|
6209
6214
|
}
|
|
6210
6215
|
const rect = data.data || commonAncestorComponent.getMaxRectangle(findFocusCell(commonAncestorComponent, startSlot), findFocusCell(commonAncestorComponent, endSlot));
|
|
6211
|
-
const renderer = this.domAdapter;
|
|
6212
6216
|
if (!rect) {
|
|
6213
6217
|
return false;
|
|
6214
6218
|
}
|
|
6215
|
-
const
|
|
6216
|
-
const
|
|
6217
|
-
|
|
6218
|
-
|
|
6219
|
-
|
|
6220
|
-
|
|
6221
|
-
|
|
6222
|
-
|
|
6223
|
-
|
|
6219
|
+
const dom = this.domAdapter.getNativeNodeByComponent(commonAncestorComponent);
|
|
6220
|
+
const content = dom.querySelector('.xnote-table-content');
|
|
6221
|
+
const trs = content.querySelectorAll('tr');
|
|
6222
|
+
const cols = content.querySelectorAll('col');
|
|
6223
|
+
const top = trs[rect.y1].getBoundingClientRect().top;
|
|
6224
|
+
const left = cols[rect.x1].getBoundingClientRect().left;
|
|
6225
|
+
let height = trs[rect.y2 - 1].getBoundingClientRect().bottom - top;
|
|
6226
|
+
if (height === 0) {
|
|
6227
|
+
height = trs[rect.y2 - 1].children.item(0).getBoundingClientRect().bottom - top;
|
|
6228
|
+
}
|
|
6229
|
+
const width = cols[rect.x2 - 1].getBoundingClientRect().right - left;
|
|
6224
6230
|
return [{
|
|
6225
6231
|
left,
|
|
6226
6232
|
top,
|
|
6227
|
-
width
|
|
6228
|
-
height
|
|
6233
|
+
width,
|
|
6234
|
+
height
|
|
6229
6235
|
}];
|
|
6230
6236
|
}
|
|
6231
6237
|
};
|
|
@@ -6353,9 +6359,22 @@ class XNoteMessageBug extends collaborate.MessageBus {
|
|
|
6353
6359
|
get() {
|
|
6354
6360
|
const selection = this.selection;
|
|
6355
6361
|
const c = selection.commonAncestorComponent;
|
|
6356
|
-
|
|
6362
|
+
const msg = Object.assign(Object.assign({}, this.userinfo), { selection: selection.getPaths() });
|
|
6363
|
+
if (!selection.isCollapsed && c instanceof TableComponent) {
|
|
6364
|
+
const selection = c.tableSelection();
|
|
6365
|
+
if (selection) {
|
|
6366
|
+
msg.data = {
|
|
6367
|
+
x1: selection.startColumn,
|
|
6368
|
+
x2: selection.endColumn,
|
|
6369
|
+
y1: selection.startRow,
|
|
6370
|
+
y2: selection.endRow,
|
|
6371
|
+
};
|
|
6372
|
+
}
|
|
6373
|
+
}
|
|
6374
|
+
return msg;
|
|
6357
6375
|
}
|
|
6358
6376
|
consume(message) {
|
|
6377
|
+
message = message.filter(i => i.message);
|
|
6359
6378
|
this.messageChangeEvent.next([...message]);
|
|
6360
6379
|
this.collaborateCursor.draw(message.filter(item => {
|
|
6361
6380
|
return item.message.id !== this.userinfo.id;
|
package/package.json
CHANGED