mirror of
https://github.com/anyproto/anytype-ts.git
synced 2025-06-08 05:57:02 +09:00
CU-fx42t2: Fix scrollContainer when saving scroll positions in Popup
This commit is contained in:
parent
52052678d1
commit
952e66a56f
5 changed files with 78 additions and 73 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -15,3 +15,4 @@ dist/*.node
|
|||
*.txt
|
||||
src/json/schema
|
||||
dist/bundle-back.js
|
||||
dist/builder-debug.yml
|
|
@ -239,6 +239,7 @@ class Cell extends React.Component<Props, {}> {
|
|||
case I.RelationType.LongText:
|
||||
param = Object.assign(param, {
|
||||
element: cell,
|
||||
horizontal: I.MenuDirection.Left,
|
||||
offsetY: -height,
|
||||
width: width,
|
||||
});
|
||||
|
@ -306,6 +307,7 @@ class Cell extends React.Component<Props, {}> {
|
|||
|
||||
if (menuId) {
|
||||
menuStore.closeAll(Constant.menuIds.cell);
|
||||
|
||||
if (commonStore.cellId != cellId) {
|
||||
window.setTimeout(() => {
|
||||
commonStore.cellId = cellId;
|
||||
|
|
|
@ -124,7 +124,6 @@ class EditorPage extends React.Component<Props, {}> {
|
|||
|
||||
win.on('mousemove.editor' + namespace, throttle((e: any) => { this.onMouseMove(e); }, THROTTLE));
|
||||
win.on('keydown.editor' + namespace, (e: any) => { this.onKeyDownEditor(e); });
|
||||
win.on('scroll.editor' + namespace, (e: any) => { this.onScroll(e); });
|
||||
win.on('paste.editor' + namespace, (e: any) => {
|
||||
if (!keyboard.isFocused) {
|
||||
this.onPaste(e);
|
||||
|
@ -134,10 +133,12 @@ class EditorPage extends React.Component<Props, {}> {
|
|||
focus.apply();
|
||||
this.getScrollContainer().scrollTop(this.scrollTop);
|
||||
});
|
||||
|
||||
|
||||
this.resize();
|
||||
win.on('resize.editor' + namespace, (e: any) => { this.resize(); });
|
||||
|
||||
this.getScrollContainer().on('scroll.editor' + namespace, (e: any) => { this.onScroll(e); });
|
||||
|
||||
Storage.set('askSurvey', 1);
|
||||
|
||||
ipcRenderer.removeAllListeners('commandEditor');
|
||||
|
@ -192,7 +193,7 @@ class EditorPage extends React.Component<Props, {}> {
|
|||
};
|
||||
|
||||
open (skipInit?: boolean) {
|
||||
const { rootId, onOpen, history } = this.props;
|
||||
const { rootId, onOpen, history, isPopup } = this.props;
|
||||
const { breadcrumbs } = blockStore;
|
||||
|
||||
// Fix editor refresh without breadcrumbs init, skipInit flag prevents recursion
|
||||
|
@ -230,7 +231,7 @@ class EditorPage extends React.Component<Props, {}> {
|
|||
this.focusTitle();
|
||||
this.forceUpdate();
|
||||
this.resize();
|
||||
this.getScrollContainer().scrollTop(Storage.getScroll('editor', rootId));
|
||||
this.getScrollContainer().scrollTop(Storage.getScroll('editor' + (isPopup ? 'Popup' : ''), rootId));
|
||||
|
||||
blockStore.setNumbers(rootId);
|
||||
|
||||
|
@ -1026,15 +1027,15 @@ class EditorPage extends React.Component<Props, {}> {
|
|||
};
|
||||
|
||||
onScroll (e: any) {
|
||||
const { rootId } = this.props;
|
||||
const top = $(window).scrollTop();
|
||||
const { rootId, isPopup } = this.props;
|
||||
const top = this.getScrollContainer().scrollTop();
|
||||
|
||||
if (Math.abs(top - this.scrollTop) >= 10) {
|
||||
this.uiHide();
|
||||
};
|
||||
|
||||
|
||||
this.scrollTop = top;
|
||||
Storage.setScroll('editor', rootId, top);
|
||||
Storage.setScroll('editor' + (isPopup ? 'Popup' : ''), rootId, top);
|
||||
Util.linkPreviewHide(false);
|
||||
};
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ class PopupShortcut extends React.Component<Props, State> {
|
|||
render () {
|
||||
const { page } = this.state;
|
||||
const platform = Util.getPlatform();
|
||||
const isMac = platform == I.Platform.Mac;
|
||||
const tabs = [
|
||||
{ id: 'main', name: 'Main' },
|
||||
{ id: 'navigation', name: 'Navigation' },
|
||||
|
@ -60,7 +61,7 @@ class PopupShortcut extends React.Component<Props, State> {
|
|||
const Item = (item: any) => {
|
||||
return (
|
||||
<div className="item">
|
||||
<div className="key">{(platform == I.Platform.Mac) && item.mac ? item.mac : item.com}</div>
|
||||
<div className="key" dangerouslySetInnerHTML={{ __html: isMac && item.mac ? item.mac : item.com }} />
|
||||
<div className="descr">{item.name}</div>
|
||||
</div>
|
||||
);
|
||||
|
@ -106,19 +107,19 @@ class PopupShortcut extends React.Component<Props, State> {
|
|||
main: [
|
||||
{
|
||||
name: 'Basics', children: [
|
||||
{ mac: '⌘ + N', com: 'Ctrl + N', name: 'Create a new page on the dashboard' },
|
||||
{ mac: '⌘ + O', com: 'Ctrl + O', name: 'Open the navigation pane' },
|
||||
{ mac: '⌘ + S', com: 'Ctrl + S', name: 'Open the search pane' },
|
||||
{ mac: '⌘ + Enter', com: 'Alt + H', name: 'Return to the home screen' },
|
||||
{ mac: '⌘ + [', com: 'Alt + ←', name: 'Show the previous page from history' },
|
||||
{ mac: '⌘ + ]', com: 'Alt + →', name: 'Show the next page from history' },
|
||||
{ mac: '⌘ + Z', com: 'Ctrl + Z', name: 'Undo' },
|
||||
{ mac: '⌘ + Shift + Z', com: 'Ctrl + Shift + Z', name: 'Redo' },
|
||||
{ mac: '⌘ + P', com: 'Ctrl + P', name: 'Print' },
|
||||
{ mac: '⌘ + F', com: 'Ctrl + F', name: 'Find on page' },
|
||||
{ mac: '⌘ + Q', com: 'Ctrl + Q', name: 'Close Anytype' },
|
||||
{ mac: '⌘ + Y', com: 'Ctrl + H', name: 'Show page edit history' },
|
||||
{ mac: '⌘ + Click', com: 'Ctrl + Click', name: 'On page link will open it in modal view' },
|
||||
{ mac: '⌘ + N', com: 'Ctrl + N', name: 'Create a new page on the dashboard' },
|
||||
{ mac: '⌘ + O', com: 'Ctrl + O', name: 'Open the navigation pane' },
|
||||
{ mac: '⌘ + S', com: 'Ctrl + S', name: 'Open the search pane' },
|
||||
{ mac: '⌘ + Enter', com: 'Alt + H', name: 'Return to the home screen' },
|
||||
{ mac: '⌘ + [', com: 'Alt + ←', name: 'Show the previous page from history' },
|
||||
{ mac: '⌘ + ]', com: 'Alt + →', name: 'Show the next page from history' },
|
||||
{ mac: '⌘ + Z', com: 'Ctrl + Z', name: 'Undo' },
|
||||
{ mac: '⌘ + Shift + Z', com: 'Ctrl + Shift + Z', name: 'Redo' },
|
||||
{ mac: '⌘ + P', com: 'Ctrl + P', name: 'Print' },
|
||||
{ mac: '⌘ + F', com: 'Ctrl + F', name: 'Find on page' },
|
||||
{ mac: '⌘ + Q', com: 'Ctrl + Q', name: 'Close Anytype' },
|
||||
{ mac: '⌘ + Y', com: 'Ctrl + H', name: 'Show page edit history' },
|
||||
{ mac: '⌘ + Click', com: 'Ctrl + Click', name: 'On page link will open it in modal view' },
|
||||
]
|
||||
},
|
||||
|
||||
|
@ -136,33 +137,33 @@ class PopupShortcut extends React.Component<Props, State> {
|
|||
name: 'Selection', children: [
|
||||
{ com: 'Double Click', name: 'Select word' },
|
||||
{ com: 'Triple Click', name: 'Select an entire block' },
|
||||
{ mac: '⌘ + A', com: 'Ctrl + A', name: 'Select all blocks in the page' },
|
||||
{ com: 'Shift + ↑ or ↓', name: 'Expand your selection up or down' },
|
||||
{ mac: '⌘ + Click', com: 'Ctrl + Click', name: 'On block will select or de-select an entire block' },
|
||||
{ com: 'Shift + Click', name: 'Select block and all blocks in between' },
|
||||
{ mac: '⌘ + A', com: 'Ctrl + A', name: 'Select all blocks in the page' },
|
||||
{ com: 'Shift + ↑ or ↓', name: 'Expand your selection up or down' },
|
||||
{ mac: '⌘ + Click', com: 'Ctrl + Click', name: 'On block will select or de-select an entire block' },
|
||||
{ com: 'Shift + Click', name: 'Select block and all blocks in between' },
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
name: 'Actions', children: [
|
||||
{ com: '/', name: 'Activate command menu' },
|
||||
{ mac: '⌘ + /', com: 'Ctrl + /', name: 'Open action menu' },
|
||||
{ mac: '⌘ + Delete', com: 'Ctrl + Backspace', name: 'Deletes the words left to the cursor' },
|
||||
{ mac: '⌘ + C', com: 'Ctrl + C', name: 'Copy selected block/blocks or text part' },
|
||||
{ mac: '⌘ + X', com: 'Ctrl + X', name: 'Cut selected block/blocks or text part' },
|
||||
{ mac: '⌘ + V', com: 'Ctrl + V', name: 'Paste data outside Anytype, block/blocks or text part' },
|
||||
{ mac: '⌘ + D', com: 'Ctrl + D', name: 'Duplicate selected block/blocks' },
|
||||
{ mac: '⌘ + E', com: 'Ctrl + E', name: 'Launch emoji menu' },
|
||||
{ com: '/', name: 'Activate command menu' },
|
||||
{ mac: '⌘ + /', com: 'Ctrl + /', name: 'Open action menu' },
|
||||
{ mac: '⌘ + Delete', com: 'Ctrl + Backspace', name: 'Deletes the words left to the cursor' },
|
||||
{ mac: '⌘ + C', com: 'Ctrl + C', name: 'Copy selected block/blocks or text part' },
|
||||
{ mac: '⌘ + X', com: 'Ctrl + X', name: 'Cut selected block/blocks or text part' },
|
||||
{ mac: '⌘ + V', com: 'Ctrl + V', name: 'Paste data outside Anytype, block/blocks or text part' },
|
||||
{ mac: '⌘ + D', com: 'Ctrl + D', name: 'Duplicate selected block/blocks' },
|
||||
{ mac: '⌘ + E', com: 'Ctrl + E', name: 'Launch emoji menu' },
|
||||
]
|
||||
},
|
||||
|
||||
{
|
||||
name: 'Text style', children: [
|
||||
{ mac: '⌘ + B', com: 'Ctrl + B', name: 'Bold' },
|
||||
{ mac: '⌘ + I', com: 'Ctrl + I', name: 'Italic' },
|
||||
{ mac: '⌘ + Shift +S', com: 'Ctrl + Shift + S', name: 'Strikethrough' },
|
||||
{ mac: '⌘ + K', com: 'Ctrl + K', name: 'Add a link' },
|
||||
{ mac: '⌘ + L', com: 'Ctrl + L', name: 'Convert to Inline code' },
|
||||
{ mac: '⌘ + B', com: 'Ctrl + B', name: 'Bold' },
|
||||
{ mac: '⌘ + I', com: 'Ctrl + I', name: 'Italic' },
|
||||
{ mac: '⌘ + Shift +S', com: 'Ctrl + Shift + S', name: 'Strikethrough' },
|
||||
{ mac: '⌘ + K', com: 'Ctrl + K', name: 'Add a link' },
|
||||
{ mac: '⌘ + L', com: 'Ctrl + L', name: 'Convert to Inline code' },
|
||||
]
|
||||
},
|
||||
],
|
||||
|
@ -180,12 +181,12 @@ class PopupShortcut extends React.Component<Props, State> {
|
|||
|
||||
{
|
||||
name: 'Page navigation', children: [
|
||||
{ com: '↓', name: 'Go down one line' },
|
||||
{ com: '↑', name: 'Go up one line' },
|
||||
{ mac: '⌘ + ←', com: 'Ctrl + ←', name: 'Go to the start of the line' },
|
||||
{ mac: '⌘ + →', com: 'Ctrl + →', name: 'Go to the end of the line' },
|
||||
{ mac: '⌘ + ↑', com: 'Ctrl + ↑', name: 'Go to the start of the page' },
|
||||
{ mac: '⌘ + ↓', com: 'Ctrl + ↓', name: 'Go to the end of the page' },
|
||||
{ com: '↓', name: 'Go down one line' },
|
||||
{ com: '↑', name: 'Go up one line' },
|
||||
{ mac: '⌘ + ←', com: 'Ctrl + ←', name: 'Go to the start of the line' },
|
||||
{ mac: '⌘ + →', com: 'Ctrl + →', name: 'Go to the end of the line' },
|
||||
{ mac: '⌘ + ↑', com: 'Ctrl + ↑', name: 'Go to the start of the page' },
|
||||
{ mac: '⌘ + ↓', com: 'Ctrl + ↓', name: 'Go to the end of the page' },
|
||||
]
|
||||
},
|
||||
],
|
||||
|
|
|
@ -74,34 +74,6 @@ class Crumbs {
|
|||
return obj;
|
||||
};
|
||||
|
||||
addCrumbs (id: string) {
|
||||
let cr = this.get(I.CrumbsType.Page);
|
||||
let lastTargetId = '';
|
||||
|
||||
if (cr.ids.length) {
|
||||
lastTargetId = cr.ids[cr.ids.length - 1];
|
||||
};
|
||||
if (!lastTargetId || (lastTargetId != id)) {
|
||||
cr = this.add(I.CrumbsType.Page, id);
|
||||
};
|
||||
this.save(I.CrumbsType.Page, cr);
|
||||
};
|
||||
|
||||
addRecent (id: string) {
|
||||
if (!id) {
|
||||
return;
|
||||
};
|
||||
|
||||
let recent = this.get(I.CrumbsType.Recent);
|
||||
recent = this.add(I.CrumbsType.Recent, id);
|
||||
|
||||
recent.ids = Util.arrayUnique(recent.ids);
|
||||
if (recent.ids.length > LIMIT_RECENT) {
|
||||
recent.ids = recent.ids.slice(recent.ids.length - LIMIT_RECENT, recent.ids.length);
|
||||
};
|
||||
this.save(I.CrumbsType.Recent, recent);
|
||||
};
|
||||
|
||||
save (key: I.CrumbsType, obj: CrumbsObject, callBack?: () => void) {
|
||||
if (!obj) {
|
||||
return;
|
||||
|
@ -130,6 +102,34 @@ class Crumbs {
|
|||
delete (key: I.CrumbsType) {
|
||||
Storage.delete(this.getKey(key));
|
||||
};
|
||||
|
||||
addCrumbs (id: string) {
|
||||
let cr = this.get(I.CrumbsType.Page);
|
||||
let lastTargetId = '';
|
||||
|
||||
if (cr.ids.length) {
|
||||
lastTargetId = cr.ids[cr.ids.length - 1];
|
||||
};
|
||||
if (!lastTargetId || (lastTargetId != id)) {
|
||||
cr = this.add(I.CrumbsType.Page, id);
|
||||
};
|
||||
this.save(I.CrumbsType.Page, cr);
|
||||
};
|
||||
|
||||
addRecent (id: string) {
|
||||
if (!id) {
|
||||
return;
|
||||
};
|
||||
|
||||
let recent = this.get(I.CrumbsType.Recent);
|
||||
recent = this.add(I.CrumbsType.Recent, id);
|
||||
|
||||
recent.ids = Util.arrayUnique(recent.ids);
|
||||
if (recent.ids.length > LIMIT_RECENT) {
|
||||
recent.ids = recent.ids.slice(recent.ids.length - LIMIT_RECENT, recent.ids.length);
|
||||
};
|
||||
this.save(I.CrumbsType.Recent, recent);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue