1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-12 02:30:41 +09:00

embed fixes

This commit is contained in:
Andrew Simachev 2024-01-17 16:22:40 +01:00
parent 824daf5cff
commit 627349dd19
No known key found for this signature in database
GPG key ID: 49A163D0D14E6FD8
3 changed files with 21 additions and 10 deletions

View file

@ -27,6 +27,7 @@
html.align1 .twitter-tweet, body.align1 .instagram-media { justify-content: center; }
html.align2 .twitter-tweet, body.align2 .instagram-media { justify-content: flex-end; }
html.isChart canvas { background: #fff; }
html.isKroki #root img { max-width: 100%; background: #fff; }
</style>
</head>

View file

@ -248,7 +248,7 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component<I.BlockComp
unbind () {
const { block } = this.props;
const events = [ 'mousedown', 'online', 'offline', 'scroll', 'resize' ];
const events = [ 'mousedown', 'mouseup', 'online', 'offline', 'scroll', 'resize' ];
$(window).off(events.map(it => `${it}.${block.id}`).join(' '));
};
@ -287,7 +287,8 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component<I.BlockComp
const length = this.text.length;
this.setRange({ from: length, to: length });
} else {
$(window).off(`mousedown.${block.id}`);
$(window).off(`mouseup.${block.id} mousedown.${block.id}`);
keyboard.disableSelection(false);
};
});
};
@ -832,12 +833,14 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component<I.BlockComp
return;
};
const { block } = this.props;
keyboard.disableSelection(true);
const win = $(window);
win.off('mouseup.embed').on('mouseup.embed', () => {
win.off(`mouseup.${block.id}`).on(`mouseup.${block.id}`, () => {
keyboard.disableSelection(false);
win.off('mouseup.embed');
win.off(`mouseup.${block.id}`);
});
};
@ -854,7 +857,7 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component<I.BlockComp
const win = $(window);
focus.set(block.id, { from: 0, to: 0 });
win.off('mousemove.embed mouseup.embed');
win.off(`mousemove.${block.id} mouseup.${block.id}`);
if (selection) {
selection.hide();
@ -864,8 +867,8 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component<I.BlockComp
keyboard.disableSelection(true);
$(`#block-${block.id}`).addClass('isResizing');
win.on('mousemove.embed', e => this.onResizeMove(e, checkMax));
win.on('mouseup.embed', e => this.onResizeEnd(e, checkMax));
win.on(`mousemove.${block.id}`, e => this.onResizeMove(e, checkMax));
win.on(`mouseup.${block.id}`, e => this.onResizeEnd(e, checkMax));
};
onResizeMove (e: any, checkMax: boolean) {
@ -914,7 +917,7 @@ const BlockEmbed = observer(class BlockEmbed extends React.Component<I.BlockComp
keyboard.setResize(false);
keyboard.disableSelection(false);
win.off('mousemove.embed mouseup.embed');
win.off(`mousemove.${block.id} mouseup.${block.id}`);
$(`#block-${block.id}`).removeClass('isResizing');
C.BlockListSetFields(rootId, [

View file

@ -55,9 +55,14 @@ class UtilEmbed {
};
getCodepenHtml (content: string): string {
const a = new URL(content);
const p = a.pathname.split('/');
let p = [];
try {
const a = new URL(content);
p = a.pathname.split('/');
} catch (e) { /**/ };
if (!p.length) {
return '';
};
@ -350,6 +355,7 @@ class UtilEmbed {
I.EmbedProcessor.GithubGist,
I.EmbedProcessor.Codepen,
I.EmbedProcessor.Kroki,
I.EmbedProcessor.Chart,
].includes(p);
};
@ -389,6 +395,7 @@ class UtilEmbed {
I.EmbedProcessor.GithubGist,
I.EmbedProcessor.Codepen,
I.EmbedProcessor.Kroki,
I.EmbedProcessor.Chart,
].includes(p);
};