mobile: reduce app size (#3068)

* mobile: reduce app size

* editor: substitute all @mdi/js icons at build time

* mobile: add script to tree shake icon font file

* mobile: fix icon loading

* mobile: remove html-entities dep

* mobile: add missing icon fonts

* mobile: include plain editor

* mobile: add missing fonts

* mobile: use webpack-bundle

* mobile: keep generated fonts in repo

* mobile: update fonts

* mobile: fix duplicate key warning

* mobile: update fonts

* mobile: disable gesure on reminder sheet

* mobile: update fonts

* mobile: reset session correctly on logout

* mobile: update icon fonts

* mobile: set button action on reminder sheet

* mobile: add missing icons

* mobile: fix crash

* mobile: fix right menus

* mobile: remove console.log

* mobile: disable bounce effect

* mobile: update deps

---------

Co-authored-by: Abdullah Atta <abdullahatta@streetwriters.co>
This commit is contained in:
Ammar Ahmed
2023-08-02 15:35:15 +05:00
committed by GitHub
parent c30c54ab97
commit 89c2d45a4b
42 changed files with 18142 additions and 478 deletions

View File

@@ -5,7 +5,6 @@ artifacts/
.DS_Store
native/android/app/src/main/assets/
*Issues.md
build_cache/
#

View File

@@ -30,41 +30,38 @@ const LoggerStorage = new MMKVLoader()
.withInstanceID("notesnook_logs")
.initialize();
database.host(
__DEV__
? {
API_HOST: "https://api.notesnook.com",
AUTH_HOST: "https://auth.streetwriters.co",
SSE_HOST: "https://events.streetwriters.co",
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
ISSUES_HOST: "https://issues.streetwriters.co"
// API_HOST: "http://192.168.8.101:5264",
// AUTH_HOST: "http://192.168.8.101:8264",
// SSE_HOST: "http://192.168.8.101:7264",
// SUBSCRIPTIONS_HOST: "http://192.168.8.101:9264",
// ISSUES_HOST: "http://192.168.8.101:2624"
}
: {
API_HOST: "https://api.notesnook.com",
AUTH_HOST: "https://auth.streetwriters.co",
SSE_HOST: "https://events.streetwriters.co",
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
ISSUES_HOST: "https://issues.streetwriters.co"
}
);
database.setup(
Storage,
Platform.OS === "ios" ? EventSource : AndroidEventSource,
filesystem,
{
compress: Gzip.deflate,
decompress: Gzip.inflate
}
);
database.host(
__DEV__
? {
API_HOST: "https://api.notesnook.com",
AUTH_HOST: "https://auth.streetwriters.co",
SSE_HOST: "https://events.streetwriters.co",
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
ISSUES_HOST: "https://issues.streetwriters.co"
// API_HOST: "http://192.168.8.101:5264",
// AUTH_HOST: "http://192.168.8.101:8264",
// SSE_HOST: "http://192.168.8.101:7264",
// SUBSCRIPTIONS_HOST: "http://192.168.8.101:9264",
// ISSUES_HOST: "http://192.168.8.101:2624"
}
: {
API_HOST: "https://api.notesnook.com",
AUTH_HOST: "https://auth.streetwriters.co",
SSE_HOST: "https://events.streetwriters.co",
SUBSCRIPTIONS_HOST: "https://subscriptions.streetwriters.co",
ISSUES_HOST: "https://issues.streetwriters.co"
}
);
database.setup(
Storage,
Platform.OS === "ios" ? EventSource : AndroidEventSource,
filesystem,
{
compress: Gzip.deflate,
decompress: Gzip.inflate
}
);
initalize(new KV(LoggerStorage), true);

View File

@@ -17,18 +17,22 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useThemeColors } from "@notesnook/theme";
import React, { useEffect, useState } from "react";
import { Modal, View } from "react-native";
import { db } from "../../common/database";
import { MMKV } from "../../common/database/mmkv";
import BiometricService from "../../services/biometrics";
import {
ToastEvent,
eSendEvent,
eSubscribeEvent
} from "../../services/event-manager";
import { setLoginMessage } from "../../services/message";
import SettingsService from "../../services/settings";
import Sync from "../../services/sync";
import { useThemeColors } from "@notesnook/theme";
import { clearAllStores } from "../../stores";
import { useUserStore } from "../../stores/use-user-store";
import { eLoginSessionExpired, eUserLoggedIn } from "../../utils/events";
import { SIZE } from "../../utils/size";
import { sleep } from "../../utils/time";
@@ -71,9 +75,12 @@ export const SessionExpired = () => {
try {
await db.user.logout();
await BiometricService.resetCredentials();
SettingsService.set({
introCompleted: true
});
setLoginMessage();
SettingsService.resetSettings();
useUserStore.getState().setUser(null);
useUserStore.getState().setSyncing(false);
MMKV.clearStore();
clearAllStores();
setVisible(false);
} catch (e) {
ToastEvent.show({

View File

@@ -33,7 +33,7 @@ import { IconButton } from "../ui/icon-button";
export const RightMenus = () => {
const { colors } = useThemeColors();
const { contextMenuColors } = useThemeColors("contextMenu");
const { colors: contextMenuColors } = useThemeColors("contextMenu");
const deviceMode = useSettingStore((state) => state.deviceMode);
const rightButtons = useNavigationStore((state) => state.headerRightButtons);
const currentScreen = useNavigationStore((state) => state.currentScreen.name);
@@ -93,7 +93,7 @@ export const RightMenus = () => {
onRequestClose={() => {
menuRef.current?.hide();
}}
button={
anchor={
<IconButton
onPress={() => {
menuRef.current?.show();
@@ -113,7 +113,7 @@ export const RightMenus = () => {
}}
type="gray"
buttonType={{
text: colors.primary.paragraph
text: contextMenuColors.primary.paragraph
}}
key={item.title}
title={item.title}

View File

@@ -102,7 +102,11 @@ const SheetProvider = ({ context = "global" }) => {
setData(null);
}}
bottomPadding={!data.noBottomPadding}
enableGesturesInScrollView={data.enableGesturesInScrollView}
enableGesturesInScrollView={
typeof data.enableGesturesInScrollView === "undefined"
? true
: data.enableGesturesInScrollView
}
>
<View
style={{

View File

@@ -16,6 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { useThemeColors } from "@notesnook/theme";
import React, { RefObject, useRef, useState } from "react";
import { Platform, TextInput, View } from "react-native";
import { ActionSheetRef, ScrollView } from "react-native-actions-sheet";
@@ -25,7 +26,6 @@ import {
ToastEvent,
presentSheet
} from "../../../services/event-manager";
import { useThemeColors } from "@notesnook/theme";
import { SIZE } from "../../../utils/size";
import { Button } from "../../ui/button";
import Input from "../../ui/input";
@@ -247,7 +247,7 @@ export default function ReminderSheet({
/>
</View>
<Dialog context="local" />
<ScrollView>
<ScrollView bounces={false}>
<Input
fwdRef={titleRef}
defaultValue={reminder?.title || referencedItem?.title}
@@ -601,7 +601,7 @@ ReminderSheet.present = (
) => {
presentSheet({
context: isSheet ? "local" : undefined,
enableGesturesInScrollView: true,
enableGesturesInScrollView: false,
noBottomPadding: true,
component: (ref, close, update) => (
<ReminderSheet

View File

@@ -28,7 +28,8 @@ import { useNoteStore } from "../../stores/use-notes-store";
import { useSettingStore } from "../../stores/use-setting-store";
import { useThemeColors } from "@notesnook/theme";
import { useUserStore } from "../../stores/use-user-store";
import { MenuItemsList, SUBSCRIPTION_STATUS } from "../../utils/constants";
import { MenuItemsList } from "../../utils/menu-items";
import { SUBSCRIPTION_STATUS } from "../../utils/constants";
import { eOpenPremiumDialog } from "../../utils/events";
import { ColorSection } from "./color-section";
import { MenuItem } from "./menu-item";

View File

@@ -631,6 +631,7 @@ const doAppLoadActions = async () => {
await useMessageStore.getState().setAnnouncement();
if (NewFeature.present()) return;
if (await checkAppUpdateAvailable()) return;
if (!(await db.user.getUser())) {
setLoginMessage();
return;

View File

@@ -16,7 +16,7 @@
"html-to-text": "9.0.5",
"phone": "^3.1.14",
"qclone": "^1.2.0",
"react-native-actions-sheet": "0.9.0-alpha.21",
"react-native-actions-sheet": "0.9.0-alpha.23",
"react-native-check-version": "https://github.com/flexible-agency/react-native-check-version",
"react-native-drax": "^0.10.2",
"react-native-image-zoom-viewer": "^3.0.1",

View File

@@ -66,6 +66,7 @@ export const Reminders = ({
});
SearchService.prepareSearch = prepareSearch;
useNavigationStore.getState().setButtonAction(PLACEHOLDER_DATA.action);
return !prev?.current;
},
onBlur: () => false,

View File

@@ -21,7 +21,7 @@ import { db } from "../../../common/database";
import { ToastEvent } from "../../../services/event-manager";
import SettingsService from "../../../services/settings";
import { useSettingStore } from "../../../stores/use-setting-store";
import { MenuItemsList } from "../../../utils/constants";
import { MenuItemsList } from "../../../utils/menu-items";
import { createSettingsPicker } from ".";
import { getFontById, getFonts } from "@notesnook/editor/dist/utils/font";
import { DATE_FORMATS, TIME_FORMATS } from "@notesnook/core/common";

View File

@@ -972,7 +972,7 @@ export const settingsGroups: SettingSection[] = [
}
},
{
id: "reminder-sound",
id: "reminder-sound-ios",
type: "screen",
name: "Change notification sound",
description:
@@ -984,7 +984,7 @@ export const settingsGroups: SettingSection[] = [
(Platform.OS === "android" && Platform.Version > 25)
},
{
id: "reminder-sound",
id: "reminder-sound-android",
name: "Change notification sound",
description:
"Set the notification sound for reminder notifications",

View File

@@ -100,49 +100,6 @@ export const SUBSCRIPTION_PROVIDER = {
}
};
export const MenuItemsList = [
{
name: "Notes",
icon: "home-variant-outline",
close: true
},
{
name: "Notebooks",
icon: "book-outline",
close: true
},
{
name: "Favorites",
icon: "star-outline",
close: true
},
{
name: "Tags",
icon: "pound",
close: true
},
{
name: "Reminders",
icon: "bell",
close: true,
isBeta: true
},
{
name: "Monographs",
icon: "text-box-multiple-outline",
close: true,
func: () => {
const Monographs = require("../screens/notes/monographs").Monographs;
Monographs.navigate();
}
},
{
name: "Trash",
icon: "delete-outline",
close: true
}
];
export const BUTTON_TYPES = {
transparent: {
primary: "transparent",

View File

@@ -0,0 +1,60 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export const MenuItemsList = [
{
name: "Notes",
icon: "home-variant-outline",
close: true
},
{
name: "Notebooks",
icon: "book-outline",
close: true
},
{
name: "Favorites",
icon: "star-outline",
close: true
},
{
name: "Tags",
icon: "pound",
close: true
},
{
name: "Reminders",
icon: "bell",
close: true,
isBeta: true
},
{
name: "Monographs",
icon: "text-box-multiple-outline",
close: true,
func: () => {
const Monographs = require("../screens/notes/monographs").Monographs;
Monographs.navigate();
}
},
{
name: "Trash",
icon: "delete-outline",
close: true
}
];

View File

@@ -224,20 +224,26 @@ task deleteFiles(type: Delete) {
delete './src/main/assets/static'
}
task copyFiles(type: Copy) {
task copyEditorBundle(type: Copy) {
from '../../../../../packages/editor-mobile/build.bundle'
into './src/main/assets'
}
copyFiles.dependsOn(deleteFiles)
preBuild.dependsOn(copyFiles)
task copyPlainEditorBundle(type: Copy) {
from '../../ios/extension.bundle'
into './src/main/assets'
}
task copyFontFiles(type: Copy) {
from '../../fonts'
into './src/main/assets/fonts'
}
project.ext.vectoricons = [
iconFontNames: ['MaterialCommunityIcons.ttf' ],
iconFontsDir: "../../../node_modules/react-native-vector-icons/Fonts"
]
apply from: "../../../node_modules/react-native-vector-icons/fonts.gradle"
copyEditorBundle.dependsOn(deleteFiles)
copyFontFiles.dependsOn(copyEditorBundle);
copyPlainEditorBundle.dependsOn(copyFontFiles);
preBuild.dependsOn(copyPlainEditorBundle)
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)

View File

@@ -1,4 +1,4 @@
let env = process.env.BABEL_ENV;
const env = process.env.BABEL_ENV || process.env.NODE_ENV;
const configs = {
env: {
development: {

Binary file not shown.

View File

@@ -1,10 +1,10 @@
/* eslint-disable @typescript-eslint/no-var-requires */
import './globals.js';
import React from 'react';
import { AppRegistry, Platform } from 'react-native';
import 'react-native-get-random-values';
import { SafeAreaProvider } from 'react-native-safe-area-context';
global.Buffer = require('buffer').Buffer;
import '../app/common/logger/index';
const ShareProvider = () => {
NotesnookShare = require('../share/index').default;
@@ -16,5 +16,6 @@ const ShareProvider = () => {
<NotesnookShare quicknote={false} />
);
};
AppRegistry.registerComponent('NotesnookShare', () => ShareProvider);

View File

@@ -51,6 +51,8 @@ const ShareProvider = () => {
);
};
AppRegistry.registerComponent('NotesnookShare', () => ShareProvider);
const QuickNoteProvider = () => {

View File

@@ -3,26 +3,32 @@
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <React/RCTLog.h>
#import <React/RCTEventEmitter.h>
@interface ShareViewController : ReactNativeShareExtension
@end
@implementation ShareViewController
@synthesize bridge = _bridge;
@synthesize callableJSModules = _callableJSModules;
+ (BOOL)requiresMainQueueSetup {
return true;
}
int rootViewTag = 0;
RCT_EXPORT_MODULE();
- (UIView*) shareView {
NSURL *jsCodeLocation;
jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation
moduleName:@"NotesnookShare"
initialProperties:nil
launchOptions:nil];
rootViewTag = rootView.tag;
rootView.window.backgroundColor =[UIColor clearColor];
rootView.layer.shadowOpacity = 0;
rootView.backgroundColor = [UIColor clearColor];
@@ -33,4 +39,5 @@ RCT_EXPORT_MODULE();
return rootView;
}
@end

View File

@@ -15,16 +15,12 @@
2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
2DCD954D1E0B4F2C00145EB5 /* NotesnookTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* NotesnookTests.m */; };
6510626F27042891009661C3 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6552012F27019F7700A43C51 /* OpenSans-Regular.ttf */; };
6510627527042893009661C3 /* OpenSans-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6552012F27019F7700A43C51 /* OpenSans-Regular.ttf */; };
6510627627042895009661C3 /* OpenSans-SemiBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6552012E27019F6E00A43C51 /* OpenSans-SemiBold.ttf */; };
6510627727042896009661C3 /* OpenSans-SemiBold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 6552012E27019F6E00A43C51 /* OpenSans-SemiBold.ttf */; };
6510E6D72877215700DACAA9 /* build.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 6510E6D62877215700DACAA9 /* build.bundle */; };
6510E6D82877215700DACAA9 /* build.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 6510E6D62877215700DACAA9 /* build.bundle */; };
6515C42F2580AA3000E83E39 /* StoreKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6515C42E2580AA2F00E83E39 /* StoreKit.framework */; };
6529A13E279BC4C70048D4A8 /* BootSplash.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6529A13D279BC4C70048D4A8 /* BootSplash.storyboard */; };
6593E4A3281C345400492C50 /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 6593E4A2281C345400492C50 /* AppDelegate.mm */; };
659670B22A2754FD00C5D2AF /* OpenSans-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 659670B12A2754FD00C5D2AF /* OpenSans-Bold.ttf */; };
659670B32A2754FD00C5D2AF /* OpenSans-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 659670B12A2754FD00C5D2AF /* OpenSans-Bold.ttf */; };
659BE46725E11A5100E05671 /* notesnook-text.png in Resources */ = {isa = PBXBuildFile; fileRef = 659BE46625E11A5100E05671 /* notesnook-text.png */; };
65AA857925E6DDEC00772A01 /* WidgetKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65AA857825E6DDEC00772A01 /* WidgetKit.framework */; };
65AA857B25E6DDEC00772A01 /* SwiftUI.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 65AA857A25E6DDEC00772A01 /* SwiftUI.framework */; };
@@ -35,12 +31,12 @@
65B5014725A672B200E2D264 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 65B5014525A672B200E2D264 /* MainInterface.storyboard */; };
65B5014B25A672B200E2D264 /* Make Note.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 65B5014025A672B200E2D264 /* Make Note.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
65B5020325A6756700E2D264 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65B5020225A6756700E2D264 /* File.swift */; };
65C149872A61151B005C40F1 /* extension.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 65C149862A61151B005C40F1 /* extension.bundle */; };
65D145C529DC30470056FE7D /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65D145C429DC30470056FE7D /* MaterialCommunityIcons.ttf */; };
65D145C629DC30470056FE7D /* MaterialCommunityIcons.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 65D145C429DC30470056FE7D /* MaterialCommunityIcons.ttf */; };
65E0340B257B9FF100793428 /* File.swift in Sources */ = {isa = PBXBuildFile; fileRef = 65E0340A257B9FF100793428 /* File.swift */; };
7C72B5EA418785B334F3B5EB /* libPods-Notesnook-Make Note.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 35547D7C07E83F889159A73D /* libPods-Notesnook-Make Note.a */; };
87CE5B71DC72F3D95B7B1AA5 /* libPods-Notesnook-tvOSTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A03E3F5851D27269540E147C /* libPods-Notesnook-tvOSTests.a */; };
A79A93DC9D0CAE8703462151 /* libPods-Notesnook-NotesnookTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 068FA9BDFA207A50B0A9E597 /* libPods-Notesnook-NotesnookTests.a */; };
C619D096A9DE2070DBEAC70F /* libPods-Make Note.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C4AF691C324D95337F2FB0A /* libPods-Make Note.a */; };
F50BF8BC21F8B58EB2B5A31A /* libPods-Notesnook-tvOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 16C0296DE7A2B4102817F5C1 /* libPods-Notesnook-tvOS.a */; };
/* End PBXBuildFile section */
@@ -107,10 +103,10 @@
279A4325E1D27BD3E720F35B /* Pods-Notesnook-Make Note.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Notesnook-Make Note.debug.xcconfig"; path = "Target Support Files/Pods-Notesnook-Make Note/Pods-Notesnook-Make Note.debug.xcconfig"; sourceTree = "<group>"; };
2D02E47B1E0B4A5D006451C7 /* Notesnook-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Notesnook-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
2D02E4901E0B4A5D006451C7 /* Notesnook-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Notesnook-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
35547D7C07E83F889159A73D /* libPods-Notesnook-Make Note.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Notesnook-Make Note.a"; sourceTree = BUILT_PRODUCTS_DIR; };
41D57E9831C724F59F18FBAE /* libPods-Notesnook-Add to Notes.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Notesnook-Add to Notes.a"; sourceTree = BUILT_PRODUCTS_DIR; };
47AE097A087A651BD60CAD7B /* Pods-Notesnook-Make Note.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Notesnook-Make Note.release.xcconfig"; path = "Target Support Files/Pods-Notesnook-Make Note/Pods-Notesnook-Make Note.release.xcconfig"; sourceTree = "<group>"; };
4BD34AE0C0FD2416E48803B8 /* libPods-Notesnook.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Notesnook.a"; sourceTree = BUILT_PRODUCTS_DIR; };
4C4AF691C324D95337F2FB0A /* libPods-Make Note.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Make Note.a"; sourceTree = BUILT_PRODUCTS_DIR; };
6510E6D62877215700DACAA9 /* build.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = build.bundle; path = "../../../../packages/editor-mobile/build.bundle"; sourceTree = "<group>"; };
6515C42E2580AA2F00E83E39 /* StoreKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = StoreKit.framework; path = System/Library/Frameworks/StoreKit.framework; sourceTree = SDKROOT; };
6529A13D279BC4C70048D4A8 /* BootSplash.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = BootSplash.storyboard; path = Notesnook/BootSplash.storyboard; sourceTree = "<group>"; };
@@ -134,6 +130,7 @@
65B501AA25A6733400E2D264 /* Make Note.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "Make Note.entitlements"; sourceTree = "<group>"; };
65B5020125A6756700E2D264 /* Make Note-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Make Note-Bridging-Header.h"; sourceTree = "<group>"; };
65B5020225A6756700E2D264 /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
65C149862A61151B005C40F1 /* extension.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = extension.bundle; sourceTree = "<group>"; };
65D145C429DC30470056FE7D /* MaterialCommunityIcons.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = MaterialCommunityIcons.ttf; path = "../../node_modules/react-native-vector-icons/Fonts/MaterialCommunityIcons.ttf"; sourceTree = "<group>"; };
65E03409257B9FF100793428 /* Notesnook-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Notesnook-Bridging-Header.h"; sourceTree = "<group>"; };
65E0340A257B9FF100793428 /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
@@ -200,7 +197,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7C72B5EA418785B334F3B5EB /* libPods-Notesnook-Make Note.a in Frameworks */,
C619D096A9DE2070DBEAC70F /* libPods-Make Note.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -254,9 +251,9 @@
16C0296DE7A2B4102817F5C1 /* libPods-Notesnook-tvOS.a */,
A03E3F5851D27269540E147C /* libPods-Notesnook-tvOSTests.a */,
41D57E9831C724F59F18FBAE /* libPods-Notesnook-Add to Notes.a */,
35547D7C07E83F889159A73D /* libPods-Notesnook-Make Note.a */,
65AA857825E6DDEC00772A01 /* WidgetKit.framework */,
65AA857A25E6DDEC00772A01 /* SwiftUI.framework */,
4C4AF691C324D95337F2FB0A /* libPods-Make Note.a */,
);
name = Frameworks;
sourceTree = "<group>";
@@ -294,6 +291,7 @@
83CBB9F61A601CBA00E9B192 = {
isa = PBXGroup;
children = (
65C149862A61151B005C40F1 /* extension.bundle */,
6510E6D62877215700DACAA9 /* build.bundle */,
65EC5B71272A7EE200FB3748 /* NotesWidgetExtensionDebug.entitlements */,
6552012F27019F7700A43C51 /* OpenSans-Regular.ttf */,
@@ -578,11 +576,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6510E6D82877215700DACAA9 /* build.bundle in Resources */,
65D145C629DC30470056FE7D /* MaterialCommunityIcons.ttf in Resources */,
659670B32A2754FD00C5D2AF /* OpenSans-Bold.ttf in Resources */,
6510627727042896009661C3 /* OpenSans-SemiBold.ttf in Resources */,
6510627527042893009661C3 /* OpenSans-Regular.ttf in Resources */,
65C149872A61151B005C40F1 /* extension.bundle in Resources */,
65B5014725A672B200E2D264 /* MainInterface.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -776,7 +770,7 @@
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Notesnook-Make Note-checkManifestLockResult.txt",
"$(DERIVED_FILE_DIR)/Pods-Make Note-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
@@ -789,7 +783,7 @@
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Notesnook-Make Note/Pods-Notesnook-Make Note-resources.sh",
"${PODS_ROOT}/Target Support Files/Pods-Make Note/Pods-Make Note-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
);
name = "[CP] Copy Pods Resources";
@@ -798,7 +792,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Notesnook-Make Note/Pods-Notesnook-Make Note-resources.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Make Note/Pods-Make Note-resources.sh\"\n";
showEnvVarsInLog = 0;
};
FD10A7F022414F080027D42C /* Start Packager */ = {
@@ -1403,7 +1397,7 @@
};
65B5014D25A672B200E2D264 /* Debug */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 279A4325E1D27BD3E720F35B /* Pods-Notesnook-Make Note.debug.xcconfig */;
baseConfigurationReference = 88211800FA8BF60638327ADE /* Pods-Make Note.debug.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_NONNULL = YES;
@@ -1506,7 +1500,7 @@
};
65B5014E25A672B200E2D264 /* Release */ = {
isa = XCBuildConfiguration;
baseConfigurationReference = 47AE097A087A651BD60CAD7B /* Pods-Notesnook-Make Note.release.xcconfig */;
baseConfigurationReference = A84F3F0D50641D1CD4569B0E /* Pods-Make Note.release.xcconfig */;
buildSettings = {
APPLICATION_EXTENSION_API_ONLY = YES;
CLANG_ANALYZER_NONNULL = YES;

View File

@@ -57,17 +57,41 @@ target 'Notesnook' do
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
# for share extension
target 'Make Note' do
inherit! :complete
end
target 'NotesnookTests' do
# Pods for testing
end
end
# for share extension
target 'Make Note' do
use_react_native!(
:path => "../../node_modules/react-native",
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => false,
:fabric_enabled => false,
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
# :flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)
# Link only required libraries in share extension manually
pod 'react-native-blob-util', :path => '../../node_modules/react-native-blob-util'
pod 'react-native-share-extension', :path => '../../node_modules/@ammarahmed/react-native-share-extension'
pod 'react-native-sodium', :path => '../../node_modules/@ammarahmed/react-native-sodium'
pod 'react-native-gzip', :path => '../../node_modules/react-native-gzip'
pod 'react-native-mmkv-storage', :path => '../../node_modules/react-native-mmkv-storage'
pod 'react-native-webview', :path => '../../node_modules/react-native-webview'
pod 'RNKeychain' , :path => '../../node_modules/react-native-keychain'
pod 'react-native-netinfo', :path => '../../node_modules/@react-native-community/netinfo'
pod 'react-native-safe-area-context', :path => '../../node_modules/react-native-safe-area-context'
end
target 'Notesnook-tvOS' do

View File

@@ -928,6 +928,6 @@ SPEC CHECKSUMS:
toolbar-android: 2a73856e98b750d7e71ce4644d3f41cc98211719
Yoga: 1d6727ed193122f6adaf435c3de1a768326ff83b
PODFILE CHECKSUM: ceb52748ea756b5ee99a76ac8a9d0323ded50075
PODFILE CHECKSUM: 2edd4792d1a9505ba0d23c245dd1ca8863e7d928
COCOAPODS: 1.11.3

View File

@@ -0,0 +1,107 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8" />
<title>Note Preview</title>
<style>
body {
background-color: transparent !important;
margin: 0px !important;
padding: 12px;
padding-top: 0px;
font-size: 16px;
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}
iframe {
max-width: 100% !important;
background-color: transparent !important;
}
.editor {
overflow-x: hidden;
overflow-y: scroll;
min-height: 150px;
outline: none !important;
border-width: 0px !important;
width: 100%;
}
[contenteditable=true]:empty:before {
content: attr(placeholder);
pointer-events: none;
display: block;
color: gray;
}
</style>
</head>
<body>
<div aria-autocomplete="none" placeholder="Write something..." contenteditable="true" id="editor" class="editor double-spaced" >
</div>
<script>
function postMessage(type, value) {
if (window.ReactNativeWebView) {
window.ReactNativeWebView.postMessage(
JSON.stringify({
type: type,
value: value
})
);
}
}
document.getElementById("editor").addEventListener("input", function (event) {
postMessage('content', event.target.innerHTML);
}, false);
attachOnMessage()
let styleElementDocument;
let doubleSpacedLines = true;
function attachOnMessage() {
let isSafari = navigator.vendor.match(/apple/i);
let listenerHandler = document;
if (isSafari) {
listenerHandler = window;
}
listenerHandler.addEventListener('message', function (data) {
console.log("message", data);
let message = JSON.parse(data.data);
let type = message.type;
let value = message.value;
switch (type) {
case 'html':
document.getElementById('editor').innerHTML = value;
break;
case 'theme':
if (!styleElementDocument) {
styleElementDocument = document.createElement('style');
styleElementDocument.type = 'text/css';
styleElementDocument.innerHTML = value;
document.getElementsByTagName('head')[0].appendChild(styleElementDocument);
} else {
styleElementDocument.innerHTML = node;
}
break;
case 'line-spacing': {
doubleSpacedLines = JSON.parse(value);
}
default:
break;
}
});
}
</script>
</body>
</html>

View File

@@ -1,4 +1,5 @@
const {getDefaultConfig, mergeConfig} = require('@react-native/metro-config');
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native

View File

@@ -107,6 +107,8 @@
"react-test-renderer": "18.2.0",
"terser-webpack-plugin": "^5.3.5",
"ts-jest": "^28.0.7",
"typescript": "4.8.4",
"webpack-cli": "^5.1.4",
"webpack": "^5.74.0"
}
}

View File

@@ -10,6 +10,7 @@ const config = {
};
if (!config.dependencies) config.dependencies = {};
config.dependencies['react-native-vector-icons'] = {
platforms: {
ios: null,

View File

@@ -97,7 +97,8 @@ module.exports = (env) => {
"deepmerge": path.join(__dirname, "../node_modules/deepmerge"),
"@selderee/plugin-htmlparser2": path.join(__dirname, "../node_modules/@selderee/plugin-htmlparser2"),
"peberminta": path.join(__dirname, "../node_modules/peberminta"),
"react-native-blob-util": path.join(__dirname, "../node_modules/react-native-blob-util")
"react-native-blob-util": path.join(__dirname, "../node_modules/react-native-blob-util"),
"@mdi/js": path.join(__dirname, "../node_modules/@mdi/js/mdi.js")
},
},
/**

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
"app/"
],
"scripts": {
"postinstall": "patch-package",
"postinstall": "patch-package && node ./scripts/optimize-fonts.mjs",
"run-android": "cd native && react-native run-android --active-arch-only",
"run-ios": "cd native && react-native run-ios",
"start": "cd native && react-native start",
@@ -23,6 +23,7 @@
"release-android-bundle": "cd native/android && ./gradlew bundleRelease --no-daemon"
},
"devDependencies": {
"fonteditor-core": "^2.1.11",
"otplib": "12.0.1",
"patch-package": "7.0.0",
"react-refresh": "0.14.0"

View File

@@ -0,0 +1,10 @@
diff --git a/node_modules/@flyerhq/react-native-link-preview/lib/utils.js b/node_modules/@flyerhq/react-native-link-preview/lib/utils.js
index c1aff89..4a3f878 100644
--- a/node_modules/@flyerhq/react-native-link-preview/lib/utils.js
+++ b/node_modules/@flyerhq/react-native-link-preview/lib/utils.js
@@ -1,4 +1,4 @@
-import { decode } from 'html-entities';
+import { decode } from 'entities';
import { Image } from 'react-native';
export const getActualImageUrl = (baseUrl, imageUrl) => {
let actualImageUrl = imageUrl === null || imageUrl === void 0 ? void 0 : imageUrl.trim();

View File

@@ -1,5 +1,5 @@
diff --git a/node_modules/react-native-blob-util/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java b/node_modules/react-native-blob-util/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java
index 9aee829..87124b3 100644
index 9aee829..0ecc59b 100644
--- a/node_modules/react-native-blob-util/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java
+++ b/node_modules/react-native-blob-util/android/src/main/java/com/ReactNativeBlobUtil/ReactNativeBlobUtilReq.java
@@ -634,7 +634,9 @@ public class ReactNativeBlobUtilReq extends BroadcastReceiver implements Runnabl
@@ -86,7 +86,7 @@ index 9aee829..87124b3 100644
break;
}
diff --git a/node_modules/react-native-blob-util/fetch.js b/node_modules/react-native-blob-util/fetch.js
index 97e5263..45c086c 100644
index 97e5263..640aaea 100644
--- a/node_modules/react-native-blob-util/fetch.js
+++ b/node_modules/react-native-blob-util/fetch.js
@@ -244,7 +244,7 @@ export function fetch(...args: any): Promise {
@@ -108,14 +108,38 @@ index 97e5263..45c086c 100644
resolve(new FetchBlobResponse(taskId, respInfo, data));
}
diff --git a/node_modules/react-native-blob-util/index.js b/node_modules/react-native-blob-util/index.js
index ecaddf9..40a5c37 100644
--- a/node_modules/react-native-blob-util/index.js
+++ b/node_modules/react-native-blob-util/index.js
@@ -14,6 +14,7 @@ import ios from './ios';
import JSONStream from './json-stream';
import {config, fetch} from './fetch';
import URIUtil from './utils/uri';
+import getUUID from "./utils/uuid";
import CanceledFetchError from './class/ReactNativeBlobUtilCanceledFetchError';
const {
@@ -45,9 +46,9 @@ if (!ReactNativeBlobUtil || !ReactNativeBlobUtil.fetchBlobForm || !ReactNativeBl
}
export {ReactNativeBlobUtilConfig, ReactNativeBlobUtilResponseInfo, ReactNativeBlobUtilStream} from './types';
-export { URIUtil } from './utils/uri';
+export { URIUtil, getUUID };
export {FetchBlobResponse} from './class/ReactNativeBlobUtilBlobResponse';
-export { getUUID } from './utils/uuid';
+
export default {
fetch,
base64,
diff --git a/node_modules/react-native-blob-util/ios/ReactNativeBlobUtilRequest.mm b/node_modules/react-native-blob-util/ios/ReactNativeBlobUtilRequest.mm
index d4e468a..25b8d81 100644
index d4e468a..ac9e42a 100644
--- a/node_modules/react-native-blob-util/ios/ReactNativeBlobUtilRequest.mm
+++ b/node_modules/react-native-blob-util/ios/ReactNativeBlobUtilRequest.mm
@@ -438,13 +438,20 @@ - (void) URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCom
}
}
+ NSHTTPURLResponse *response = (NSHTTPURLResponse *) [task response];
+
@@ -128,7 +152,7 @@ index d4e468a..25b8d81 100644
+ @"status": [NSNumber numberWithInteger:[response statusCode]]
+ }
]);
+
+
respData = nil;

View File

@@ -0,0 +1,70 @@
diff --git a/node_modules/react-native-svg/__tests__/css.test.tsx b/node_modules/react-native-svg/__tests__/css.test.tsx
index 579c357..57acc09 100644
--- a/node_modules/react-native-svg/__tests__/css.test.tsx
+++ b/node_modules/react-native-svg/__tests__/css.test.tsx
@@ -1,6 +1,7 @@
import React from 'react';
import renderer from 'react-test-renderer';
-import { SvgCss, parse, inlineStyles } from '../src/ReactNativeSVG';
+import { parse } from '../src/ReactNativeSVG';
+import { SvgCss, inlineStyles } from '../css';
const xml = `<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
diff --git a/node_modules/react-native-svg/css/index.ts b/node_modules/react-native-svg/css/index.ts
new file mode 100644
index 0000000..3b268af
--- /dev/null
+++ b/node_modules/react-native-svg/css/index.ts
@@ -0,0 +1,2 @@
+export * from '../src/css';
+export { LocalSvg, WithLocalSvg, loadLocalRawResource } from '../src/LocalSvg';
\ No newline at end of file
diff --git a/node_modules/react-native-svg/src/LocalSvg.tsx b/node_modules/react-native-svg/src/LocalSvg.tsx
index f13c46f..0457159 100644
--- a/node_modules/react-native-svg/src/LocalSvg.tsx
+++ b/node_modules/react-native-svg/src/LocalSvg.tsx
@@ -7,7 +7,7 @@ import {
} from 'react-native';
import { fetchText } from './xml';
-import { SvgCss, SvgWithCss } from './css';
+import { SvgCss, SvgWithCss } from '../css';
import { SvgProps } from './elements/Svg';
const { getRawResource } = NativeModules.RNSVGRenderableManager || {};
diff --git a/node_modules/react-native-svg/src/ReactNativeSVG.ts b/node_modules/react-native-svg/src/ReactNativeSVG.ts
index 6b72423..1daca6c 100644
--- a/node_modules/react-native-svg/src/ReactNativeSVG.ts
+++ b/node_modules/react-native-svg/src/ReactNativeSVG.ts
@@ -25,14 +25,7 @@ import Marker from './elements/Marker';
import ForeignObject from './elements/ForeignObject';
import { parse, SvgAst, SvgFromUri, SvgFromXml, SvgUri, SvgXml } from './xml';
-import {
- SvgCss,
- SvgCssUri,
- SvgWithCss,
- SvgWithCssUri,
- inlineStyles,
-} from './css';
-import { LocalSvg, WithLocalSvg, loadLocalRawResource } from './LocalSvg';
+
import {
RNSVGCircle,
RNSVGClipPath,
@@ -116,14 +109,6 @@ export {
SvgFromXml,
SvgUri,
SvgXml,
- SvgCss,
- SvgCssUri,
- SvgWithCss,
- SvgWithCssUri,
- inlineStyles,
- LocalSvg,
- WithLocalSvg,
- loadLocalRawResource,
Shape,
RNSVGMarker,
RNSVGMask,

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,167 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import fg from "fast-glob";
import { Font } from "fonteditor-core";
import { existsSync } from "fs";
import { mkdir, readFile, writeFile } from "fs/promises";
import Listr from "listr";
import os from "os";
import path from "path";
import { fileURLToPath } from "url";
const EXTRA_ICON_NAMES = [
"menu",
"lock-open-outline",
"key-outline",
"pin-off-outline",
"pin-outline",
"star-off",
"star-outline",
"link-variant-remove",
"link-variant",
"bell",
"bell-off-outline",
"check",
"magnify",
"plus",
"view-list-outline",
"view-list",
"play",
"pause",
"notebook-outline",
"text-short",
"radiobox-marked",
"radiobox-blank",
"sort-descending",
"information",
"sort-ascending",
"alert",
"arrow-right",
"bookmark-outline",
"checkbox-marked",
"checkbox-blank-outline",
"unfold-less-horizontal",
"minus-circle",
"vibrate",
"volume-high",
"checkbox-blank-circle-outline",
"check-circle-outline",
"chevron-up",
"chevron-down"
];
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const ROOT_DIR = path.resolve(path.join(__dirname, ".."));
const GLYPH_MAP_PATH = path.join(
ROOT_DIR,
"node_modules",
"react-native-vector-icons",
"glyphmaps",
"MaterialCommunityIcons.json"
);
const GLYPH_MAP_OLD_PATH = path.join(
ROOT_DIR,
"node_modules",
"react-native-vector-icons",
"glyphmaps",
"MaterialCommunityIcons.old.json"
);
const ICON_FONT_PATH = path.join(
ROOT_DIR,
"node_modules",
"react-native-vector-icons",
"Fonts",
"MaterialCommunityIcons.ttf"
);
if (!existsSync(GLYPH_MAP_OLD_PATH) && !existsSync(GLYPH_MAP_PATH))
throw new Error("Glyph file not found.");
if (!existsSync(GLYPH_MAP_OLD_PATH)) {
await writeFile(
GLYPH_MAP_OLD_PATH,
await readFile(GLYPH_MAP_PATH, "utf-8"),
"utf-8"
);
}
const glyphs = JSON.parse(await readFile(GLYPH_MAP_OLD_PATH, "utf-8"));
const files = await fg("app/**/*.{js,jsx,ts,tsx}");
const pattern = /.name="(.+?)"/gm;
const glyphCodepoints = new Set();
class SilentRenderer {
static get nonTTY() {
return true;
}
render() {}
end() {}
}
const MODIFIED_GLYPH_MAP = {};
const tasks = new Listr([], {
concurrent: os.cpus().length,
renderer: SilentRenderer
});
for (const filePath of files) {
tasks.add({
title: `Searching ${filePath}`,
task: async () => {
const file = await readFile(filePath, "utf-8");
const matches = [
...file.matchAll(pattern),
...file.matchAll(/.icon: "(.+?)"/gm)
];
const icons = matches
.map((m) => m[1])
.filter((value) => value !== null && value !== undefined);
icons.push(...EXTRA_ICON_NAMES);
for (const icon of icons) {
if (!glyphs[icon]) continue;
MODIFIED_GLYPH_MAP[icon] = glyphs[icon];
glyphCodepoints.add(glyphs[icon]);
}
}
});
}
await tasks.run();
const font = Font.create(await readFile(ICON_FONT_PATH), {
type: "ttf",
subset: Array.from(glyphCodepoints.values()),
hinting: true
});
if (!existsSync(path.join(ROOT_DIR, "native", "fonts"))) {
await mkdir(path.join(ROOT_DIR, "native", "fonts"));
}
await writeFile(
path.join(ROOT_DIR, "native", "fonts", "MaterialCommunityIcons.ttf"),
font.write({ type: "ttf", hinting: true })
);
await writeFile(GLYPH_MAP_PATH, JSON.stringify(MODIFIED_GLYPH_MAP), "utf-8");

View File

@@ -16,8 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { getDefaultPresets } from "@notesnook/editor/dist/toolbar/tool-definitions";
import { useThemeColors, useThemeEngineStore } from "@notesnook/theme";
import { useThemeColors } from "@notesnook/theme";
import React, {
useCallback,
useEffect,
@@ -28,34 +27,47 @@ import React, {
} from "react";
import { Linking, Platform, View } from "react-native";
import { WebView } from "react-native-webview";
import { EDITOR_URI } from "../app/screens/editor/source";
import Commands from "../app/screens/editor/tiptap/commands";
import { EventTypes } from "../app/screens/editor/tiptap/editor-events";
import { EditorEvents, post } from "../app/screens/editor/tiptap/utils";
import {
eSubscribeEvent,
eUnSubscribeEvent
} from "../app/services/event-manager";
import { useSettingStore } from "../app/stores/use-setting-store";
import { eOnLoadNote } from "../app/utils/events";
const EditorMobileSourceUrl =
Platform.OS === "android"
? "file:///android_asset/plaineditor.html"
: "extension.bundle/plaineditor.html";
/**
* Replace this with dev url when debugging or working on the editor mobile repo.
* The url should be something like this: http://192.168.100.126:3000/index.html
*/
export const EDITOR_URI = __DEV__
? EditorMobileSourceUrl
: EditorMobileSourceUrl;
export async function post(ref, type, value = null) {
const message = {
type,
value
};
setImmediate(() => ref.current?.postMessage(JSON.stringify(message)));
}
const useEditor = () => {
const ref = useRef();
const [sessionId] = useState("share-editor-session" + Date.now());
const theme = useThemeEngineStore((state) => state.theme);
const { colors } = useThemeColors("editor");
const commands = useMemo(() => new Commands(ref), [ref]);
const currentNote = useRef();
const doubleSpacedLines = useSettingStore(
(state) => state.settings?.doubleSpacedLines
);
const postMessage = useCallback(
async (type, data) => post(ref, sessionId, type, data),
[sessionId]
async (type, data) => post(ref, type, data),
[]
);
const loadNote = useCallback(
(note) => {
postMessage(EditorEvents.html, note.content.data);
postMessage("html", note.content.data);
currentNote.current = note;
},
[postMessage]
@@ -69,58 +81,41 @@ const useEditor = () => {
}, [loadNote]);
const onLoad = () => {
postMessage(EditorEvents.theme, theme);
commands.setInsets({ top: 0, left: 0, right: 0, bottom: 0 });
commands.setSettings({
deviceMode: "mobile",
fullscreen: false,
premium: false,
readonly: false,
tools: getDefaultPresets().default,
noHeader: true,
noToolbar: true,
keyboardShown: false,
doubleSpacedLines: doubleSpacedLines
});
setTimeout(() => {
postMessage(
"theme",
`
body * {
color: ${colors.primary.paragraph};
}
h1,
h2,
h3,
h4,
h5,
h6 {
color: ${colors.primary.heading};
}
a {
color: ${colors.primary.accent};
}
`
);
}, 300);
};
return { ref, onLoad, sessionId, currentNote, commands };
return { ref, onLoad, currentNote, commands };
};
const useEditorEvents = (editor, onChange) => {
const doubleSpacedLines = useSettingStore(
(state) => state.settings?.doubleSpacedLines
);
useEffect(() => {
editor.commands.setSettings({
deviceMode: "mobile",
fullscreen: false,
premium: false,
readonly: false,
tools: getDefaultPresets().default,
noHeader: true,
noToolbar: true,
keyboardShown: false,
doubleSpacedLines: doubleSpacedLines
});
}, [editor, doubleSpacedLines]);
const onMessage = (event) => {
const data = event.nativeEvent.data;
const editorMessage = JSON.parse(data);
if (
editorMessage.sessionId !== editor.sessionId &&
editorMessage.type !== EditorEvents.status
) {
return;
}
switch (editorMessage.type) {
case EventTypes.logger:
console.log("[WEBVIEW LOG]", editorMessage.value);
break;
case EventTypes.content:
console.log("[WEBVIEW LOG]", "EditorTypes.content");
case "content":
onChange(editorMessage.value);
break;
}
@@ -172,12 +167,6 @@ export const Editor = ({ onChange, onLoad }) => {
ref={editor.ref}
onLoad={editor.onLoad}
nestedScrollEnabled
injectedJavaScriptBeforeContentLoaded={`
globalThis.readonly=${false};
globalThis.noToolbar=${true};
globalThis.noHeader=${true};
`}
injectedJavaScript={`globalThis.sessionId="${editor.sessionId}";`}
javaScriptEnabled={true}
focusable={true}
setSupportMultipleWindows={false}

View File

@@ -17,8 +17,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { FlashList } from "@shopify/flash-list";
import React, { useEffect, useRef, useState } from "react";
import React, { useEffect, useRef, useState, FlatList } from "react";
import {
Platform,
StatusBar,
@@ -133,10 +132,7 @@ const ListItem = ({ item, mode, close }) => {
numberOfLines={1}
style={{
color: colors.primary.paragraph,
fontFamily:
item.type === "topic"
? "OpenSans-Regular"
: "OpenSans-SemiBold",
fontWeight: item.type === "topic" ? "normal" : "bold",
fontSize: 15
}}
>
@@ -293,7 +289,6 @@ export const Search = ({ close, getKeyboardHeight, quicknote, mode }) => {
placeholderTextColor={colors.primary.placeholder}
style={{
fontSize: 15,
fontFamily: "OpenSans-Regular",
flex: 1
}}
onChangeText={(value) => {
@@ -321,12 +316,11 @@ export const Search = ({ close, getKeyboardHeight, quicknote, mode }) => {
height: searchHeight > 550 ? 550 : searchHeight
}}
>
<FlashList
<FlatList
data={searchResults}
keyboardShouldPersistTaps="always"
keyboardDismissMode="none"
renderItem={renderItem}
estimatedItemSize={50}
ListHeaderComponent={
mode === "selectTags" &&
(searchResults.length === 0 ||
@@ -357,7 +351,6 @@ export const Search = ({ close, getKeyboardHeight, quicknote, mode }) => {
>
<Text
style={{
fontFamily: "OpenSans-Regular",
color: colors.secondary.icon
}}
>

View File

@@ -262,6 +262,7 @@ const ShareView = ({ quicknote = false }) => {
defaultNote.content.data = null;
setNote({ ...defaultNote });
const data = await ShareExtension.data();
if (!data || data.length === 0) {
setRawData({
value: ""
@@ -299,8 +300,9 @@ const ShareView = ({ quicknote = false }) => {
}
}
}
setNote({ ...note });
onLoad();
setNote({ ...note });
} catch (e) {
console.error(e);
}
@@ -479,8 +481,7 @@ const ShareView = ({ quicknote = false }) => {
<Text
style={{
color: colors.primary.paragraph,
fontSize: 17,
fontFamily: "OpenSans-Regular"
fontSize: 17
}}
>
Quick note
@@ -580,7 +581,7 @@ const ShareView = ({ quicknote = false }) => {
<Text
style={{
fontSize: 18,
fontFamily: "OpenSans-SemiBold",
fontWeight: "bold",
color: colors.primary.heading
}}
>
@@ -728,7 +729,6 @@ const ShareView = ({ quicknote = false }) => {
style={{
fontSize: 12,
color: colors.secondary.paragraph,
fontFamily: "OpenSans-Regular",
paddingHorizontal: 12,
marginBottom: 10,
flexWrap: "wrap"
@@ -738,7 +738,7 @@ const ShareView = ({ quicknote = false }) => {
<Text
style={{
color: colors.primary.accent,
fontFamily: "OpenSans-SemiBold"
fontWeight: "bold"
}}
>
{`"${appendNote.title}"`}
@@ -1191,7 +1191,6 @@ const Button = ({
style={[
{
fontSize: fontSize || 18,
fontFamily: "OpenSans-Regular",
color: textColor,
marginLeft: loading ? 10 : 5
},

56
package-lock.json generated
View File

@@ -19,6 +19,7 @@
},
"devDependencies": {
"@commitlint/cli": "^17.1.1",
"@types/listr": "^0.14.4",
"@types/node": "^18.7.13",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
@@ -2791,6 +2792,34 @@
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==",
"dev": true
},
"node_modules/@types/listr": {
"version": "0.14.4",
"resolved": "https://registry.npmjs.org/@types/listr/-/listr-0.14.4.tgz",
"integrity": "sha512-+MWvidNujBUgJsi4yMVwEQQwaHe6oHedPSy+dwk3akGEeuIbvhWkK+TGsXSwbFup7Y0cCBb+wzzdD+yGKp7sOg==",
"dev": true,
"dependencies": {
"@types/node": "*",
"rxjs": "^6.5.1"
}
},
"node_modules/@types/listr/node_modules/rxjs": {
"version": "6.6.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz",
"integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==",
"dev": true,
"dependencies": {
"tslib": "^1.9.0"
},
"engines": {
"npm": ">=2.0.0"
}
},
"node_modules/@types/listr/node_modules/tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
},
"node_modules/@types/minimist": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz",
@@ -11755,6 +11784,33 @@
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==",
"dev": true
},
"@types/listr": {
"version": "0.14.4",
"resolved": "https://registry.npmjs.org/@types/listr/-/listr-0.14.4.tgz",
"integrity": "sha512-+MWvidNujBUgJsi4yMVwEQQwaHe6oHedPSy+dwk3akGEeuIbvhWkK+TGsXSwbFup7Y0cCBb+wzzdD+yGKp7sOg==",
"dev": true,
"requires": {
"@types/node": "*",
"rxjs": "^6.5.1"
},
"dependencies": {
"rxjs": {
"version": "6.6.7",
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-6.6.7.tgz",
"integrity": "sha512-hTdwr+7yYNIT5n4AMYp85KA6yw2Va0FLa3Rguvbpa4W3I5xynaBZo41cM3XM+4Q6fRMj3sBYIR1VAmZMXYJvRQ==",
"dev": true,
"requires": {
"tslib": "^1.9.0"
}
},
"tslib": {
"version": "1.14.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
"integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
"dev": true
}
}
},
"@types/minimist": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz",

View File

@@ -35,6 +35,7 @@
},
"devDependencies": {
"@commitlint/cli": "^17.1.1",
"@types/listr": "^0.14.4",
"@types/node": "^18.7.13",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",

View File

@@ -80,6 +80,7 @@
"scripts": {
"test": "vitest run",
"prebuild": "node ./scripts/build.mjs",
"postbuild": "node ./scripts/postbuild.mjs",
"prewatch": "node ./scripts/build.mjs",
"build": "tsc",
"watch": "tsc --watch",

View File

@@ -0,0 +1,53 @@
/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import * as Mjs from "@mdi/js";
import path from "path";
import fs from "fs";
import { fileURLToPath } from "url";
import { readFile, writeFile } from "fs/promises";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const ROOT_DIR = path.resolve(path.join(__dirname, ".."));
const DIST_DIR = path.resolve(ROOT_DIR, "dist");
const ICONS_FILE_PATH = path.join(DIST_DIR, "toolbar", "icons.js");
if (!fs.existsSync(DIST_DIR) || !fs.existsSync(ICONS_FILE_PATH))
throw new Error("Please build the editor before running this script.");
console.log("Replacing icons with their path...");
let ICON_FILE = await readFile(ICONS_FILE_PATH, "utf-8");
const icons = ICON_FILE.matchAll(/: (mdi.+),/g);
for (const icon of icons) {
const iconPath = Mjs[icon[1]];
if (!iconPath) throw new Error(`Could not find path for icon: ${icon[1]}.`);
ICON_FILE = ICON_FILE.replace(icon[0], `: "${iconPath}",`);
}
console.log("Removing @mdi/js import...");
ICON_FILE = ICON_FILE.replace(/^import \{.+ } from "@mdi\/js";/gm, "");
console.log("Saving file...");
await writeFile(ICONS_FILE_PATH, ICON_FILE);
console.log("Done.");