1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-07 21:47:02 +09:00

JS-5004: fix

This commit is contained in:
Andrew Simachev 2025-02-28 00:54:11 +01:00
parent d90e19bad0
commit 58408d4350
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF
3 changed files with 40 additions and 30 deletions

View file

@ -5,7 +5,7 @@ npx lint-staged --concurrent false
# npm run typecheck
# Checking for secrets
# gitleaks protect --verbose --redact --staged
gitleaks protect --verbose --redact --staged
# Checking dependencies' licenses
npx license-checker --production --json --out licenses.json

View file

@ -27,6 +27,7 @@ const BlockTable = observer(class BlockTable extends React.Component<I.BlockComp
rowId = '';
cellId = '';
data: any = {};
frameResize = 0;
constructor (props: I.BlockComponent) {
super(props);
@ -165,6 +166,7 @@ const BlockTable = observer(class BlockTable extends React.Component<I.BlockComp
unbind () {
const { block } = this.props;
$(window).off(`resize.${block.id}`);
$(this.node).off('resizeInit resizeMove');
};
rebind () {
@ -173,6 +175,7 @@ const BlockTable = observer(class BlockTable extends React.Component<I.BlockComp
this.unbind();
win.on(`resize.${block.id}`, () => raf(() => this.resize()));
$(this.node).on('resizeInit resizeMove', e => this.resize());
};
getData () {
@ -1530,35 +1533,41 @@ const BlockTable = observer(class BlockTable extends React.Component<I.BlockComp
const row = node.find(`#row-${rows[0].id}`);
const obj = $(`#block-${block.id}`);
let width = J.Size.blockMenu + 10;
let maxWidth = 0;
let wrapperWidth = 0;
String(row.css('grid-template-columns') || '').split(' ').forEach(it => width += parseInt(it));
obj.css({ width: 'auto' });
if (parent.isPage() || parent.isLayoutDiv()) {
const container = U.Common.getPageContainer(isPopup);
maxWidth = container.width() - PADDING;
wrapperWidth = getWrapperWidth() + J.Size.blockMenu;
wrap.toggleClass('withScroll', width > maxWidth);
width = Math.max(wrapperWidth, Math.min(maxWidth, width));
obj.css({
width: (width >= wrapperWidth) ? width : 'auto',
marginLeft: (width >= wrapperWidth) ? Math.min(0, (wrapperWidth - width) / 2) : '',
});
} else {
const parentObj = $(`#block-${parent.id}`);
if (parentObj.length) {
maxWidth = parentObj.width() - J.Size.blockMenu;
};
wrap.toggleClass('withScroll', width > maxWidth);
if (this.frameResize) {
raf.cancel(this.frameResize);
};
this.frameResize = raf(() => {
let width = J.Size.blockMenu + 10;
let maxWidth = 0;
let wrapperWidth = 0;
String(row.css('grid-template-columns') || '').split(' ').forEach(it => width += parseInt(it));
obj.css({ width: 'auto', marginLeft: 0 });
if (parent.isPage() || parent.isLayoutDiv()) {
const container = U.Common.getPageContainer(isPopup);
maxWidth = container.width() - PADDING;
wrapperWidth = getWrapperWidth() + J.Size.blockMenu;
wrap.toggleClass('withScroll', width > maxWidth);
width = Math.max(wrapperWidth, Math.min(maxWidth, width));
obj.css({
width: (width >= wrapperWidth) ? width : 'auto',
marginLeft: (width >= wrapperWidth) ? Math.min(0, (wrapperWidth - width) / 2) : '',
});
} else {
const parentObj = $(`#block-${parent.id}`);
if (parentObj.length) {
maxWidth = parentObj.width() - J.Size.blockMenu;
};
wrap.toggleClass('withScroll', width > maxWidth);
};
});
};
});

View file

@ -2319,7 +2319,6 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
const cover = node.find('.block.blockCover');
const pageContainer = U.Common.getPageContainer(isPopup);
const header = pageContainer.find('#header');
const root = S.Block.getLeaf(rootId, rootId);
const scrollContainer = U.Common.getScrollContainer(isPopup);
const hh = isPopup ? header.height() : J.Size.header;
@ -2393,6 +2392,8 @@ const EditorPage = observer(class EditorPage extends React.Component<Props, Stat
this.refHeader.refDrag.setValue(v);
this.refHeader.setPercent(v);
};
$('.resizable').trigger('resizeInit');
};
getWidth (w: number) {