Merge remote-tracking branch 'upstream/develop' into account-menu-split-fix
This commit is contained in:
@@ -27,7 +27,10 @@ const SearchOptions = observer(({ appState }: Props) => {
|
|||||||
} = searchOptions;
|
} = searchOptions;
|
||||||
|
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [optionsPanelTop, setOptionsPanelTop] = useState(0);
|
const [position, setPosition] = useState({
|
||||||
|
top: 0,
|
||||||
|
right: 0,
|
||||||
|
});
|
||||||
const buttonRef = useRef<HTMLButtonElement>();
|
const buttonRef = useRef<HTMLButtonElement>();
|
||||||
const panelRef = useRef<HTMLDivElement>();
|
const panelRef = useRef<HTMLDivElement>();
|
||||||
const [closeOnBlur, setLockCloseOnBlur] = useCloseOnBlur(panelRef, setOpen);
|
const [closeOnBlur, setLockCloseOnBlur] = useCloseOnBlur(panelRef, setOpen);
|
||||||
@@ -45,9 +48,12 @@ const SearchOptions = observer(({ appState }: Props) => {
|
|||||||
<Disclosure
|
<Disclosure
|
||||||
open={open}
|
open={open}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
const { height } = buttonRef.current.getBoundingClientRect();
|
const rect = buttonRef.current.getBoundingClientRect();
|
||||||
setOptionsPanelTop(height);
|
setPosition({
|
||||||
setOpen((prevOpen) => !prevOpen);
|
top: rect.bottom,
|
||||||
|
right: document.body.clientWidth - rect.right,
|
||||||
|
});
|
||||||
|
setOpen(!open);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<DisclosureButton
|
<DisclosureButton
|
||||||
@@ -61,9 +67,9 @@ const SearchOptions = observer(({ appState }: Props) => {
|
|||||||
<DisclosurePanel
|
<DisclosurePanel
|
||||||
ref={panelRef}
|
ref={panelRef}
|
||||||
style={{
|
style={{
|
||||||
top: optionsPanelTop,
|
...position,
|
||||||
}}
|
}}
|
||||||
className="sn-dropdown sn-dropdown--anchor-right sn-dropdown--animated min-w-80 absolute grid gap-2 py-2"
|
className="sn-dropdown sn-dropdown--animated min-w-80 fixed grid gap-2 py-2"
|
||||||
onBlur={closeOnBlur}
|
onBlur={closeOnBlur}
|
||||||
>
|
>
|
||||||
<Switch
|
<Switch
|
||||||
|
|||||||
@@ -61,10 +61,11 @@ class HistoryMenuCtrl extends PureViewCtrl<unknown, HistoryState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async openSessionRevision(revision: HistoryEntry) {
|
async openSessionRevision(revision: HistoryEntry & { previewTitle: () => string }) {
|
||||||
this.application.presentRevisionPreviewModal(
|
this.application.presentRevisionPreviewModal(
|
||||||
revision.payload.uuid,
|
revision.payload.uuid,
|
||||||
revision.payload.content
|
revision.payload.content,
|
||||||
|
revision.previewTitle()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +85,8 @@ class HistoryMenuCtrl extends PureViewCtrl<unknown, HistoryState> {
|
|||||||
}
|
}
|
||||||
this.application.presentRevisionPreviewModal(
|
this.application.presentRevisionPreviewModal(
|
||||||
remoteRevision.payload.uuid,
|
remoteRevision.payload.uuid,
|
||||||
remoteRevision.payload.content
|
remoteRevision.payload.content,
|
||||||
|
this.previewRemoteHistoryTitle(revision)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +156,7 @@ class HistoryMenuCtrl extends PureViewCtrl<unknown, HistoryState> {
|
|||||||
this.reloadState();
|
this.reloadState();
|
||||||
}
|
}
|
||||||
|
|
||||||
previewRemoteHistoryTitle(revision: SingleRevision) {
|
previewRemoteHistoryTitle(revision: RevisionListEntry) {
|
||||||
return new Date(revision.created_at).toLocaleString();
|
return new Date(revision.created_at).toLocaleString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ class RevisionPreviewModalCtrl extends PureViewCtrl implements RevisionPreviewSc
|
|||||||
$timeout: ng.ITimeoutService
|
$timeout: ng.ITimeoutService
|
||||||
uuid!: string
|
uuid!: string
|
||||||
content!: PayloadContent
|
content!: PayloadContent
|
||||||
|
title?: string
|
||||||
application!: WebApplication
|
application!: WebApplication
|
||||||
unregisterComponent?: any
|
unregisterComponent?: any
|
||||||
note!: SNNote
|
note!: SNNote
|
||||||
@@ -139,6 +140,7 @@ export class RevisionPreviewModal extends WebDirective {
|
|||||||
this.scope = {
|
this.scope = {
|
||||||
uuid: '=',
|
uuid: '=',
|
||||||
content: '=',
|
content: '=',
|
||||||
|
title: '=',
|
||||||
application: '='
|
application: '='
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -189,13 +189,14 @@ export class WebApplication extends SNApplication {
|
|||||||
this.applicationElement.append(el);
|
this.applicationElement.append(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
presentRevisionPreviewModal(uuid: string, content: any) {
|
presentRevisionPreviewModal(uuid: string, content: any, title?: string) {
|
||||||
const scope: any = this.scope!.$new(true);
|
const scope: any = this.scope!.$new(true);
|
||||||
scope.uuid = uuid;
|
scope.uuid = uuid;
|
||||||
scope.content = content;
|
scope.content = content;
|
||||||
|
scope.title = title;
|
||||||
scope.application = this;
|
scope.application = this;
|
||||||
const el = this.$compile!(
|
const el = this.$compile!(
|
||||||
`<revision-preview-modal application='application' uuid='uuid' content='content'
|
`<revision-preview-modal application='application' uuid='uuid' content='content' title='title'
|
||||||
class='sk-modal'></revision-preview-modal>`
|
class='sk-modal'></revision-preview-modal>`
|
||||||
)(scope);
|
)(scope);
|
||||||
this.applicationElement.append(el);
|
this.applicationElement.append(el);
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
public editorValues: EditorValues = { title: '', text: '' };
|
public editorValues: EditorValues = { title: '', text: '' };
|
||||||
onEditorLoad?: () => void;
|
onEditorLoad?: () => void;
|
||||||
|
|
||||||
|
private scrollPosition = 0;
|
||||||
private removeAltKeyObserver?: any;
|
private removeAltKeyObserver?: any;
|
||||||
private removeTrashKeyObserver?: any;
|
private removeTrashKeyObserver?: any;
|
||||||
private removeTabObserver?: any;
|
private removeTabObserver?: any;
|
||||||
@@ -131,6 +132,8 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
|
|
||||||
this.editorMenuOnSelect = this.editorMenuOnSelect.bind(this);
|
this.editorMenuOnSelect = this.editorMenuOnSelect.bind(this);
|
||||||
this.onPanelResizeFinish = this.onPanelResizeFinish.bind(this);
|
this.onPanelResizeFinish = this.onPanelResizeFinish.bind(this);
|
||||||
|
this.setScrollPosition = this.setScrollPosition.bind(this);
|
||||||
|
this.resetScrollPosition = this.resetScrollPosition.bind(this);
|
||||||
this.onEditorLoad = () => {
|
this.onEditorLoad = () => {
|
||||||
this.application!.getDesktopService().redoSearch();
|
this.application!.getDesktopService().redoSearch();
|
||||||
};
|
};
|
||||||
@@ -868,6 +871,20 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setScrollPosition() {
|
||||||
|
const editor = document.getElementById(
|
||||||
|
ElementIds.NoteTextEditor
|
||||||
|
) as HTMLInputElement;
|
||||||
|
this.scrollPosition = editor.scrollTop;
|
||||||
|
}
|
||||||
|
|
||||||
|
resetScrollPosition() {
|
||||||
|
const editor = document.getElementById(
|
||||||
|
ElementIds.NoteTextEditor
|
||||||
|
) as HTMLInputElement;
|
||||||
|
editor.scrollTop = this.scrollPosition;
|
||||||
|
}
|
||||||
|
|
||||||
onSystemEditorLoad() {
|
onSystemEditorLoad() {
|
||||||
if (this.removeTabObserver) {
|
if (this.removeTabObserver) {
|
||||||
return;
|
return;
|
||||||
@@ -915,6 +932,9 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
editor.addEventListener('scroll', this.setScrollPosition);
|
||||||
|
editor.addEventListener('input', this.resetScrollPosition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles when the editor is destroyed,
|
* Handles when the editor is destroyed,
|
||||||
* (and not when our controller is destroyed.)
|
* (and not when our controller is destroyed.)
|
||||||
@@ -922,6 +942,9 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
|
|||||||
angular.element(editor).one('$destroy', () => {
|
angular.element(editor).one('$destroy', () => {
|
||||||
this.removeTabObserver?.();
|
this.removeTabObserver?.();
|
||||||
this.removeTabObserver = undefined;
|
this.removeTabObserver = undefined;
|
||||||
|
editor.removeEventListener('scroll', this.setScrollPosition);
|
||||||
|
editor.removeEventListener('scroll', this.resetScrollPosition);
|
||||||
|
this.scrollPosition = 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
|
|||||||
break;
|
break;
|
||||||
case ApplicationEvent.CompletedFullSync:
|
case ApplicationEvent.CompletedFullSync:
|
||||||
this.getMostValidNotes().then((notes) => {
|
this.getMostValidNotes().then((notes) => {
|
||||||
if (notes.length === 0 && this.selectedTag?.isAllTag) {
|
if (notes.length === 0 && this.selectedTag?.isAllTag && this.state.noteFilter.text === '') {
|
||||||
this.createPlaceholderNote();
|
this.createPlaceholderNote();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,11 @@
|
|||||||
.sn-component
|
.sn-component
|
||||||
.sk-panel
|
.sk-panel
|
||||||
.sk-panel-header
|
.sk-panel-header
|
||||||
.sk-panel-header-title Preview
|
div
|
||||||
|
.sk-panel-header-title Preview
|
||||||
|
.sk-subtitle.neutral.mt-1(
|
||||||
|
ng-if="ctrl.title"
|
||||||
|
) {{ctrl.title}}
|
||||||
.sk-horizontal-group
|
.sk-horizontal-group
|
||||||
a.sk-a.info.close-button(
|
a.sk-a.info.close-button(
|
||||||
ng-click="ctrl.restore(false)"
|
ng-click="ctrl.restore(false)"
|
||||||
|
|||||||
Reference in New Issue
Block a user