Skip to content

Commit

Permalink
Merge branch 'dev' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavotoyota committed Jul 26, 2023
2 parents d8ed0a5 + 6216397 commit 8839375
Show file tree
Hide file tree
Showing 28 changed files with 211 additions and 130 deletions.
3 changes: 2 additions & 1 deletion apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@deepnotes/client",
"description": "DeepNotes",
"homepage": "https://deepnotes.app",
"version": "1.0.4",
"version": "1.0.5",
"author": "Gustavo Toyota <[email protected]>",
"dependencies": {
"@_ueberdosis/prosemirror-tables": "1.1.3",
Expand Down Expand Up @@ -54,6 +54,7 @@
"dotenv": "16.0.3",
"dotenv-expand": "9.0.0",
"downloadjs": "^1.4.7",
"electron-context-menu": "^3.6.1",
"electron-log": "^4.4.8",
"electron-updater": "4.3.1",
"express": "4.18.2",
Expand Down
4 changes: 2 additions & 2 deletions apps/client/src-capacitor/android/app/version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Mon Jul 24 09:09:25 AMT 2023
VERSION_CODE=41
#Wed Jul 26 15:09:36 AMT 2023
VERSION_CODE=42
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
PRODUCT_BUNDLE_IDENTIFIER = app.deepnotes;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand All @@ -382,7 +382,7 @@
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.productivity";
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 1.0.3;
PRODUCT_BUNDLE_IDENTIFIER = app.deepnotes;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
18 changes: 8 additions & 10 deletions apps/client/src-electron/electron-main.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { app, BrowserWindow, ipcMain, nativeTheme } from 'electron';
import { app, BrowserWindow, ipcMain, nativeTheme, shell } from 'electron';
import cookie from 'cookie';
import path from 'path';
import os from 'os';
import log from 'electron-log';
import { autoUpdater } from 'electron-updater';
import contextMenu from 'electron-context-menu';

contextMenu({
showSaveImageAs: true,
});

log.transports.file.level = 'info';

Expand Down Expand Up @@ -83,15 +88,8 @@ function createWindow() {
}

mainWindow.webContents.setWindowOpenHandler((details) => {
return {
action: 'allow',
overrideBrowserWindowOptions: {
autoHideMenuBar: true,
webPreferences: {
devTools: false,
},
},
};
shell.openExternal(details.url);
return { action: 'deny' };
});

mainWindow.on('closed', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,12 @@ export function usePageNavigationInterception() {
event.preventDefault(); // Prevent default

const matches =
href.match(/\/(?:pages|groups)\/([\w-]{21})(?:\?note=([\w-]{21}))?/) ??
[];
href.match(
/\/(?:pages|groups)\/([\w-]{21})(?:\?(?:note|elem)=([\w-]{21}))?/,
) ?? [];

const id = matches[1];
const noteId = matches[2];
const elemId = matches[2];

if (href.includes('/groups/')) {
await internals.pages.goToGroup(id, {
Expand All @@ -75,7 +76,7 @@ export function usePageNavigationInterception() {
await internals.pages.goToPage(id, {
fromParent: true,
openInNewTab: isCtrlDown(event),
noteId,
elemId,
});
}
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/code/pages/page/elems/find-and-replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class PageFindAndReplace {
editor.commands.setTextSelection(result);
editor.commands.focus(undefined, { scrollIntoView: false });

scrollIntoView(resultElems[this.resultIndex] as HTMLElement, {
scrollIntoView(resultElems[this.resultIndex], {
centerCamera: true,
});
}
Expand Down
27 changes: 13 additions & 14 deletions apps/client/src/code/pages/page/notes/note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export interface INoteReact extends IRegionReact, IElemReact {
color: ComputedRef<string>;

link: {
url: ComputedRef<string>;
external: ComputedRef<boolean>;
};

Expand Down Expand Up @@ -460,7 +461,7 @@ export class PageNote extends PageElem() implements IPageRegion {
return 'default';
}

if (this.react.collab.link) {
if (this.react.link.url) {
return 'pointer';
}

Expand All @@ -476,26 +477,24 @@ export class PageNote extends PageElem() implements IPageRegion {
),

link: {
external: computed(() => {
if (this.react.collab.link == null) {
return false;
url: computed(() => {
if (!this.react.collab.link) {
return '';
}

if (
!this.react.collab.link.startsWith('http://') &&
!this.react.collab.link.startsWith('https://')
) {
return false;
if (this.react.collab.link.startsWith('/')) {
return `https://deepnotes.app${this.react.collab.link}`;
}

if (
this.react.collab.link.startsWith('http://deepnotes.app/pages/')
) {
return false;
if (!this.react.collab.link.includes('://')) {
return `https://deepnotes.app/${this.react.collab.link}`;
}

return true;
return this.react.collab.link;
}),
external: computed(
() => !this.react.link.url.startsWith('https://deepnotes.app/pages/'),
),
},

editors: computed(() => {
Expand Down
32 changes: 20 additions & 12 deletions apps/client/src/code/pages/page/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,18 +300,26 @@ export class Page implements IPageRegion {

mainLogger.sub('page.finishSetup').info('All notes loaded');

const noteId = (route().value.query.note as string) ?? '';

if (isNanoID(noteId)) {
const note = this.notes.fromId(noteId);

if (note != null) {
this.selection.set(note);

const noteElem = note.getElem('note-frame');

if (noteElem != null) {
scrollIntoView(noteElem, { animate: false, centerCamera: true });
const elemId =
((route().value.query.note ?? route().value.query.elem) as string) ??
'';

if (isNanoID(elemId)) {
const elem = this.notes.fromId(elemId) ?? this.arrows.fromId(elemId);

if (elem != null) {
this.selection.set(elem);

const elemElem =
elem.type === 'note'
? elem.getElem('note-frame')
: elem.getHitboxElem();

if (elemElem != null) {
scrollIntoView(elemElem, {
animate: false,
centerCamera: true,
});
}
}
}
Expand Down
25 changes: 15 additions & 10 deletions apps/client/src/code/pages/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,14 @@ export class Pages {

async goToPage(
pageId: string,
params?: { fromParent?: boolean; openInNewTab?: boolean; noteId?: string },
params?: { fromParent?: boolean; openInNewTab?: boolean; elemId?: string },
) {
mainLogger.sub('Pages.goToPage').info('pageId: %s', pageId);

if (params?.openInNewTab) {
window.open(
multiModePath(
`/pages/${pageId}${params?.noteId ? `?note=${params?.noteId}` : ''}`,
`/pages/${pageId}${params?.elemId ? `?elem=${params?.elemId}` : ''}`,
),
'_blank',
);
Expand All @@ -220,7 +220,7 @@ export class Pages {
await router().push({
name: 'page',
params: { pageId },
query: { note: params?.noteId },
query: { elem: params?.elemId },
});

const cachedPage = this.pageCache.get(pageId);
Expand All @@ -229,17 +229,22 @@ export class Pages {
cachedPage != null &&
cachedPage.react.status === 'success' &&
!cachedPage.react.loading &&
isNanoID(params?.noteId ?? '')
isNanoID(params?.elemId ?? '')
) {
const note = cachedPage.notes.fromId(params?.noteId!);
const elem =
cachedPage.notes.fromId(params?.elemId!) ??
cachedPage.arrows.fromId(params?.elemId!);

if (note != null) {
cachedPage.selection.set(note);
if (elem != null) {
cachedPage.selection.set(elem);

const noteElem = note.getElem('note-frame');
const elemElem =
elem.type === 'note'
? elem.getElem('note-frame')
: elem.getHitboxElem();

if (noteElem != null) {
scrollIntoView(noteElem, { centerCamera: true });
if (elemElem != null) {
scrollIntoView(elemElem, { centerCamera: true });
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions apps/client/src/code/utils/scroll-into-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ function easeInOutQuint(x: number): number {
}

export function scrollIntoView(
target: HTMLElement,
target: Element,
params?: { animate?: boolean; centerCamera?: boolean },
) {
let ancestor: HTMLElement | null = target.parentElement;
let ancestor: Element | null = target.parentElement;

const targetRect = domRectScreenToWorld(target.getBoundingClientRect());

const scrollElems: { elem: HTMLElement; from: IVec2; to: IVec2 }[] = [];
const scrollElems: { elem: Element; from: IVec2; to: IVec2 }[] = [];

while (ancestor != null) {
if (hasScrollbar(ancestor)) {
if (hasScrollbar(ancestor as HTMLElement)) {
const ancestorRect = domRectScreenToWorld(
ancestor.getBoundingClientRect(),
);
Expand Down
2 changes: 1 addition & 1 deletion apps/client/src/components/PageItem.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<a
:href="`/pages/${pageId}`"
:href="`https://deepnotes.app/pages/${pageId}`"
@click.prevent.stop
>
<q-item
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,7 @@ const page = inject<Page>('page')!;
left: 0;
overflow: visible;
z-index: 2147483646;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

<NoteLinkIcon />

<ArrowLinkZones />

<NoteContent>
<NoteTextSection section="head" />

Expand All @@ -32,8 +34,6 @@
</NoteContent>

<NoteResizeHandles />

<ArrowLinkZones />
</NoteFrame>
</NoteAnchor>
</Teleport>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
position:
note.react.floating || note.react.resizing?.active
? 'absolute'
: 'relative',
: 'relative', // relative is needed for the drop zones
left: note.react.resizing?.active
? `${note.react.resizing.newWorldRect.topLeft.x}px`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<template>
<a
:href="
note.react.selected ? undefined : note.react.collab.link || undefined
"
:href="note.react.selected ? undefined : note.react.link.url || undefined"
:style="{ cursor: note.react.cursor }"
tabindex="-1"
target="_blank"
Expand Down Expand Up @@ -55,7 +53,7 @@ function onLeftPointerDown(event: PointerEvent) {
if (
((event.target instanceof HTMLElement && event.target.nodeName === 'A') ||
note.react.collab.link) &&
note.react.link.url) &&
!event.altKey &&
!event.shiftKey &&
!internals.mobileAltKey &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function onLeftPointerUp() {
background-color: #42a5f5;
opacity: 0;
z-index: 2147483645;
z-index: 2147483640;
}
.note-drop-zone.active {
opacity: 0.25;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<div
class="note-frame"
ref="frameElem"
style="position: relative"
:style="{
'min-width': note.react.width.minCSS,
width: note.react.width.finalCSS,
Expand Down Expand Up @@ -65,3 +64,9 @@ useResizeObserver(
},
);
</script>

<style scoped lang="scss">
.note-frame {
position: relative; /* relative is needed for the zones and handles */
}
</style>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<q-icon
class="note-link-icon"
v-if="note.react.collab.link"
v-if="note.react.link.url"
:name="note.react.link.external ? 'mdi-launch' : 'mdi-link-variant'"
:size="note.react.link.external ? '15px' : '16px'"
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<template>
<NoteSection
section="container"
style="position: relative"
>
<NoteSection section="container">
<NoteSpatialContainer v-if="note.react.collab.container.spatial" />
<NoteListContainer v-else />
</NoteSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
v-for="(childNote, index) in note.react.notes"
:key="childNote?.id ?? index"
class="note-container-child"
style="z-index: 2147483646"
:style="{
'flex-direction': note.react.collab.container.horizontal
? 'row'
Expand Down
Loading

0 comments on commit 8839375

Please sign in to comment.