Skip to content

Commit

Permalink
fix: wrong selection layer position in table popup body (#1744)
Browse files Browse the repository at this point in the history
* fix: wrong selection layer position in table popup body

* fix: change meta mark to calculated property in custom block
  • Loading branch information
js87zz authored Aug 10, 2021
1 parent f7a5b02 commit 7347499
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
6 changes: 5 additions & 1 deletion apps/editor/src/markdown/plugins/helper/markInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ function customBlock(node: MdNode, start: MdPos, end: MdPos) {

if (info) {
marks.push(
markInfo(addOffsetPos(start, 2), addOffsetPos(start, syntaxLength + info.length), META)
markInfo(
addOffsetPos(start, syntaxEnd),
addOffsetPos(start, syntaxLength + info.length),
META
)
);
}

Expand Down
16 changes: 7 additions & 9 deletions apps/editor/src/ui/components/toolbar/tablePopupBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,16 @@ export class TablePopupBody extends Component<Props, State> {
return range;
}

mounted() {
const { left, top } = this.refs.tableEl.getBoundingClientRect();

this.offsetRect = {
left: window.pageXOffset + left,
top: window.pageYOffset + top,
};
}

updated() {
if (!this.props.show) {
this.setState({ colIdx: -1, rowIdx: -1 });
} else if (this.state.colIdx === -1 && this.state.rowIdx === -1) {
const { left, top } = this.refs.tableEl.getBoundingClientRect();

this.offsetRect = {
left: window.pageXOffset + left,
top: window.pageYOffset + top,
};
}
}

Expand Down

0 comments on commit 7347499

Please sign in to comment.