Merge branch 'release/3.8.10' into main

This commit is contained in:
Antonella Sgarlatta
2021-06-24 14:36:30 -03:00
12 changed files with 62 additions and 22 deletions

View File

@@ -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

View File

@@ -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();
} }
} }

View File

@@ -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: '='
}; };
} }

View File

@@ -4,7 +4,7 @@ import { WebApplication } from "../application";
export class SearchOptionsState { export class SearchOptionsState {
includeProtectedContents = false; includeProtectedContents = false;
includeArchived = true; includeArchived = false;
includeTrashed = false; includeTrashed = false;
constructor( constructor(

View File

@@ -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);

View File

@@ -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;
}); });
} }
} }

View File

@@ -132,7 +132,7 @@
ng-class="{'selected' : self.isNoteSelected(note.uuid) }" ng-class="{'selected' : self.isNoteSelected(note.uuid) }"
ng-click='self.selectNote(note, true)' ng-click='self.selectNote(note, true)'
) )
.note-flags(ng-show='self.noteFlags[note.uuid].length > 0') .note-flags.flex.flex-wrap(ng-show='self.noteFlags[note.uuid].length > 0')
.flag(ng-class='flag.class', ng-repeat='flag in self.noteFlags[note.uuid]') .flag(ng-class='flag.class', ng-repeat='flag in self.noteFlags[note.uuid]')
.label {{flag.text}} .label {{flag.text}}
.name(ng-show='note.title') .name(ng-show='note.title')

View File

@@ -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();
} }
}); });

View File

@@ -169,6 +169,7 @@
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
margin-bottom: 8px; margin-bottom: 8px;
margin-top: -4px;
.flag { .flag {
padding: 4px; padding: 4px;
@@ -176,6 +177,7 @@
padding-right: 6px; padding-right: 6px;
border-radius: var(--sn-stylekit-general-border-radius); border-radius: var(--sn-stylekit-general-border-radius);
margin-right: 4px; margin-right: 4px;
margin-top: 4px;
&.info { &.info {
background-color: var(--sn-stylekit-info-color); background-color: var(--sn-stylekit-info-color);

View File

@@ -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)"

View File

@@ -1,6 +1,6 @@
{ {
"name": "standard-notes-web", "name": "standard-notes-web",
"version": "3.8.9", "version": "3.8.10",
"license": "AGPL-3.0-or-later", "license": "AGPL-3.0-or-later",
"repository": { "repository": {
"type": "git", "type": "git",
@@ -71,7 +71,7 @@
"@reach/checkbox": "^0.13.2", "@reach/checkbox": "^0.13.2",
"@reach/dialog": "^0.13.0", "@reach/dialog": "^0.13.0",
"@standardnotes/sncrypto-web": "1.2.10", "@standardnotes/sncrypto-web": "1.2.10",
"@standardnotes/snjs": "2.7.6", "@standardnotes/snjs": "2.7.7",
"mobx": "^6.1.6", "mobx": "^6.1.6",
"mobx-react-lite": "^3.2.0", "mobx-react-lite": "^3.2.0",
"preact": "^10.5.12" "preact": "^10.5.12"

View File

@@ -1936,10 +1936,10 @@
"@standardnotes/sncrypto-common" "^1.2.7" "@standardnotes/sncrypto-common" "^1.2.7"
libsodium-wrappers "^0.7.8" libsodium-wrappers "^0.7.8"
"@standardnotes/snjs@2.7.6": "@standardnotes/snjs@2.7.7":
version "2.7.6" version "2.7.7"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.7.6.tgz#f0b965bfad61e93af6803ec2698c02b1489d1073" resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.7.7.tgz#5a88269271c322889e67b4904cf63d040d09726e"
integrity sha512-E1Gj02gWvqypVpPed2YCSUnMUi2ZqFsb8NT2Jo8dqFS6Wk3FMzptWlFM/DuTifyzaYsmwPkXv1v5KpeU+dA+CQ== integrity sha512-trxDkLVtGM5XuewrZvMojoRQ7t3AQ4vuMNrGi6RNlCnhRV1evPYwn8Iq6N2fGCQ4GWjBYRddbG91xC7zAgkG+w==
dependencies: dependencies:
"@standardnotes/auth" "^2.0.0" "@standardnotes/auth" "^2.0.0"
"@standardnotes/sncrypto-common" "^1.2.9" "@standardnotes/sncrypto-common" "^1.2.9"