Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

refactor: run prettier on the whole codebase

thecodrre898ef5d86d9
diff --git a/.prettierignore b/.prettierignore
index 6fd05c848..6b4f155a0 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -1,6 +1,14 @@
+# all
build
coverage
node_modules
dist
-native/
-public/an.js
\ No newline at end of file
+
+# mobile
+apps/mobile/native/
+
+# web
+apps/web/public/an.js
+
+# editor
+packages/editor/styles/
\ No newline at end of file
diff --git a/apps/mobile/.eslintrc.js b/apps/mobile/.eslintrc.js
index 831ede52e..c6a70e997 100644
--- a/apps/mobile/.eslintrc.js
+++ b/apps/mobile/.eslintrc.js
@@ -1,16 +1,16 @@
module.exports = {
- parser: '@typescript-eslint/parser',
+ parser: "@typescript-eslint/parser",
env: {
browser: true,
es2021: true,
- 'react-native/react-native': true
+ "react-native/react-native": true
},
extends: [
- 'eslint:recommended',
- 'plugin:react/recommended',
- 'plugin:prettier/recommended',
- 'plugin:@typescript-eslint/eslint-recommended',
- 'plugin:@typescript-eslint/recommended'
+ "eslint:recommended",
+ "plugin:react/recommended",
+ "plugin:prettier/recommended",
+ "plugin:@typescript-eslint/eslint-recommended",
+ "plugin:@typescript-eslint/recommended"
],
parserOptions: {
ecmaFeatures: {
@@ -18,22 +18,31 @@ module.exports = {
},
ecmaVersion: 12,
es6: true,
- sourceType: 'module'
+ sourceType: "module"
},
- plugins: ['react', 'react-native', 'prettier', 'unused-imports', '@typescript-eslint'],
+ plugins: [
+ "react",
+ "react-native",
+ "prettier",
+ "unused-imports",
+ "@typescript-eslint"
+ ],
rules: {
- 'react/display-name': 0,
- 'no-unused-vars': 'off',
- 'react/no-unescaped-entities': 'off',
- 'unused-imports/no-unused-vars': 'off',
- '@typescript-eslint/ban-ts-comment': 'off',
- '@typescript-eslint/no-unused-vars': 'off',
- 'prefer-const': 'off',
- 'no-empty': 'off',
- 'react/prop-types': 0,
- 'react/jsx-filename-extension': [1, { extensions: ['.js', '.jsx', 'ts', 'tsx'] }],
- 'prettier/prettier': [
- 'error',
+ "react/display-name": 0,
+ "no-unused-vars": "off",
+ "react/no-unescaped-entities": "off",
+ "unused-imports/no-unused-vars": "off",
+ "@typescript-eslint/ban-ts-comment": "off",
+ "@typescript-eslint/no-unused-vars": "off",
+ "prefer-const": "off",
+ "no-empty": "off",
+ "react/prop-types": 0,
+ "react/jsx-filename-extension": [
+ 1,
+ { extensions: [".js", ".jsx", "ts", "tsx"] }
+ ],
+ "prettier/prettier": [
+ "error",
{},
{
usePrettierrc: true
diff --git a/apps/mobile/.github/workflows/android-public-release.yml b/apps/mobile/.github/workflows/android-public-release.yml
index 4cc17217c..de27c8485 100644
--- a/apps/mobile/.github/workflows/android-public-release.yml
+++ b/apps/mobile/.github/workflows/android-public-release.yml
@@ -28,13 +28,13 @@ jobs:
- uses: actions/setup-node@master
with:
- node-version: '16'
+ node-version: "16"
- name: Use specific Java version for the builds
uses: joschi/setup-jdk@v2
with:
- java-version: '11'
- architecture: 'x64'
+ java-version: "11"
+ architecture: "x64"
- name: Install node modules
run: |
diff --git a/apps/mobile/.github/workflows/android-release.yml b/apps/mobile/.github/workflows/android-release.yml
index 8946e4211..a4057d7b3 100644
--- a/apps/mobile/.github/workflows/android-release.yml
+++ b/apps/mobile/.github/workflows/android-release.yml
@@ -28,13 +28,13 @@ jobs:
- uses: actions/setup-node@master
with:
- node-version: '16'
+ node-version: "16"
- name: Use specific Java version for the builds
uses: joschi/setup-jdk@v2
with:
- java-version: '11'
- architecture: 'x64'
+ java-version: "11"
+ architecture: "x64"
- name: Install node modules
run: |
diff --git a/apps/mobile/.prettierrc.js b/apps/mobile/.prettierrc.js
deleted file mode 100644
index 4a66763d4..000000000
--- a/apps/mobile/.prettierrc.js
+++ /dev/null
@@ -1,13 +0,0 @@
-module.exports = {
- arrowParens: 'avoid',
- bracketSpacing: true,
- jsxBracketSameLine: false,
- jsxSingleQuote: false,
- quoteProps: 'as-needed',
- singleQuote: true,
- semi: true,
- printWidth: 100,
- useTabs: false,
- tabWidth: 2,
- trailingComma: 'none'
-};
diff --git a/apps/mobile/.vscode/launch.json b/apps/mobile/.vscode/launch.json
index 7a623a22a..1a48c7f0c 100644
--- a/apps/mobile/.vscode/launch.json
+++ b/apps/mobile/.vscode/launch.json
@@ -4,8 +4,6 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
-
-
{
"name": "Debug Android",
"cwd": "${workspaceFolder}",
@@ -27,4 +25,4 @@
"request": "attach"
}
]
-}
\ No newline at end of file
+}
diff --git a/apps/mobile/.watchmanconfig b/apps/mobile/.watchmanconfig
index 9e26dfeeb..0967ef424 100644
--- a/apps/mobile/.watchmanconfig
+++ b/apps/mobile/.watchmanconfig
@@ -1 +1 @@
-{}
\ No newline at end of file
+{}
diff --git a/apps/mobile/__tests__/App-test.js b/apps/mobile/__tests__/App-test.js
index a98d92c8a..8fd0553bf 100644
--- a/apps/mobile/__tests__/App-test.js
+++ b/apps/mobile/__tests__/App-test.js
@@ -2,21 +2,21 @@
* @format
*/
-import React from 'react';
-import 'react-native';
+import React from "react";
+import "react-native";
// Note: test renderer must be required after react-native.
-import renderer from 'react-test-renderer';
-import Heading from '../app/components/ui/typography/heading';
-import Paragraph from '../app/components/ui/typography/paragraph';
+import renderer from "react-test-renderer";
+import Heading from "../app/components/ui/typography/heading";
+import Paragraph from "../app/components/ui/typography/paragraph";
-it('Heading renders correctly', done => {
+it("Heading renders correctly", (done) => {
let instance = renderer.create(<Heading>Heading</Heading>);
- expect(instance.root.props.children).toBe('Heading');
+ expect(instance.root.props.children).toBe("Heading");
done();
});
-it('Paragraph renders correctly', done => {
+it("Paragraph renders correctly", (done) => {
let instance = renderer.create(<Paragraph>Paragraph</Paragraph>);
- expect(instance.root.props.children).toBe('Paragraph');
+ expect(instance.root.props.children).toBe("Paragraph");
done();
});
diff --git a/apps/mobile/app/app.js b/apps/mobile/app/app.js
index 9bed15ffc..0e90d6544 100644
--- a/apps/mobile/app/app.js
+++ b/apps/mobile/app/app.js
@@ -1,14 +1,14 @@
-import React, { useEffect } from 'react';
-import { GestureHandlerRootView } from 'react-native-gesture-handler';
-import { SafeAreaProvider } from 'react-native-safe-area-context';
-import { withErrorBoundry } from './components/exception-handler';
-import Launcher from './components/launcher';
-import { ApplicationHolder } from './navigation';
-import Notifications from './services/notifications';
-import SettingsService from './services/settings';
-import { TipManager } from './services/tip-manager';
-import { useUserStore } from './stores/use-user-store';
-import { useAppEvents } from './hooks/use-app-events';
+import React, { useEffect } from "react";
+import { GestureHandlerRootView } from "react-native-gesture-handler";
+import { SafeAreaProvider } from "react-native-safe-area-context";
+import { withErrorBoundry } from "./components/exception-handler";
+import Launcher from "./components/launcher";
+import { ApplicationHolder } from "./navigation";
+import Notifications from "./services/notifications";
+import SettingsService from "./services/settings";
+import { TipManager } from "./services/tip-manager";
+import { useUserStore } from "./stores/use-user-store";
+import { useAppEvents } from "./hooks/use-app-events";
SettingsService.init();
SettingsService.checkOrientation();
@@ -16,7 +16,7 @@ const App = () => {
useAppEvents();
useEffect(() => {
let { appLockMode } = SettingsService.get();
- if (appLockMode && appLockMode !== 'none') {
+ if (appLockMode && appLockMode !== "none") {
useUserStore.getState().setVerifyUser(true);
}
setTimeout(() => {
@@ -39,4 +39,4 @@ const App = () => {
);
};
-export default withErrorBoundry(App, 'App');
+export default withErrorBoundry(App, "App");
diff --git a/apps/mobile/app/assets/images/assets.js b/apps/mobile/app/assets/images/assets.js
index f78210ad6..0a66eec9b 100644
--- a/apps/mobile/app/assets/images/assets.js
+++ b/apps/mobile/app/assets/images/assets.js
@@ -1,12 +1,12 @@
-export const LAUNCH_ROCKET = color =>
+export const LAUNCH_ROCKET = (color) =>
`<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" width="748.82965" height="557.20035" viewBox="0 0 748.82965 557.20035" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M276.60133,642.057c-3.59968,0-7.20676.1709-10.72934.51563l-.51267.0498c-23.36542,2.37793-40.45611,16.17286-39.75323,32.08985l.13588,2.87793c.08961,1.81933.18508,3.77539.26367,5.94531.04255,1.07031,1.31106,1.8916,2.88946,1.8916H803.62751c40.52148-.2832,80.89606-.63965,119.9956-1.05957a177.65216,177.65216,0,0,0,21.95374-1.30957c10.86591-1.48047,18.40759-4.415,23.05841-8.97168h.00147c5.78332-5.65039,5.96551-12.76562,5.6159-20.80469-.71246-16.23242-1.419-33.28515-2.12414-50.28613-.62281-14.9834-1.24274-29.92676-1.86261-44.2334-.38343-8.49023-1.23536-15.98437-7.80317-21.71191-7.11865-6.19434-20.10137-9.334-38.58831-9.334-.22333,0-.44507,0-.67133.001-57.9361.23731-115.34192,23.1709-142.8454,57.06732-3.16711,3.90332-6.11822,8.082-8.97247,12.124a158.91584,158.91584,0,0,1-13.7804,17.66406,66.94863,66.94863,0,0,1-9.10321,8.16894c-.22326.17774-.47888.36817-.7492.54883-.61847.46387-1.26477.91114-1.895,1.30957a62.04148,62.04148,0,0,1-11.60926,6.07617l-.40692.15723c-.30627.126-.6383.252-.97027.36719a68.20886,68.20886,0,0,1-7.17,2.20605c-10.484,2.66016-22.40545,3.29785-35.43151,1.89356a151.75182,151.75182,0,0,1-35.2295-8.26465c-12.06244-4.38867-23.3529-9.86035-34.27173-15.15137-4.79614-2.32519-9.75683-4.72851-14.711-7.00586-.93134-.42871-1.84723-.84765-2.7771-1.2666-6.05066-2.71484-11.5365-4.957-16.77045-6.85449a146.28118,146.28118,0,0,0-39.96478-8.52149c-14.40918-.9082-27.10688.80469-37.73191,5.07911a60.6496,60.6496,0,0,0-8.53469,4.23339c-12.58466,7.52344-20.343,18.627-27.845,29.36524-9.33233,13.35644-18.98275,27.16894-38.0382,34.3291-21.98825,8.26953-54.08371,4.834-76.791-1.14062-7.13919-1.87891-14.26956-4.04-21.16565-6.13086q-4.17768-1.26719-8.36136-2.51661c-5.48071-1.6289-9.96621-2.877-14.116-3.93066l-1.31253-.33594c-.73008-.18261-1.46088-.36523-2.20493-.53906-4.92911-1.19141-9.51892-2.12891-14.03891-2.86621l-1.06943-.17969c-2.144-.32519-4.14834-.5957-6.11526-.82324l-.78516-.08984A109.23844,109.23844,0,0,0,276.60133,642.057Z" transform="translate(-225.58517 -171.39982)" fill="#f2f2f2"/><path d="M343.64,685.3514a1.19069,1.19069,0,0,1,1.18683-1.19452h510.294a1.19069,1.19069,0,0,1,0,2.38135h-510.294A1.19066,1.19066,0,0,1,343.64,685.3514Z" transform="translate(-225.58517 -171.39982)" fill="#cacaca"/><path d="M746.00469,214.43986a42.86006,42.86006,0,0,1-11.46,29.24c-.56.61-1.15,1.2-1.75,1.77a650.40347,650.40347,0,0,0-69.84-46.89c.3-.76.62-1.51.97-2.25a43.04295,43.04295,0,0,1,82.08,18.13Z" transform="translate(-225.58517 -171.39982)" fill="#ff6584"/><path d="M780.91466,302.03984l-.04.45q-42.465-2.925-84.92-5.86c-20.45-1.41-41.61-3.01-59.68-12.69-6.86005-3.67-13.54-8.57-21.32-8.91-9.65-.43-18.07,6.32-24.69,13.36-39.13,41.68-50.46,105.41-94.36,142.02a1394.13755,1394.13755,0,0,1,98.86-197.31c7.04-11.65,15.39-24.09,28.46-27.89,12.47-3.63,25.23,1.67,36.71,8.47,2.46,1.46,4.86,2.99,7.18,4.51q26.535,17.36994,52.2,36.06995Q750.82971,277.19487,780.91466,302.03984Z" transform="translate(-225.58517 -171.39982)" fill="#f2f2f2"/><path d="M872.47466,390.43986a670.65125,670.65125,0,0,0-104.75-116.27q-16.965-14.91-34.93-28.72a650.40347,650.40347,0,0,0-69.84-46.89q-11.94-6.93-24.16-13.31c-6.33-3.29-13.07-6.3-20.37-5.83a27.10218,27.10218,0,0,0-14.07,5.41c-8.97,6.55-14.91,16.78-19.8,26.53-4.28,8.55-8.27,17.27-12.34,25.94-1.73,3.69-3.46,7.37-5.25,11.03q-9.36008,19.23-19.16,38.25-12.63,24.51-25.99,48.65-28.065,50.745-59.23,99.66-45.81006,71.895-98.02,139.43c-4.27,5.51-6.03,6.79-10.36,12.26-1,1.28-2.78-.52-1.79-1.79,36.11005-45.64,67.55005-88.76,99.25-137.58q35.85-55.215,67.76-112.88,10.245-18.49494,20.06-37.22,15.885-30.315,30.67-61.2,3.9-8.13,7.72-16.32c8.09-17.33,19.87-43.1,42.62-42.75,6.69.1,12.9,2.81,18.76,5.81,5.97,3.07,11.83,6.33,17.68,9.64q3.51,1.98,6.99,4.02,13.785,8.00994,27.16,16.69,22.32,14.47494,43.46,30.68,10.035,7.695,19.77,15.74a673.54712,673.54712,0,0,1,109.09,114.31q5.74493,7.635,11.25,15.44C875.59472,390.49986,873.40472,391.75981,872.47466,390.43986Z" transform="translate(-225.58517 -171.39982)" fill="#e4e4e4"/><path d="M769.97685,261.4421c1.32186-1.47358,2.63549-2.94715,3.966-4.42072C784.43462,245.418,795.6924,233.94944,810.1,227.2973a52.4571,52.4571,0,0,1,21.97735-5.09434c7.86453.02529,15.55227,2.08825,22.819,4.97649,3.43559,1.37253,6.79554,2.93029,10.10449,4.58908,3.781,1.903,7.4945,3.93237,11.19076,5.97852q10.40791,5.75957,20.54571,12.02432,20.17137,12.46641,39.07925,26.83584,9.80167,7.45209,19.19878,15.39253,8.74029,7.37624,17.127,15.14831c1.19563,1.10307,2.98086-.68205,1.78523-1.78512-1.47357-1.37253-2.964-2.73664-4.45443-4.08388q-6.31532-5.70906-12.8329-11.19919-11.885-10.0287-24.38547-19.2827-19.43869-14.39893-40.21568-26.84427-10.38264-6.21425-21.051-11.90647c-2.14745-1.14516-4.32-2.26509-6.51759-3.32607a103.89918,103.89918,0,0,0-15.49347-6.30688,55.11725,55.11725,0,0,0-23.40035-2.29875,60.92335,60.92335,0,0,0-21.59005,7.46889c-14.14612,7.90678-25.11773,20.13318-35.795,32.06494C767.11358,260.86109,768.89058,262.65464,769.97685,261.4421Z" transform="translate(-225.58517 -171.39982)" fill="#e4e4e4"/><path d="M480.12667,381.68342l-33.89782-12.39828-16.83038-6.15579c-5.48137-2.00484-10.94957-4.28719-16.616-5.72275a26.21362,26.21362,0,0,0-15.03952.19162,34.66256,34.66256,0,0,0-11.73046,7.27166,95.19524,95.19524,0,0,0-9.62144,10.275c-3.66428,4.40365-7.27444,8.85345-10.90079,13.28835q-22.45,27.45558-44.6064,55.14948-22.1559,27.69344-44.01554,55.62218-21.91307,27.997-43.52474,56.22818-2.64747,3.45842-5.2904,6.92031c-.97346,1.275-3.16844.018-2.18124-1.275q21.77112-28.515,43.84571-56.79666,22.1289-28.3492,44.56359-56.45793,22.43425-28.10817,45.17171-55.97256,5.66458-6.94185,11.34787-13.86842c3.196-3.89521,6.356-7.83243,9.86155-11.45793,6.43462-6.65486,14.47386-12.536,24.09692-12.69554,5.65786-.09382,11.13345,1.70155,16.3902,3.60326,5.667,2.05012,11.32041,4.1386,16.98015,6.20868l34.13486,12.485,8.53372,3.12124c1.51441.55391.8602,2.99613-.67154,2.43589Z" transform="translate(-225.58517 -171.39982)" fill="#e4e4e4"/><path d="M814.56088,241.89784c17.22612-8.85335,39.28657-7.11936,55.11616,3.94157a786.11526,786.11526,0,0,0-89.43729,20.87423C792.44014,259.5639,801.98377,248.36189,814.56088,241.89784Z" transform="translate(-225.58517 -171.39982)" fill="#f2f2f2"/><path d="M869.84659,245.80893l3.31625,2.69552c-1.12172-.94344-2.28786-1.828-3.4858-2.665C869.73362,245.82965,869.79,245.8187,869.84659,245.80893Z" transform="translate(-225.58517 -171.39982)" fill="#f2f2f2"/><path d="M387.28886,381.80727c3.33682-4.06177,6.94448-8.31469,11.93551-9.96449l4.65975.18379A528.5525,528.5525,0,0,1,263.10428,532.971Q325.19657,457.38918,387.28886,381.80727Z" transform="translate(-225.58517 -171.39982)" fill="#f2f2f2"/><path d="M736.79357,610.34291l-28.21714-12.44874V587.19183l10.0561-.05651a7.46918,7.46918,0,0,0,7.044-5.10714l7.06437-21.193a7.46924,7.46924,0,0,0-7.08594-9.83122h-17.0785v-9.959h21.44024a7.46925,7.46925,0,0,0,7.27937-5.79584l4.865-21.16286a7.46923,7.46923,0,0,0-7.27937-9.14265H708.57643v-2.48975a4.97949,4.97949,0,0,0-9.959,0v2.48975H522.26028v-2.48975a4.9795,4.9795,0,0,0-9.959,0v2.48975h-20.9108a7.46923,7.46923,0,0,0-7.27937,9.14265l4.865,21.16286a7.46925,7.46925,0,0,0,7.27937,5.79584h16.04578v9.959H500.617a7.46923,7.46923,0,0,0-7.10927,9.76L500.7181,583.141a7.46925,7.46925,0,0,0,7.15123,5.17837l4.432-.0249v9.59968l-22.82269,12.44874a7.46922,7.46922,0,0,0-7.46924,7.46922v0a7.46925,7.46925,0,0,0,7.46924,7.46925h22.82269v54.77446a4.9795,4.9795,0,0,0,9.959,0V625.2814H698.61744v54.77446a4.9795,4.9795,0,0,0,9.959,0V625.2814h28.21714a7.46925,7.46925,0,0,0,7.46925-7.46925v0A7.46922,7.46922,0,0,0,736.79357,610.34291Zm-214.53329-69.298H698.61744v9.959H522.26028Zm0,56.84925v-9.65563l176.35716-.99076v10.64639Z" transform="translate(-225.58517 -171.39982)" fill="#ccc"/><path d="M315.95555,589.21408l7.98486-26.00457a87.77022,87.77022,0,0,0-35.0839-23.50552c13.12443,21.74329.40683,50.10772,5.70643,74.94591a52.79391,52.79391,0,0,0,28.27717,35.97783l12.11706,15.0135a88.46589,88.46589,0,0,0,6.50218-73.78667,85.453,85.453,0,0,0-9.89442-19.0176C324.36444,581.302,315.95555,589.21408,315.95555,589.21408Z" transform="translate(-225.58517 -171.39982)" fill="#f2f2f2"/><path d="M272.05023,592.53665l-4.45075-26.83629a87.7702,87.7702,0,0,0-41.8846-5.39169c21.444,13.60792,22.71121,44.6671,38.53194,64.53481a52.79391,52.79391,0,0,0,41.3547,19.59061l17.541,8.03374a88.466,88.466,0,0,0-27.08773-68.942,85.45248,85.45248,0,0,0-17.3374-12.60883C276.04789,581.70478,272.05023,592.53665,272.05023,592.53665Z" transform="translate(-225.58517 -171.39982)" fill="#f2f2f2"/><path d="M902.5106,479.11845,885.044,458.26383a87.77019,87.77019,0,0,1,23.18573-35.29606c-3.63882,25.13524,19.10562,46.32412,23.87929,71.26873a52.79386,52.79386,0,0,1-12.06557,44.141l-5.327,18.54322a88.4659,88.4659,0,0,1-34.67683-65.45432,85.45238,85.45238,0,0,1,1.72257-21.36823C891.68721,475.0979,902.5106,479.11845,902.5106,479.11845Z" transform="translate(-225.58517 -171.39982)" fill="#f2f2f2"/><path d="M944.2538,465.1105,937.92125,438.655a87.77005,87.77005,0,0,1,36.49358-21.25108c-14.46674,20.87426-3.55934,49.98279-10.41151,74.43825a52.79393,52.79393,0,0,1-30.48523,34.127l-13.03785,14.2212a88.46591,88.46591,0,0,1-1.84586-74.0496,85.45328,85.45328,0,0,1,11.0716-18.35724C936.35949,456.68492,944.2538,465.1105,944.2538,465.1105Z" transform="translate(-225.58517 -171.39982)" fill="#f2f2f2"/><polygon points="373.867 536.045 362.393 541.58 335.583 499.958 352.517 491.789 373.867 536.045" fill="#ffb6b6"/><path d="M600.74559,539.92239,590.54818,555.309s-60.63447,40.15326-58.10323,55.09015c.88547,5.22518,4.73286,16.21626,9.68184,28.46477,1.52072,3.76372,8.6663,11.24446,10.34108,15.11482,8.45541,19.54026,12.66545,35.17435,16.72606,37.26588,4.50965,2.33785,4.0477.48289,6.81076,4.74524l16-6s2.492-5.59411,3.72976-8.36482-.70312-4.14914-.70312-4.14914-2.34884,1.25171-1.9409-1.37838.26732-3.45993-.70312-4.14914-4.72555-7.73579-4.72555-7.73579a69.82223,69.82223,0,0,1-8.19389-16.23385c-.89266-2.521-.8037-8.56182-2-11-2.52046-5.13691-3.41208-8.92851-7.48445-11.59957,0,0,51.26687-24.90725,56.0774-36.82s-.13917-51.19588-.13917-51.19588Z" transform="translate(-225.58517 -171.39982)" fill="#2f2e41"/><path d="M605.53555,713.49,566.738,728.60018l-.19114-.49072A16.2068,16.2068,0,0,1,575.766,707.127l.001-.00038,4.99263-8.13674,15.31681.227,3.38679-1.319Z" transform="translate(-225.58517 -171.39982)" fill="#2f2e41"/><polygon points="470.462 475.448 489.209 474.029 486.873 523.483 474.17 524.444 470.462 475.448" fill="#ffb6b6"/><path d="M593.02692,553.52922c-4.3106-18.98155,7.83714,37.61669,20.4366,48.19854,4.95423,4.16091,25.69256-.14621,42.8621,1.16619a87.67112,87.67112,0,0,1,30.31954,8.23641c-2.73885,4.99134.12692,12.43982.6598,19.13657.97215,12.21694,1.951,23.45149,1.951,23.45149s-.00949,7.98466-.54308,9.04866-.26835,1.86279,1.326,3.99393-1.06716,2.12794-1.06716,2.12794-1.06715,2.128,1.326,3.99393,8.07377,7.30057,8.07377,7.30057l15.2371-1.353c.44-5.06062,1.75485-5.72611,4.64021-9.90671,2.74584-3.95613,2.11713-27.69491.18239-49.97665-.13112-1.5101,1.975-6.26147,1.83251-7.75157-1.42952-14.95072-5.64132-25.31417-7.49858-30.90816-1.28141-3.85954-7.43466-7.18789-15.75192-9.99213-1.26923-.42794-2.58886-.84367-3.94927-1.24722-22.9351-6.80347-57.45854-10.145-57.45854-10.145l-18.87706-16.79029Z" transform="translate(-225.58517 -171.39982)" fill="#2f2e41"/><path d="M698.047,693.13029l3.44938-1.14538,11.64877-9.948,9.036,3.07948.001-.00032a16.2068,16.2068,0,0,1,20.48676,10.27369l.16594.49981-39.51465,13.1209Z" transform="translate(-225.58517 -171.39982)" fill="#2f2e41"/><path d="M610.42386,444.23228l-11.34,8.635-13.676,4.20263s-5.65377,79.52833-10.74813,84.62269-.49987,5.23128-1.52352,11.84916-3.51168,20.18377-3.51168,20.18377c34.38707,18.20258,64.03233,18.69086,87.845-2.60926a5.93117,5.93117,0,0,0-3.23608-6.69462c-4.43194-2.35163,4.08556-13.32756.4636-15.16273s1.47241-17.755,1.47241-17.755l-3.34187-33.21557,2.64024-5.30957-6.44317-32.48858-11.18013-4.083-4.466-10.76026Z" transform="translate(-225.58517 -171.39982)" fill="${color}"/><circle cx="396.44756" cy="245.59574" r="22.43078" fill="#ffb6b6"/><path d="M603.31993,585.581a9.8303,9.8303,0,0,0-11.20736-10.08022l-15.98166-31.06366L567.227,560.25692l16.54148,27.07327a9.88361,9.88361,0,0,0,19.55136-1.74918Z" transform="translate(-225.58517 -171.39982)" fill="#ffb6b6"/><path d="M576.40552,577.98205l-34.27838-53.12743.11315-.24444c.12942-.28007,7.89169-17.0446,15.413-32.39983,1.15826-2.36467,2.31081-4.69592,3.42889-6.9284q.72381-1.44525,1.42605-2.83006c3.159-6.22783,5.919-11.37528,7.56649-13.8204A29.01536,29.01536,0,0,1,585.45,456.96784l.15859-.04078.15141.06312a14.72433,14.72433,0,0,1,8.76284,16.19753,104.296,104.296,0,0,1-19.35291,43.755l-5.557,7.32473,19.31154,41.98522Z" transform="translate(-225.58517 -171.39982)" fill="${color}"/><path d="M665.672,597.791v1.42726a3.15238,3.15238,0,0,1-3.1517,3.15168H557.69779a3.15237,3.15237,0,0,1-3.1517-3.15168V597.791a3.15235,3.15235,0,0,1,3.1517-3.15167H559.559a2.65083,2.65083,0,0,1-.10157-.70776V540.43129a2.645,2.645,0,0,1,2.64324-2.64334h96.01673a2.645,2.645,0,0,1,2.64325,2.64334v53.50028a2.49845,2.49845,0,0,1-.10158.70776h1.8612A3.15235,3.15235,0,0,1,665.672,597.791Z" transform="translate(-225.58517 -171.39982)" fill="#3f3d56"/><path d="M612.17439,568.01513a5.99072,5.99072,0,1,1,5.99071-5.99072A5.99747,5.99747,0,0,1,612.17439,568.01513Zm0-10.94882a4.95811,4.95811,0,1,0,4.9581,4.9581A4.96375,4.96375,0,0,0,612.17439,557.06631Z" transform="translate(-225.58517 -171.39982)" fill="#fff"/><circle cx="384.52404" cy="388.55935" r="5.47437" fill="#fff"/><path d="M694.27889,374.33627a9.83029,9.83029,0,0,0,2.35881,14.888l-7.14559,34.1951,16.87861-6.68267,4.19795-31.44773A9.88361,9.88361,0,0,0,694.279,374.33631Z" transform="translate(-225.58517 -171.39982)" fill="#ffb6b6"/><path d="M710.402,397.18741l-6.82552,62.85653-.24182.11865c-.19928.09793-8.84664,4.33935-19.46132,9.3906-1.79066.85213-1.534,4.54333-3.40547,5.42554-1.28914.60769-4.69342-1.5973-5.996-.98816-11.6023,5.42574-23.33421,10.70159-28.00981,12.13114a29.01531,29.01531,0,0,1-19.2887-.621l-.14887-.06818-.07788-.14438a14.72433,14.72433,0,0,1,3.39225-18.10082,104.29609,104.29609,0,0,1,42.58656-21.80405l8.92931-2.19087,11.43611-44.77622Z" transform="translate(-225.58517 -171.39982)" fill="${color}"/><path d="M672.18567,373.68221l2.56841,23.30916A2.84507,2.84507,0,0,0,677.47344,399h11.83939a2.84516,2.84516,0,0,0,2.71966-2.00863l2.12733-17.86534A4.32088,4.32088,0,1,0,695.274,370.998a2.8198,2.8198,0,0,0-2.15867-.998h-18.21A2.84558,2.84558,0,0,0,672.18567,373.68221Zm22.34593,4.23569,1.303-4.23569a2.8158,2.8158,0,0,0,.04308-1.506c.05574-.003.10816-.01661.1645-.01661a3.08511,3.08511,0,0,1,0,6.17022A3.04612,3.04612,0,0,1,694.5316,377.9179Z" transform="translate(-225.58517 -171.39982)" fill="#3f3d56"/><path d="M640.30289,397.72555c-1.84465-5.36654-11.02746-9.08881-25.91418-9.60638s-18.66227,17.02576-18.66227,17.02576c-9.938,8.06174,10.61182,29.64505,11.606,28.86767l-.447-4.05508C606.1452,423.24079,603,418,607,411l3.841.0441q7.441,1.43086,14.882,2.8617l-5.87291-5.17092.1656-.25624a22.7265,22.7265,0,0,0,8.01667,2.43412c3.15652.18554,6.6074-1.0707,8.11933-3.84781a6.46562,6.46562,0,0,0,.72539-2.46008c4.25656,1.70064,6.203,6.94811,6.203,6.94811S642.14753,403.09209,640.30289,397.72555Z" transform="translate(-225.58517 -171.39982)" fill="#2f2e41"/></svg>`;
-export const COMMUNITY_SVG = color => `
+export const COMMUNITY_SVG = (color) => `
<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 1135 713"><defs/><path fill="${color}" d="M1128 491c-11 27-35 52-61 76q-33 31-72 59l-22 16-5 4-13 9-1 1-14 9a375 375 0 01-67 35l-11 4a199 199 0 01-41 8 303 303 0 01-110-11l-4-1c-39-9-77-23-116-32l-42-9-21-3a614 614 0 00-118 0l-9 1-10 3a187 187 0 00-27 11l-5 3-16 8a200 200 0 01-30 13 157 157 0 01-17 4 252 252 0 01-71 4h-1a361 361 0 01-44-5c-41-6-80-17-111-34-42-24-69-59-65-94 3-25 21-48 38-71 32-43 61-86 77-132 13-38 17-77 46-111 9-11 21-20 35-29a225 225 0 0133-16 282 282 0 0139-13 314 314 0 0136-7l19-2 15-1h11a437 437 0 0168 7l41 8 24 6 8 2c57 15 107 36 162 54a338 338 0 0035 9 503 503 0 0067 9h3l61 5 21 2 13 2 9 1 10 1a443 443 0 0144 7l22 4 16 3 12 3c31 8 61 18 86 32 65 36 95 96 73 148z" opacity=".1"/><circle cx="249" cy="68.8" r="21.6" fill="${color}" opacity=".1"/><circle cx="691.1" cy="21.6" r="21.6" fill="${color}" opacity=".1"/><circle cx="953.3" cy="70.1" r="21.6" fill="${color}" opacity=".1"/><circle cx="36.3" cy="121.1" r="36.3" fill="${color}" opacity=".1"/><circle cx="71" cy="300.1" r="36.3" fill="${color}" opacity=".1"/><circle cx="1043.9" cy="234.2" r="36.3" fill="${color}" opacity=".1"/><path fill="#be6f72" d="M354 239a39 39 0 010 9c-2 10-11 16-19 21s-17 9-22 18c-6 9-4 23 3 32s18 15 29 17c21 4 43-2 58-16s23-36 20-57c-9 1-16-6-19-14s-2-17-3-25a9 9 0 00-1-4c-1-2-3-2-5-3-10-3-26-8-36-6-9 2-5 21-5 28z"/><path d="M354 239a39 39 0 010 9c-2 10-11 16-19 21s-17 9-22 18c-6 9-4 23 3 32s18 15 29 17c21 4 43-2 58-16s23-36 20-57c-9 1-16-6-19-14s-2-17-3-25a9 9 0 00-1-4c-1-2-3-2-5-3-10-3-26-8-36-6-9 2-5 21-5 28z" opacity=".1"/><path fill="#be6f72" d="M343 682a200 200 0 01-30 13 157 157 0 01-17 4 108 108 0 011-23l2-13a34 34 0 00-4-19c12-1 22-4 33-3h1a12 12 0 014 1 11 11 0 014 4 26 26 0 012 2c3 6 4 12 4 18a121 121 0 010 16zM401 657l-10 3a187 187 0 00-27 11 40 40 0 01-1-8 46 46 0 0135-7 5 5 0 012 1 3 3 0 011 0z"/><path fill="#3f3d56" d="M418 607c0 7-1 13-4 19-2 7-6 13-6 20l2 10-9 1-10 3a187 187 0 00-27 11l-5 3h-3c-5-1-10-4-13-8a11 11 0 01-1-3c-2-4 0-11-3-14h-1a34 34 0 01-6 4 41 41 0 01-33 3 36 36 0 01-6-2c-5-3-9-7-9-13l2-8-3-6c-7-12 1-27-3-40v-1l-1-3-3-5a33 33 0 01-1-6 63 63 0 01-1-15c0-13 2-27 6-40l2-9a70 70 0 013-11c2-4 5-8 9-9 5-1 14 1 20 2l22 3 45 5a49 49 0 0123 7 25 25 0 015 5l1 2a42 42 0 014 7c6 13 6 28 6 43s0 30-2 45z"/><path d="M332 653l-4-14a188 188 0 01-4-21c-1-13-3-30 2-42 4 2 8 8 9 13 7 15 0 34 6 49a8 8 0 011 3 7 7 0 01-1 4l-3 4z" opacity=".1"/><path fill="#be6f72" d="M476 178c8-12 18-24 17-38l-3-15a94 94 0 01-1-43 49 49 0 0136 8c3 2 6 5 7 8 2 4 1 8 1 11 0 9-1 18-6 24l-5 6c-3 3-4 7-5 10l-17 47c-9 23-18 47-37 63-1 1-14-18-15-20-5-8-3-12 3-18 10-13 16-29 25-43z"/><path fill="#fbbebe" d="M281 572a77 77 0 01-1 10v4c-4 18-12 35-18 52-8 23-11 43-14 65h-24l-8-1c3-21-2-43 3-64 1-9 4-17 6-26a72 72 0 001-7l2-7a5 5 0 010-1 17 17 0 014-4 88 88 0 0143-21h6z"/><path d="M281 572a77 77 0 01-1 10v4c-4 18-12 35-18 52-8 23-11 43-14 65h-24l-8-1c3-21-2-43 3-64 1-9 4-17 6-26a72 72 0 001-7l2-7a5 5 0 010-1 17 17 0 014-4 88 88 0 0143-21h6z" opacity=".1"/><path fill="#fbbebe" d="M231 617a157 157 0 01-2 17l-5 69a361 361 0 01-44-5l3-15 2-19-3-18c-3-13-5-26-9-38a50 50 0 00-11-18c18-8 36-8 57-7a7 7 0 014 1 7 7 0 012 3 78 78 0 015 23 75 75 0 011 7z"/><circle cx="381.6" cy="195.2" r="39" fill="#be6f72"/><path fill="#e3e8f4" d="M390 286c5-8 9-19 19-21 5-2 11 0 16 2a8 8 0 014 2 8 8 0 011 5 271 271 0 010 53l-4 37c0 17 3 35 2 52-1 13-4 26-7 39l-12 54a9 9 0 01-2 4 9 9 0 01-3 2 132 132 0 01-107-8c-4-2-8-5-11-9-4-6-5-14-3-21l6-20c3-10 3-21 4-32 1-14 2-29 0-43l-5-29a323 323 0 01-4-45c0-9 0-18 6-25 3-3 7-5 11-6 7-3 15-4 22-2s12 9 11 17l-4 9c-1 4 2 9 5 12 18 16 46-11 55-27z"/><path fill="#3f3d56" d="M391 246a29 29 0 0117-1c4 1 8 3 11 1l3-2c4-1 8 1 11-2 2-1 2-3 3-6a53 53 0 0118-26c-1 7-2 16 3 22 2 3 5 4 9 6s10 3 15 2 9-5 10-10c0 7-7 13-9 20l-2 8c-1 7-6 13-10 19a132 132 0 00-27 63 31 31 0 01-1 8 50 50 0 01-4 6c-7 12-5 28-2 42a604 604 0 0019 76c-1 8-10 12-18 16a86 86 0 00-21 15c-2 2-5 4-5 7l-2 9c-1 3-5 4-6 2-3-8 1-17 1-25l-2-17c-1-7 1-13 3-19 6-18 13-35 15-53s-2-37-15-50c-15-16-23-36-39-50-3-3-6-5-5-9a9 9 0 011-4l19-22c6-8 11-16 10-26zM338 263l-3 3a9 9 0 01-5 1 145 145 0 01-17 2c-5 0-11-1-15 1-7 2-12 7-16 13s-5 13-6 20a266 266 0 00-5 46 121 121 0 0022-23c5-6 9-14 16-18l10-5c7-4 11-11 16-17 3-5 12-14 13-20 1-5-7-8-10-3zM373 168a32 32 0 013 3c7 5 16 4 24 3l7-2c4-2 6-7 5-11l-5-11a40 40 0 00-27-15 18 18 0 00-8 1l-9 6c-9 5-22 3-28 12-4 6-1 15-3 22-1 5-6 10-5 16l4 8a37 37 0 015 20c3 3 9-1 10-6l1-14c1-8 8-14 12-21 2-6 6-15 14-11z"/><path fill="#fbbebe" d="M278 257l1 6c2 3 6 2 10 2 5 1 9 6 11 12s-1 11-2 16q-5 19-12 37c-11-1-24-6-30-16-6-9-6-21-9-31-3-8-7-14-12-20 7 1 13-8 13-15s-2-15 0-22c0-2 29 4 32 5 8 6-1 18-2 26z"/><path d="M278 257l1 6c2 3 6 2 10 2 5 1 9 6 11 12s-1 11-2 16q-5 19-12 37c-11-1-24-6-30-16-6-9-6-21-9-31-3-8-7-14-12-20 7 1 13-8 13-15s-2-15 0-22c0-2 29 4 32 5 8 6-1 18-2 26z" opacity=".1"/><circle cx="271.6" cy="206.2" r="39" fill="#fbbebe"/><path fill="#3f3d56" d="M260 252v-8l3-3a13 13 0 004-5 57 57 0 005-38c-1-4-1-10 2-12a7 7 0 014 0c7 0 14 5 21 3a12 12 0 009-11c0-6-5-12-9-16-9-8-22-10-34-10h-21c-7 0-15 0-20 5-7 7-3 19-4 29a30 30 0 01-11 20c-5 3-11 7-11 13l1 5c3 8 1 16-4 23s-10 11-17 16c-3 2-7 4-9 7a23 23 0 00-5 13 17 17 0 002 11c4 6 14 7 21 4s11-12 14-19c2-5 4-10 8-12 5-2 12 2 15 7s6 10 10 14c7 6 20 5 26-2 4-5 5-12 5-19a28 28 0 00-5-15z"/><path fill="#f86d70" d="M274 302c-5 1-10-1-13-4l-8-11a196 196 0 00-20-28c-6-7-16-15-25-13a24 24 0 00-9 5 65 65 0 00-24 58l3 19a122 122 0 010 16c0 16-1 33-9 46-14 21-21 46-31 69-5 13-8 26-11 39l-6 23-12 51c-1 6-3 11-1 16 2 8 9 14 17 16s16 2 24 2c15 0 31 2 45 7 5 2 9 4 13 4l13-2c11-5 21-12 31-19a124 124 0 0121-9c3-2 7-3 10-6l3-8c3-16 1-32 0-48s-11-33-3-47c2-3 4-6 4-9l1-12 4-9c2-5 2-11 2-16a179 179 0 00-4-36c-3-15 7-30 13-44 3-6 6-10 7-16l-1-15a130 130 0 01-2-23c0-6 1-13-1-20s-6-13-13-15a5 5 0 00-4 1 6 6 0 00-2 3c-2 6-2 14-3 21s-3 13-9 14z"/><path fill="#be6f72" d="M179 345c1-2-1-6-3-6-3 0-4 3-4 6s0 6-2 7c-1 2-4 2-6 3a5 5 0 00-2 4l1 5c0 2-1 3-3 2a6 6 0 001 8l2 2a6 6 0 010 2c0 3 2 6 4 7-1 1-1 3 1 5s3 1 5 1a33 33 0 0012-3 8 8 0 004-2 3 3 0 000-4c2 0 4 1 5-1 2-2 0-5-2-7a4 4 0 002-7l-2-2c-1-1 1-1 1-2 1-1 0-3-2-4l-11-4c-3-2-1-7-1-10z"/><path fill="#3f3d56" d="M386 194a47 47 0 01-8 0 2 2 0 00-2 1l-4 35a14 14 0 01-3 7 15 15 0 00-4 12v59s0 8 6 8a88 88 0 0022 0s5-1 5-9v-58a14 14 0 00-3-11 15 15 0 01-3-7l-5-36a2 2 0 00-1-1z"/><path d="M386 194a47 47 0 01-8 0 2 2 0 00-2 1l-4 35a14 14 0 01-3 7 15 15 0 00-4 12v59s0 8 6 8a88 88 0 0022 0s5-1 5-9v-58a14 14 0 00-3-11 15 15 0 01-3-7l-5-36a2 2 0 00-1-1z" opacity=".1"/><rect width="29.5" height="49.8" x="367" y="250" fill="${color}" rx="11.1"/><path fill="#3f3d56" d="M485 43a46 46 0 01-7 3 2 2 0 00-1 2l9 34a14 14 0 010 7 15 15 0 001 12l23 55s3 7 8 5a87 87 0 0021-8s4-3 1-10l-23-54a14 14 0 00-7-9 15 15 0 01-5-5l-18-31a2 2 0 00-2-1z"/><rect width="29.5" height="49.8" x="530" y="188" fill="${color}" rx="11.1" transform="rotate(-23 295 247)"/><path fill="#fbbebe" d="M204 253c-11 4-15 18-13 29s11 21 18 30l21 25c5 7 12 15 20 17 13 4 26-4 37-12a552 552 0 01105-55c4-1 8-2 11-5 6-5 7-15 4-22s-11-12-20-12-15 4-20 11l-6 9c-6 8-15 13-24 17a589 589 0 01-64 28c-4 2-8 3-12 1l-5-5a140 140 0 01-15-32c-3-9-5-18-12-24-9-9-26-7-33 4 0 0-8 12-3 17s11-21 11-21zM765 211l1 13c0 5-1 11-6 13-3 1-7 0-10 2s-3 7-2 11c1 11 3 22 9 31l11 13c9 8 19 15 30 18a12 12 0 006 0 12 12 0 005-3c6-6 10-15 14-22 3-6 7-11 9-18a30 30 0 00-10-30l-6-5c-5-4-7-11-9-17s-1-13 0-20c-10-1-20 0-30 2l-14 4c-5 2 1 5 2 8z"/><path d="M765 211l1 13c0 5-1 11-6 13-3 1-7 0-10 2s-3 7-2 11c1 11 3 22 9 31l11 13c9 8 19 15 30 18a12 12 0 006 0 12 12 0 005-3c6-6 10-15 14-22 3-6 7-11 9-18a30 30 0 00-10-30l-6-5c-5-4-7-11-9-17s-1-13 0-20c-10-1-20 0-30 2l-14 4c-5 2 1 5 2 8z" opacity=".1"/><path fill="#fbbebe" d="M709 241c-16-6-24-28-41-30l-8-1c-10-2-14-14-17-23-9-32-22-64-40-92-7-12-19-22-24-35-2-3-2-7-4-9s-7-3-9 0a7 7 0 000 3l1 13-20-2a12 12 0 00-6 0 10 10 0 00-4 5c-7 13 0 30 13 38 14 10 34 11 43 25 6 9 6 20 10 29l6 13 9 27a231 231 0 0035 60l17 11c14 8 31 16 46 9 1-13-2-28-7-41zM758 671c-1 13-9 25-11 38l-36-8-4-1c7-18 1-38 3-57l1-5c15-5 28-12 44-10l1 9 2 19a78 78 0 010 15zM863 704a199 199 0 01-42 8c0-14-10-27-11-41a60 60 0 010-11v-4l3-29a44 44 0 017 0c13 0 25 6 38 10a90 90 0 011 19c-1 15-3 31 2 45l2 3z"/><path fill="#f86d70" d="M694 485c1 13-5 26-9 40-2 8-2 18-2 27l-2 54c0 6 0 11 2 16 3 11 13 18 24 21s22 1 33-1c5 0 11-1 15-4 6-5 9-12 11-19l7-20c7 17 4 35 9 53a10 10 0 002 5 225 225 0 0067 2c4-2 10-3 14-7 4-5 5-12 5-18-1-22-8-43-10-64l-1-28a186 186 0 00-2-21 28 28 0 00-2-9c-3-5-10-9-16-11-45-18-96-18-145-16z"/><circle cx="778.6" cy="173.2" r="43" fill="#fbbebe"/><path fill="#e3e8f4" d="M816 249c-3 7-8 14-16 16-6 1-14-2-19-7s-8-11-12-17c-2-5-5-9-9-12-6-4-14-4-21-3s-14 3-21 3c-9-1-18-5-26-2 3 12 2 25 1 38a17 17 0 01-1 5 18 18 0 01-2 5l-8 10c8 7 16 15 19 25l1 18c-1 18 3 36 2 54-1 21-10 41-14 61a160 160 0 00-2 54c45 15 91 23 138 26 9 0 18 1 25-4 5-4 9-11 10-18s0-14-1-21l-6-56-2-32 4-24 10-48c2-7 3-14 6-20l8-15a67 67 0 006-19 13 13 0 000-6c-1-4-4-6-7-7a215 215 0 00-59-21c-2 6-1 11-4 17z"/><path fill="#3f3d56" d="M812 220c5-9 14-16 20-26a38 38 0 001-35c-2-3-5-7-6-11l-4-14c-2-7-8-11-14-14s-13-3-20-4l-23-3h-10c-3 1-6 3-6 7-1 4 3 7 2 11l-1 4a4 4 0 002 2c6 3 12 3 18 5s12 7 11 13c0 4-2 7-1 10 2 3 5 3 8 4 9 3 16 13 15 23l-2 9c-1 10 1 13 9 19z"/><path fill="#be6f72" d="M870 266a15 15 0 01-1 6c-3 6-12 6-19 10-8 4-9 15-10 24-1 10-1 21 1 31s7 20 15 26c11 7 25 7 37 3s21-13 30-22c8-9 15-19 20-30l1-6c-1-3-5-4-7-6-6-4-11-10-13-17s-2-15-2-22 0-16-5-21-13-8-21-8c-6 0-23 1-27 6s2 19 1 26z"/><path d="M870 266a15 15 0 01-1 6c-3 6-12 6-19 10-8 4-9 15-10 24-1 10-1 21 1 31s7 20 15 26c11 7 25 7 37 3s21-13 30-22c8-9 15-19 20-30l1-6c-1-3-5-4-7-6-6-4-11-10-13-17s-2-15-2-22 0-16-5-21-13-8-21-8c-6 0-23 1-27 6s2 19 1 26z" opacity=".1"/><path fill="#be6f72" d="M817 534a9 9 0 002 4 8 8 0 003 2c33 9 68 5 102 1-4-14-9-28-10-43-1-12 0-25-5-36-1-4-75 12-83 13-4 1-8 1-11 4s-3 12-3 16c-1 13 1 26 5 39zM892 693l-19 7-10 4-19 5-11-28-7-20a128 128 0 01-4-15 103 103 0 012-50l41 7 22 3 2 15 2 22 1 50z"/><path d="M892 693l-19 7-10 4-19 5-11-28-7-20a128 128 0 01-4-15 103 103 0 012-50l41 7 22 3 2 15 2 22 1 50z" opacity=".1"/><path fill="#be6f72" d="M969 649l-3 18-1 1a16 16 0 01-9-7 19 19 0 01-2-5l-14 9a375 375 0 01-67 35l-4-14a131 131 0 01-3-15 75 75 0 014-33v-2a74 74 0 017-13c2-4 7-4 12-2l7 1c13 3 26 0 40 1a48 48 0 0118 5c7 3 12 8 14 15a22 22 0 010 3 27 27 0 011 3zM728 189c-21-20-44-37-68-53a187 187 0 01-18-13c-6-5-11-11-18-15s-14-8-22-6-14 8-13 16c1 7 7 11 13 15 10 8 21 15 33 21a103 103 0 0111 6c7 5 13 12 18 19a260 260 0 0074 63s12-26 12-29c-1-8-16-19-22-24z"/><path fill="#3f3d56" d="M905 512c-16 1-32 6-47 10s-33 4-47-2l9 60v10l-2 9c0 5 5 9 9 11a85 85 0 0043 10l-4 13c7 8 19 9 30 11l23 7a100 100 0 0029 5c7-1 14-1 19-6 7-5 9-13 10-22 1-4 2-9 1-13 0-5-2-10-4-15l-14-33-8-18c-10-19-26-38-47-37z"/><path fill="${color}" d="M917 304a15 15 0 0116-9c4 0 7 2 11 5l19 12a83 83 0 019 6c13 11 18 29 19 46s0 34 4 51l-25 19-12 11-7 11a26 26 0 01-17 10c4 3 6 8 8 12s1 10 2 15c2 7 6 13 7 20l1 14c1 25 21 46 20 71a107 107 0 01-26-13l-10-9-26-20c-12-10-25-20-35-33l-17-24c-6-7-14-15-23-19l-6 6a4 4 0 000 1 5 5 0 000 3 57 57 0 012 12l1 8a26 26 0 010 6c-1 6-7 11-14 12a6 6 0 01-2 0l-4-4c-2-9 2-18 2-27a64 64 0 000-7l-1-8c-6-2-9-8-11-14-4-15-8-31-6-47 1-4 2-8 1-13s-5-10-7-15c-7-18 8-37 7-55-1-8-6-15-9-22a62 62 0 00-6-12c-3-5-7-8-11-12a428 428 0 01-35-34 26 26 0 01-15-7c-3-3-5-6-5-10s2-7 6-7l6 1c7 1 13-3 16-9s3-13 3-20a19 19 0 0117 6c5 5 8 11 11 17a26 26 0 006 6c4 4 11 5 16 9l5 8c5 7 15 8 23 12s12 13 21 16l9 2c7 3 11 10 12 17s-1 15-2 22l-4 16c-1 4-2 9 1 11a11 11 0 005 3c7 2 14 4 21 1l8-7c9-11 16-27 21-41z"/><path fill="#be6f72" d="M996 644c-2 9-7 18-15 23a21 21 0 01-16 1 16 16 0 01-9-7 19 19 0 01-2-5v-1a44 44 0 01-1-10 141 141 0 011-17 91 91 0 013-14l7-19 3-10 2-6v-1-1l4-17c6-12 18-9 20 2a20 20 0 010 3c0 14-6 28-3 42a98 98 0 003 10l2 9a53 53 0 011 18z"/><path fill="${color}" d="M1001 487l1 18c3 13 13 25 12 39 0 3-1 7-4 8s-8 2-9 5v3c-1 2-3 3-5 3l-6-1c-7 1-10 10-17 14-4 2-10 1-13-3s-5-8-5-13l2-11v-20c-1-9-2-19-5-28l-5-13c-2-6-2-13-2-19-1-13 0-28 8-39 6-8 15-15 22-22 4-5 6-6 10-2 4 3 8 7 9 12 1 11 0 23 2 34s5 23 5 35z"/><circle cx="897.6" cy="216.2" r="51" fill="#be6f72"/><path fill="#3f3d56" d="M944 314c1-2 3-4 5-4a8 8 0 014 1l13 6a44 44 0 006-20l1-13 6-18c1-5-1-10-1-15-3-16 0-32-1-48s-8-33-22-40l-13-5c-9-3-17-9-26-13s-20-5-29-1-14 17-8 25l7 6c5 4 11 9 12 15 2 12-10 21-13 33a28 28 0 00-1 14c2 6 5 13 5 20 0 8-4 14-5 22l-1 8a43 43 0 01-3 11c-8 20-16 40-28 58a77 77 0 0037-8 61 61 0 01-10 21 69 69 0 0029-10 93 93 0 01-9 22l8-3a14 14 0 005-6c4-6 6-13 9-19a287 287 0 0123-39zM558 8a47 47 0 01-8 0 2 2 0 00-2 1l-4 35a14 14 0 01-3 7 15 15 0 00-4 12v59s0 8 6 8a88 88 0 0022 0s5-1 5-9V63a14 14 0 00-3-11 15 15 0 01-3-7l-5-36a2 2 0 00-1-1z"/><rect width="29.5" height="49.8" x="539" y="64" fill="${color}" rx="11.1"/><path fill="#3f3d56" d="M627 59a47 47 0 01-8 0 2 2 0 00-2 1l-4 35a14 14 0 01-3 7 15 15 0 00-4 12v59s0 8 6 8a88 88 0 0022 0s5-1 5-9v-58a14 14 0 00-3-11 15 15 0 01-3-7l-5-36a2 2 0 00-1-1z"/><rect width="29.5" height="49.8" x="608" y="115" fill="${color}" rx="11.1"/><g opacity=".2"><path fill="#3f3d56" d="M549 656a19 19 0 010 3l-21-3a17 17 0 012-9c2-3 5-5 9-5s6 2 8 6a17 17 0 012 8z"/><ellipse cx="571.2" cy="732.3" fill="#3f3d56" rx="14" ry="10.7" transform="rotate(-88 507 702)"/><ellipse cx="571.8" cy="715.2" fill="#3f3d56" rx="14" ry="10.7" transform="rotate(-88 507 685)"/><ellipse cx="572.3" cy="698.1" fill="#3f3d56" rx="14" ry="10.7" transform="rotate(-88 508 668)"/><ellipse cx="572.8" cy="681" fill="#3f3d56" rx="14" ry="10.7" transform="rotate(-88 508 651)"/><path fill="${color}" d="M504 469a50 50 0 01-4-6l29-4h-31a51 51 0 010-41l41 22-37-29a51 51 0 1183 60 51 51 0 015 10l-37 18 39-12a51 51 0 01-9 48 51 51 0 11-81-3 51 51 0 012-63z"/><path d="M595 504a51 51 0 01-12 31 51 51 0 11-81-3c-7-9 93-34 93-28z" opacity=".1"/></g></svg>
`;
export const SUPPORT_SVG = () =>
`<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="979.32677" height="424.8366" viewBox="0 0 979.32677 424.8366" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M993.71816,412.83936H419.142a9.19888,9.19888,0,0,0,0,18.39776H435.417V651.3026a9.19888,9.19888,0,0,0,18.39776,0l.1398-220.06548h461.1557l42.52,220.06548a9.19887,9.19887,0,1,0,18.39775,0l2.67633-220.06548h15.01383a9.19888,9.19888,0,0,0,0-18.39776Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M518.73716,371.85047v38.9547H421.141a19.48915,19.48915,0,1,1-1.35523-38.95474q.67739-.02358,1.35523,0Z" transform="translate(-110.33661 -237.5817)" fill="#f2f2f2"/><path d="M521.13449,410.50552a1.49881,1.49881,0,0,1-1.49822,1.49822H419.40273a20.52615,20.52615,0,0,1,0-41.05229H519.63627a1.49827,1.49827,0,1,1,0,2.99653H419.40273a17.52964,17.52964,0,0,0,0,35.05924H519.63627A1.49883,1.49883,0,0,1,521.13449,410.50552Z" transform="translate(-110.33661 -237.5817)" fill="#000000"/><path d="M518.73716,380.84H413.85905a.29966.29966,0,0,1-.00552-.59929H518.73716a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M518.73716,388.03169H413.85905a.29966.29966,0,0,1-.00552-.59929H518.73716a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M518.73716,395.22332H413.85905a.29966.29966,0,0,1-.00552-.59929H518.73716a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M518.73716,402.41487H413.85905a.29966.29966,0,0,1-.00552-.59929H518.73716a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M500.33941,330.80932v38.95474H402.74324a19.48915,19.48915,0,0,1-1.35522-38.95474q.67737-.02358,1.35522,0Z" transform="translate(-110.33661 -237.5817)" fill="#f2f2f2"/><path d="M502.73673,369.46442a1.49885,1.49885,0,0,1-1.49822,1.49826H401.005a20.52614,20.52614,0,0,1,0-41.05229H501.23851a1.49826,1.49826,0,1,1,0,2.99652H401.005a17.52964,17.52964,0,0,0,0,35.05928H501.23851A1.49884,1.49884,0,0,1,502.73673,369.46442Z" transform="translate(-110.33661 -237.5817)" fill="#3f3d56"/><path d="M500.33941,339.79886H395.4613a.29966.29966,0,0,1-.00553-.59929H500.33941a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M500.33941,346.99054H395.4613a.29966.29966,0,0,1-.00553-.59929H500.33941a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M500.33941,354.18217H395.4613a.29966.29966,0,0,1-.00553-.59929H500.33941a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M500.33941,361.37376H395.4613a.29966.29966,0,0,1-.00553-.59929H500.33941a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M613.87355,550.68347V516.71838a5.661,5.661,0,0,0-5.66085-5.66085H479.4284a5.661,5.661,0,0,0-5.66084,5.66085v33.96509Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><rect x="363.43092" y="325.83868" width="140.10602" height="43.87158" fill="#ccc"/><path d="M473.76756,620.02887V653.994a5.661,5.661,0,0,0,5.66084,5.66084H608.2127a5.661,5.661,0,0,0,5.66085-5.66084V620.02887Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><circle cx="432.77633" cy="294.70402" r="4.24564" fill="#fff"/><circle cx="432.77633" cy="351.3125" r="4.24564" fill="#fff"/><circle cx="433.00385" cy="406.72228" r="4.24564" fill="#fff"/><path d="M597.989,472.33053v38.9547H500.39287a19.48916,19.48916,0,0,1-1.35647-38.9547q.678-.02358,1.35647,0Z" transform="translate(-110.33661 -237.5817)" fill="#f2f2f2"/><path d="M600.38637,510.98558a1.49881,1.49881,0,0,1-1.49822,1.49822H498.65461a20.52615,20.52615,0,0,1-.0247-41.05229H598.88815a1.49827,1.49827,0,1,1,0,2.99653H498.65461a17.52963,17.52963,0,0,0,0,35.05923H598.88815A1.49885,1.49885,0,0,1,600.38637,510.98558Z" transform="translate(-110.33661 -237.5817)" fill="#3f3d56"/><path d="M597.989,481.32H493.111a.29966.29966,0,0,1-.00553-.59929H597.98913a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M597.989,488.51175H493.111a.29966.29966,0,0,1-.00553-.59929H597.98913a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M597.989,495.70338H493.111a.29966.29966,0,0,1-.00553-.59929H597.98913a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M597.989,502.89493H493.111a.29966.29966,0,0,1-.00553-.59929H597.98913a.29966.29966,0,0,1,0,.59929Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M483.36747,317.81415H438.90162a2.74745,2.74745,0,0,0-1.21689.28306l-11.22288,5.61835a2.0452,2.0452,0,0,0,0,3.76443l11.22288,5.61835a2.74718,2.74718,0,0,0,1.21689.28306h44.46585a2.33381,2.33381,0,0,0,2.4628-2.16532v-11.2367A2.3338,2.3338,0,0,0,483.36747,317.81415Z" transform="translate(-110.33661 -237.5817)" fill="#3f3d56"/><path d="M485.83027,319.97947v11.2367a2.33383,2.33383,0,0,1-2.4628,2.16532h-8.8589V317.81415h8.8589A2.33383,2.33383,0,0,1,485.83027,319.97947Z" transform="translate(-110.33661 -237.5817)" fill="#000000"/><path d="M216.78083,537.99332a35.33951,35.33951,0,0,0,34.12552-6.01134c11.95262-10.03214,15.70013-26.56,18.74934-41.864q4.50949-22.63308,9.019-45.26617l-18.88217,13.00153c-13.57891,9.34993-27.46375,18.99939-36.86572,32.54233S209.42082,522.42587,216.975,537.08" transform="translate(-110.33661 -237.5817)" fill="#e6e6e6"/><path d="M218.39489,592.79741c-1.91113-13.92071-3.87625-28.0202-2.53572-42.09016,1.19057-12.4956,5.00277-24.70032,12.764-34.70734a57.73582,57.73582,0,0,1,14.81307-13.42309c1.48131-.935,2.84468,1.41257,1.36983,2.34348a54.88844,54.88844,0,0,0-21.71125,26.19626c-4.72684,12.02273-5.48591,25.12848-4.67135,37.90006.4926,7.72345,1.53656,15.39627,2.58859,23.05926a1.40615,1.40615,0,0,1-.94781,1.66928,1.3653,1.3653,0,0,1-1.6693-.94781Z" transform="translate(-110.33661 -237.5817)" fill="#f2f2f2"/><path d="M236.80246,568.16434a26.01425,26.01425,0,0,0,22.6665,11.69871c11.47417-.54466,21.04-8.55293,29.651-16.15584l25.46969-22.48783-16.85671-.80672c-12.12234-.58011-24.55745-1.12124-36.10356,2.617s-22.19457,12.73508-24.30583,24.68624" transform="translate(-110.33661 -237.5817)" fill="#e6e6e6"/><path d="M212.99392,600.79976c9.19853-16.27621,19.86805-34.36538,38.93262-40.14695A43.445,43.445,0,0,1,268.3022,558.962c1.73863.14991,1.30448,2.82994-.431,2.6803a40.36111,40.36111,0,0,0-26.133,6.91386c-7.36852,5.01554-13.10573,11.98848-17.96161,19.383-2.97439,4.52936-5.63867,9.25082-8.30346,13.966-.85161,1.50687-3.34078.41915-2.47922-1.10534Z" transform="translate(-110.33661 -237.5817)" fill="#f2f2f2"/><path d="M198.25523,617.93168a19.69836,19.69836,0,0,1,12.0709-16.49847v-9.40956h15.782v9.70608a19.68812,19.68812,0,0,1,11.41362,16.202l3.711,43.13835H194.54417Z" transform="translate(-110.33661 -237.5817)" fill="#f2f2f2"/><path d="M734.973,411.955l-4.69488-1.97685-3.22067-23.53551h-42.889l-3.491,23.43936-4.20031,2.10013a.99744.99744,0,0,0,.44611,1.88955h57.66283A.99739.99739,0,0,0,734.973,411.955Z" transform="translate(-110.33661 -237.5817)" fill="#e6e6e6"/><path d="M811.1898,389.574H600.50692a4.174,4.174,0,0,1-4.16467-4.174V355.69092H815.35446V385.4A4.17408,4.17408,0,0,1,811.1898,389.574Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/><path d="M815.57469,369.73213H596.15V242.61337a5.0375,5.0375,0,0,1,5.03186-5.03167h209.361a5.03755,5.03755,0,0,1,5.03191,5.03167Z" transform="translate(-110.33661 -237.5817)" fill="#3f3d56"/><path d="M802.46932,360.50584h-193.214a3.88344,3.88344,0,0,1-3.87919-3.87908V250.68707a3.88365,3.88365,0,0,1,3.87919-3.87932h193.214a3.88366,3.88366,0,0,1,3.8792,3.87932V356.62676A3.88345,3.88345,0,0,1,802.46932,360.50584Z" transform="translate(-110.33661 -237.5817)" fill="#fff"/><path d="M751.57964,397.88662a11.6159,11.6159,0,0,1,17.666,2.27241l26.13446-4.64642,6.69716,15.19317-36.99908,6.04328a11.67883,11.67883,0,0,1-13.49855-18.86244Z" transform="translate(-110.33661 -237.5817)" fill="#ffb6b6"/><path d="M775.77611,417.286l27.24571-.33963,3.44882-.04668,55.43253-.69843s15.05312-14.3609,28.16068-29.1465l-1.83719-13.28833A54.29159,54.29159,0,0,0,870.023,340.1519C851.24988,352.696,840.363,377.52559,840.363,377.52559l-34.37018,8.22071-3.43848.82227-21.35608,5.10326Z" transform="translate(-110.33661 -237.5817)" fill="#000000"/><path d="M915.25011,498.96167H864.39249c0,2.17915-55.59414,3.94772-55.59414,3.94772a20.30858,20.30858,0,0,0-3.33166,3.15818,19.59694,19.59694,0,0,0-4.58,12.63271v3.15818a19.74588,19.74588,0,0,0,19.73861,19.73861h94.62478a19.75579,19.75579,0,0,0,19.73862-19.73861v-3.15818A19.76607,19.76607,0,0,0,915.25011,498.96167Z" transform="translate(-110.33661 -237.5817)" fill="#e4e4e4"/><rect x="747.4019" y="303.23122" width="20.52816" height="118.48951" fill="#e4e4e4"/><path d="M799.31222,658.58132c0,2.218,31.10721.858,69.47992.858s69.47991,1.36012,69.47991-.858-31.1072-19.807-69.47991-19.807S799.31222,656.36323,799.31222,658.58132Z" transform="translate(-110.33661 -237.5817)" fill="#e4e4e4"/><polygon points="675.186 407.461 659.908 407.46 652.64 348.531 675.188 348.532 675.186 407.461" fill="#ffb6b6"/><path d="M789.41863,659.852l-49.2623-.00183v-.62309a19.17528,19.17528,0,0,1,19.17426-19.17395h.00122l30.08773.00122Z" transform="translate(-110.33661 -237.5817)" fill="#2f2e41"/><polygon points="630.031 407.461 614.753 407.46 607.485 348.531 630.033 348.532 630.031 407.461" fill="#ffb6b6"/><path d="M744.2636,659.852l-49.2623-.00183v-.62309a19.1753,19.1753,0,0,1,19.17426-19.17395h.00122l30.08773.00122Z" transform="translate(-110.33661 -237.5817)" fill="#2f2e41"/><circle cx="766.88656" cy="41.63615" r="26.56401" fill="#ffb6b6"/><path d="M920.21655,461.22417s8.91308,47.1307-24.99958,53.13247-82.86639,10.21993-82.86639,10.21993L790.36706,627.14324l-29.53443-2.63675s3.928-123.46737,13.5876-133.127,70.71212-38.58282,70.71212-38.58282Z" transform="translate(-110.33661 -237.5817)" fill="#2f2e41"/><path d="M853.98286,441.47135,839.151,456.35062s-107.0941,17.25-111.22553,41.9852c-6.23747,37.34427-13.60493,118.552-13.60493,118.552l32.1988-2.41491,12.62647-92.31123,51.5182-11.71874L869.27729,478.5Z" transform="translate(-110.33661 -237.5817)" fill="#2f2e41"/><path d="M902.78526,263.36115c-2.6223-4.94751-5.95413-14.80785-11.24679-16.63657a42.07731,42.07731,0,0,0-9.05841-1.92972l-8.99618,3.46009,4.89616-3.808q-1.42988-.08519-2.85817-.13928l-6.0699,2.33453,3.10542-2.41532c-5.65883-.05808-11.5.53031-15.88468,3.9752-3.73817,2.93677-7.44169,14.06185-8.04057,18.77753a35.9171,35.9171,0,0,0,.6603,13.53055l1.53716,1.46166a18.85936,18.85936,0,0,0,1.206-3.83883,18.18056,18.18056,0,0,1,8.70263-11.80641l.08368-.0472c2.5782-1.451,5.7065-1.3841,8.66308-1.27769l14.04158.50527c3.37829.12158,7.01608.33533,9.64978,2.45443a15.888,15.888,0,0,1,3.85826,5.58929c1.30868,2.6414,3.8661,12.60418,3.8661,12.60418s1.44689-1.88062,2.1404-.48092a48.39766,48.39766,0,0,0,2.01437-11.23347A22.00877,22.00877,0,0,0,902.78526,263.36115Z" transform="translate(-110.33661 -237.5817)" fill="#2f2e41"/><path d="M995.69426,290.88349A11.61582,11.61582,0,0,0,985.181,305.26136l-21.3614,15.75722,6.40951,15.31674,29.8539-22.67594a11.67883,11.67883,0,0,0-4.38876-22.77589Z" transform="translate(-110.33661 -237.5817)" fill="#ffb6b6"/><path d="M992.25627,323.052l-53.551,59.4744s-25.60913-8.19816-45.41466-17.08624l-8.8977-27.32787a54.34329,54.34329,0,0,1-2.60112-19.66442c27.45606-7.306,59.391,19.87863,59.391,19.87863l40.08517-31.39877Z" transform="translate(-110.33661 -237.5817)" fill="#000000"/><path d="M867.301,465.6169c-9.554-3.30029-19.43312-6.71277-30.08912-7.99385l-.45773-.05533.12632-.443c11.03073-38.7308,8.27761-63.50657,2.87195-100.72306a37.59072,37.59072,0,0,1,21.5483-39.50121l.06542-.02958,30.43436-1.93391.06935-.00423,22.13437,6.50989a15.18313,15.18313,0,0,1,10.86724,14.83111c-.23987,12.23937.26868,25.9043.80711,40.37114,1.20787,32.45569,2.45686,66.01647-4.63045,87.79166l-.03718.11412-.09462.07416a36.09883,36.09883,0,0,1-23.08086,8.10758C887.90057,472.73235,877.76186,469.23034,867.301,465.6169Z" transform="translate(-110.33661 -237.5817)" fill="#000000"/><path d="M1088.24817,662.4183H111.75183a1.41521,1.41521,0,1,1,0-2.83042h976.49634a1.41521,1.41521,0,1,1,0,2.83042Z" transform="translate(-110.33661 -237.5817)" fill="#ccc"/></svg>`;
-export const WELCOME_SVG = color =>
+export const WELCOME_SVG = (color) =>
`<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="613.35286" height="700.56123" viewBox="0 0 613.35286 700.56123" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M587.667,756.93133l-.78168-17.57606q-.12187-.06468-.24405-.12879c-8.37606-4.39513-17.97576,3.561-15.3004,12.63392,2.51722,8.5366,4.20846,17.73958,8.81613,25.21162a34.14441,34.14441,0,0,0,25.03847,15.77861l10.64166,6.51555a57.21525,57.21525,0,0,0-12.05953-46.36368,55.2668,55.2668,0,0,0-10.157-9.4375C591.07189,750.28541,587.667,756.93133,587.667,756.93133Z" transform="translate(-293.32357 -99.71938)" fill="#f2f2f2"/><path d="M492.3909,578.56387c-20.48783-21.12931-50.17767-33.24712-81.45666-33.24712l-1.20652.00324a116.3146,116.3146,0,0,1-58.63546-15.83485l-1.85205-1.07912,1.49167-1.537a113.37272,113.37272,0,0,0,19.99317-28.30616,34.28239,34.28239,0,0,1-27.66751,8.93789,35.10416,35.10416,0,0,1-25.77016-16.50626c-10.93231-17.73787-23.96381-42.90658-23.96381-62.0803a116.66888,116.66888,0,0,1,38.0631-86.091,72.65143,72.65143,0,0,0,23.99981-54.17137l-.00607-1.45284a164.77416,164.77416,0,0,1,4.8908-39.87268l.33005-1.31694,1.355.04732a111.39121,111.39121,0,0,0,26.04681-2.1821,87.918,87.918,0,0,1-23.35954-6.213l-1.45769-.58971.4947-1.4937C397.78172,214.464,474.7579,225.398,519.43718,123.17462,555.666,40.28535,683.49348,196.75549,683.49348,287.199c0,9.2287-9.13324,21.42423-2.29615,27.52391,73.90979,65.93827,22.91308,108.27972,6.83466,150.88534-3.81479,10.10871,4.45682,21.20613,4.45682,32.14249,0,1.85569-.04732,3.77124-.14076,5.69327l-.14237,2.955-2.46441-1.63971a81.62563,81.62563,0,0,1-13.47964-11.05649,71.13531,71.13531,0,0,1-2.25612,61.41172c-7.74552,14.619-15.23907,25.085-22.27193,31.10507a116.2904,116.2904,0,0,1-159.34268-7.65574Z" transform="translate(-293.32357 -99.71938)" fill="#e6e6e6"/><path d="M616.13152,798.499a2.09333,2.09333,0,0,0,2.06993-1.79837c.08893-.62489,8.80049-63.45379.97652-146.956-7.22548-77.11632-30.4294-188.191-99.9393-279.41478a2.0935,2.0935,0,1,0-3.33028,2.53775c68.90954,90.436,91.9264,200.69567,99.10094,277.2675,7.77849,83.01636-.86476,145.3553-.953,145.97542a2.09519,2.09519,0,0,0,2.0752,2.38851Z" transform="translate(-293.32357 -99.71938)" fill="#3f3d56"/><path d="M559.40732,499.0052a2.09343,2.09343,0,0,0,1.23242-3.78686c-.25231-.18331-25.681-18.50562-63.69657-32.425-35.14253-12.86589-88.582-24.5297-143.597-7.02036a2.0932,2.0932,0,1,0,1.26956,3.98925c53.88785-17.14953,106.35862-5.67858,140.88784,6.96312,37.47293,13.72044,62.427,31.7,62.67472,31.87988A2.08515,2.08515,0,0,0,559.40732,499.0052Z" transform="translate(-293.32357 -99.71938)" fill="#3f3d56"/><path d="M655.2196,260.37275a2.09343,2.09343,0,0,0-3.68827-1.50192c-.201.23845-20.307,24.28166-36.928,61.19609-15.36327,34.12475-30.84523,86.58548-17.34326,142.71855a2.09319,2.09319,0,1,0,4.07031-.979c-13.22427-54.983,1.99558-106.49141,17.09108-140.02058,16.38342-36.38756,36.11335-59.982,36.31062-60.21616A2.0852,2.0852,0,0,0,655.2196,260.37275Z" transform="translate(-293.32357 -99.71938)" fill="#3f3d56"/><path d="M652.38648,368.31675c1.76623,14.25037,11.64059,26,26,26a26,26,0,0,0,26-26c0-14.3594-11.70215-24.67241-26-26C663.21558,340.90809,650.11884,350.02107,652.38648,368.31675Z" transform="translate(-293.32357 -99.71938)" fill="#2f2e41"/><polygon points="397.105 687.328 407.006 687.327 411.716 649.137 397.103 649.138 397.105 687.328" fill="#ffb6b6"/><path d="M690.08055,797.37579l30.447-.00116v-.385A11.85149,11.85149,0,0,0,708.67674,785.139H708.676l-5.56152-4.21923-10.37659,4.21991-2.65783.00006Z" transform="translate(-293.32357 -99.71938)" fill="#2f2e41"/><polygon points="358.105 687.328 368.006 687.327 372.716 649.137 358.103 649.138 358.105 687.328" fill="#ffb6b6"/><path d="M651.08055,797.37579l30.447-.00116v-.385A11.85149,11.85149,0,0,0,669.67674,785.139H669.676l-5.56152-4.21923-10.37659,4.21991-2.65783.00006Z" transform="translate(-293.32357 -99.71938)" fill="#2f2e41"/><path d="M724.50065,547.85614l7,24L723.25419,673.501s4.24646,6.35511,1.24646,6.35511-6.84686,1.40942-4.4234,5.20471-5.86,17.4209-5.86,17.4209l-11.71661,72.37439-14.92914-.22046s-7.59009-4.22833-3.3305-8.504,7.25958-4.27557,3.25958-8.27557-4-2.79529-4-5.89765-4.00751-41.01574,5.49628-55.559l-2.86365-59.29529-6.74457,58.16144-13.888,77.59052-14.38171-.11847s-6.64276-6.40271-6.6305-11.14209,4.10419-5.13312,1.05823-7.93628-3.046-45.86615,5.954-69.80316c0,0,5.09108-13.37393-.01155-17.95666s-.00631-9.82652-.00631-9.82652,8.08172-2.92145-.0073-11.33883-.04369-67.94913-.04369-67.94913-8.84271-24.03067.1131-33.47977S724.50065,547.85614,724.50065,547.85614Z" transform="translate(-293.32357 -99.71938)" fill="#2f2e41"/><path d="M599.82611,589.20574l12.48925-30.1823,9.84,5.46667-5.94253,30.70307a10.93464,10.93464,0,1,1-16.38671-5.98744Z" transform="translate(-293.32357 -99.71938)" fill="#ffb6b6"/><path d="M809.4002,350.535l-19.00315,26.56751-8.34544-7.554,12.7447-28.5581A10.93464,10.93464,0,1,1,809.4002,350.535Z" transform="translate(-293.32357 -99.71938)" fill="#ffb6b6"/><path d="M726.38648,550.31675c12.32568,19.11831-49.63137,43.38055-73.40448,33.64-4.1628-1.7056-18.48212-7.33918-8.69439-15.14958s-1.1348-8.90952-1.393-13.99392c-.1726-3.39918,2.45917-10.85592-.28674-10.5362s-5.95975-4.3811.0205-6.404.06411-3.86767.11651-5.78787c.57186-20.95538,16.64979-54.2869,16.64979-54.2869l-28.971,74.05682s.214,12.81223-3.48049,8.897-3.42565,8.75675-3.42565,8.75675-5.49354,3.83389-2.33452,5.9676-3.401,8.6937-3.401,8.6937l-15.30666-1.09334s.23964-11.37068,2.85315-13.88533,1.32975-6.47144,1.32975-6.47144,6.80457-6.02348,2.24268-10.91429c-5.86712-6.29013,15.52417-112.52993,22.90637-111.47784a28.12048,28.12048,0,0,1,20.08017-21.45161l16.53221-4.55191,2.93564-11.64749h23.27852l4.0548,7.65333,17.69783,7.98657c3.33362-4.70352,5.82477-9.65991,19.47546-11.26657,0,0,36.78255-33.46683,34.98668-36.08s3.906-8.73109,3.906-8.73109,4.86956-1.59377,2.12179-2.44467,2.446-2.81826,2.446-2.81826,4.81028-1.264,2.54157-2.92832,7.57128-2.75765,7.57128-2.75765l12.767,10.4168-2.58037,4.37541s1.5733,5.958-.48,3.78289-2.43983,4.1371-2.43983,4.1371-1.0486,6.912-7.26682,8.99446S778.502,404.8635,778.502,404.8635c-14.6648,19.0673-31.97132,33.9415-52.48,43.73331C734.01483,457.77113,726.38648,550.31675,726.38648,550.31675Z" transform="translate(-293.32357 -99.71938)" fill="${color}"/><circle cx="387.93692" cy="273.08556" r="23.0557" fill="#ffb6b6"/><path d="M657.38648,375.31675c.73,5.01,5,12,4,12s-8.11-20.65332-1-22c5.15722-.97681,6.31-.12,11.13-2.21l-.68.64c3.19,2.32,7.63.89,11.27-.62,3.65-1.5,8.08-2.93,11.28-.62,2.01,1.45,2.86,3.97,4.11,6.11,1.25,2.15,3.56,4.18,5.94,3.52,1.91-.53,3.01-2.67005,3-4.65s-2.58825-3.86355-1.72-5.64c2.57319-5.26444.25916-8.85275-5.35-11.33q-3.06-.465-6.12-.95a17.35842,17.35842,0,0,1,3.84-3.86,8.77436,8.77436,0,0,0-3.1-3.97c-1.63-.97-3.65-.9-5.54-.8q-6.33.33-12.65.66c-3.12.16-6.35.35-9.13995,1.78-3.48,1.79-5.76,5.28-7.42005,8.83C655.51648,360.18675,656.10645,366.60679,657.38648,375.31675Z" transform="translate(-293.32357 -99.71938)" fill="#2f2e41"/><path d="M561.476,799.97328l226.75.30734a1.19068,1.19068,0,1,0,0-2.38137l-226.75-.30733a1.19068,1.19068,0,0,0,0,2.38136Z" transform="translate(-293.32357 -99.71938)" fill="#cacaca"/><ellipse cx="471.98821" cy="695.09416" rx="5.25681" ry="7.55666" transform="translate(-577.14417 962.36498) rotate(-81.72174)" fill="#e6e6e6"/><ellipse cx="521.15973" cy="690.29611" rx="5.2568" ry="7.55666" transform="translate(-530.30434 1006.91693) rotate(-81.72174)" fill="#3f3d56"/><ellipse cx="458.5236" cy="655.286" rx="5.25681" ry="7.55666" transform="translate(-549.27676 914.96411) rotate(-81.72174)" fill="#ff6584"/><ellipse cx="441.31304" cy="640.04291" rx="4.77581" ry="3.3223" transform="translate(-495.37215 976.78425) rotate(-89.56675)" fill="#e6e6e6"/><ellipse cx="434.06731" cy="609.6713" rx="4.77581" ry="3.3223" transform="translate(-472.19234 939.39678) rotate(-89.56675)" fill="#3f3d56"/><ellipse cx="490.41248" cy="663.12322" rx="4.77581" ry="3.3223" transform="translate(-469.72363 1048.78806) rotate(-89.56675)" fill="#e6e6e6"/><ellipse cx="466.65067" cy="674.98721" rx="4.77581" ry="3.3223" transform="translate(-505.16941 1036.80122) rotate(-89.56675)" fill="#ff6584"/><ellipse cx="499.72794" cy="696.91495" rx="4.77581" ry="3.3223" transform="translate(-494.26937 1091.63947) rotate(-89.56675)" fill="#3f3d56"/><ellipse cx="849.98821" cy="541.09416" rx="5.25681" ry="7.55666" transform="translate(-101.17347 1204.59943) rotate(-81.72174)" fill="#e6e6e6"/><ellipse cx="899.15973" cy="536.29611" rx="5.2568" ry="7.55666" transform="translate(-54.33364 1249.15138) rotate(-81.72174)" fill="#3f3d56"/><ellipse cx="836.5236" cy="501.286" rx="5.25681" ry="7.55666" transform="matrix(0.14398, -0.98958, 0.98958, 0.14398, -73.30606, 1157.19856)" fill="#ff6584"/><ellipse cx="819.31304" cy="486.04292" rx="4.77581" ry="3.3223" transform="translate(33.76519 1201.93792) rotate(-89.56675)" fill="#e6e6e6"/><ellipse cx="812.06731" cy="455.6713" rx="4.77581" ry="3.3223" transform="translate(56.94499 1164.55045) rotate(-89.56675)" fill="#3f3d56"/><ellipse cx="868.41248" cy="509.12322" rx="4.77581" ry="3.3223" transform="translate(59.41371 1273.94173) rotate(-89.56675)" fill="#e6e6e6"/><ellipse cx="844.65067" cy="520.98721" rx="4.77581" ry="3.3223" transform="translate(23.96793 1261.95489) rotate(-89.56675)" fill="#ff6584"/><ellipse cx="877.72794" cy="542.91495" rx="4.77581" ry="3.3223" transform="translate(34.86796 1316.79314) rotate(-89.56675)" fill="#3f3d56"/><ellipse cx="666.98821" cy="256.09416" rx="5.25681" ry="7.55666" transform="translate(24.20544 779.54069) rotate(-81.72174)" fill="#fff"/><ellipse cx="716.15973" cy="251.29611" rx="5.2568" ry="7.55666" transform="translate(71.04527 824.09264) rotate(-81.72174)" fill="#3f3d56"/><ellipse cx="653.5236" cy="216.286" rx="5.25681" ry="7.55666" transform="translate(52.07285 732.13983) rotate(-81.72174)" fill="#ff6584"/><ellipse cx="636.31304" cy="201.04292" rx="4.77581" ry="3.3223" transform="translate(137.1408 736.09819) rotate(-89.56675)" fill="#e6e6e6"/><ellipse cx="629.06731" cy="170.6713" rx="4.77581" ry="3.3223" transform="translate(160.32061 698.71071) rotate(-89.56675)" fill="#3f3d56"/><ellipse cx="685.41248" cy="224.12322" rx="4.77581" ry="3.3223" transform="translate(162.78933 808.102) rotate(-89.56675)" fill="#e6e6e6"/><ellipse cx="661.65067" cy="235.98721" rx="4.77581" ry="3.3223" transform="translate(127.34354 796.11516) rotate(-89.56675)" fill="#ff6584"/><ellipse cx="694.72794" cy="257.91495" rx="4.77581" ry="3.3223" transform="translate(138.24358 850.95341) rotate(-89.56675)" fill="#3f3d56"/></svg>`;
diff --git a/apps/mobile/app/common/analytics/index.js b/apps/mobile/app/common/analytics/index.js
index 7fa40c8c2..e908ad7ee 100644
--- a/apps/mobile/app/common/analytics/index.js
+++ b/apps/mobile/app/common/analytics/index.js
@@ -1,12 +1,12 @@
-import { Platform } from 'react-native';
-import { MMKV } from '../database/mmkv';
-import { useSettingStore } from '../../stores/use-setting-store';
+import { Platform } from "react-native";
+import { MMKV } from "../database/mmkv";
+import { useSettingStore } from "../../stores/use-setting-store";
const WEBSITE_ID = `3c6890ce-8410-49d5-8831-15fb2eb28a21`;
const baseUrl = `https://analytics.streetwriters.co/api/collect`;
const UA =
- Platform.OS === 'ios'
+ Platform.OS === "ios"
? `Mozilla/5.0 (iPhone; CPU iPhone OS 12_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.0 Mobile/15E148 Safari/604.1`
: `
Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.84 Mobile Safari/537.36`;
@@ -19,37 +19,37 @@ Mozilla/5.0 (Linux; Android 8.0.0; SM-G960F Build/R16NW) AppleWebKit/537.36 (KHT
*/
async function canUpdateAnalytics(route, conditions = []) {
if (!useSettingStore?.getState()?.settings?.telemetry) return false;
- let eventsList = MMKV.getString('notesnookUserEvents');
+ let eventsList = MMKV.getString("notesnookUserEvents");
if (eventsList) {
eventsList = JSON.parse(eventsList);
}
if (eventsList && eventsList[route]) {
- console.log('analytics: event already sent', route);
+ console.log("analytics: event already sent", route);
return false;
}
- if (route !== '/welcome') {
+ if (route !== "/welcome") {
for (let cond of conditions) {
if (!eventsList || !eventsList[cond]) {
- console.log('analytics: conditions not met for event', route, cond);
+ console.log("analytics: conditions not met for event", route, cond);
return false;
}
}
}
- console.log('analytics: will send event', route);
+ console.log("analytics: will send event", route);
return true;
}
async function saveAnalytics(route, value = true) {
- let eventsList = MMKV.getString('notesnookUserEvents');
+ let eventsList = MMKV.getString("notesnookUserEvents");
if (eventsList) {
eventsList = JSON.parse(eventsList);
} else {
eventsList = {};
}
eventsList[route] = value;
- MMKV.setString('notesnookUserEvents', JSON.stringify(eventsList));
+ MMKV.setString("notesnookUserEvents", JSON.stringify(eventsList));
}
/**
@@ -61,7 +61,12 @@ async function saveAnalytics(route, value = true) {
* @returns
*/
-async function pageView(route, prevRoute = '', conditions = ['/welcome'], once = true) {
+async function pageView(
+ route,
+ prevRoute = "",
+ conditions = ["/welcome"],
+ once = true
+) {
if (__DEV__) return;
if (!(await canUpdateAnalytics(route, conditions)) && once) return;
let body = {
@@ -70,22 +75,22 @@ async function pageView(route, prevRoute = '', conditions = ['/welcome'], once =
url: `notesnook-${Platform.OS}${prevRoute}${route}`,
referrer: `https://notesnook.com/notesnook-${Platform.OS}${prevRoute}`,
hostname: `notesnook-${Platform.OS}`,
- language: 'en-US',
- screen: '1920x1080'
+ language: "en-US",
+ screen: "1920x1080"
},
- type: 'pageview'
+ type: "pageview"
};
try {
let response = await fetch(baseUrl, {
- method: 'POST',
+ method: "POST",
headers: {
- 'Content-Type': 'application/json',
- 'User-Agent': UA
+ "Content-Type": "application/json",
+ "User-Agent": UA
},
body: JSON.stringify(body)
});
- console.log('analytics: event sent', route);
+ console.log("analytics: event sent", route);
await saveAnalytics(route);
return await response.text();
} catch (e) {
@@ -99,22 +104,22 @@ async function sendEvent(type, value, once = true) {
let body = {
payload: {
website: WEBSITE_ID,
- url: '/',
+ url: "/",
event_type: type,
event_value: value,
- hostname: 'notesnook-android-app',
- language: 'en-US',
- screen: '1920x1080'
+ hostname: "notesnook-android-app",
+ language: "en-US",
+ screen: "1920x1080"
},
- type: 'event'
+ type: "event"
};
try {
let response = await fetch(baseUrl, {
- method: 'POST',
+ method: "POST",
headers: {
- 'Content-Type': 'application/json',
- 'User-Agent': UA
+ "Content-Type": "application/json",
+ "User-Agent": UA
},
body: JSON.stringify(body)
});
diff --git a/apps/mobile/app/common/database/encryption.js b/apps/mobile/app/common/database/encryption.js
index 9f8e7bf92..f93c64b9b 100644
--- a/apps/mobile/app/common/database/encryption.js
+++ b/apps/mobile/app/common/database/encryption.js
@@ -1,8 +1,8 @@
-import { Platform } from 'react-native';
-import 'react-native-get-random-values';
-import * as Keychain from 'react-native-keychain';
-import { generateSecureRandom } from 'react-native-securerandom';
-import Sodium from 'react-native-sodium';
+import { Platform } from "react-native";
+import "react-native-get-random-values";
+import * as Keychain from "react-native-keychain";
+import { generateSecureRandom } from "react-native-securerandom";
+import Sodium from "react-native-sodium";
const KEYSTORE_CONFIG = Platform.select({
ios: {
@@ -14,15 +14,23 @@ const KEYSTORE_CONFIG = Platform.select({
export async function deriveCryptoKey(name, data) {
try {
let credentials = await Sodium.deriveKey(data.password, data.salt);
- await Keychain.setInternetCredentials('notesnook', name, credentials.key, KEYSTORE_CONFIG);
+ await Keychain.setInternetCredentials(
+ "notesnook",
+ name,
+ credentials.key,
+ KEYSTORE_CONFIG
+ );
return credentials.key;
} catch (e) {}
}
export async function getCryptoKey(name) {
try {
- if (await Keychain.hasInternetCredentials('notesnook')) {
- let credentials = await Keychain.getInternetCredentials('notesnook', KEYSTORE_CONFIG);
+ if (await Keychain.hasInternetCredentials("notesnook")) {
+ let credentials = await Keychain.getInternetCredentials(
+ "notesnook",
+ KEYSTORE_CONFIG
+ );
return credentials.password;
} else {
return null;
@@ -32,7 +40,7 @@ export async function getCryptoKey(name) {
export async function removeCryptoKey(name) {
try {
- let result = await Keychain.resetInternetCredentials('notesnook');
+ let result = await Keychain.resetInternetCredentials("notesnook");
return result;
} catch (e) {}
}
@@ -51,7 +59,7 @@ export async function generateCryptoKey(password, salt) {
let credentials = await Sodium.deriveKey(password, salt || null);
return credentials;
} catch (e) {
- console.log('generateCryptoKey: ', e);
+ console.log("generateCryptoKey: ", e);
}
}
@@ -61,30 +69,32 @@ export function getAlgorithm(base64Variant) {
export async function decrypt(password, data) {
if (!password.password && !password.key) return undefined;
- if (password.password && password.password === '' && !password.key) return undefined;
+ if (password.password && password.password === "" && !password.key)
+ return undefined;
let _data = { ...data };
- _data.output = 'plain';
+ _data.output = "plain";
return await Sodium.decrypt(password, _data);
}
export function parseAlgorithm(alg) {
if (!alg) return {};
- const [enc, kdf, compressed, compressionAlg, base64variant] = alg.split('-');
+ const [enc, kdf, compressed, compressionAlg, base64variant] = alg.split("-");
return {
encryptionAlgorithm: enc,
kdfAlgorithm: kdf,
compressionAlgorithm: compressionAlg,
- isCompress: compressed === '1',
+ isCompress: compressed === "1",
base64_variant: base64variant
};
}
export async function encrypt(password, data) {
if (!password.password && !password.key) return undefined;
- if (password.password && password.password === '' && !password.key) return undefined;
+ if (password.password && password.password === "" && !password.key)
+ return undefined;
let message = {
- type: 'plain',
+ type: "plain",
data: data
};
let result = await Sodium.encrypt(password, message);
diff --git a/apps/mobile/app/common/database/index.js b/apps/mobile/app/common/database/index.js
index 3a426d612..fbd6c8db7 100644
--- a/apps/mobile/app/common/database/index.js
+++ b/apps/mobile/app/common/database/index.js
@@ -1,12 +1,17 @@
-import Database from '@streetwriters/notesnook-core/api/index';
-import { initalize, logger as dbLogger } from '@streetwriters/notesnook-core/logger';
-import { Platform } from 'react-native';
-import { MMKVLoader } from 'react-native-mmkv-storage';
-import filesystem from '../filesystem';
-import EventSource from '../../utils/sse/even-source-ios';
-import AndroidEventSource from '../../utils/sse/event-source';
-import Storage, { KV } from './storage';
-const LoggerStorage = new MMKVLoader().withInstanceID('notesnook_logs').initialize();
+import Database from "@streetwriters/notesnook-core/api/index";
+import {
+ initalize,
+ logger as dbLogger
+} from "@streetwriters/notesnook-core/logger";
+import { Platform } from "react-native";
+import { MMKVLoader } from "react-native-mmkv-storage";
+import filesystem from "../filesystem";
+import EventSource from "../../utils/sse/even-source-ios";
+import AndroidEventSource from "../../utils/sse/event-source";
+import Storage, { KV } from "./storage";
+const LoggerStorage = new MMKVLoader()
+ .withInstanceID("notesnook_logs")
+ .initialize();
console.log(LoggerStorage);
initalize(new KV(LoggerStorage));
export const DatabaseLogger = dbLogger;
@@ -16,18 +21,18 @@ export const DatabaseLogger = dbLogger;
*/
export var db = new Database(
Storage,
- Platform.OS === 'ios' ? EventSource : AndroidEventSource,
+ Platform.OS === "ios" ? EventSource : AndroidEventSource,
filesystem
);
db.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: "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.10.29:5264',
// AUTH_HOST: 'http://192.168.10.29:8264',
// SSE_HOST: 'http://192.168.10.29:7264',
@@ -35,11 +40,11 @@ db.host(
// ISSUES_HOST: 'http://192.168.10.29: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'
+ 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"
}
);
diff --git a/apps/mobile/app/common/database/mmkv.js b/apps/mobile/app/common/database/mmkv.js
index 5b3b4a933..347cd765a 100644
--- a/apps/mobile/app/common/database/mmkv.js
+++ b/apps/mobile/app/common/database/mmkv.js
@@ -1,8 +1,10 @@
-import { Platform } from 'react-native';
-import MMKVStorage, { ProcessingModes } from 'react-native-mmkv-storage';
+import { Platform } from "react-native";
+import MMKVStorage, { ProcessingModes } from "react-native-mmkv-storage";
export const MMKV = new MMKVStorage.Loader()
.setProcessingMode(
- Platform.OS === 'ios' ? ProcessingModes.MULTI_PROCESS : ProcessingModes.SINGLE_PROCESS
+ Platform.OS === "ios"
+ ? ProcessingModes.MULTI_PROCESS
+ : ProcessingModes.SINGLE_PROCESS
)
.initialize();
diff --git a/apps/mobile/app/common/database/storage.js b/apps/mobile/app/common/database/storage.js
index a73d5b1a6..97c114910 100644
--- a/apps/mobile/app/common/database/storage.js
+++ b/apps/mobile/app/common/database/storage.js
@@ -1,5 +1,5 @@
-import { Platform } from 'react-native';
-import RNFetchBlob from 'rn-fetch-blob';
+import { Platform } from "react-native";
+import RNFetchBlob from "rn-fetch-blob";
import {
decrypt,
deriveCryptoKey,
@@ -9,8 +9,8 @@ import {
getRandomBytes,
hash,
removeCryptoKey
-} from './encryption';
-import { MMKV } from './mmkv';
+} from "./encryption";
+import { MMKV } from "./mmkv";
export class KV {
storage = null;
@@ -30,7 +30,10 @@ export class KV {
}
async write(key, data) {
- this.storage.setString(key, typeof data === 'string' ? data : JSON.stringify(data));
+ this.storage.setString(
+ key,
+ typeof data === "string" ? data : JSON.stringify(data)
+ );
return true;
}
@@ -64,12 +67,12 @@ export class KV {
async getAllKeys() {
let keys = (await this.storage.indexer.getKeys()) || [];
keys = keys.filter(
- k =>
- k !== 'stringIndex' &&
- k !== 'boolIndex' &&
- k !== 'mapIndex' &&
- k !== 'arrayIndex' &&
- k !== 'numberIndex' &&
+ (k) =>
+ k !== "stringIndex" &&
+ k !== "boolIndex" &&
+ k !== "mapIndex" &&
+ k !== "arrayIndex" &&
+ k !== "numberIndex" &&
k !== this.storage.instanceID
);
return keys;
@@ -79,14 +82,14 @@ export class KV {
const DefaultStorage = new KV(MMKV);
async function requestPermission() {
- if (Platform.OS === 'ios') return true;
+ if (Platform.OS === "ios") return true;
return true;
}
async function checkAndCreateDir(path) {
let dir =
- Platform.OS === 'ios'
+ Platform.OS === "ios"
? RNFetchBlob.fs.dirs.DocumentDir + path
- : RNFetchBlob.fs.dirs.SDCardDir + '/Notesnook/' + path;
+ : RNFetchBlob.fs.dirs.SDCardDir + "/Notesnook/" + path;
try {
let exists = await RNFetchBlob.fs.exists(dir);
@@ -102,10 +105,10 @@ async function checkAndCreateDir(path) {
}
export default {
- read: key => DefaultStorage.read(key),
+ read: (key) => DefaultStorage.read(key),
write: (key, value) => DefaultStorage.write(key, value),
- readMulti: keys => DefaultStorage.readMulti(keys),
- remove: key => DefaultStorage.remove(key),
+ readMulti: (keys) => DefaultStorage.readMulti(keys),
+ remove: (key) => DefaultStorage.remove(key),
clear: () => DefaultStorage.clear(),
getAllKeys: () => DefaultStorage.getAllKeys(),
encrypt,
diff --git a/apps/mobile/app/common/filesystem/download.js b/apps/mobile/app/common/filesystem/download.js
index 211516c0d..b441e54b6 100644
--- a/apps/mobile/app/common/filesystem/download.js
+++ b/apps/mobile/app/common/filesystem/download.js
@@ -1,48 +1,51 @@
-import React from 'react';
-import { Platform } from 'react-native';
-import * as ScopedStorage from 'react-native-scoped-storage';
-import Sodium from 'react-native-sodium';
-import RNFetchBlob from 'rn-fetch-blob';
-import { ShareComponent } from '../../components/sheets/export-notes/share';
-import { useAttachmentStore } from '../../stores/use-attachment-store';
-import { presentSheet, ToastEvent } from '../../services/event-manager';
-import { db } from '../database';
-import Storage from '../database/storage';
-import { cacheDir, fileCheck } from './utils';
-import hosts from '@streetwriters/notesnook-core/utils/constants';
-import NetInfo from '@react-native-community/netinfo';
+import React from "react";
+import { Platform } from "react-native";
+import * as ScopedStorage from "react-native-scoped-storage";
+import Sodium from "react-native-sodium";
+import RNFetchBlob from "rn-fetch-blob";
+import { ShareComponent } from "../../components/sheets/export-notes/share";
+import { useAttachmentStore } from "../../stores/use-attachment-store";
+import { presentSheet, ToastEvent } from "../../services/event-manager";
+import { db } from "../database";
+import Storage from "../database/storage";
+import { cacheDir, fileCheck } from "./utils";
+import hosts from "@streetwriters/notesnook-core/utils/constants";
+import NetInfo from "@react-native-community/netinfo";
export async function downloadFile(filename, data, cancelToken) {
if (!data) return false;
let { url, headers } = data;
- console.log('downloading file: ', filename, url);
+ console.log("downloading file: ", filename, url);
let path = `${cacheDir}/${filename}`;
try {
let exists = await RNFetchBlob.fs.exists(path);
if (exists) {
- console.log('file is downloaded');
+ console.log("file is downloaded");
return true;
}
let res = await fetch(url, {
- method: 'GET',
+ method: "GET",
headers
});
- if (!res.ok) throw new Error(`${res.status}: Unable to resolve download url`);
+ if (!res.ok)
+ throw new Error(`${res.status}: Unable to resolve download url`);
const downloadUrl = await res.text();
- if (!downloadUrl) throw new Error('Unable to resolve download url');
+ if (!downloadUrl) throw new Error("Unable to resolve download url");
let totalSize = 0;
let request = RNFetchBlob.config({
path: path,
IOSBackgroundTask: true
})
- .fetch('GET', downloadUrl, null)
+ .fetch("GET", downloadUrl, null)
.progress((recieved, total) => {
- useAttachmentStore.getState().setProgress(0, total, filename, recieved, 'download');
+ useAttachmentStore
+ .getState()
+ .setProgress(0, total, filename, recieved, "download");
totalSize = total;
- console.log('downloading: ', recieved, total);
+ console.log("downloading: ", recieved, total);
});
cancelToken.cancel = request.cancel;
@@ -53,21 +56,21 @@ export async function downloadFile(filename, data, cancelToken) {
return status >= 200 && status < 300;
} catch (e) {
ToastEvent.show({
- heading: 'Error downloading file',
+ heading: "Error downloading file",
message: e.message,
- type: 'error',
- context: 'global'
+ type: "error",
+ context: "global"
});
ToastEvent.show({
- heading: 'Error downloading file',
+ heading: "Error downloading file",
message: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
useAttachmentStore.getState().remove(filename);
RNFetchBlob.fs.unlink(path).catch(console.log);
- console.log('download file error: ', e, url, headers);
+ console.log("download file error: ", e, url, headers);
return false;
}
}
@@ -75,24 +78,30 @@ export async function downloadFile(filename, data, cancelToken) {
export async function downloadAttachment(hash, global = true) {
let attachment = db.attachments.attachment(hash);
if (!attachment) {
- console.log('attachment not found');
+ console.log("attachment not found");
return;
}
let folder = {};
- if (Platform.OS === 'android') {
+ if (Platform.OS === "android") {
folder = await ScopedStorage.openDocumentTree();
if (!folder) return;
} else {
- folder.uri = await Storage.checkAndCreateDir('/downloads/');
+ folder.uri = await Storage.checkAndCreateDir("/downloads/");
}
try {
- await db.fs.downloadFile(attachment.metadata.hash, attachment.metadata.hash);
- if (!(await RNFetchBlob.fs.exists(`${cacheDir}/${attachment.metadata.hash}`))) return;
+ await db.fs.downloadFile(
+ attachment.metadata.hash,
+ attachment.metadata.hash
+ );
+ if (
+ !(await RNFetchBlob.fs.exists(`${cacheDir}/${attachment.metadata.hash}`))
+ )
+ return;
let key = await db.attachments.decryptKey(attachment.key);
- console.log('attachment key', key);
+ console.log("attachment key", key);
let info = {
iv: attachment.iv,
salt: attachment.salt,
@@ -108,37 +117,48 @@ export async function downloadAttachment(hash, global = true) {
let fileUri = await Sodium.decryptFile(key, info, false);
ToastEvent.show({
- heading: 'Download successful',
- message: attachment.metadata.filename + ' downloaded',
- type: 'success'
+ heading: "Download successful",
+ message: attachment.metadata.filename + " downloaded",
+ type: "success"
});
if (attachment.dateUploaded) {
- console.log('Deleting attachment after download', attachment.dateUploaded);
+ console.log(
+ "Deleting attachment after download",
+ attachment.dateUploaded
+ );
RNFetchBlob.fs
.unlink(RNFetchBlob.fs.dirs.CacheDir + `/${attachment.metadata.hash}`)
.catch(console.log);
}
- if (Platform.OS === 'ios') {
+ if (Platform.OS === "ios") {
fileUri = folder.uri + `/${attachment.metadata.filename}`;
}
- console.log('saved file uri: ', fileUri);
+ console.log("saved file uri: ", fileUri);
presentSheet({
title: `File downloaded`,
paragraph: `${attachment.metadata.filename} saved to ${
- Platform.OS === 'android' ? 'selected path' : 'File Manager/Notesnook/downloads'
+ Platform.OS === "android"
+ ? "selected path"
+ : "File Manager/Notesnook/downloads"
}`,
- icon: 'download',
+ icon: "download",
context: global ? null : attachment.metadata.hash,
- component: <ShareComponent uri={fileUri} name={attachment.metadata.filename} padding={12} />
+ component: (
+ <ShareComponent
+ uri={fileUri}
+ name={attachment.metadata.filename}
+ padding={12}
+ />
+ )
});
return fileUri;
} catch (e) {
- console.log('download attachment error: ', e);
+ console.log("download attachment error: ", e);
if (attachment.dateUploaded) {
- console.log('Deleting attachment on error', attachment.dateUploaded);
+ console.log("Deleting attachment on error", attachment.dateUploaded);
RNFetchBlob.fs
.unlink(RNFetchBlob.fs.dirs.CacheDir + `/${attachment.metadata.hash}`)
.catch(console.log);
@@ -152,26 +172,27 @@ export async function getUploadedFileSize(hash) {
const token = await db.user.tokenManager.getAccessToken();
const attachmentInfo = await fetch(url, {
- method: 'HEAD',
+ method: "HEAD",
headers: { Authorization: `Bearer ${token}` }
});
- const contentLength = parseInt(attachmentInfo.headers?.get('content-length'));
- console.log('contentLength:', contentLength, attachmentInfo.headers);
+ const contentLength = parseInt(attachmentInfo.headers?.get("content-length"));
+ console.log("contentLength:", contentLength, attachmentInfo.headers);
return isNaN(contentLength) ? 0 : contentLength;
}
export async function checkAttachment(hash) {
const internetState = await NetInfo.fetch();
- const isInternetReachable = internetState.isConnected && internetState.isInternetReachable;
+ const isInternetReachable =
+ internetState.isConnected && internetState.isInternetReachable;
if (!isInternetReachable) return { success: true };
const attachment = db.attachments.attachment(hash);
- if (!attachment) return { failed: 'Attachment not found.' };
+ if (!attachment) return { failed: "Attachment not found." };
try {
const size = await getUploadedFileSize(hash);
- if (size <= 0) return { failed: 'File length is 0.' };
+ if (size <= 0) return { failed: "File length is 0." };
} catch (e) {
return { failed: e?.message };
}
diff --git a/apps/mobile/app/common/filesystem/index.js b/apps/mobile/app/common/filesystem/index.js
index c7e1753d5..2c9720277 100644
--- a/apps/mobile/app/common/filesystem/index.js
+++ b/apps/mobile/app/common/filesystem/index.js
@@ -1,7 +1,18 @@
-import { downloadAttachment, downloadFile, getUploadedFileSize, checkAttachment } from './download';
-import { clearFileStorage, deleteFile, exists, readEncrypted, writeEncrypted } from './io';
-import { uploadFile } from './upload';
-import { cancelable } from './utils';
+import {
+ downloadAttachment,
+ downloadFile,
+ getUploadedFileSize,
+ checkAttachment
+} from "./download";
+import {
+ clearFileStorage,
+ deleteFile,
+ exists,
+ readEncrypted,
+ writeEncrypted
+} from "./io";
+import { uploadFile } from "./upload";
+import { cancelable } from "./utils";
export default {
readEncrypted,
diff --git a/apps/mobile/app/common/filesystem/io.js b/apps/mobile/app/common/filesystem/io.js
index beb5c5669..de3103fea 100644
--- a/apps/mobile/app/common/filesystem/io.js
+++ b/apps/mobile/app/common/filesystem/io.js
@@ -1,7 +1,7 @@
-import { Platform } from 'react-native';
-import Sodium from 'react-native-sodium';
-import RNFetchBlob from 'rn-fetch-blob';
-import { cacheDir, getRandomId } from './utils';
+import { Platform } from "react-native";
+import Sodium from "react-native-sodium";
+import RNFetchBlob from "rn-fetch-blob";
+import { cacheDir, getRandomId } from "./utils";
export async function readEncrypted(filename, key, cipherData) {
let path = `${cacheDir}/${filename}`;
@@ -19,28 +19,28 @@ export async function readEncrypted(filename, key, cipherData) {
},
true
);
- console.log('output length: ', output?.length);
+ console.log("output length: ", output?.length);
return output;
} catch (e) {
RNFetchBlob.fs.unlink(path).catch(console.log);
console.log(e);
- console.log('error');
+ console.log("error");
return false;
}
}
export async function writeEncrypted(filename, { data, type, key }) {
- console.log('file input: ', { type, key });
- let filepath = cacheDir + `/${getRandomId('imagecache_')}`;
+ console.log("file input: ", { type, key });
+ let filepath = cacheDir + `/${getRandomId("imagecache_")}`;
console.log(filepath);
- await RNFetchBlob.fs.writeFile(filepath, data, 'base64');
+ await RNFetchBlob.fs.writeFile(filepath, data, "base64");
let output = await Sodium.encryptFile(key, {
- uri: Platform.OS === 'ios' ? filepath : `file://` + filepath,
- type: 'url'
+ uri: Platform.OS === "ios" ? filepath : `file://` + filepath,
+ type: "url"
});
RNFetchBlob.fs.unlink(filepath).catch(console.log);
- console.log('encrypted file output: ', output);
+ console.log("encrypted file output: ", output);
return {
...output,
alg: `xcha-stream`
@@ -57,7 +57,7 @@ export async function deleteFile(filename, data) {
let { url, headers } = data;
try {
- let response = await RNFetchBlob.fetch('DELETE', url, headers);
+ let response = await RNFetchBlob.fetch("DELETE", url, headers);
let status = response.info().status;
let ok = status >= 200 && status < 300;
if (ok) {
@@ -65,7 +65,7 @@ export async function deleteFile(filename, data) {
}
return ok;
} catch (e) {
- console.log('delete file: ', e, url, headers);
+ console.log("delete file: ", e, url, headers);
return false;
}
}
diff --git a/apps/mobile/app/common/filesystem/upload.js b/apps/mobile/app/common/filesystem/upload.js
index 5daa27527..4905fb0e0 100644
--- a/apps/mobile/app/common/filesystem/upload.js
+++ b/apps/mobile/app/common/filesystem/upload.js
@@ -1,36 +1,38 @@
-import RNFetchBlob from 'rn-fetch-blob';
-import { useAttachmentStore } from '../../stores/use-attachment-store';
-import { db } from '../database';
-import { cacheDir } from './utils';
+import RNFetchBlob from "rn-fetch-blob";
+import { useAttachmentStore } from "../../stores/use-attachment-store";
+import { db } from "../database";
+import { cacheDir } from "./utils";
export async function uploadFile(filename, data, cancelToken) {
if (!data) return false;
let { url, headers } = data;
- console.log('uploading file: ', filename, headers);
+ console.log("uploading file: ", filename, headers);
try {
let res = await fetch(url, {
- method: 'PUT',
+ method: "PUT",
headers
});
if (!res.ok) throw new Error(`${res.status}: Unable to resolve upload url`);
const uploadUrl = await res.text();
- if (!uploadUrl) throw new Error('Unable to resolve upload url');
+ if (!uploadUrl) throw new Error("Unable to resolve upload url");
let request = RNFetchBlob.config({
IOSBackgroundTask: true
})
.fetch(
- 'PUT',
+ "PUT",
uploadUrl,
{
- 'content-type': ''
+ "content-type": ""
},
RNFetchBlob.wrap(`${cacheDir}/${filename}`)
)
.uploadProgress((sent, total) => {
- useAttachmentStore.getState().setProgress(sent, total, filename, 0, 'upload');
- console.log('uploading: ', sent, total);
+ useAttachmentStore
+ .getState()
+ .setProgress(sent, total, filename, 0, "upload");
+ console.log("uploading: ", sent, total);
});
cancelToken.cancel = request.cancel;
let response = await request;
@@ -42,7 +44,7 @@ export async function uploadFile(filename, data, cancelToken) {
if (result) {
let attachment = db.attachments.attachment(filename);
if (!attachment) return result;
- if (!attachment.metadata.type.startsWith('image/')) {
+ if (!attachment.metadata.type.startsWith("image/")) {
RNFetchBlob.fs.unlink(`${cacheDir}/${filename}`).catch(console.log);
}
}
@@ -50,7 +52,7 @@ export async function uploadFile(filename, data, cancelToken) {
return result;
} catch (e) {
useAttachmentStore.getState().remove(filename);
- console.log('upload file: ', e, url, headers);
+ console.log("upload file: ", e, url, headers);
return false;
}
}
diff --git a/apps/mobile/app/common/filesystem/utils.js b/apps/mobile/app/common/filesystem/utils.js
index 05ca87d68..3d1cbbfa2 100644
--- a/apps/mobile/app/common/filesystem/utils.js
+++ b/apps/mobile/app/common/filesystem/utils.js
@@ -1,25 +1,28 @@
-import RNFetchBlob from 'rn-fetch-blob';
+import RNFetchBlob from "rn-fetch-blob";
export const cacheDir = RNFetchBlob.fs.dirs.CacheDir;
export function getRandomId(prefix) {
return Math.random()
.toString(36)
- .replace('0.', prefix || '');
+ .replace("0.", prefix || "");
}
export function extractValueFromXmlTag(code, xml) {
if (!xml.includes(code)) return `Unknown ${code}`;
- return xml.slice(xml.indexOf(`<${code}>`) + code.length + 2, xml.indexOf(`</${code}>`));
+ return xml.slice(
+ xml.indexOf(`<${code}>`) + code.length + 2,
+ xml.indexOf(`</${code}>`)
+ );
}
export async function fileCheck(response, totalSize) {
if (totalSize < 1000) {
let text = await response.text();
- if (text.startsWith('<?xml')) {
+ if (text.startsWith("<?xml")) {
let errorJson = {
- Code: extractValueFromXmlTag('Code', text),
- Message: extractValueFromXmlTag('Message', text)
+ Code: extractValueFromXmlTag("Code", text),
+ Message: extractValueFromXmlTag("Message", text)
};
throw new Error(`${errorJson.Code}: ${errorJson.Message}`);
}
diff --git a/apps/mobile/app/common/logger/index.ts b/apps/mobile/app/common/logger/index.ts
index 608821b4e..bfca054c2 100644
--- a/apps/mobile/app/common/logger/index.ts
+++ b/apps/mobile/app/common/logger/index.ts
@@ -3,7 +3,10 @@ function info(context: string, ...logs: any[]) {
}
function error(context: string, ...logs: any[]) {
- console.log(`${new Date().toLocaleDateString()}::error::${context}: `, ...logs);
+ console.log(
+ `${new Date().toLocaleDateString()}::error::${context}: `,
+ ...logs
+ );
}
type Logger = {
diff --git a/apps/mobile/app/components/announcements/announcement.js b/apps/mobile/app/components/announcements/announcement.js
index c35573a71..3a30fc872 100644
--- a/apps/mobile/app/components/announcements/announcement.js
+++ b/apps/mobile/app/components/announcements/announcement.js
@@ -1,20 +1,20 @@
-import React from 'react';
-import { FlatList, View } from 'react-native';
-import { useSelectionStore } from '../../stores/use-selection-store';
-import { useMessageStore } from '../../stores/use-message-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { allowedOnPlatform, renderItem } from './functions';
+import React from "react";
+import { FlatList, View } from "react-native";
+import { useSelectionStore } from "../../stores/use-selection-store";
+import { useMessageStore } from "../../stores/use-message-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { allowedOnPlatform, renderItem } from "./functions";
export const Announcement = ({ color }) => {
- const colors = useThemeStore(state => state.colors);
- const announcements = useMessageStore(state => state.announcements);
+ const colors = useThemeStore((state) => state.colors);
+ const announcements = useMessageStore((state) => state.announcements);
let announcement = announcements.length > 0 ? announcements[0] : null;
- const selectionMode = useSelectionStore(state => state.selectionMode);
+ const selectionMode = useSelectionStore((state) => state.selectionMode);
return !announcement || selectionMode ? null : (
<View
style={{
backgroundColor: colors.bg,
- width: '100%',
+ width: "100%",
paddingHorizontal: 12,
paddingTop: 12,
paddingBottom: 12
@@ -22,9 +22,9 @@ export const Announcement = ({ color }) => {
>
<View
style={{
- width: '100%',
+ width: "100%",
borderRadius: 10,
- overflow: 'hidden',
+ overflow: "hidden",
backgroundColor: colors.nav,
paddingBottom: 12
}}
@@ -32,12 +32,19 @@ export const Announcement = ({ color }) => {
<View>
<FlatList
style={{
- width: '100%',
+ width: "100%",
marginTop: 12
}}
- data={announcement?.body.filter(item => allowedOnPlatform(item.platforms))}
+ data={announcement?.body.filter((item) =>
+ allowedOnPlatform(item.platforms)
+ )}
renderItem={({ item, index }) =>
- renderItem({ item: item, index: index, color: colors[color], inline: true })
+ renderItem({
+ item: item,
+ index: index,
+ color: colors[color],
+ inline: true
+ })
}
/>
</View>
diff --git a/apps/mobile/app/components/announcements/body.js b/apps/mobile/app/components/announcements/body.js
index eaceb2c60..7b5345384 100644
--- a/apps/mobile/app/components/announcements/body.js
+++ b/apps/mobile/app/components/announcements/body.js
@@ -1,10 +1,10 @@
-import React from 'react';
-import { useThemeStore } from '../../stores/use-theme-store';
-import Paragraph from '../ui/typography/paragraph';
-import { getStyle } from './functions';
+import React from "react";
+import { useThemeStore } from "../../stores/use-theme-store";
+import Paragraph from "../ui/typography/paragraph";
+import { getStyle } from "./functions";
export const Body = ({ text, style = {} }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<Paragraph
diff --git a/apps/mobile/app/components/announcements/cta.js b/apps/mobile/app/components/announcements/cta.js
index eb61a6084..f13f4307b 100644
--- a/apps/mobile/app/components/announcements/cta.js
+++ b/apps/mobile/app/components/announcements/cta.js
@@ -1,30 +1,34 @@
-import React from 'react';
-import { Linking, View } from 'react-native';
+import React from "react";
+import { Linking, View } from "react-native";
//import SettingsBackupAndRestore from '../../screens/settings/backup-restore';
-import { eSendEvent, presentSheet } from '../../services/event-manager';
-import Sync from '../../services/sync';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eCloseAnnouncementDialog, eCloseProgressDialog } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { PricingPlans } from '../premium/pricing-plans';
-import SheetProvider from '../sheet-provider';
-import { Progress } from '../sheets/progress';
-import { Button } from '../ui/button';
-import { allowedOnPlatform, getStyle } from './functions';
+import { eSendEvent, presentSheet } from "../../services/event-manager";
+import Sync from "../../services/sync";
+import { useThemeStore } from "../../stores/use-theme-store";
+import {
+ eCloseAnnouncementDialog,
+ eCloseProgressDialog
+} from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { PricingPlans } from "../premium/pricing-plans";
+import SheetProvider from "../sheet-provider";
+import { Progress } from "../sheets/progress";
+import { Button } from "../ui/button";
+import { allowedOnPlatform, getStyle } from "./functions";
export const Cta = ({ actions, style = {}, color, inline }) => {
- const colors = useThemeStore(state => state.colors);
- let buttons = actions.filter(item => allowedOnPlatform(item.platforms)) || [];
+ const colors = useThemeStore((state) => state.colors);
+ let buttons =
+ actions.filter((item) => allowedOnPlatform(item.platforms)) || [];
- const onPress = async item => {
+ const onPress = async (item) => {
if (!inline) {
eSendEvent(eCloseAnnouncementDialog);
await sleep(500);
}
- if (item.type === 'link') {
+ if (item.type === "link") {
Linking.openURL(item.data).catch(console.log);
- } else if (item.type === 'promo') {
+ } else if (item.type === "promo") {
presentSheet({
component: (
<PricingPlans
@@ -36,11 +40,11 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
/>
)
});
- } else if (item.type === 'force-sync') {
+ } else if (item.type === "force-sync") {
eSendEvent(eCloseProgressDialog);
await sleep(300);
Progress.present();
- Sync.run('global', true, true, () => {
+ Sync.run("global", true, true, () => {
eSendEvent(eCloseProgressDialog);
});
}
@@ -50,7 +54,7 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
style={{
paddingHorizontal: 12,
...getStyle(style),
- flexDirection: inline ? 'row' : 'column'
+ flexDirection: inline ? "row" : "column"
}}
>
<SheetProvider context="premium_cta" />
@@ -58,20 +62,20 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
{inline ? (
<>
{buttons.length > 0 &&
- buttons.slice(0, 1).map(item => (
+ buttons.slice(0, 1).map((item) => (
<Button
key={item.title}
title={item.title}
fontSize={SIZE.sm}
type="transparent"
textStyle={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
onPress={() => onPress(item)}
bold
style={{
height: 30,
- alignSelf: 'flex-start',
+ alignSelf: "flex-start",
paddingHorizontal: 0,
marginTop: -6
}}
@@ -89,13 +93,13 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
width={null}
height={30}
style={{
- alignSelf: 'flex-start',
+ alignSelf: "flex-start",
paddingHorizontal: 0,
marginTop: -6,
marginLeft: 12
}}
textStyle={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
/>
))}
@@ -103,7 +107,7 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
) : (
<>
{buttons.length > 0 &&
- buttons.slice(0, 1).map(item => (
+ buttons.slice(0, 1).map((item) => (
<Button
key={item.title}
title={item.title}
@@ -134,11 +138,11 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
width={null}
height={30}
style={{
- minWidth: '50%',
+ minWidth: "50%",
marginTop: 5
}}
textStyle={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
/>
))}
diff --git a/apps/mobile/app/components/announcements/description.js b/apps/mobile/app/components/announcements/description.js
index 82e799cde..5085bb418 100644
--- a/apps/mobile/app/components/announcements/description.js
+++ b/apps/mobile/app/components/announcements/description.js
@@ -1,17 +1,17 @@
-import React from 'react';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import Paragraph from '../ui/typography/paragraph';
-import { getStyle } from './functions';
+import React from "react";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import Paragraph from "../ui/typography/paragraph";
+import { getStyle } from "./functions";
export const Description = ({ text, style = {}, inline }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<Paragraph
style={{
marginHorizontal: 12,
...getStyle(style),
- textAlign: inline ? 'left' : style?.textAlign
+ textAlign: inline ? "left" : style?.textAlign
}}
size={inline ? SIZE.sm : SIZE.md}
>
diff --git a/apps/mobile/app/components/announcements/functions.js b/apps/mobile/app/components/announcements/functions.js
index 5ba387462..530421a08 100644
--- a/apps/mobile/app/components/announcements/functions.js
+++ b/apps/mobile/app/components/announcements/functions.js
@@ -1,18 +1,18 @@
-import React, { Fragment } from 'react';
-import { View } from 'react-native';
-import { allowedPlatforms } from '../../stores/use-message-store';
-import { ProFeatures } from '../dialogs/result/pro-features';
-import { Body } from './body';
-import { Cta } from './cta';
-import { Description } from './description';
-import { List } from './list';
-import { Photo } from './photo';
-import { SubHeading } from './subheading';
-import { Title } from './title';
+import React, { Fragment } from "react";
+import { View } from "react-native";
+import { allowedPlatforms } from "../../stores/use-message-store";
+import { ProFeatures } from "../dialogs/result/pro-features";
+import { Body } from "./body";
+import { Cta } from "./cta";
+import { Description } from "./description";
+import { List } from "./list";
+import { Photo } from "./photo";
+import { SubHeading } from "./subheading";
+import { Title } from "./title";
export function allowedOnPlatform(platforms) {
if (!platforms) return true;
- return platforms.some(platform => allowedPlatforms.indexOf(platform) > -1);
+ return platforms.some((platform) => allowedPlatforms.indexOf(platform) > -1);
}
export const margins = {
@@ -21,12 +21,12 @@ export const margins = {
2: 20
};
-export const getStyle = style => {
+export const getStyle = (style) => {
if (!style) return {};
return {
marginTop: margins[style.marginTop] || 0,
marginBottom: margins[style.marginBottom] || 0,
- textAlign: style.textAlign || 'left'
+ textAlign: style.textAlign || "left"
};
};
@@ -35,8 +35,8 @@ const Features = () => {
<View
style={{
paddingHorizontal: 12,
- alignItems: 'center',
- width: '100%'
+ alignItems: "center",
+ width: "100%"
}}
>
<ProFeatures />
diff --git a/apps/mobile/app/components/announcements/index.js b/apps/mobile/app/components/announcements/index.js
index 70dd72069..e8289ba70 100644
--- a/apps/mobile/app/components/announcements/index.js
+++ b/apps/mobile/app/components/announcements/index.js
@@ -1,18 +1,24 @@
-import React, { useEffect, useState } from 'react';
-import { FlatList, View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useMessageStore } from '../../stores/use-message-store';
-import { DDS } from '../../services/device-detection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import { eCloseAnnouncementDialog, eOpenAnnouncementDialog } from '../../utils/events';
-import BaseDialog from '../dialog/base-dialog';
-import { allowedOnPlatform, renderItem } from './functions';
+import React, { useEffect, useState } from "react";
+import { FlatList, View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useMessageStore } from "../../stores/use-message-store";
+import { DDS } from "../../services/device-detection";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import {
+ eCloseAnnouncementDialog,
+ eOpenAnnouncementDialog
+} from "../../utils/events";
+import BaseDialog from "../dialog/base-dialog";
+import { allowedOnPlatform, renderItem } from "./functions";
export const AnnouncementDialog = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [info, setInfo] = useState(null);
- const remove = useMessageStore(state => state.remove);
+ const remove = useMessageStore((state) => state.remove);
useEffect(() => {
eSubscribeEvent(eOpenAnnouncementDialog, open);
@@ -23,7 +29,7 @@ export const AnnouncementDialog = () => {
};
}, [visible]);
- const open = data => {
+ const open = (data) => {
setInfo(data);
setVisible(true);
};
@@ -46,11 +52,11 @@ export const AnnouncementDialog = () => {
>
<View
style={{
- width: DDS.isTab ? 600 : '100%',
+ width: DDS.isTab ? 600 : "100%",
backgroundColor: colors.bg,
- maxHeight: DDS.isTab ? '90%' : '100%',
+ maxHeight: DDS.isTab ? "90%" : "100%",
borderRadius: DDS.isTab ? 10 : 0,
- overflow: 'hidden',
+ overflow: "hidden",
marginBottom: DDS.isTab ? 20 : 0,
borderTopRightRadius: 10,
borderTopLeftRadius: 10
@@ -58,9 +64,9 @@ export const AnnouncementDialog = () => {
>
<FlatList
style={{
- width: '100%'
+ width: "100%"
}}
- data={info?.body.filter(item => allowedOnPlatform(item.platforms))}
+ data={info?.body.filter((item) => allowedOnPlatform(item.platforms))}
renderItem={renderItem}
/>
diff --git a/apps/mobile/app/components/announcements/list.js b/apps/mobile/app/components/announcements/list.js
index 2eef25059..4c117f0eb 100644
--- a/apps/mobile/app/components/announcements/list.js
+++ b/apps/mobile/app/components/announcements/list.js
@@ -1,18 +1,18 @@
-import React from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../stores/use-theme-store';
-import Paragraph from '../ui/typography/paragraph';
-import { getStyle } from './functions';
+import React from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../stores/use-theme-store";
+import Paragraph from "../ui/typography/paragraph";
+import { getStyle } from "./functions";
export const List = ({ items, listType, style = {} }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<View
style={{
paddingHorizontal: 12,
- paddingLeft: listType === 'ordered' ? 25 : 25,
+ paddingLeft: listType === "ordered" ? 25 : 25,
...getStyle(style)
}}
>
@@ -21,10 +21,10 @@ export const List = ({ items, listType, style = {} }) => {
key={item.text}
style={{
paddingVertical: 6,
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
- {listType === 'ordered' ? (
+ {listType === "ordered" ? (
<Paragraph
style={{
marginRight: 5
diff --git a/apps/mobile/app/components/announcements/photo.js b/apps/mobile/app/components/announcements/photo.js
index 7a0f6c15f..099e849c1 100644
--- a/apps/mobile/app/components/announcements/photo.js
+++ b/apps/mobile/app/components/announcements/photo.js
@@ -1,6 +1,6 @@
-import React from 'react';
-import { Image } from 'react-native';
-import { getStyle } from './functions';
+import React from "react";
+import { Image } from "react-native";
+import { getStyle } from "./functions";
export const Photo = ({ src, style = {} }) => {
return src ? (
@@ -8,9 +8,9 @@ export const Photo = ({ src, style = {} }) => {
source={{ uri: src }}
resizeMode="cover"
style={{
- width: '100%',
+ width: "100%",
height: 200,
- alignSelf: 'center',
+ alignSelf: "center",
...getStyle(style)
}}
/>
diff --git a/apps/mobile/app/components/announcements/subheading.js b/apps/mobile/app/components/announcements/subheading.js
index e5ff43537..8b5685f7b 100644
--- a/apps/mobile/app/components/announcements/subheading.js
+++ b/apps/mobile/app/components/announcements/subheading.js
@@ -1,11 +1,11 @@
-import React from 'react';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import Heading from '../ui/typography/heading';
-import { getStyle } from './functions';
+import React from "react";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import Heading from "../ui/typography/heading";
+import { getStyle } from "./functions";
export const SubHeading = ({ text, style = {} }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<Heading
diff --git a/apps/mobile/app/components/announcements/title.js b/apps/mobile/app/components/announcements/title.js
index 5f41a7d97..bf931e62f 100644
--- a/apps/mobile/app/components/announcements/title.js
+++ b/apps/mobile/app/components/announcements/title.js
@@ -1,22 +1,22 @@
-import React from 'react';
-import { View } from 'react-native';
-import { useMessageStore } from '../../stores/use-message-store';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import Heading from '../ui/typography/heading';
-import { getStyle } from './functions';
+import React from "react";
+import { View } from "react-native";
+import { useMessageStore } from "../../stores/use-message-store";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import Heading from "../ui/typography/heading";
+import { getStyle } from "./functions";
export const Title = ({ text, style = {}, inline }) => {
- const announcements = useMessageStore(state => state.announcements);
+ const announcements = useMessageStore((state) => state.announcements);
let announcement = announcements.length > 0 ? announcements[0] : null;
- const remove = useMessageStore(state => state.remove);
+ const remove = useMessageStore((state) => state.remove);
return inline ? (
<View
style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
marginBottom: inline ? 5 : 0
}}
>
@@ -25,7 +25,7 @@ export const Title = ({ text, style = {}, inline }) => {
marginHorizontal: 12,
marginTop: 12,
...getStyle(style),
- textAlign: inline ? 'left' : style?.textAlign,
+ textAlign: inline ? "left" : style?.textAlign,
flexShrink: 1
}}
numberOfLines={1}
diff --git a/apps/mobile/app/components/attachments/actions.js b/apps/mobile/app/components/attachments/actions.js
index 6317e56ba..0790b4369 100644
--- a/apps/mobile/app/components/attachments/actions.js
+++ b/apps/mobile/app/components/attachments/actions.js
@@ -1,34 +1,42 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import React, { useEffect, useState } from 'react';
-import { View } from 'react-native';
-import { ScrollView } from 'react-native-gesture-handler';
-import picker from '../../screens/editor/tiptap/picker';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
-import PremiumService from '../../services/premium';
-import { useAttachmentStore } from '../../stores/use-attachment-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { formatBytes } from '../../utils';
-import { db } from '../../common/database';
-import { eCloseAttachmentDialog, eCloseProgressDialog } from '../../utils/events';
-import filesystem from '../../common/filesystem';
-import { useAttachmentProgress } from '../../hooks/use-attachment-progress';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { Dialog } from '../dialog';
-import { presentDialog } from '../dialog/functions';
-import { openNote } from '../list-items/note/wrapper';
-import { DateMeta } from '../properties/date-meta';
-import { Button } from '../ui/button';
-import { Notice } from '../ui/notice';
-import { PressableButton } from '../ui/pressable';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import Clipboard from "@react-native-clipboard/clipboard";
+import React, { useEffect, useState } from "react";
+import { View } from "react-native";
+import { ScrollView } from "react-native-gesture-handler";
+import picker from "../../screens/editor/tiptap/picker";
+import {
+ eSendEvent,
+ presentSheet,
+ ToastEvent
+} from "../../services/event-manager";
+import PremiumService from "../../services/premium";
+import { useAttachmentStore } from "../../stores/use-attachment-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { formatBytes } from "../../utils";
+import { db } from "../../common/database";
+import {
+ eCloseAttachmentDialog,
+ eCloseProgressDialog
+} from "../../utils/events";
+import filesystem from "../../common/filesystem";
+import { useAttachmentProgress } from "../../hooks/use-attachment-progress";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { Dialog } from "../dialog";
+import { presentDialog } from "../dialog/functions";
+import { openNote } from "../list-items/note/wrapper";
+import { DateMeta } from "../properties/date-meta";
+import { Button } from "../ui/button";
+import { Notice } from "../ui/notice";
+import { PressableButton } from "../ui/pressable";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
const Actions = ({ attachment, setAttachments, fwdRef }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const contextId = attachment.metadata.hash;
const [filename, setFilename] = useState(attachment.metadata.filename);
- const [currentProgress, setCurrentProgress] = useAttachmentProgress(attachment);
+ const [currentProgress, setCurrentProgress] =
+ useAttachmentProgress(attachment);
const [failed, setFailed] = useState(attachment.failed);
const [notes, setNotes] = useState([]);
const [loading, setLoading] = useState({
@@ -37,25 +45,25 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
const actions = [
{
- name: 'Download',
+ name: "Download",
onPress: async () => {
if (currentProgress) {
- await db.fs.cancel(attachment.metadata.hash, 'download');
+ await db.fs.cancel(attachment.metadata.hash, "download");
useAttachmentStore.getState().remove(attachment.metadata.hash);
}
filesystem.downloadAttachment(attachment.metadata.hash, false);
eSendEvent(eCloseProgressDialog, contextId);
},
- icon: 'download'
+ icon: "download"
},
{
- name: 'Reupload',
+ name: "Reupload",
onPress: async () => {
if (!PremiumService.get()) {
ToastEvent.show({
- heading: 'Upgrade to pro',
- type: 'error',
- context: 'local'
+ heading: "Upgrade to pro",
+ type: "error",
+ context: "local"
});
return;
}
@@ -66,13 +74,13 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
type: attachment.metadata.type
});
},
- icon: 'upload'
+ icon: "upload"
},
{
- name: 'Run file check',
+ name: "Run file check",
onPress: async () => {
setLoading({
- name: 'Run file check'
+ name: "Run file check"
});
let res = await filesystem.checkAttachment(attachment.metadata.hash);
if (res.failed) {
@@ -83,27 +91,27 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
db.attachments.markAsFailed(attachment.id, null);
}
ToastEvent.show({
- heading: 'File check passed',
- type: 'success',
- context: 'local'
+ heading: "File check passed",
+ type: "success",
+ context: "local"
});
setAttachments([...db.attachments.all]);
setLoading({
name: null
});
},
- icon: 'file-check'
+ icon: "file-check"
},
{
- name: 'Rename',
+ name: "Rename",
onPress: () => {
presentDialog({
context: contextId,
input: true,
- title: 'Rename file',
- paragraph: 'Enter a new name for the file',
+ title: "Rename file",
+ paragraph: "Enter a new name for the file",
defaultValue: attachment.metadata.filename,
- positivePress: async value => {
+ positivePress: async (value) => {
if (value && value.length > 0) {
await db.attachments.add({
hash: attachment.metadata.hash,
@@ -113,31 +121,31 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
setAttachments([...db.attachments.all]);
}
},
- positiveText: 'Rename'
+ positiveText: "Rename"
});
},
- icon: 'form-textbox'
+ icon: "form-textbox"
},
{
- name: 'Delete',
+ name: "Delete",
onPress: async () => {
await db.attachments.remove(attachment.metadata.hash, false);
setAttachments([...db.attachments.all]);
eSendEvent(eCloseProgressDialog, contextId);
},
- icon: 'delete-outline'
+ icon: "delete-outline"
}
];
const getNotes = () => {
let allNotes = db.notes.all;
- let attachmentNotes = attachment.noteIds?.map(id => {
- let index = allNotes?.findIndex(note => id === note.id);
+ let attachmentNotes = attachment.noteIds?.map((id) => {
+ let index = allNotes?.findIndex((note) => id === note.id);
if (index !== -1) {
return allNotes[index];
} else {
return {
- type: 'notfound',
+ type: "notfound",
title: `Note with id ${id} does not exist.`,
id: id
};
@@ -157,7 +165,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
}}
nestedScrollEnabled={true}
style={{
- maxHeight: '100%'
+ maxHeight: "100%"
}}
>
<Dialog context={contextId} />
@@ -179,7 +187,7 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
<View
style={{
- flexDirection: 'row',
+ flexDirection: "row",
marginBottom: 10,
paddingHorizontal: 12
}}
@@ -210,15 +218,16 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
size={SIZE.xs + 1}
color={colors.icon}
>
- {attachment.noteIds.length} note{attachment.noteIds.length > 1 ? 's' : ''}
+ {attachment.noteIds.length} note
+ {attachment.noteIds.length > 1 ? "s" : ""}
</Paragraph>
<Paragraph
onPress={() => {
Clipboard.setString(attachment.metadata.hash);
ToastEvent.show({
- type: 'success',
- heading: 'Attachment hash copied',
- context: 'local'
+ type: "success",
+ heading: "Attachment hash copied",
+ context: "local"
});
}}
size={SIZE.xs + 1}
@@ -250,16 +259,16 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
List of notes:
</Heading>
- {notes.map(item => (
+ {notes.map((item) => (
<PressableButton
onPress={async () => {
- if (item.type === 'notfound') {
+ if (item.type === "notfound") {
ToastEvent.show({
- heading: 'Note not found',
+ heading: "Note not found",
message:
- 'A note with the given id was not found. Maybe you have deleted the note or moved it to trash already.',
- type: 'error',
- context: 'local'
+ "A note with the given id was not found. Maybe you have deleted the note or moved it to trash already.",
+ type: "error",
+ context: "local"
});
return;
}
@@ -267,11 +276,11 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
await sleep(150);
eSendEvent(eCloseAttachmentDialog);
await sleep(300);
- openNote(item, item.type === 'trash');
+ openNote(item, item.type === "trash");
}}
customStyle={{
paddingVertical: 12,
- alignItems: 'flex-start',
+ alignItems: "flex-start",
paddingHorizontal: 12
}}
@@ -284,13 +293,13 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
</View>
) : null}
- {actions.map(item => (
+ {actions.map((item) => (
<Button
key={item.name}
buttonType={{
text: item.on
? colors.accent
- : item.name === 'Delete' || item.name === 'PermDelete'
+ : item.name === "Delete" || item.name === "PermDelete"
? colors.errorText
: colors.pri
}}
@@ -298,13 +307,13 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
title={item.name}
icon={item.icon}
loading={loading?.name === item.name}
- type={item.on ? 'shade' : 'gray'}
+ type={item.on ? "shade" : "gray"}
fontSize={SIZE.sm}
style={{
borderRadius: 0,
- justifyContent: 'flex-start',
- alignSelf: 'flex-start',
- width: '100%'
+ justifyContent: "flex-start",
+ alignSelf: "flex-start",
+ width: "100%"
}}
/>
))}
@@ -329,7 +338,9 @@ const Actions = ({ attachment, setAttachments, fwdRef }) => {
Actions.present = (attachment, set, context) => {
presentSheet({
context: context,
- component: ref => <Actions fwdRef={ref} setAttachments={set} attachment={attachment} />
+ component: (ref) => (
+ <Actions fwdRef={ref} setAttachments={set} attachment={attachment} />
+ )
});
};
diff --git a/apps/mobile/app/components/attachments/attachment-item.js b/apps/mobile/app/components/attachments/attachment-item.js
index e88059f08..bb2da4cb9 100644
--- a/apps/mobile/app/components/attachments/attachment-item.js
+++ b/apps/mobile/app/components/attachments/attachment-item.js
@@ -1,28 +1,31 @@
-import React from 'react';
-import { TouchableOpacity, View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useAttachmentStore } from '../../stores/use-attachment-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { formatBytes } from '../../utils';
-import { db } from '../../common/database';
-import { useAttachmentProgress } from '../../hooks/use-attachment-progress';
-import { SIZE } from '../../utils/size';
-import SheetProvider from '../sheet-provider';
-import { IconButton } from '../ui/icon-button';
-import { ProgressCircleComponent } from '../ui/svg/lazy';
-import Paragraph from '../ui/typography/paragraph';
-import Actions from './actions';
+import React from "react";
+import { TouchableOpacity, View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useAttachmentStore } from "../../stores/use-attachment-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { formatBytes } from "../../utils";
+import { db } from "../../common/database";
+import { useAttachmentProgress } from "../../hooks/use-attachment-progress";
+import { SIZE } from "../../utils/size";
+import SheetProvider from "../sheet-provider";
+import { IconButton } from "../ui/icon-button";
+import { ProgressCircleComponent } from "../ui/svg/lazy";
+import Paragraph from "../ui/typography/paragraph";
+import Actions from "./actions";
function getFileExtension(filename) {
var ext = /^.+\.([^.]+)$/.exec(filename);
- return ext == null ? '' : ext[1];
+ return ext == null ? "" : ext[1];
}
export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {
- const colors = useThemeStore(state => state.colors);
- const [currentProgress, setCurrentProgress] = useAttachmentProgress(attachment, encryption);
+ const colors = useThemeStore((state) => state.colors);
+ const [currentProgress, setCurrentProgress] = useAttachmentProgress(
+ attachment,
+ encryption
+ );
const encryptionProgress = encryption
- ? useAttachmentStore(state => state.encryptionProgress)
+ ? useAttachmentStore((state) => state.encryptionProgress)
: null;
const onPress = () => {
@@ -33,9 +36,9 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {
activeOpacity={0.9}
onPress={onPress}
style={{
- flexDirection: 'row',
+ flexDirection: "row",
marginVertical: 5,
- justifyContent: 'space-between',
+ justifyContent: "space-between",
padding: 12,
paddingVertical: 6,
borderRadius: 5,
@@ -47,14 +50,14 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {
<View
style={{
flexShrink: 1,
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<View
style={{
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
marginLeft: -5
}}
>
@@ -65,7 +68,7 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {
size={6}
color={colors.light}
style={{
- position: 'absolute'
+ position: "absolute"
}}
>
{getFileExtension(attachment.metadata.filename).toUpperCase()}
@@ -81,7 +84,7 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {
<Paragraph
size={SIZE.sm - 1}
style={{
- flexWrap: 'wrap',
+ flexWrap: "wrap",
marginBottom: 2.5
}}
numberOfLines={1}
@@ -92,8 +95,10 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {
</Paragraph>
<Paragraph color={colors.icon} size={SIZE.xs}>
- {formatBytes(attachment.length)}{' '}
- {currentProgress?.type ? '(' + currentProgress.type + 'ing - tap to cancel)' : ''}
+ {formatBytes(attachment.length)}{" "}
+ {currentProgress?.type
+ ? "(" + currentProgress.type + "ing - tap to cancel)"
+ : ""}
</Paragraph>
</View>
</View>
@@ -107,7 +112,7 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {
setCurrentProgress(null);
}}
style={{
- justifyContent: 'center',
+ justifyContent: "center",
marginLeft: 5,
marginTop: 5,
marginRight: -5
@@ -127,7 +132,7 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {
fontSize: 10
}}
color={colors.accent}
- formatText={progress => (progress * 100).toFixed(0)}
+ formatText={(progress) => (progress * 100).toFixed(0)}
borderWidth={0}
thickness={2}
/>
@@ -135,7 +140,11 @@ export const AttachmentItem = ({ attachment, encryption, setAttachments }) => {
) : (
<>
{attachment.failed ? (
- <IconButton onPress={onPress} name="alert-circle-outline" color={colors.errorText} />
+ <IconButton
+ onPress={onPress}
+ name="alert-circle-outline"
+ color={colors.errorText}
+ />
) : null}
</>
)}
diff --git a/apps/mobile/app/components/attachments/index.js b/apps/mobile/app/components/attachments/index.js
index 49fb1caf5..7c5e072d3 100644
--- a/apps/mobile/app/components/attachments/index.js
+++ b/apps/mobile/app/components/attachments/index.js
@@ -1,22 +1,28 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { View } from 'react-native';
-import { FlatList } from 'react-native-gesture-handler';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { db } from '../../common/database';
-import { eCloseAttachmentDialog, eOpenAttachmentsDialog } from '../../utils/events';
-import filesystem from '../../common/filesystem';
-import { SIZE } from '../../utils/size';
-import DialogHeader from '../dialog/dialog-header';
-import { Toast } from '../toast';
-import Input from '../ui/input';
-import Seperator from '../ui/seperator';
-import SheetWrapper from '../ui/sheet';
-import Paragraph from '../ui/typography/paragraph';
-import { AttachmentItem } from './attachment-item';
+import React, { useEffect, useRef, useState } from "react";
+import { View } from "react-native";
+import { FlatList } from "react-native-gesture-handler";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { db } from "../../common/database";
+import {
+ eCloseAttachmentDialog,
+ eOpenAttachmentsDialog
+} from "../../utils/events";
+import filesystem from "../../common/filesystem";
+import { SIZE } from "../../utils/size";
+import DialogHeader from "../dialog/dialog-header";
+import { Toast } from "../toast";
+import Input from "../ui/input";
+import Seperator from "../ui/seperator";
+import SheetWrapper from "../ui/sheet";
+import Paragraph from "../ui/typography/paragraph";
+import { AttachmentItem } from "./attachment-item";
export const AttachmentDialog = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [note, setNote] = useState(null);
const actionSheetRef = useRef();
@@ -34,10 +40,10 @@ export const AttachmentDialog = () => {
};
}, [visible]);
- const open = data => {
+ const open = (data) => {
if (data?.id) {
setNote(data);
- let _attachments = db.attachments.ofNote(data.id, 'all');
+ let _attachments = db.attachments.ofNote(data.id, "all");
setAttachments(_attachments);
} else {
setAttachments([...db.attachments.all]);
@@ -56,18 +62,24 @@ export const AttachmentDialog = () => {
setVisible(false);
};
- const onChangeText = text => {
+ const onChangeText = (text) => {
attachmentSearchValue.current = text;
console.log(attachmentSearchValue.current?.length);
- if (!attachmentSearchValue.current || attachmentSearchValue.current === '') {
- console.log('resetting all');
+ if (
+ !attachmentSearchValue.current ||
+ attachmentSearchValue.current === ""
+ ) {
+ console.log("resetting all");
setAttachments([...db.attachments.all]);
}
console.log(attachments.length);
clearTimeout(searchTimer.current);
searchTimer.current = setTimeout(() => {
- let results = db.lookup.attachments(db.attachments.all, attachmentSearchValue.current);
- console.log('results', results.length, attachments.length);
+ let results = db.lookup.attachments(
+ db.attachments.all,
+ attachmentSearchValue.current
+ );
+ console.log("results", results.length, attachments.length);
if (results.length === 0) return;
setAttachments(results);
}, 300);
@@ -88,24 +100,29 @@ export const AttachmentDialog = () => {
<Toast context="local" />
<View
style={{
- width: '100%',
- alignSelf: 'center',
+ width: "100%",
+ alignSelf: "center",
paddingHorizontal: 12
}}
>
<DialogHeader
- title={note ? 'Attachments' : 'Manage attachments'}
+ title={note ? "Attachments" : "Manage attachments"}
paragraph="Tap on an attachment to view properties"
button={{
- title: 'Check all',
- type: 'grayAccent',
+ title: "Check all",
+ type: "grayAccent",
loading: loading,
onPress: async () => {
setLoading(true);
for (let attachment of attachments) {
- let result = await filesystem.checkAttachment(attachment.metadata.hash);
+ let result = await filesystem.checkAttachment(
+ attachment.metadata.hash
+ );
if (result.failed) {
- db.attachments.markAsFailed(attachment.metadata.hash, result.failed);
+ db.attachments.markAsFailed(
+ attachment.metadata.hash,
+ result.failed
+ );
} else {
db.attachments.markAsFailed(attachment.id, null);
}
@@ -139,12 +156,14 @@ export const AttachmentDialog = () => {
<View
style={{
height: 150,
- justifyContent: 'center',
- alignItems: 'center'
+ justifyContent: "center",
+ alignItems: "center"
}}
>
<Icon name="attachment" size={60} color={colors.icon} />
- <Paragraph>{note ? `No attachments on this note` : `No attachments`}</Paragraph>
+ <Paragraph>
+ {note ? `No attachments on this note` : `No attachments`}
+ </Paragraph>
</View>
}
ListFooterComponent={
@@ -155,7 +174,7 @@ export const AttachmentDialog = () => {
/>
}
data={attachments}
- keyExtractor={item => item.id}
+ keyExtractor={(item) => item.id}
renderItem={renderItem}
/>
@@ -163,12 +182,12 @@ export const AttachmentDialog = () => {
color={colors.icon}
size={SIZE.xs}
style={{
- textAlign: 'center',
+ textAlign: "center",
marginTop: 10
}}
>
<Icon name="shield-key-outline" size={SIZE.xs} color={colors.icon} />
- {' '}All attachments are end-to-end encrypted.
+ {" "}All attachments are end-to-end encrypted.
</Paragraph>
</View>
</SheetWrapper>
diff --git a/apps/mobile/app/components/auth/auth-modal.js b/apps/mobile/app/components/auth/auth-modal.js
index 1d239c742..4d4e16f88 100644
--- a/apps/mobile/app/components/auth/auth-modal.js
+++ b/apps/mobile/app/components/auth/auth-modal.js
@@ -1,18 +1,21 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eCloseLoginDialog, eOpenLoginDialog } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import BaseDialog from '../dialog/base-dialog';
-import { Toast } from '../toast';
-import { Button } from '../ui/button';
-import { IconButton } from '../ui/icon-button';
-import { hideAuth, initialAuthMode } from './common';
-import { Login } from './login';
-import { Signup } from './signup';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { Platform, View } from 'react-native';
+import React, { useEffect, useRef, useState } from "react";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { eCloseLoginDialog, eOpenLoginDialog } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import BaseDialog from "../dialog/base-dialog";
+import { Toast } from "../toast";
+import { Button } from "../ui/button";
+import { IconButton } from "../ui/icon-button";
+import { hideAuth, initialAuthMode } from "./common";
+import { Login } from "./login";
+import { Signup } from "./signup";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { Platform, View } from "react-native";
export const AuthMode = {
login: 0,
@@ -22,7 +25,7 @@ export const AuthMode = {
};
const AuthModal = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [currentAuthMode, setCurrentAuthMode] = useState(AuthMode.login);
const actionSheetRef = useRef();
@@ -66,29 +69,31 @@ const AuthModal = () => {
>
{currentAuthMode !== AuthMode.login ? (
<Signup
- changeMode={mode => setCurrentAuthMode(mode)}
+ changeMode={(mode) => setCurrentAuthMode(mode)}
trial={AuthMode.trialSignup === currentAuthMode}
welcome={initialAuthMode.current === AuthMode.welcomeSignup}
/>
) : (
<Login
welcome={initialAuthMode.current === AuthMode.welcomeSignup}
- changeMode={mode => setCurrentAuthMode(mode)}
+ changeMode={(mode) => setCurrentAuthMode(mode)}
/>
)}
<View
style={{
- position: 'absolute',
- top: Platform.OS === 'ios' ? insets.top : 0,
+ position: "absolute",
+ top: Platform.OS === "ios" ? insets.top : 0,
zIndex: 999,
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
paddingHorizontal: 12,
- width: '100%',
+ width: "100%",
height: 50,
justifyContent:
- initialAuthMode.current !== AuthMode.welcomeSignup ? 'space-between' : 'flex-end'
+ initialAuthMode.current !== AuthMode.welcomeSignup
+ ? "space-between"
+ : "flex-end"
}}
>
{initialAuthMode.current === AuthMode.welcomeSignup ? null : (
diff --git a/apps/mobile/app/components/auth/background.js b/apps/mobile/app/components/auth/background.js
index ebf0fdb70..a3a559caf 100644
--- a/apps/mobile/app/components/auth/background.js
+++ b/apps/mobile/app/components/auth/background.js
@@ -1,2 +1,2 @@
-export const SVG = color =>
+export const SVG = (color) =>
`<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="1920" height="1080" preserveAspectRatio="none" viewBox="0 0 1920 1080"><g fill="none"><path d="M684.78-215.3C516.78-49.87 619.54 659.12 349.29 666.13 79.03 673.14-116.04 204.76-321.7 180.13" stroke="${color}" stroke-width="2"></path><path d="M1337.71-20.29C1105.2 122.03 1140.53 887.64 809.58 933.71 478.63 979.78 545.52 798.71 281.45 798.71 17.39 798.71-110.41 932.65-246.68 933.71" stroke="${color}" stroke-width="2"></path><path d="M1631.89-52.3C1379.35-21.93 1283.05 511.66 808.42 545.28 333.79 578.9 209.15 894.14-15.05 901.68" stroke="${color}" stroke-width="2"></path><path d="M1523.21-71.7C1244.4-46.38 1056.2 532.95 581.02 533.49 105.84 534.03-109.4 182.98-361.17 177.09" stroke="${color}" stroke-width="2"></path><path d="M1333.35-39.1C1041.86 57 974.42 893.52 550.36 906.48 126.3 919.44-23.8 619.56-232.63 614.88" stroke="${color}" stroke-width="2"></path></g><defs><mask id="SvgjsMask1032"><rect width="1920" height="1080" fill="#ffffff"></rect></mask></defs></svg>`;
diff --git a/apps/mobile/app/components/auth/change-password.js b/apps/mobile/app/components/auth/change-password.js
index eec802941..2893cc24e 100644
--- a/apps/mobile/app/components/auth/change-password.js
+++ b/apps/mobile/app/components/auth/change-password.js
@@ -1,18 +1,22 @@
-import React, { useRef, useState } from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useUserStore } from '../../stores/use-user-store';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
-import { db } from '../../common/database';
-import { eCloseProgressDialog } from '../../utils/events';
-import { Button } from '../ui/button';
-import DialogHeader from '../dialog/dialog-header';
-import Input from '../ui/input';
-import { Notice } from '../ui/notice';
-import Seperator from '../ui/seperator';
+import React, { useRef, useState } from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useUserStore } from "../../stores/use-user-store";
+import {
+ eSendEvent,
+ presentSheet,
+ ToastEvent
+} from "../../services/event-manager";
+import { db } from "../../common/database";
+import { eCloseProgressDialog } from "../../utils/events";
+import { Button } from "../ui/button";
+import DialogHeader from "../dialog/dialog-header";
+import Input from "../ui/input";
+import { Notice } from "../ui/notice";
+import Seperator from "../ui/seperator";
export const ChangePassword = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const passwordInputRef = useRef();
const password = useRef();
const oldPasswordInputRef = useRef();
@@ -20,24 +24,24 @@ export const ChangePassword = () => {
const [error, setError] = useState(false);
const [loading, setLoading] = useState(false);
- const user = useUserStore(state => state.user);
+ const user = useUserStore((state) => state.user);
const changePassword = async () => {
if (!user?.isEmailConfirmed) {
ToastEvent.show({
- heading: 'Email not confirmed',
- message: 'Please confirm your email to change account password',
- type: 'error',
- context: 'local'
+ heading: "Email not confirmed",
+ message: "Please confirm your email to change account password",
+ type: "error",
+ context: "local"
});
return;
}
if (error || !oldPassword.current || !password.current) {
ToastEvent.show({
- heading: 'All fields required',
- message: 'Fill all the fields and try again.',
- type: 'error',
- context: 'local'
+ heading: "All fields required",
+ message: "Fill all the fields and try again.",
+ type: "error",
+ context: "local"
});
return;
}
@@ -47,18 +51,18 @@ export const ChangePassword = () => {
await db.user.changePassword(oldPassword.current, password.current);
ToastEvent.show({
heading: `Account password updated`,
- type: 'success',
- context: 'global'
+ type: "success",
+ context: "global"
});
setLoading(false);
eSendEvent(eCloseProgressDialog);
} catch (e) {
setLoading(false);
ToastEvent.show({
- heading: 'Failed to change password',
+ heading: "Failed to change password",
message: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
}
setLoading(false);
@@ -67,16 +71,19 @@ export const ChangePassword = () => {
return (
<View
style={{
- width: '100%',
+ width: "100%",
padding: 12
}}
>
- <DialogHeader title="Change password" paragraph="Enter your old and new passwords" />
+ <DialogHeader
+ title="Change password"
+ paragraph="Enter your old and new passwords"
+ />
<Seperator />
<Input
fwdRef={oldPasswordInputRef}
- onChangeText={value => {
+ onChangeText={(value) => {
oldPassword.current = value;
}}
returnKeyLabel="Next"
@@ -90,10 +97,10 @@ export const ChangePassword = () => {
<Input
fwdRef={passwordInputRef}
- onChangeText={value => {
+ onChangeText={(value) => {
password.current = value;
}}
- onErrorCheck={e => setError(e)}
+ onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
returnKeyType="next"
secureTextEntry
@@ -112,12 +119,12 @@ export const ChangePassword = () => {
<Button
style={{
marginTop: 10,
- width: '100%'
+ width: "100%"
}}
loading={loading}
onPress={changePassword}
type="accent"
- title={loading ? null : 'I understand, change my password'}
+ title={loading ? null : "I understand, change my password"}
/>
</View>
);
diff --git a/apps/mobile/app/components/auth/common.js b/apps/mobile/app/components/auth/common.js
index b5e91d4b9..0f2500d35 100644
--- a/apps/mobile/app/components/auth/common.js
+++ b/apps/mobile/app/components/auth/common.js
@@ -1,9 +1,9 @@
-import { createRef } from 'react';
-import { eSendEvent } from '../../services/event-manager';
-import Navigation from '../../services/navigation';
-import SettingsService from '../../services/settings';
-import { eCloseLoginDialog } from '../../utils/events';
-import { tabBarRef } from '../../utils/global-refs';
+import { createRef } from "react";
+import { eSendEvent } from "../../services/event-manager";
+import Navigation from "../../services/navigation";
+import SettingsService from "../../services/settings";
+import { eCloseLoginDialog } from "../../utils/events";
+import { tabBarRef } from "../../utils/global-refs";
export const initialAuthMode = createRef(0);
export function hideAuth() {
diff --git a/apps/mobile/app/components/auth/forgot-password.js b/apps/mobile/app/components/auth/forgot-password.js
index e8ea00b0c..b78e5b0b9 100644
--- a/apps/mobile/app/components/auth/forgot-password.js
+++ b/apps/mobile/app/components/auth/forgot-password.js
@@ -1,21 +1,21 @@
-import React, { useRef, useState } from 'react';
-import { View } from 'react-native';
-import ActionSheet from 'react-native-actions-sheet';
-import { DDS } from '../../services/device-detection';
-import { ToastEvent } from '../../services/event-manager';
-import SettingsService from '../../services/settings';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { db } from '../../common/database';
-import DialogHeader from '../dialog/dialog-header';
-import { Button } from '../ui/button';
-import { IconButton } from '../ui/icon-button';
-import Input from '../ui/input';
-import Seperator from '../ui/seperator';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React, { useRef, useState } from "react";
+import { View } from "react-native";
+import ActionSheet from "react-native-actions-sheet";
+import { DDS } from "../../services/device-detection";
+import { ToastEvent } from "../../services/event-manager";
+import SettingsService from "../../services/settings";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { db } from "../../common/database";
+import DialogHeader from "../dialog/dialog-header";
+import { Button } from "../ui/button";
+import { IconButton } from "../ui/icon-button";
+import Input from "../ui/input";
+import Seperator from "../ui/seperator";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
export const ForgotPassword = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const email = useRef();
const emailInputRef = useRef();
const [error, setError] = useState(false);
@@ -25,17 +25,20 @@ export const ForgotPassword = () => {
const sendRecoveryEmail = async () => {
if (!email.current || error) {
ToastEvent.show({
- heading: 'Account email is required.',
- type: 'error',
- context: 'local'
+ heading: "Account email is required.",
+ type: "error",
+ context: "local"
});
return;
}
setLoading(true);
try {
let lastRecoveryEmailTime = SettingsService.get().lastRecoveryEmailTime;
- if (lastRecoveryEmailTime && Date.now() - JSON.parse(lastRecoveryEmailTime) < 60000 * 3) {
- throw new Error('Please wait before requesting another email');
+ if (
+ lastRecoveryEmailTime &&
+ Date.now() - JSON.parse(lastRecoveryEmailTime) < 60000 * 3
+ ) {
+ throw new Error("Please wait before requesting another email");
}
await db.user.recoverAccount(email.current.toLowerCase());
SettingsService.set({
@@ -44,8 +47,8 @@ export const ForgotPassword = () => {
ToastEvent.show({
heading: `Check your email to reset password`,
message: `Recovery email has been sent to ${email.current.toLowerCase()}`,
- type: 'success',
- context: 'local',
+ type: "success",
+ context: "local",
duration: 7000
});
setLoading(false);
@@ -53,10 +56,10 @@ export const ForgotPassword = () => {
} catch (e) {
setLoading(false);
ToastEvent.show({
- heading: 'Recovery email not sent',
+ heading: "Recovery email not sent",
message: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
}
};
@@ -64,7 +67,7 @@ export const ForgotPassword = () => {
return (
<>
<ActionSheet
- onBeforeShow={data => (email.current = data)}
+ onBeforeShow={(data) => (email.current = data)}
onClose={() => {
setSent(false);
setLoading(false);
@@ -82,8 +85,8 @@ export const ForgotPassword = () => {
<View
style={{
padding: 12,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
paddingBottom: 50
}}
>
@@ -99,7 +102,7 @@ export const ForgotPassword = () => {
<Heading>Recovery email sent!</Heading>
<Paragraph
style={{
- textAlign: 'center'
+ textAlign: "center"
}}
>
Please follow the link in the email to recover your account.
@@ -111,7 +114,7 @@ export const ForgotPassword = () => {
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.bg,
zIndex: 10,
- width: '100%',
+ width: "100%",
padding: 12
}}
>
@@ -123,11 +126,11 @@ export const ForgotPassword = () => {
<Input
fwdRef={emailInputRef}
- onChangeText={value => {
+ onChangeText={(value) => {
email.current = value;
}}
defaultValue={email.current}
- onErrorCheck={e => setError(e)}
+ onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
returnKeyType="next"
autoComplete="email"
@@ -142,12 +145,12 @@ export const ForgotPassword = () => {
<Button
style={{
marginTop: 10,
- width: '100%'
+ width: "100%"
}}
loading={loading}
onPress={sendRecoveryEmail}
type="accent"
- title={loading ? null : 'Next'}
+ title={loading ? null : "Next"}
/>
</View>
)}
diff --git a/apps/mobile/app/components/auth/index.js b/apps/mobile/app/components/auth/index.js
index 8c14dc07d..3f256d3b2 100644
--- a/apps/mobile/app/components/auth/index.js
+++ b/apps/mobile/app/components/auth/index.js
@@ -1,13 +1,13 @@
-import React, { useState } from 'react';
-import { View } from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { tabBarRef } from '../../utils/global-refs';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
-import { Toast } from '../toast';
-import { initialAuthMode } from './common';
-import { Login } from './login';
-import { Signup } from './signup';
+import React, { useState } from "react";
+import { View } from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { tabBarRef } from "../../utils/global-refs";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
+import { Toast } from "../toast";
+import { initialAuthMode } from "./common";
+import { Login } from "./login";
+import { Signup } from "./signup";
export const AuthMode = {
login: 0,
@@ -17,8 +17,10 @@ export const AuthMode = {
};
const Auth = ({ navigation, route }) => {
- const colors = useThemeStore(state => state.colors);
- const [currentAuthMode, setCurrentAuthMode] = useState(route?.params?.mode || AuthMode.login);
+ const colors = useThemeStore((state) => state.colors);
+ const [currentAuthMode, setCurrentAuthMode] = useState(
+ route?.params?.mode || AuthMode.login
+ );
const insets = useSafeAreaInsets();
initialAuthMode.current = route?.params.mode || AuthMode.login;
useNavigationFocus(navigation, {
@@ -32,12 +34,15 @@ const Auth = ({ navigation, route }) => {
<View style={{ flex: 1 }}>
{currentAuthMode !== AuthMode.login ? (
<Signup
- changeMode={mode => setCurrentAuthMode(mode)}
+ changeMode={(mode) => setCurrentAuthMode(mode)}
trial={AuthMode.trialSignup === currentAuthMode}
welcome={initialAuthMode.current === AuthMode.welcomeSignup}
/>
) : (
- <Login welcome={initialAuthMode.current} changeMode={mode => setCurrentAuthMode(mode)} />
+ <Login
+ welcome={initialAuthMode.current}
+ changeMode={(mode) => setCurrentAuthMode(mode)}
+ />
)}
{/* {initialAuthMode.current === AuthMode.welcomeSignup ? null : (
diff --git a/apps/mobile/app/components/auth/login.js b/apps/mobile/app/components/auth/login.js
index bccd568a7..567bb6ab7 100644
--- a/apps/mobile/app/components/auth/login.js
+++ b/apps/mobile/app/components/auth/login.js
@@ -1,36 +1,40 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { Platform, View } from 'react-native';
-import { SheetManager } from 'react-native-actions-sheet';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { DDS } from '../../services/device-detection';
-import { eSendEvent, ToastEvent } from '../../services/event-manager';
-import { clearMessage } from '../../services/message';
-import PremiumService from '../../services/premium';
-import SettingsService from '../../services/settings';
-import { useUserStore } from '../../stores/use-user-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { db } from '../../common/database';
-import { eCloseLoginDialog } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import BaseDialog from '../dialog/base-dialog';
-import SheetProvider from '../sheet-provider';
-import { Progress } from '../sheets/progress';
-import { Button } from '../ui/button';
-import { IconButton } from '../ui/icon-button';
-import Input from '../ui/input';
-import { SvgView } from '../ui/svg';
-import { BouncingView } from '../ui/transitions/bouncing-view';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { SVG } from './background';
-import { ForgotPassword } from './forgot-password';
-import TwoFactorVerification from './two-factor';
-import Animated, { FadeInDown, FadeOutDown, FadeOutUp } from 'react-native-reanimated';
-import Navigation from '../../services/navigation';
-import { hideAuth } from './common';
+import React, { useEffect, useRef, useState } from "react";
+import { Platform, View } from "react-native";
+import { SheetManager } from "react-native-actions-sheet";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { DDS } from "../../services/device-detection";
+import { eSendEvent, ToastEvent } from "../../services/event-manager";
+import { clearMessage } from "../../services/message";
+import PremiumService from "../../services/premium";
+import SettingsService from "../../services/settings";
+import { useUserStore } from "../../stores/use-user-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { db } from "../../common/database";
+import { eCloseLoginDialog } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import BaseDialog from "../dialog/base-dialog";
+import SheetProvider from "../sheet-provider";
+import { Progress } from "../sheets/progress";
+import { Button } from "../ui/button";
+import { IconButton } from "../ui/icon-button";
+import Input from "../ui/input";
+import { SvgView } from "../ui/svg";
+import { BouncingView } from "../ui/transitions/bouncing-view";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { SVG } from "./background";
+import { ForgotPassword } from "./forgot-password";
+import TwoFactorVerification from "./two-factor";
+import Animated, {
+ FadeInDown,
+ FadeOutDown,
+ FadeOutUp
+} from "react-native-reanimated";
+import Navigation from "../../services/navigation";
+import { hideAuth } from "./common";
export const Login = ({ changeMode, welcome }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const email = useRef();
const emailInputRef = useRef();
const passwordInputRef = useRef();
@@ -40,15 +44,15 @@ export const Login = ({ changeMode, welcome }) => {
const [loading, setLoading] = useState(false);
const insets = useSafeAreaInsets();
- const setUser = useUserStore(state => state.setUser);
+ const setUser = useUserStore((state) => state.setUser);
const validateInfo = () => {
if (!password.current || !email.current) {
ToastEvent.show({
- heading: 'All fields required',
- message: 'Fill all the fields and try again',
- type: 'error',
- context: 'local'
+ heading: "All fields required",
+ message: "Fill all the fields and try again",
+ type: "error",
+ context: "local"
});
return false;
@@ -71,37 +75,41 @@ export const Login = ({ changeMode, welcome }) => {
let user;
try {
if (mfa) {
- await db.user.mfaLogin(email.current.toLowerCase(), password.current, mfa);
+ await db.user.mfaLogin(
+ email.current.toLowerCase(),
+ password.current,
+ mfa
+ );
} else {
await db.user.login(email.current.toLowerCase(), password.current);
}
callback && callback(true);
user = await db.user.getUser();
- if (!user) throw new Error('Email or password incorrect!');
+ if (!user) throw new Error("Email or password incorrect!");
PremiumService.setPremiumStatus();
setUser(user);
clearMessage();
ToastEvent.show({
- heading: 'Login successful',
+ heading: "Login successful",
message: `Logged in as ${user.email}`,
- type: 'success',
- context: 'global'
+ type: "success",
+ context: "global"
});
hideAuth();
SettingsService.set({
sessionExpired: false,
userEmailConfirmed: user?.isEmailConfirmed
});
- eSendEvent('userLoggedIn', true);
+ eSendEvent("userLoggedIn", true);
await sleep(500);
Progress.present();
} catch (e) {
callback && callback(false);
- if (e.message === 'Multifactor authentication required.') {
+ if (e.message === "Multifactor authentication required.") {
setLoading(false);
await sleep(300);
- TwoFactorVerification.present(async mfa => {
+ TwoFactorVerification.present(async (mfa) => {
if (mfa) {
console.log(mfa);
await login(mfa);
@@ -112,10 +120,10 @@ export const Login = ({ changeMode, welcome }) => {
} else {
setLoading(false);
ToastEvent.show({
- heading: user ? 'Failed to sync' : 'Login failed',
+ heading: user ? "Failed to sync" : "Login failed",
message: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
}
}
@@ -125,7 +133,9 @@ export const Login = ({ changeMode, welcome }) => {
<>
<ForgotPassword />
<SheetProvider context="two_factor_verify" />
- {loading ? <BaseDialog transparent={true} visible={true} animation="fade" /> : null}
+ {loading ? (
+ <BaseDialog transparent={true} visible={true} animation="fade" />
+ ) : null}
<Animated.View
entering={FadeInDown}
exiting={FadeOutUp}
@@ -133,23 +143,26 @@ export const Login = ({ changeMode, welcome }) => {
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.bg,
zIndex: 10,
- width: '100%',
- minHeight: '100%'
+ width: "100%",
+ minHeight: "100%"
}}
>
<View
style={{
height: 250,
- overflow: 'hidden'
+ overflow: "hidden"
}}
>
- <SvgView src={SVG(colors.night ? colors.icon : 'black')} height={700} />
+ <SvgView
+ src={SVG(colors.night ? colors.icon : "black")}
+ height={700}
+ />
</View>
<View
style={{
- width: '100%',
- justifyContent: 'center',
- alignSelf: 'center',
+ width: "100%",
+ justifyContent: "center",
+ alignSelf: "center",
paddingHorizontal: 12,
marginBottom: 30,
marginTop: 15
@@ -157,7 +170,7 @@ export const Login = ({ changeMode, welcome }) => {
>
<Heading
style={{
- textAlign: 'center'
+ textAlign: "center"
}}
size={30}
color={colors.heading}
@@ -166,8 +179,8 @@ export const Login = ({ changeMode, welcome }) => {
</Heading>
<Paragraph
style={{
- textDecorationLine: 'underline',
- textAlign: 'center',
+ textDecorationLine: "underline",
+ textAlign: "center",
marginTop: 5
}}
onPress={() => {
@@ -180,20 +193,26 @@ export const Login = ({ changeMode, welcome }) => {
</View>
<View
style={{
- width: DDS.isTab ? (focused ? '50%' : '49.99%') : focused ? '100%' : '99.9%',
+ width: DDS.isTab
+ ? focused
+ ? "50%"
+ : "49.99%"
+ : focused
+ ? "100%"
+ : "99.9%",
padding: 12,
backgroundColor: colors.bg,
flexGrow: 1,
- alignSelf: 'center'
+ alignSelf: "center"
}}
>
<Input
fwdRef={emailInputRef}
- onChangeText={value => {
+ onChangeText={(value) => {
email.current = value;
}}
testID="input.email"
- onErrorCheck={e => setError(e)}
+ onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
returnKeyType="next"
autoComplete="email"
@@ -209,7 +228,7 @@ export const Login = ({ changeMode, welcome }) => {
<Input
fwdRef={passwordInputRef}
- onChangeText={value => {
+ onChangeText={(value) => {
password.current = value;
}}
testID="input.password"
@@ -226,15 +245,15 @@ export const Login = ({ changeMode, welcome }) => {
<Button
title="Forgot your password?"
style={{
- alignSelf: 'flex-end',
+ alignSelf: "flex-end",
height: 30,
paddingHorizontal: 0
}}
onPress={() => {
- SheetManager.show('forgotpassword_sheet', email.current);
+ SheetManager.show("forgotpassword_sheet", email.current);
}}
textStyle={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
fontSize={SIZE.xs}
type="gray"
@@ -244,7 +263,7 @@ export const Login = ({ changeMode, welcome }) => {
style={{
// position: 'absolute',
marginTop: 25,
- alignSelf: 'center'
+ alignSelf: "center"
}}
>
<Button
@@ -256,7 +275,7 @@ export const Login = ({ changeMode, welcome }) => {
onPress={() => login()}
// width="100%"
type="accent"
- title={loading ? null : 'Login to your account'}
+ title={loading ? null : "Login to your account"}
/>
</View>
</View>
diff --git a/apps/mobile/app/components/auth/session-expired.js b/apps/mobile/app/components/auth/session-expired.js
index 39b559ac2..22f8ff383 100644
--- a/apps/mobile/app/components/auth/session-expired.js
+++ b/apps/mobile/app/components/auth/session-expired.js
@@ -1,47 +1,47 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { Modal, View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useUserStore } from '../../stores/use-user-store';
-import BiometricService from '../../services/biometrics';
+import React, { useEffect, useRef, useState } from "react";
+import { Modal, View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useUserStore } from "../../stores/use-user-store";
+import BiometricService from "../../services/biometrics";
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet,
ToastEvent
-} from '../../services/event-manager';
-import { clearMessage } from '../../services/message';
-import PremiumService from '../../services/premium';
-import Sync from '../../services/sync';
-import { db } from '../../common/database';
-import { MMKV } from '../../common/database/mmkv';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { IconButton } from '../ui/icon-button';
-import { Button } from '../ui/button';
-import { Dialog } from '../dialog';
-import { presentDialog } from '../dialog/functions';
-import Input from '../ui/input';
-import { Toast } from '../toast';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import SettingsService from '../../services/settings';
-import TwoFactorVerification from './two-factor';
-import SheetProvider from '../sheet-provider';
-import { Progress } from '../sheets/progress';
+} from "../../services/event-manager";
+import { clearMessage } from "../../services/message";
+import PremiumService from "../../services/premium";
+import Sync from "../../services/sync";
+import { db } from "../../common/database";
+import { MMKV } from "../../common/database/mmkv";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { IconButton } from "../ui/icon-button";
+import { Button } from "../ui/button";
+import { Dialog } from "../dialog";
+import { presentDialog } from "../dialog/functions";
+import Input from "../ui/input";
+import { Toast } from "../toast";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import SettingsService from "../../services/settings";
+import TwoFactorVerification from "./two-factor";
+import SheetProvider from "../sheet-provider";
+import { Progress } from "../sheets/progress";
function getEmail(email) {
if (!email) return null;
return email.replace(/(.{2})(.*)(?=@)/, function (gp1, gp2, gp3) {
for (let i = 0; i < gp3.length; i++) {
- gp2 += '*';
+ gp2 += "*";
}
return gp2;
});
}
export const SessionExpired = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const email = useRef();
const emailInputRef = useRef();
const passwordInputRef = useRef();
@@ -49,7 +49,7 @@ export const SessionExpired = () => {
const [visible, setVisible] = useState(false);
const [focused, setFocused] = useState(false);
- const setUser = useUserStore(state => state.setUser);
+ const setUser = useUserStore((state) => state.setUser);
const [error, setError] = useState(false);
const [loading, setLoading] = useState(false);
@@ -65,27 +65,28 @@ export const SessionExpired = () => {
} catch (e) {
ToastEvent.show({
heading: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
}
};
useEffect(() => {
- eSubscribeEvent('session_expired', open);
+ eSubscribeEvent("session_expired", open);
return () => {
- eUnSubscribeEvent('session_expired', open);
+ eUnSubscribeEvent("session_expired", open);
setFocused(false);
};
}, [visible]);
const open = async () => {
try {
- console.log('REQUESTING NEW TOKEN');
+ console.log("REQUESTING NEW TOKEN");
let res = await db.user.tokenManager.getToken();
- if (!res) throw new Error('no token found');
- if (db.user.tokenManager._isTokenExpired(res)) throw new Error('token expired');
- Sync.run('global', false, true, async complete => {
+ if (!res) throw new Error("no token found");
+ if (db.user.tokenManager._isTokenExpired(res))
+ throw new Error("token expired");
+ Sync.run("global", false, true, async (complete) => {
if (!complete) {
let user = await db.user.getUser();
if (!user) return;
@@ -113,35 +114,39 @@ export const SessionExpired = () => {
let user;
try {
if (mfa) {
- await db.user.mfaLogin(email.current.toLowerCase(), password.current, mfa);
+ await db.user.mfaLogin(
+ email.current.toLowerCase(),
+ password.current,
+ mfa
+ );
} else {
await db.user.login(email.current.toLowerCase(), password.current);
}
callback && callback(true);
setVisible(false);
user = await db.user.getUser();
- if (!user) throw new Error('Email or password incorrect!');
+ if (!user) throw new Error("Email or password incorrect!");
PremiumService.setPremiumStatus();
setUser(user);
clearMessage();
ToastEvent.show({
- heading: 'Login successful',
+ heading: "Login successful",
message: `Logged in as ${user.email}`,
- type: 'success',
- context: 'global'
+ type: "success",
+ context: "global"
});
await SettingsService.set({
sessionExpired: false,
userEmailConfirmed: user?.isEmailConfirmed
});
- eSendEvent('userLoggedIn', true);
+ eSendEvent("userLoggedIn", true);
await sleep(500);
Progress.present();
setLoading(false);
} catch (e) {
callback && callback(false);
- if (e.message === 'Multifactor authentication required.') {
- TwoFactorVerification.present(async mfa => {
+ if (e.message === "Multifactor authentication required.") {
+ TwoFactorVerification.present(async (mfa) => {
if (mfa) {
console.log(mfa);
await login(mfa);
@@ -153,10 +158,10 @@ export const SessionExpired = () => {
console.log(e.stack);
setLoading(false);
ToastEvent.show({
- heading: user ? 'Failed to sync' : 'Login failed',
+ heading: user ? "Failed to sync" : "Login failed",
message: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
}
}
@@ -174,17 +179,17 @@ export const SessionExpired = () => {
<SheetProvider context="two_factor_verify" />
<View
style={{
- width: focused ? '100%' : '99.9%',
+ width: focused ? "100%" : "99.9%",
padding: 12,
- justifyContent: 'center',
+ justifyContent: "center",
flex: 1
}}
>
<View
style={{
- justifyContent: 'center',
- alignItems: 'center',
- width: '100%',
+ justifyContent: "center",
+ alignItems: "center",
+ width: "100%",
marginBottom: 20,
borderRadius: 10,
paddingVertical: 20
@@ -204,17 +209,17 @@ export const SessionExpired = () => {
</Heading>
<Paragraph
style={{
- textAlign: 'center'
+ textAlign: "center"
}}
>
- Your session on this device has expired. Please enter password for{' '}
+ Your session on this device has expired. Please enter password for{" "}
{getEmail(email.current)} to continue.
</Paragraph>
</View>
<Input
fwdRef={passwordInputRef}
- onChangeText={value => {
+ onChangeText={(value) => {
password.current = value;
}}
returnKeyLabel="Next"
@@ -230,32 +235,32 @@ export const SessionExpired = () => {
<Button
style={{
marginTop: 10,
- width: '100%'
+ width: "100%"
}}
loading={loading}
onPress={() => login()}
type="accent"
- title={loading ? null : 'Login'}
+ title={loading ? null : "Login"}
/>
<Button
style={{
marginTop: 10,
- width: '100%'
+ width: "100%"
}}
onPress={() => {
presentDialog({
- context: 'session_expiry',
- title: 'Logout',
+ context: "session_expiry",
+ title: "Logout",
paragraph:
- 'Are you sure you want to logout from this device? Any unsynced changes will be lost.',
- positiveText: 'Logout',
- positiveType: 'errorShade',
+ "Are you sure you want to logout from this device? Any unsynced changes will be lost.",
+ positiveText: "Logout",
+ positiveType: "errorShade",
positivePress: logout
});
}}
type="errorShade"
- title={loading ? null : 'Logout from this device'}
+ title={loading ? null : "Logout from this device"}
/>
</View>
<Toast context="local" />
diff --git a/apps/mobile/app/components/auth/signup.js b/apps/mobile/app/components/auth/signup.js
index 6ddc09fc0..a7faa6a7d 100644
--- a/apps/mobile/app/components/auth/signup.js
+++ b/apps/mobile/app/components/auth/signup.js
@@ -1,32 +1,36 @@
-import React, { useRef, useState } from 'react';
-import { Dimensions, View } from 'react-native';
-import Animated, { FadeInDown, FadeOutDown, FadeOutUp } from 'react-native-reanimated';
-import { DDS } from '../../services/device-detection';
-import { eSendEvent, ToastEvent } from '../../services/event-manager';
-import { clearMessage, setEmailVerifyMessage } from '../../services/message';
-import Navigation from '../../services/navigation';
-import PremiumService from '../../services/premium';
-import SettingsService from '../../services/settings';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useUserStore } from '../../stores/use-user-store';
-import umami from '../../common/analytics';
-import { db } from '../../common/database';
-import { eCloseLoginDialog } from '../../utils/events';
-import { openLinkInBrowser } from '../../utils/functions';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import BaseDialog from '../dialog/base-dialog';
-import { Button } from '../ui/button';
-import Input from '../ui/input';
-import { SvgView } from '../ui/svg';
-import { BouncingView } from '../ui/transitions/bouncing-view';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { SVG } from './background';
-import { hideAuth } from './common';
+import React, { useRef, useState } from "react";
+import { Dimensions, View } from "react-native";
+import Animated, {
+ FadeInDown,
+ FadeOutDown,
+ FadeOutUp
+} from "react-native-reanimated";
+import { DDS } from "../../services/device-detection";
+import { eSendEvent, ToastEvent } from "../../services/event-manager";
+import { clearMessage, setEmailVerifyMessage } from "../../services/message";
+import Navigation from "../../services/navigation";
+import PremiumService from "../../services/premium";
+import SettingsService from "../../services/settings";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useUserStore } from "../../stores/use-user-store";
+import umami from "../../common/analytics";
+import { db } from "../../common/database";
+import { eCloseLoginDialog } from "../../utils/events";
+import { openLinkInBrowser } from "../../utils/functions";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import BaseDialog from "../dialog/base-dialog";
+import { Button } from "../ui/button";
+import Input from "../ui/input";
+import { SvgView } from "../ui/svg";
+import { BouncingView } from "../ui/transitions/bouncing-view";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { SVG } from "./background";
+import { hideAuth } from "./common";
export const Signup = ({ changeMode, welcome, trial }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const email = useRef();
const emailInputRef = useRef();
const passwordInputRef = useRef();
@@ -35,16 +39,16 @@ export const Signup = ({ changeMode, welcome, trial }) => {
const confirmPassword = useRef();
const [error, setError] = useState(false);
const [loading, setLoading] = useState(false);
- const setUser = useUserStore(state => state.setUser);
- const setLastSynced = useUserStore(state => state.setLastSynced);
+ const setUser = useUserStore((state) => state.setUser);
+ const setLastSynced = useUserStore((state) => state.setLastSynced);
const validateInfo = () => {
if (!password.current || !email.current || !confirmPassword.current) {
ToastEvent.show({
- heading: 'All fields required',
- message: 'Fill all the fields and try again',
- type: 'error',
- context: 'local'
+ heading: "All fields required",
+ message: "Fill all the fields and try again",
+ type: "error",
+ context: "local"
});
return false;
@@ -64,7 +68,7 @@ export const Signup = ({ changeMode, welcome, trial }) => {
clearMessage();
setEmailVerifyMessage();
hideAuth();
- umami.pageView('/account-created', '/welcome/signup');
+ umami.pageView("/account-created", "/welcome/signup");
await sleep(300);
if (trial) {
PremiumService.sheet(null, null, true);
@@ -74,17 +78,19 @@ export const Signup = ({ changeMode, welcome, trial }) => {
} catch (e) {
setLoading(false);
ToastEvent.show({
- heading: 'Signup failed',
+ heading: "Signup failed",
message: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
}
};
return (
<>
- {loading ? <BaseDialog transparent={true} visible={true} animation="fade" /> : null}
+ {loading ? (
+ <BaseDialog transparent={true} visible={true} animation="fade" />
+ ) : null}
<Animated.View
entering={FadeInDown}
exiting={FadeOutUp}
@@ -92,32 +98,35 @@ export const Signup = ({ changeMode, welcome, trial }) => {
borderRadius: DDS.isTab ? 5 : 0,
backgroundColor: colors.bg,
zIndex: 10,
- width: '100%',
- minHeight: '100%'
+ width: "100%",
+ minHeight: "100%"
}}
>
<View
style={{
height: 250,
- overflow: 'hidden'
+ overflow: "hidden"
}}
>
- <SvgView src={SVG(colors.night ? colors.icon : 'black')} height={700} />
+ <SvgView
+ src={SVG(colors.night ? colors.icon : "black")}
+ height={700}
+ />
</View>
<View
style={{
- width: '100%',
- justifyContent: 'center',
- alignSelf: 'center',
+ width: "100%",
+ justifyContent: "center",
+ alignSelf: "center",
paddingHorizontal: 12,
marginBottom: 30,
- marginTop: Dimensions.get('window').height < 700 ? -75 : 15
+ marginTop: Dimensions.get("window").height < 700 ? -75 : 15
}}
>
<Heading
style={{
- textAlign: 'center'
+ textAlign: "center"
}}
size={30}
color={colors.heading}
@@ -126,8 +135,8 @@ export const Signup = ({ changeMode, welcome, trial }) => {
</Heading>
<Paragraph
style={{
- textDecorationLine: 'underline',
- textAlign: 'center'
+ textDecorationLine: "underline",
+ textAlign: "center"
}}
onPress={() => {
changeMode(0);
@@ -139,20 +148,20 @@ export const Signup = ({ changeMode, welcome, trial }) => {
</View>
<View
style={{
- width: DDS.isTab ? '50%' : '100%',
+ width: DDS.isTab ? "50%" : "100%",
padding: 12,
backgroundColor: colors.bg,
flexGrow: 1,
- alignSelf: 'center'
+ alignSelf: "center"
}}
>
<Input
fwdRef={emailInputRef}
- onChangeText={value => {
+ onChangeText={(value) => {
email.current = value;
}}
testID="input.email"
- onErrorCheck={e => setError(e)}
+ onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
returnKeyType="next"
autoComplete="email"
@@ -168,11 +177,11 @@ export const Signup = ({ changeMode, welcome, trial }) => {
<Input
fwdRef={passwordInputRef}
- onChangeText={value => {
+ onChangeText={(value) => {
password.current = value;
}}
testID="input.password"
- onErrorCheck={e => setError(e)}
+ onErrorCheck={(e) => setError(e)}
returnKeyLabel="Next"
returnKeyType="next"
secureTextEntry
@@ -188,11 +197,11 @@ export const Signup = ({ changeMode, welcome, trial }) => {
<Input
fwdRef={confirmPasswordInputRef}
- onChangeText={value => {
+ onChangeText={(value) => {
confirmPassword.current = value;
}}
testID="input.confirmPassword"
- onErrorCheck={e => setError(e)}
+ onErrorCheck={(e) => setError(e)}
returnKeyLabel="Signup"
returnKeyType="done"
secureTextEntry
@@ -208,7 +217,7 @@ export const Signup = ({ changeMode, welcome, trial }) => {
<View
style={{
marginTop: 25,
- alignSelf: 'center'
+ alignSelf: "center"
}}
>
<Button
@@ -219,42 +228,42 @@ export const Signup = ({ changeMode, welcome, trial }) => {
loading={loading}
onPress={signup}
type="accent"
- title={loading ? null : 'Agree and continue'}
+ title={loading ? null : "Agree and continue"}
/>
</View>
<Paragraph
style={{
- textAlign: 'center',
- position: 'absolute',
+ textAlign: "center",
+ position: "absolute",
bottom: 0,
- alignSelf: 'center',
+ alignSelf: "center",
marginBottom: 20
}}
size={SIZE.xs}
color={colors.icon}
>
- By signing up, you agree to our{' '}
+ By signing up, you agree to our{" "}
<Paragraph
size={SIZE.xs}
onPress={() => {
- openLinkInBrowser('https://notesnook.com/tos', colors);
+ openLinkInBrowser("https://notesnook.com/tos", colors);
}}
style={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
color={colors.accent}
>
- terms of service{' '}
+ terms of service{" "}
</Paragraph>
- and{' '}
+ and{" "}
<Paragraph
size={SIZE.xs}
onPress={() => {
- openLinkInBrowser('https://notesnook.com/privacy', colors);
+ openLinkInBrowser("https://notesnook.com/privacy", colors);
}}
style={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
color={colors.accent}
>
diff --git a/apps/mobile/app/components/auth/two-factor.js b/apps/mobile/app/components/auth/two-factor.js
index 1bbd40a97..a9884ebbb 100644
--- a/apps/mobile/app/components/auth/two-factor.js
+++ b/apps/mobile/app/components/auth/two-factor.js
@@ -1,22 +1,22 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { View } from 'react-native';
-import { eSendEvent, presentSheet } from '../../services/event-manager';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eCloseProgressDialog } from '../../utils/events';
-import useTimer from '../../hooks/use-timer';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import { IconButton } from '../ui/icon-button';
-import Input from '../ui/input';
-import { PressableButton } from '../ui/pressable';
-import Seperator from '../ui/seperator';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { db } from '../../common/database/index';
-import { ToastEvent } from '../../services/event-manager';
+import React, { useEffect, useRef, useState } from "react";
+import { View } from "react-native";
+import { eSendEvent, presentSheet } from "../../services/event-manager";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { eCloseProgressDialog } from "../../utils/events";
+import useTimer from "../../hooks/use-timer";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import { IconButton } from "../ui/icon-button";
+import Input from "../ui/input";
+import { PressableButton } from "../ui/pressable";
+import Seperator from "../ui/seperator";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { db } from "../../common/database/index";
+import { ToastEvent } from "../../services/event-manager";
const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const code = useRef();
const [currentMethod, setCurrentMethod] = useState({
method: mfaInfo?.primaryMethod,
@@ -28,10 +28,10 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
const [sending, setSending] = useState(false);
const codeHelpText = {
- app: 'Enter the 6 digit code from your authenticator app to continue logging in',
- sms: 'Enter the 6 digit code sent to your phone number to continue logging in',
- email: 'Enter the 6 digit code sent to your email to continue logging in',
- recoveryCode: 'Enter the 8 digit recovery code to continue logging in'
+ app: "Enter the 6 digit code from your authenticator app to continue logging in",
+ sms: "Enter the 6 digit code sent to your phone number to continue logging in",
+ email: "Enter the 6 digit code sent to your email to continue logging in",
+ recoveryCode: "Enter the 8 digit recovery code to continue logging in"
};
const secondaryMethodsText = {
@@ -42,7 +42,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
};
const onNext = async () => {
- const length = currentMethod.method === 'recoveryCode' ? 8 : 6;
+ const length = currentMethod.method === "recoveryCode" ? 8 : 6;
if (!code.current || code.current.length !== length) return;
console.log(currentMethod.method, code.current);
@@ -53,10 +53,10 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
method: currentMethod.method,
code: code.current
},
- result => {
- console.log('result recieved');
+ (result) => {
+ console.log("result recieved");
if (result) {
- eSendEvent(eCloseProgressDialog, 'two_factor_verify');
+ eSendEvent(eCloseProgressDialog, "two_factor_verify");
}
setLoading(false);
}
@@ -73,38 +73,38 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
const methods = [
{
- id: 'sms',
- title: 'Send code via SMS',
- icon: 'message-plus-outline'
+ id: "sms",
+ title: "Send code via SMS",
+ icon: "message-plus-outline"
},
{
- id: 'email',
- title: 'Send code via email',
- icon: 'email-outline'
+ id: "email",
+ title: "Send code via email",
+ icon: "email-outline"
},
{
- id: 'app',
- title: 'Enter code from authenticator app',
- icon: 'cellphone-key'
+ id: "app",
+ title: "Enter code from authenticator app",
+ icon: "cellphone-key"
},
{
- id: 'recoveryCode',
- title: 'I have a recovery code',
- icon: 'key'
+ id: "recoveryCode",
+ title: "I have a recovery code",
+ icon: "key"
}
];
const getMethods = () => {
return methods.filter(
- m =>
+ (m) =>
m.id === mfaInfo?.primaryMethod ||
m.id === mfaInfo?.secondaryMethod ||
- m.id === 'recoveryCode'
+ m.id === "recoveryCode"
);
};
useEffect(() => {
- if (currentMethod.method === 'sms' || currentMethod.method === 'email') {
+ if (currentMethod.method === "sms" || currentMethod.method === "email") {
onSendCode();
}
}, [currentMethod.method]);
@@ -114,13 +114,13 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
// TODO
setSending(true);
try {
- console.log('sending code', currentMethod.method, mfaInfo.token);
+ console.log("sending code", currentMethod.method, mfaInfo.token);
await db.mfa.sendCode(currentMethod.method, mfaInfo.token);
start(60);
setSending(false);
} catch (e) {
setSending(false);
- ToastEvent.error(e, 'Error sending 2FA Code', 'local');
+ ToastEvent.error(e, "Error sending 2FA Code", "local");
}
};
@@ -128,7 +128,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
<View>
<View
style={{
- alignItems: 'center',
+ alignItems: "center",
paddingHorizontal: currentMethod.method ? 12 : 0
}}
>
@@ -143,29 +143,34 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
/>
<Heading
style={{
- textAlign: 'center'
+ textAlign: "center"
}}
>
{currentMethod.method
- ? 'Two factor authentication'
- : 'Select methods for two-factor authentication'}
+ ? "Two factor authentication"
+ : "Select methods for two-factor authentication"}
</Heading>
<Paragraph
style={{
- width: '80%',
- textAlign: 'center'
+ width: "80%",
+ textAlign: "center"
}}
>
- {codeHelpText[currentMethod.method] || `Select how you would like to recieve the code`}
+ {codeHelpText[currentMethod.method] ||
+ `Select how you would like to recieve the code`}
</Paragraph>
<Seperator />
- {currentMethod.method === 'sms' || currentMethod.method === 'email' ? (
+ {currentMethod.method === "sms" || currentMethod.method === "email" ? (
<Button
onPress={onSendCode}
- type={seconds ? 'gray' : 'transparent'}
- title={sending ? '' : `${seconds ? `Resend code in (${seconds})` : 'Send code'}`}
+ type={seconds ? "gray" : "transparent"}
+ title={
+ sending
+ ? ""
+ : `${seconds ? `Resend code in (${seconds})` : "Send code"}`
+ }
loading={sending}
height={30}
/>
@@ -176,11 +181,13 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
{currentMethod.method ? (
<>
<Input
- placeholder={currentMethod.method === 'recoveryCode' ? 'xxxxxxxx' : 'xxxxxx'}
- maxLength={currentMethod.method === 'recoveryCode' ? 8 : 6}
+ placeholder={
+ currentMethod.method === "recoveryCode" ? "xxxxxxxx" : "xxxxxx"
+ }
+ maxLength={currentMethod.method === "recoveryCode" ? 8 : 6}
fwdRef={inputRef}
textAlign="center"
- onChangeText={value => {
+ onChangeText={(value) => {
code.current = value;
onNext();
}}
@@ -188,22 +195,24 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
inputStyle={{
fontSize: SIZE.lg,
height: 60,
- textAlign: 'center',
+ textAlign: "center",
letterSpacing: 10,
width: null
}}
- keyboardType={currentMethod.method === 'recoveryCode' ? 'default' : 'numeric'}
+ keyboardType={
+ currentMethod.method === "recoveryCode" ? "default" : "numeric"
+ }
containerStyle={{
height: 60,
borderWidth: 0,
//@ts-ignore
width: null,
- minWidth: '50%'
+ minWidth: "50%"
}}
/>
<Seperator />
<Button
- title={loading ? null : 'Next'}
+ title={loading ? null : "Next"}
type="accent"
width={250}
loading={loading}
@@ -223,7 +232,7 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
</>
) : (
<>
- {getMethods().map(item => (
+ {getMethods().map((item) => (
<PressableButton
key={item.title}
onPress={() => {
@@ -236,11 +245,11 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
paddingHorizontal: 12,
paddingVertical: 12,
marginTop: 0,
- flexDirection: 'row',
+ flexDirection: "row",
borderRadius: 0,
- alignItems: 'center',
- width: '100%',
- justifyContent: 'flex-start'
+ alignItems: "center",
+ width: "100%",
+ justifyContent: "flex-start"
}}
>
<IconButton
@@ -271,12 +280,12 @@ const TwoFactorVerification = ({ onMfaLogin, mfaInfo }) => {
};
TwoFactorVerification.present = (onMfaLogin, data, context) => {
- console.log('presenting sheet');
+ console.log("presenting sheet");
presentSheet({
component: <TwoFactorVerification onMfaLogin={onMfaLogin} mfaInfo={data} />,
- context: context || 'two_factor_verify',
+ context: context || "two_factor_verify",
onClose: () => {
- console.log('on close called');
+ console.log("on close called");
onMfaLogin();
},
disableClosing: true
diff --git a/apps/mobile/app/components/container/container-header.js b/apps/mobile/app/components/container/container-header.js
index 8134f2f31..a40fbae99 100644
--- a/apps/mobile/app/components/container/container-header.js
+++ b/apps/mobile/app/components/container/container-header.js
@@ -1,18 +1,18 @@
-import React from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useSelectionStore } from '../../stores/use-selection-store';
+import React from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useSelectionStore } from "../../stores/use-selection-store";
export const ContainerHeader = ({ children }) => {
- const colors = useThemeStore(state => state.colors);
- const selectionMode = useSelectionStore(state => state.selectionMode);
+ const colors = useThemeStore((state) => state.colors);
+ const selectionMode = useSelectionStore((state) => state.selectionMode);
return !selectionMode ? (
<View
style={{
backgroundColor: colors.bg,
- width: '100%',
- overflow: 'hidden'
+ width: "100%",
+ overflow: "hidden"
}}
>
{children}
diff --git a/apps/mobile/app/components/container/floating-button.js b/apps/mobile/app/components/container/floating-button.js
index efebe95c1..7f7cd3377 100644
--- a/apps/mobile/app/components/container/floating-button.js
+++ b/apps/mobile/app/components/container/floating-button.js
@@ -1,25 +1,30 @@
-import React, { useEffect } from 'react';
-import { Keyboard, Platform, View } from 'react-native';
+import React, { useEffect } from "react";
+import { Keyboard, Platform, View } from "react-native";
import Animated, {
Easing,
useAnimatedStyle,
useSharedValue,
withTiming
-} from 'react-native-reanimated';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { notesnook } from '../../../e2e/test.ids';
-import { editorState } from '../../screens/editor/tiptap/utils';
-import { useSelectionStore } from '../../stores/use-selection-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { getElevation, showTooltip, TOOLTIP_POSITIONS } from '../../utils';
-import { normalize, SIZE } from '../../utils/size';
-import { PressableButton } from '../ui/pressable';
+} from "react-native-reanimated";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { notesnook } from "../../../e2e/test.ids";
+import { editorState } from "../../screens/editor/tiptap/utils";
+import { useSelectionStore } from "../../stores/use-selection-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { getElevation, showTooltip, TOOLTIP_POSITIONS } from "../../utils";
+import { normalize, SIZE } from "../../utils/size";
+import { PressableButton } from "../ui/pressable";
-export const FloatingButton = ({ title, onPress, color = 'accent', shouldShow = false }) => {
+export const FloatingButton = ({
+ title,
+ onPress,
+ color = "accent",
+ shouldShow = false
+}) => {
const insets = useSafeAreaInsets();
- const deviceMode = useSettingStore(state => state.deviceMode);
- const selectionMode = useSelectionStore(state => state.selectionMode);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
+ const selectionMode = useSelectionStore((state) => state.selectionMode);
const translate = useSharedValue(0);
const animatedStyle = useAnimatedStyle(() => {
@@ -48,19 +53,19 @@ export const FloatingButton = ({ title, onPress, color = 'accent', shouldShow =
const onKeyboardHide = async () => {
editorState().keyboardState = false;
- if (deviceMode !== 'mobile') return;
+ if (deviceMode !== "mobile") return;
animate(0);
};
const onKeyboardShow = async () => {
editorState().keyboardState = true;
- if (deviceMode !== 'mobile') return;
+ if (deviceMode !== "mobile") return;
animate(150);
};
useEffect(() => {
- let sub1 = Keyboard.addListener('keyboardDidShow', onKeyboardShow);
- let sub2 = Keyboard.addListener('keyboardDidHide', onKeyboardHide);
+ let sub1 = Keyboard.addListener("keyboardDidShow", onKeyboardShow);
+ let sub2 = Keyboard.addListener("keyboardDidHide", onKeyboardHide);
return () => {
sub1?.remove();
sub2?.remove();
@@ -72,13 +77,13 @@ export const FloatingButton = ({ title, onPress, color = 'accent', shouldShow =
iPad: 20
};
- return deviceMode !== 'mobile' && !shouldShow ? null : (
+ return deviceMode !== "mobile" && !shouldShow ? null : (
<Animated.View
style={[
{
- position: 'absolute',
+ position: "absolute",
right: 12,
- bottom: paddings[Platform.isPad ? 'iPad' : Platform.OS],
+ bottom: paddings[Platform.isPad ? "iPad" : Platform.OS],
zIndex: 10
},
animatedStyle
@@ -87,27 +92,27 @@ export const FloatingButton = ({ title, onPress, color = 'accent', shouldShow =
<PressableButton
testID={notesnook.buttons.add}
type="accent"
- accentColor={color || 'accent'}
+ accentColor={color || "accent"}
accentText="light"
customStyle={{
...getElevation(5),
borderRadius: 100
}}
- onLongPress={event => {
+ onLongPress={(event) => {
showTooltip(event, title, TOOLTIP_POSITIONS.LEFT);
}}
onPress={onPress}
>
<View
style={{
- alignItems: 'center',
- justifyContent: 'center',
+ alignItems: "center",
+ justifyContent: "center",
height: normalize(60),
width: normalize(60)
}}
>
<Icon
- name={title === 'Clear all trash' ? 'delete' : 'plus'}
+ name={title === "Clear all trash" ? "delete" : "plus"}
color="white"
size={SIZE.xxl}
/>
diff --git a/apps/mobile/app/components/container/index.js b/apps/mobile/app/components/container/index.js
index 58904d153..4d6f1a595 100644
--- a/apps/mobile/app/components/container/index.js
+++ b/apps/mobile/app/components/container/index.js
@@ -1,16 +1,18 @@
-import React from 'react';
-import { KeyboardAvoidingView, Platform, SafeAreaView } from 'react-native';
-import { useSettingStore } from '../../stores/use-setting-store';
-import useIsFloatingKeyboard from '../../hooks/use-is-floating-keyboard';
-import { Header } from '../header';
-import SelectionHeader from '../selection-header';
+import React from "react";
+import { KeyboardAvoidingView, Platform, SafeAreaView } from "react-native";
+import { useSettingStore } from "../../stores/use-setting-store";
+import useIsFloatingKeyboard from "../../hooks/use-is-floating-keyboard";
+import { Header } from "../header";
+import SelectionHeader from "../selection-header";
export const Container = ({ children }) => {
const floating = useIsFloatingKeyboard();
- const introCompleted = useSettingStore(state => state.settings.introCompleted);
+ const introCompleted = useSettingStore(
+ (state) => state.settings.introCompleted
+ );
return (
<KeyboardAvoidingView
behavior="padding"
- enabled={Platform.OS === 'ios' && !floating}
+ enabled={Platform.OS === "ios" && !floating}
style={{
flex: 1
}}
@@ -18,7 +20,7 @@ export const Container = ({ children }) => {
<SafeAreaView
style={{
flex: 1,
- overflow: 'hidden'
+ overflow: "hidden"
}}
>
{!introCompleted ? null : (
diff --git a/apps/mobile/app/components/delay-layout/default-placeholder.tsx b/apps/mobile/app/components/delay-layout/default-placeholder.tsx
index d780c8dfe..075853388 100644
--- a/apps/mobile/app/components/delay-layout/default-placeholder.tsx
+++ b/apps/mobile/app/components/delay-layout/default-placeholder.tsx
@@ -1,29 +1,31 @@
-import React from 'react';
-import { View } from 'react-native';
-import { useMessageStore } from '../../stores/use-message-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { COLORS_NOTE } from '../../utils/color-scheme';
-import { hexToRGBA } from '../../utils/color-scheme/utils';
+import React from "react";
+import { View } from "react-native";
+import { useMessageStore } from "../../stores/use-message-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { COLORS_NOTE } from "../../utils/color-scheme";
+import { hexToRGBA } from "../../utils/color-scheme/utils";
export const DefaultPlaceholder = ({ color }: { color: string }) => {
- const colors = useThemeStore(state => state.colors);
- const message = useMessageStore(state => state.message);
- const annoucements = useMessageStore(state => state.announcements);
+ const colors = useThemeStore((state) => state.colors);
+ const message = useMessageStore((state) => state.message);
+ const annoucements = useMessageStore((state) => state.announcements);
const hasAnnoucements = annoucements.length > 0;
//@ts-ignore
- const shadeColor = color ? hexToRGBA(COLORS_NOTE[color?.toLowerCase()], 0.15) : colors.shade;
+ const shadeColor = color
+ ? hexToRGBA(COLORS_NOTE[color?.toLowerCase()], 0.15)
+ : colors.shade;
return (
<View
style={{
- width: '100%',
+ width: "100%",
paddingHorizontal: 12
}}
>
{hasAnnoucements ? (
<View
style={{
- width: '100%',
+ width: "100%",
height: 100,
borderRadius: 10,
marginBottom: 20,
@@ -64,12 +66,12 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
{message ? (
<View
style={{
- width: '100%',
+ width: "100%",
height: 60,
borderRadius: 10,
marginBottom: 20,
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
paddingHorizontal: 20
}}
>
@@ -106,15 +108,15 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
<View
style={{
- width: '100%',
+ width: "100%",
height: 30,
backgroundColor: colors.nav,
borderRadius: 10,
marginBottom: 20,
padding: 5,
- justifyContent: 'space-between',
- flexDirection: 'row',
- alignItems: 'center'
+ justifyContent: "space-between",
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<View
@@ -128,7 +130,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
<View
style={{
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
<View
@@ -161,7 +163,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
/>
<View
style={{
- width: '85%',
+ width: "85%",
height: 13,
backgroundColor: colors.nav,
borderRadius: 5,
@@ -171,7 +173,7 @@ export const DefaultPlaceholder = ({ color }: { color: string }) => {
<View
style={{
- flexDirection: 'row',
+ flexDirection: "row",
marginTop: 10
}}
>
diff --git a/apps/mobile/app/components/delay-layout/index.tsx b/apps/mobile/app/components/delay-layout/index.tsx
index 573d7f90d..9c326f175 100644
--- a/apps/mobile/app/components/delay-layout/index.tsx
+++ b/apps/mobile/app/components/delay-layout/index.tsx
@@ -1,15 +1,15 @@
-import React from 'react';
-import { ViewProps } from 'react-native';
-import Animated, { FadeOutUp } from 'react-native-reanimated';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useDelayLayout } from '../../hooks/use-delay-layout';
-import { DefaultPlaceholder } from './default-placeholder';
-import { SettingsPlaceholder } from './settings-placeholder';
+import React from "react";
+import { ViewProps } from "react-native";
+import Animated, { FadeOutUp } from "react-native-reanimated";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useDelayLayout } from "../../hooks/use-delay-layout";
+import { DefaultPlaceholder } from "./default-placeholder";
+import { SettingsPlaceholder } from "./settings-placeholder";
interface IDelayLayoutProps extends ViewProps {
delay?: number;
wait?: boolean;
- type?: 'default' | 'settings';
+ type?: "default" | "settings";
color?: string;
animated?: boolean;
}
@@ -19,10 +19,15 @@ const placeholder = {
settings: SettingsPlaceholder
};
-export default function DelayLayout({ animated = true, ...props }: IDelayLayoutProps) {
- const colors = useThemeStore(state => state.colors);
- const loading = useDelayLayout(!props.delay || props.delay < 300 ? 300 : props.delay);
- const Placeholder = placeholder[props.type || 'default'];
+export default function DelayLayout({
+ animated = true,
+ ...props
+}: IDelayLayoutProps) {
+ const colors = useThemeStore((state) => state.colors);
+ const loading = useDelayLayout(
+ !props.delay || props.delay < 300 ? 300 : props.delay
+ );
+ const Placeholder = placeholder[props.type || "default"];
return loading || props.wait ? (
<Animated.View
diff --git a/apps/mobile/app/components/delay-layout/settings-placeholder.tsx b/apps/mobile/app/components/delay-layout/settings-placeholder.tsx
index 7efcc5c1c..6e7e8ea97 100644
--- a/apps/mobile/app/components/delay-layout/settings-placeholder.tsx
+++ b/apps/mobile/app/components/delay-layout/settings-placeholder.tsx
@@ -1,9 +1,9 @@
-import React from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
+import React from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
export const SettingsPlaceholder = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<View>
@@ -19,12 +19,12 @@ export const SettingsPlaceholder = () => {
/>
<View
style={{
- width: '100%',
+ width: "100%",
height: 60,
borderRadius: 10,
marginBottom: 20,
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
paddingHorizontal: 16
}}
>
@@ -60,14 +60,14 @@ export const SettingsPlaceholder = () => {
<View
style={{
- width: '100%',
+ width: "100%",
height: 60,
borderRadius: 10,
marginBottom: 20,
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
paddingHorizontal: 16,
- justifyContent: 'space-between'
+ justifyContent: "space-between"
}}
>
<View
@@ -106,8 +106,8 @@ export const SettingsPlaceholder = () => {
backgroundColor: colors.nav,
borderRadius: 100,
marginLeft: 15,
- alignItems: 'flex-end',
- justifyContent: 'center',
+ alignItems: "flex-end",
+ justifyContent: "center",
paddingHorizontal: 4
}}
>
diff --git a/apps/mobile/app/components/dialog-provider/index.js b/apps/mobile/app/components/dialog-provider/index.js
index 2bb645eaf..031788ac6 100644
--- a/apps/mobile/app/components/dialog-provider/index.js
+++ b/apps/mobile/app/components/dialog-provider/index.js
@@ -1,33 +1,33 @@
-import React from 'react';
-import { useNoteStore } from '../../stores/use-notes-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { AnnouncementDialog } from '../announcements';
-import { AttachmentDialog } from '../attachments';
-import Auth from '../auth';
-import AuthModal from '../auth/auth-modal';
-import { SessionExpired } from '../auth/session-expired';
-import { Dialog } from '../dialog';
-import { AddTopicDialog } from '../dialogs/add-topic';
-import ResultDialog from '../dialogs/result';
-import { VaultDialog } from '../dialogs/vault';
-import ImagePreview from '../image-preview';
-import MergeConflicts from '../merge-conflicts';
-import PremiumDialog from '../premium';
-import { Expiring } from '../premium/expiring';
-import SheetProvider from '../sheet-provider';
-import { AddNotebookSheet } from '../sheets/add-notebook';
-import AddToNotebookSheet from '../sheets/add-to';
-import ExportNotesSheet from '../sheets/export-notes';
-import ManageTagsSheet from '../sheets/manage-tags';
-import PublishNoteSheet from '../sheets/publish-note';
-import RateAppSheet from '../sheets/rate-app';
-import RecoveryKeySheet from '../sheets/recovery-key';
-import RestoreDataSheet from '../sheets/restore-data';
+import React from "react";
+import { useNoteStore } from "../../stores/use-notes-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { AnnouncementDialog } from "../announcements";
+import { AttachmentDialog } from "../attachments";
+import Auth from "../auth";
+import AuthModal from "../auth/auth-modal";
+import { SessionExpired } from "../auth/session-expired";
+import { Dialog } from "../dialog";
+import { AddTopicDialog } from "../dialogs/add-topic";
+import ResultDialog from "../dialogs/result";
+import { VaultDialog } from "../dialogs/vault";
+import ImagePreview from "../image-preview";
+import MergeConflicts from "../merge-conflicts";
+import PremiumDialog from "../premium";
+import { Expiring } from "../premium/expiring";
+import SheetProvider from "../sheet-provider";
+import { AddNotebookSheet } from "../sheets/add-notebook";
+import AddToNotebookSheet from "../sheets/add-to";
+import ExportNotesSheet from "../sheets/export-notes";
+import ManageTagsSheet from "../sheets/manage-tags";
+import PublishNoteSheet from "../sheets/publish-note";
+import RateAppSheet from "../sheets/rate-app";
+import RecoveryKeySheet from "../sheets/recovery-key";
+import RestoreDataSheet from "../sheets/restore-data";
const DialogProvider = React.memo(
() => {
- const colors = useThemeStore(state => state.colors);
- const loading = useNoteStore(state => state.loading);
+ const colors = useThemeStore((state) => state.colors);
+ const loading = useNoteStore((state) => state.loading);
return (
<>
diff --git a/apps/mobile/app/components/dialog-provider/recievers.js b/apps/mobile/app/components/dialog-provider/recievers.js
index f1f439563..54da9358d 100644
--- a/apps/mobile/app/components/dialog-provider/recievers.js
+++ b/apps/mobile/app/components/dialog-provider/recievers.js
@@ -1,4 +1,4 @@
-import { eSendEvent } from '../../services/event-manager';
+import { eSendEvent } from "../../services/event-manager";
import {
eCloseActionSheet,
eCloseAddNotebookDialog,
@@ -8,7 +8,7 @@ import {
eOpenAddNotebookDialog,
eOpenAddTopicDialog,
eOpenMoveNoteDialog
-} from '../../utils/events';
+} from "../../utils/events";
export const ActionSheetEvent = (item, buttons) => {
eSendEvent(eOpenActionSheet, {
@@ -27,15 +27,15 @@ export const moveNoteHideEvent = () => {
eSendEvent(eCloseMoveNoteDialog);
};
-export const AddNotebookEvent = notebook => {
+export const AddNotebookEvent = (notebook) => {
eSendEvent(eOpenAddNotebookDialog, notebook);
};
-export const HideAddNotebookEvent = notebook => {
+export const HideAddNotebookEvent = (notebook) => {
eSendEvent(eCloseAddNotebookDialog, notebook);
};
-export const AddTopicEvent = topic => {
+export const AddTopicEvent = (topic) => {
eSendEvent(eOpenAddTopicDialog, topic);
};
-export const HideAddTopicEvent = notebook => {
+export const HideAddTopicEvent = (notebook) => {
eSendEvent(eCloseAddTopicDialog, notebook);
};
diff --git a/apps/mobile/app/components/dialog/base-dialog.js b/apps/mobile/app/components/dialog/base-dialog.js
index ac6ae3a4f..bbe57b770 100644
--- a/apps/mobile/app/components/dialog/base-dialog.js
+++ b/apps/mobile/app/components/dialog/base-dialog.js
@@ -1,4 +1,4 @@
-import React, { useEffect } from 'react';
+import React, { useEffect } from "react";
import {
KeyboardAvoidingView,
Modal,
@@ -7,17 +7,17 @@ import {
StyleSheet,
TouchableOpacity,
View
-} from 'react-native';
-import { useSettingStore } from '../../stores/use-setting-store';
-import useIsFloatingKeyboard from '../../hooks/use-is-floating-keyboard';
-import { BouncingView } from '../ui/transitions/bouncing-view';
+} from "react-native";
+import { useSettingStore } from "../../stores/use-setting-store";
+import useIsFloatingKeyboard from "../../hooks/use-is-floating-keyboard";
+import { BouncingView } from "../ui/transitions/bouncing-view";
const BaseDialog = ({
visible,
onRequestClose,
children,
onShow,
- animation = 'fade',
+ animation = "fade",
premium,
statusBarTranslucent = true,
transparent,
@@ -46,11 +46,11 @@ const BaseDialog = ({
animated
statusBarTranslucent={statusBarTranslucent}
supportedOrientations={[
- 'portrait',
- 'portrait-upside-down',
- 'landscape',
- 'landscape-left',
- 'landscape-right'
+ "portrait",
+ "portrait-upside-down",
+ "landscape",
+ "landscape-left",
+ "landscape-right"
]}
onShow={() => {
if (onShow) {
@@ -67,10 +67,17 @@ const BaseDialog = ({
>
<Wrapper
style={{
- backgroundColor: background ? background : transparent ? 'transparent' : 'rgba(0,0,0,0.3)'
+ backgroundColor: background
+ ? background
+ : transparent
+ ? "transparent"
+ : "rgba(0,0,0,0.3)"
}}
>
- <KeyboardAvoidingView enabled={!floating && Platform.OS === 'ios'} behavior="padding">
+ <KeyboardAvoidingView
+ enabled={!floating && Platform.OS === "ios"}
+ behavior="padding"
+ >
<BouncingView
duration={400}
animated={animated}
@@ -78,7 +85,11 @@ const BaseDialog = ({
style={[
styles.backdrop,
{
- justifyContent: centered ? 'center' : bottom ? 'flex-end' : 'flex-start'
+ justifyContent: centered
+ ? "center"
+ : bottom
+ ? "flex-end"
+ : "flex-start"
}
]}
>
@@ -97,15 +108,15 @@ const BaseDialog = ({
const styles = StyleSheet.create({
backdrop: {
- width: '100%',
- height: '100%',
- justifyContent: 'center',
- alignItems: 'center'
+ width: "100%",
+ height: "100%",
+ justifyContent: "center",
+ alignItems: "center"
},
overlayButton: {
- width: '100%',
- height: '100%',
- position: 'absolute'
+ width: "100%",
+ height: "100%",
+ position: "absolute"
}
});
diff --git a/apps/mobile/app/components/dialog/dialog-buttons.js b/apps/mobile/app/components/dialog/dialog-buttons.js
index 14489cc6e..12019087e 100644
--- a/apps/mobile/app/components/dialog/dialog-buttons.js
+++ b/apps/mobile/app/components/dialog/dialog-buttons.js
@@ -1,22 +1,22 @@
-import React from 'react';
-import { ActivityIndicator, StyleSheet, View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import Paragraph from '../ui/typography/paragraph';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { notesnook } from '../../../e2e/test.ids';
+import React from "react";
+import { ActivityIndicator, StyleSheet, View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import Paragraph from "../ui/typography/paragraph";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { notesnook } from "../../../e2e/test.ids";
const DialogButtons = ({
onPressPositive,
onPressNegative,
positiveTitle,
- negativeTitle = 'Cancel',
+ negativeTitle = "Cancel",
loading,
doneText,
positiveType
}) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<View
@@ -36,12 +36,16 @@ const DialogButtons = ({
) : doneText ? (
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
- <Icon color={colors.accent} name="check-circle-outline" size={SIZE.md} />
- <Paragraph color={colors.accent}>{' ' + doneText}</Paragraph>
+ <Icon
+ color={colors.accent}
+ name="check-circle-outline"
+ size={SIZE.md}
+ />
+ <Paragraph color={colors.accent}>{" " + doneText}</Paragraph>
</View>
) : (
<View />
@@ -49,8 +53,8 @@ const DialogButtons = ({
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<Button
@@ -70,7 +74,7 @@ const DialogButtons = ({
marginLeft: 10
}}
bold
- type={positiveType || 'transparent'}
+ type={positiveType || "transparent"}
title={positiveTitle}
/>
) : null}
@@ -83,9 +87,9 @@ export default DialogButtons;
const styles = StyleSheet.create({
container: {
- justifyContent: 'space-between',
- alignItems: 'center',
- flexDirection: 'row',
+ justifyContent: "space-between",
+ alignItems: "center",
+ flexDirection: "row",
marginTop: 10
}
});
diff --git a/apps/mobile/app/components/dialog/dialog-container.js b/apps/mobile/app/components/dialog/dialog-container.js
index d1c5a5e6c..e3e3ccd8b 100644
--- a/apps/mobile/app/components/dialog/dialog-container.js
+++ b/apps/mobile/app/components/dialog/dialog-container.js
@@ -1,18 +1,18 @@
-import React from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { DDS } from '../../services/device-detection';
-import { getElevation } from '../../utils';
+import React from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { DDS } from "../../services/device-detection";
+import { getElevation } from "../../utils";
const DialogContainer = ({ width, height, ...restProps }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<View
{...restProps}
style={{
...getElevation(5),
- width: width || DDS.isTab ? 500 : '85%',
+ width: width || DDS.isTab ? 500 : "85%",
maxHeight: height || 450,
borderRadius: 10,
backgroundColor: colors.bg,
diff --git a/apps/mobile/app/components/dialog/dialog-header.tsx b/apps/mobile/app/components/dialog/dialog-header.tsx
index da2613ad3..1ccf35b91 100644
--- a/apps/mobile/app/components/dialog/dialog-header.tsx
+++ b/apps/mobile/app/components/dialog/dialog-header.tsx
@@ -1,12 +1,12 @@
-import React from 'react';
-import { Text } from 'react-native';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import { PressableButtonProps } from '../ui/pressable';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React from "react";
+import { Text } from "react-native";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import { PressableButtonProps } from "../ui/pressable";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
type DialogHeaderProps = {
icon?: string;
@@ -16,7 +16,7 @@ type DialogHeaderProps = {
onPress?: () => void;
loading?: boolean;
title?: string;
- type?: PressableButtonProps['type'];
+ type?: PressableButtonProps["type"];
};
paragraphColor?: string;
padding?: number;
@@ -34,33 +34,39 @@ const DialogHeader = ({
centered,
titlePart
}: DialogHeaderProps) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'space-between',
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "space-between",
minHeight: 50,
paddingHorizontal: padding
}}
>
<View
style={{
- width: '100%'
+ width: "100%"
}}
>
<View
style={{
- flexDirection: 'row',
- justifyContent: centered ? 'center' : 'space-between',
- alignItems: 'center'
+ flexDirection: "row",
+ justifyContent: centered ? "center" : "space-between",
+ alignItems: "center"
}}
>
- <Heading style={{ textAlign: centered ? 'center' : 'left' }} size={SIZE.lg}>
- {title} {titlePart ? <Text style={{ color: colors.accent }}>{titlePart}</Text> : null}
+ <Heading
+ style={{ textAlign: centered ? "center" : "left" }}
+ size={SIZE.lg}
+ >
+ {title}{" "}
+ {titlePart ? (
+ <Text style={{ color: colors.accent }}>{titlePart}</Text>
+ ) : null}
</Heading>
{button ? (
@@ -73,7 +79,7 @@ const DialogHeader = ({
loading={button.loading}
fontSize={13}
title={button.title}
- type={button.type || 'grayBg'}
+ type={button.type || "grayBg"}
height={25}
/>
) : null}
@@ -82,9 +88,9 @@ const DialogHeader = ({
{paragraph ? (
<Paragraph
style={{
- textAlign: centered ? 'center' : 'left',
- maxWidth: centered ? '90%' : '100%',
- alignSelf: centered ? 'center' : 'flex-start'
+ textAlign: centered ? "center" : "left",
+ maxWidth: centered ? "90%" : "100%",
+ alignSelf: centered ? "center" : "flex-start"
}}
color={paragraphColor || colors.icon}
>
diff --git a/apps/mobile/app/components/dialog/functions.ts b/apps/mobile/app/components/dialog/functions.ts
index 3724cfdc2..815403862 100644
--- a/apps/mobile/app/components/dialog/functions.ts
+++ b/apps/mobile/app/components/dialog/functions.ts
@@ -1,5 +1,5 @@
-import { eSendEvent } from '../../services/event-manager';
-import { eCloseSimpleDialog, eOpenSimpleDialog } from '../../utils/events';
+import { eSendEvent } from "../../services/event-manager";
+import { eCloseSimpleDialog, eOpenSimpleDialog } from "../../utils/events";
type DialogInfo = {
title?: string;
@@ -9,20 +9,20 @@ type DialogInfo = {
positivePress?: (value: any) => void;
onClose?: () => void;
positiveType?:
- | 'transparent'
- | 'gray'
- | 'grayBg'
- | 'accent'
- | 'inverted'
- | 'shade'
- | 'error'
- | 'errorShade';
+ | "transparent"
+ | "gray"
+ | "grayBg"
+ | "accent"
+ | "inverted"
+ | "shade"
+ | "error"
+ | "errorShade";
icon?: string;
paragraphColor: string;
input: boolean;
inputPlaceholder: string;
defaultValue: string;
- context: 'global' | 'local';
+ context: "global" | "local";
};
export function presentDialog(data: Partial<DialogInfo>): void {
diff --git a/apps/mobile/app/components/dialog/index.js b/apps/mobile/app/components/dialog/index.js
index d28479906..f8f3ca0c3 100644
--- a/apps/mobile/app/components/dialog/index.js
+++ b/apps/mobile/app/components/dialog/index.js
@@ -1,36 +1,39 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { DDS } from '../../services/device-detection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import { getElevation } from '../../utils';
-import { eCloseSimpleDialog, eOpenSimpleDialog } from '../../utils/events';
-import { sleep } from '../../utils/time';
-import Input from '../ui/input';
-import Seperator from '../ui/seperator';
-import { Toast } from '../toast';
-import BaseDialog from './base-dialog';
-import DialogButtons from './dialog-buttons';
-import DialogHeader from './dialog-header';
+import React, { useEffect, useRef, useState } from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { DDS } from "../../services/device-detection";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import { getElevation } from "../../utils";
+import { eCloseSimpleDialog, eOpenSimpleDialog } from "../../utils/events";
+import { sleep } from "../../utils/time";
+import Input from "../ui/input";
+import Seperator from "../ui/seperator";
+import { Toast } from "../toast";
+import BaseDialog from "./base-dialog";
+import DialogButtons from "./dialog-buttons";
+import DialogHeader from "./dialog-header";
-export const Dialog = ({ context = 'global' }) => {
- const colors = useThemeStore(state => state.colors);
+export const Dialog = ({ context = "global" }) => {
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [inputValue, setInputValue] = useState(null);
const inputRef = useRef();
const [dialogInfo, setDialogInfo] = useState({
- title: '',
- paragraph: '',
- positiveText: 'Done',
- negativeText: 'Cancel',
+ title: "",
+ paragraph: "",
+ positiveText: "Done",
+ negativeText: "Cancel",
positivePress: () => {},
onClose: () => {},
- positiveType: 'transparent',
+ positiveType: "transparent",
icon: null,
paragraphColor: colors.pri,
input: false,
- inputPlaceholder: 'Enter some text',
- defaultValue: '',
+ inputPlaceholder: "Enter some text",
+ defaultValue: "",
disableBackdropClosing: false
});
@@ -47,7 +50,9 @@ export const Dialog = ({ context = 'global' }) => {
const onPressPositive = async () => {
if (dialogInfo.positivePress) {
inputRef.current?.blur();
- let result = await dialogInfo.positivePress(inputValue || dialogInfo.defaultValue);
+ let result = await dialogInfo.positivePress(
+ inputValue || dialogInfo.defaultValue
+ );
if (result === false) {
return;
}
@@ -56,8 +61,8 @@ export const Dialog = ({ context = 'global' }) => {
hide();
};
- const show = data => {
- if (!data.context) data.context = 'global';
+ const show = (data) => {
+ if (!data.context) data.context = "global";
if (data.context !== context) return;
setDialogInfo(data);
setVisible(true);
@@ -78,7 +83,7 @@ export const Dialog = ({ context = 'global' }) => {
const style = {
...getElevation(5),
- width: DDS.isTab ? 400 : '85%',
+ width: DDS.isTab ? 400 : "85%",
maxHeight: 450,
borderRadius: 5,
backgroundColor: colors.bg,
@@ -121,7 +126,7 @@ export const Dialog = ({ context = 'global' }) => {
<Input
fwdRef={inputRef}
autoCapitalize="none"
- onChangeText={value => {
+ onChangeText={(value) => {
setInputValue(value);
}}
testID="input-value"
diff --git a/apps/mobile/app/components/dialogs/add-topic/index.js b/apps/mobile/app/components/dialogs/add-topic/index.js
index d344af62a..76d2df73d 100644
--- a/apps/mobile/app/components/dialogs/add-topic/index.js
+++ b/apps/mobile/app/components/dialogs/add-topic/index.js
@@ -1,19 +1,30 @@
-import React, { createRef } from 'react';
-import { Keyboard, LayoutAnimation, UIManager, View } from 'react-native';
-import { Transition, Transitioning, TransitioningView } from 'react-native-reanimated';
-import { useMenuStore } from '../../../stores/use-menu-store';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { db } from '../../../common/database';
-import { eCloseAddTopicDialog, eOpenAddTopicDialog } from '../../../utils/events';
-import { sleep } from '../../../utils/time';
-import BaseDialog from '../../dialog/base-dialog';
-import DialogButtons from '../../dialog/dialog-buttons';
-import DialogContainer from '../../dialog/dialog-container';
-import DialogHeader from '../../dialog/dialog-header';
-import Input from '../../ui/input';
-import Seperator from '../../ui/seperator';
-import { Toast } from '../../toast';
+import React, { createRef } from "react";
+import { Keyboard, LayoutAnimation, UIManager, View } from "react-native";
+import {
+ Transition,
+ Transitioning,
+ TransitioningView
+} from "react-native-reanimated";
+import { useMenuStore } from "../../../stores/use-menu-store";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent,
+ ToastEvent
+} from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { db } from "../../../common/database";
+import {
+ eCloseAddTopicDialog,
+ eOpenAddTopicDialog
+} from "../../../utils/events";
+import { sleep } from "../../../utils/time";
+import BaseDialog from "../../dialog/base-dialog";
+import DialogButtons from "../../dialog/dialog-buttons";
+import DialogContainer from "../../dialog/dialog-container";
+import DialogHeader from "../../dialog/dialog-header";
+import Input from "../../ui/input";
+import Seperator from "../../ui/seperator";
+import { Toast } from "../../toast";
export class AddTopicDialog extends React.Component {
constructor(props) {
@@ -34,11 +45,11 @@ export class AddTopicDialog extends React.Component {
addNewTopic = async () => {
try {
this.setState({ loading: true });
- if (!this.title || this.title?.trim() === '') {
+ if (!this.title || this.title?.trim() === "") {
ToastEvent.show({
- heading: 'Topic title is required',
- type: 'error',
- context: 'local'
+ heading: "Topic title is required",
+ type: "error",
+ context: "local"
});
this.setState({ loading: false });
return;
@@ -54,7 +65,7 @@ export class AddTopicDialog extends React.Component {
}
this.setState({ loading: false });
this.close();
- Navigation.queueRoutesForUpdate('Notebooks', 'Notebook', 'TopicNotes');
+ Navigation.queueRoutesForUpdate("Notebooks", "Notebook", "TopicNotes");
useMenuStore.getState().setMenuPins();
} catch (e) {}
};
@@ -116,9 +127,11 @@ export class AddTopicDialog extends React.Component {
<DialogContainer>
<DialogHeader
icon="book-outline"
- title={this.toEdit ? 'Edit topic' : 'New topic'}
+ title={this.toEdit ? "Edit topic" : "New topic"}
paragraph={
- this.toEdit ? 'Edit title of the topic' : 'Add a new topic in ' + this.notebook.title
+ this.toEdit
+ ? "Edit title of the topic"
+ : "Add a new topic in " + this.notebook.title
}
padding={12}
/>
@@ -132,7 +145,7 @@ export class AddTopicDialog extends React.Component {
<Input
fwdRef={this.titleRef}
testID="input-title"
- onChangeText={value => {
+ onChangeText={(value) => {
this.title = value;
}}
blurOnSubmit={false}
@@ -144,7 +157,7 @@ export class AddTopicDialog extends React.Component {
</View>
<DialogButtons
- positiveTitle={this.toEdit ? 'Save' : 'Add'}
+ positiveTitle={this.toEdit ? "Save" : "Add"}
onPressNegative={() => this.close()}
onPressPositive={() => this.addNewTopic()}
loading={this.state.loading}
diff --git a/apps/mobile/app/components/dialogs/jump-to-section/index.js b/apps/mobile/app/components/dialogs/jump-to-section/index.js
index 4def3def1..1463a8591 100644
--- a/apps/mobile/app/components/dialogs/jump-to-section/index.js
+++ b/apps/mobile/app/components/dialogs/jump-to-section/index.js
@@ -1,26 +1,35 @@
-import React, { useEffect, useState } from 'react';
-import { ScrollView, View } from 'react-native';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { useMessageStore } from '../../../stores/use-message-store';
-import { DDS } from '../../../services/device-detection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
-import { getElevation } from '../../../utils';
-import { eCloseJumpToDialog, eOpenJumpToDialog, eScrollEvent } from '../../../utils/events';
-import { SIZE } from '../../../utils/size';
-import BaseDialog from '../../dialog/base-dialog';
-import { PressableButton } from '../../ui/pressable';
-import Paragraph from '../../ui/typography/paragraph';
+import React, { useEffect, useState } from "react";
+import { ScrollView, View } from "react-native";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { useMessageStore } from "../../../stores/use-message-store";
+import { DDS } from "../../../services/device-detection";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../../services/event-manager";
+import { getElevation } from "../../../utils";
+import {
+ eCloseJumpToDialog,
+ eOpenJumpToDialog,
+ eScrollEvent
+} from "../../../utils/events";
+import { SIZE } from "../../../utils/size";
+import BaseDialog from "../../dialog/base-dialog";
+import { PressableButton } from "../../ui/pressable";
+import Paragraph from "../../ui/typography/paragraph";
const offsets = [];
let timeout = null;
const JumpToSectionDialog = ({ scrollRef, data, type, screen }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const notes = data;
const [visible, setVisible] = useState(false);
const [currentIndex, setCurrentIndex] = useState(null);
const onPress = (item, index) => {
- let ind = notes.findIndex(i => i.title === item.title && i.type === 'header');
+ let ind = notes.findIndex(
+ (i) => i.title === item.title && i.type === "header"
+ );
console.log(scrollRef.current);
scrollRef.current?.scrollToIndex({
index: ind,
@@ -41,7 +50,7 @@ const JumpToSectionDialog = ({ scrollRef, data, type, screen }) => {
};
}, []);
- const onScroll = data => {
+ const onScroll = (data) => {
let y = data.y;
if (timeout) {
clearTimeout(timeout);
@@ -53,7 +62,7 @@ const JumpToSectionDialog = ({ scrollRef, data, type, screen }) => {
}, 200);
};
- const open = _type => {
+ const open = (_type) => {
if (_type !== type) return;
setVisible(true);
};
@@ -68,10 +77,12 @@ const JumpToSectionDialog = ({ scrollRef, data, type, screen }) => {
const loadOffsets = () => {
notes
- .filter(i => i.type === 'header')
+ .filter((i) => i.type === "header")
.map((item, index) => {
let offset = 35 * index;
- let ind = notes.findIndex(i => i.title === item.title && i.type === 'header');
+ let ind = notes.findIndex(
+ (i) => i.title === item.title && i.type === "header"
+ );
let messageState = useMessageStore.getState().message;
let msgOffset = messageState?.visible ? 60 : 10;
ind = ind + 1;
@@ -92,41 +103,41 @@ const JumpToSectionDialog = ({ scrollRef, data, type, screen }) => {
<View
style={{
...getElevation(5),
- width: DDS.isTab ? 500 : '85%',
+ width: DDS.isTab ? 500 : "85%",
backgroundColor: colors.bg,
zIndex: 100,
bottom: 20,
- maxHeight: '65%',
+ maxHeight: "65%",
borderRadius: 10,
- alignSelf: 'center',
+ alignSelf: "center",
padding: 10,
paddingTop: 30
}}
>
<ScrollView
style={{
- maxHeight: '100%'
+ maxHeight: "100%"
}}
>
<View
style={{
- flexDirection: 'row',
- flexWrap: 'wrap',
- alignSelf: 'center',
- justifyContent: 'center',
+ flexDirection: "row",
+ flexWrap: "wrap",
+ alignSelf: "center",
+ justifyContent: "center",
paddingBottom: 20
}}
>
{notes
- .filter(i => i.type === 'header')
+ .filter((i) => i.type === "header")
.map((item, index) => {
return item.title ? (
<PressableButton
key={item.title}
onPress={() => onPress(item, index)}
- type={currentIndex === index ? 'accent' : 'transparent'}
+ type={currentIndex === index ? "accent" : "transparent"}
customStyle={{
- minWidth: '20%',
+ minWidth: "20%",
width: null,
paddingHorizontal: 12,
margin: 5,
@@ -137,9 +148,11 @@ const JumpToSectionDialog = ({ scrollRef, data, type, screen }) => {
>
<Paragraph
size={SIZE.sm}
- color={currentIndex === index ? colors.light : colors.accent}
+ color={
+ currentIndex === index ? colors.light : colors.accent
+ }
style={{
- textAlign: 'center'
+ textAlign: "center"
}}
>
{item.title}
diff --git a/apps/mobile/app/components/dialogs/result/index.js b/apps/mobile/app/components/dialogs/result/index.js
index 96071b787..aa8d0cb68 100644
--- a/apps/mobile/app/components/dialogs/result/index.js
+++ b/apps/mobile/app/components/dialogs/result/index.js
@@ -1,25 +1,29 @@
-import React, { useEffect, useState } from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { DDS } from '../../../services/device-detection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
-import { getElevation } from '../../../utils';
-import { eCloseResultDialog, eOpenResultDialog } from '../../../utils/events';
-import { SIZE } from '../../../utils/size';
-import { Button } from '../../ui/button';
-import BaseDialog from '../../dialog/base-dialog';
-import Seperator from '../../ui/seperator';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
-import { ProFeatures } from './pro-features';
+import React, { useEffect, useState } from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { DDS } from "../../../services/device-detection";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../../services/event-manager";
+import { getElevation } from "../../../utils";
+import { eCloseResultDialog, eOpenResultDialog } from "../../../utils/events";
+import { SIZE } from "../../../utils/size";
+import { Button } from "../../ui/button";
+import BaseDialog from "../../dialog/base-dialog";
+import Seperator from "../../ui/seperator";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
+import { ProFeatures } from "./pro-features";
const ResultDialog = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [dialogData, setDialogData] = useState({
- title: 'Thank you for signing up!',
- paragraph: 'Try out all features of Notesnook free for 7 days. No limitations. No commitments.',
- button: 'Start taking notes'
+ title: "Thank you for signing up!",
+ paragraph:
+ "Try out all features of Notesnook free for 7 days. No limitations. No commitments.",
+ button: "Start taking notes"
});
useEffect(() => {
eSubscribeEvent(eOpenResultDialog, open);
@@ -30,7 +34,7 @@ const ResultDialog = () => {
};
}, []);
- const open = data => {
+ const open = (data) => {
if (data) {
setDialogData(data);
}
@@ -46,23 +50,23 @@ const ResultDialog = () => {
<View
style={{
...getElevation(5),
- width: DDS.isTab ? 350 : '85%',
+ width: DDS.isTab ? 350 : "85%",
maxHeight: 500,
borderRadius: 10,
backgroundColor: colors.bg,
paddingTop: 20,
- justifyContent: 'center',
- alignItems: 'center'
+ justifyContent: "center",
+ alignItems: "center"
}}
>
<Heading
size={SIZE.lg}
textBreakStrategy="balanced"
style={{
- alignSelf: 'center',
- textAlign: 'center',
+ alignSelf: "center",
+ textAlign: "center",
marginTop: 10,
- maxWidth: '100%',
+ maxWidth: "100%",
marginBottom: 10,
paddingHorizontal: 12
}}
@@ -74,9 +78,9 @@ const ResultDialog = () => {
color={colors.icon}
size={SIZE.md}
style={{
- alignSelf: 'center',
- textAlign: 'center',
- maxWidth: '80%',
+ alignSelf: "center",
+ textAlign: "center",
+ maxWidth: "80%",
lineHeight: SIZE.sm + 5
}}
>
@@ -88,8 +92,8 @@ const ResultDialog = () => {
<View
style={{
paddingHorizontal: 12,
- alignItems: 'center',
- width: '100%'
+ alignItems: "center",
+ width: "100%"
}}
>
<ProFeatures count={4} />
@@ -99,7 +103,7 @@ const ResultDialog = () => {
<View
style={{
backgroundColor: colors.nav,
- width: '100%',
+ width: "100%",
borderBottomRightRadius: 10,
borderBottomLeftRadius: 10,
paddingVertical: 10
diff --git a/apps/mobile/app/components/dialogs/result/pro-features.js b/apps/mobile/app/components/dialogs/result/pro-features.js
index 2450d96f1..d1e828ead 100644
--- a/apps/mobile/app/components/dialogs/result/pro-features.js
+++ b/apps/mobile/app/components/dialogs/result/pro-features.js
@@ -1,58 +1,63 @@
-import React from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { eSendEvent } from '../../../services/event-manager';
+import React from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { eSendEvent } from "../../../services/event-manager";
import {
eCloseProgressDialog,
eCloseResultDialog,
eOpenPremiumDialog
-} from '../../../utils/events';
-import { SIZE } from '../../../utils/size';
-import { sleep } from '../../../utils/time';
-import Paragraph from '../../ui/typography/paragraph';
+} from "../../../utils/events";
+import { SIZE } from "../../../utils/size";
+import { sleep } from "../../../utils/time";
+import Paragraph from "../../ui/typography/paragraph";
export const ProFeatures = ({ count = 6 }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<>
{[
{
- content: 'Unlock unlimited notebooks, tags, colors. Organize like a pro'
+ content:
+ "Unlock unlimited notebooks, tags, colors. Organize like a pro"
},
{
- content: 'Attach files upto 500MB, upload 4K images with unlimited storage'
+ content:
+ "Attach files upto 500MB, upload 4K images with unlimited storage"
},
{
- content: 'Instantly sync to unlimited devices'
+ content: "Instantly sync to unlimited devices"
},
{
- content: 'A private vault to keep everything imporant always locked'
+ content: "A private vault to keep everything imporant always locked"
},
{
- content: 'Rich note editing experience with markdown, tables, checklists and more'
+ content:
+ "Rich note editing experience with markdown, tables, checklists and more"
},
{
- content: 'Export your notes in Pdf, markdown and html formats'
+ content: "Export your notes in Pdf, markdown and html formats"
}
]
.slice(0, count)
- .map(item => (
+ .map((item) => (
<View
key={item.content}
style={{
- flexDirection: 'row',
- width: '100%',
+ flexDirection: "row",
+ width: "100%",
height: 40,
paddingHorizontal: 0,
marginBottom: 10,
- alignItems: 'center',
+ alignItems: "center",
borderRadius: 5,
- justifyContent: 'flex-start'
+ justifyContent: "flex-start"
}}
>
<Icon size={SIZE.lg} color={colors.accent} name="check" />
- <Paragraph style={{ marginLeft: 5, flexShrink: 1 }}>{item.content}</Paragraph>
+ <Paragraph style={{ marginLeft: 5, flexShrink: 1 }}>
+ {item.content}
+ </Paragraph>
</View>
))}
<Paragraph
@@ -64,7 +69,7 @@ export const ProFeatures = ({ count = 6 }) => {
}}
size={SIZE.xs + 1}
style={{
- textDecorationLine: 'underline',
+ textDecorationLine: "underline",
color: colors.icon
}}
>
diff --git a/apps/mobile/app/components/dialogs/vault/index.js b/apps/mobile/app/components/dialogs/vault/index.js
index f064358a8..f70703190 100644
--- a/apps/mobile/app/components/dialogs/vault/index.js
+++ b/apps/mobile/app/components/dialogs/vault/index.js
@@ -1,39 +1,39 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import React, { Component, createRef } from 'react';
-import { InteractionManager, View } from 'react-native';
-import Share from 'react-native-share';
-import { notesnook } from '../../../../e2e/test.ids';
-import { editorController } from '../../../screens/editor/tiptap/utils';
-import BiometricService from '../../../services/biometrics';
-import { DDS } from '../../../services/device-detection';
+import Clipboard from "@react-native-clipboard/clipboard";
+import React, { Component, createRef } from "react";
+import { InteractionManager, View } from "react-native";
+import Share from "react-native-share";
+import { notesnook } from "../../../../e2e/test.ids";
+import { editorController } from "../../../screens/editor/tiptap/utils";
+import BiometricService from "../../../services/biometrics";
+import { DDS } from "../../../services/device-detection";
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent
-} from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import SearchService from '../../../services/search';
-import { getElevation, toTXT } from '../../../utils';
-import { db } from '../../../common/database';
+} from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import SearchService from "../../../services/search";
+import { getElevation, toTXT } from "../../../utils";
+import { db } from "../../../common/database";
import {
eClearEditor,
eCloseActionSheet,
eCloseVaultDialog,
eOnLoadNote,
eOpenVaultDialog
-} from '../../../utils/events';
-import { deleteItems } from '../../../utils/functions';
-import { tabBarRef } from '../../../utils/global-refs';
-import { sleep } from '../../../utils/time';
-import BaseDialog from '../../dialog/base-dialog';
-import DialogButtons from '../../dialog/dialog-buttons';
-import DialogHeader from '../../dialog/dialog-header';
-import { Toast } from '../../toast';
-import { Button } from '../../ui/button';
-import Input from '../../ui/input';
-import Seperator from '../../ui/seperator';
-import Paragraph from '../../ui/typography/paragraph';
+} from "../../../utils/events";
+import { deleteItems } from "../../../utils/functions";
+import { tabBarRef } from "../../../utils/global-refs";
+import { sleep } from "../../../utils/time";
+import BaseDialog from "../../dialog/base-dialog";
+import DialogButtons from "../../dialog/dialog-buttons";
+import DialogHeader from "../../dialog/dialog-header";
+import { Toast } from "../../toast";
+import { Button } from "../../ui/button";
+import Input from "../../ui/input";
+import Seperator from "../../ui/seperator";
+import Paragraph from "../../ui/typography/paragraph";
let Keychain;
const passInputRef = createRef();
@@ -62,7 +62,7 @@ export class VaultDialog extends Component {
changePassword: false,
copyNote: false,
revokeFingerprintAccess: false,
- title: 'Unlock Note',
+ title: "Unlock Note",
description: null,
clearVault: false,
deleteVault: false,
@@ -72,45 +72,45 @@ export class VaultDialog extends Component {
this.confirmPassword = null;
this.newPassword = null;
(this.title = !this.state.novault
- ? 'Create Vault'
+ ? "Create Vault"
: this.state.fingerprintAccess
- ? 'Vault Fingerprint Unlock'
+ ? "Vault Fingerprint Unlock"
: this.state.revokeFingerprintAccess
- ? 'Revoke Vault Fingerprint Unlock'
+ ? "Revoke Vault Fingerprint Unlock"
: this.state.changePassword
- ? 'Change Vault Password'
+ ? "Change Vault Password"
: this.state.note.locked
? this.state.deleteNote
- ? 'Delete note'
+ ? "Delete note"
: this.state.share
- ? 'Share note'
+ ? "Share note"
: this.state.copyNote
- ? 'Copy note'
+ ? "Copy note"
: this.state.goToEditor
- ? 'Unlock note'
- : 'Unlock note'
- : 'Lock note'),
+ ? "Unlock note"
+ : "Unlock note"
+ : "Lock note"),
(this.description = !this.state.novault
- ? 'Set a password to create vault'
+ ? "Set a password to create vault"
: this.state.fingerprintAccess
- ? 'Enter vault password to enable fingerprint unlocking.'
+ ? "Enter vault password to enable fingerprint unlocking."
: this.state.revokeFingerprintAccess
- ? 'Disable vault fingerprint unlock '
+ ? "Disable vault fingerprint unlock "
: this.state.changePassword
- ? 'Setup a new password for the vault.'
+ ? "Setup a new password for the vault."
: this.state.permanant
- ? 'Enter password to remove note from vault.'
+ ? "Enter password to remove note from vault."
: this.state.note.locked
? this.state.deleteNote
- ? 'Unlock note to delete it. If biometrics are not working, you can enter device pin to unlock vault.'
+ ? "Unlock note to delete it. If biometrics are not working, you can enter device pin to unlock vault."
: this.state.share
- ? 'Unlock note to share it. If biometrics are not working, you can enter device pin to unlock vault.'
+ ? "Unlock note to share it. If biometrics are not working, you can enter device pin to unlock vault."
: this.state.copyNote
- ? 'Unlock note to copy it. If biometrics are not working, you can enter device pin to unlock vault.'
+ ? "Unlock note to copy it. If biometrics are not working, you can enter device pin to unlock vault."
: this.state.goToEditor
- ? 'Unlock note to open it in editor. If biometrics are not working, you can enter device pin to unlock vault.'
- : 'Enter vault password to unlock note. If biometrics are not working, you can enter device pin to unlock vault.'
- : 'Enter vault password to lock note. If biometrics are not working, you can enter device pin to lock note.');
+ ? "Unlock note to open it in editor. If biometrics are not working, you can enter device pin to unlock vault."
+ : "Enter vault password to unlock note. If biometrics are not working, you can enter device pin to unlock vault."
+ : "Enter vault password to lock note. If biometrics are not working, you can enter device pin to lock note.");
}
componentDidMount() {
@@ -127,13 +127,13 @@ export class VaultDialog extends Component {
*
* @param {import('../../../services/event-manager').vaultType} data
*/
- open = async data => {
+ open = async (data) => {
if (!Keychain) {
- Keychain = require('react-native-keychain');
+ Keychain = require("react-native-keychain");
}
let biometry = await BiometricService.isBiometryAvailable();
let available = false;
- let fingerprint = await BiometricService.hasInternetCredentials('nn_vault');
+ let fingerprint = await BiometricService.hasInternetCredentials("nn_vault");
if (biometry) {
available = true;
@@ -181,19 +181,19 @@ export class VaultDialog extends Component {
if (this.state.loading) {
ToastEvent.show({
heading: this.state.title,
- message: 'Please wait and do not close the app.',
- type: 'success',
- context: 'local'
+ message: "Please wait and do not close the app.",
+ type: "success",
+ context: "local"
});
return;
}
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'TopicNotes',
- 'TaggedNotes',
- 'ColoredNotes'
+ "Notes",
+ "Favorites",
+ "TopicNotes",
+ "TaggedNotes",
+ "ColoredNotes"
);
this.password = null;
@@ -223,19 +223,19 @@ export class VaultDialog extends Component {
if (!this.password) {
ToastEvent.show({
- heading: 'Password not entered',
- message: 'Enter a password for the vault and try again.',
- type: 'error',
- context: 'local'
+ heading: "Password not entered",
+ message: "Enter a password for the vault and try again.",
+ type: "error",
+ context: "local"
});
return;
}
if (this.password && this.password.length < 3) {
ToastEvent.show({
- heading: 'Password too short',
- message: 'Password must be longer than 3 characters.',
- type: 'error',
- context: 'local'
+ heading: "Password too short",
+ message: "Password must be longer than 3 characters.",
+ type: "error",
+ context: "local"
});
return;
@@ -244,9 +244,9 @@ export class VaultDialog extends Component {
if (!this.state.novault) {
if (this.password !== this.confirmPassword) {
ToastEvent.show({
- heading: 'Passwords do not match',
- type: 'error',
- context: 'local'
+ heading: "Passwords do not match",
+ type: "error",
+ context: "local"
});
this.setState({
passwordsDontMatch: true
@@ -262,7 +262,7 @@ export class VaultDialog extends Component {
db.vault
.changePassword(this.password, this.newPassword)
- .then(result => {
+ .then((result) => {
this.setState({
loading: false
});
@@ -270,32 +270,32 @@ export class VaultDialog extends Component {
this._enrollFingerprint(this.newPassword);
}
ToastEvent.show({
- heading: 'Vault password updated successfully',
- type: 'success',
- context: 'global'
+ heading: "Vault password updated successfully",
+ type: "success",
+ context: "global"
});
this.close();
})
- .catch(e => {
+ .catch((e) => {
this.setState({
loading: false
});
if (e.message === db.vault.ERRORS.wrongPassword) {
ToastEvent.show({
- heading: 'Incorrect password',
- message: 'Please enter the correct password and try again',
- type: 'error',
- context: 'local'
+ heading: "Incorrect password",
+ message: "Please enter the correct password and try again",
+ type: "error",
+ context: "local"
});
}
});
} else if (this.state.locked) {
if (!this.password || this.password.trim() === 0) {
ToastEvent.show({
- heading: 'Incorrect password',
- message: 'Please enter the correct password and try again',
- type: 'error',
- context: 'local'
+ heading: "Incorrect password",
+ message: "Please enter the correct password and try again",
+ type: "error",
+ context: "local"
});
this.setState({
wrongPassword: true
@@ -313,7 +313,7 @@ export class VaultDialog extends Component {
});
await this._lockNote();
})
- .catch(e => {
+ .catch((e) => {
this._takeErrorAction(e);
});
}
@@ -335,17 +335,17 @@ export class VaultDialog extends Component {
if (!(await db.user.getUser())) verified = true;
if (verified) {
await db.vault.delete(this.state.deleteAll);
- eSendEvent('vaultUpdated');
+ eSendEvent("vaultUpdated");
this.setState({
loading: false
});
this.close();
} else {
ToastEvent.show({
- heading: 'Account password incorrect',
- message: 'Please enter correct password for your account.',
- type: 'error',
- context: 'local'
+ heading: "Account password incorrect",
+ message: "Please enter correct password for your account.",
+ type: "error",
+ context: "local"
});
}
} catch (e) {}
@@ -364,13 +364,13 @@ export class VaultDialog extends Component {
loading: false
});
this.close();
- eSendEvent('vaultUpdated');
+ eSendEvent("vaultUpdated");
} catch (e) {
ToastEvent.show({
- heading: 'Vault password incorrect',
- message: 'Please enter correct password to clear vault.',
- type: 'error',
- context: 'local'
+ heading: "Vault password incorrect",
+ message: "Please enter correct password to clear vault.",
+ type: "error",
+ context: "local"
});
}
this.setState({
@@ -381,11 +381,11 @@ export class VaultDialog extends Component {
async _lockNote() {
if (!this.password || this.password.trim() === 0) {
ToastEvent.show({
- heading: 'Incorrect password',
- type: 'error',
- context: 'local'
+ heading: "Incorrect password",
+ type: "error",
+ context: "local"
});
- console.log('returning from here');
+ console.log("returning from here");
return;
} else {
await db.vault.add(this.state.note.id);
@@ -394,9 +394,9 @@ export class VaultDialog extends Component {
}
this.close();
ToastEvent.show({
- message: 'Note locked successfully',
- type: 'error',
- context: 'local'
+ message: "Note locked successfully",
+ type: "error",
+ context: "local"
});
this.setState({
loading: false
@@ -407,10 +407,10 @@ export class VaultDialog extends Component {
async _unlockNote() {
if (!this.password || this.password.trim() === 0) {
ToastEvent.show({
- heading: 'Incorrect password',
- message: 'Please enter the correct password and try again',
- type: 'error',
- context: 'local'
+ heading: "Incorrect password",
+ message: "Please enter the correct password and try again",
+ type: "error",
+ context: "local"
});
return;
}
@@ -464,20 +464,21 @@ export class VaultDialog extends Component {
this.setState({
loading: false
});
- eSendEvent('vaultUpdated');
+ eSendEvent("vaultUpdated");
ToastEvent.show({
- heading: 'Biometric unlocking enabled!',
- message: 'Now you can unlock notes in vault with biometrics.',
- type: 'success',
- context: 'global'
+ heading: "Biometric unlocking enabled!",
+ message: "Now you can unlock notes in vault with biometrics.",
+ type: "success",
+ context: "global"
});
this.close();
} catch (e) {
ToastEvent.show({
- heading: 'Incorrect password',
- message: 'Please enter the correct vault password to enable biometrics.',
- type: 'error',
- context: 'local'
+ heading: "Incorrect password",
+ message:
+ "Please enter the correct vault password to enable biometrics.",
+ type: "error",
+ context: "local"
});
this.setState({
loading: false
@@ -506,17 +507,17 @@ export class VaultDialog extends Component {
loading: false
});
ToastEvent.show({
- heading: 'Note added to vault',
- type: 'success',
- context: 'global'
+ heading: "Note added to vault",
+ type: "success",
+ context: "global"
});
this.close();
} else {
- eSendEvent('vaultUpdated');
+ eSendEvent("vaultUpdated");
ToastEvent.show({
- heading: 'Vault created successfully',
- type: 'success',
- context: 'global'
+ heading: "Vault created successfully",
+ type: "success",
+ context: "global"
});
this.close();
}
@@ -525,15 +526,15 @@ export class VaultDialog extends Component {
_permanantUnlock() {
db.vault
.remove(this.state.note.id, this.password)
- .then(r => {
+ .then((r) => {
ToastEvent.show({
- heading: 'Note permanantly unlocked.',
- type: 'success',
- context: 'global'
+ heading: "Note permanantly unlocked.",
+ type: "success",
+ context: "global"
});
this.close();
})
- .catch(e => {
+ .catch((e) => {
this._takeErrorAction(e);
});
}
@@ -551,10 +552,10 @@ export class VaultDialog extends Component {
async _copyNote(note) {
Clipboard.setString(await toTXT(note));
ToastEvent.show({
- heading: 'Note copied',
- type: 'success',
- message: 'Note has been copied to clipboard!',
- context: 'global'
+ heading: "Note copied",
+ type: "success",
+ message: "Note has been copied to clipboard!",
+ context: "global"
});
this.close();
}
@@ -563,7 +564,7 @@ export class VaultDialog extends Component {
this.close();
try {
await Share.open({
- heading: 'Share note',
+ heading: "Share note",
failOnCancel: false,
message: await toTXT(note)
});
@@ -571,16 +572,19 @@ export class VaultDialog extends Component {
}
_takeErrorAction(e) {
- if (e.message === db.vault.ERRORS.wrongPassword || e.message === 'FAILURE') {
+ if (
+ e.message === db.vault.ERRORS.wrongPassword ||
+ e.message === "FAILURE"
+ ) {
this.setState({
wrongPassword: true,
visible: true
});
setTimeout(() => {
ToastEvent.show({
- heading: 'Incorrect password',
- type: 'error',
- context: 'local'
+ heading: "Incorrect password",
+ type: "error",
+ context: "local"
});
}, 500);
@@ -591,18 +595,18 @@ export class VaultDialog extends Component {
_revokeFingerprintAccess = async () => {
try {
await BiometricService.resetCredentials();
- eSendEvent('vaultUpdated');
+ eSendEvent("vaultUpdated");
ToastEvent.show({
- heading: 'Biometric unlocking disabled!',
- type: 'success',
- context: 'global'
+ heading: "Biometric unlocking disabled!",
+ type: "success",
+ context: "global"
});
} catch (e) {
ToastEvent.show({
- heading: 'Failed to disable Biometric unlocking.',
+ heading: "Failed to disable Biometric unlocking.",
message: e.message,
- type: 'success',
- context: 'global'
+ type: "success",
+ context: "global"
});
}
};
@@ -663,7 +667,7 @@ export class VaultDialog extends Component {
<View
style={{
...getElevation(5),
- width: DDS.isTab ? 350 : '85%',
+ width: DDS.isTab ? 350 : "85%",
borderRadius: 10,
backgroundColor: colors.bg,
paddingTop: 12
@@ -682,7 +686,10 @@ export class VaultDialog extends Component {
paddingHorizontal: 12
}}
>
- {(novault || changePassword || this.state.clearVault || this.state.deleteVault) &&
+ {(novault ||
+ changePassword ||
+ this.state.clearVault ||
+ this.state.deleteVault) &&
!this.state.revokeFingerprintAccess ? (
<>
<Input
@@ -690,7 +697,7 @@ export class VaultDialog extends Component {
editable={!loading}
autoCapitalize="none"
testID={notesnook.ids.dialogs.vault.pwd}
- onChangeText={value => {
+ onChangeText={(value) => {
this.password = value;
}}
marginBottom={
@@ -702,13 +709,15 @@ export class VaultDialog extends Component {
: 10
}
onSubmit={() => {
- changePassword ? changePassInputRef.current?.focus() : this.onPress;
+ changePassword
+ ? changePassInputRef.current?.focus()
+ : this.onPress;
}}
autoComplete="password"
- returnKeyLabel={changePassword ? 'Next' : this.state.title}
- returnKeyType={changePassword ? 'next' : 'done'}
+ returnKeyLabel={changePassword ? "Next" : this.state.title}
+ returnKeyType={changePassword ? "next" : "done"}
secureTextEntry
- placeholder={changePassword ? 'Current password' : 'Password'}
+ placeholder={changePassword ? "Current password" : "Password"}
/>
{!this.state.biometricUnlock ||
@@ -716,10 +725,12 @@ export class VaultDialog extends Component {
!novault ||
changePassword ? null : (
<Button
- onPress={() => this._onPressFingerprintAuth('Unlock note', '')}
+ onPress={() =>
+ this._onPressFingerprintAuth("Unlock note", "")
+ }
icon="fingerprint"
width="100%"
- title={'Biometric unlock'}
+ title={"Biometric unlock"}
type="transparent"
/>
)}
@@ -734,13 +745,15 @@ export class VaultDialog extends Component {
})
}
icon={
- this.state.deleteAll ? 'check-circle-outline' : 'checkbox-blank-circle-outline'
+ this.state.deleteAll
+ ? "check-circle-outline"
+ : "checkbox-blank-circle-outline"
}
style={{
marginTop: 10
}}
width="100%"
- title={'Delete all notes'}
+ title={"Delete all notes"}
type="errorShade"
/>
)}
@@ -753,7 +766,7 @@ export class VaultDialog extends Component {
editable={!loading}
testID={notesnook.ids.dialogs.vault.changePwd}
autoCapitalize="none"
- onChangeText={value => {
+ onChangeText={(value) => {
this.newPassword = value;
}}
autoComplete="password"
@@ -761,7 +774,7 @@ export class VaultDialog extends Component {
returnKeyLabel="Change"
returnKeyType="done"
secureTextEntry
- placeholder={'New password'}
+ placeholder={"New password"}
/>
</>
) : null}
@@ -772,7 +785,7 @@ export class VaultDialog extends Component {
fwdRef={passInputRef}
autoCapitalize="none"
testID={notesnook.ids.dialogs.vault.pwd}
- onChangeText={value => {
+ onChangeText={(value) => {
this.password = value;
}}
autoComplete="password"
@@ -793,12 +806,12 @@ export class VaultDialog extends Component {
validationType="confirmPassword"
customValidator={() => this.password}
errorMessage="Passwords do not match."
- onErrorCheck={e => null}
+ onErrorCheck={(e) => null}
marginBottom={0}
autoComplete="password"
returnKeyLabel="Create"
returnKeyType="done"
- onChangeText={value => {
+ onChangeText={(value) => {
this.confirmPassword = value;
if (value !== this.password) {
this.setState({
@@ -816,8 +829,12 @@ export class VaultDialog extends Component {
</View>
) : null}
- {this.state.biometricUnlock && !this.state.isBiometryEnrolled && novault ? (
- <Paragraph>Unlock with password once to enable biometric access.</Paragraph>
+ {this.state.biometricUnlock &&
+ !this.state.isBiometryEnrolled &&
+ novault ? (
+ <Paragraph>
+ Unlock with password once to enable biometric access.
+ </Paragraph>
) : null}
{this.state.isBiometryAvailable &&
@@ -838,7 +855,7 @@ export class VaultDialog extends Component {
icon="fingerprint"
width="100%"
title="Biometric unlocking"
- type={this.state.biometricUnlock ? 'transparent' : 'gray'}
+ type={this.state.biometricUnlock ? "transparent" : "gray"}
/>
) : null}
</View>
@@ -847,29 +864,31 @@ export class VaultDialog extends Component {
onPressNegative={this.close}
onPressPositive={this.onPress}
loading={loading}
- positiveType={deleteVault || clearVault ? 'errorShade' : 'transparent'}
+ positiveType={
+ deleteVault || clearVault ? "errorShade" : "transparent"
+ }
positiveTitle={
deleteVault
- ? 'Delete'
+ ? "Delete"
: clearVault
- ? 'Clear'
+ ? "Clear"
: fingerprintAccess
- ? 'Enable'
+ ? "Enable"
: this.state.revokeFingerprintAccess
- ? 'Revoke'
+ ? "Revoke"
: changePassword
- ? 'Change'
+ ? "Change"
: note.locked
? deleteNote
- ? 'Delete'
+ ? "Delete"
: share
- ? 'Share '
+ ? "Share "
: goToEditor
- ? 'Open'
- : 'Unlock'
+ ? "Open"
+ : "Unlock"
: !note.id
- ? 'Create'
- : 'Lock'
+ ? "Create"
+ : "Lock"
}
/>
</View>
diff --git a/apps/mobile/app/components/exception-handler/index.tsx b/apps/mobile/app/components/exception-handler/index.tsx
index 472566b58..461659339 100644
--- a/apps/mobile/app/components/exception-handler/index.tsx
+++ b/apps/mobile/app/components/exception-handler/index.tsx
@@ -1,8 +1,8 @@
-import React from 'react';
-import RNBootSplash from 'react-native-bootsplash';
-import { SafeAreaProvider, SafeAreaView } from 'react-native-safe-area-context';
-import { Dialog } from '../dialog';
-import { Issue } from '../sheets/github/issue';
+import React from "react";
+import RNBootSplash from "react-native-bootsplash";
+import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";
+import { Dialog } from "../dialog";
+import { Issue } from "../sheets/github/issue";
const error = (
stack: string,
@@ -12,7 +12,10 @@ const error = (
_______________________________
Stacktrace: In ${component}::${stack}`;
-class ExceptionHandler extends React.Component<{ children: React.ReactNode; component: string }> {
+class ExceptionHandler extends React.Component<{
+ children: React.ReactNode;
+ component: string;
+}> {
state: {
error: {
title: string;
@@ -45,8 +48,11 @@ class ExceptionHandler extends React.Component<{ children: React.ReactNode; comp
}}
>
<Issue
- defaultBody={error(this.state.error?.stack || '', this.props.component)}
- defaultTitle={this.state.error?.title || 'Unknown Error'}
+ defaultBody={error(
+ this.state.error?.stack || "",
+ this.props.component
+ )}
+ defaultTitle={this.state.error?.title || "Unknown Error"}
issueTitle="An exception occured"
/>
<Dialog />
diff --git a/apps/mobile/app/components/header/index.js b/apps/mobile/app/components/header/index.js
index 26b3f62b3..2f0288cc8 100644
--- a/apps/mobile/app/components/header/index.js
+++ b/apps/mobile/app/components/header/index.js
@@ -1,25 +1,30 @@
-import React, { useEffect, useState } from 'react';
-import { Platform, StyleSheet, View } from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { SearchBar } from '../../screens/search/search-bar';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useSelectionStore } from '../../stores/use-selection-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eScrollEvent } from '../../utils/events';
-import { LeftMenus } from './left-menus';
-import { RightMenus } from './right-menus';
-import { Title } from './title';
+import React, { useEffect, useState } from "react";
+import { Platform, StyleSheet, View } from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { SearchBar } from "../../screens/search/search-bar";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useSelectionStore } from "../../stores/use-selection-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { eScrollEvent } from "../../utils/events";
+import { LeftMenus } from "./left-menus";
+import { RightMenus } from "./right-menus";
+import { Title } from "./title";
export const Header = React.memo(
() => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const insets = useSafeAreaInsets();
const [hide, setHide] = useState(true);
- const selectionMode = useSelectionStore(state => state.selectionMode);
- const currentScreen = useNavigationStore(state => state.currentScreen?.name);
+ const selectionMode = useSelectionStore((state) => state.selectionMode);
+ const currentScreen = useNavigationStore(
+ (state) => state.currentScreen?.name
+ );
- const onScroll = data => {
+ const onScroll = (data) => {
if (data.y > 150) {
if (!hide) return;
setHide(false);
@@ -42,16 +47,16 @@ export const Header = React.memo(
style={[
styles.container,
{
- marginTop: Platform.OS === 'android' ? insets.top : null,
+ marginTop: Platform.OS === "android" ? insets.top : null,
backgroundColor: colors.bg,
- overflow: 'hidden',
+ overflow: "hidden",
borderBottomWidth: 1,
- borderBottomColor: hide ? 'transparent' : colors.nav,
- justifyContent: 'space-between'
+ borderBottomColor: hide ? "transparent" : colors.nav,
+ justifyContent: "space-between"
}
]}
>
- {currentScreen === 'Search' ? (
+ {currentScreen === "Search" ? (
<SearchBar />
) : (
<>
@@ -71,24 +76,24 @@ export const Header = React.memo(
const styles = StyleSheet.create({
container: {
- flexDirection: 'row',
+ flexDirection: "row",
zIndex: 11,
height: 50,
maxHeight: 50,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
paddingHorizontal: 12,
- width: '100%'
+ width: "100%"
},
leftBtnContainer: {
- flexDirection: 'row',
- justifyContent: 'flex-start',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "flex-start",
+ alignItems: "center",
flexShrink: 1
},
leftBtn: {
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
height: 40,
width: 40,
borderRadius: 100,
@@ -96,12 +101,12 @@ const styles = StyleSheet.create({
marginRight: 25
},
rightBtnContainer: {
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
},
rightBtn: {
- justifyContent: 'center',
- alignItems: 'flex-end',
+ justifyContent: "center",
+ alignItems: "flex-end",
height: 40,
width: 40,
paddingRight: 0
diff --git a/apps/mobile/app/components/header/left-menus.js b/apps/mobile/app/components/header/left-menus.js
index f63a2b87e..67835b88b 100644
--- a/apps/mobile/app/components/header/left-menus.js
+++ b/apps/mobile/app/components/header/left-menus.js
@@ -1,18 +1,18 @@
-import React from 'react';
-import { notesnook } from '../../../e2e/test.ids';
-import { DDS } from '../../services/device-detection';
-import Navigation from '../../services/navigation';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { tabBarRef } from '../../utils/global-refs';
-import { IconButton } from '../ui/icon-button';
+import React from "react";
+import { notesnook } from "../../../e2e/test.ids";
+import { DDS } from "../../services/device-detection";
+import Navigation from "../../services/navigation";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { tabBarRef } from "../../utils/global-refs";
+import { IconButton } from "../ui/icon-button";
export const LeftMenus = () => {
- const colors = useThemeStore(state => state.colors);
- const deviceMode = useSettingStore(state => state.deviceMode);
- const canGoBack = useNavigationStore(state => state.canGoBack);
- const isTablet = deviceMode === 'tablet';
+ const colors = useThemeStore((state) => state.colors);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
+ const canGoBack = useNavigationStore((state) => state.canGoBack);
+ const isTablet = deviceMode === "tablet";
const onLeftButtonPress = () => {
if (!canGoBack) {
@@ -25,8 +25,8 @@ export const LeftMenus = () => {
}
Navigation.goBack();
if (
- useNavigationStore.getState().currentScreen.name === 'Signup' ||
- useNavigationStore.getState().currentScreen.name === 'Login'
+ useNavigationStore.getState().currentScreen.name === "Signup" ||
+ useNavigationStore.getState().currentScreen.name === "Login"
) {
tabBarRef.current.unlock();
}
@@ -36,8 +36,8 @@ export const LeftMenus = () => {
<IconButton
testID={notesnook.ids.default.header.buttons.left}
customStyle={{
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
height: 40,
width: 40,
borderRadius: 100,
@@ -51,7 +51,7 @@ export const LeftMenus = () => {
onLongPress={() => {
Navigation.popToTop();
}}
- name={canGoBack ? 'arrow-left' : 'menu'}
+ name={canGoBack ? "arrow-left" : "menu"}
color={colors.pri}
iconStyle={{
marginLeft: canGoBack ? -5 : 0
diff --git a/apps/mobile/app/components/header/right-menus.js b/apps/mobile/app/components/header/right-menus.js
index 6515c2091..a3aafdfe0 100644
--- a/apps/mobile/app/components/header/right-menus.js
+++ b/apps/mobile/app/components/header/right-menus.js
@@ -1,33 +1,33 @@
-import React, { useRef } from 'react';
-import { Platform, StyleSheet, View } from 'react-native';
-import Menu from 'react-native-reanimated-material-menu';
-import { notesnook } from '../../../e2e/test.ids';
-import Navigation from '../../services/navigation';
-import SearchService from '../../services/search';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { Button } from '../ui/button';
-import { IconButton } from '../ui/icon-button';
+import React, { useRef } from "react";
+import { Platform, StyleSheet, View } from "react-native";
+import Menu from "react-native-reanimated-material-menu";
+import { notesnook } from "../../../e2e/test.ids";
+import Navigation from "../../services/navigation";
+import SearchService from "../../services/search";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { Button } from "../ui/button";
+import { IconButton } from "../ui/icon-button";
export const RightMenus = () => {
- const colors = useThemeStore(state => state.colors);
- const deviceMode = useSettingStore(state => state.deviceMode);
- const rightButtons = useNavigationStore(state => state.headerRightButtons);
- const currentScreen = useNavigationStore(state => state.currentScreen.name);
- const buttonAction = useNavigationStore(state => state.buttonAction);
+ const colors = useThemeStore((state) => state.colors);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
+ const rightButtons = useNavigationStore((state) => state.headerRightButtons);
+ const currentScreen = useNavigationStore((state) => state.currentScreen.name);
+ const buttonAction = useNavigationStore((state) => state.buttonAction);
const menuRef = useRef();
return (
<View style={styles.rightBtnContainer}>
- {!currentScreen.startsWith('Settings') ? (
+ {!currentScreen.startsWith("Settings") ? (
<IconButton
onPress={async () => {
SearchService.prepareSearch();
Navigation.navigate({
- name: 'Search'
+ name: "Search"
});
}}
testID="icon-search"
@@ -37,11 +37,11 @@ export const RightMenus = () => {
/>
) : null}
- {deviceMode !== 'mobile' ? (
+ {deviceMode !== "mobile" ? (
<Button
onPress={buttonAction}
testID={notesnook.ids.default.addBtn}
- icon={currentScreen === 'Trash' ? 'delete' : 'plus'}
+ icon={currentScreen === "Trash" ? "delete" : "plus"}
iconSize={SIZE.xl}
type="shade"
hitSlop={{
@@ -88,7 +88,7 @@ export const RightMenus = () => {
<Button
style={{
width: 150,
- justifyContent: 'flex-start',
+ justifyContent: "flex-start",
borderRadius: 0
}}
type="gray"
@@ -99,7 +99,7 @@ export const RightMenus = () => {
title={item.title}
onPress={async () => {
menuRef.current?.hide();
- if (Platform.OS === 'ios') await sleep(300);
+ if (Platform.OS === "ios") await sleep(300);
item.onPress();
}}
/>
@@ -112,12 +112,12 @@ export const RightMenus = () => {
const styles = StyleSheet.create({
rightBtnContainer: {
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
},
rightBtn: {
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
height: 40,
width: 40,
marginLeft: 10,
diff --git a/apps/mobile/app/components/header/title.js b/apps/mobile/app/components/header/title.js
index c3394a918..c47521495 100644
--- a/apps/mobile/app/components/header/title.js
+++ b/apps/mobile/app/components/header/title.js
@@ -1,40 +1,43 @@
-import React, { useEffect, useState } from 'react';
-import { Platform, View } from 'react-native';
-import Notebook from '../../screens/notebook';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { db } from '../../common/database';
-import { eScrollEvent } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React, { useEffect, useState } from "react";
+import { Platform, View } from "react-native";
+import Notebook from "../../screens/notebook";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { db } from "../../common/database";
+import { eScrollEvent } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
const titleState = {};
export const Title = () => {
- const colors = useThemeStore(state => state.colors);
- const currentScreen = useNavigationStore(state => state.currentScreen);
- const isNotebook = currentScreen.name === 'Notebook';
- const isTopic = currentScreen?.name === 'TopicNotes';
+ const colors = useThemeStore((state) => state.colors);
+ const currentScreen = useNavigationStore((state) => state.currentScreen);
+ const isNotebook = currentScreen.name === "Notebook";
+ const isTopic = currentScreen?.name === "TopicNotes";
const [hide, setHide] = useState(
isNotebook
- ? typeof titleState[currentScreen.id] === 'boolean'
+ ? typeof titleState[currentScreen.id] === "boolean"
? titleState[currentScreen.id]
: true
: false
);
const isHidden = titleState[currentScreen.id];
- console.log(currentScreen, 'header');
+ console.log(currentScreen, "header");
const notebook =
isTopic && currentScreen.notebookId
? db.notebooks?.notebook(currentScreen.notebookId)?.data
: null;
const title = currentScreen.title;
- const isTag = currentScreen?.name === 'TaggedNotes';
+ const isTag = currentScreen?.name === "TaggedNotes";
- const onScroll = data => {
- if (currentScreen.name !== 'Notebook') {
+ const onScroll = (data) => {
+ if (currentScreen.name !== "Notebook") {
setHide(false);
return;
}
@@ -48,9 +51,11 @@ export const Title = () => {
};
useEffect(() => {
- if (currentScreen.name === 'Notebook') {
+ if (currentScreen.name === "Notebook") {
let value =
- typeof titleState[currentScreen.id] === 'boolean' ? titleState[currentScreen.id] : true;
+ typeof titleState[currentScreen.id] === "boolean"
+ ? titleState[currentScreen.id]
+ : true;
setHide(value);
} else {
setHide(titleState[currentScreen.id]);
@@ -77,7 +82,7 @@ export const Title = () => {
style={{
opacity: 1,
flexShrink: 1,
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
{!hide && !isHidden ? (
@@ -86,19 +91,22 @@ export const Title = () => {
numberOfLines={isTopic ? 2 : 1}
size={isTopic ? SIZE.md + 2 : SIZE.xl}
style={{
- flexWrap: 'wrap',
- marginTop: Platform.OS === 'ios' ? -1 : 0
+ flexWrap: "wrap",
+ marginTop: Platform.OS === "ios" ? -1 : 0
}}
color={currentScreen.color || colors.heading}
>
{isTopic ? (
<Paragraph numberOfLines={1} size={SIZE.xs + 1}>
{notebook?.title}
- {'\n'}
+ {"\n"}
</Paragraph>
) : null}
{isTag ? (
- <Heading size={isTopic ? SIZE.md + 2 : SIZE.xl} color={colors.accent}>
+ <Heading
+ size={isTopic ? SIZE.md + 2 : SIZE.xl}
+ color={colors.accent}
+ >
#
</Heading>
) : null}
diff --git a/apps/mobile/app/components/image-preview/index.js b/apps/mobile/app/components/image-preview/index.js
index 922c83b38..95d975ee5 100644
--- a/apps/mobile/app/components/image-preview/index.js
+++ b/apps/mobile/app/components/image-preview/index.js
@@ -1,23 +1,26 @@
-import React, { useEffect, useState } from 'react';
-import { View } from 'react-native';
-import ImageViewer from 'react-native-image-zoom-viewer';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import BaseDialog from '../dialog/base-dialog';
-import { IconButton } from '../ui/icon-button';
+import React, { useEffect, useState } from "react";
+import { View } from "react-native";
+import ImageViewer from "react-native-image-zoom-viewer";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import BaseDialog from "../dialog/base-dialog";
+import { IconButton } from "../ui/icon-button";
const ImagePreview = () => {
const [visible, setVisible] = useState(false);
- const [image, setImage] = useState('');
+ const [image, setImage] = useState("");
useEffect(() => {
- eSubscribeEvent('ImagePreview', open);
+ eSubscribeEvent("ImagePreview", open);
return () => {
- eUnSubscribeEvent('ImagePreview', open);
+ eUnSubscribeEvent("ImagePreview", open);
};
}, []);
- const open = image => {
+ const open = (image) => {
setImage(image);
setVisible(true);
};
@@ -32,9 +35,9 @@ const ImagePreview = () => {
<BaseDialog animation="slide" visible={true} onRequestClose={close}>
<View
style={{
- width: '100%',
- height: '100%',
- backgroundColor: 'black'
+ width: "100%",
+ height: "100%",
+ backgroundColor: "black"
}}
>
<ImageViewer
@@ -47,16 +50,16 @@ const ImagePreview = () => {
renderHeader={() => (
<View
style={{
- flexDirection: 'row',
- width: '100%',
- justifyContent: 'flex-end',
- alignItems: 'center',
+ flexDirection: "row",
+ width: "100%",
+ justifyContent: "flex-end",
+ alignItems: "center",
height: 80,
marginTop: 0,
paddingHorizontal: 12,
- position: 'absolute',
+ position: "absolute",
zIndex: 999,
- backgroundColor: 'rgba(0,0,0,0.3)',
+ backgroundColor: "rgba(0,0,0,0.3)",
paddingTop: 30
}}
>
diff --git a/apps/mobile/app/components/intro/index.js b/apps/mobile/app/components/intro/index.js
index 9c6d6b86a..85d2eedf9 100644
--- a/apps/mobile/app/components/intro/index.js
+++ b/apps/mobile/app/components/intro/index.js
@@ -1,30 +1,40 @@
-import React, { useEffect } from 'react';
-import { Dimensions, Image, TouchableOpacity, useWindowDimensions, View } from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { DDS } from '../../services/device-detection';
-import SettingsService from '../../services/settings';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { getElevation } from '../../utils';
-import umami from '../../common/analytics';
-import { tabBarRef } from '../../utils/global-refs';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import { SvgView } from '../ui/svg';
-import { BouncingView } from '../ui/transitions/bouncing-view';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React, { useEffect } from "react";
+import {
+ Dimensions,
+ Image,
+ TouchableOpacity,
+ useWindowDimensions,
+ View
+} from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { DDS } from "../../services/device-detection";
+import SettingsService from "../../services/settings";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { getElevation } from "../../utils";
+import umami from "../../common/analytics";
+import { tabBarRef } from "../../utils/global-refs";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import { SvgView } from "../ui/svg";
+import { BouncingView } from "../ui/transitions/bouncing-view";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
let SVG_D = `<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="485.83373" height="483.5" viewBox="0 0 485.83373 483.5" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M677.54186,336.34717H597.80041a11.47812,11.47812,0,0,1-9.06567-4.39356h0a11.62154,11.62154,0,0,1-2.17652-9.96777,201.63052,201.63052,0,0,0-.00049-93.647,11.62425,11.62425,0,0,1,2.17676-9.96729,11.47753,11.47753,0,0,1,9.06592-4.39355h79.74145a11.6235,11.6235,0,0,1,11.439,9.75537,337.96108,337.96108,0,0,1,0,102.8584A11.6235,11.6235,0,0,1,677.54186,336.34717Z" transform="translate(-357.08314 -208.25)" fill="#e6e6e6"/><path d="M597.80041,219.978a5.51264,5.51264,0,0,0-4.35449,2.1084,5.65943,5.65943,0,0,0-1.05371,4.85351,207.656,207.656,0,0,1,.00048,96.44531,5.65638,5.65638,0,0,0,1.053,4.85254l.00049.00049a5.5112,5.5112,0,0,0,4.35425,2.10889h79.74145a5.58248,5.58248,0,0,0,5.50879-4.667,331.9854,331.9854,0,0,0,0-101.03516,5.58248,5.58248,0,0,0-5.50879-4.667Z" transform="translate(-357.08314 -208.25)" fill="#fff"/><path d="M660.14054,248.82872h-41.845a6.00633,6.00633,0,0,1-5.99977-5.99977v-2.34463a6.00633,6.00633,0,0,1,5.99977-5.99977h41.845a6.00633,6.00633,0,0,1,5.99976,5.99977V242.829A6.00632,6.00632,0,0,1,660.14054,248.82872Z" transform="translate(-357.08314 -208.25)" fill="#e6e6e6"/><path d="M660.14054,278.4545h-41.845a6.00632,6.00632,0,0,1-5.99977-5.99976V270.1101a6.00632,6.00632,0,0,1,5.99977-5.99976h41.845a6.00632,6.00632,0,0,1,5.99976,5.99976v2.34464A6.00632,6.00632,0,0,1,660.14054,278.4545Z" transform="translate(-357.08314 -208.25)" fill="#e6e6e6"/><path d="M660.14054,308.08029h-41.845a6.00633,6.00633,0,0,1-5.99977-5.99977v-2.34463a6.00632,6.00632,0,0,1,5.99977-5.99976h41.845a6.00632,6.00632,0,0,1,5.99976,5.99976v2.34463A6.00632,6.00632,0,0,1,660.14054,308.08029Z" transform="translate(-357.08314 -208.25)" fill="#e6e6e6"/><path d="M827.54186,412.34717H747.80041a11.47812,11.47812,0,0,1-9.06567-4.39356h0a11.62154,11.62154,0,0,1-2.17652-9.96777,201.63052,201.63052,0,0,0-.00049-93.647,11.62425,11.62425,0,0,1,2.17676-9.96729,11.47753,11.47753,0,0,1,9.06592-4.39355h79.74145a11.6235,11.6235,0,0,1,11.439,9.75537,337.96108,337.96108,0,0,1,0,102.8584A11.6235,11.6235,0,0,1,827.54186,412.34717Z" transform="translate(-357.08314 -208.25)" fill="#e6e6e6"/><path d="M747.80041,295.978a5.51264,5.51264,0,0,0-4.35449,2.1084,5.65943,5.65943,0,0,0-1.05371,4.85351,207.656,207.656,0,0,1,.00048,96.44531,5.65638,5.65638,0,0,0,1.053,4.85254l.00049.00049a5.5112,5.5112,0,0,0,4.35425,2.10889h79.74145a5.58248,5.58248,0,0,0,5.50879-4.667,331.9854,331.9854,0,0,0,0-101.03516,5.58248,5.58248,0,0,0-5.50879-4.667Z" transform="translate(-357.08314 -208.25)" fill="#fff"/><path d="M668.54186,498.84717H588.80041a11.97546,11.97546,0,0,1-9.45825-4.584,12.1192,12.1192,0,0,1-2.27-10.394,201.13112,201.13112,0,0,0-.00049-93.41357,12.12077,12.12077,0,0,1,2.27026-10.39356,11.97561,11.97561,0,0,1,9.4585-4.584h79.74145a12.12667,12.12667,0,0,1,11.93311,10.1792,338.45925,338.45925,0,0,1,0,103.01074A12.12668,12.12668,0,0,1,668.54186,498.84717Z" transform="translate(-357.08314 -208.25)" fill="#f2f2f2"/><path d="M810.14054,339.82872h-41.845a6.00633,6.00633,0,0,1-5.99977-5.99977v-2.34463a6.00633,6.00633,0,0,1,5.99977-5.99977h41.845a6.00633,6.00633,0,0,1,5.99976,5.99977V333.829A6.00632,6.00632,0,0,1,810.14054,339.82872Z" transform="translate(-357.08314 -208.25)" fill="#e6e6e6"/><path d="M810.14054,369.4545h-41.845a6.00632,6.00632,0,0,1-5.99977-5.99976V361.1101a6.00632,6.00632,0,0,1,5.99977-5.99976h41.845a6.00632,6.00632,0,0,1,5.99976,5.99976v2.34464A6.00632,6.00632,0,0,1,810.14054,369.4545Z" transform="translate(-357.08314 -208.25)" fill="#e6e6e6"/><circle cx="271.81102" cy="228.5" r="23" fill="#fff"/><path d="M639.89416,433.75h-8v-8a3,3,0,0,0-6,0v8h-8a3,3,0,0,0,0,6h8v8a3,3,0,0,0,6,0v-8h8a3,3,0,0,0,0-6Z" transform="translate(-357.08314 -208.25)" fill="#e6e6e6"/><path d="M657.89416,225.25h-42a4.50508,4.50508,0,0,1-4.5-4.5v-8a4.50508,4.50508,0,0,1,4.5-4.5h42a4.50508,4.50508,0,0,1,4.5,4.5v8A4.50508,4.50508,0,0,1,657.89416,225.25Z" transform="translate(-357.08314 -208.25)" fill="#ccc"/><path d="M809.89416,302.25h-42a4.50508,4.50508,0,0,1-4.5-4.5v-8a4.50508,4.50508,0,0,1,4.5-4.5h42a4.50508,4.50508,0,0,1,4.5,4.5v8A4.50508,4.50508,0,0,1,809.89416,302.25Z" transform="translate(-357.08314 -208.25)" fill="#ccc"/><polygon points="88.596 471.061 100.856 471.061 104.689 423.773 88.594 423.773 88.596 471.061" fill="#ffb8b8"/><path d="M442.55234,675.30845l24.1438-.001h.001a15.38605,15.38605,0,0,1,15.38647,15.38623v.5l-39.53051.00146Z" transform="translate(-357.08314 -208.25)" fill="#2f2e41"/><polygon points="22.596 471.061 34.856 471.061 40.689 423.773 22.594 423.773 22.596 471.061" fill="#ffb8b8"/><path d="M376.55234,675.30845l24.1438-.001h.001a15.38605,15.38605,0,0,1,15.38647,15.38623v.5l-39.53051.00146Z" transform="translate(-357.08314 -208.25)" fill="#2f2e41"/><path d="M381.85436,664.37256a4.98141,4.98141,0,0,1-3.375-1.31836h0a4.961,4.961,0,0,1-1.61572-3.53711L371.947,483.30371l69.81115,17.45215,21.53955,64.61768a70.461,70.461,0,0,1,3.54541,25.82421l-2.67456,62.63672a4.996,4.996,0,0,1-4.99438,4.75879h-11.709a5.02349,5.02349,0,0,1-4.95483-4.32959l-8.3689-69.1416a37.82338,37.82338,0,0,0-5.53173-15.16406l-16.46949-26.07617a1.00011,1.00011,0,0,0-1.83764.41015L397.378,659.38037a4.99328,4.99328,0,0,1-4.687,4.39649l-10.552.58691C382.04406,664.36914,381.94934,664.37256,381.85436,664.37256Z" transform="translate(-357.08314 -208.25)" fill="#2f2e41"/><circle cx="73.05767" cy="136.40609" r="24.56103" fill="#ffb8b8"/><path d="M441.4237,507.92236a5.07628,5.07628,0,0,1-1.25293-.15918H440.17l-69.26428-17.75976a4.9985,4.9985,0,0,1-3.66285-5.81543L383.15,398.49707a31.21377,31.21377,0,0,1,18.24975-22.53955,30.11308,30.11308,0,0,1,28.26563,2.07519c.96973.605,1.94653,1.26465,2.90259,1.96094a30.96046,30.96046,0,0,1,12.57885,24.5293l1.2649,98.32861a5.00656,5.00656,0,0,1-4.988,5.0708Z" transform="translate(-357.08314 -208.25)" fill="#f0f0f0"/><path d="M378.03248,508.93008a10.05576,10.05576,0,0,1,4.214-14.83233l-3.08079-35.6018,16.326,8.84848.42262,32.4515a10.11027,10.11027,0,0,1-17.8818,9.13415Z" transform="translate(-357.08314 -208.25)" fill="#ffb8b8"/><path d="M383.86511,489.38916a5.53224,5.53224,0,0,1-1.36573-.17285,5.49559,5.49559,0,0,1-3.97192-3.98633l-8.02319-31.88379a47.37028,47.37028,0,0,1,3.76123-33.13476l16.80884-32.88184a15.54083,15.54083,0,0,1,18.8081-11.01855,15.35574,15.35574,0,0,1,9.47485,7.10058,15.56707,15.56707,0,0,1,1.65406,11.91309l-23.92749,53.50586.28418,32.03564a5.5186,5.5186,0,0,1-3.58448,5.20459l-8.00732,2.97363A5.48,5.48,0,0,1,383.86511,489.38916Z" transform="translate(-357.08314 -208.25)" fill="#f0f0f0"/><path d="M498.40087,495.83467a10.05578,10.05578,0,0,1-8.493-12.86954l-28.99341-20.88926,17.35654-6.60182,24.8717,20.84893a10.11027,10.11027,0,0,1-4.74186,19.51169Z" transform="translate(-357.08314 -208.25)" fill="#ffb8b8"/><path d="M483.223,480.58057a5.52249,5.52249,0,0,1-2.46265-.58155L451.3612,465.28174a47.381,47.381,0,0,1-22.66064-24.46533L414.74328,406.626a15.54363,15.54363,0,0,1,3.91772-21.44434,15.35158,15.35158,0,0,1,11.59034-2.54346,15.56975,15.56975,0,0,1,10.08081,6.51221l24.94507,53.03955L489.743,462.87256a5.51764,5.51764,0,0,1,1.60669,6.11182l-2.96973,8.0083a5.474,5.474,0,0,1-2.00684,2.59619,5.49717,5.49717,0,0,1-3.15014.9917Z" transform="translate(-357.08314 -208.25)" fill="#f0f0f0"/><path d="M424.98332,369.5931c1.305.571,3.97732-9.82732,2.78025-11.90707-1.78025-3.09293-1.675-3.07072-2.85681-5.117s-1.44623-4.84712.08417-6.64761,5.072-1.56163,5.77042.69581c-.4493-4.2878,3.79189-7.73454,7.993-8.70313s8.63244-.36723,12.85668-1.22917c4.90243-1.00032,10.00316-5.10972,8.04719-10.5007a7.5931,7.5931,0,0,0-1.48106-2.43408c-2.25993-2.54094-5.42117-3.62594-8.512-4.675-6.43006-2.18246-13.036-4.39233-19.82212-4.15141A28.7977,28.7977,0,0,0,404.3967,333.533a26.15571,26.15571,0,0,0-1.08344,4.02534c-2.32924,12.52423,4.94368,24.87794,16.75623,29.64715Z" transform="translate(-357.08314 -208.25)" fill="#2f2e41"/><polygon points="38.9 273.343 39.457 240.414 56.9 205.343 42.9 241.343 38.9 273.343" opacity="0.2"/><path d="M554.16035,564.23244,480.522,533.63692a11.47817,11.47817,0,0,1-6.68609-7.53565h0a11.62155,11.62155,0,0,1,1.81454-10.04,201.63062,201.63062,0,0,0,35.9304-86.47983,11.62422,11.62422,0,0,1,5.83445-8.36925,11.47751,11.47751,0,0,1,10.05779-.57884l73.63839,30.59552a11.62349,11.62349,0,0,1,6.8205,13.39769,337.96147,337.96147,0,0,1-39.46512,94.98607A11.6235,11.6235,0,0,1,554.16035,564.23244Z" transform="translate(-357.08314 -208.25)" fill="#e6e6e6"/><path d="M525.17093,426.17415a5.51263,5.51263,0,0,0-4.83017.27629,5.65945,5.65945,0,0,0-2.83529,4.07775,207.65608,207.65608,0,0,1-37.00407,89.064,5.65636,5.65636,0,0,0-.88946,4.88515l.00027.00064a5.51116,5.51116,0,0,0,3.21185,3.61814l73.63839,30.59552a5.58247,5.58247,0,0,0,6.87782-2.19616,331.98566,331.98566,0,0,0,38.76558-93.30238,5.58248,5.58248,0,0,0-3.29652-6.42343Z" transform="translate(-357.08314 -208.25)" fill="#fff"/><path d="M564.38028,494.28148l-38.6424-16.05527a6.00633,6.00633,0,0,1-3.23855-7.84259l.8996-2.16518a6.00632,6.00632,0,0,1,7.84258-3.23856l38.6424,16.05527a6.00634,6.00634,0,0,1,3.23855,7.84259l-.8996,2.16518A6.00632,6.00632,0,0,1,564.38028,494.28148Z" transform="translate(-357.08314 -208.25)" fill="#808080"/><path d="M553.01334,521.63984l-38.6424-16.05527a6.00633,6.00633,0,0,1-3.23855-7.84259l.89959-2.16518a6.00634,6.00634,0,0,1,7.84259-3.23856L558.517,508.39351a6.00633,6.00633,0,0,1,3.23856,7.84258l-.8996,2.16519A6.00632,6.00632,0,0,1,553.01334,521.63984Z" transform="translate(-357.08314 -208.25)" fill="#808080"/><path d="M579.86437,455.832a4.48944,4.48944,0,0,1-1.68725-.33057l-38.938-15.74267a4.50518,4.50518,0,0,1-2.48535-5.8584l2.99878-7.417a4.50027,4.50027,0,0,1,5.85864-2.48486l38.938,15.74267a4.50518,4.50518,0,0,1,2.48535,5.8584l-2.99878,7.417a4.51079,4.51079,0,0,1-4.17139,2.81543Z" transform="translate(-357.08314 -208.25)" fill="#ccc"/><path d="M498.08314,691.75h-140a1,1,0,1,1,0-2h140a1,1,0,0,1,0,2Z" transform="translate(-357.08314 -208.25)" fill="#ccc"/></svg>`;
export const SVG_Z = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 245.487 113.9115"><g transform="translate(15.9581 -70.1437)"><path fill="#f2f2f2" d="M181.8672 183.796H88.3134v-54.8973l-.43-.2765 15.1857-14.7907a41.4878 41.4878 0 0 1 28.6939-11.8174l27.916-.2551.04.0477 22.2131 26.426-.0655.7316z" style="stroke-width:.264583"/><path fill="#fff" d="M105.9334 112.1178h55.9519v.5292h-55.9519zM100.3772 117.6741h55.9519v.5292h-55.9519z" style="stroke-width:.264583"/><path fill="#fff" d="M178.6826 154.0514h10.1706v8.9897h-10.1706z" data-name="Rectangle 371" style="stroke-width:.264583"/><path fill="#fff" d="M178.6826 138.4916h10.1706v8.8471h-10.1706z" data-name="Rectangle 372" style="stroke-width:.264583"/><path fill="#f2f2f2" d="M166.653 102.649h9.1202v31.5648h-9.1202z" style="stroke-width:.264583"/><path fill="#e6e6e6" d="M181.8672 183.7957h-50.0656v-36.3798a35.3975 35.3975 0 0 1 8.4588-22.9515l19.3804-22.7213 22.2264 26.4599z" style="stroke-width:.264583"/><path fill="#fff" d="M155.3064 156.4369h10.1706v8.9897h-10.1706z" data-name="Rectangle 374" style="stroke-width:.264583"/><path fill="#fff" d="M155.3064 140.8768h10.1706v8.8471h-10.1706z" data-name="Rectangle 375" style="stroke-width:.264583"/><path fill="#fff" d="M106.7252 154.0514h10.1706v8.9897h-10.1706z" data-name="Rectangle 378" style="stroke-width:.264583"/><path fill="#fff" d="M106.7252 138.4916h10.1706v8.8471h-10.1706z" data-name="Rectangle 379" style="stroke-width:.264583"/><path fill="#f2f2f2" d="M91.7626 85.332h11.0675v38.3117H91.7626z" style="stroke-width:.264583"/><path fill="#f2f2f2" d="M110.199 183.7954H-3.295v-66.6167l-.5047-.325.119-.116 20.73-20.1916A41.863 41.863 0 0 1 46.0038 84.621l37.2782-.3406.0402.0477 26.9535 32.0651-.0773.8764z" style="stroke-width:.264583"/><path fill="#e6e6e6" d="M110.199 183.7954H49.4881V134.88a29.9322 29.9322 0 0 1 7.1528-19.408l26.6087-31.1956 26.9492 32.0815Z" style="stroke-width:.264583"/><path fill="#fff" d="M80.3413 150.6172h9.8174v8.6775h-9.8174zM80.3413 135.5359h9.8174v8.6775h-9.8174z" data-name="Rectangle 381" style="stroke-width:.264583"/><path fill="#fff" d="M19.0243 147.7216H31.369v10.9112H19.0243z" data-name="Rectangle 385" style="stroke-width:.264583"/><path fill="#fff" d="M19.0243 128.8356H31.369v10.7381H19.0243z" data-name="Rectangle 386" style="stroke-width:.264583"/><ellipse cx="20.8891" cy="154.324" fill="#3f3d56" data-name="Ellipse 519" rx="8.7979" ry="17.9515" style="stroke-width:.264583"/><path fill="#808080" d="M21.7016 183.7075c-3.5237-21.1402-.0354-42.2063 0-42.4164l.6856.1162c-.0355.209-3.5036 21.1635 0 42.1862z" data-name="Path 2702" style="fill:#999;stroke-width:.264583"/><path fill="#808080" d="M-54.7406 146.1809h9.0223v.6953h-9.0223z" data-name="Rectangle 388" style="fill:#b3b3b3;stroke-width:.264583" transform="rotate(-28.142)"/><path fill="#808080" d="M-129.2795 83.128h.6953v9.0226h-.6953z" data-name="Rectangle 389" style="fill:#b3b3b3;stroke-width:.264583" transform="rotate(-61.842)"/><ellipse cx="-.4146" cy="141.6901" fill="#808080" data-name="Ellipse 520" rx="12.6968" ry="25.9067" style="fill:#333;stroke-width:.264583"/><path fill="#3f3d56" d="M.9996 184.0552c-5.0784-30.47-.0514-60.829 0-61.1323l.5056.0857c-.0513.3025-5.0636 30.5798 0 60.9624z" data-name="Path 2703" style="fill:#e6e6e6;stroke-width:.264583"/><path fill="#3f3d56" d="M-67.7316 125.3486h13.0209v.513h-13.0209z" data-name="Rectangle 390" style="fill:#ccc;stroke-width:.264583" transform="rotate(-28.142)"/><path fill="#3f3d56" d="M-129.3145 54.7885h.513v13.0209h-.513z" data-name="Rectangle 391" style="fill:#b3b3b3;stroke-width:.264583" transform="rotate(-61.842)"/><path fill="#3f3d56" d="m159.149 89.5463 2.7831-2.2262c-2.1621-.2381-3.0506.9406-3.413 1.874-1.6892-.7014-3.5283.2178-3.5283.2178l5.5687 2.0217a4.2137 4.2137 0 0 0-1.4097-1.8876z" data-name="Path 2708" style="stroke-width:.264583"/><path fill="#3f3d56" d="m108.853 72.401 2.7831-2.2262c-2.1621-.2381-3.0506.9406-3.413 1.874-1.6892-.7013-3.5283.2178-3.5283.2178l5.5687 2.0217a4.214 4.214 0 0 0-1.4105-1.8873z" data-name="Path 2709" style="stroke-width:.264583"/><path fill="#3f3d56" d="m178.9044 76.546 2.7831-2.2262c-2.1622-.2381-3.0506.9406-3.4131 1.874-1.6891-.7014-3.5282.2178-3.5282.2178l5.5687 2.0217a4.2138 4.2138 0 0 0-1.4097-1.8876z" data-name="Path 2710" style="stroke-width:.264583"/><path fill="#3f3d56" d="M60.5922 179.896a4.2088 4.2088 0 0 0-2.1077.5656 4.5297 4.5297 0 0 0-7.567 3.365h13.8924a4.2299 4.2299 0 0 0-4.2174-3.9304z" data-name="Path 2712" style="stroke-width:.264583"/><path fill="#3f3d56" d="M132.852 179.896a4.2088 4.2088 0 0 0-2.1076.5656 4.5297 4.5297 0 0 0-7.5671 3.365h13.8925a4.2299 4.2299 0 0 0-4.2178-3.9307z" data-name="Path 2713" style="stroke-width:.264583"/><g fill="#3f3d56" data-name="Group 204"><path d="M97.2576 176.8633H77.5234v.6366h3.0777v6.0476h.6365v-6.0476H93.225v6.0476h.6365v-6.0476h3.396z" data-name="Path 2714"/><path d="M77.5623 174.9588h19.7342v.6366H77.5623z" data-name="Rectangle 400"/><path d="M77.5623 173.3674h19.7342v.6365H77.5623z" data-name="Rectangle 401"/></g><ellipse cx="215.2396" cy="158.3491" fill="#e6e6e6" data-name="Ellipse 525" rx="7.7041" ry="15.7197" style="stroke-width:.264583"/><path fill="#3f3d56" d="M214.3815 184.0552c3.0816-18.4886.031-36.9094 0-37.0946l-.3069.053c.031.1833 3.0726 18.5551 0 36.9908z" data-name="Path 2716" style="stroke-width:.264583"/><path fill="#3f3d56" d="M-38.7353 256.9106h.3115v7.9035h-.3115z" data-name="Rectangle 406" style="stroke-width:.264583" transform="rotate(-61.847)"/><path fill="#3f3d56" d="M114.2645 243.4071h7.9035v.3115h-7.9035z" data-name="Rectangle 407" style="stroke-width:.264583" transform="rotate(-28.153)"/><g fill="#3f3d56" data-name="Group 205"><path d="M169.5172 176.8633H149.783v.6366h3.0776v6.0476h.6366v-6.0476h11.9872v6.0476h.6366v-6.0476h3.396z" data-name="Path 2714-2"/><path d="M149.8219 174.9588h19.7342v.6366h-19.7342z" data-name="Rectangle 400-2"/><path d="M149.8219 173.3674h19.7342v.6365h-19.7342z" data-name="Rectangle 401-2"/></g><path fill="#f2f2f2" d="m90.2625 105.5306-2.3728-5.5049-4.763.085-2.8892 5.488.0583.0732h-.0208v11.4152h9.981v-11.4153zM164.4423 119.3093l-1.9175-4.0238-3.849.062-2.3348 4.0115.0471.0535h-.0168v8.3438h8.0658v-8.3438z" data-name="Path 2700" style="stroke-width:.264583"/><path fill="#fff" d="M10.3066 102.6488h55.9519v.5292H10.3066zM10.3066 103.178h55.9519v.5292H10.3066zM166.653 104.181h9.1202v.5292h-9.1202zM166.653 109.7372h9.1202v.5292h-9.1202zM91.7626 87.2476h11.0675v.5292H91.7626zM91.7626 92.8039h11.0675v.5292H91.7626z" style="stroke-width:.264583"/></g></svg>`;
const Intro = ({ navigation, route }) => {
- const colors = useThemeStore(state => state.colors);
- const introCompleted = useSettingStore(state => state.settings.introCompleted);
- const isTelemetryEnabled = useSettingStore(state => state.settings.telemetry);
+ const colors = useThemeStore((state) => state.colors);
+ const introCompleted = useSettingStore(
+ (state) => state.settings.introCompleted
+ );
+ const isTelemetryEnabled = useSettingStore(
+ (state) => state.settings.telemetry
+ );
const { height } = useWindowDimensions();
const insets = useSafeAreaInsets();
useNavigationFocus(navigation, {
@@ -35,7 +45,7 @@ const Intro = ({ navigation, route }) => {
useEffect(() => {
if (!introCompleted) {
- umami.pageView('/welcome', '', []);
+ umami.pageView("/welcome", "", []);
}
}, [introCompleted]);
@@ -43,27 +53,27 @@ const Intro = ({ navigation, route }) => {
<View
testID="notesnook.splashscreen"
style={{
- width: '100%',
- height: '100%',
- justifyContent: 'center',
- alignItems: 'center',
+ width: "100%",
+ height: "100%",
+ justifyContent: "center",
+ alignItems: "center",
marginTop: insets.top
}}
>
<Image
- source={require('../../assets/images/notesnook.png')}
+ source={require("../../assets/images/notesnook.png")}
style={{
width: 40,
height: 40,
- position: 'absolute',
+ position: "absolute",
top: 0
}}
/>
<View
style={{
flexGrow: 1,
- alignItems: 'center',
- justifyContent: 'center',
+ alignItems: "center",
+ justifyContent: "center",
marginBottom: 100
}}
>
@@ -77,7 +87,7 @@ const Intro = ({ navigation, route }) => {
style={{
marginTop: 40,
marginBottom: 20,
- maxWidth: '80%',
+ maxWidth: "80%",
opacity: 0.8
}}
>
@@ -90,21 +100,21 @@ const Intro = ({ navigation, route }) => {
<View
style={{
- width: '100%',
+ width: "100%",
zIndex: 20,
- position: 'absolute',
+ position: "absolute",
bottom: height / 10
}}
>
<TouchableOpacity
activeOpacity={1}
style={{
- flexDirection: 'row',
- alignSelf: 'center',
- width: '90%',
+ flexDirection: "row",
+ alignSelf: "center",
+ width: "90%",
marginBottom: 12,
paddingHorizontal: 12,
- justifyContent: 'center',
+ justifyContent: "center",
padding: 12,
maxWidth: 500
}}
@@ -114,7 +124,9 @@ const Intro = ({ navigation, route }) => {
>
<Icon
size={SIZE.lg}
- name={isTelemetryEnabled ? 'checkbox-marked' : 'checkbox-blank-outline'}
+ name={
+ isTelemetryEnabled ? "checkbox-marked" : "checkbox-blank-outline"
+ }
color={isTelemetryEnabled ? colors.accent : colors.icon}
/>
@@ -125,7 +137,7 @@ const Intro = ({ navigation, route }) => {
}}
size={SIZE.md}
>
- Help improve Notesnook by sending completely anonymized{' '}
+ Help improve Notesnook by sending completely anonymized{" "}
<Heading size={SIZE.md}>private analytics and bug reports.</Heading>
</Paragraph>
</TouchableOpacity>
@@ -135,15 +147,15 @@ const Intro = ({ navigation, route }) => {
height={45}
width={250}
onPress={async () => {
- navigation.navigate('AppLock', {
+ navigation.navigate("AppLock", {
welcome: true
});
- umami.pageView('/home', '/welcome');
+ umami.pageView("/home", "/welcome");
}}
style={{
paddingHorizontal: 24,
- alignSelf: 'center',
+ alignSelf: "center",
borderRadius: 100,
...getElevation(5)
}}
@@ -154,15 +166,15 @@ const Intro = ({ navigation, route }) => {
<BouncingView
style={{
- position: 'absolute',
+ position: "absolute",
bottom: DDS.isTab ? -300 : -100,
zIndex: -1
}}
duration={3000}
>
<SvgView
- width={Dimensions.get('window').width}
- height={Dimensions.get('window').width}
+ width={Dimensions.get("window").width}
+ height={Dimensions.get("window").width}
src={SVG_Z}
/>
</BouncingView>
diff --git a/apps/mobile/app/components/intro/welcome.js b/apps/mobile/app/components/intro/welcome.js
index 7f02ce531..17baf67c0 100644
--- a/apps/mobile/app/components/intro/welcome.js
+++ b/apps/mobile/app/components/intro/welcome.js
@@ -1,33 +1,33 @@
-import React from 'react';
-import Animated, { FadeInDown } from 'react-native-reanimated';
-import { DDS } from '../../services/device-detection';
-import { eSendEvent } from '../../services/event-manager';
-import Navigation from '../../services/navigation';
-import SettingsService from '../../services/settings';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { getElevation } from '../../utils';
-import umami from '../../common/analytics';
-import { eOpenLoginDialog } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { AuthMode } from '../auth';
-import { Button } from '../ui/button';
-import { SvgView } from '../ui/svg';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-const IMAGE = color =>
+import React from "react";
+import Animated, { FadeInDown } from "react-native-reanimated";
+import { DDS } from "../../services/device-detection";
+import { eSendEvent } from "../../services/event-manager";
+import Navigation from "../../services/navigation";
+import SettingsService from "../../services/settings";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { getElevation } from "../../utils";
+import umami from "../../common/analytics";
+import { eOpenLoginDialog } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { AuthMode } from "../auth";
+import { Button } from "../ui/button";
+import { SvgView } from "../ui/svg";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+const IMAGE = (color) =>
`<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" width="1100.50064" height="691.70682" viewBox="0 0 1100.50064 691.70682" xmlns:xlink="http://www.w3.org/1999/xlink"><title>two_factor_authentication</title><path d="M1150.25032,388.23743h-1.85859V337.32194a29.4685,29.4685,0,0,0-29.46859-29.46853H1011.05186a29.4685,29.4685,0,0,0-29.46859,29.46853V616.64827a29.46851,29.46851,0,0,0,29.46859,29.46854h107.87128a29.46851,29.46851,0,0,0,29.46859-29.46854V424.47994h1.85859Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><path d="M1142.121,339.05342v278.92a22.01111,22.01111,0,0,1-22.01,22.01h-108.39a22.00248,22.00248,0,0,1-22-22.01v-278.92a22.00031,22.00031,0,0,1,22-22h13.15a10.4608,10.4608,0,0,0,9.68,14.4h61.8a10.44027,10.44027,0,0,0,9.67993-14.4H1120.111A22.00894,22.00894,0,0,1,1142.121,339.05342Z" transform="translate(-49.74968 -104.14659)" fill="#d0cde1"/><rect x="945.85129" y="355.70682" width="126" height="34" fill="${color}"/><path d="M1126.601,487.85341h-122a3.00328,3.00328,0,0,1-3-3v-30a3.00328,3.00328,0,0,1,3-3h122a3.00328,3.00328,0,0,1,3,3v30A3.00328,3.00328,0,0,1,1126.601,487.85341Zm-122-34a1.001,1.001,0,0,0-1,1v30a1.00067,1.00067,0,0,0,1,1h122a1.00067,1.00067,0,0,0,1-1v-30a1.001,1.001,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="959.85129" y="374.70682" width="16" height="2" fill="#3f3d56"/><rect x="981.85129" y="374.70682" width="16" height="2" fill="#3f3d56"/><rect x="1003.85129" y="374.70682" width="16" height="2" fill="#3f3d56"/><rect x="1025.85129" y="374.70682" width="16" height="2" fill="#3f3d56"/><rect x="1047.85129" y="374.70682" width="16" height="2" fill="#3f3d56"/><path d="M1142.121,589.61342v28.36a22.01111,22.01111,0,0,1-22.01,22.01h-108.39a22.00248,22.00248,0,0,1-22-22.01v-130.46Z" transform="translate(-49.74968 -104.14659)" opacity="0.1"/><rect x="99.85129" y="459.70682" width="473" height="232" fill="#d0cde1"/><path d="M502.351,795.85341H151.601a2.00591,2.00591,0,0,1-2-2v-228a2.00587,2.00587,0,0,1,2-2h4.44Z" transform="translate(-49.74968 -104.14659)" opacity="0.1"/><rect x="318.85129" y="490.70682" width="732.99951" height="2" fill="#3f3d56"/><path d="M600.34268,108.46435H390.853v-4.31776H295.86217v4.31776H85.5089a14.17039,14.17039,0,0,0-14.1704,14.1704V409.4906a14.17043,14.17043,0,0,0,14.1704,14.17045H600.34268a14.17044,14.17044,0,0,0,14.1704-14.17045V122.63475A14.17039,14.17039,0,0,0,600.34268,108.46435Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="40.59128" y="29.35679" width="505.16998" height="284.98004" fill="#d0cde1"/><circle cx="292.74433" cy="16.4075" r="5.18132" fill="${color}"/><path d="M240.601,239.85341h-12a3.00328,3.00328,0,0,1-3-3v-12a3.00328,3.00328,0,0,1,3-3h12a3.00328,3.00328,0,0,1,3,3v12A3.00328,3.00328,0,0,1,240.601,239.85341Zm-12-16a1.0013,1.0013,0,0,0-1,1v12a1.0013,1.0013,0,0,0,1,1h12a1.0013,1.0013,0,0,0,1-1v-12a1.0013,1.0013,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="176.85129" y="133.70682" width="228" height="2" fill="#3f3d56"/><rect x="345.85129" y="188.70682" width="53" height="16" fill="${color}"/><path d="M452.601,304.85341h-49a3.00328,3.00328,0,0,1-3-3v-12a3.00328,3.00328,0,0,1,3-3h49a3.00328,3.00328,0,0,1,3,3v12A3.00328,3.00328,0,0,1,452.601,304.85341Zm-49-16a1.0013,1.0013,0,0,0-1,1v12a1.0013,1.0013,0,0,0,1,1h49a1.0013,1.0013,0,0,0,1-1v-12a1.0013,1.0013,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="703.85129" y="206.70682" width="100" height="70" fill="${color}"/><path d="M863.601,375.35341h-96a4.00427,4.00427,0,0,1-4-4v-66a4.00427,4.00427,0,0,1,4-4h96a4.00426,4.00426,0,0,1,4,4v66A4.00426,4.00426,0,0,1,863.601,375.35341Zm-96-70v66H863.6039l-.00293-66Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><path d="M852.601,302.85341h-4a33,33,0,1,0-66,0h-4a37,37,0,1,1,74,0Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><path d="M825.601,330.35341a10.00023,10.00023,0,1,0-15.29412,8.47258V349.5593a5.29411,5.29411,0,0,0,5.29412,5.29411h0a5.29411,5.29411,0,0,0,5.29411-5.29411V338.826A9.98327,9.98327,0,0,0,825.601,330.35341Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="284.35129" y="562.70682" width="16" height="2" fill="#3f3d56"/><rect x="306.35129" y="562.70682" width="16" height="2" fill="#3f3d56"/><rect x="328.35129" y="562.70682" width="16" height="2" fill="#3f3d56"/><rect x="350.35129" y="562.70682" width="16" height="2" fill="#3f3d56"/><rect x="372.35129" y="562.70682" width="16" height="2" fill="#3f3d56"/><path d="M643.60059,778.85352H174.60107a4.00428,4.00428,0,0,1-4-4v-228a4.00427,4.00427,0,0,1,4-4H643.60059a4.004,4.004,0,0,1,4,4v228A4.004,4.004,0,0,1,643.60059,778.85352Zm-468.99952-232v228H643.60352l-.00293-228Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><circle cx="145.85129" cy="470.70682" r="6" fill="#3f3d56"/><circle cx="166.85129" cy="470.70682" r="6" fill="#3f3d56"/><circle cx="187.85129" cy="470.70682" r="6" fill="#3f3d56"/><path d="M453.601,680.85341h-135a3.00328,3.00328,0,0,1-3-3v-34a3.00328,3.00328,0,0,1,3-3h135a3.00328,3.00328,0,0,1,3,3v34A3.00328,3.00328,0,0,1,453.601,680.85341Zm-135-38a1.001,1.001,0,0,0-1,1v34a1.001,1.001,0,0,0,1,1h135a1.001,1.001,0,0,0,1-1v-34a1.001,1.001,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><circle cx="437.85129" cy="559.70682" r="18" fill="${color}"/><path d="M493.601,679.85341a19,19,0,1,1,19-19A19.02162,19.02162,0,0,1,493.601,679.85341Zm0-36a17,17,0,1,0,17,17A17.019,17.019,0,0,0,493.601,643.85341Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><polygon points="444.118 563.803 434.437 554.121 437.265 551.293 443.584 557.611 461.216 532.555 464.487 534.858 444.118 563.803" fill="#3f3d56"/><polygon points="433.761 314.337 40.591 314.337 40.591 50.947 433.761 314.337" opacity="0.1"/><path d="M628.69739,413.2984H579.39527v-3.55218a.7043.7043,0,0,0-.70431-.70432H561.78737a.70429.70429,0,0,0-.70431.70432v3.55218H550.51832v-3.55218a.7043.7043,0,0,0-.70432-.70432H532.91042a.7043.7043,0,0,0-.70432.70432v3.55218H521.64136v-3.55218a.70429.70429,0,0,0-.70431-.70432H504.03347a.7043.7043,0,0,0-.70432.70432v3.55218H492.76441v-3.55218a.7043.7043,0,0,0-.70432-.70432H475.15651a.70429.70429,0,0,0-.70431.70432v3.55218H463.88746v-3.55218a.7043.7043,0,0,0-.70432-.70432H446.27956a.7043.7043,0,0,0-.70432.70432v3.55218H435.0105v-3.55218a.70429.70429,0,0,0-.70431-.70432H417.4026a.7043.7043,0,0,0-.70431.70432v3.55218H406.13355v-3.55218a.7043.7043,0,0,0-.70432-.70432H273.01784a.7043.7043,0,0,0-.70432.70432v3.55218H261.74878v-3.55218a.7043.7043,0,0,0-.70432-.70432H244.14088a.70429.70429,0,0,0-.70431.70432v3.55218H232.87183v-3.55218a.7043.7043,0,0,0-.70432-.70432H215.26393a.7043.7043,0,0,0-.70432.70432v3.55218H203.99487v-3.55218a.70429.70429,0,0,0-.70431-.70432H186.387a.7043.7043,0,0,0-.70431.70432v3.55218H175.11792v-3.55218a.7043.7043,0,0,0-.70432-.70432H157.51a.7043.7043,0,0,0-.70432.70432v3.55218H146.241v-3.55218a.7043.7043,0,0,0-.70432-.70432H128.63307a.7043.7043,0,0,0-.70432.70432v3.55218H117.364v-3.55218a.7043.7043,0,0,0-.70431-.70432H99.75611a.70429.70429,0,0,0-.70431.70432v3.55218H66.65326A16.90359,16.90359,0,0,0,49.74968,430.202v7.6434a16.90358,16.90358,0,0,0,16.90358,16.90354H628.69739A16.90358,16.90358,0,0,0,645.601,437.84539V430.202A16.90359,16.90359,0,0,0,628.69739,413.2984Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><path d="M474.601,321.85341h-264a3.00328,3.00328,0,0,1-3-3v-110a3.00328,3.00328,0,0,1,3-3h264a3.00328,3.00328,0,0,1,3,3v110A3.00328,3.00328,0,0,1,474.601,321.85341Zm-264-114a1.0013,1.0013,0,0,0-1,1v110a1.0013,1.0013,0,0,0,1,1h264a1.0013,1.0013,0,0,0,1-1v-110a1.0013,1.0013,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><path d="M240.601,269.85341h-12a3.00328,3.00328,0,0,1-3-3v-12a3.00328,3.00328,0,0,1,3-3h12a3.00328,3.00328,0,0,1,3,3v12A3.00328,3.00328,0,0,1,240.601,269.85341Zm-12-16a1.0013,1.0013,0,0,0-1,1v12a1.0013,1.0013,0,0,0,1,1h12a1.0013,1.0013,0,0,0,1-1v-12a1.0013,1.0013,0,0,0-1-1Z" transform="translate(-49.74968 -104.14659)" fill="#3f3d56"/><rect x="176.85129" y="163.70682" width="228" height="2" fill="#3f3d56"/><rect x="264.85129" y="269.70682" width="732.99951" height="2" fill="#3f3d56"/><circle cx="264.85129" cy="269.70682" r="14" fill="#3f3d56"/><circle cx="997.85129" cy="271.70682" r="11" fill="#3f3d56"/><circle cx="1051.85129" cy="492.70682" r="11" fill="#3f3d56"/><circle cx="321.85129" cy="492.70682" r="11" fill="#3f3d56"/></svg>`;
export const WelcomeNotice = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<Animated.View
entering={FadeInDown}
style={{
padding: 12,
- alignItems: 'center',
- justifyContent: 'center',
- width: DDS.isTab ? '50%' : '95%',
- alignSelf: 'center'
+ alignItems: "center",
+ justifyContent: "center",
+ width: DDS.isTab ? "50%" : "95%",
+ alignSelf: "center"
}}
>
<SvgView width={200} height={200} src={IMAGE(colors.accent)} />
@@ -35,13 +35,13 @@ export const WelcomeNotice = () => {
<Heading>100% encrypted notes</Heading>
<Paragraph
style={{
- textAlign: 'center',
- width: '90%'
+ textAlign: "center",
+ width: "90%"
}}
size={SIZE.md}
>
- Notesnook encrypts everything on your device before syncing. This means that no one can read
- your notes except you. Not even us.
+ Notesnook encrypts everything on your device before syncing. This means
+ that no one can read your notes except you. Not even us.
</Paragraph>
<Button
@@ -56,18 +56,18 @@ export const WelcomeNotice = () => {
});
Navigation.replace(
{
- name: 'Notes'
+ name: "Notes"
},
{
canGoBack: false
}
);
}, 1000);
- umami.pageView('/encryptionnotice', '/welcome/privacymode');
+ umami.pageView("/encryptionnotice", "/welcome/privacymode");
}}
style={{
paddingHorizontal: 24,
- alignSelf: 'center',
+ alignSelf: "center",
borderRadius: 100,
...getElevation(5),
marginTop: 30
diff --git a/apps/mobile/app/components/launcher/index.js b/apps/mobile/app/components/launcher/index.js
index d5783c7f0..c768f3c3f 100644
--- a/apps/mobile/app/components/launcher/index.js
+++ b/apps/mobile/app/components/launcher/index.js
@@ -1,55 +1,61 @@
-import React, { useEffect, useRef } from 'react';
-import { Platform, View } from 'react-native';
-import RNBootSplash from 'react-native-bootsplash';
-import { checkVersion } from 'react-native-check-version';
-import { enabled } from 'react-native-privacy-snapshot';
-import { editorState } from '../../screens/editor/tiptap/utils';
-import BackupService from '../../services/backup';
-import BiometricService from '../../services/biometrics';
-import { DDS } from '../../services/device-detection';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
-import { setRateAppMessage } from '../../services/message';
-import PremiumService from '../../services/premium';
-import SettingsService from '../../services/settings';
-import { initialize } from '../../stores';
-import { useMessageStore } from '../../stores/use-message-store';
-import { useNoteStore } from '../../stores/use-notes-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useUserStore } from '../../stores/use-user-store';
-import { DatabaseLogger, db, loadDatabase } from '../../common/database';
-import { MMKV } from '../../common/database/mmkv';
-import { eOpenAnnouncementDialog } from '../../utils/events';
-import { tabBarRef } from '../../utils/global-refs';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { SVG } from '../auth/background';
-import Migrate from '../sheets/migrate';
-import NewFeature from '../sheets/new-feature/index';
-import { Update } from '../sheets/update';
-import { Button } from '../ui/button';
-import { IconButton } from '../ui/icon-button';
-import Input from '../ui/input';
-import Seperator from '../ui/seperator';
-import { SvgView } from '../ui/svg';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { Walkthrough } from '../walkthroughs';
-import { useAppState } from '../../hooks/use-app-state';
+import React, { useEffect, useRef } from "react";
+import { Platform, View } from "react-native";
+import RNBootSplash from "react-native-bootsplash";
+import { checkVersion } from "react-native-check-version";
+import { enabled } from "react-native-privacy-snapshot";
+import { editorState } from "../../screens/editor/tiptap/utils";
+import BackupService from "../../services/backup";
+import BiometricService from "../../services/biometrics";
+import { DDS } from "../../services/device-detection";
+import {
+ eSendEvent,
+ presentSheet,
+ ToastEvent
+} from "../../services/event-manager";
+import { setRateAppMessage } from "../../services/message";
+import PremiumService from "../../services/premium";
+import SettingsService from "../../services/settings";
+import { initialize } from "../../stores";
+import { useMessageStore } from "../../stores/use-message-store";
+import { useNoteStore } from "../../stores/use-notes-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useUserStore } from "../../stores/use-user-store";
+import { DatabaseLogger, db, loadDatabase } from "../../common/database";
+import { MMKV } from "../../common/database/mmkv";
+import { eOpenAnnouncementDialog } from "../../utils/events";
+import { tabBarRef } from "../../utils/global-refs";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { SVG } from "../auth/background";
+import Migrate from "../sheets/migrate";
+import NewFeature from "../sheets/new-feature/index";
+import { Update } from "../sheets/update";
+import { Button } from "../ui/button";
+import { IconButton } from "../ui/icon-button";
+import Input from "../ui/input";
+import Seperator from "../ui/seperator";
+import { SvgView } from "../ui/svg";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { Walkthrough } from "../walkthroughs";
+import { useAppState } from "../../hooks/use-app-state";
const Launcher = React.memo(
() => {
- const colors = useThemeStore(state => state.colors);
- const setLoading = useNoteStore(state => state.setLoading);
- const loading = useNoteStore(state => state.loading);
- const user = useUserStore(state => state.user);
- const verifyUser = useUserStore(state => state.verifyUser);
- const setVerifyUser = useUserStore(state => state.setVerifyUser);
- const deviceMode = useSettingStore(state => state.deviceMode);
+ const colors = useThemeStore((state) => state.colors);
+ const setLoading = useNoteStore((state) => state.setLoading);
+ const loading = useNoteStore((state) => state.loading);
+ const user = useUserStore((state) => state.user);
+ const verifyUser = useUserStore((state) => state.verifyUser);
+ const setVerifyUser = useUserStore((state) => state.setVerifyUser);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
const appState = useAppState();
const passwordInputRef = useRef();
const password = useRef();
- const introCompleted = useSettingStore(state => state.settings.introCompleted);
+ const introCompleted = useSettingStore(
+ (state) => state.settings.introCompleted
+ );
const dbInitCompleted = useRef(false);
const loadNotes = async () => {
if (verifyUser) {
@@ -76,7 +82,7 @@ const Launcher = React.memo(
if (!dbInitCompleted.current) {
await RNBootSplash.hide({ fade: true });
await loadDatabase();
- DatabaseLogger.info('Initializing database');
+ DatabaseLogger.info("Initializing database");
await db.init();
dbInitCompleted.current = true;
}
@@ -115,16 +121,20 @@ const Launcher = React.memo(
const doAppLoadActions = async () => {
await sleep(500);
if (SettingsService.get().sessionExpired) {
- eSendEvent('session_expired');
+ eSendEvent("session_expired");
return;
}
const user = await db.user.getUser();
await useMessageStore.getState().setAnnouncement();
if (PremiumService.get() && user) {
- if (SettingsService.get().reminder === 'off') {
- SettingsService.set({ reminder: 'daily' });
+ if (SettingsService.get().reminder === "off") {
+ SettingsService.set({ reminder: "daily" });
}
- if (await BackupService.checkBackupRequired(SettingsService.get().reminder)) {
+ if (
+ await BackupService.checkBackupRequired(
+ SettingsService.get().reminder
+ )
+ ) {
sleep(2000).then(() => BackupService.run());
}
}
@@ -135,7 +145,7 @@ const Launcher = React.memo(
if (await PremiumService.getRemainingTrialDaysStatus()) return;
if (introCompleted) {
- useMessageStore.subscribe(state => {
+ useMessageStore.subscribe((state) => {
let dialogs = state.dialogs;
if (dialogs.length > 0) {
eSendEvent(eOpenAnnouncementDialog, dialogs[0]);
@@ -150,7 +160,7 @@ const Launcher = React.memo(
const version = await checkVersion();
if (!version.needsUpdate) return false;
presentSheet({
- component: ref => <Update version={version} fwdRef={ref} />
+ component: (ref) => <Update version={version} fwdRef={ref} />
});
return true;
} catch (e) {
@@ -159,7 +169,7 @@ const Launcher = React.memo(
};
const restoreEditorState = async () => {
- let appState = MMKV.getString('appState');
+ let appState = MMKV.getString("appState");
if (appState) {
appState = JSON.parse(appState);
if (
@@ -174,14 +184,18 @@ const Launcher = React.memo(
if (!DDS.isTab) {
tabBarRef.current?.goToPage(1);
}
- eSendEvent('loadingNote', appState.note);
+ eSendEvent("loadingNote", appState.note);
}
}
};
const checkForRateAppRequest = async () => {
let rateApp = SettingsService.get().rateApp;
- if (rateApp && rateApp < Date.now() && !useMessageStore.getState().message?.visible) {
+ if (
+ rateApp &&
+ rateApp < Date.now() &&
+ !useMessageStore.getState().message?.visible
+ ) {
setRateAppMessage();
return false;
}
@@ -208,12 +222,15 @@ const Launcher = React.memo(
const onUnlockBiometrics = async () => {
if (!(await BiometricService.isBiometryAvailable())) {
ToastEvent.show({
- heading: 'Biometrics unavailable',
- message: 'Try unlocking the app with your account password'
+ heading: "Biometrics unavailable",
+ message: "Try unlocking the app with your account password"
});
return;
}
- let verified = await BiometricService.validateUser('Unlock to access your notes', '');
+ let verified = await BiometricService.validateUser(
+ "Unlock to access your notes",
+ ""
+ );
if (verified) {
setVerifyUser(false);
enabled(false);
@@ -226,7 +243,7 @@ const Launcher = React.memo(
}, [verifyUser]);
useEffect(() => {
- if (verifyUser && appState === 'active') {
+ if (verifyUser && appState === "active") {
onUnlockBiometrics();
}
}, [appState]);
@@ -247,30 +264,35 @@ const Launcher = React.memo(
<View
style={{
backgroundColor: colors.bg,
- width: '100%',
- height: '100%',
- position: 'absolute',
+ width: "100%",
+ height: "100%",
+ position: "absolute",
zIndex: 999
}}
>
<View
style={{
height: 250,
- overflow: 'hidden'
+ overflow: "hidden"
}}
>
- <SvgView src={SVG(colors.night ? 'white' : 'black')} height={700} />
+ <SvgView src={SVG(colors.night ? "white" : "black")} height={700} />
</View>
<View
style={{
flex: 1,
- justifyContent: 'center',
- width: deviceMode !== 'mobile' ? '50%' : Platform.OS == 'ios' ? '95%' : '100%',
+ justifyContent: "center",
+ width:
+ deviceMode !== "mobile"
+ ? "50%"
+ : Platform.OS == "ios"
+ ? "95%"
+ : "100%",
paddingHorizontal: 12,
marginBottom: 30,
marginTop: 15,
- alignSelf: 'center'
+ alignSelf: "center"
}}
>
<IconButton
@@ -288,8 +310,8 @@ const Launcher = React.memo(
<Heading
color={colors.heading}
style={{
- alignSelf: 'center',
- textAlign: 'center'
+ alignSelf: "center",
+ textAlign: "center"
}}
>
Unlock to access your notes
@@ -297,10 +319,10 @@ const Launcher = React.memo(
<Paragraph
style={{
- alignSelf: 'center',
- textAlign: 'center',
+ alignSelf: "center",
+ textAlign: "center",
fontSize: SIZE.md,
- maxWidth: '90%'
+ maxWidth: "90%"
}}
>
Please verify it's you
@@ -308,7 +330,7 @@ const Launcher = React.memo(
<Seperator />
<View
style={{
- width: '100%',
+ width: "100%",
padding: 12,
backgroundColor: colors.bg,
flexGrow: 1
@@ -320,7 +342,7 @@ const Launcher = React.memo(
fwdRef={passwordInputRef}
secureTextEntry
placeholder="Enter account password"
- onChangeText={v => (password.current = v)}
+ onChangeText={(v) => (password.current = v)}
onSubmit={onSubmit}
/>
</>
@@ -356,8 +378,8 @@ const Launcher = React.memo(
borderRadius: 100
}}
onPress={onUnlockBiometrics}
- icon={'fingerprint'}
- type={user ? 'grayAccent' : 'accent'}
+ icon={"fingerprint"}
+ type={user ? "grayAccent" : "accent"}
fontSize={SIZE.md}
/>
</View>
diff --git a/apps/mobile/app/components/list-items/footer/index.js b/apps/mobile/app/components/list-items/footer/index.js
index 2c66c98a2..9d747cff9 100644
--- a/apps/mobile/app/components/list-items/footer/index.js
+++ b/apps/mobile/app/components/list-items/footer/index.js
@@ -1,5 +1,5 @@
-import React from 'react';
-import { View } from 'react-native';
+import React from "react";
+import { View } from "react-native";
export const Footer = () => {
return <View style={{ height: 150 }} />;
diff --git a/apps/mobile/app/components/list-items/headers/header.js b/apps/mobile/app/components/list-items/headers/header.js
index f1f8d6934..16c81951d 100644
--- a/apps/mobile/app/components/list-items/headers/header.js
+++ b/apps/mobile/app/components/list-items/headers/header.js
@@ -1,20 +1,27 @@
-import React from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { useMessageStore } from '../../../stores/use-message-store';
-import { COLORS_NOTE } from '../../../utils/color-scheme';
-import { Announcement } from '../../announcements/announcement';
-import { Card } from '../../list/card';
-import Paragraph from '../../ui/typography/paragraph';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { SIZE } from '../../../utils/size';
-import { useSelectionStore } from '../../../stores/use-selection-store';
-import Animated, { FadeInUp, FadeOutUp } from 'react-native-reanimated';
+import React from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { useMessageStore } from "../../../stores/use-message-store";
+import { COLORS_NOTE } from "../../../utils/color-scheme";
+import { Announcement } from "../../announcements/announcement";
+import { Card } from "../../list/card";
+import Paragraph from "../../ui/typography/paragraph";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { SIZE } from "../../../utils/size";
+import { useSelectionStore } from "../../../stores/use-selection-store";
+import Animated, { FadeInUp, FadeOutUp } from "react-native-reanimated";
export const Header = React.memo(
- ({ type, messageCard = true, color, shouldShow = false, noAnnouncement, warning }) => {
- const colors = useThemeStore(state => state.colors);
- const announcements = useMessageStore(state => state.announcements);
- const selectionMode = useSelectionStore(state => state.selectionMode);
+ ({
+ type,
+ messageCard = true,
+ color,
+ shouldShow = false,
+ noAnnouncement,
+ warning
+ }) => {
+ const colors = useThemeStore((state) => state.colors);
+ const announcements = useMessageStore((state) => state.announcements);
+ const selectionMode = useSelectionStore((state) => state.selectionMode);
return selectionMode ? null : (
<>
@@ -23,11 +30,11 @@ export const Header = React.memo(
style={{
padding: 12,
backgroundColor: colors.errorBg,
- width: '95%',
- alignSelf: 'center',
+ width: "95%",
+ alignSelf: "center",
borderRadius: 5,
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<Icon name="sync-alert" size={SIZE.md} color={colors.red} f />
@@ -37,18 +44,20 @@ export const Header = React.memo(
</View>
) : announcements.length !== 0 && !noAnnouncement ? (
<Announcement color={color || colors.accent} />
- ) : type === 'search' ? null : !shouldShow ? (
+ ) : type === "search" ? null : !shouldShow ? (
<View
style={{
marginBottom: 5,
padding: 0,
- width: '100%',
- justifyContent: 'center',
- alignItems: 'center'
+ width: "100%",
+ justifyContent: "center",
+ alignItems: "center"
}}
>
{messageCard ? (
- <Card color={COLORS_NOTE[color?.toLowerCase()] || colors.accent} />
+ <Card
+ color={COLORS_NOTE[color?.toLowerCase()] || colors.accent}
+ />
) : null}
</View>
) : null}
@@ -57,4 +66,4 @@ export const Header = React.memo(
}
);
-Header.displayName = 'Header';
+Header.displayName = "Header";
diff --git a/apps/mobile/app/components/list-items/headers/notebook-header.js b/apps/mobile/app/components/list-items/headers/notebook-header.js
index efb22752d..36edb153a 100644
--- a/apps/mobile/app/components/list-items/headers/notebook-header.js
+++ b/apps/mobile/app/components/list-items/headers/notebook-header.js
@@ -1,19 +1,21 @@
-import React, { useRef, useState } from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { useMenuStore } from '../../../stores/use-menu-store';
-import { ToastEvent } from '../../../services/event-manager';
-import { getTotalNotes } from '../../../utils';
-import { db } from '../../../common/database';
-import { SIZE } from '../../../utils/size';
-import { IconButton } from '../../ui/icon-button';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
+import React, { useRef, useState } from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { useMenuStore } from "../../../stores/use-menu-store";
+import { ToastEvent } from "../../../services/event-manager";
+import { getTotalNotes } from "../../../utils";
+import { db } from "../../../common/database";
+import { SIZE } from "../../../utils/size";
+import { IconButton } from "../../ui/icon-button";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
export const NotebookHeader = ({ notebook, onEditNotebook }) => {
- const colors = useThemeStore(state => state.colors);
- const [isPinnedToMenu, setIsPinnedToMenu] = useState(db.settings.isPinned(notebook.id));
- const setMenuPins = useMenuStore(state => state.setMenuPins);
+ const colors = useThemeStore((state) => state.colors);
+ const [isPinnedToMenu, setIsPinnedToMenu] = useState(
+ db.settings.isPinned(notebook.id)
+ );
+ const setMenuPins = useMenuStore((state) => state.setMenuPins);
const totalNotes = getTotalNotes(notebook);
const shortcutRef = useRef();
@@ -24,8 +26,8 @@ export const NotebookHeader = ({ notebook, onEditNotebook }) => {
} else {
await db.settings.pin(notebook.type, { id: notebook.id });
ToastEvent.show({
- heading: 'Shortcut created',
- type: 'success'
+ heading: "Shortcut created",
+ type: "success"
});
}
setIsPinnedToMenu(db.settings.isPinned(notebook.id));
@@ -38,10 +40,10 @@ export const NotebookHeader = ({ notebook, onEditNotebook }) => {
style={{
marginBottom: 5,
padding: 0,
- width: '100%',
+ width: "100%",
paddingVertical: 15,
paddingHorizontal: 12,
- alignSelf: 'center',
+ alignSelf: "center",
borderRadius: 10,
paddingTop: 25
}}
@@ -51,29 +53,29 @@ export const NotebookHeader = ({ notebook, onEditNotebook }) => {
</Paragraph>
<View
style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center'
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center"
}}
>
<Heading size={SIZE.xxl}>{notebook.title}</Heading>
<View
style={{
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
<IconButton
- name={isPinnedToMenu ? 'link-variant-off' : 'link-variant'}
+ name={isPinnedToMenu ? "link-variant-off" : "link-variant"}
onPress={onPinNotebook}
- tooltipText={'Create shortcut in side menu'}
+ tooltipText={"Create shortcut in side menu"}
fwdRef={shortcutRef}
customStyle={{
marginRight: 15,
width: 40,
height: 40
}}
- type={isPinnedToMenu ? 'grayBg' : 'grayBg'}
+ type={isPinnedToMenu ? "grayBg" : "grayBg"}
color={isPinnedToMenu ? colors.accent : colors.icon}
size={SIZE.lg}
/>
@@ -101,18 +103,21 @@ export const NotebookHeader = ({ notebook, onEditNotebook }) => {
<Paragraph
style={{
marginTop: 10,
- fontStyle: 'italic',
+ fontStyle: "italic",
fontFamily: null
}}
size={SIZE.xs}
color={colors.icon}
>
- {notebook.topics.length === 1 ? '1 topic' : `${notebook.topics.length} topics`},{' '}
+ {notebook.topics.length === 1
+ ? "1 topic"
+ : `${notebook.topics.length} topics`}
+ ,{" "}
{notebook && totalNotes > 1
- ? totalNotes + ' notes'
+ ? totalNotes + " notes"
: totalNotes === 1
- ? totalNotes + ' note'
- : '0 notes'}
+ ? totalNotes + " note"
+ : "0 notes"}
</Paragraph>
</View>
);
diff --git a/apps/mobile/app/components/list-items/headers/section-header.js b/apps/mobile/app/components/list-items/headers/section-header.js
index 4fdde8133..2cd1049ae 100644
--- a/apps/mobile/app/components/list-items/headers/section-header.js
+++ b/apps/mobile/app/components/list-items/headers/section-header.js
@@ -1,40 +1,48 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { TouchableOpacity, useWindowDimensions, View } from 'react-native';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { useSettingStore } from '../../../stores/use-setting-store';
+import React, { useEffect, useRef, useState } from "react";
+import { TouchableOpacity, useWindowDimensions, View } from "react-native";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { useSettingStore } from "../../../stores/use-setting-store";
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
presentSheet
-} from '../../../services/event-manager';
-import SettingsService from '../../../services/settings';
-import { GROUP } from '../../../utils/constants';
-import { COLORS_NOTE } from '../../../utils/color-scheme';
-import { db } from '../../../common/database';
-import { eOpenJumpToDialog } from '../../../utils/events';
-import { SIZE } from '../../../utils/size';
-import { IconButton } from '../../ui/icon-button';
-import { Button } from '../../ui/button';
-import Sort from '../../sheets/sort';
-import Heading from '../../ui/typography/heading';
+} from "../../../services/event-manager";
+import SettingsService from "../../../services/settings";
+import { GROUP } from "../../../utils/constants";
+import { COLORS_NOTE } from "../../../utils/color-scheme";
+import { db } from "../../../common/database";
+import { eOpenJumpToDialog } from "../../../utils/events";
+import { SIZE } from "../../../utils/size";
+import { IconButton } from "../../ui/icon-button";
+import { Button } from "../../ui/button";
+import Sort from "../../sheets/sort";
+import Heading from "../../ui/typography/heading";
export const SectionHeader = React.memo(
({ item, index, type, color, screen }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const { fontScale } = useWindowDimensions();
- const [groupOptions, setGroupOptions] = useState(db.settings?.getGroupOptions(type));
- let groupBy = Object.keys(GROUP).find(key => GROUP[key] === groupOptions.groupBy);
+ const [groupOptions, setGroupOptions] = useState(
+ db.settings?.getGroupOptions(type)
+ );
+ let groupBy = Object.keys(GROUP).find(
+ (key) => GROUP[key] === groupOptions.groupBy
+ );
const jumpToRef = useRef();
const sortRef = useRef();
const compactModeRef = useRef();
- const notebooksListMode = useSettingStore(state => state.settings.notebooksListMode);
- const notesListMode = useSettingStore(state => state.settings.notesListMode);
- const listMode = type === 'notebooks' ? notebooksListMode : notesListMode;
+ const notebooksListMode = useSettingStore(
+ (state) => state.settings.notebooksListMode
+ );
+ const notesListMode = useSettingStore(
+ (state) => state.settings.notesListMode
+ );
+ const listMode = type === "notebooks" ? notebooksListMode : notesListMode;
groupBy = !groupBy
- ? 'Default'
+ ? "Default"
: groupBy.slice(0, 1).toUpperCase() + groupBy.slice(1, groupBy.length);
const onUpdate = () => {
@@ -42,23 +50,23 @@ export const SectionHeader = React.memo(
};
useEffect(() => {
- eSubscribeEvent('groupOptionsUpdate', onUpdate);
+ eSubscribeEvent("groupOptionsUpdate", onUpdate);
return () => {
- eUnSubscribeEvent('groupOptionsUpdate', onUpdate);
+ eUnSubscribeEvent("groupOptionsUpdate", onUpdate);
};
}, []);
return (
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
- width: '95%',
- justifyContent: 'space-between',
+ flexDirection: "row",
+ alignItems: "center",
+ width: "95%",
+ justifyContent: "space-between",
paddingHorizontal: 12,
height: 35 * fontScale,
backgroundColor: colors.nav,
- alignSelf: 'center',
+ alignSelf: "center",
borderRadius: 5,
marginVertical: 5
}}
@@ -71,8 +79,8 @@ export const SectionHeader = React.memo(
activeOpacity={0.9}
hitSlop={{ top: 10, left: 10, right: 30, bottom: 15 }}
style={{
- height: '100%',
- justifyContent: 'center'
+ height: "100%",
+ justifyContent: "center"
}}
>
<Heading
@@ -80,18 +88,18 @@ export const SectionHeader = React.memo(
size={SIZE.sm}
style={{
minWidth: 60,
- alignSelf: 'center',
- textAlignVertical: 'center'
+ alignSelf: "center",
+ textAlignVertical: "center"
}}
>
- {!item.title || item.title === '' ? 'Pinned' : item.title}
+ {!item.title || item.title === "" ? "Pinned" : item.title}
</Heading>
</TouchableOpacity>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
{index === 0 ? (
@@ -105,19 +113,26 @@ export const SectionHeader = React.memo(
tooltipText="Change sorting of items in list"
fwdRef={sortRef}
title={groupBy}
- icon={groupOptions.sortDirection === 'asc' ? 'sort-ascending' : 'sort-descending'}
+ icon={
+ groupOptions.sortDirection === "asc"
+ ? "sort-ascending"
+ : "sort-descending"
+ }
height={25}
style={{
borderRadius: 100,
paddingHorizontal: 0,
- backgroundColor: 'transparent',
- marginRight: type === 'notes' || type === 'home' || type === 'notebooks' ? 10 : 0
+ backgroundColor: "transparent",
+ marginRight:
+ type === "notes" || type === "home" || type === "notebooks"
+ ? 10
+ : 0
}}
type="gray"
iconPosition="right"
/>
- {type === 'notes' || type === 'notebooks' || type === 'home' ? (
+ {type === "notes" || type === "notebooks" || type === "home" ? (
<IconButton
customStyle={{
width: 25,
@@ -125,15 +140,22 @@ export const SectionHeader = React.memo(
}}
testID="icon-compact-mode"
tooltipText={
- listMode == 'compact' ? 'Switch to normal mode' : 'Switch to compact mode'
+ listMode == "compact"
+ ? "Switch to normal mode"
+ : "Switch to compact mode"
}
fwdRef={compactModeRef}
color={colors.icon}
- name={listMode == 'compact' ? 'view-list' : 'view-list-outline'}
+ name={
+ listMode == "compact" ? "view-list" : "view-list-outline"
+ }
onPress={() => {
let settings = {};
- settings[type !== 'notebooks' ? 'notesListMode' : 'notebooksListMode'] =
- listMode === 'normal' ? 'compact' : 'normal';
+ settings[
+ type !== "notebooks"
+ ? "notesListMode"
+ : "notebooksListMode"
+ ] = listMode === "normal" ? "compact" : "normal";
SettingsService.set(settings);
}}
diff --git a/apps/mobile/app/components/list-items/note/index.js b/apps/mobile/app/components/list-items/note/index.js
index e03701bae..42ee67892 100644
--- a/apps/mobile/app/components/list-items/note/index.js
+++ b/apps/mobile/app/components/list-items/note/index.js
@@ -1,24 +1,24 @@
-import { decode, EntityLevel } from 'entities';
-import React from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { notesnook } from '../../../../e2e/test.ids';
-import { TaggedNotes } from '../../../screens/notes/tagged';
-import { TopicNotes } from '../../../screens/notes/topic-notes';
-import useNavigationStore from '../../../stores/use-navigation-store';
-import { useSettingStore } from '../../../stores/use-setting-store';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { COLORS_NOTE } from '../../../utils/color-scheme';
-import { db } from '../../../common/database';
-import { SIZE } from '../../../utils/size';
-import { Properties } from '../../properties';
-import { Button } from '../../ui/button';
-import { IconButton } from '../../ui/icon-button';
-import { TimeSince } from '../../ui/time-since';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
+import { decode, EntityLevel } from "entities";
+import React from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { notesnook } from "../../../../e2e/test.ids";
+import { TaggedNotes } from "../../../screens/notes/tagged";
+import { TopicNotes } from "../../../screens/notes/topic-notes";
+import useNavigationStore from "../../../stores/use-navigation-store";
+import { useSettingStore } from "../../../stores/use-setting-store";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { COLORS_NOTE } from "../../../utils/color-scheme";
+import { db } from "../../../common/database";
+import { SIZE } from "../../../utils/size";
+import { Properties } from "../../properties";
+import { Button } from "../../ui/button";
+import { IconButton } from "../../ui/icon-button";
+import { TimeSince } from "../../ui/time-since";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
-const navigateToTopic = topic => {
+const navigateToTopic = (topic) => {
TopicNotes.navigate(topic, true);
};
@@ -28,16 +28,19 @@ function navigateToTag(item) {
TaggedNotes.navigate(tag, true);
}
-const showActionSheet = item => {
+const showActionSheet = (item) => {
Properties.present(item);
};
function getNotebook(item) {
- const isTrash = item.type === 'trash';
+ const isTrash = item.type === "trash";
if (isTrash || !item.notebooks || item.notebooks.length < 1) return [];
const currentScreen = useNavigationStore.getState().currentScreen;
- const filteredNotebooks = item.notebooks?.filter(n => n.id !== currentScreen.notebookId);
- let item_notebook = filteredNotebooks?.length > 0 ? filteredNotebooks.slice(0, 1)[0] : null;
+ const filteredNotebooks = item.notebooks?.filter(
+ (n) => n.id !== currentScreen.notebookId
+ );
+ let item_notebook =
+ filteredNotebooks?.length > 0 ? filteredNotebooks.slice(0, 1)[0] : null;
let notebook = item_notebook && db.notebooks.notebook(item_notebook.id);
if (!notebook) return [];
let topic = notebook.topics.topic(item_notebook.topics[0])?._topic;
@@ -52,11 +55,19 @@ function getNotebook(item) {
];
}
-const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false }) => {
- const colors = useThemeStore(state => state.colors);
- const notesListMode = useSettingStore(state => state.settings.notesListMode);
- const compactMode = notesListMode === 'compact';
- const attachmentCount = db.attachments?.ofNote(item.id, 'all')?.length || 0;
+const NoteItem = ({
+ item,
+ isTrash,
+ tags,
+ dateBy = "dateCreated",
+ noOpen = false
+}) => {
+ const colors = useThemeStore((state) => state.colors);
+ const notesListMode = useSettingStore(
+ (state) => state.settings.notesListMode
+ );
+ const compactMode = notesListMode === "compact";
+ const attachmentCount = db.attachments?.ofNote(item.id, "all")?.length || 0;
const notebooks = React.useMemo(() => getNotebook(item), [item]);
return (
@@ -70,14 +81,14 @@ const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false
{!compactMode ? (
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
zIndex: 10,
elevation: 10,
marginBottom: 2.5
}}
>
- {notebooks.map(_item => (
+ {notebooks.map((_item) => (
<Button
title={_item.title}
key={_item}
@@ -106,7 +117,7 @@ const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false
numberOfLines={1}
color={COLORS_NOTE[item.color?.toLowerCase()] || colors.heading}
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
size={SIZE.md}
>
@@ -116,7 +127,7 @@ const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false
{item.headline && !compactMode ? (
<Paragraph
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
numberOfLines={2}
>
@@ -128,10 +139,10 @@ const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false
<View
style={{
- flexDirection: 'row',
- justifyContent: 'flex-start',
- alignItems: 'center',
- width: '100%',
+ flexDirection: "row",
+ justifyContent: "flex-start",
+ alignItems: "center",
+ width: "100%",
marginTop: 5,
height: SIZE.md + 2
}}
@@ -155,14 +166,16 @@ const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false
marginRight: 6
}}
time={item[dateBy]}
- updateFrequency={Date.now() - item[dateBy] < 60000 ? 2000 : 60000}
+ updateFrequency={
+ Date.now() - item[dateBy] < 60000 ? 2000 : 60000
+ }
/>
{attachmentCount > 0 ? (
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
marginRight: 6
}}
>
@@ -181,7 +194,9 @@ const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false
style={{
marginRight: 6
}}
- color={COLORS_NOTE[item.color?.toLowerCase()] || colors.accent}
+ color={
+ COLORS_NOTE[item.color?.toLowerCase()] || colors.accent
+ }
/>
) : null}
@@ -210,15 +225,15 @@ const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false
) : null}
{!isTrash && !compactMode && tags
- ? tags.map(item =>
+ ? tags.map((item) =>
item.id ? (
<Button
- title={'#' + item.alias}
+ title={"#" + item.alias}
key={item.id}
height={23}
type="gray"
textStyle={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
hitSlop={{ top: 8, bottom: 12, left: 0, right: 0 }}
fontSize={SIZE.xs}
@@ -244,7 +259,7 @@ const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false
marginRight: 6
}}
>
- Deleted on{' '}
+ Deleted on{" "}
{item && item.dateDeleted
? new Date(item.dateDeleted).toISOString().slice(0, 10)
: null}
@@ -270,11 +285,11 @@ const NoteItem = ({ item, isTrash, tags, dateBy = 'dateCreated', noOpen = false
size={SIZE.xl}
onPress={() => !noOpen && showActionSheet(item, isTrash)}
customStyle={{
- justifyContent: 'center',
+ justifyContent: "center",
height: 35,
width: 35,
borderRadius: 100,
- alignItems: 'center'
+ alignItems: "center"
}}
/>
</>
diff --git a/apps/mobile/app/components/list-items/note/wrapper.js b/apps/mobile/app/components/list-items/note/wrapper.js
index 39e202ddb..ab81838f0 100644
--- a/apps/mobile/app/components/list-items/note/wrapper.js
+++ b/apps/mobile/app/components/list-items/note/wrapper.js
@@ -1,24 +1,28 @@
-import React from 'react';
-import NoteItem from '.';
-import { notesnook } from '../../../../e2e/test.ids';
-import { useSelectionStore } from '../../../stores/use-selection-store';
-import { useTrashStore } from '../../../stores/use-trash-store';
-import { useEditorStore } from '../../../stores/use-editor-store';
-import { DDS } from '../../../services/device-detection';
-import { eSendEvent, openVault, ToastEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { history } from '../../../utils';
-import { db } from '../../../common/database';
-import { eOnLoadNote, eShowMergeDialog } from '../../../utils/events';
-import { tabBarRef } from '../../../utils/global-refs';
-import { presentDialog } from '../../dialog/functions';
-import SelectionWrapper from '../selection-wrapper';
+import React from "react";
+import NoteItem from ".";
+import { notesnook } from "../../../../e2e/test.ids";
+import { useSelectionStore } from "../../../stores/use-selection-store";
+import { useTrashStore } from "../../../stores/use-trash-store";
+import { useEditorStore } from "../../../stores/use-editor-store";
+import { DDS } from "../../../services/device-detection";
+import {
+ eSendEvent,
+ openVault,
+ ToastEvent
+} from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { history } from "../../../utils";
+import { db } from "../../../common/database";
+import { eOnLoadNote, eShowMergeDialog } from "../../../utils/events";
+import { tabBarRef } from "../../../utils/global-refs";
+import { presentDialog } from "../../dialog/functions";
+import SelectionWrapper from "../selection-wrapper";
const present = () =>
presentDialog({
- title: 'Note not synced',
- negativeText: 'Ok',
- paragraph: 'Please sync again to open this note for editing'
+ title: "Note not synced",
+ negativeText: "Ok",
+ paragraph: "Please sync again to open this note for editing"
});
export const openNote = async (item, isTrash, setSelectedItem) => {
@@ -55,8 +59,8 @@ export const openNote = async (item, isTrash, setSelectedItem) => {
novault: true,
locked: true,
goToEditor: true,
- title: 'Open note',
- description: 'Unlock note to open it in editor.'
+ title: "Open note",
+ description: "Unlock note to open it in editor."
});
return;
}
@@ -64,24 +68,24 @@ export const openNote = async (item, isTrash, setSelectedItem) => {
presentDialog({
title: `Restore ${item.itemType}`,
paragraph: `Restore or delete ${item.itemType} forever`,
- positiveText: 'Restore',
- negativeText: 'Delete',
+ positiveText: "Restore",
+ negativeText: "Delete",
positivePress: async () => {
await db.trash.restore(item.id);
Navigation.queueRoutesForUpdate(
- 'Tags',
- 'Notes',
- 'Notebooks',
- 'Favorites',
- 'Trash',
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes'
+ "Tags",
+ "Notes",
+ "Notebooks",
+ "Favorites",
+ "Trash",
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes"
);
useSelectionStore.getState().setSelectionMode(false);
ToastEvent.show({
- heading: 'Restore successful',
- type: 'success'
+ heading: "Restore successful",
+ type: "success"
});
},
onClose: async () => {
@@ -89,9 +93,9 @@ export const openNote = async (item, isTrash, setSelectedItem) => {
useTrashStore.getState().setTrash();
useSelectionStore.getState().setSelectionMode(false);
ToastEvent.show({
- heading: 'Permanantly deleted items',
- type: 'success',
- context: 'local'
+ heading: "Permanantly deleted items",
+ type: "success",
+ context: "local"
});
}
});
@@ -106,8 +110,8 @@ export const openNote = async (item, isTrash, setSelectedItem) => {
export const NoteWrapper = React.memo(
({ item, index, tags, dateBy }) => {
- const isTrash = item.type === 'trash';
- const setSelectedItem = useSelectionStore(state => state.setSelectedItem);
+ const isTrash = item.type === "trash";
+ const setSelectedItem = useSelectionStore((state) => state.setSelectedItem);
return (
<SelectionWrapper
diff --git a/apps/mobile/app/components/list-items/notebook/index.js b/apps/mobile/app/components/list-items/notebook/index.js
index 0e75461d9..13d69d068 100644
--- a/apps/mobile/app/components/list-items/notebook/index.js
+++ b/apps/mobile/app/components/list-items/notebook/index.js
@@ -1,31 +1,39 @@
-import React from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { notesnook } from '../../../../e2e/test.ids';
-import { TopicNotes } from '../../../screens/notes/topic-notes';
-import { useSettingStore } from '../../../stores/use-setting-store';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { getTotalNotes, history } from '../../../utils';
-import { SIZE } from '../../../utils/size';
-import { Properties } from '../../properties';
-import { Button } from '../../ui/button';
-import { IconButton } from '../../ui/icon-button';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
+import React from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { notesnook } from "../../../../e2e/test.ids";
+import { TopicNotes } from "../../../screens/notes/topic-notes";
+import { useSettingStore } from "../../../stores/use-setting-store";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { getTotalNotes, history } from "../../../utils";
+import { SIZE } from "../../../utils/size";
+import { Properties } from "../../properties";
+import { Button } from "../../ui/button";
+import { IconButton } from "../../ui/icon-button";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
-const showActionSheet = item => {
+const showActionSheet = (item) => {
Properties.present(item);
};
-const navigateToTopic = topic => {
+const navigateToTopic = (topic) => {
if (history.selectedItemsList.length > 0) return;
TopicNotes.navigate(topic, true);
};
-export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateBy }) => {
- const colors = useThemeStore(state => state.colors);
- const notebooksListMode = useSettingStore(state => state.settings.notebooksListMode);
- const compactMode = notebooksListMode === 'compact';
+export const NotebookItem = ({
+ item,
+ isTopic = false,
+ notebookID,
+ isTrash,
+ dateBy
+}) => {
+ const colors = useThemeStore((state) => state.colors);
+ const notebooksListMode = useSettingStore(
+ (state) => state.settings.notebooksListMode
+ );
+ const compactMode = notebooksListMode === "compact";
const topics = item.topics?.slice(0, 3) || [];
const totalNotes = getTotalNotes(item);
@@ -41,7 +49,7 @@ export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateB
size={SIZE.md}
numberOfLines={1}
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
>
{item.title}
@@ -51,7 +59,7 @@ export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateB
size={SIZE.sm}
numberOfLines={2}
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
>
{item.description}
@@ -61,18 +69,18 @@ export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateB
{isTopic || compactMode ? null : (
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
- flexWrap: 'wrap'
+ flexDirection: "row",
+ alignItems: "center",
+ flexWrap: "wrap"
}}
>
- {topics.map(topic => (
+ {topics.map((topic) => (
<Button
title={topic.title}
key={topic.id}
height={null}
textStyle={{
- fontWeight: 'normal',
+ fontWeight: "normal",
fontFamily: null,
marginRight: 0
}}
@@ -98,9 +106,9 @@ export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateB
<View
style={{
- flexDirection: 'row',
- justifyContent: 'flex-start',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "flex-start",
+ alignItems: "center",
marginTop: 5,
height: SIZE.md + 2
}}
@@ -112,7 +120,7 @@ export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateB
marginRight: 6
}}
>
- {isTopic ? 'Topic' : 'Notebook'}
+ {isTopic ? "Topic" : "Notebook"}
</Paragraph>
{isTrash ? (
@@ -121,17 +129,18 @@ export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateB
color={colors.icon}
size={SIZE.xs}
style={{
- textAlignVertical: 'center',
+ textAlignVertical: "center",
marginRight: 6
}}
>
- {'Deleted on ' + new Date(item.dateDeleted).toISOString().slice(0, 10)}
+ {"Deleted on " +
+ new Date(item.dateDeleted).toISOString().slice(0, 10)}
</Paragraph>
<Paragraph
color={colors.accent}
size={SIZE.xs}
style={{
- textAlignVertical: 'center',
+ textAlignVertical: "center",
marginRight: 6
}}
>
@@ -157,10 +166,10 @@ export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateB
}}
>
{item && totalNotes > 1
- ? totalNotes + ' notes'
+ ? totalNotes + " notes"
: totalNotes === 1
- ? totalNotes + ' note'
- : '0 notes'}
+ ? totalNotes + " note"
+ : "0 notes"}
</Paragraph>
{item.pinned ? (
@@ -183,11 +192,11 @@ export const NotebookItem = ({ item, isTopic = false, notebookID, isTrash, dateB
size={SIZE.xl}
onPress={() => showActionSheet(item)}
customStyle={{
- justifyContent: 'center',
+ justifyContent: "center",
height: 35,
width: 35,
borderRadius: 100,
- alignItems: 'center'
+ alignItems: "center"
}}
/>
</>
diff --git a/apps/mobile/app/components/list-items/notebook/wrapper.js b/apps/mobile/app/components/list-items/notebook/wrapper.js
index bc6784b4b..0666fff15 100644
--- a/apps/mobile/app/components/list-items/notebook/wrapper.js
+++ b/apps/mobile/app/components/list-items/notebook/wrapper.js
@@ -1,18 +1,18 @@
-import React from 'react';
-import { NotebookItem } from '.';
-import Notebook from '../../../screens/notebook';
-import { TopicNotes } from '../../../screens/notes/topic-notes';
-import { ToastEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { useSelectionStore } from '../../../stores/use-selection-store';
-import { useTrashStore } from '../../../stores/use-trash-store';
-import { history } from '../../../utils';
-import { db } from '../../../common/database';
-import { presentDialog } from '../../dialog/functions';
-import SelectionWrapper from '../selection-wrapper';
+import React from "react";
+import { NotebookItem } from ".";
+import Notebook from "../../../screens/notebook";
+import { TopicNotes } from "../../../screens/notes/topic-notes";
+import { ToastEvent } from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { useSelectionStore } from "../../../stores/use-selection-store";
+import { useTrashStore } from "../../../stores/use-trash-store";
+import { history } from "../../../utils";
+import { db } from "../../../common/database";
+import { presentDialog } from "../../dialog/functions";
+import SelectionWrapper from "../selection-wrapper";
-export const openNotebookTopic = item => {
- const isTrash = item.type === 'trash';
+export const openNotebookTopic = (item) => {
+ const isTrash = item.type === "trash";
if (history.selectedItemsList.length > 0 && history.selectionMode) {
useSelectionStore.getState().setSelectedItem(item);
return;
@@ -24,24 +24,24 @@ export const openNotebookTopic = item => {
presentDialog({
title: `Restore ${item.itemType}`,
paragraph: `Restore or delete ${item.itemType} forever`,
- positiveText: 'Restore',
- negativeText: 'Delete',
+ positiveText: "Restore",
+ negativeText: "Delete",
positivePress: async () => {
await db.trash.restore(item.id);
Navigation.queueRoutesForUpdate(
- 'Tags',
- 'Notes',
- 'Notebooks',
- 'Favorites',
- 'Trash',
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes'
+ "Tags",
+ "Notes",
+ "Notebooks",
+ "Favorites",
+ "Trash",
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes"
);
useSelectionStore.getState().setSelectionMode(false);
ToastEvent.show({
- heading: 'Restore successful',
- type: 'success'
+ heading: "Restore successful",
+ type: "success"
});
},
onClose: async () => {
@@ -49,15 +49,15 @@ export const openNotebookTopic = item => {
useTrashStore.getState().setTrash();
useSelectionStore.getState().setSelectionMode(false);
ToastEvent.show({
- heading: 'Permanantly deleted items',
- type: 'success',
- context: 'local'
+ heading: "Permanantly deleted items",
+ type: "success",
+ context: "local"
});
}
});
return;
}
- if (item.type === 'topic') {
+ if (item.type === "topic") {
TopicNotes.navigate(item, true);
} else {
Notebook.navigate(item, true);
@@ -66,18 +66,18 @@ export const openNotebookTopic = item => {
export const NotebookWrapper = React.memo(
({ item, index, dateBy }) => {
- const isTrash = item.type === 'trash';
+ const isTrash = item.type === "trash";
return (
<SelectionWrapper
pinned={item.pinned}
index={index}
onPress={() => openNotebookTopic(item)}
- height={item.type === 'topic' ? 80 : 110}
+ height={item.type === "topic" ? 80 : 110}
item={item}
>
<NotebookItem
- isTopic={item.type === 'topic'}
+ isTopic={item.type === "topic"}
item={item}
dateBy={dateBy}
index={index}
diff --git a/apps/mobile/app/components/list-items/selection-wrapper/action-strip.js b/apps/mobile/app/components/list-items/selection-wrapper/action-strip.js
index c93e4447d..53a177368 100644
--- a/apps/mobile/app/components/list-items/selection-wrapper/action-strip.js
+++ b/apps/mobile/app/components/list-items/selection-wrapper/action-strip.js
@@ -1,59 +1,59 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import React, { useEffect, useState } from 'react';
-import { View } from 'react-native';
-import Animated, { SlideInUp, SlideOutDown } from 'react-native-reanimated';
-import { openVault, ToastEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { useSelectionStore } from '../../../stores/use-selection-store';
-import { useTrashStore } from '../../../stores/use-trash-store';
-import { useMenuStore } from '../../../stores/use-menu-store';
-import { useNotebookStore } from '../../../stores/use-notebook-store';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { dWidth, getElevation, toTXT } from '../../../utils';
-import { db } from '../../../common/database';
-import { deleteItems } from '../../../utils/functions';
-import { presentDialog } from '../../dialog/functions';
-import { Button } from '../../ui/button';
-import { IconButton } from '../../ui/icon-button';
+import Clipboard from "@react-native-clipboard/clipboard";
+import React, { useEffect, useState } from "react";
+import { View } from "react-native";
+import Animated, { SlideInUp, SlideOutDown } from "react-native-reanimated";
+import { openVault, ToastEvent } from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { useSelectionStore } from "../../../stores/use-selection-store";
+import { useTrashStore } from "../../../stores/use-trash-store";
+import { useMenuStore } from "../../../stores/use-menu-store";
+import { useNotebookStore } from "../../../stores/use-notebook-store";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { dWidth, getElevation, toTXT } from "../../../utils";
+import { db } from "../../../common/database";
+import { deleteItems } from "../../../utils/functions";
+import { presentDialog } from "../../dialog/functions";
+import { Button } from "../../ui/button";
+import { IconButton } from "../../ui/icon-button";
export const ActionStrip = ({ note, setActionStrip }) => {
- const colors = useThemeStore(state => state.colors);
- const selectionMode = useSelectionStore(state => state.selectionMode);
- const setNotebooks = useNotebookStore(state => state.setNotebooks);
- const setMenuPins = useMenuStore(state => state.setMenuPins);
- const setSelectedItem = useSelectionStore(state => state.setSelectedItem);
- const setSelectionMode = useSelectionStore(state => state.setSelectionMode);
+ const colors = useThemeStore((state) => state.colors);
+ const selectionMode = useSelectionStore((state) => state.selectionMode);
+ const setNotebooks = useNotebookStore((state) => state.setNotebooks);
+ const setMenuPins = useMenuStore((state) => state.setMenuPins);
+ const setSelectedItem = useSelectionStore((state) => state.setSelectedItem);
+ const setSelectionMode = useSelectionStore((state) => state.setSelectionMode);
const [isPinnedToMenu, setIsPinnedToMenu] = useState(false);
const [width, setWidth] = useState(dWidth - 16);
useEffect(() => {
- if (note.type === 'note') return;
+ if (note.type === "note") return;
setIsPinnedToMenu(db.settings.isPinned(note.id));
}, []);
const updateNotes = () => {
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes"
);
};
const actions = [
{
- title: 'Pin ' + note.type,
- icon: note.pinned ? 'pin-off' : 'pin',
- visible: note.type === 'note' || note.type === 'notebook',
+ title: "Pin " + note.type,
+ icon: note.pinned ? "pin-off" : "pin",
+ visible: note.type === "note" || note.type === "notebook",
onPress: async () => {
if (!note.id) return;
- if (note.type === 'note') {
+ if (note.type === "note") {
if (db.notes.pinned.length === 3 && !note.pinned) {
ToastEvent.show({
- heading: 'Cannot pin more than 3 notes',
- type: 'error'
+ heading: "Cannot pin more than 3 notes",
+ type: "error"
});
return;
}
@@ -61,8 +61,8 @@ export const ActionStrip = ({ note, setActionStrip }) => {
} else {
if (db.notebooks.pinned.length === 3 && !note.pinned) {
ToastEvent.show({
- heading: 'Cannot pin more than 3 notebooks',
- type: 'error'
+ heading: "Cannot pin more than 3 notebooks",
+ type: "error"
});
return;
}
@@ -74,11 +74,11 @@ export const ActionStrip = ({ note, setActionStrip }) => {
}
},
{
- title: 'Add to favorites',
- icon: note.favorite ? 'star-off' : 'star',
+ title: "Add to favorites",
+ icon: note.favorite ? "star-off" : "star",
onPress: async () => {
if (!note.id) return;
- if (note.type === 'note') {
+ if (note.type === "note") {
await db.notes.note(note.id).favorite();
} else {
await db.notebooks.notebook(note.id).favorite();
@@ -86,23 +86,25 @@ export const ActionStrip = ({ note, setActionStrip }) => {
updateNotes();
setActionStrip(false);
},
- visible: note.type === 'note',
- color: !note.favorite ? 'orange' : null
+ visible: note.type === "note",
+ color: !note.favorite ? "orange" : null
},
{
- title: isPinnedToMenu ? 'Remove Shortcut from Menu' : 'Add Shortcut to Menu',
- icon: isPinnedToMenu ? 'link-variant-remove' : 'link-variant',
+ title: isPinnedToMenu
+ ? "Remove Shortcut from Menu"
+ : "Add Shortcut to Menu",
+ icon: isPinnedToMenu ? "link-variant-remove" : "link-variant",
onPress: async () => {
try {
if (isPinnedToMenu) {
await db.settings.unpin(note.id);
ToastEvent.show({
- heading: 'Shortcut removed from menu',
- type: 'success'
+ heading: "Shortcut removed from menu",
+ type: "success"
});
} else {
- if (note.type === 'topic') {
+ if (note.type === "topic") {
await db.settings.pin(note.type, {
id: note.id,
notebookId: note.notebookId
@@ -111,8 +113,8 @@ export const ActionStrip = ({ note, setActionStrip }) => {
await db.settings.pin(note.type, { id: note.id });
}
ToastEvent.show({
- heading: 'Shortcut added to menu',
- type: 'success'
+ heading: "Shortcut added to menu",
+ type: "success"
});
}
setIsPinnedToMenu(db.settings.isPinned(note.id));
@@ -121,12 +123,12 @@ export const ActionStrip = ({ note, setActionStrip }) => {
setActionStrip(false);
} catch (e) {}
},
- visible: note.type !== 'note'
+ visible: note.type !== "note"
},
{
- title: 'Copy Note',
- icon: 'content-copy',
- visible: note.type === 'note',
+ title: "Copy Note",
+ icon: "content-copy",
+ visible: note.type === "note",
onPress: async () => {
if (note.locked) {
openVault({
@@ -134,75 +136,77 @@ export const ActionStrip = ({ note, setActionStrip }) => {
novault: true,
locked: true,
item: note,
- title: 'Copy note',
- description: 'Unlock note to copy to clipboard.'
+ title: "Copy note",
+ description: "Unlock note to copy to clipboard."
});
} else {
let text = await toTXT(note);
text = `${note.title}\n \n ${text}`;
Clipboard.setString(text);
ToastEvent.show({
- heading: 'Note copied to clipboard',
- type: 'success'
+ heading: "Note copied to clipboard",
+ type: "success"
});
}
setActionStrip(false);
}
},
{
- title: 'Restore ' + note.itemType,
- icon: 'delete-restore',
+ title: "Restore " + note.itemType,
+ icon: "delete-restore",
onPress: async () => {
await db.trash.restore(note.id);
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes',
- 'Trash',
- 'Notebooks'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes",
+ "Trash",
+ "Notebooks"
);
ToastEvent.show({
heading:
- note.type === 'note' ? 'Note restored from trash' : 'Notebook restored from trash',
- type: 'success'
+ note.type === "note"
+ ? "Note restored from trash"
+ : "Notebook restored from trash",
+ type: "success"
});
setActionStrip(false);
},
- visible: note.type === 'trash'
+ visible: note.type === "trash"
},
{
- title: 'Delete' + note.itemType,
- icon: 'delete',
- visible: note.type === 'trash',
+ title: "Delete" + note.itemType,
+ icon: "delete",
+ visible: note.type === "trash",
onPress: () => {
presentDialog({
title: `Permanent delete`,
paragraph: `Are you sure you want to delete this ${note.itemType} permanantly from trash?`,
- positiveText: 'Delete',
- negativeText: 'Cancel',
+ positiveText: "Delete",
+ negativeText: "Cancel",
positivePress: async () => {
await db.trash.delete(note.id);
useTrashStore.getState().setTrash();
useSelectionStore.getState().setSelectionMode(false);
ToastEvent.show({
- heading: 'Permanantly deleted items',
- type: 'success',
- context: 'local'
+ heading: "Permanantly deleted items",
+ type: "success",
+ context: "local"
});
},
- positiveType: 'errorShade'
+ positiveType: "errorShade"
});
setActionStrip(false);
}
},
{
- title: 'Delete' + note.type,
- icon: 'delete',
- visible: note.type !== 'trash',
+ title: "Delete" + note.type,
+ icon: "delete",
+ visible: note.type !== "trash",
onPress: async () => {
try {
await deleteItems(note);
@@ -211,8 +215,8 @@ export const ActionStrip = ({ note, setActionStrip }) => {
}
},
{
- title: 'Close',
- icon: 'close',
+ title: "Close",
+ icon: "close",
onPress: () => setActionStrip(false),
color: colors.light,
bg: colors.red,
@@ -222,19 +226,19 @@ export const ActionStrip = ({ note, setActionStrip }) => {
return (
<Animated.View
- onLayout={event => {
+ onLayout={(event) => {
setWidth(event.nativeEvent.layout.width);
}}
entering={SlideInUp.springify().mass(0.4)}
exiting={SlideOutDown}
style={{
- position: 'absolute',
+ position: "absolute",
zIndex: 999,
- width: '102%',
- height: '100%',
- flexDirection: 'row',
- justifyContent: 'flex-end',
- alignItems: 'center'
+ width: "102%",
+ height: "100%",
+ flexDirection: "row",
+ justifyContent: "flex-end",
+ alignItems: "center"
}}
>
<Button
@@ -242,7 +246,7 @@ export const ActionStrip = ({ note, setActionStrip }) => {
title="Select"
icon="check"
tooltipText="Select Item"
- onPress={event => {
+ onPress={(event) => {
if (!selectionMode) {
setSelectionMode(true);
}
@@ -256,7 +260,7 @@ export const ActionStrip = ({ note, setActionStrip }) => {
}}
height={30}
/>
- {actions.map(item =>
+ {actions.map((item) =>
item.visible ? (
<View
key={item.icon}
@@ -265,8 +269,8 @@ export const ActionStrip = ({ note, setActionStrip }) => {
height: width / 1.4 / actions.length,
backgroundColor: item.bg || colors.nav,
borderRadius: 100,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
...getElevation(5),
marginLeft: 15
}}
diff --git a/apps/mobile/app/components/list-items/selection-wrapper/back-fill.js b/apps/mobile/app/components/list-items/selection-wrapper/back-fill.js
index b6fe3921b..00c7241d8 100644
--- a/apps/mobile/app/components/list-items/selection-wrapper/back-fill.js
+++ b/apps/mobile/app/components/list-items/selection-wrapper/back-fill.js
@@ -1,26 +1,33 @@
-import React from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { useEditorStore } from '../../../stores/use-editor-store';
-import { hexToRGBA } from '../../../utils/color-scheme/utils';
+import React from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { useEditorStore } from "../../../stores/use-editor-store";
+import { hexToRGBA } from "../../../utils/color-scheme/utils";
export const Filler = ({ item, background }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
- const currentEditingNote = useEditorStore(state => state.currentEditingNote);
+ const currentEditingNote = useEditorStore(
+ (state) => state.currentEditingNote
+ );
- const color = 'gray';
+ const color = "gray";
return currentEditingNote === item.id ? (
<View
style={{
- position: 'absolute',
- width: '110%',
- height: '150%',
- backgroundColor: currentEditingNote === item.id ? hexToRGBA(colors[color], 0.12) : null,
+ position: "absolute",
+ width: "110%",
+ height: "150%",
+ backgroundColor:
+ currentEditingNote === item.id
+ ? hexToRGBA(colors[color], 0.12)
+ : null,
borderLeftWidth: 5,
borderLeftColor:
- currentEditingNote === item.id ? colors[item.color || 'accent'] : 'transparent'
+ currentEditingNote === item.id
+ ? colors[item.color || "accent"]
+ : "transparent"
}}
></View>
) : null;
diff --git a/apps/mobile/app/components/list-items/selection-wrapper/index.js b/apps/mobile/app/components/list-items/selection-wrapper/index.js
index c99b42c5d..c8cb392b2 100644
--- a/apps/mobile/app/components/list-items/selection-wrapper/index.js
+++ b/apps/mobile/app/components/list-items/selection-wrapper/index.js
@@ -1,20 +1,36 @@
-import React, { useEffect, useState } from 'react';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
-import { useSettingStore } from '../../../stores/use-setting-store';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { history } from '../../../utils';
-import { PressableButton } from '../../ui/pressable';
-import { ActionStrip } from './action-strip';
-import { Filler } from './back-fill';
-import { SelectionIcon } from './selection';
+import React, { useEffect, useState } from "react";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../../services/event-manager";
+import { useSettingStore } from "../../../stores/use-setting-store";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { history } from "../../../utils";
+import { PressableButton } from "../../ui/pressable";
+import { ActionStrip } from "./action-strip";
+import { Filler } from "./back-fill";
+import { SelectionIcon } from "./selection";
-const SelectionWrapper = ({ children, item, background, onLongPress, onPress, testID }) => {
- const colors = useThemeStore(state => state.colors);
+const SelectionWrapper = ({
+ children,
+ item,
+ background,
+ onLongPress,
+ onPress,
+ testID
+}) => {
+ const colors = useThemeStore((state) => state.colors);
const [actionStrip, setActionStrip] = useState(false);
- const notebooksListMode = useSettingStore(state => state.settings.notebooksListMode);
- const notesListMode = useSettingStore(state => state.settings.notesListMode);
- const listMode = item.type === 'notebook' ? notebooksListMode : notesListMode;
- const compactMode = (item.type === 'notebook' || item.type === 'note') && listMode === 'compact';
+ const notebooksListMode = useSettingStore(
+ (state) => state.settings.notebooksListMode
+ );
+ const notesListMode = useSettingStore(
+ (state) => state.settings.notesListMode
+ );
+ const listMode = item.type === "notebook" ? notebooksListMode : notesListMode;
+ const compactMode =
+ (item.type === "notebook" || item.type === "note") &&
+ listMode === "compact";
const _onLongPress = () => {
if (history.selectedItemsList.length > 0) return;
@@ -34,10 +50,10 @@ const SelectionWrapper = ({ children, item, background, onLongPress, onPress, te
};
useEffect(() => {
- eSubscribeEvent('navigate', closeStrip);
+ eSubscribeEvent("navigate", closeStrip);
return () => {
- eUnSubscribeEvent('navigate', closeStrip);
+ eUnSubscribeEvent("navigate", closeStrip);
};
}, []);
@@ -51,17 +67,19 @@ const SelectionWrapper = ({ children, item, background, onLongPress, onPress, te
customAlpha={!colors.night ? -0.02 : 0.02}
customOpacity={1}
customStyle={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
- width: '100%',
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
+ width: "100%",
borderRadius: 0,
- overflow: 'hidden',
+ overflow: "hidden",
paddingHorizontal: 12,
paddingVertical: compactMode ? 8 : 12
}}
>
- {item.type === 'note' ? <Filler background={background} item={item} /> : null}
+ {item.type === "note" ? (
+ <Filler background={background} item={item} />
+ ) : null}
<SelectionIcon
compactMode={compactMode}
setActionStrip={setActionStrip}
@@ -70,7 +88,9 @@ const SelectionWrapper = ({ children, item, background, onLongPress, onPress, te
/>
{children}
- {actionStrip ? <ActionStrip note={item} setActionStrip={setActionStrip} /> : null}
+ {actionStrip ? (
+ <ActionStrip note={item} setActionStrip={setActionStrip} />
+ ) : null}
</PressableButton>
);
};
diff --git a/apps/mobile/app/components/list-items/selection-wrapper/selection.js b/apps/mobile/app/components/list-items/selection-wrapper/selection.js
index d9c7938e4..01d5227a1 100644
--- a/apps/mobile/app/components/list-items/selection-wrapper/selection.js
+++ b/apps/mobile/app/components/list-items/selection-wrapper/selection.js
@@ -1,22 +1,26 @@
-import React, { useEffect, useState } from 'react';
-import { TouchableOpacity, View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useSelectionStore } from '../../../stores/use-selection-store';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { SIZE } from '../../../utils/size';
+import React, { useEffect, useState } from "react";
+import { TouchableOpacity, View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useSelectionStore } from "../../../stores/use-selection-store";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { SIZE } from "../../../utils/size";
export const SelectionIcon = ({ setActionStrip, item, compactMode }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
- const selectionMode = useSelectionStore(state => state.selectionMode);
- const selectedItemsList = useSelectionStore(state => state.selectedItemsList);
- const setSelectedItem = useSelectionStore(state => state.setSelectedItem);
+ const selectionMode = useSelectionStore((state) => state.selectionMode);
+ const selectedItemsList = useSelectionStore(
+ (state) => state.selectedItemsList
+ );
+ const setSelectedItem = useSelectionStore((state) => state.setSelectedItem);
const [selected, setSelected] = useState(false);
useEffect(() => {
if (selectionMode) {
setActionStrip(false);
- let exists = selectedItemsList.filter(o => o.dateCreated === item.dateCreated);
+ let exists = selectedItemsList.filter(
+ (o) => o.dateCreated === item.dateCreated
+ );
if (exists[0]) {
if (!selected) {
@@ -37,12 +41,12 @@ export const SelectionIcon = ({ setActionStrip, item, compactMode }) => {
return selectionMode ? (
<View
style={{
- display: 'flex',
+ display: "flex",
opacity: 1,
- width: '10%',
+ width: "10%",
height: compactMode ? 40 : 70,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
backgroundColor: colors.bg,
borderRadius: 5,
marginRight: 10,
@@ -54,13 +58,17 @@ export const SelectionIcon = ({ setActionStrip, item, compactMode }) => {
activeOpacity={1}
onPress={onPress}
style={{
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
height: 70
}}
>
{selected && (
- <Icon size={SIZE.xl} color={selected ? colors.accent : colors.icon} name="check" />
+ <Icon
+ size={SIZE.xl}
+ color={selected ? colors.accent : colors.icon}
+ name="check"
+ />
)}
</TouchableOpacity>
</View>
diff --git a/apps/mobile/app/components/list-items/tag/index.js b/apps/mobile/app/components/list-items/tag/index.js
index 8f2459235..97b135b13 100644
--- a/apps/mobile/app/components/list-items/tag/index.js
+++ b/apps/mobile/app/components/list-items/tag/index.js
@@ -1,19 +1,19 @@
-import React from 'react';
-import { View } from 'react-native';
-import { notesnook } from '../../../../e2e/test.ids';
-import { TaggedNotes } from '../../../screens/notes/tagged';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { db } from '../../../common/database';
-import { SIZE } from '../../../utils/size';
-import { Properties } from '../../properties';
-import { IconButton } from '../../ui/icon-button';
-import { PressableButton } from '../../ui/pressable';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
+import React from "react";
+import { View } from "react-native";
+import { notesnook } from "../../../../e2e/test.ids";
+import { TaggedNotes } from "../../../screens/notes/tagged";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { db } from "../../../common/database";
+import { SIZE } from "../../../utils/size";
+import { Properties } from "../../properties";
+import { IconButton } from "../../ui/icon-button";
+import { PressableButton } from "../../ui/pressable";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
const TagItem = React.memo(
({ item, index }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const onPress = () => {
TaggedNotes.navigate(item, true);
};
@@ -27,16 +27,16 @@ const TagItem = React.memo(
opacity={1}
customStyle={{
paddingHorizontal: 12,
- flexDirection: 'row',
+ flexDirection: "row",
paddingVertical: 12,
- alignItems: 'center',
- width: '100%',
- justifyContent: 'space-between'
+ alignItems: "center",
+ width: "100%",
+ justifyContent: "space-between"
}}
>
<View
style={{
- maxWidth: '92%'
+ maxWidth: "92%"
}}
>
<Heading size={SIZE.md}>
@@ -58,9 +58,9 @@ const TagItem = React.memo(
}}
>
{item && item.noteIds.length && item.noteIds.length > 1
- ? item.noteIds.length + ' notes'
+ ? item.noteIds.length + " notes"
: item.noteIds.length === 1
- ? item.noteIds.length + ' note'
+ ? item.noteIds.length + " note"
: null}
</Paragraph>
</View>
@@ -74,11 +74,11 @@ const TagItem = React.memo(
}}
testID={notesnook.ids.tag.menu}
customStyle={{
- justifyContent: 'center',
+ justifyContent: "center",
height: 35,
width: 35,
borderRadius: 100,
- alignItems: 'center'
+ alignItems: "center"
}}
/>
</PressableButton>
@@ -96,6 +96,6 @@ const TagItem = React.memo(
}
);
-TagItem.displayName = 'TagItem';
+TagItem.displayName = "TagItem";
export default TagItem;
diff --git a/apps/mobile/app/components/list/card.js b/apps/mobile/app/components/list/card.js
index 9711d624e..038d199cb 100644
--- a/apps/mobile/app/components/list/card.js
+++ b/apps/mobile/app/components/list/card.js
@@ -1,23 +1,23 @@
-import React from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useMessageStore } from '../../stores/use-message-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { hexToRGBA } from '../../utils/color-scheme/utils';
-import { SIZE } from '../../utils/size';
-import { PressableButton } from '../ui/pressable';
-import Paragraph from '../ui/typography/paragraph';
+import React from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useMessageStore } from "../../stores/use-message-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { hexToRGBA } from "../../utils/color-scheme/utils";
+import { SIZE } from "../../utils/size";
+import { PressableButton } from "../ui/pressable";
+import Paragraph from "../ui/typography/paragraph";
export const Card = ({ color, warning }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
color = color ? color : colors.accent;
- const messageBoardState = useMessageStore(state => state.message);
- const announcement = useMessageStore(state => state.announcement);
+ const messageBoardState = useMessageStore((state) => state.message);
+ const announcement = useMessageStore((state) => state.announcement);
return !messageBoardState.visible || announcement || warning ? null : (
<View
style={{
- width: '95%'
+ width: "95%"
}}
>
<PressableButton
@@ -25,10 +25,10 @@ export const Card = ({ color, warning }) => {
type="gray"
customStyle={{
paddingVertical: 12,
- width: '95%',
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'flex-start',
+ width: "95%",
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "flex-start",
paddingHorizontal: 0
}}
>
@@ -36,19 +36,21 @@ export const Card = ({ color, warning }) => {
style={{
width: 40,
backgroundColor:
- messageBoardState.type === 'error'
+ messageBoardState.type === "error"
? hexToRGBA(colors.red, 0.15)
: hexToRGBA(color, 0.15),
height: 40,
marginLeft: 10,
borderRadius: 100,
- alignItems: 'center',
- justifyContent: 'center'
+ alignItems: "center",
+ justifyContent: "center"
}}
>
<Icon
size={SIZE.lg}
- color={messageBoardState.type === 'error' ? colors.errorText : color}
+ color={
+ messageBoardState.type === "error" ? colors.errorText : color
+ }
name={messageBoardState.icon}
/>
</View>
@@ -56,7 +58,7 @@ export const Card = ({ color, warning }) => {
<View
style={{
marginLeft: 10,
- maxWidth: '70%'
+ maxWidth: "70%"
}}
>
<Paragraph color={colors.icon} size={SIZE.xs}>
@@ -64,7 +66,7 @@ export const Card = ({ color, warning }) => {
</Paragraph>
<Paragraph
style={{
- maxWidth: '100%'
+ maxWidth: "100%"
}}
color={colors.heading}
>
@@ -76,15 +78,15 @@ export const Card = ({ color, warning }) => {
style={{
width: 40,
height: 40,
- justifyContent: 'center',
- alignItems: 'center',
- position: 'absolute',
+ justifyContent: "center",
+ alignItems: "center",
+ position: "absolute",
right: 6
}}
>
<Icon
name="chevron-right"
- color={messageBoardState.type === 'error' ? colors.red : color}
+ color={messageBoardState.type === "error" ? colors.red : color}
size={SIZE.lg}
/>
</View>
diff --git a/apps/mobile/app/components/list/empty.js b/apps/mobile/app/components/list/empty.js
index 3c188ca67..ff8a2b78e 100644
--- a/apps/mobile/app/components/list/empty.js
+++ b/apps/mobile/app/components/list/empty.js
@@ -1,49 +1,61 @@
-import React from 'react';
-import { ActivityIndicator, useWindowDimensions, View } from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useTip } from '../../services/tip-manager';
-import { COLORS_NOTE } from '../../utils/color-scheme';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import Seperator from '../ui/seperator';
-import { Tip } from '../tip';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { notesnook } from '../../../e2e/test.ids';
+import React from "react";
+import { ActivityIndicator, useWindowDimensions, View } from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useTip } from "../../services/tip-manager";
+import { COLORS_NOTE } from "../../utils/color-scheme";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import Seperator from "../ui/seperator";
+import { Tip } from "../tip";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { notesnook } from "../../../e2e/test.ids";
export const Empty = React.memo(
({ loading = true, placeholderData, headerProps, type, screen }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const insets = useSafeAreaInsets();
const { height } = useWindowDimensions();
- const introCompleted = useSettingStore(state => state.settings.introCompleted);
+ const introCompleted = useSettingStore(
+ (state) => state.settings.introCompleted
+ );
const tip = useTip(
- screen === 'Notes' && introCompleted ? 'first-note' : placeholderData.type || type,
- screen === 'Notes' ? 'notes' : null
+ screen === "Notes" && introCompleted
+ ? "first-note"
+ : placeholderData.type || type,
+ screen === "Notes" ? "notes" : null
);
const color =
- colors[COLORS_NOTE[headerProps.color?.toLowerCase()] ? headerProps.color : 'accent'];
+ colors[
+ COLORS_NOTE[headerProps.color?.toLowerCase()]
+ ? headerProps.color
+ : "accent"
+ ];
return (
<View
style={[
{
height: height - (140 + insets.top),
- width: '80%',
- justifyContent: 'center',
- alignSelf: 'center'
+ width: "80%",
+ justifyContent: "center",
+ alignSelf: "center"
}
]}
>
{!loading ? (
<>
<Tip
- color={COLORS_NOTE[headerProps.color?.toLowerCase()] ? headerProps.color : 'accent'}
+ color={
+ COLORS_NOTE[headerProps.color?.toLowerCase()]
+ ? headerProps.color
+ : "accent"
+ }
tip={tip || { text: placeholderData.paragraph }}
style={{
- backgroundColor: 'transparent',
+ backgroundColor: "transparent",
paddingHorizontal: 0
}}
/>
@@ -56,11 +68,13 @@ export const Empty = React.memo(
icon="arrow-right"
onPress={placeholderData.action}
accentColor={
- COLORS_NOTE[headerProps.color?.toLowerCase()] ? headerProps.color : 'accent'
+ COLORS_NOTE[headerProps.color?.toLowerCase()]
+ ? headerProps.color
+ : "accent"
}
accentText="light"
style={{
- alignSelf: 'flex-start',
+ alignSelf: "flex-start",
borderRadius: 5,
height: 40
}}
@@ -71,9 +85,9 @@ export const Empty = React.memo(
<>
<View
style={{
- alignSelf: 'center',
- alignItems: 'flex-start',
- width: '100%'
+ alignSelf: "center",
+ alignItems: "flex-start",
+ width: "100%"
}}
>
<Heading>{placeholderData.heading}</Heading>
@@ -83,7 +97,9 @@ export const Empty = React.memo(
<Seperator />
<ActivityIndicator
size={SIZE.lg}
- color={COLORS_NOTE[headerProps.color?.toLowerCase()] || colors.accent}
+ color={
+ COLORS_NOTE[headerProps.color?.toLowerCase()] || colors.accent
+ }
/>
</View>
</>
diff --git a/apps/mobile/app/components/list/index.js b/apps/mobile/app/components/list/index.js
index 42273a5fc..b0e5474e6 100644
--- a/apps/mobile/app/components/list/index.js
+++ b/apps/mobile/app/components/list/index.js
@@ -1,21 +1,21 @@
-import React, { useRef } from 'react';
-import { FlatList, RefreshControl, View } from 'react-native';
-import Animated, { FadeInDown } from 'react-native-reanimated';
-import { notesnook } from '../../../e2e/test.ids';
-import { eSendEvent } from '../../services/event-manager';
-import Sync from '../../services/sync';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { db } from '../../common/database';
-import { eScrollEvent } from '../../utils/events';
-import { tabBarRef } from '../../utils/global-refs';
-import JumpToSectionDialog from '../dialogs/jump-to-section';
-import { Footer } from '../list-items/footer';
-import { Header } from '../list-items/headers/header';
-import { SectionHeader } from '../list-items/headers/section-header';
-import { NoteWrapper } from '../list-items/note/wrapper';
-import { NotebookWrapper } from '../list-items/notebook/wrapper';
-import TagItem from '../list-items/tag';
-import { Empty } from './empty';
+import React, { useRef } from "react";
+import { FlatList, RefreshControl, View } from "react-native";
+import Animated, { FadeInDown } from "react-native-reanimated";
+import { notesnook } from "../../../e2e/test.ids";
+import { eSendEvent } from "../../services/event-manager";
+import Sync from "../../services/sync";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { db } from "../../common/database";
+import { eScrollEvent } from "../../utils/events";
+import { tabBarRef } from "../../utils/global-refs";
+import JumpToSectionDialog from "../dialogs/jump-to-section";
+import { Footer } from "../list-items/footer";
+import { Header } from "../list-items/headers/header";
+import { SectionHeader } from "../list-items/headers/section-header";
+import { NoteWrapper } from "../list-items/note/wrapper";
+import { NotebookWrapper } from "../list-items/notebook/wrapper";
+import TagItem from "../list-items/tag";
+import { Empty } from "./empty";
const renderItems = {
note: NoteWrapper,
@@ -30,12 +30,13 @@ const RenderItem = ({ item, index, type, ...restArgs }) => {
if (!item) return <View />;
const Item = renderItems[item.itemType || item.type] || View;
const groupOptions = db.settings?.getGroupOptions(type);
- const dateBy = groupOptions.sortBy !== 'title' ? groupOptions.sortBy : 'dateEdited';
+ const dateBy =
+ groupOptions.sortBy !== "title" ? groupOptions.sortBy : "dateEdited";
const tags =
item.tags
?.slice(0, 3)
- ?.map(item => {
+ ?.map((item) => {
let tag = db.tags.tag(item);
if (!tag) return null;
@@ -45,8 +46,17 @@ const RenderItem = ({ item, index, type, ...restArgs }) => {
alias: tag.alias
};
})
- .filter(t => t !== null) || [];
- return <Item item={item} tags={tags} dateBy={dateBy} index={index} type={type} {...restArgs} />;
+ .filter((t) => t !== null) || [];
+ return (
+ <Item
+ item={item}
+ tags={tags}
+ dateBy={dateBy}
+ index={index}
+ type={type}
+ {...restArgs}
+ />
+ );
};
const List = ({
@@ -56,14 +66,14 @@ const List = ({
placeholderData,
loading,
headerProps = {
- heading: 'Home',
+ heading: "Home",
color: null
},
screen,
ListHeader,
warning
}) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const scrollRef = useRef();
const renderItem = React.useCallback(
@@ -73,7 +83,7 @@ const List = ({
index={index}
color={headerProps.color}
title={headerProps.heading}
- type={screen === 'Notes' ? 'home' : type}
+ type={screen === "Notes" ? "home" : type}
screen={screen}
/>
),
@@ -81,7 +91,7 @@ const List = ({
);
const _onRefresh = async () => {
- Sync.run('global', false, true, () => {
+ Sync.run("global", false, true, () => {
if (refreshCallback) {
refreshCallback();
}
@@ -89,7 +99,7 @@ const List = ({
};
const _onScroll = React.useCallback(
- event => {
+ (event) => {
if (!event) return;
let y = event.nativeEvent.contentOffset.y;
eSendEvent(eScrollEvent, {
@@ -101,12 +111,12 @@ const List = ({
);
let styles = {
- width: '100%',
+ width: "100%",
minHeight: 1,
minWidth: 1
};
- const _keyExtractor = item => item.id || item.title;
+ const _keyExtractor = (item) => item.id || item.title;
return (
<>
@@ -114,7 +124,7 @@ const List = ({
style={{
flex: 1
}}
- entering={type === 'search' ? undefined : FadeInDown}
+ entering={type === "search" ? undefined : FadeInDown}
>
<FlatList
style={styles}
@@ -171,7 +181,7 @@ const List = ({
<JumpToSectionDialog
screen={screen}
data={listData}
- type={screen === 'Notes' ? 'home' : type}
+ type={screen === "Notes" ? "home" : type}
scrollRef={scrollRef}
/>
</>
diff --git a/apps/mobile/app/components/merge-conflicts/index.js b/apps/mobile/app/components/merge-conflicts/index.js
index 3121c1436..888719ccb 100644
--- a/apps/mobile/app/components/merge-conflicts/index.js
+++ b/apps/mobile/app/components/merge-conflicts/index.js
@@ -1,31 +1,35 @@
-import KeepAwake from '@sayem314/react-native-keep-awake';
-import React, { useEffect, useRef, useState } from 'react';
-import { Modal, SafeAreaView, Text, View } from 'react-native';
-import Animated from 'react-native-reanimated';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import Editor from '../../screens/editor';
-import { editorController } from '../../screens/editor/tiptap/utils';
-import { DDS } from '../../services/device-detection';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import Navigation from '../../services/navigation';
-import Sync from '../../services/sync';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { dHeight } from '../../utils';
-import { db } from '../../common/database';
-import { eOnLoadNote, eShowMergeDialog } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { timeConverter } from '../../utils/time';
-import BaseDialog from '../dialog/base-dialog';
-import DialogButtons from '../dialog/dialog-buttons';
-import DialogContainer from '../dialog/dialog-container';
-import DialogHeader from '../dialog/dialog-header';
-import { Button } from '../ui/button';
-import { IconButton } from '../ui/icon-button';
-import Seperator from '../ui/seperator';
-import Paragraph from '../ui/typography/paragraph';
+import KeepAwake from "@sayem314/react-native-keep-awake";
+import React, { useEffect, useRef, useState } from "react";
+import { Modal, SafeAreaView, Text, View } from "react-native";
+import Animated from "react-native-reanimated";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import Editor from "../../screens/editor";
+import { editorController } from "../../screens/editor/tiptap/utils";
+import { DDS } from "../../services/device-detection";
+import {
+ eSendEvent,
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import Navigation from "../../services/navigation";
+import Sync from "../../services/sync";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { dHeight } from "../../utils";
+import { db } from "../../common/database";
+import { eOnLoadNote, eShowMergeDialog } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { timeConverter } from "../../utils/time";
+import BaseDialog from "../dialog/base-dialog";
+import DialogButtons from "../dialog/dialog-buttons";
+import DialogContainer from "../dialog/dialog-container";
+import DialogHeader from "../dialog/dialog-header";
+import { Button } from "../ui/button";
+import { IconButton } from "../ui/icon-button";
+import Seperator from "../ui/seperator";
+import Paragraph from "../ui/typography/paragraph";
const MergeConflicts = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [keep, setKeep] = useState(null);
const [copy, setCopy] = useState(null);
@@ -55,7 +59,7 @@ const MergeConflicts = () => {
if (copy) {
await db.notes.add({
- title: note.title + ' (Copy)',
+ title: note.title + " (Copy)",
content: {
data: copy.data,
type: copy.type
@@ -63,21 +67,24 @@ const MergeConflicts = () => {
});
}
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes"
);
if (editorController.current?.note?.id === note.id) {
// reload the note in editor
- eSendEvent(eOnLoadNote, { ...editorController.current?.note, forced: true });
+ eSendEvent(eOnLoadNote, {
+ ...editorController.current?.note,
+ forced: true
+ });
}
close();
Sync.run();
};
- const show = async item => {
+ const show = async (item) => {
let noteContent = await db.content.raw(item.contentId);
content.current = { ...noteContent };
if (__DEV__) {
@@ -102,42 +109,59 @@ const MergeConflicts = () => {
setDialogVisible(false);
};
- const ConfigBar = ({ isDiscarded, keeping, back, isCurrent, contentToKeep }) => {
+ const ConfigBar = ({
+ isDiscarded,
+ keeping,
+ back,
+ isCurrent,
+ contentToKeep
+ }) => {
return (
<View
style={{
- width: '100%',
+ width: "100%",
height: 50,
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
paddingHorizontal: 12,
paddingLeft: 6
}}
>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'space-between',
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "space-between",
flexShrink: 1
}}
>
- {back && <IconButton onPress={close} color={colors.pri} name="arrow-left" />}
- <Paragraph style={{ flexWrap: 'wrap' }} color={colors.icon} size={SIZE.xs}>
- <Text style={{ color: isCurrent ? colors.accent : colors.red, fontWeight: 'bold' }}>
- {isCurrent ? '(This Device)' : '(Incoming)'}
+ {back && (
+ <IconButton onPress={close} color={colors.pri} name="arrow-left" />
+ )}
+ <Paragraph
+ style={{ flexWrap: "wrap" }}
+ color={colors.icon}
+ size={SIZE.xs}
+ >
+ <Text
+ style={{
+ color: isCurrent ? colors.accent : colors.red,
+ fontWeight: "bold"
+ }}
+ >
+ {isCurrent ? "(This Device)" : "(Incoming)"}
</Text>
- {'\n'}
+ {"\n"}
{timeConverter(contentToKeep?.dateEdited)}
</Paragraph>
</View>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'flex-end'
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "flex-end"
}}
>
{isDiscarded ? (
@@ -187,7 +211,7 @@ const MergeConflicts = () => {
}}
type="accent"
fontSize={SIZE.xs}
- title={keeping && !isDiscarded ? 'Undo' : 'Keep'}
+ title={keeping && !isDiscarded ? "Undo" : "Keep"}
onPress={() => {
setKeep(keeping && !isDiscarded ? null : contentToKeep);
}}
@@ -208,11 +232,11 @@ const MergeConflicts = () => {
close();
}}
supportedOrientations={[
- 'portrait',
- 'portrait-upside-down',
- 'landscape',
- 'landscape-left',
- 'landscape-right'
+ "portrait",
+ "portrait-upside-down",
+ "landscape",
+ "landscape-left",
+ "landscape-right"
]}
visible={true}
>
@@ -244,9 +268,9 @@ const MergeConflicts = () => {
<View
style={{
- height: '100%',
- width: '100%',
- backgroundColor: DDS.isLargeTablet() ? 'rgba(0,0,0,0.3)' : null
+ height: "100%",
+ width: "100%",
+ backgroundColor: DDS.isLargeTablet() ? "rgba(0,0,0,0.3)" : null
}}
>
<ConfigBar
@@ -273,7 +297,7 @@ const MergeConflicts = () => {
onLoad={() => {
const note = db.notes.note(content.current?.noteId)?.data;
if (!note) return;
- eSendEvent(eOnLoadNote + ':conflictPrimary', {
+ eSendEvent(eOnLoadNote + ":conflictPrimary", {
...note,
content: {
...content.current,
@@ -307,7 +331,7 @@ const MergeConflicts = () => {
onLoad={() => {
const note = db.notes.note(content.current?.noteId)?.data;
if (!note) return;
- eSendEvent(eOnLoadNote + ':conflictSecondary', {
+ eSendEvent(eOnLoadNote + ":conflictSecondary", {
...note,
content: { ...content.current.conflicted, isPreview: true }
});
diff --git a/apps/mobile/app/components/note-history/index.js b/apps/mobile/app/components/note-history/index.js
index acbe2ef52..390c66ecb 100644
--- a/apps/mobile/app/components/note-history/index.js
+++ b/apps/mobile/app/components/note-history/index.js
@@ -1,24 +1,24 @@
-import React, { useCallback, useEffect, useState } from 'react';
-import { Text, View } from 'react-native';
-import { FlatList } from 'react-native-gesture-handler';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { presentSheet } from '../../services/event-manager';
-import { db } from '../../common/database';
-import { openLinkInBrowser } from '../../utils/functions';
-import { SIZE } from '../../utils/size';
-import { timeConverter, timeSince } from '../../utils/time';
-import DialogHeader from '../dialog/dialog-header';
-import SheetProvider from '../sheet-provider';
-import { PressableButton } from '../ui/pressable';
-import Seperator from '../ui/seperator';
-import Paragraph from '../ui/typography/paragraph';
-import NotePreview from './preview';
+import React, { useCallback, useEffect, useState } from "react";
+import { Text, View } from "react-native";
+import { FlatList } from "react-native-gesture-handler";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { presentSheet } from "../../services/event-manager";
+import { db } from "../../common/database";
+import { openLinkInBrowser } from "../../utils/functions";
+import { SIZE } from "../../utils/size";
+import { timeConverter, timeSince } from "../../utils/time";
+import DialogHeader from "../dialog/dialog-header";
+import SheetProvider from "../sheet-provider";
+import { PressableButton } from "../ui/pressable";
+import Seperator from "../ui/seperator";
+import Paragraph from "../ui/typography/paragraph";
+import NotePreview from "./preview";
export default function NoteHistory({ note, fwdRef }) {
const [history, setHistory] = useState([]);
const [loading, setLoading] = useState(true);
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
useEffect(() => {
(async () => {
@@ -40,7 +40,7 @@ export default function NoteHistory({ note, fwdRef }) {
content={content}
/>
),
- context: 'note_history'
+ context: "note_history"
});
}
@@ -48,12 +48,12 @@ export default function NoteHistory({ note, fwdRef }) {
let _start = timeConverter(start);
let _end = timeConverter(end + 60000);
if (_start === _end) return _start;
- let final = _end.lastIndexOf(',');
+ let final = _end.lastIndexOf(",");
let part = _end.slice(0, final + 1);
if (_start.includes(part)) {
- return _start + ' —' + _end.replace(part, '');
+ return _start + " —" + _end.replace(part, "");
}
- return _start + ' — ' + _end;
+ return _start + " — " + _end;
};
const renderItem = useCallback(
@@ -62,12 +62,12 @@ export default function NoteHistory({ note, fwdRef }) {
type="grayBg"
onPress={() => preview(item)}
customStyle={{
- justifyContent: 'space-between',
- alignItems: 'center',
+ justifyContent: "space-between",
+ alignItems: "center",
paddingHorizontal: 12,
height: 45,
marginBottom: 10,
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
<Paragraph>{getDate(item.dateCreated, item.dateModified)}</Paragraph>
@@ -97,19 +97,21 @@ export default function NoteHistory({ note, fwdRef }) {
style={{
paddingHorizontal: 12
}}
- keyExtractor={item => item.id}
+ keyExtractor={(item) => item.id}
data={history}
ListEmptyComponent={
<View
style={{
- width: '100%',
- justifyContent: 'center',
- alignItems: 'center',
+ width: "100%",
+ justifyContent: "center",
+ alignItems: "center",
height: 200
}}
>
<Icon name="history" size={60} color={colors.icon} />
- <Paragraph color={colors.icon}>No note history found on this device.</Paragraph>
+ <Paragraph color={colors.icon}>
+ No note history found on this device.
+ </Paragraph>
</View>
}
renderItem={renderItem}
@@ -118,15 +120,18 @@ export default function NoteHistory({ note, fwdRef }) {
size={SIZE.xs}
color={colors.icon}
style={{
- alignSelf: 'center'
+ alignSelf: "center"
}}
>
- Note version history is local only.{' '}
+ Note version history is local only.{" "}
<Text
onPress={() => {
- openLinkInBrowser('https://docs.notesnook.com/versionhistory', colors);
+ openLinkInBrowser(
+ "https://docs.notesnook.com/versionhistory",
+ colors
+ );
}}
- style={{ color: colors.accent, textDecorationLine: 'underline' }}
+ style={{ color: colors.accent, textDecorationLine: "underline" }}
>
Learn how this works.
</Text>
diff --git a/apps/mobile/app/components/note-history/preview.js b/apps/mobile/app/components/note-history/preview.js
index ca2290401..5134db10e 100644
--- a/apps/mobile/app/components/note-history/preview.js
+++ b/apps/mobile/app/components/note-history/preview.js
@@ -1,42 +1,45 @@
-import React from 'react';
-import { View } from 'react-native';
-import Editor from '../../screens/editor';
-import EditorOverlay from '../../screens/editor/loading';
-import { editorController } from '../../screens/editor/tiptap/utils';
-import { eSendEvent, ToastEvent } from '../../services/event-manager';
-import Navigation from '../../services/navigation';
-import { useEditorStore } from '../../stores/use-editor-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { db } from '../../common/database';
-import { eCloseProgressDialog, eOnLoadNote } from '../../utils/events';
-import DialogHeader from '../dialog/dialog-header';
-import { Button } from '../ui/button';
-import Paragraph from '../ui/typography/paragraph';
+import React from "react";
+import { View } from "react-native";
+import Editor from "../../screens/editor";
+import EditorOverlay from "../../screens/editor/loading";
+import { editorController } from "../../screens/editor/tiptap/utils";
+import { eSendEvent, ToastEvent } from "../../services/event-manager";
+import Navigation from "../../services/navigation";
+import { useEditorStore } from "../../stores/use-editor-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { db } from "../../common/database";
+import { eCloseProgressDialog, eOnLoadNote } from "../../utils/events";
+import DialogHeader from "../dialog/dialog-header";
+import { Button } from "../ui/button";
+import Paragraph from "../ui/typography/paragraph";
export default function NotePreview({ session, content }) {
- const colors = useThemeStore(state => state.colors);
- const editorId = ':noteHistory';
+ const colors = useThemeStore((state) => state.colors);
+ const editorId = ":noteHistory";
async function restore() {
await db.noteHistory.restore(session.id);
if (useEditorStore.getState()?.currentEditingNote === session?.noteId) {
if (editorController.current?.note) {
- eSendEvent(eOnLoadNote, { ...editorController.current?.note, forced: true });
+ eSendEvent(eOnLoadNote, {
+ ...editorController.current?.note,
+ forced: true
+ });
}
}
- eSendEvent(eCloseProgressDialog, 'note_history');
+ eSendEvent(eCloseProgressDialog, "note_history");
eSendEvent(eCloseProgressDialog);
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes"
);
ToastEvent.show({
- heading: 'Note restored successfully',
- type: 'success'
+ heading: "Note restored successfully",
+ type: "success"
});
}
@@ -44,7 +47,7 @@ export default function NotePreview({ session, content }) {
<View
style={{
height: session.locked ? null : 600,
- width: '100%'
+ width: "100%"
}}
>
<DialogHeader padding={12} title={session.session} />
@@ -71,13 +74,15 @@ export default function NotePreview({ session, content }) {
) : (
<View
style={{
- width: '100%',
+ width: "100%",
height: 100,
- justifyContent: 'center',
- alignItems: 'center'
+ justifyContent: "center",
+ alignItems: "center"
}}
>
- <Paragraph color={colors.icon}>Preview not available, content is encrypted.</Paragraph>
+ <Paragraph color={colors.icon}>
+ Preview not available, content is encrypted.
+ </Paragraph>
</View>
)}
@@ -86,7 +91,12 @@ export default function NotePreview({ session, content }) {
paddingHorizontal: 12
}}
>
- <Button onPress={restore} title="Restore this version" type="accent" width="100%" />
+ <Button
+ onPress={restore}
+ title="Restore this version"
+ type="accent"
+ width="100%"
+ />
</View>
</View>
);
diff --git a/apps/mobile/app/components/premium/compact-features.js b/apps/mobile/app/components/premium/compact-features.js
index 2dd2d90be..8fd0db498 100644
--- a/apps/mobile/app/components/premium/compact-features.js
+++ b/apps/mobile/app/components/premium/compact-features.js
@@ -1,50 +1,55 @@
-import React from 'react';
-import { ScrollView } from 'react-native';
-import { FeatureBlock } from './feature';
+import React from "react";
+import { ScrollView } from "react-native";
+import { FeatureBlock } from "./feature";
-export const CompactFeatures = ({ vertical, features = [], maxHeight = 500, scrollRef }) => {
+export const CompactFeatures = ({
+ vertical,
+ features = [],
+ maxHeight = 500,
+ scrollRef
+}) => {
let data = vertical
? features
: [
{
- highlight: 'Everything',
- content: 'in basic',
- icon: 'emoticon-wink'
+ highlight: "Everything",
+ content: "in basic",
+ icon: "emoticon-wink"
},
{
- highlight: 'Unlimited',
- content: 'notebooks',
- icon: 'notebook'
+ highlight: "Unlimited",
+ content: "notebooks",
+ icon: "notebook"
},
{
- highlight: 'File & image',
- content: 'attachments',
- icon: 'attachment'
+ highlight: "File & image",
+ content: "attachments",
+ icon: "attachment"
},
{
- highlight: 'Instant',
- content: 'syncing',
- icon: 'sync'
+ highlight: "Instant",
+ content: "syncing",
+ icon: "sync"
},
{
- highlight: 'Private',
- content: 'vault',
- icon: 'shield'
+ highlight: "Private",
+ content: "vault",
+ icon: "shield"
},
{
- highlight: 'Rich text',
- content: 'editing',
- icon: 'square-edit-outline'
+ highlight: "Rich text",
+ content: "editing",
+ icon: "square-edit-outline"
},
{
- highlight: 'PDF & markdown',
- content: 'exports',
- icon: 'file'
+ highlight: "PDF & markdown",
+ content: "exports",
+ icon: "file"
},
{
- highlight: 'Encrypted',
- content: 'backups',
- icon: 'backup-restore'
+ highlight: "Encrypted",
+ content: "backups",
+ icon: "backup-restore"
}
];
@@ -57,11 +62,11 @@ export const CompactFeatures = ({ vertical, features = [], maxHeight = 500, scro
}}
showsHorizontalScrollIndicator={false}
style={{
- width: '100%',
+ width: "100%",
maxHeight: maxHeight
}}
>
- {data.map(item => (
+ {data.map((item) => (
<FeatureBlock key={item.highlight} vertical={vertical} {...item} />
))}
</ScrollView>
diff --git a/apps/mobile/app/components/premium/component.js b/apps/mobile/app/components/premium/component.js
index 0a4eea7d0..9f81864ab 100644
--- a/apps/mobile/app/components/premium/component.js
+++ b/apps/mobile/app/components/premium/component.js
@@ -1,62 +1,64 @@
-import React, { useState } from 'react';
-import { ActivityIndicator, ScrollView, View } from 'react-native';
-import { LAUNCH_ROCKET } from '../../assets/images/assets';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useUserStore } from '../../stores/use-user-store';
-import { DDS } from '../../services/device-detection';
-import { eSendEvent, presentSheet } from '../../services/event-manager';
-import PremiumService from '../../services/premium';
-import { getElevation } from '../../utils';
-import { db } from '../../common/database';
+import React, { useState } from "react";
+import { ActivityIndicator, ScrollView, View } from "react-native";
+import { LAUNCH_ROCKET } from "../../assets/images/assets";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useUserStore } from "../../stores/use-user-store";
+import { DDS } from "../../services/device-detection";
+import { eSendEvent, presentSheet } from "../../services/event-manager";
+import PremiumService from "../../services/premium";
+import { getElevation } from "../../utils";
+import { db } from "../../common/database";
import {
eClosePremiumDialog,
eCloseProgressDialog,
eOpenLoginDialog,
eOpenResultDialog
-} from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import umami from '../../common/analytics';
-import { IconButton } from '../ui/icon-button';
-import { AuthMode } from '../auth';
-import { Button } from '../ui/button';
-import SheetProvider from '../sheet-provider';
-import { SvgView } from '../ui/svg';
-import Seperator from '../ui/seperator';
-import { Toast } from '../toast';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { Walkthrough } from '../walkthroughs';
-import { features } from './features';
-import { Group } from './group';
-import { PricingPlans } from './pricing-plans';
-import { usePricing } from '../../hooks/use-pricing';
+} from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import umami from "../../common/analytics";
+import { IconButton } from "../ui/icon-button";
+import { AuthMode } from "../auth";
+import { Button } from "../ui/button";
+import SheetProvider from "../sheet-provider";
+import { SvgView } from "../ui/svg";
+import Seperator from "../ui/seperator";
+import { Toast } from "../toast";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { Walkthrough } from "../walkthroughs";
+import { features } from "./features";
+import { Group } from "./group";
+import { PricingPlans } from "./pricing-plans";
+import { usePricing } from "../../hooks/use-pricing";
export const Component = ({ close, promo, getRef }) => {
- const colors = useThemeStore(state => state.colors);
- const user = useUserStore(state => state.user);
+ const colors = useThemeStore((state) => state.colors);
+ const user = useUserStore((state) => state.user);
const userCanRequestTrial =
user && (!user.subscription || !user.subscription.expiry) ? true : false;
const [floatingButton, setFloatingButton] = useState(false);
- const pricing = usePricing('monthly');
+ const pricing = usePricing("monthly");
const onPress = async () => {
if (user) {
- umami.pageView('/pro-plans', `/pro-screen`);
+ umami.pageView("/pro-plans", `/pro-screen`);
presentSheet({
- context: 'pricing_plans',
- component: <PricingPlans showTrialOption={false} marginTop={1} promo={promo} />
+ context: "pricing_plans",
+ component: (
+ <PricingPlans showTrialOption={false} marginTop={1} promo={promo} />
+ )
});
} else {
close();
- umami.pageView('/signup', `/pro-screen`);
+ umami.pageView("/signup", `/pro-screen`);
setTimeout(() => {
eSendEvent(eOpenLoginDialog, AuthMode.trialSignup);
}, 400);
}
};
- const onScroll = event => {
+ const onScroll = (event) => {
let contentSize = event.nativeEvent.contentSize.height;
contentSize = contentSize - event.nativeEvent.layoutMeasurement.height;
let yOffset = event.nativeEvent.contentOffset.y;
@@ -70,11 +72,11 @@ export const Component = ({ close, promo, getRef }) => {
return (
<View
style={{
- width: '100%',
+ width: "100%",
backgroundColor: colors.bg,
- justifyContent: 'space-between',
+ justifyContent: "space-between",
borderRadius: 10,
- maxHeight: '100%'
+ maxHeight: "100%"
}}
>
<SheetProvider context="pricing_plans" />
@@ -83,7 +85,7 @@ export const Component = ({ close, promo, getRef }) => {
close();
}}
customStyle={{
- position: 'absolute',
+ position: "absolute",
right: DDS.isTab ? 30 : 15,
top: 30,
zIndex: 10,
@@ -106,24 +108,28 @@ export const Component = ({ close, promo, getRef }) => {
<View
key="top-banner"
style={{
- width: '100%',
- alignItems: 'center',
+ width: "100%",
+ alignItems: "center",
height: 400,
- justifyContent: 'center'
+ justifyContent: "center"
}}
>
- <SvgView width={350} height={350} src={LAUNCH_ROCKET(colors.accent)} />
+ <SvgView
+ width={350}
+ height={350}
+ src={LAUNCH_ROCKET(colors.accent)}
+ />
</View>
<Heading
key="heading"
size={SIZE.lg}
style={{
- alignSelf: 'center',
+ alignSelf: "center",
paddingTop: 20
}}
>
- Notesnook{' '}
+ Notesnook{" "}
<Heading size={SIZE.lg} color={colors.accent}>
Pro
</Heading>
@@ -140,7 +146,7 @@ export const Component = ({ close, promo, getRef }) => {
) : (
<Paragraph
style={{
- alignSelf: 'center',
+ alignSelf: "center",
marginBottom: 20
}}
size={SIZE.md}
@@ -154,10 +160,10 @@ export const Component = ({ close, promo, getRef }) => {
size={SIZE.md}
style={{
paddingHorizontal: 12,
- textAlign: 'center',
- alignSelf: 'center',
+ textAlign: "center",
+ alignSelf: "center",
paddingBottom: 20,
- width: '90%'
+ width: "90%"
}}
>
Ready to take the next step on your private note taking journey?
@@ -172,7 +178,7 @@ export const Component = ({ close, promo, getRef }) => {
eSendEvent(eClosePremiumDialog);
eSendEvent(eCloseProgressDialog);
await sleep(300);
- Walkthrough.present('trialstarted', false, true);
+ Walkthrough.present("trialstarted", false, true);
} catch (e) {}
}}
title="Try free for 14 days"
@@ -189,8 +195,10 @@ export const Component = ({ close, promo, getRef }) => {
<Button
key="calltoaction"
onPress={onPress}
- title={promo ? promo.text : user ? `See all plans` : `Sign up for free`}
- type={userCanRequestTrial ? 'grayAccent' : 'accent'}
+ title={
+ promo ? promo.text : user ? `See all plans` : `Sign up for free`
+ }
+ type={userCanRequestTrial ? "grayAccent" : "accent"}
width={250}
style={{
paddingHorizontal: 12,
@@ -204,16 +212,16 @@ export const Component = ({ close, promo, getRef }) => {
color={colors.icon}
size={SIZE.xs}
style={{
- alignSelf: 'center',
- textAlign: 'center',
+ alignSelf: "center",
+ textAlign: "center",
marginTop: 10,
- maxWidth: '80%'
+ maxWidth: "80%"
}}
>
{user
? `On clicking "Try free for 14 days", your free trial will be activated.`
- : `After sign up you will be asked to activate your free trial.`}{' '}
- <Paragraph size={SIZE.xs} style={{ fontWeight: 'bold' }}>
+ : `After sign up you will be asked to activate your free trial.`}{" "}
+ <Paragraph size={SIZE.xs} style={{ fontWeight: "bold" }}>
No credit card is required.
</Paragraph>
</Paragraph>
@@ -238,11 +246,13 @@ export const Component = ({ close, promo, getRef }) => {
{floatingButton ? (
<Button
onPress={onPress}
- title={promo ? promo.text : user ? `See all plans` : 'Sign up for free'}
+ title={
+ promo ? promo.text : user ? `See all plans` : "Sign up for free"
+ }
type="accent"
style={{
paddingHorizontal: 24,
- position: 'absolute',
+ position: "absolute",
borderRadius: 100,
bottom: 30,
...getElevation(10)
diff --git a/apps/mobile/app/components/premium/expiring.js b/apps/mobile/app/components/premium/expiring.js
index e73478c32..7e05102f5 100644
--- a/apps/mobile/app/components/premium/expiring.js
+++ b/apps/mobile/app/components/premium/expiring.js
@@ -1,30 +1,38 @@
-import React, { useEffect, useState } from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import PremiumService from '../../services/premium';
-import { eOpenPremiumDialog, eOpenResultDialog, eOpenTrialEndingDialog } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { Button } from '../ui/button';
-import BaseDialog from '../dialog/base-dialog';
-import DialogContainer from '../dialog/dialog-container';
-import Seperator from '../ui/seperator';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { CompactFeatures } from './compact-features';
-import { Offer } from './offer';
-import { usePricing } from '../../hooks/use-pricing';
+import React, { useEffect, useState } from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import {
+ eSendEvent,
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import PremiumService from "../../services/premium";
+import {
+ eOpenPremiumDialog,
+ eOpenResultDialog,
+ eOpenTrialEndingDialog
+} from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { Button } from "../ui/button";
+import BaseDialog from "../dialog/base-dialog";
+import DialogContainer from "../dialog/dialog-container";
+import Seperator from "../ui/seperator";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { CompactFeatures } from "./compact-features";
+import { Offer } from "./offer";
+import { usePricing } from "../../hooks/use-pricing";
export const Expiring = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [status, setStatus] = useState({
- title: 'Your trial is ending soon',
+ title: "Your trial is ending soon",
offer: null,
extend: true
});
- const pricing = usePricing('yearly');
+ const pricing = usePricing("yearly");
console.log(pricing?.info?.discount);
const promo = status.offer
@@ -32,8 +40,10 @@ export const Expiring = () => {
promoCode:
pricing?.info?.discount > 30
? pricing.info.sku
- : 'com.streetwriters.notesnook.sub.yr.trialoffer',
- text: `GET ${pricing?.info?.discount > 30 ? pricing?.info?.discount : 30}% OFF on yearly`,
+ : "com.streetwriters.notesnook.sub.yr.trialoffer",
+ text: `GET ${
+ pricing?.info?.discount > 30 ? pricing?.info?.discount : 30
+ }% OFF on yearly`,
discount: pricing?.info?.discount > 30 ? pricing?.info?.discount : 30
}
: null;
@@ -45,7 +55,7 @@ export const Expiring = () => {
};
}, []);
- const open = status => {
+ const open = (status) => {
setStatus(status);
setVisible(true);
};
@@ -60,20 +70,20 @@ export const Expiring = () => {
<DialogContainer>
<View
style={{
- width: '100%',
- alignItems: 'center'
+ width: "100%",
+ alignItems: "center"
}}
>
<View
style={{
paddingHorizontal: 12,
- width: '100%'
+ width: "100%"
}}
>
<Heading
textBreakStrategy="balanced"
style={{
- textAlign: 'center',
+ textAlign: "center",
paddingTop: 18
}}
>
@@ -82,8 +92,8 @@ export const Expiring = () => {
<Seperator />
<View
style={{
- width: '100%',
- alignItems: 'center'
+ width: "100%",
+ alignItems: "center"
}}
>
{status.offer ? (
@@ -95,13 +105,14 @@ export const Expiring = () => {
<Paragraph
textBreakStrategy="balanced"
style={{
- textAlign: 'center',
+ textAlign: "center",
paddingTop: 0,
paddingBottom: 20
}}
size={SIZE.md + 2}
>
- Upgrade now to continue using all the pro features after your trial ends
+ Upgrade now to continue using all the pro features after
+ your trial ends
</Paragraph>
</>
)}
@@ -116,7 +127,7 @@ export const Expiring = () => {
}}
size={SIZE.xs + 1}
style={{
- textDecorationLine: 'underline',
+ textDecorationLine: "underline",
color: colors.icon,
marginTop: 10
}}
@@ -131,7 +142,7 @@ export const Expiring = () => {
<View
style={{
backgroundColor: colors.nav,
- width: '100%',
+ width: "100%",
borderBottomRightRadius: 10,
borderBottomLeftRadius: 10
}}
@@ -142,7 +153,10 @@ export const Expiring = () => {
onPress={async () => {
setVisible(false);
await sleep(300);
- PremiumService.sheet(null, promo?.discount > 30 ? null : promo);
+ PremiumService.sheet(
+ null,
+ promo?.discount > 30 ? null : promo
+ );
}}
fontSize={SIZE.md + 2}
style={{
@@ -157,16 +171,16 @@ export const Expiring = () => {
type="gray"
title="Not sure yet? Extend trial for 7 days"
textStyle={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
onPress={async () => {
setVisible(false);
await sleep(300);
eSendEvent(eOpenResultDialog, {
- title: 'Your trial has been extended',
+ title: "Your trial has been extended",
paragraph:
- 'Try out all features of Notesnook free for 7 more days. No limitations. No commitments.',
- button: 'Continue'
+ "Try out all features of Notesnook free for 7 more days. No limitations. No commitments.",
+ button: "Continue"
});
}}
fontSize={SIZE.xs}
diff --git a/apps/mobile/app/components/premium/feature.js b/apps/mobile/app/components/premium/feature.js
index f15ff763a..865daec66 100644
--- a/apps/mobile/app/components/premium/feature.js
+++ b/apps/mobile/app/components/premium/feature.js
@@ -1,19 +1,26 @@
-import React from 'react';
-import { Text, View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import Paragraph from '../ui/typography/paragraph';
-import { ProTag } from './pro-tag';
+import React from "react";
+import { Text, View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import Paragraph from "../ui/typography/paragraph";
+import { ProTag } from "./pro-tag";
-export const FeatureBlock = ({ vertical, highlight, content, icon, pro, proTagBg }) => {
- const colors = useThemeStore(state => state.colors);
+export const FeatureBlock = ({
+ vertical,
+ highlight,
+ content,
+ icon,
+ pro,
+ proTagBg
+}) => {
+ const colors = useThemeStore((state) => state.colors);
return vertical ? (
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
paddingHorizontal: 12,
marginBottom: 10
}}
@@ -22,7 +29,7 @@ export const FeatureBlock = ({ vertical, highlight, content, icon, pro, proTagBg
<Paragraph
style={{
- flexWrap: 'wrap',
+ flexWrap: "wrap",
marginLeft: 5,
flexShrink: 1
}}
@@ -35,7 +42,7 @@ export const FeatureBlock = ({ vertical, highlight, content, icon, pro, proTagBg
<View
style={{
height: 100,
- justifyContent: 'center',
+ justifyContent: "center",
padding: 10,
marginRight: 10,
borderRadius: 5,
@@ -45,7 +52,7 @@ export const FeatureBlock = ({ vertical, highlight, content, icon, pro, proTagBg
<Icon color={colors.icon} name={icon} size={SIZE.xl} />
<Paragraph size={SIZE.md}>
<Text style={{ color: colors.accent }}>{highlight}</Text>
- {'\n'}
+ {"\n"}
{content}
</Paragraph>
diff --git a/apps/mobile/app/components/premium/features.js b/apps/mobile/app/components/premium/features.js
index c44953298..ac91a6b45 100644
--- a/apps/mobile/app/components/premium/features.js
+++ b/apps/mobile/app/components/premium/features.js
@@ -1,224 +1,227 @@
export const features = [
{
- title: 'Focused on privacy',
+ title: "Focused on privacy",
detail:
- 'Everything you do in Notesnook stays private. We use XChaCha20-Poly1305-IETF and Argon2 to encrypt your notes.',
+ "Everything you do in Notesnook stays private. We use XChaCha20-Poly1305-IETF and Argon2 to encrypt your notes.",
features: [
{
- highlight: 'Zero ads',
- content: '& zero trackers',
- icon: 'billboard'
+ highlight: "Zero ads",
+ content: "& zero trackers",
+ icon: "billboard"
},
{
- highlight: 'On device',
- content: 'encryption',
- icon: 'cellphone'
+ highlight: "On device",
+ content: "encryption",
+ icon: "cellphone"
},
{
- highlight: 'Secure app',
- content: 'lock for all',
- icon: 'cellphone-lock'
+ highlight: "Secure app",
+ content: "lock for all",
+ icon: "cellphone-lock"
},
{
- highlight: '100% end-to-end ',
- content: 'encrypted',
- icon: 'lock'
+ highlight: "100% end-to-end ",
+ content: "encrypted",
+ icon: "lock"
},
{
- highlight: 'Password protected',
- content: 'notes sharing',
- icon: 'file-lock'
+ highlight: "Password protected",
+ content: "notes sharing",
+ icon: "file-lock"
}
]
},
{
- title: 'No limit on notes or devices',
+ title: "No limit on notes or devices",
detail:
"Basic or Pro, you can create unlimited number of notes and access them on all your devices. You won't be running out of space or blocks ever."
},
{
- title: 'Attach files & images',
- detail: 'Add your documents, PDFs, images and videos, and keep them safe and organized.',
+ title: "Attach files & images",
+ detail:
+ "Add your documents, PDFs, images and videos, and keep them safe and organized.",
pro: true,
features: [
{
- highlight: 'Bullet proof',
- content: 'encryption',
- icon: 'lock'
+ highlight: "Bullet proof",
+ content: "encryption",
+ icon: "lock"
},
{
- highlight: 'High quality',
- content: '4k images',
- icon: 'image-multiple'
+ highlight: "High quality",
+ content: "4k images",
+ icon: "image-multiple"
},
{
- highlight: 'No monthly',
- content: 'storage limit',
- icon: 'harddisk'
+ highlight: "No monthly",
+ content: "storage limit",
+ icon: "harddisk"
},
{
- highlight: 'Generous 500 MB',
- content: 'max file size',
- icon: 'file-cabinet'
+ highlight: "Generous 500 MB",
+ content: "max file size",
+ icon: "file-cabinet"
},
{
- highlight: 'No restriction',
- content: 'on file type',
- icon: 'file'
+ highlight: "No restriction",
+ content: "on file type",
+ icon: "file"
}
]
},
{
- title: 'Keep secrets always locked with private vault',
+ title: "Keep secrets always locked with private vault",
detail:
- 'An extra layer of security for any important data. Notes in the vault always stay encrypted and require a password to be accessed or edited everytime.',
+ "An extra layer of security for any important data. Notes in the vault always stay encrypted and require a password to be accessed or edited everytime.",
pro: true
},
{
- title: 'Organize yourself in the best way',
- detail: 'We offer multiple ways to keep you organized. The only limit is your imagination.',
+ title: "Organize yourself in the best way",
+ detail:
+ "We offer multiple ways to keep you organized. The only limit is your imagination.",
features: [
{
- highlight: 'Unlimited',
- content: 'notebooks & tags*',
- icon: 'emoticon',
+ highlight: "Unlimited",
+ content: "notebooks & tags*",
+ icon: "emoticon",
pro: true
},
{
- highlight: 'Organize',
- content: 'with colors',
- icon: 'palette',
+ highlight: "Organize",
+ content: "with colors",
+ icon: "palette",
pro: true
},
{
- highlight: 'Side menu',
- content: 'shortcuts',
- icon: 'link-variant'
+ highlight: "Side menu",
+ content: "shortcuts",
+ icon: "link-variant"
},
{
- highlight: 'Pin note in',
- content: 'notifications',
- icon: 'pin',
- platform: 'android'
+ highlight: "Pin note in",
+ content: "notifications",
+ icon: "pin",
+ platform: "android"
}
],
- info: '* Free users are limited to keeping 3 notebooks (no limit on topics) and 5 tags.'
+ info: "* Free users are limited to keeping 3 notebooks (no limit on topics) and 5 tags."
},
{
- title: 'Instant syncing',
+ title: "Instant syncing",
detail:
- 'Seemlessly work from anywhere on any device. Every change is synced instantly to all your devices.',
+ "Seemlessly work from anywhere on any device. Every change is synced instantly to all your devices.",
pro: true
},
{
- title: 'Rich tools for rich editing',
+ title: "Rich tools for rich editing",
detail:
- 'Having the right tool at the right time is crucial for note taking. Lists, tables, codeblocks — you name it, we have it.',
+ "Having the right tool at the right time is crucial for note taking. Lists, tables, codeblocks — you name it, we have it.",
features: [
{
- highlight: 'Basic formating',
- content: 'and lists',
- icon: 'format-bold'
+ highlight: "Basic formating",
+ content: "and lists",
+ icon: "format-bold"
},
{
- highlight: 'Checklists',
- content: '& tables',
- icon: 'table',
+ highlight: "Checklists",
+ content: "& tables",
+ icon: "table",
pro: true
},
{
- highlight: 'Markdown',
- content: 'support',
- icon: 'language-markdown',
+ highlight: "Markdown",
+ content: "support",
+ icon: "language-markdown",
pro: true
},
{
- highlight: 'Write notes from',
- content: 'notifications',
- icon: 'bell',
- platform: 'android'
+ highlight: "Write notes from",
+ content: "notifications",
+ icon: "bell",
+ platform: "android"
}
]
},
{
- title: 'Safe publishing to the Internet',
+ title: "Safe publishing to the Internet",
detail:
- 'Publishing is nothing new but we offer fully encrypted, anonymous publishing. Take any note & share it with the world.',
+ "Publishing is nothing new but we offer fully encrypted, anonymous publishing. Take any note & share it with the world.",
features: [
{
- highlight: 'Password protected',
- content: 'sharing',
- icon: 'send-lock'
+ highlight: "Password protected",
+ content: "sharing",
+ icon: "send-lock"
},
{
- highlight: 'Self destruct',
- content: 'monographs',
- icon: 'bomb'
+ highlight: "Self destruct",
+ content: "monographs",
+ icon: "bomb"
}
]
},
{
- title: 'Export and take your notes anywhere',
+ title: "Export and take your notes anywhere",
pro: true,
detail:
- 'You own your notes, not us. No proprietary formats. No vendor lock in. No waiting for hours to download your notes.',
- info: '* Free users can export notes in well formatted plain text.',
+ "You own your notes, not us. No proprietary formats. No vendor lock in. No waiting for hours to download your notes.",
+ info: "* Free users can export notes in well formatted plain text.",
features: [
{
- highlight: 'Export as ',
- content: 'Markdown',
- icon: 'language-markdown',
+ highlight: "Export as ",
+ content: "Markdown",
+ icon: "language-markdown",
pro: true
},
{
- highlight: 'Export as',
- content: 'PDF',
- icon: 'file-pdf-box',
+ highlight: "Export as",
+ content: "PDF",
+ icon: "file-pdf-box",
pro: true
},
{
- highlight: 'Export as',
- content: 'HTML',
- icon: 'language-html5',
+ highlight: "Export as",
+ content: "HTML",
+ icon: "language-html5",
pro: true
},
{
- highlight: 'Export as',
- content: 'text',
- icon: 'clipboard-text-outline'
+ highlight: "Export as",
+ content: "text",
+ icon: "clipboard-text-outline"
}
]
},
{
- title: 'Backup & keep your notes safe',
+ title: "Backup & keep your notes safe",
detail:
- 'Do not worry about losing your data. Turn on automatic backups on weekly or daily basis.',
+ "Do not worry about losing your data. Turn on automatic backups on weekly or daily basis.",
features: [
{
- highlight: 'Backup',
- content: 'encryption',
- icon: 'backup-restore'
+ highlight: "Backup",
+ content: "encryption",
+ icon: "backup-restore"
}
],
pro: true
},
{
- title: 'Personalize & make Notesnook your own',
- detail: 'Change app themes to match your style. Custom themes are coming soon.',
+ title: "Personalize & make Notesnook your own",
+ detail:
+ "Change app themes to match your style. Custom themes are coming soon.",
features: [
{
- highlight: 'Automatic',
- content: 'dark mode',
- icon: 'theme-light-dark',
+ highlight: "Automatic",
+ content: "dark mode",
+ icon: "theme-light-dark",
pro: false
},
{
- highlight: 'Change accent',
- content: 'color',
- icon: 'invert-colors',
+ highlight: "Change accent",
+ content: "color",
+ icon: "invert-colors",
pro: true
}
]
diff --git a/apps/mobile/app/components/premium/group.js b/apps/mobile/app/components/premium/group.js
index 0b607840f..136a9ec5d 100644
--- a/apps/mobile/app/components/premium/group.js
+++ b/apps/mobile/app/components/premium/group.js
@@ -1,14 +1,14 @@
-import React from 'react';
-import { ScrollView, View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { FeatureBlock } from './feature';
-import { ProTag } from './pro-tag';
+import React from "react";
+import { ScrollView, View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { FeatureBlock } from "./feature";
+import { ProTag } from "./pro-tag";
export const Group = ({ item, index }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<View
@@ -19,7 +19,10 @@ export const Group = ({ item, index }) => {
}}
>
{item?.pro ? (
- <ProTag size={SIZE.sm} background={index % 2 === 0 ? colors.bg : colors.nav} />
+ <ProTag
+ size={SIZE.sm}
+ background={index % 2 === 0 ? colors.bg : colors.nav}
+ />
) : null}
<Heading>{item.title}</Heading>
<Paragraph size={SIZE.md}>{item.detail}</Paragraph>
@@ -32,7 +35,7 @@ export const Group = ({ item, index }) => {
horizontal
showsHorizontalScrollIndicator={false}
>
- {item.features?.map(item => (
+ {item.features?.map((item) => (
<FeatureBlock
key={item.detail}
{...item}
diff --git a/apps/mobile/app/components/premium/index.js b/apps/mobile/app/components/premium/index.js
index ad02a1cb0..d320dab36 100644
--- a/apps/mobile/app/components/premium/index.js
+++ b/apps/mobile/app/components/premium/index.js
@@ -1,8 +1,11 @@
-import React, { createRef } from 'react';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import { eClosePremiumDialog, eOpenPremiumDialog } from '../../utils/events';
-import BaseDialog from '../dialog/base-dialog';
-import { Component } from './component';
+import React, { createRef } from "react";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import { eClosePremiumDialog, eOpenPremiumDialog } from "../../utils/events";
+import BaseDialog from "../dialog/base-dialog";
+import { Component } from "./component";
class PremiumDialog extends React.Component {
constructor(props) {
@@ -24,7 +27,7 @@ class PremiumDialog extends React.Component {
eUnSubscribeEvent(eClosePremiumDialog, this.close);
}
- open = promoInfo => {
+ open = (promoInfo) => {
this.setState({
visible: true,
promo: promoInfo
@@ -52,7 +55,11 @@ class PremiumDialog extends React.Component {
background={this.props.colors.bg}
onRequestClose={this.onClose}
>
- <Component getRef={() => this.actionSheetRef} promo={this.state.promo} close={this.close} />
+ <Component
+ getRef={() => this.actionSheetRef}
+ promo={this.state.promo}
+ close={this.close}
+ />
</BaseDialog>
);
}
diff --git a/apps/mobile/app/components/premium/offer.js b/apps/mobile/app/components/premium/offer.js
index 3f2bd9765..8fd104ebb 100644
--- a/apps/mobile/app/components/premium/offer.js
+++ b/apps/mobile/app/components/premium/offer.js
@@ -1,22 +1,26 @@
-import React from 'react';
-import { Text } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import Paragraph from '../ui/typography/paragraph';
+import React from "react";
+import { Text } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import Paragraph from "../ui/typography/paragraph";
-export const Offer = ({ off = '30', text = 'on yearly plan, offer ends soon', padding = 0 }) => {
- const colors = useThemeStore(state => state.colors);
+export const Offer = ({
+ off = "30",
+ text = "on yearly plan, offer ends soon",
+ padding = 0
+}) => {
+ const colors = useThemeStore((state) => state.colors);
return (
<Paragraph
style={{
- textAlign: 'center',
+ textAlign: "center",
paddingVertical: padding
}}
size={SIZE.xxxl}
>
GET {off}
- <Text style={{ color: colors.accent }}>%</Text> OFF!{'\n'}
+ <Text style={{ color: colors.accent }}>%</Text> OFF!{"\n"}
<Paragraph color={colors.icon}>{text}</Paragraph>
</Paragraph>
);
diff --git a/apps/mobile/app/components/premium/premium-toast.js b/apps/mobile/app/components/premium/premium-toast.js
index 04fbd81cb..1e03e8a4e 100644
--- a/apps/mobile/app/components/premium/premium-toast.js
+++ b/apps/mobile/app/components/premium/premium-toast.js
@@ -1,24 +1,32 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { View } from 'react-native';
-import Animated, { FadeInUp, FadeOutUp } from 'react-native-reanimated';
-import { editorState } from '../../screens/editor/tiptap/utils';
-import { DDS } from '../../services/device-detection';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { getElevation } from '../../utils';
-import { eCloseActionSheet, eOpenPremiumDialog, eShowGetPremium } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { Button } from '../ui/button';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React, { useEffect, useRef, useState } from "react";
+import { View } from "react-native";
+import Animated, { FadeInUp, FadeOutUp } from "react-native-reanimated";
+import { editorState } from "../../screens/editor/tiptap/utils";
+import { DDS } from "../../services/device-detection";
+import {
+ eSendEvent,
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { getElevation } from "../../utils";
+import {
+ eCloseActionSheet,
+ eOpenPremiumDialog,
+ eShowGetPremium
+} from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { Button } from "../ui/button";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
-export const PremiumToast = ({ close, context = 'global', offset = 0 }) => {
- const colors = useThemeStore(state => state.colors);
+export const PremiumToast = ({ close, context = "global", offset = 0 }) => {
+ const colors = useThemeStore((state) => state.colors);
const [msg, setMsg] = useState(null);
const timer = useRef();
- const open = event => {
+ const open = (event) => {
if (!event) {
clearTimeout(timer);
timer.current = null;
@@ -62,17 +70,17 @@ export const PremiumToast = ({ close, context = 'global', offset = 0 }) => {
entering={FadeInUp}
exiting={FadeOutUp}
style={{
- position: 'absolute',
+ position: "absolute",
backgroundColor: colors.nav,
zIndex: 999,
...getElevation(20),
padding: 12,
borderRadius: 10,
- flexDirection: 'row',
- alignSelf: 'center',
- justifyContent: 'space-between',
+ flexDirection: "row",
+ alignSelf: "center",
+ justifyContent: "space-between",
top: offset,
- maxWidth: DDS.isLargeTablet() ? 400 : '98%'
+ maxWidth: DDS.isLargeTablet() ? 400 : "98%"
}}
>
<View
@@ -84,7 +92,7 @@ export const PremiumToast = ({ close, context = 'global', offset = 0 }) => {
>
<Heading
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
color={colors.accent}
size={SIZE.md}
@@ -94,7 +102,7 @@ export const PremiumToast = ({ close, context = 'global', offset = 0 }) => {
<Paragraph
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
size={SIZE.sm}
color={colors.pri}
diff --git a/apps/mobile/app/components/premium/pricing-item.js b/apps/mobile/app/components/premium/pricing-item.js
index 8b22c8e0f..06287c689 100644
--- a/apps/mobile/app/components/premium/pricing-item.js
+++ b/apps/mobile/app/components/premium/pricing-item.js
@@ -1,42 +1,48 @@
-import React from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { getElevation } from '../../utils';
-import { SIZE } from '../../utils/size';
-import { PressableButton } from '../ui/pressable';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { getElevation } from "../../utils";
+import { SIZE } from "../../utils/size";
+import { PressableButton } from "../ui/pressable";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
export const PricingItem = ({ product, onPress, compact }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<PressableButton
onPress={onPress}
type="grayBg"
customStyle={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
paddingHorizontal: 12,
paddingVertical: compact ? 15 : 10,
- width: compact ? null : '100%',
+ width: compact ? null : "100%",
minWidth: 150
}}
>
{!compact && (
<View>
<Heading size={SIZE.lg - 2}>
- {product?.type === 'yearly' || product?.offerType === 'yearly' ? 'Yearly' : 'Monthly'}
+ {product?.type === "yearly" || product?.offerType === "yearly"
+ ? "Yearly"
+ : "Monthly"}
</Heading>
- {product?.info && <Paragraph size={SIZE.xs}>{product.info}</Paragraph>}
+ {product?.info && (
+ <Paragraph size={SIZE.xs}>{product.info}</Paragraph>
+ )}
</View>
)}
<View>
<Paragraph size={SIZE.sm}>
<Heading size={SIZE.lg - 2}>{product?.data?.localizedPrice}/</Heading>
- {product?.type === 'yearly' || product?.offerType === 'yearly' ? '/year' : '/month'}
+ {product?.type === "yearly" || product?.offerType === "yearly"
+ ? "/year"
+ : "/month"}
</Paragraph>
</View>
</PressableButton>
diff --git a/apps/mobile/app/components/premium/pricing-plans.js b/apps/mobile/app/components/premium/pricing-plans.js
index 1266b28ca..716dee99e 100644
--- a/apps/mobile/app/components/premium/pricing-plans.js
+++ b/apps/mobile/app/components/premium/pricing-plans.js
@@ -1,54 +1,63 @@
-import React, { useEffect, useState } from 'react';
-import { ActivityIndicator, Platform, Text, View } from 'react-native';
-import * as RNIap from 'react-native-iap';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useUserStore } from '../../stores/use-user-store';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
-import PremiumService from '../../services/premium';
-import { db } from '../../common/database';
+import React, { useEffect, useState } from "react";
+import { ActivityIndicator, Platform, Text, View } from "react-native";
+import * as RNIap from "react-native-iap";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useUserStore } from "../../stores/use-user-store";
+import {
+ eSendEvent,
+ presentSheet,
+ ToastEvent
+} from "../../services/event-manager";
+import PremiumService from "../../services/premium";
+import { db } from "../../common/database";
import {
eClosePremiumDialog,
eCloseProgressDialog,
eCloseSimpleDialog,
eOpenLoginDialog
-} from '../../utils/events';
-import { openLinkInBrowser } from '../../utils/functions';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import umami from '../../common/analytics';
-import { Button } from '../ui/button';
-import { Dialog } from '../dialog';
-import BaseDialog from '../dialog/base-dialog';
-import { presentDialog } from '../dialog/functions';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { Walkthrough } from '../walkthroughs';
-import { PricingItem } from './pricing-item';
-import { usePricing } from '../../hooks/use-pricing';
+} from "../../utils/events";
+import { openLinkInBrowser } from "../../utils/functions";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import umami from "../../common/analytics";
+import { Button } from "../ui/button";
+import { Dialog } from "../dialog";
+import BaseDialog from "../dialog/base-dialog";
+import { presentDialog } from "../dialog/functions";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { Walkthrough } from "../walkthroughs";
+import { PricingItem } from "./pricing-item";
+import { usePricing } from "../../hooks/use-pricing";
const promoCyclesMonthly = {
- 1: 'first month',
- 2: 'first 2 months',
- 3: 'first 3 months'
+ 1: "first month",
+ 2: "first 2 months",
+ 3: "first 3 months"
};
const promoCyclesYearly = {
- 1: 'first year',
- 2: 'first 2 years',
- 3: 'first 3 years'
+ 1: "first year",
+ 2: "first 2 years",
+ 3: "first 3 years"
};
-export const PricingPlans = ({ promo, marginTop, heading = true, compact = false }) => {
- const colors = useThemeStore(state => state.colors);
- const user = useUserStore(state => state.user);
+export const PricingPlans = ({
+ promo,
+ marginTop,
+ heading = true,
+ compact = false
+}) => {
+ const colors = useThemeStore((state) => state.colors);
+ const user = useUserStore((state) => state.user);
const [product, setProduct] = useState(null);
const [buying, setBuying] = useState(false);
const [loading, setLoading] = useState(false);
const userCanRequestTrial =
user && (!user.subscription || !user.subscription.expiry) ? true : false;
const [upgrade, setUpgrade] = useState(!userCanRequestTrial);
- const yearlyPlan = usePricing('yearly');
- const monthlyPlan = usePricing('monthly');
+ const yearlyPlan = usePricing("yearly");
+ const monthlyPlan = usePricing("monthly");
const getSkus = async () => {
try {
@@ -59,41 +68,43 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
setLoading(false);
} catch (e) {
setLoading(false);
- console.log('error getting sku', e);
+ console.log("error getting sku", e);
}
};
- const getPromo = async code => {
+ const getPromo = async (code) => {
try {
let productId;
- if (code.startsWith('com.streetwriters.notesnook')) {
+ if (code.startsWith("com.streetwriters.notesnook")) {
productId = code;
} else {
- productId = await db.offers.getCode(code.split(':')[0], Platform.OS);
+ productId = await db.offers.getCode(code.split(":")[0], Platform.OS);
}
let products = await PremiumService.getProducts();
- let product = products.find(p => p.productId === productId);
+ let product = products.find((p) => p.productId === productId);
if (!product) return false;
- let isMonthly = product.productId.indexOf('.mo') > -1;
+ let isMonthly = product.productId.indexOf(".mo") > -1;
let cycleText = isMonthly
? promoCyclesMonthly[
- product.introductoryPriceCyclesAndroid || product.introductoryPriceNumberOfPeriodsIOS
+ product.introductoryPriceCyclesAndroid ||
+ product.introductoryPriceNumberOfPeriodsIOS
]
: promoCyclesYearly[
- product.introductoryPriceCyclesAndroid || product.introductoryPriceNumberOfPeriodsIOS
+ product.introductoryPriceCyclesAndroid ||
+ product.introductoryPriceNumberOfPeriodsIOS
];
setProduct({
- type: 'promo',
- offerType: isMonthly ? 'monthly' : 'yearly',
+ type: "promo",
+ offerType: isMonthly ? "monthly" : "yearly",
data: product,
cycleText: cycleText,
- info: 'Pay monthly, cancel anytime'
+ info: "Pay monthly, cancel anytime"
});
return true;
} catch (e) {
- console.log('PROMOCODE ERROR:', code, e);
+ console.log("PROMOCODE ERROR:", code, e);
return false;
}
};
@@ -102,7 +113,7 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
getSkus();
}, []);
- const buySubscription = async product => {
+ const buySubscription = async (product) => {
if (buying) return;
setBuying(true);
try {
@@ -110,20 +121,30 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
setBuying(false);
return;
}
- umami.pageView('/iap-native', `${compact ? 'pro-sheet' : 'pro-screen'}/pro-plans`);
- await RNIap.requestSubscription(product?.productId, false, null, null, null, user.id);
+ umami.pageView(
+ "/iap-native",
+ `${compact ? "pro-sheet" : "pro-screen"}/pro-plans`
+ );
+ await RNIap.requestSubscription(
+ product?.productId,
+ false,
+ null,
+ null,
+ null,
+ user.id
+ );
setBuying(false);
eSendEvent(eCloseProgressDialog);
eSendEvent(eClosePremiumDialog);
await sleep(500);
presentSheet({
- title: 'Thank you for subscribing!',
+ title: "Thank you for subscribing!",
paragraph: `Your Notesnook Pro subscription will be activated soon. If your account is not upgraded to Notesnook Pro, your money will be refunded to you. In case of any issues, please reach out to us at [email protected]`,
action: async () => {
eSendEvent(eCloseProgressDialog);
},
- icon: 'check',
- actionText: 'Continue'
+ icon: "check",
+ actionText: "Continue"
});
} catch (e) {
setBuying(false);
@@ -135,8 +156,8 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
<View
style={{
paddingHorizontal: 12,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
height: 100
}}
>
@@ -158,7 +179,7 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
<>
<Paragraph
style={{
- alignSelf: 'center'
+ alignSelf: "center"
}}
size={SIZE.lg}
>
@@ -186,7 +207,7 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
eSendEvent(eClosePremiumDialog);
eSendEvent(eCloseProgressDialog);
await sleep(300);
- Walkthrough.present('trialstarted', false, true);
+ Walkthrough.present("trialstarted", false, true);
} catch (e) {}
}}
title={`Try free for 14 days`}
@@ -201,25 +222,25 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
</>
) : (
<>
- {product?.type === 'promo' ? (
+ {product?.type === "promo" ? (
<Heading
style={{
paddingVertical: 15,
- alignSelf: 'center',
- textAlign: 'center'
+ alignSelf: "center",
+ textAlign: "center"
}}
size={SIZE.lg - 4}
>
{product.data.introductoryPrice}
<Paragraph
style={{
- textDecorationLine: 'line-through',
+ textDecorationLine: "line-through",
color: colors.icon
}}
size={SIZE.sm}
>
({product.data.localizedPrice})
- </Paragraph>{' '}
+ </Paragraph>{" "}
for {product.cycleText}
</Heading>
) : null}
@@ -231,19 +252,20 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
{monthlyPlan && monthlyPlan?.info?.discount > 0 ? (
<View
style={{
- alignSelf: 'center',
+ alignSelf: "center",
marginTop: marginTop || 20,
marginBottom: 20
}}
>
<Heading color={colors.accent}>
- Get {monthlyPlan?.info?.discount}% off in {monthlyPlan?.info?.country}
+ Get {monthlyPlan?.info?.discount}% off in{" "}
+ {monthlyPlan?.info?.country}
</Heading>
</View>
) : (
<Heading
style={{
- alignSelf: 'center',
+ alignSelf: "center",
marginTop: marginTop || 20,
marginBottom: 20
}}
@@ -256,18 +278,18 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
<View
style={{
- flexDirection: !compact ? 'column' : 'row',
- flexWrap: 'wrap',
- justifyContent: 'space-around'
+ flexDirection: !compact ? "column" : "row",
+ flexWrap: "wrap",
+ justifyContent: "space-around"
}}
>
<PricingItem
onPress={() => buySubscription(monthlyPlan?.product)}
compact={compact}
product={{
- type: 'monthly',
+ type: "monthly",
data: monthlyPlan?.product,
- info: 'Pay monthly, cancel anytime.'
+ info: "Pay monthly, cancel anytime."
}}
/>
@@ -284,14 +306,14 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
onPress={() => buySubscription(yearlyPlan?.product)}
compact={compact}
product={{
- type: 'yearly',
+ type: "yearly",
data: yearlyPlan?.product,
- info: 'Pay yearly'
+ info: "Pay yearly"
}}
/>
</View>
- {Platform.OS !== 'ios' ? (
+ {Platform.OS !== "ios" ? (
<Button
height={35}
style={{
@@ -299,36 +321,37 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
}}
onPress={() => {
presentDialog({
- context: 'local',
+ context: "local",
input: true,
- inputPlaceholder: 'Enter code',
- positiveText: 'Apply',
- positivePress: async value => {
+ inputPlaceholder: "Enter code",
+ positiveText: "Apply",
+ positivePress: async (value) => {
if (!value) return;
console.log(value);
eSendEvent(eCloseSimpleDialog);
setBuying(true);
try {
if (!(await getPromo(value)))
- throw new Error('Error applying promo code');
+ throw new Error("Error applying promo code");
ToastEvent.show({
- heading: 'Discount applied!',
- type: 'success',
- context: 'local'
+ heading: "Discount applied!",
+ type: "success",
+ context: "local"
});
setBuying(false);
} catch (e) {
setBuying(false);
ToastEvent.show({
- heading: 'Promo code invalid or expired',
+ heading: "Promo code invalid or expired",
message: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
}
},
- title: 'Have a promo code?',
- paragraph: 'Enter your promo code to get a special discount.'
+ title: "Have a promo code?",
+ paragraph:
+ "Enter your promo code to get a special discount."
});
}}
title="I have a promo code"
@@ -363,26 +386,26 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
borderRadius: 100
}}
/>
- {Platform.OS !== 'ios' &&
+ {Platform.OS !== "ios" &&
promo &&
- !promo.promoCode.startsWith('com.streetwriters.notesnook') ? (
+ !promo.promoCode.startsWith("com.streetwriters.notesnook") ? (
<Paragraph
size={SIZE.md}
textBreakStrategy="balanced"
style={{
- alignSelf: 'center',
- justifyContent: 'center',
- textAlign: 'center'
+ alignSelf: "center",
+ justifyContent: "center",
+ textAlign: "center"
}}
>
- Use promo code{' '}
+ Use promo code{" "}
<Text
style={{
- fontFamily: 'OpenSans-SemiBold'
+ fontFamily: "OpenSans-SemiBold"
}}
>
{promo.promoCode}
- </Text>{' '}
+ </Text>{" "}
at checkout
</Paragraph>
) : null}
@@ -421,16 +444,16 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
color={colors.icon}
size={SIZE.xs}
style={{
- alignSelf: 'center',
- textAlign: 'center',
+ alignSelf: "center",
+ textAlign: "center",
marginTop: 10,
- maxWidth: '80%'
+ maxWidth: "80%"
}}
>
{user
? `On clicking "Try free for 14 days", your free trial will be activated.`
- : `After sign up you will be asked to activate your free trial.`}{' '}
- <Paragraph size={SIZE.xs} style={{ fontWeight: 'bold' }}>
+ : `After sign up you will be asked to activate your free trial.`}{" "}
+ <Paragraph size={SIZE.xs} style={{ fontWeight: "bold" }}>
No credit card is required.
</Paragraph>
</Paragraph>
@@ -438,78 +461,79 @@ export const PricingPlans = ({ promo, marginTop, heading = true, compact = false
{user && upgrade ? (
<>
- {Platform.OS === 'ios' ? (
+ {Platform.OS === "ios" ? (
<Paragraph
textBreakStrategy="balanced"
size={SIZE.xs}
color={colors.icon}
style={{
- alignSelf: 'center',
+ alignSelf: "center",
marginTop: 10,
- textAlign: 'center'
+ textAlign: "center"
}}
>
- By subscribing, you will be charged to your iTunes Account for the selected plan.
- Subscriptions will automatically renew unless cancelled within 24-hours before the end
- of the current period.
+ By subscribing, you will be charged to your iTunes Account for the
+ selected plan. Subscriptions will automatically renew unless
+ cancelled within 24-hours before the end of the current period.
</Paragraph>
) : (
<Paragraph
size={SIZE.xs}
color={colors.icon}
style={{
- alignSelf: 'center',
+ alignSelf: "center",
marginTop: 10,
- textAlign: 'center'
+ textAlign: "center"
}}
>
- By subscribing, your will be charged on your Google Account, and your subscription
- will automatically renew until you cancel prior to the end of the then current period.
+ By subscribing, your will be charged on your Google Account, and
+ your subscription will automatically renew until you cancel prior
+ to the end of the then current period.
</Paragraph>
)}
<View
style={{
- width: '100%'
+ width: "100%"
}}
>
<Paragraph
size={SIZE.xs}
color={colors.icon}
style={{
- maxWidth: '100%',
- textAlign: 'center'
+ maxWidth: "100%",
+ textAlign: "center"
}}
>
- By subscribing, you agree to our{' '}
+ By subscribing, you agree to our{" "}
<Paragraph
size={SIZE.xs}
onPress={() => {
- openLinkInBrowser('https://notesnook.com/tos', colors)
- .catch(e => {})
- .then(r => {
- console.log('closed');
+ openLinkInBrowser("https://notesnook.com/tos", colors)
+ .catch((e) => {})
+ .then((r) => {
+ console.log("closed");
});
}}
style={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
color={colors.accent}
>
- Terms of Service{' '}
+ Terms of Service{" "}
</Paragraph>
- and{' '}
+ and{" "}
<Paragraph
size={SIZE.xs}
onPress={() => {
- openLinkInBrowser('https://notesnook.com/privacy', colors)
- .catch(e => {})
- .then(r => {
- console.log('closed');
+ openLinkInBrowser("https://notesnook.com/privacy", colors)
+ .catch((e) => {})
+ .then((r) => {
+ console.log("closed");
});
}}
style={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
color={colors.accent}
>
diff --git a/apps/mobile/app/components/premium/pro-tag.js b/apps/mobile/app/components/premium/pro-tag.js
index e375990fc..d38208d03 100644
--- a/apps/mobile/app/components/premium/pro-tag.js
+++ b/apps/mobile/app/components/premium/pro-tag.js
@@ -1,11 +1,11 @@
-import React from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../stores/use-theme-store';
-import Paragraph from '../ui/typography/paragraph';
+import React from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../stores/use-theme-store";
+import Paragraph from "../ui/typography/paragraph";
export const ProTag = ({ width, size, background }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<View
@@ -13,10 +13,10 @@ export const ProTag = ({ width, size, background }) => {
backgroundColor: background || colors.bg,
borderRadius: 100,
width: width || 60,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
paddingVertical: 2.5,
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
<Icon
diff --git a/apps/mobile/app/components/properties/color-tags.js b/apps/mobile/app/components/properties/color-tags.js
index bf9ca9e66..ab68920ef 100644
--- a/apps/mobile/app/components/properties/color-tags.js
+++ b/apps/mobile/app/components/properties/color-tags.js
@@ -1,26 +1,26 @@
-import React, { useState } from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { notesnook } from '../../../e2e/test.ids';
-import { useMenuStore } from '../../stores/use-menu-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { DDS } from '../../services/device-detection';
-import { eSendEvent } from '../../services/event-manager';
-import Navigation from '../../services/navigation';
-import { dWidth } from '../../utils';
-import { COLORS_NOTE } from '../../utils/color-scheme';
-import { db } from '../../common/database';
-import { refreshNotesPage } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { PressableButton } from '../ui/pressable';
+import React, { useState } from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { notesnook } from "../../../e2e/test.ids";
+import { useMenuStore } from "../../stores/use-menu-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { DDS } from "../../services/device-detection";
+import { eSendEvent } from "../../services/event-manager";
+import Navigation from "../../services/navigation";
+import { dWidth } from "../../utils";
+import { COLORS_NOTE } from "../../utils/color-scheme";
+import { db } from "../../common/database";
+import { refreshNotesPage } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { PressableButton } from "../ui/pressable";
export const ColorTags = ({ item, close }) => {
const [note, setNote] = useState(item);
- const setColorNotes = useMenuStore(state => state.setColorNotes);
- const dimensions = useSettingStore(state => state.dimensions);
+ const setColorNotes = useMenuStore((state) => state.setColorNotes);
+ const dimensions = useSettingStore((state) => state.dimensions);
let width = dimensions.width > 600 ? 600 : 500;
- const changeColor = async color => {
+ const changeColor = async (color) => {
if (note.color === color.name) {
await db.notes.note(note.id).uncolor();
} else {
@@ -30,16 +30,16 @@ export const ColorTags = ({ item, close }) => {
setNote({ ..._note });
setColorNotes();
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes"
);
eSendEvent(refreshNotesPage);
};
- const _renderColor = c => {
+ const _renderColor = (c) => {
const color = {
name: c,
value: COLORS_NOTE[c?.toLowerCase()]
@@ -56,8 +56,8 @@ export const ColorTags = ({ item, close }) => {
width: DDS.isTab ? width / 10 : dWidth / 9,
height: DDS.isTab ? width / 10 : dWidth / 9,
borderRadius: 100,
- justifyContent: 'center',
- alignItems: 'center'
+ justifyContent: "center",
+ alignItems: "center"
}}
>
{note.color?.toLowerCase() === color.name ? (
@@ -70,14 +70,14 @@ export const ColorTags = ({ item, close }) => {
return (
<View
style={{
- flexDirection: 'row',
- flexWrap: 'wrap',
+ flexDirection: "row",
+ flexWrap: "wrap",
paddingHorizontal: 12,
- width: '100%',
+ width: "100%",
marginVertical: 10,
marginTop: 20,
- alignItems: 'center',
- justifyContent: 'space-between'
+ alignItems: "center",
+ justifyContent: "space-between"
}}
>
{Object.keys(COLORS_NOTE).map(_renderColor)}
diff --git a/apps/mobile/app/components/properties/date-meta.js b/apps/mobile/app/components/properties/date-meta.js
index 2ec2e7707..949c9b618 100644
--- a/apps/mobile/app/components/properties/date-meta.js
+++ b/apps/mobile/app/components/properties/date-meta.js
@@ -1,37 +1,37 @@
-import React from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import { timeConverter } from '../../utils/time';
-import Paragraph from '../ui/typography/paragraph';
+import React from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import { timeConverter } from "../../utils/time";
+import Paragraph from "../ui/typography/paragraph";
export const DateMeta = ({ item }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
- const getNameFromKey = key => {
+ const getNameFromKey = (key) => {
switch (key) {
- case 'dateCreated':
- return 'Created at:';
- case 'dateEdited':
- return 'Last edited at:';
- case 'dateModified':
- return 'Last modified at:';
- case 'dateDeleted':
- return 'Deleted at:';
- case 'dateUploaded':
- return 'Uploaded at:';
+ case "dateCreated":
+ return "Created at:";
+ case "dateEdited":
+ return "Last edited at:";
+ case "dateModified":
+ return "Last modified at:";
+ case "dateDeleted":
+ return "Deleted at:";
+ case "dateUploaded":
+ return "Uploaded at:";
default:
return key;
}
};
- const renderItem = key =>
- key.startsWith('date') ? (
+ const renderItem = (key) =>
+ key.startsWith("date") ? (
<View
key={key}
style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
+ flexDirection: "row",
+ justifyContent: "space-between",
paddingVertical: 3
}}
>
diff --git a/apps/mobile/app/components/properties/dev-mode.js b/apps/mobile/app/components/properties/dev-mode.js
index cf9cd96e7..a45d2f962 100644
--- a/apps/mobile/app/components/properties/dev-mode.js
+++ b/apps/mobile/app/components/properties/dev-mode.js
@@ -1,19 +1,19 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import React from 'react';
-import { View } from 'react-native';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { ToastEvent } from '../../services/event-manager';
-import { db } from '../../common/database';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
+import Clipboard from "@react-native-clipboard/clipboard";
+import React from "react";
+import { View } from "react-native";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { ToastEvent } from "../../services/event-manager";
+import { db } from "../../common/database";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
export const DevMode = ({ item }) => {
- const devMode = useSettingStore(state => state.settings.devMode);
+ const devMode = useSettingStore((state) => state.settings.devMode);
return devMode ? (
<View
style={{
- width: '100%',
+ width: "100%",
paddingHorizontal: 12,
marginTop: 10
}}
@@ -21,7 +21,7 @@ export const DevMode = ({ item }) => {
<Button
onPress={async () => {
let additionalData = {};
- if (item.type === 'note') {
+ if (item.type === "note") {
let content = await db.content.raw(item.contentId);
if (content) {
content = db.debug.strip(content);
@@ -34,9 +34,9 @@ export const DevMode = ({ item }) => {
Clipboard.setString(db.debug.strip(_note));
ToastEvent.show({
- heading: 'Debug data copied!',
- type: 'success',
- context: 'local'
+ heading: "Debug data copied!",
+ type: "success",
+ context: "local"
});
}}
fontSize={SIZE.sm}
@@ -45,7 +45,7 @@ export const DevMode = ({ item }) => {
height={30}
type="warn"
style={{
- alignSelf: 'flex-end'
+ alignSelf: "flex-end"
}}
/>
</View>
diff --git a/apps/mobile/app/components/properties/index.js b/apps/mobile/app/components/properties/index.js
index b4990fdaf..a374977ea 100644
--- a/apps/mobile/app/components/properties/index.js
+++ b/apps/mobile/app/components/properties/index.js
@@ -1,26 +1,31 @@
-import React from 'react';
-import { Platform, View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { DDS } from '../../services/device-detection';
-import { presentSheet } from '../../services/event-manager';
-import { db } from '../../common/database';
-import { SIZE } from '../../utils/size';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { ColorTags } from './color-tags';
-import { DateMeta } from './date-meta';
-import { DevMode } from './dev-mode';
-import { Items } from './items';
-import Notebooks from './notebooks';
-import { Synced } from './synced';
-import { Tags } from './tags';
-import { Topics } from './topics';
-import SearchService from '../../services/search';
-import { COLORS_NOTE } from '../../utils/color-scheme';
-import { ScrollView } from 'react-native-gesture-handler';
+import React from "react";
+import { Platform, View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { DDS } from "../../services/device-detection";
+import { presentSheet } from "../../services/event-manager";
+import { db } from "../../common/database";
+import { SIZE } from "../../utils/size";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { ColorTags } from "./color-tags";
+import { DateMeta } from "./date-meta";
+import { DevMode } from "./dev-mode";
+import { Items } from "./items";
+import Notebooks from "./notebooks";
+import { Synced } from "./synced";
+import { Tags } from "./tags";
+import { Topics } from "./topics";
+import SearchService from "../../services/search";
+import { COLORS_NOTE } from "../../utils/color-scheme";
+import { ScrollView } from "react-native-gesture-handler";
-export const Properties = ({ close = () => {}, item, buttons = [], getRef }) => {
- const colors = useThemeStore(state => state.colors);
+export const Properties = ({
+ close = () => {},
+ item,
+ buttons = [],
+ getRef
+}) => {
+ const colors = useThemeStore((state) => state.colors);
const alias = item.alias || item.title;
const isColor = !!COLORS_NOTE[item.title];
@@ -39,11 +44,11 @@ export const Properties = ({ close = () => {}, item, buttons = [], getRef }) =>
paddingHorizontal: 0,
borderBottomRightRadius: DDS.isLargeTablet() ? 10 : 1,
borderBottomLeftRadius: DDS.isLargeTablet() ? 10 : 1,
- maxHeight: '95%'
+ maxHeight: "95%"
}}
>
{!item || !item.id ? (
- <Paragraph style={{ marginVertical: 10, alignSelf: 'center' }}>
+ <Paragraph style={{ marginVertical: 10, alignSelf: "center" }}>
Start writing to save your note.
</Paragraph>
) : (
@@ -59,7 +64,7 @@ export const Properties = ({ close = () => {}, item, buttons = [], getRef }) =>
}}
>
<Heading size={SIZE.lg}>
- {item.type === 'tag' && !isColor ? (
+ {item.type === "tag" && !isColor ? (
<Heading size={SIZE.xl} color={colors.accent}>
#
</Heading>
@@ -75,21 +80,25 @@ export const Properties = ({ close = () => {}, item, buttons = [], getRef }) =>
numberOfLines={2}
color={colors.icon}
>
- {(item.type === 'notebook' || item.itemType === 'notebook') && item?.description
+ {(item.type === "notebook" || item.itemType === "notebook") &&
+ item?.description
? item.description
: null}
- {(item.type === 'note' || item.itemType === 'note') && item?.headline
+ {(item.type === "note" || item.itemType === "note") &&
+ item?.headline
? item.headline
: null}
</Paragraph>
) : null}
- {item.type === 'note' ? <Tags close={close} item={item} /> : null}
+ {item.type === "note" ? <Tags close={close} item={item} /> : null}
<Topics item={item} close={close} />
</View>
- {item.type === 'note' ? <Notebooks note={item} close={close} /> : null}
+ {item.type === "note" ? (
+ <Notebooks note={item} close={close} />
+ ) : null}
<DateMeta item={item} />
</View>
@@ -102,7 +111,7 @@ export const Properties = ({ close = () => {}, item, buttons = [], getRef }) =>
}}
/>
- {item.type === 'note' ? <ColorTags close={close} item={item} /> : null}
+ {item.type === "note" ? <ColorTags close={close} item={item} /> : null}
<Items
item={item}
@@ -134,44 +143,46 @@ Properties.present = (item, buttons = []) => {
let props = [];
let android = [];
switch (type) {
- case 'trash':
+ case "trash":
props[0] = item;
- props.push(['PermDelete', 'Restore']);
+ props.push(["PermDelete", "Restore"]);
break;
- case 'note':
- android = Platform.OS === 'android' ? ['PinToNotif'] : [];
+ case "note":
+ android = Platform.OS === "android" ? ["PinToNotif"] : [];
props[0] = db.notes.note(item.id).data;
props.push([
- 'Add to notebook',
- 'Share',
- 'Export',
- 'Copy',
- 'Publish',
- 'Pin',
- 'Favorite',
- 'Attachments',
- 'Vault',
- 'Delete',
- 'RemoveTopic',
- 'History',
- 'ReadOnly',
- 'Local only',
- 'Duplicate',
+ "Add to notebook",
+ "Share",
+ "Export",
+ "Copy",
+ "Publish",
+ "Pin",
+ "Favorite",
+ "Attachments",
+ "Vault",
+ "Delete",
+ "RemoveTopic",
+ "History",
+ "ReadOnly",
+ "Local only",
+ "Duplicate",
...android,
...buttons
]);
break;
- case 'notebook':
+ case "notebook":
props[0] = db.notebooks.notebook(item.id).data;
- props.push(['Edit Notebook', 'Pin', 'Add Shortcut', 'Delete']);
+ props.push(["Edit Notebook", "Pin", "Add Shortcut", "Delete"]);
break;
- case 'topic':
- props[0] = db.notebooks.notebook(item.notebookId).topics.topic(item.id)._topic;
- props.push(['Move notes', 'Edit Topic', 'Add Shortcut', 'Delete']);
+ case "topic":
+ props[0] = db.notebooks
+ .notebook(item.notebookId)
+ .topics.topic(item.id)._topic;
+ props.push(["Move notes", "Edit Topic", "Add Shortcut", "Delete"]);
break;
- case 'tag':
+ case "tag":
props[0] = db.tags.tag(item.id);
- props.push(['Add Shortcut', 'Delete', 'Rename Tag']);
+ props.push(["Add Shortcut", "Delete", "Rename Tag"]);
break;
}
if (!props[0]) return;
diff --git a/apps/mobile/app/components/properties/items.js b/apps/mobile/app/components/properties/items.js
index 18a54fb03..08feb9f4b 100644
--- a/apps/mobile/app/components/properties/items.js
+++ b/apps/mobile/app/components/properties/items.js
@@ -1,21 +1,21 @@
-import React from 'react';
-import { View } from 'react-native';
-import { FlatList } from 'react-native-gesture-handler';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { DDS } from '../../services/device-detection';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import { PressableButton } from '../ui/pressable';
-import Paragraph from '../ui/typography/paragraph';
-import { useActions } from '../../hooks/use-actions';
+import React from "react";
+import { View } from "react-native";
+import { FlatList } from "react-native-gesture-handler";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { DDS } from "../../services/device-detection";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import { PressableButton } from "../ui/pressable";
+import Paragraph from "../ui/typography/paragraph";
+import { useActions } from "../../hooks/use-actions";
export const Items = ({ item, buttons, close }) => {
- const colors = useThemeStore(state => state.colors);
- const dimensions = useSettingStore(state => state.dimensions);
+ const colors = useThemeStore((state) => state.colors);
+ const dimensions = useSettingStore((state) => state.dimensions);
const actions = useActions({ item, close });
- const data = actions.filter(i => buttons.indexOf(i.name) > -1 && !i.hidden);
+ const data = actions.filter((i) => buttons.indexOf(i.name) > -1 && !i.hidden);
let width = dimensions.width > 600 ? 600 : dimensions.width;
let columnItemsCount = DDS.isLargeTablet() ? 7 : 5;
@@ -27,24 +27,24 @@ export const Items = ({ item, buttons, close }) => {
<View
onPress={item.func}
key={item.name}
- testID={'icon-' + item.name}
+ testID={"icon-" + item.name}
style={{
- alignItems: 'center',
+ alignItems: "center",
width: columnItemWidth,
marginBottom: 10
}}
>
<PressableButton
onPress={item.func}
- type={item.on ? 'shade' : 'grayBg'}
+ type={item.on ? "shade" : "grayBg"}
customStyle={{
height: columnItemWidth - 12,
width: columnItemWidth - 12,
borderRadius: 5,
- justifyContent: 'center',
- alignItems: 'center',
- textAlign: 'center',
- textAlignVertical: 'center',
+ justifyContent: "center",
+ alignItems: "center",
+ textAlign: "center",
+ textAlignVertical: "center",
marginBottom: DDS.isTab ? 7 : 3.5
}}
>
@@ -54,14 +54,14 @@ export const Items = ({ item, buttons, close }) => {
color={
item.on
? colors.accent
- : item.name === 'Delete' || item.name === 'PermDelete'
+ : item.name === "Delete" || item.name === "PermDelete"
? colors.errorText
: colors.icon
}
/>
</PressableButton>
- <Paragraph size={SIZE.xs + 1} style={{ textAlign: 'center' }}>
+ <Paragraph size={SIZE.xs + 1} style={{ textAlign: "center" }}>
{item.title}
</Paragraph>
</View>
@@ -72,44 +72,48 @@ export const Items = ({ item, buttons, close }) => {
buttonType={{
text: item.on
? colors.accent
- : item.name === 'Delete' || item.name === 'PermDelete'
+ : item.name === "Delete" || item.name === "PermDelete"
? colors.errorText
: colors.pri
}}
onPress={item.func}
title={item.title}
icon={item.icon}
- type={item.on ? 'shade' : 'gray'}
+ type={item.on ? "shade" : "gray"}
fontSize={SIZE.sm}
style={{
borderRadius: 0,
- justifyContent: 'flex-start',
- alignSelf: 'flex-start',
- width: '100%'
+ justifyContent: "flex-start",
+ alignSelf: "flex-start",
+ width: "100%"
}}
/>
);
- return item.type === 'note' ? (
+ return item.type === "note" ? (
<FlatList
data={data}
- keyExtractor={item => item.title}
+ keyExtractor={(item) => item.title}
numColumns={buttons.length < 5 ? buttons.length : columnItemsCount}
style={{
- marginTop: item.type !== 'note' ? 10 : 0,
+ marginTop: item.type !== "note" ? 10 : 0,
paddingTop: 10
}}
columnWrapperStyle={{
- justifyContent: 'flex-start'
+ justifyContent: "flex-start"
}}
contentContainerStyle={{
- alignSelf: 'center',
- width: buttons.length < 5 ? '100%' : null,
+ alignSelf: "center",
+ width: buttons.length < 5 ? "100%" : null,
paddingLeft: buttons.length < 5 ? 10 : 0
}}
renderItem={_renderRowItem}
/>
) : (
- <FlatList data={data} keyExtractor={item => item.title} renderItem={renderColumnItem} />
+ <FlatList
+ data={data}
+ keyExtractor={(item) => item.title}
+ renderItem={renderColumnItem}
+ />
);
};
diff --git a/apps/mobile/app/components/properties/notebooks.js b/apps/mobile/app/components/properties/notebooks.js
index b6d94f958..93ab48c6f 100644
--- a/apps/mobile/app/components/properties/notebooks.js
+++ b/apps/mobile/app/components/properties/notebooks.js
@@ -1,20 +1,20 @@
-import React from 'react';
-import { ScrollView, View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eSendEvent } from '../../services/event-manager';
-import Navigation from '../../services/navigation';
-import { db } from '../../common/database';
-import { eOnNewTopicAdded, refreshNotesPage } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import { PressableButton } from '../ui/pressable';
-import Heading from '../ui/typography/heading';
-import { TopicNotes } from '../../screens/notes/topic-notes';
-import Notebook from '../../screens/notebook';
+import React from "react";
+import { ScrollView, View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { eSendEvent } from "../../services/event-manager";
+import Navigation from "../../services/navigation";
+import { db } from "../../common/database";
+import { eOnNewTopicAdded, refreshNotesPage } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import { PressableButton } from "../ui/pressable";
+import Heading from "../ui/typography/heading";
+import { TopicNotes } from "../../screens/notes/topic-notes";
+import Notebook from "../../screens/notebook";
export default function Notebooks({ note, close }) {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
function getNotebooks(item) {
if (!item.notebooks || item.notebooks.length < 1) return [];
@@ -27,7 +27,7 @@ export default function Notebooks({ note, close }) {
id: notebook.id,
title: item_notebook.title,
topics: notebook.topics
- .map(item => {
+ .map((item) => {
let topic = item_notebook.topics.topic(item)?._topic;
if (!topic) return null;
return {
@@ -35,7 +35,7 @@ export default function Notebooks({ note, close }) {
title: topic.title
};
})
- .filter(i => i !== null)
+ .filter((i) => i !== null)
};
notebooks.push(data);
}
@@ -43,7 +43,7 @@ export default function Notebooks({ note, close }) {
return notebooks;
}
- const navigateNotebook = id => {
+ const navigateNotebook = (id) => {
let item = db.notebooks.notebook(id)?.data;
if (!item) return;
Notebook.navigate(item, true);
@@ -58,12 +58,12 @@ export default function Notebooks({ note, close }) {
return !note.notebooks || note.notebooks.length === 0 ? null : (
<View
style={{
- width: '100%',
+ width: "100%",
borderTopWidth: 1,
borderTopColor: colors.nav
}}
>
- {getNotebooks(note).map(item => (
+ {getNotebooks(note).map((item) => (
<PressableButton
key={item.id}
onPress={() => {
@@ -71,10 +71,10 @@ export default function Notebooks({ note, close }) {
close();
}}
customStyle={{
- justifyContent: 'flex-start',
+ justifyContent: "flex-start",
paddingHorizontal: 12,
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
flexShrink: 1,
flexGrow: 1,
marginTop: 5,
@@ -92,7 +92,7 @@ export default function Notebooks({ note, close }) {
<Heading
numberOfLines={1}
style={{
- maxWidth: '50%'
+ maxWidth: "50%"
}}
size={SIZE.sm}
>
@@ -103,14 +103,14 @@ export default function Notebooks({ note, close }) {
horizontal={true}
showsHorizontalScrollIndicator={false}
style={{
- flexDirection: 'row',
+ flexDirection: "row",
marginLeft: 8,
borderLeftColor: colors.nav,
borderLeftWidth: 1,
paddingLeft: 8
}}
>
- {item.topics.map(topic => (
+ {item.topics.map((topic) => (
<Button
key={topic.id}
onPress={() => {
diff --git a/apps/mobile/app/components/properties/synced.js b/apps/mobile/app/components/properties/synced.js
index 2ad2af330..5dda6ba3e 100644
--- a/apps/mobile/app/components/properties/synced.js
+++ b/apps/mobile/app/components/properties/synced.js
@@ -1,30 +1,30 @@
-import React from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useUserStore } from '../../stores/use-user-store';
-import { openLinkInBrowser } from '../../utils/functions';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { Button } from '../ui/button';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useUserStore } from "../../stores/use-user-store";
+import { openLinkInBrowser } from "../../utils/functions";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { Button } from "../ui/button";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
export const Synced = ({ item, close }) => {
- const colors = useThemeStore(state => state.colors);
- const user = useUserStore(state => state.user);
- const lastSynced = useUserStore(state => state.lastSynced);
+ const colors = useThemeStore((state) => state.colors);
+ const user = useUserStore((state) => state.user);
+ const lastSynced = useUserStore((state) => state.lastSynced);
return user && lastSynced >= item.dateModified ? (
<View
style={{
paddingVertical: 0,
- width: '100%',
+ width: "100%",
paddingHorizontal: 12,
- alignItems: 'center',
- flexDirection: 'row',
- justifyContent: 'flex-start',
- alignSelf: 'center',
+ alignItems: "center",
+ flexDirection: "row",
+ justifyContent: "flex-start",
+ alignSelf: "center",
paddingTop: 10,
marginTop: 10,
borderTopWidth: 1,
@@ -44,14 +44,14 @@ export const Synced = ({ item, close }) => {
color={colors.heading}
size={SIZE.xs}
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
>
Encrypted and synced
</Heading>
<Paragraph
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
size={SIZE.xs}
color={colors.pri}
@@ -65,7 +65,10 @@ export const Synced = ({ item, close }) => {
try {
close();
await sleep(300);
- await openLinkInBrowser('https://docs.notesnook.com/how-is-my-data-encrypted/', colors);
+ await openLinkInBrowser(
+ "https://docs.notesnook.com/how-is-my-data-encrypted/",
+ colors
+ );
} catch (e) {}
}}
fontSize={SIZE.xs + 1}
diff --git a/apps/mobile/app/components/properties/tags.js b/apps/mobile/app/components/properties/tags.js
index f5dd4532e..79525a008 100644
--- a/apps/mobile/app/components/properties/tags.js
+++ b/apps/mobile/app/components/properties/tags.js
@@ -1,17 +1,17 @@
-import React, { useState } from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eSendEvent } from '../../services/event-manager';
-import Navigation from '../../services/navigation';
-import { db } from '../../common/database';
-import { eOpenTagsDialog, refreshNotesPage } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { Button } from '../ui/button';
-import { TaggedNotes } from '../../screens/notes/tagged';
+import React, { useState } from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { eSendEvent } from "../../services/event-manager";
+import Navigation from "../../services/navigation";
+import { db } from "../../common/database";
+import { eOpenTagsDialog, refreshNotesPage } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { Button } from "../ui/button";
+import { TaggedNotes } from "../../screens/notes/tagged";
export const Tags = ({ item, close }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return item.id ? (
<View
@@ -22,9 +22,9 @@ export const Tags = ({ item, close }) => {
>
<View
style={{
- flexDirection: 'row',
- flexWrap: 'wrap',
- alignItems: 'center'
+ flexDirection: "row",
+ flexWrap: "wrap",
+ alignItems: "center"
}}
>
<Button
@@ -59,7 +59,7 @@ export const Tags = ({ item, close }) => {
const TagItem = ({ tag, close }) => {
const onPress = async () => {
let tags = db.tags.all;
- let _tag = tags.find(t => t.title === tag);
+ let _tag = tags.find((t) => t.title === tag);
TaggedNotes.navigate(_tag, true);
await sleep(300);
close();
@@ -75,7 +75,7 @@ const TagItem = ({ tag, close }) => {
return (
<Button
onPress={onPress}
- title={'#' + tag}
+ title={"#" + tag}
// buttonType={{
// text: colors.accent
// }}
diff --git a/apps/mobile/app/components/properties/topics.js b/apps/mobile/app/components/properties/topics.js
index 55bec4526..85dc1f4b5 100644
--- a/apps/mobile/app/components/properties/topics.js
+++ b/apps/mobile/app/components/properties/topics.js
@@ -1,16 +1,16 @@
-import React from 'react';
-import { View } from 'react-native';
-import { TopicNotes } from '../../screens/notes/topic-notes';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
+import React from "react";
+import { View } from "react-native";
+import { TopicNotes } from "../../screens/notes/topic-notes";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
export const Topics = ({ item, close }) => {
- const open = topic => {
+ const open = (topic) => {
close();
TopicNotes.navigate(topic, true);
};
- const renderItem = topic => (
+ const renderItem = (topic) => (
<Button
key={topic.id}
title={topic.title}
@@ -31,13 +31,16 @@ export const Topics = ({ item, close }) => {
/>
);
- return item && item.type === 'notebook' && item.topics && item.topics.length > 0 ? (
+ return item &&
+ item.type === "notebook" &&
+ item.topics &&
+ item.topics.length > 0 ? (
<View
style={{
- flexDirection: 'row',
+ flexDirection: "row",
marginTop: 5,
- width: '100%',
- flexWrap: 'wrap'
+ width: "100%",
+ flexWrap: "wrap"
}}
>
{item.topics
diff --git a/apps/mobile/app/components/selection-header/index.js b/apps/mobile/app/components/selection-header/index.js
index 8af6c80af..6a527408a 100644
--- a/apps/mobile/app/components/selection-header/index.js
+++ b/apps/mobile/app/components/selection-header/index.js
@@ -1,29 +1,31 @@
-import React, { useEffect } from 'react';
-import { BackHandler, Platform, View } from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useSelectionStore } from '../../stores/use-selection-store';
-import { eSendEvent, ToastEvent } from '../../services/event-manager';
-import Navigation from '../../services/navigation';
-import { db } from '../../common/database';
-import { eOpenMoveNoteDialog } from '../../utils/events';
-import { deleteItems } from '../../utils/functions';
-import { tabBarRef } from '../../utils/global-refs';
-import layoutmanager from '../../utils/layout-manager';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { presentDialog } from '../dialog/functions';
-import { IconButton } from '../ui/icon-button';
-import Heading from '../ui/typography/heading';
-import useNavigationStore from '../../stores/use-navigation-store';
+import React, { useEffect } from "react";
+import { BackHandler, Platform, View } from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useSelectionStore } from "../../stores/use-selection-store";
+import { eSendEvent, ToastEvent } from "../../services/event-manager";
+import Navigation from "../../services/navigation";
+import { db } from "../../common/database";
+import { eOpenMoveNoteDialog } from "../../utils/events";
+import { deleteItems } from "../../utils/functions";
+import { tabBarRef } from "../../utils/global-refs";
+import layoutmanager from "../../utils/layout-manager";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { presentDialog } from "../dialog/functions";
+import { IconButton } from "../ui/icon-button";
+import Heading from "../ui/typography/heading";
+import useNavigationStore from "../../stores/use-navigation-store";
export const SelectionHeader = React.memo(() => {
- const colors = useThemeStore(state => state.colors);
- const selectionMode = useSelectionStore(state => state.selectionMode);
- const selectedItemsList = useSelectionStore(state => state.selectedItemsList);
- const setSelectionMode = useSelectionStore(state => state.setSelectionMode);
- const clearSelection = useSelectionStore(state => state.clearSelection);
- const currentScreen = useNavigationStore(state => state.currentScreen);
+ const colors = useThemeStore((state) => state.colors);
+ const selectionMode = useSelectionStore((state) => state.selectionMode);
+ const selectedItemsList = useSelectionStore(
+ (state) => state.selectedItemsList
+ );
+ const setSelectionMode = useSelectionStore((state) => state.setSelectionMode);
+ const clearSelection = useSelectionStore((state) => state.clearSelection);
+ const currentScreen = useNavigationStore((state) => state.currentScreen);
const screen = currentScreen.name;
const insets = useSafeAreaInsets();
@@ -37,15 +39,15 @@ export const SelectionHeader = React.memo(() => {
const addToFavorite = async () => {
if (selectedItemsList.length > 0) {
- selectedItemsList.forEach(item => {
+ selectedItemsList.forEach((item) => {
db.notes.note(item.id).favorite();
});
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes"
);
clearSelection();
}
@@ -54,58 +56,60 @@ export const SelectionHeader = React.memo(() => {
const restoreItem = async () => {
if (selectedItemsList.length > 0) {
let noteIds = [];
- selectedItemsList.forEach(item => {
+ selectedItemsList.forEach((item) => {
noteIds.push(item.id);
});
await db.trash.restore(...noteIds);
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes',
- 'Trash',
- 'Notebooks',
- 'Tags'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes",
+ "Trash",
+ "Notebooks",
+ "Tags"
);
clearSelection();
ToastEvent.show({
- heading: 'Restore successful',
- type: 'success'
+ heading: "Restore successful",
+ type: "success"
});
}
};
const deleteItem = async () => {
presentDialog({
- title: `Delete ${selectedItemsList.length > 1 ? 'items' : 'item'}`,
+ title: `Delete ${selectedItemsList.length > 1 ? "items" : "item"}`,
paragraph: `Are you sure you want to delete ${
- selectedItemsList.length > 1 ? 'these items permanently?' : 'this item permanently?'
+ selectedItemsList.length > 1
+ ? "these items permanently?"
+ : "this item permanently?"
}`,
- positiveText: 'Delete',
- negativeText: 'Cancel',
+ positiveText: "Delete",
+ negativeText: "Cancel",
positivePress: async () => {
if (selectedItemsList.length > 0) {
let noteIds = [];
- selectedItemsList.forEach(item => {
+ selectedItemsList.forEach((item) => {
noteIds.push(item.id);
});
await db.trash.delete(...noteIds);
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes',
- 'Trash',
- 'Notebooks',
- 'Tags'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes",
+ "Trash",
+ "Notebooks",
+ "Tags"
);
clearSelection();
}
},
- positiveType: 'errorShade'
+ positiveType: "errorShade"
});
};
@@ -117,38 +121,38 @@ export const SelectionHeader = React.memo(() => {
useEffect(() => {
if (selectionMode) {
- BackHandler.addEventListener('hardwareBackPress', onBackPress);
+ BackHandler.addEventListener("hardwareBackPress", onBackPress);
} else {
- BackHandler.removeEventListener('hardwareBackPress', onBackPress);
+ BackHandler.removeEventListener("hardwareBackPress", onBackPress);
}
}, [selectionMode]);
return !selectionMode ? null : (
<View
style={{
- width: '100%',
+ width: "100%",
height: 50 + insets.top,
- paddingTop: Platform.OS === 'android' ? insets.top : null,
+ paddingTop: Platform.OS === "android" ? insets.top : null,
backgroundColor: colors.bg,
- justifyContent: 'space-between',
- alignItems: 'center',
- flexDirection: 'row',
+ justifyContent: "space-between",
+ alignItems: "center",
+ flexDirection: "row",
zIndex: 999,
paddingHorizontal: 12
}}
>
<View
style={{
- flexDirection: 'row',
- justifyContent: 'flex-start',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "flex-start",
+ alignItems: "center",
borderRadius: 100
}}
>
<IconButton
customStyle={{
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
height: 40,
width: 40,
borderRadius: 100,
@@ -169,21 +173,21 @@ export const SelectionHeader = React.memo(() => {
height: 40,
borderRadius: 100,
paddingHorizontal: 16,
- justifyContent: 'center',
- flexDirection: 'row',
- alignItems: 'center'
+ justifyContent: "center",
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<Heading size={SIZE.md} color={colors.accent}>
- {selectedItemsList.length + ' Selected'}
+ {selectedItemsList.length + " Selected"}
</Heading>
</View>
</View>
<View
style={{
- flexDirection: 'row',
- justifyContent: 'flex-start',
- alignItems: 'center'
+ flexDirection: "row",
+ justifyContent: "flex-start",
+ alignItems: "center"
}}
>
{/* <ActionIcon
@@ -201,7 +205,9 @@ export const SelectionHeader = React.memo(() => {
size={SIZE.xl}
/> */}
- {screen === 'Trash' || screen === 'Notebooks' || screen === 'Notebook' ? null : (
+ {screen === "Trash" ||
+ screen === "Notebooks" ||
+ screen === "Notebook" ? null : (
<IconButton
onPress={async () => {
//setSelectionMode(false);
@@ -217,23 +223,24 @@ export const SelectionHeader = React.memo(() => {
/>
)}
- {screen === 'TopicNotes' ? (
+ {screen === "TopicNotes" ? (
<IconButton
onPress={async () => {
if (selectedItemsList.length > 0) {
- const currentTopic = useNavigationStore.getState().currentScreen;
+ const currentTopic =
+ useNavigationStore.getState().currentScreen;
await db.notebooks
.notebook(currentTopic.notebookId)
.topics.topic(currentTopic.id)
- .delete(...selectedItemsList.map(item => item.id));
+ .delete(...selectedItemsList.map((item) => item.id));
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes',
- 'Notebooks',
- 'Notebook'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes",
+ "Notebooks",
+ "Notebook"
);
clearSelection();
}
@@ -248,7 +255,7 @@ export const SelectionHeader = React.memo(() => {
/>
) : null}
- {screen === 'Favorites' ? (
+ {screen === "Favorites" ? (
<IconButton
onPress={addToFavorite}
customStyle={{
@@ -260,23 +267,25 @@ export const SelectionHeader = React.memo(() => {
/>
) : null}
- {screen === 'Trash' ? null : (
+ {screen === "Trash" ? null : (
<IconButton
customStyle={{
marginLeft: 10
}}
onPress={async () => {
presentDialog({
- title: `Delete ${selectedItemsList.length > 1 ? 'items' : 'item'}`,
+ title: `Delete ${
+ selectedItemsList.length > 1 ? "items" : "item"
+ }`,
paragraph: `Are you sure you want to delete ${
- selectedItemsList.length > 1 ? 'these items?' : 'this item?'
+ selectedItemsList.length > 1 ? "these items?" : "this item?"
}`,
- positiveText: 'Delete',
- negativeText: 'Cancel',
+ positiveText: "Delete",
+ negativeText: "Cancel",
positivePress: () => {
deleteItems();
},
- positiveType: 'errorShade'
+ positiveType: "errorShade"
});
return;
@@ -287,7 +296,7 @@ export const SelectionHeader = React.memo(() => {
/>
)}
- {screen === 'Trash' ? (
+ {screen === "Trash" ? (
<>
<IconButton
customStyle={{
@@ -315,6 +324,6 @@ export const SelectionHeader = React.memo(() => {
);
});
-SelectionHeader.displayName = 'SelectionHeader';
+SelectionHeader.displayName = "SelectionHeader";
export default SelectionHeader;
diff --git a/apps/mobile/app/components/sheet-provider/index.js b/apps/mobile/app/components/sheet-provider/index.js
index dc9107b54..b94c24d07 100644
--- a/apps/mobile/app/components/sheet-provider/index.js
+++ b/apps/mobile/app/components/sheet-provider/index.js
@@ -1,19 +1,22 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { ActivityIndicator, View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { editorState } from '../../screens/editor/tiptap/utils';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eCloseProgressDialog, eOpenProgressDialog } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { Button } from '../ui/button';
-import SheetWrapper from '../ui/sheet';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React, { useEffect, useRef, useState } from "react";
+import { ActivityIndicator, View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { editorState } from "../../screens/editor/tiptap/utils";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { eCloseProgressDialog, eOpenProgressDialog } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { Button } from "../ui/button";
+import SheetWrapper from "../ui/sheet";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
-const SheetProvider = ({ context = 'global' }) => {
- const colors = useThemeStore(state => state.colors);
+const SheetProvider = ({ context = "global" }) => {
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [dialogData, setDialogData] = useState(null);
const actionSheetRef = useRef();
@@ -30,8 +33,8 @@ const SheetProvider = ({ context = 'global' }) => {
};
}, [visible]);
- const open = async data => {
- if (!data.context) data.context = 'global';
+ const open = async (data) => {
+ if (!data.context) data.context = "global";
if (data.context !== context) return;
if (visible || dialogData) {
setDialogData(null);
@@ -65,8 +68,8 @@ const SheetProvider = ({ context = 'global' }) => {
})();
}, [visible, dialogData]);
- const close = ctx => {
- if (!ctx) ctx = 'global';
+ const close = (ctx) => {
+ if (!ctx) ctx = "global";
if (ctx !== context) return;
actionSheetRef.current?.setModalVisible(false);
};
@@ -75,7 +78,9 @@ const SheetProvider = ({ context = 'global' }) => {
<SheetWrapper
fwdRef={actionSheetRef}
gestureEnabled={!dialogData?.progress && !dialogData?.disableClosing}
- closeOnTouchBackdrop={!dialogData?.progress && !dialogData?.disableClosing}
+ closeOnTouchBackdrop={
+ !dialogData?.progress && !dialogData?.disableClosing
+ }
onClose={() => {
dialogData.onClose && dialogData.onClose();
setVisible(false);
@@ -84,10 +89,13 @@ const SheetProvider = ({ context = 'global' }) => {
>
<View
style={{
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
marginBottom:
- !dialogData.progress && !dialogData.icon && !dialogData.title && !dialogData.paragraph
+ !dialogData.progress &&
+ !dialogData.icon &&
+ !dialogData.title &&
+ !dialogData.paragraph
? 0
: 10,
paddingHorizontal: 12
@@ -114,11 +122,13 @@ const SheetProvider = ({ context = 'global' }) => {
{dialogData?.title ? <Heading> {dialogData?.title}</Heading> : null}
{dialogData?.paragraph ? (
- <Paragraph style={{ textAlign: 'center' }}>{dialogData?.paragraph}</Paragraph>
+ <Paragraph style={{ textAlign: "center" }}>
+ {dialogData?.paragraph}
+ </Paragraph>
) : null}
</View>
- {typeof dialogData.component === 'function'
+ {typeof dialogData.component === "function"
? dialogData.component(actionSheetRef, close)
: dialogData.component}
@@ -129,18 +139,18 @@ const SheetProvider = ({ context = 'global' }) => {
}}
>
{dialogData.valueArray &&
- dialogData.valueArray.map(v => (
+ dialogData.valueArray.map((v) => (
<Button
title={v}
type="gray"
key={v}
- textStyle={{ fontWeight: 'normal' }}
+ textStyle={{ fontWeight: "normal" }}
fontSize={SIZE.sm}
icon="check"
width="100%"
style={{
- justifyContent: 'flex-start',
- backgroundColor: 'transparent'
+ justifyContent: "flex-start",
+ backgroundColor: "transparent"
}}
/>
))}
@@ -156,7 +166,7 @@ const SheetProvider = ({ context = 'global' }) => {
onPress={dialogData.action}
key={dialogData.actionText}
title={dialogData.actionText}
- accentColor={dialogData.iconColor || 'accent'}
+ accentColor={dialogData.iconColor || "accent"}
accentText="light"
type="accent"
height={50}
@@ -172,7 +182,7 @@ const SheetProvider = ({ context = 'global' }) => {
key={item.accentText}
title={item.actionText}
icon={item.icon && item.icon}
- type={item.type || 'accent'}
+ type={item.type || "accent"}
height={50}
style={{
marginBottom: 10
@@ -185,15 +195,19 @@ const SheetProvider = ({ context = 'global' }) => {
{dialogData?.learnMore ? (
<Paragraph
style={{
- alignSelf: 'center',
+ alignSelf: "center",
marginTop: 10,
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
size={SIZE.xs}
onPress={dialogData.learnMorePress}
color={colors.icon}
>
- <Icon color={colors.icon} name="information-outline" size={SIZE.xs} />{' '}
+ <Icon
+ color={colors.icon}
+ name="information-outline"
+ size={SIZE.xs}
+ />{" "}
{dialogData.learnMore}
</Paragraph>
) : null}
diff --git a/apps/mobile/app/components/sheets/add-notebook/index.js b/apps/mobile/app/components/sheets/add-notebook/index.js
index 734f6b84d..2651e970a 100644
--- a/apps/mobile/app/components/sheets/add-notebook/index.js
+++ b/apps/mobile/app/components/sheets/add-notebook/index.js
@@ -1,23 +1,36 @@
-import React, { createRef } from 'react';
-import { Keyboard, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native';
-import { FlatList } from 'react-native-gesture-handler';
-import { notesnook } from '../../../../e2e/test.ids';
-import { useMenuStore } from '../../../stores/use-menu-store';
-import { DDS } from '../../../services/device-detection';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { db } from '../../../common/database';
-import { eCloseAddNotebookDialog, eOpenAddNotebookDialog } from '../../../utils/events';
-import { ph, pv, SIZE } from '../../../utils/size';
-import { sleep } from '../../../utils/time';
-import { IconButton } from '../../ui/icon-button';
-import { Button } from '../../ui/button';
-import DialogHeader from '../../dialog/dialog-header';
-import Input from '../../ui/input';
-import { MoveNotes } from '../move-notes/movenote';
-import Seperator from '../../ui/seperator';
-import SheetWrapper from '../../ui/sheet';
-import { Toast } from '../../toast';
+import React, { createRef } from "react";
+import {
+ Keyboard,
+ StyleSheet,
+ TextInput,
+ TouchableOpacity,
+ View
+} from "react-native";
+import { FlatList } from "react-native-gesture-handler";
+import { notesnook } from "../../../../e2e/test.ids";
+import { useMenuStore } from "../../../stores/use-menu-store";
+import { DDS } from "../../../services/device-detection";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent,
+ ToastEvent
+} from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { db } from "../../../common/database";
+import {
+ eCloseAddNotebookDialog,
+ eOpenAddNotebookDialog
+} from "../../../utils/events";
+import { ph, pv, SIZE } from "../../../utils/size";
+import { sleep } from "../../../utils/time";
+import { IconButton } from "../../ui/icon-button";
+import { Button } from "../../ui/button";
+import DialogHeader from "../../dialog/dialog-header";
+import Input from "../../ui/input";
+import { MoveNotes } from "../move-notes/movenote";
+import Seperator from "../../ui/seperator";
+import SheetWrapper from "../../ui/sheet";
+import { Toast } from "../../toast";
let refs = [];
@@ -64,7 +77,7 @@ export class AddNotebookSheet extends React.Component {
eUnSubscribeEvent(eCloseAddNotebookDialog, this.close);
}
- open = notebook => {
+ open = (notebook) => {
refs = [];
if (notebook) {
@@ -87,7 +100,7 @@ export class AddNotebookSheet extends React.Component {
notebook: null
});
}
- sleep(100).then(r => {
+ sleep(100).then((r) => {
this.actionSheetRef.current?.show();
});
};
@@ -104,7 +117,7 @@ export class AddNotebookSheet extends React.Component {
this.id = null;
};
- onDelete = index => {
+ onDelete = (index) => {
let { topics } = this.state;
let prevTopics = topics;
refs = [];
@@ -139,9 +152,9 @@ export class AddNotebookSheet extends React.Component {
if (!this.title || this.title?.trim().length === 0) {
ToastEvent.show({
- heading: 'Notebook title is required',
- type: 'error',
- context: 'local'
+ heading: "Notebook title is required",
+ type: "error",
+ context: "local"
});
this.setState({
loading: false
@@ -166,7 +179,9 @@ export class AddNotebookSheet extends React.Component {
let newNotebookId = null;
if (notebook) {
if (this.topicsToDelete?.length > 0) {
- await db.notebooks.notebook(toEdit.id).topics.delete(...this.topicsToDelete);
+ await db.notebooks
+ .notebook(toEdit.id)
+ .topics.delete(...this.topicsToDelete);
toEdit = db.notebooks.notebook(toEdit.id).data;
}
@@ -199,12 +214,12 @@ export class AddNotebookSheet extends React.Component {
}
useMenuStore.getState().setMenuPins();
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes',
- 'Notebooks',
- 'Notebook'
+ "Notes",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes",
+ "Notebooks",
+ "Notebook"
);
this.setState({
@@ -221,7 +236,8 @@ export class AddNotebookSheet extends React.Component {
this.hiddenInput.current?.focus();
let willFocus = true;
let { topics } = this.state;
- if (!this.currentInputValue || this.currentInputValue?.trim().length === 0) return;
+ if (!this.currentInputValue || this.currentInputValue?.trim().length === 0)
+ return;
let prevTopics = [...topics];
if (this.prevItem === null) {
@@ -259,7 +275,7 @@ export class AddNotebookSheet extends React.Component {
}
}
this.topicInputRef.current?.setNativeProps({
- text: ''
+ text: ""
});
willFocus && this.topicInputRef.current?.focus();
};
@@ -292,7 +308,7 @@ export class AddNotebookSheet extends React.Component {
>
<View
style={{
- maxHeight: DDS.isTab ? '90%' : '96%',
+ maxHeight: DDS.isTab ? "90%" : "96%",
borderRadius: DDS.isTab ? 5 : 0,
paddingHorizontal: 12
}}
@@ -303,24 +319,28 @@ export class AddNotebookSheet extends React.Component {
width: 1,
height: 1,
opacity: 0,
- position: 'absolute'
+ position: "absolute"
}}
blurOnSubmit={false}
/>
<DialogHeader
- title={notebook && notebook.dateCreated ? 'Edit Notebook' : 'New Notebook'}
+ title={
+ notebook && notebook.dateCreated
+ ? "Edit Notebook"
+ : "New Notebook"
+ }
paragraph={
notebook && notebook.dateCreated
- ? 'You are editing ' + this.title + ' notebook.'
- : 'Notebooks are the best way to organize your notes.'
+ ? "You are editing " + this.title + " notebook."
+ : "Notebooks are the best way to organize your notes."
}
/>
<Seperator half />
<Input
- fwdRef={ref => (this.titleRef = ref)}
+ fwdRef={(ref) => (this.titleRef = ref)}
testID={notesnook.ids.dialogs.notebook.inputs.title}
- onChangeText={value => {
+ onChangeText={(value) => {
this.title = value;
}}
placeholder="Enter a title"
@@ -333,9 +353,9 @@ export class AddNotebookSheet extends React.Component {
/>
<Input
- fwdRef={ref => (this.descriptionRef = ref)}
+ fwdRef={(ref) => (this.descriptionRef = ref)}
testID={notesnook.ids.dialogs.notebook.inputs.description}
- onChangeText={value => {
+ onChangeText={(value) => {
this.description = value;
}}
placeholder="Describe your notebook."
@@ -350,7 +370,7 @@ export class AddNotebookSheet extends React.Component {
<Input
fwdRef={this.topicInputRef}
testID={notesnook.ids.dialogs.notebook.inputs.topic}
- onChangeText={value => {
+ onChangeText={(value) => {
this.currentInputValue = value;
if (this.prevItem !== null) {
refs[this.prevIndex].setNativeProps({
@@ -368,8 +388,8 @@ export class AddNotebookSheet extends React.Component {
}}
blurOnSubmit={false}
button={{
- testID: 'topic-add-button',
- icon: this.state.editTopic ? 'check' : 'plus',
+ testID: "topic-add-button",
+ icon: this.state.editTopic ? "check" : "plus",
onPress: this.onSubmit,
color: topicInputFocused ? colors.accent : colors.icon
}}
@@ -378,7 +398,7 @@ export class AddNotebookSheet extends React.Component {
<FlatList
data={topics}
- ref={ref => (this.listRef = ref)}
+ ref={(ref) => (this.listRef = ref)}
nestedScrollEnabled
keyExtractor={(item, index) => item + index.toString()}
onMomentumScrollEnd={() => {
@@ -413,7 +433,11 @@ export class AddNotebookSheet extends React.Component {
width="100%"
height={50}
fontSize={SIZE.md}
- title={notebook && notebook.dateCreated ? 'Save changes' : 'Create notebook'}
+ title={
+ notebook && notebook.dateCreated
+ ? "Save changes"
+ : "Create notebook"
+ }
type="accent"
onPress={this.addNewNotebook}
/>
@@ -434,14 +458,14 @@ export class AddNotebookSheet extends React.Component {
}
const TopicItem = ({ item, index, colors, onPress, onDelete }) => {
- const topicRef = ref => (refs[index] = ref);
+ const topicRef = (ref) => (refs[index] = ref);
return (
<View
style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
backgroundColor: colors.nav,
borderRadius: 5,
marginVertical: 5
@@ -449,10 +473,10 @@ const TopicItem = ({ item, index, colors, onPress, onDelete }) => {
>
<TouchableOpacity
style={{
- width: '80%',
- backgroundColor: 'transparent',
+ width: "80%",
+ backgroundColor: "transparent",
zIndex: 10,
- position: 'absolute',
+ position: "absolute",
height: 30
}}
onPress={() => {
@@ -475,11 +499,11 @@ const TopicItem = ({ item, index, colors, onPress, onDelete }) => {
<View
style={{
width: 80,
- position: 'absolute',
+ position: "absolute",
right: 0,
- alignItems: 'center',
- flexDirection: 'row',
- justifyContent: 'flex-end'
+ alignItems: "center",
+ flexDirection: "row",
+ justifyContent: "flex-end"
}}
>
<IconButton
@@ -505,21 +529,21 @@ const TopicItem = ({ item, index, colors, onPress, onDelete }) => {
const styles = StyleSheet.create({
wrapper: {
- width: '100%',
- height: '100%',
- backgroundColor: 'rgba(0,0,0,0.3)',
- justifyContent: 'center',
- alignItems: 'center'
+ width: "100%",
+ height: "100%",
+ backgroundColor: "rgba(0,0,0,0.3)",
+ justifyContent: "center",
+ alignItems: "center"
},
overlay: {
- width: '100%',
- height: '100%',
- position: 'absolute'
+ width: "100%",
+ height: "100%",
+ position: "absolute"
},
headingContainer: {
- flexDirection: 'row',
- justifyContent: 'center',
- alignItems: 'center'
+ flexDirection: "row",
+ justifyContent: "center",
+ alignItems: "center"
},
headingText: {
marginLeft: 5,
@@ -537,25 +561,25 @@ const styles = StyleSheet.create({
marginBottom: 5
},
addBtn: {
- width: '12%',
+ width: "12%",
minHeight: 45,
- justifyContent: 'center',
- alignItems: 'center',
- position: 'absolute',
+ justifyContent: "center",
+ alignItems: "center",
+ position: "absolute",
right: 0
},
buttonContainer: {
- justifyContent: 'space-between',
- alignItems: 'center',
- flexDirection: 'row',
- width: '100%',
+ justifyContent: "space-between",
+ alignItems: "center",
+ flexDirection: "row",
+ width: "100%",
marginTop: 20
},
topicContainer: {
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
marginTop: 10
},
topicInput: {
@@ -565,16 +589,16 @@ const styles = StyleSheet.create({
paddingHorizontal: ph,
paddingRight: 40,
paddingVertical: 10,
- width: '100%',
- maxWidth: '100%'
+ width: "100%",
+ maxWidth: "100%"
},
topicBtn: {
borderRadius: 5,
width: 40,
height: 40,
- justifyContent: 'center',
- alignItems: 'center',
- position: 'absolute',
+ justifyContent: "center",
+ alignItems: "center",
+ position: "absolute",
right: 0
}
});
diff --git a/apps/mobile/app/components/sheets/add-to/index.js b/apps/mobile/app/components/sheets/add-to/index.js
index 9cb2b3652..fb1f66b9a 100644
--- a/apps/mobile/app/components/sheets/add-to/index.js
+++ b/apps/mobile/app/components/sheets/add-to/index.js
@@ -1,28 +1,32 @@
-import React, { createRef, useEffect, useState } from 'react';
-import { Keyboard, TouchableOpacity, View } from 'react-native';
-import { FlatList } from 'react-native-gesture-handler';
-import { notesnook } from '../../../../e2e/test.ids';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import SearchService from '../../../services/search';
-import { useSelectionStore } from '../../../stores/use-selection-store';
-import { useNotebookStore } from '../../../stores/use-notebook-store';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { getTotalNotes } from '../../../utils';
-import { db } from '../../../common/database';
-import { eOpenMoveNoteDialog } from '../../../utils/events';
-import layoutmanager from '../../../utils/layout-manager';
-import { SIZE } from '../../../utils/size';
-import { Dialog } from '../../dialog';
-import DialogHeader from '../../dialog/dialog-header';
-import { presentDialog } from '../../dialog/functions';
-import { Button } from '../../ui/button';
-import { IconButton } from '../../ui/icon-button';
-import Input from '../../ui/input';
-import { PressableButton } from '../../ui/pressable';
-import SheetWrapper from '../../ui/sheet';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
+import React, { createRef, useEffect, useState } from "react";
+import { Keyboard, TouchableOpacity, View } from "react-native";
+import { FlatList } from "react-native-gesture-handler";
+import { notesnook } from "../../../../e2e/test.ids";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent,
+ ToastEvent
+} from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import SearchService from "../../../services/search";
+import { useSelectionStore } from "../../../stores/use-selection-store";
+import { useNotebookStore } from "../../../stores/use-notebook-store";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { getTotalNotes } from "../../../utils";
+import { db } from "../../../common/database";
+import { eOpenMoveNoteDialog } from "../../../utils/events";
+import layoutmanager from "../../../utils/layout-manager";
+import { SIZE } from "../../../utils/size";
+import { Dialog } from "../../dialog";
+import DialogHeader from "../../dialog/dialog-header";
+import { presentDialog } from "../../dialog/functions";
+import { Button } from "../../ui/button";
+import { IconButton } from "../../ui/icon-button";
+import Input from "../../ui/input";
+import { PressableButton } from "../../ui/pressable";
+import SheetWrapper from "../../ui/sheet";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
let newNotebookTitle = null;
const notebookInput = createRef();
@@ -52,13 +56,13 @@ const AddToNotebookSheet = () => {
newNotebookTitle = null;
setNote(null);
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes',
- 'Notebooks',
- 'Notebook'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes",
+ "Notebooks",
+ "Notebook"
);
};
@@ -72,21 +76,25 @@ const AddToNotebookSheet = () => {
export default AddToNotebookSheet;
const MoveNoteComponent = ({ note }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
- const notebooks = useNotebookStore(state => state.notebooks.filter(n => n?.type === 'notebook'));
+ const notebooks = useNotebookStore((state) =>
+ state.notebooks.filter((n) => n?.type === "notebook")
+ );
- const selectedItemsList = useSelectionStore(state => state.selectedItemsList);
- const setNotebooks = useNotebookStore(state => state.setNotebooks);
- const [expanded, setExpanded] = useState('');
+ const selectedItemsList = useSelectionStore(
+ (state) => state.selectedItemsList
+ );
+ const setNotebooks = useNotebookStore((state) => state.setNotebooks);
+ const [expanded, setExpanded] = useState("");
const [notebookInputFocused, setNotebookInputFocused] = useState(false);
const [noteExists, setNoteExists] = useState([]);
const addNewNotebook = async () => {
if (!newNotebookTitle || newNotebookTitle.trim().length === 0)
return ToastEvent.show({
- heading: 'Notebook title is required',
- type: 'error',
- context: 'local'
+ heading: "Notebook title is required",
+ type: "error",
+ context: "local"
});
let id = await db.notebooks.add({
@@ -95,7 +103,7 @@ const MoveNoteComponent = ({ note }) => {
topics: [],
id: null
});
- console.log('added notebook id', id);
+ console.log("added notebook id", id);
setExpanded(id);
openAddTopicDialog(db.notebooks.notebook(id).data);
notebookInput.current?.clear();
@@ -107,9 +115,9 @@ const MoveNoteComponent = ({ note }) => {
const addNewTopic = async (value, item) => {
if (!value || value.trim().length === 0) {
ToastEvent.show({
- heading: 'Topic title is required',
- type: 'error',
- context: 'local'
+ heading: "Topic title is required",
+ type: "error",
+ context: "local"
});
return false;
}
@@ -121,7 +129,10 @@ const MoveNoteComponent = ({ note }) => {
};
const handlePress = async (item, index) => {
- let noteIds = selectedItemsList.length > 0 ? selectedItemsList.map(n => n.id) : [note?.id];
+ let noteIds =
+ selectedItemsList.length > 0
+ ? selectedItemsList.map((n) => n.id)
+ : [note?.id];
if (getCount(item)) {
await db.notebooks
@@ -139,11 +150,11 @@ const MoveNoteComponent = ({ note }) => {
}
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes"
);
setNotebooks();
@@ -158,17 +169,20 @@ const MoveNoteComponent = ({ note }) => {
const updateNoteExists = () => {
if (!note?.id && selectedItemsList?.length === 0) return;
- let notes = selectedItemsList.length > 0 ? selectedItemsList.map(n => n.id) : [note?.id];
+ let notes =
+ selectedItemsList.length > 0
+ ? selectedItemsList.map((n) => n.id)
+ : [note?.id];
let ids = [];
let notebooks = db.notebooks.all;
for (let i = 0; i < notebooks.length; i++) {
if (notebooks[i].topics) {
for (let t = 0; t < notebooks[i].topics.length; t++) {
let topic = notebooks[i].topics[t];
- if (topic.type !== 'topic') continue;
+ if (topic.type !== "topic") continue;
for (let id of notes) {
if (topic.notes.indexOf(id) > -1) {
- console.log('found', ids.indexOf(notebooks[i].id));
+ console.log("found", ids.indexOf(notebooks[i].id));
if (ids.indexOf(notebooks[i].id) === -1) {
ids.push(notebooks[i].id);
}
@@ -178,27 +192,30 @@ const MoveNoteComponent = ({ note }) => {
}
}
}
- console.log('ids: ', ids);
+ console.log("ids: ", ids);
setNoteExists(ids);
};
- const openAddTopicDialog = item => {
+ const openAddTopicDialog = (item) => {
presentDialog({
- context: 'move_note',
+ context: "move_note",
input: true,
- inputPlaceholder: 'Enter title',
- title: 'New topic',
- paragraph: 'Add a new topic in ' + item.title,
- positiveText: 'Add',
- positivePress: value => {
+ inputPlaceholder: "Enter title",
+ title: "New topic",
+ paragraph: "Add a new topic in " + item.title,
+ positiveText: "Add",
+ positivePress: (value) => {
return addNewTopic(value, item);
}
});
};
- const getCount = topic => {
+ const getCount = (topic) => {
if (!topic) return;
- let notes = selectedItemsList.length > 0 ? selectedItemsList.map(n => n.id) : [note?.id];
+ let notes =
+ selectedItemsList.length > 0
+ ? selectedItemsList.map((n) => n.id)
+ : [note?.id];
let count = 0;
for (let id of notes) {
if (topic.notes.indexOf(id) > -1) {
@@ -216,9 +233,9 @@ const MoveNoteComponent = ({ note }) => {
<View>
<TouchableOpacity
style={{
- width: '100%',
- height: '100%',
- position: 'absolute'
+ width: "100%",
+ height: "100%",
+ position: "absolute"
}}
onPress={() => {
Keyboard.dismiss();
@@ -227,8 +244,8 @@ const MoveNoteComponent = ({ note }) => {
<View
style={{
paddingHorizontal: 12,
- flexDirection: 'row',
- justifyContent: 'space-between'
+ flexDirection: "row",
+ justifyContent: "space-between"
}}
>
<DialogHeader
@@ -255,13 +272,13 @@ const MoveNoteComponent = ({ note }) => {
ListHeaderComponent={
<View
style={{
- width: '100%',
+ width: "100%",
marginTop: 10
}}
>
<Input
fwdRef={notebookInput}
- onChangeText={value => {
+ onChangeText={(value) => {
newNotebookTitle = value;
}}
testID={notesnook.ids.dialogs.addTo.addNotebook}
@@ -273,7 +290,7 @@ const MoveNoteComponent = ({ note }) => {
setNotebookInputFocused(false);
}}
button={{
- icon: 'check',
+ icon: "check",
color: notebookInputFocused ? colors.accent : colors.icon,
onPress: addNewNotebook
}}
@@ -289,9 +306,9 @@ const MoveNoteComponent = ({ note }) => {
<View
style={{
borderWidth: 1,
- borderColor: expanded ? colors.nav : 'transparent',
+ borderColor: expanded ? colors.nav : "transparent",
borderRadius: 6,
- overflow: 'hidden',
+ overflow: "hidden",
marginBottom: 10
}}
>
@@ -309,40 +326,42 @@ const MoveNoteComponent = ({ note }) => {
type="grayBg"
customStyle={{
height: 50,
- width: '100%',
+ width: "100%",
borderRadius: 5,
- alignItems: 'flex-start'
+ alignItems: "flex-start"
}}
>
<View
style={{
- width: '100%',
+ width: "100%",
height: 50,
- justifyContent: 'space-between',
- flexDirection: 'row',
- alignItems: 'center',
+ justifyContent: "space-between",
+ flexDirection: "row",
+ alignItems: "center",
paddingHorizontal: 12
}}
>
<View>
<Heading
- color={noteExists.indexOf(item.id) > -1 ? colors.accent : null}
+ color={
+ noteExists.indexOf(item.id) > -1 ? colors.accent : null
+ }
size={SIZE.md}
>
{item.title}
</Heading>
{item.topics?.length > 0 ? (
<Paragraph size={SIZE.xs} color={colors.icon}>
- {getTotalNotes(item) + ' notes' + ' & '}
+ {getTotalNotes(item) + " notes" + " & "}
{item.topics.length === 1
- ? item.topics.length + ' topic'
- : item.topics.length + ' topics'}
+ ? item.topics.length + " topic"
+ : item.topics.length + " topics"}
</Paragraph>
) : null}
</View>
<IconButton
- name={expanded === item.id ? 'plus' : 'chevron-down'}
+ name={expanded === item.id ? "plus" : "chevron-down"}
color={expanded === item.id ? colors.accent : colors.pri}
size={SIZE.xl}
onPress={() => {
@@ -361,15 +380,15 @@ const MoveNoteComponent = ({ note }) => {
{expanded === item.id ? (
<FlatList
nestedScrollEnabled
- data={item.topics?.filter(t => t.type === 'topic')}
+ data={item.topics?.filter((t) => t.type === "topic")}
keyboardShouldPersistTaps="always"
keyboardDismissMode="none"
onMomentumScrollEnd={() => {
actionSheetRef.current?.handleChildScrollEnd();
}}
style={{
- width: '100%',
- alignSelf: 'flex-end',
+ width: "100%",
+ alignSelf: "flex-end",
maxHeight: 500
}}
renderItem={({ item, index }) => (
@@ -380,19 +399,21 @@ const MoveNoteComponent = ({ note }) => {
minHeight: 50,
borderTopWidth: index === 0 ? 0 : 1,
borderTopColor: index === 0 ? null : colors.nav,
- width: '100%',
+ width: "100%",
borderRadius: 0,
- alignItems: 'center',
- flexDirection: 'row',
+ alignItems: "center",
+ flexDirection: "row",
paddingHorizontal: 12,
- justifyContent: 'space-between',
+ justifyContent: "space-between",
paddingVertical: 12
}}
>
<View>
- <Paragraph color={colors.heading}>{item.title}</Paragraph>
+ <Paragraph color={colors.heading}>
+ {item.title}
+ </Paragraph>
<Paragraph color={colors.icon} size={SIZE.xs}>
- {item.notes.length + ' notes'}
+ {item.notes.length + " notes"}
</Paragraph>
{getCount(item) ? (
<View
diff --git a/apps/mobile/app/components/sheets/export-notes/index.js b/apps/mobile/app/components/sheets/export-notes/index.js
index d803819da..88ca135ef 100644
--- a/apps/mobile/app/components/sheets/export-notes/index.js
+++ b/apps/mobile/app/components/sheets/export-notes/index.js
@@ -1,27 +1,30 @@
-import React, { Fragment, useEffect, useRef, useState } from 'react';
-import { Platform, StyleSheet, View } from 'react-native';
-import FileViewer from 'react-native-file-viewer';
-import Share from 'react-native-share';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { notesnook } from '../../../../e2e/test.ids';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { ToastEvent } from '../../../services/event-manager';
-import Exporter from '../../../services/exporter';
-import { getElevation } from '../../../utils';
-import { ph, pv, SIZE } from '../../../utils/size';
-import { sleep } from '../../../utils/time';
-import SheetWrapper from '../../ui/sheet';
-import { Button } from '../../ui/button';
-import DialogHeader from '../../dialog/dialog-header';
-import { PressableButton } from '../../ui/pressable';
-import Seperator from '../../ui/seperator';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
-import { eOpenExportDialog, eCloseExportDialog } from '../../../utils/events';
+import React, { Fragment, useEffect, useRef, useState } from "react";
+import { Platform, StyleSheet, View } from "react-native";
+import FileViewer from "react-native-file-viewer";
+import Share from "react-native-share";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { notesnook } from "../../../../e2e/test.ids";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { ToastEvent } from "../../../services/event-manager";
+import Exporter from "../../../services/exporter";
+import { getElevation } from "../../../utils";
+import { ph, pv, SIZE } from "../../../utils/size";
+import { sleep } from "../../../utils/time";
+import SheetWrapper from "../../ui/sheet";
+import { Button } from "../../ui/button";
+import DialogHeader from "../../dialog/dialog-header";
+import { PressableButton } from "../../ui/pressable";
+import Seperator from "../../ui/seperator";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../../services/event-manager";
+import { eOpenExportDialog, eCloseExportDialog } from "../../../utils/events";
const ExportNotesSheet = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const actionSheetRef = useRef();
@@ -40,12 +43,12 @@ const ExportNotesSheet = () => {
};
}, []);
- const open = data => {
+ const open = (data) => {
setVisible(true);
setNotes(data);
};
- const close = data => {
+ const close = (data) => {
setComplete(false);
setExporting(false);
setVisible(false);
@@ -67,7 +70,9 @@ const ExportNotesSheet = () => {
}
setDoneText(
`Note exported successfully! You can find the exported note in ${
- Platform.OS === 'ios' ? 'Files Manager/Notesnook' : `Storage/Notesnook/exported/${name}`
+ Platform.OS === "ios"
+ ? "Files Manager/Notesnook"
+ : `Storage/Notesnook/exported/${name}`
}.`
);
@@ -84,39 +89,39 @@ const ExportNotesSheet = () => {
const actions = [
{
- title: 'PDF',
+ title: "PDF",
func: async () => {
- await save(Exporter.saveToPDF, 'PDF');
+ await save(Exporter.saveToPDF, "PDF");
},
- icon: 'file-pdf-box',
- desc: 'Can be opened in a pdf reader like Adobe or Foxit Reader',
+ icon: "file-pdf-box",
+ desc: "Can be opened in a pdf reader like Adobe or Foxit Reader",
id: notesnook.ids.dialogs.export.pdf
},
{
- title: 'Markdown',
+ title: "Markdown",
func: async () => {
- await save(Exporter.saveToMarkdown, 'Markdown');
+ await save(Exporter.saveToMarkdown, "Markdown");
},
- icon: 'language-markdown',
- desc: 'Can be opened in any text or markdown editor',
+ icon: "language-markdown",
+ desc: "Can be opened in any text or markdown editor",
id: notesnook.ids.dialogs.export.md
},
{
- title: 'Plain Text',
+ title: "Plain Text",
func: async () => {
- await save(Exporter.saveToText, 'Text');
+ await save(Exporter.saveToText, "Text");
},
- icon: 'card-text',
- desc: 'Can be opened in any text editor',
+ icon: "card-text",
+ desc: "Can be opened in any text editor",
id: notesnook.ids.dialogs.export.text
},
{
- title: 'HTML',
+ title: "HTML",
func: async () => {
- await save(Exporter.saveToHTML, 'Html');
+ await save(Exporter.saveToHTML, "Html");
},
- icon: 'language-html5',
- desc: 'Can be opened in any web browser',
+ icon: "language-html5",
+ desc: "Can be opened in any web browser",
id: notesnook.ids.dialogs.export.html
}
];
@@ -132,24 +137,26 @@ const ExportNotesSheet = () => {
<DialogHeader
icon="export"
title="Export Note"
- paragraph={'All exports are saved in Notesnook/exported folder in phone storage'}
+ paragraph={
+ "All exports are saved in Notesnook/exported folder in phone storage"
+ }
/>
</View>
<Seperator half />
<View style={styles.buttonContainer}>
- {actions.map(item => (
+ {actions.map((item) => (
<Fragment key={item.title}>
<Seperator half />
<PressableButton
onPress={item.func}
customStyle={{
- width: '100%',
- alignItems: 'center',
- flexDirection: 'row',
+ width: "100%",
+ alignItems: "center",
+ flexDirection: "row",
paddingRight: 12,
paddingVertical: 10,
- justifyContent: 'flex-start',
+ justifyContent: "flex-start",
borderRadius: 0,
paddingHorizontal: 12
}}
@@ -160,11 +167,15 @@ const ExportNotesSheet = () => {
borderRadius: 5,
height: 60,
width: 60,
- justifyContent: 'center',
- alignItems: 'center'
+ justifyContent: "center",
+ alignItems: "center"
}}
>
- <Icon name={item.icon} color={colors.accent} size={SIZE.xxxl + 10} />
+ <Icon
+ name={item.icon}
+ color={colors.accent}
+ size={SIZE.xxxl + 10}
+ />
</View>
<View
style={{
@@ -174,7 +185,11 @@ const ExportNotesSheet = () => {
<Heading style={{ marginLeft: 10 }} size={SIZE.md}>
{item.title}
</Heading>
- <Paragraph style={{ marginLeft: 10 }} size={SIZE.sm} color={colors.icon}>
+ <Paragraph
+ style={{ marginLeft: 10 }}
+ size={SIZE.sm}
+ color={colors.icon}
+ >
{item.desc}
</Paragraph>
</View>
@@ -184,7 +199,7 @@ const ExportNotesSheet = () => {
<View
style={{
- width: '100%',
+ width: "100%",
paddingHorizontal: 12,
marginTop: 10
}}
@@ -202,12 +217,12 @@ const ExportNotesSheet = () => {
FileViewer.open(result.filePath, {
showOpenWithDialog: true,
showAppsSuggestions: true
- }).catch(e => {
+ }).catch((e) => {
ToastEvent.show({
- heading: 'Cannot open',
+ heading: "Cannot open",
message: `No application found to open ${result.name} file.`,
- type: 'success',
- context: 'local'
+ type: "success",
+ context: "local"
});
});
}}
@@ -222,9 +237,9 @@ const ExportNotesSheet = () => {
marginTop: 10
}}
onPress={async () => {
- if (Platform.OS === 'ios') {
+ if (Platform.OS === "ios") {
Share.open({
- url: 'file:/' + result.filePath
+ url: "file:/" + result.filePath
}).catch(console.log);
} else {
FileViewer.open(result.filePath, {
@@ -241,16 +256,18 @@ const ExportNotesSheet = () => {
{complete && (
<Paragraph
style={{
- textAlign: 'center',
+ textAlign: "center",
marginTop: 5
}}
color={colors.icon}
size={SIZE.xs}
>
- {'Note exported as ' + result.fileName}
+ {"Note exported as " + result.fileName}
</Paragraph>
)}
- {exporting && !complete && <Button loading={true} height={50} width="100%" />}
+ {exporting && !complete && (
+ <Button loading={true} height={50} width="100%" />
+ )}
</View>
</View>
</View>
@@ -265,30 +282,30 @@ const styles = StyleSheet.create({
paddingVertical: pv
},
buttonContainer: {
- justifyContent: 'space-between',
- alignItems: 'center'
+ justifyContent: "space-between",
+ alignItems: "center"
},
button: {
paddingVertical: pv,
paddingHorizontal: ph,
marginTop: 10,
borderRadius: 5,
- width: '100%',
- justifyContent: 'center',
- alignItems: 'center',
+ width: "100%",
+ justifyContent: "center",
+ alignItems: "center",
borderWidth: 1,
- flexDirection: 'row'
+ flexDirection: "row"
},
buttonText: {
//fontFamily: "sans-serif",
- color: 'white',
+ color: "white",
fontSize: SIZE.sm,
marginLeft: 5
},
overlay: {
- width: '100%',
- height: '100%',
- position: 'absolute'
+ width: "100%",
+ height: "100%",
+ position: "absolute"
}
});
diff --git a/apps/mobile/app/components/sheets/export-notes/share.js b/apps/mobile/app/components/sheets/export-notes/share.js
index 0e6d3fd30..8badbeeb2 100644
--- a/apps/mobile/app/components/sheets/export-notes/share.js
+++ b/apps/mobile/app/components/sheets/export-notes/share.js
@@ -1,10 +1,10 @@
-import React from 'react';
-import { View } from 'react-native';
-import FileViewer from 'react-native-file-viewer';
-import Share from 'react-native-share';
-import { ToastEvent } from '../../../services/event-manager';
-import { SIZE } from '../../../utils/size';
-import { Button } from '../../ui/button';
+import React from "react";
+import { View } from "react-native";
+import FileViewer from "react-native-file-viewer";
+import Share from "react-native-share";
+import { ToastEvent } from "../../../services/event-manager";
+import { SIZE } from "../../../utils/size";
+import { Button } from "../../ui/button";
export const ShareComponent = ({ uri, name, padding }) => {
return (
@@ -22,12 +22,12 @@ export const ShareComponent = ({ uri, name, padding }) => {
FileViewer.open(uri, {
showOpenWithDialog: true,
showAppsSuggestions: true
- }).catch(e => {
+ }).catch((e) => {
ToastEvent.show({
- heading: 'Cannot open',
+ heading: "Cannot open",
message: `No application found to open ${name} file.`,
- type: 'success',
- context: 'local'
+ type: "success",
+ context: "local"
});
});
}}
diff --git a/apps/mobile/app/components/sheets/github/issue.js b/apps/mobile/app/components/sheets/github/issue.js
index effb26964..b2d296a55 100644
--- a/apps/mobile/app/components/sheets/github/issue.js
+++ b/apps/mobile/app/components/sheets/github/issue.js
@@ -1,27 +1,27 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import React, { useRef, useState } from 'react';
-import { Linking, Platform, Text, TextInput, View } from 'react-native';
-import { APP_VERSION } from '../../../version';
-import { eSendEvent, ToastEvent } from '../../../services/event-manager';
-import PremiumService from '../../../services/premium';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { useUserStore } from '../../../stores/use-user-store';
-import { db } from '../../../common/database';
-import { eCloseProgressDialog } from '../../../utils/events';
-import { openLinkInBrowser } from '../../../utils/functions';
-import { SIZE } from '../../../utils/size';
-import { sleep } from '../../../utils/time';
-import DialogHeader from '../../dialog/dialog-header';
-import { presentDialog } from '../../dialog/functions';
-import { Button } from '../../ui/button';
-import Seperator from '../../ui/seperator';
-import Paragraph from '../../ui/typography/paragraph';
+import Clipboard from "@react-native-clipboard/clipboard";
+import React, { useRef, useState } from "react";
+import { Linking, Platform, Text, TextInput, View } from "react-native";
+import { APP_VERSION } from "../../../version";
+import { eSendEvent, ToastEvent } from "../../../services/event-manager";
+import PremiumService from "../../../services/premium";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { useUserStore } from "../../../stores/use-user-store";
+import { db } from "../../../common/database";
+import { eCloseProgressDialog } from "../../../utils/events";
+import { openLinkInBrowser } from "../../../utils/functions";
+import { SIZE } from "../../../utils/size";
+import { sleep } from "../../../utils/time";
+import DialogHeader from "../../dialog/dialog-header";
+import { presentDialog } from "../../dialog/functions";
+import { Button } from "../../ui/button";
+import Seperator from "../../ui/seperator";
+import Paragraph from "../../ui/typography/paragraph";
export const Issue = ({ defaultTitle, defaultBody, issueTitle }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const body = useRef(defaultBody);
const title = useRef(defaultTitle);
- const user = useUserStore(state => state.user);
+ const user = useUserStore((state) => state.user);
const [loading, setLoading] = useState(false);
const bodyRef = useRef();
const initialLayout = useRef(false);
@@ -29,7 +29,8 @@ export const Issue = ({ defaultTitle, defaultBody, issueTitle }) => {
const onPress = async () => {
if (loading) return;
if (!title.current || !body.current) return;
- if (title.current?.trim() === '' || body.current?.trim().length === 0) return;
+ if (title.current?.trim() === "" || body.current?.trim().length === 0)
+ return;
try {
setLoading(true);
@@ -42,24 +43,24 @@ export const Issue = ({ defaultTitle, defaultBody, issueTitle }) => {
**Device information:**
App version: ${APP_VERSION}
Platform: ${Platform.OS}
-Model: ${Platform.constants.Brand || ''}-${Platform.constants.Model || ''}-${
- Platform.constants.Version || ''
+Model: ${Platform.constants.Brand || ""}-${Platform.constants.Model || ""}-${
+ Platform.constants.Version || ""
}
Pro: ${PremiumService.get()}
-Logged in: ${user ? 'yes' : 'no'}`,
+Logged in: ${user ? "yes" : "no"}`,
userId: user?.id
});
setLoading(false);
eSendEvent(eCloseProgressDialog);
await sleep(300);
presentDialog({
- title: 'Issue reported',
+ title: "Issue reported",
paragraph: (
<Text>
- You can track your issue at{' '}
+ You can track your issue at{" "}
<Text
style={{
- textDecorationLine: 'underline',
+ textDecorationLine: "underline",
color: colors.accent
}}
onPress={() => {
@@ -67,28 +68,28 @@ Logged in: ${user ? 'yes' : 'no'}`,
}}
>
{issue_url}.
- </Text>{' '}
- Please note that we will respond to your issue on the given link. We recommend that you
- save it.
+ </Text>{" "}
+ Please note that we will respond to your issue on the given link. We
+ recommend that you save it.
</Text>
),
- positiveText: 'Copy link',
+ positiveText: "Copy link",
positivePress: () => {
Clipboard.setString(issue_url);
ToastEvent.show({
- heading: 'Issue url copied!',
- type: 'success',
- context: 'global'
+ heading: "Issue url copied!",
+ type: "success",
+ context: "global"
});
},
- negativeText: 'Close'
+ negativeText: "Close"
});
} catch (e) {
setLoading(false);
ToastEvent.show({
- heading: 'An error occured',
+ heading: "An error occured",
message: e.message,
- type: 'error'
+ type: "error"
});
}
};
@@ -97,15 +98,15 @@ Logged in: ${user ? 'yes' : 'no'}`,
<View
style={{
paddingHorizontal: 12,
- width: '100%'
+ width: "100%"
}}
>
<DialogHeader
- title={issueTitle || 'Report issue'}
+ title={issueTitle || "Report issue"}
paragraph={
issueTitle
- ? 'We are sorry, it seems that the app crashed due to an error. You can submit a bug report below so we can fix this asap.'
- : 'Let us know if you have faced any issue/bug while using Notesnook.'
+ ? "We are sorry, it seems that the app crashed due to an error. You can submit a bug report below so we can fix this asap."
+ : "Let us know if you have faced any issue/bug while using Notesnook."
}
/>
@@ -113,14 +114,14 @@ Logged in: ${user ? 'yes' : 'no'}`,
<TextInput
placeholder="Title"
- onChangeText={v => (title.current = v)}
+ onChangeText={(v) => (title.current = v)}
defaultValue={title.current}
style={{
borderWidth: 1,
borderColor: colors.nav,
borderRadius: 5,
padding: 12,
- fontFamily: 'OpenSans-Regular',
+ fontFamily: "OpenSans-Regular",
marginBottom: 10,
fontSize: SIZE.md,
color: colors.heading
@@ -138,7 +139,7 @@ For example:
multiline
numberOfLines={5}
textAlignVertical="top"
- onChangeText={v => (body.current = v)}
+ onChangeText={(v) => (body.current = v)}
onLayout={() => {
if (initialLayout.current) return;
initialLayout.current = true;
@@ -157,7 +158,7 @@ For example:
borderColor: colors.nav,
borderRadius: 5,
padding: 12,
- fontFamily: 'OpenSans-Regular',
+ fontFamily: "OpenSans-Regular",
maxHeight: 200,
fontSize: SIZE.sm,
marginBottom: 2.5,
@@ -173,7 +174,7 @@ For example:
<Seperator />
<Button
onPress={onPress}
- title={loading ? null : 'Submit'}
+ title={loading ? null : "Submit"}
loading={loading}
height={50}
width="100%"
@@ -185,30 +186,31 @@ For example:
size={SIZE.xs}
style={{
marginTop: 10,
- textAlign: 'center'
+ textAlign: "center"
}}
>
- The information above will be publically available at{' '}
+ The information above will be publically available at{" "}
<Text
onPress={() => {
- Linking.openURL('https://github.com/streetwriters/notesnook');
+ Linking.openURL("https://github.com/streetwriters/notesnook");
}}
style={{
- textDecorationLine: 'underline',
+ textDecorationLine: "underline",
color: colors.accent
}}
>
github.com/streetwriters/notesnook.
- </Text>{' '}
- If you want to ask something in general or need some assistance, we would suggest that you{' '}
+ </Text>{" "}
+ If you want to ask something in general or need some assistance, we
+ would suggest that you{" "}
<Text
style={{
- textDecorationLine: 'underline',
+ textDecorationLine: "underline",
color: colors.accent
}}
onPress={async () => {
try {
- await openLinkInBrowser('https://discord.gg/zQBK97EE22', colors);
+ await openLinkInBrowser("https://discord.gg/zQBK97EE22", colors);
} catch (e) {}
}}
>
diff --git a/apps/mobile/app/components/sheets/manage-tags/index.js b/apps/mobile/app/components/sheets/manage-tags/index.js
index c191d001d..b47d60426 100644
--- a/apps/mobile/app/components/sheets/manage-tags/index.js
+++ b/apps/mobile/app/components/sheets/manage-tags/index.js
@@ -1,24 +1,28 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { ScrollView, View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { useTagStore } from '../../../stores/use-tag-store';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { db } from '../../../common/database';
-import { eCloseTagsDialog, eOpenTagsDialog } from '../../../utils/events';
-import { SIZE } from '../../../utils/size';
-import { sleep } from '../../../utils/time';
-import Input from '../../ui/input';
-import { PressableButton } from '../../ui/pressable';
-import SheetWrapper from '../../ui/sheet';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
+import React, { useEffect, useRef, useState } from "react";
+import { ScrollView, View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { useTagStore } from "../../../stores/use-tag-store";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent,
+ ToastEvent
+} from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { db } from "../../../common/database";
+import { eCloseTagsDialog, eOpenTagsDialog } from "../../../utils/events";
+import { SIZE } from "../../../utils/size";
+import { sleep } from "../../../utils/time";
+import Input from "../../ui/input";
+import { PressableButton } from "../../ui/pressable";
+import SheetWrapper from "../../ui/sheet";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
const ManageTagsSheet = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const [note, setNote] = useState(null);
- const allTags = useTagStore(state => state.tags);
+ const allTags = useTagStore((state) => state.tags);
const [tags, setTags] = useState([]);
const [query, setQuery] = useState(null);
const inputRef = useRef();
@@ -35,17 +39,17 @@ const ManageTagsSheet = () => {
useEffect(() => {
if (visible) {
- console.log('sorting tags');
+ console.log("sorting tags");
sortTags();
}
}, [allTags, note, query, visible]);
const sortTags = () => {
let _tags = [...allTags];
- _tags = _tags.filter(t => t.type === 'tag');
+ _tags = _tags.filter((t) => t.type === "tag");
_tags = _tags.sort((a, b) => a.title.localeCompare(b.title));
if (query) {
- _tags = _tags.filter(t => t.title.startsWith(query));
+ _tags = _tags.filter((t) => t.title.startsWith(query));
}
if (!note || !note.tags) {
@@ -54,7 +58,7 @@ const ManageTagsSheet = () => {
}
let noteTags = [];
for (let tag of note.tags) {
- let index = _tags.findIndex(t => t.title === tag);
+ let index = _tags.findIndex((t) => t.title === tag);
if (index !== -1) {
noteTags.push(_tags[index]);
_tags.splice(index, 1);
@@ -65,7 +69,7 @@ const ManageTagsSheet = () => {
setTags(combinedTags);
};
- const open = item => {
+ const open = (item) => {
setNote(item);
useTagStore.getState().setTags();
sortTags();
@@ -85,11 +89,11 @@ const ManageTagsSheet = () => {
const onSubmit = async () => {
let _query = query;
- if (!_query || _query === '' || _query.trimStart().length == 0) {
+ if (!_query || _query === "" || _query.trimStart().length == 0) {
ToastEvent.show({
- heading: 'Tag field is empty',
- type: 'error',
- context: 'local'
+ heading: "Tag field is empty",
+ type: "error",
+ context: "local"
});
return;
}
@@ -98,7 +102,7 @@ const ManageTagsSheet = () => {
setNote({ ...note, tags: note.tags ? [...note.tags, tag] : [tag] });
setQuery(null);
inputRef.current?.setNativeProps({
- text: ''
+ text: ""
});
try {
await db.notes.note(note.id).tag(tag);
@@ -106,21 +110,21 @@ const ManageTagsSheet = () => {
setNote(db.notes.note(note.id).data);
} catch (e) {
ToastEvent.show({
- heading: 'Cannot add tag',
- type: 'error',
+ heading: "Cannot add tag",
+ type: "error",
message: e.message,
- context: 'local'
+ context: "local"
});
}
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes',
- 'Notebooks',
- 'Notebook'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes",
+ "Notebooks",
+ "Notebook"
);
};
@@ -139,22 +143,22 @@ const ManageTagsSheet = () => {
>
<View
style={{
- width: '100%',
- alignSelf: 'center',
+ width: "100%",
+ alignSelf: "center",
paddingHorizontal: 12,
- minHeight: '60%'
+ minHeight: "60%"
}}
>
<Input
button={{
- icon: 'magnify',
+ icon: "magnify",
color: colors.accent,
size: SIZE.lg
}}
testID="tag-input"
fwdRef={inputRef}
autoCapitalize="none"
- onChangeText={v => {
+ onChangeText={(v) => {
setQuery(db.tags.sanitize(v));
}}
onSubmit={onSubmit}
@@ -174,18 +178,18 @@ const ManageTagsSheet = () => {
>
{query && query !== tags[0]?.title ? (
<PressableButton
- key={'query_item'}
+ key={"query_item"}
customStyle={{
- flexDirection: 'row',
+ flexDirection: "row",
marginVertical: 5,
- justifyContent: 'space-between',
+ justifyContent: "space-between",
padding: 12
}}
onPress={onSubmit}
type="accent"
>
<Heading size={SIZE.sm} color={colors.light}>
- Add {`"` + '#' + query + `"`}
+ Add {`"` + "#" + query + `"`}
</Heading>
<Icon name="plus" color={colors.light} size={SIZE.lg} />
</PressableButton>
@@ -193,10 +197,10 @@ const ManageTagsSheet = () => {
{!allTags || allTags.length === 0 ? (
<View
style={{
- width: '100%',
+ width: "100%",
height: 200,
- justifyContent: 'center',
- alignItems: 'center'
+ justifyContent: "center",
+ alignItems: "center"
}}
>
<Heading size={50} color={colors.icon}>
@@ -208,8 +212,13 @@ const ManageTagsSheet = () => {
</View>
) : null}
- {tags.map(item => (
- <TagItem key={item.title} tag={item} note={note} setNote={setNote} />
+ {tags.map((item) => (
+ <TagItem
+ key={item.title}
+ tag={item}
+ note={note}
+ setNote={setNote}
+ />
))}
</ScrollView>
</View>
@@ -220,13 +229,15 @@ const ManageTagsSheet = () => {
export default ManageTagsSheet;
const TagItem = ({ tag, note, setNote }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const onPress = async () => {
let prevNote = { ...note };
try {
if (prevNote.tags.indexOf(tag.title) !== -1) {
- await db.notes.note(note.id).untag(prevNote.tags[prevNote.tags.indexOf(tag.title)]);
+ await db.notes
+ .note(note.id)
+ .untag(prevNote.tags[prevNote.tags.indexOf(tag.title)]);
} else {
await db.notes.note(note.id).tag(tag.title);
}
@@ -235,11 +246,11 @@ const TagItem = ({ tag, note, setNote }) => {
} catch (e) {}
setTimeout(() => {
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes"
);
}, 1);
};
@@ -247,26 +258,38 @@ const TagItem = ({ tag, note, setNote }) => {
return (
<PressableButton
customStyle={{
- flexDirection: 'row',
+ flexDirection: "row",
marginVertical: 5,
- justifyContent: 'space-between',
+ justifyContent: "space-between",
padding: 12
}}
onPress={onPress}
- type={note && note.tags.findIndex(t => t === tag.title) !== -1 ? 'shade' : 'grayBg'}
+ type={
+ note && note.tags.findIndex((t) => t === tag.title) !== -1
+ ? "shade"
+ : "grayBg"
+ }
>
<Heading
size={SIZE.sm}
color={
- note && note?.tags.findIndex(t => t === tag.title) !== -1 ? colors.accent : colors.pri
+ note && note?.tags.findIndex((t) => t === tag.title) !== -1
+ ? colors.accent
+ : colors.pri
}
>
- {'#' + tag.title}
+ {"#" + tag.title}
</Heading>
<Icon
- name={note && note?.tags.findIndex(t => t === tag.title) !== -1 ? 'minus' : 'plus'}
+ name={
+ note && note?.tags.findIndex((t) => t === tag.title) !== -1
+ ? "minus"
+ : "plus"
+ }
color={
- note && note?.tags.findIndex(t => t === tag.title) !== -1 ? colors.accent : colors.accent
+ note && note?.tags.findIndex((t) => t === tag.title) !== -1
+ ? colors.accent
+ : colors.accent
}
size={SIZE.lg}
/>
diff --git a/apps/mobile/app/components/sheets/migrate/index.tsx b/apps/mobile/app/components/sheets/migrate/index.tsx
index 6f1ab1b9e..96281be33 100644
--- a/apps/mobile/app/components/sheets/migrate/index.tsx
+++ b/apps/mobile/app/components/sheets/migrate/index.tsx
@@ -1,22 +1,25 @@
-import React, { useState } from 'react';
-import { View } from 'react-native';
-import BackupService from '../../../services/backup';
-import { eSendEvent, ToastEvent } from '../../../services/event-manager';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { db } from '../../../common/database';
-import { eCloseProgressDialog, eCloseSimpleDialog } from '../../../utils/events';
-import { sleep } from '../../../utils/time';
-import { Dialog } from '../../dialog';
-import DialogHeader from '../../dialog/dialog-header';
-import { Button } from '../../ui/button';
-import { Notice } from '../../ui/notice';
-import Seperator from '../../ui/seperator';
-import { ProgressBarComponent } from '../../ui/svg/lazy';
-import Paragraph from '../../ui/typography/paragraph';
-import { presentDialog } from '../../dialog/functions';
+import React, { useState } from "react";
+import { View } from "react-native";
+import BackupService from "../../../services/backup";
+import { eSendEvent, ToastEvent } from "../../../services/event-manager";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { db } from "../../../common/database";
+import {
+ eCloseProgressDialog,
+ eCloseSimpleDialog
+} from "../../../utils/events";
+import { sleep } from "../../../utils/time";
+import { Dialog } from "../../dialog";
+import DialogHeader from "../../dialog/dialog-header";
+import { Button } from "../../ui/button";
+import { Notice } from "../../ui/notice";
+import Seperator from "../../ui/seperator";
+import { ProgressBarComponent } from "../../ui/svg/lazy";
+import Paragraph from "../../ui/typography/paragraph";
+import { presentDialog } from "../../dialog/functions";
export default function Migrate() {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [loading, setLoading] = useState(false);
return (
@@ -29,7 +32,7 @@ export default function Migrate() {
<DialogHeader
title="Database migration required"
paragraph={
- 'Due to new features we need to migrate your data to a newer version. This is NOT a destructive operation.'
+ "Due to new features we need to migrate your data to a newer version. This is NOT a destructive operation."
}
/>
<Seperator />
@@ -51,8 +54,8 @@ If you face any other issues or are unsure about what to do, feel free to reach
style={{
width: 200,
height: 100,
- alignSelf: 'center',
- justifyContent: 'center'
+ alignSelf: "center",
+ justifyContent: "center"
}}
>
<ProgressBarComponent
@@ -69,7 +72,7 @@ If you face any other issues or are unsure about what to do, feel free to reach
<Paragraph
style={{
marginTop: 5,
- textAlign: 'center'
+ textAlign: "center"
}}
>
Migration in progress... please wait
@@ -83,12 +86,13 @@ If you face any other issues or are unsure about what to do, feel free to reach
width={250}
onPress={async () => {
setLoading(true);
- const backupSaved = await BackupService.run(false, 'local');
+ const backupSaved = await BackupService.run(false, "local");
if (!backupSaved) {
ToastEvent.show({
- heading: 'Migration failed',
- message: 'You must download a backup of your data before migrating.',
- context: 'local'
+ heading: "Migration failed",
+ message:
+ "You must download a backup of your data before migrating.",
+ context: "local"
});
setLoading(false);
}
@@ -97,11 +101,11 @@ If you face any other issues or are unsure about what to do, feel free to reach
setLoading(false);
await sleep(500);
presentDialog({
- title: 'Migration successful',
+ title: "Migration successful",
paragraph:
- 'Your data has been migrated. If you face any issues after the migration please reach out to us via email or Discord.',
- context: 'global',
- negativeText: 'Ok'
+ "Your data has been migrated. If you face any issues after the migration please reach out to us via email or Discord.",
+ context: "global",
+ negativeText: "Ok"
});
}}
style={{
diff --git a/apps/mobile/app/components/sheets/move-notes/movenote.tsx b/apps/mobile/app/components/sheets/move-notes/movenote.tsx
index 104b1a731..c206b7767 100644
--- a/apps/mobile/app/components/sheets/move-notes/movenote.tsx
+++ b/apps/mobile/app/components/sheets/move-notes/movenote.tsx
@@ -1,23 +1,27 @@
-import React, { RefObject, useState } from 'react';
-import { Platform, View } from 'react-native';
-import ActionSheet from 'react-native-actions-sheet';
-import { FlatList } from 'react-native-gesture-handler';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { eSendEvent, presentSheet, ToastEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { db } from '../../../common/database';
-import { eCloseProgressDialog } from '../../../utils/events';
-import { SIZE } from '../../../utils/size';
-import { IconButton } from '../../ui/icon-button';
-import { Button } from '../../ui/button';
-import { Dialog } from '../../dialog';
-import DialogHeader from '../../dialog/dialog-header';
-import { presentDialog } from '../../dialog/functions';
-import { PressableButton } from '../../ui/pressable';
-import Seperator from '../../ui/seperator';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
-import SearchService from '../../../services/search';
+import React, { RefObject, useState } from "react";
+import { Platform, View } from "react-native";
+import ActionSheet from "react-native-actions-sheet";
+import { FlatList } from "react-native-gesture-handler";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import {
+ eSendEvent,
+ presentSheet,
+ ToastEvent
+} from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { db } from "../../../common/database";
+import { eCloseProgressDialog } from "../../../utils/events";
+import { SIZE } from "../../../utils/size";
+import { IconButton } from "../../ui/icon-button";
+import { Button } from "../../ui/button";
+import { Dialog } from "../../dialog";
+import DialogHeader from "../../dialog/dialog-header";
+import { presentDialog } from "../../dialog/functions";
+import { PressableButton } from "../../ui/pressable";
+import Seperator from "../../ui/seperator";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
+import SearchService from "../../../services/search";
export const MoveNotes = ({
notebook,
@@ -28,7 +32,7 @@ export const MoveNotes = ({
selectedTopic?: any;
fwdRef: RefObject<ActionSheet>;
}) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [currentNotebook, setCurrentNotebook] = useState(notebook);
let notes = db.notes?.all;
@@ -36,18 +40,18 @@ export const MoveNotes = ({
const [selectedNoteIds, setSelectedNoteIds] = useState<string[]>([]);
const [topic, setTopic] = useState(selectedTopic);
//@ts-ignore
- notes = notes.filter(note => topic?.notes.indexOf(note.id) === -1);
+ notes = notes.filter((note) => topic?.notes.indexOf(note.id) === -1);
const select = (id: string) => {
let index = selectedNoteIds.indexOf(id);
if (index > -1) {
- setSelectedNoteIds(selectedNoteIds => {
+ setSelectedNoteIds((selectedNoteIds) => {
let next = [...selectedNoteIds];
next.splice(index, 1);
return next;
});
} else {
- setSelectedNoteIds(selectedNoteIds => {
+ setSelectedNoteIds((selectedNoteIds) => {
let next = [...selectedNoteIds];
next.push(id);
return next;
@@ -58,13 +62,13 @@ export const MoveNotes = ({
const openAddTopicDialog = () => {
presentDialog({
//@ts-ignore
- context: 'local',
+ context: "local",
input: true,
- inputPlaceholder: 'Enter title',
- title: 'New topic',
- paragraph: 'Add a new topic in ' + currentNotebook.title,
- positiveText: 'Add',
- positivePress: value => {
+ inputPlaceholder: "Enter title",
+ title: "New topic",
+ paragraph: "Add a new topic in " + currentNotebook.title,
+ positiveText: "Add",
+ positivePress: (value) => {
return addNewTopic(value);
}
});
@@ -74,9 +78,9 @@ export const MoveNotes = ({
if (!value || value.trim().length === 0) {
//@ts-ignore
ToastEvent.show({
- heading: 'Topic title is required',
- type: 'error',
- context: 'local'
+ heading: "Topic title is required",
+ type: "error",
+ context: "local"
});
return false;
}
@@ -84,13 +88,13 @@ export const MoveNotes = ({
setCurrentNotebook(db.notebooks?.notebook(currentNotebook.id).data);
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes',
- 'Notebook',
- 'Notebooks'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes",
+ "Notebook",
+ "Notebooks"
);
return true;
};
@@ -100,18 +104,18 @@ export const MoveNotes = ({
<PressableButton
testID="listitem.select"
onPress={() => {
- if (item.type == 'topic') {
+ if (item.type == "topic") {
setTopic(topic ? null : item);
} else {
select(item.id);
}
}}
- type={'transparent'}
+ type={"transparent"}
customStyle={{
paddingVertical: 12,
- justifyContent: 'space-between',
+ justifyContent: "space-between",
paddingHorizontal: 12,
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
<View
@@ -119,17 +123,20 @@ export const MoveNotes = ({
flexShrink: 1
}}
>
- <Paragraph numberOfLines={1} color={item?.id === topic?.id ? colors.accent : colors.pri}>
+ <Paragraph
+ numberOfLines={1}
+ color={item?.id === topic?.id ? colors.accent : colors.pri}
+ >
{item.title}
</Paragraph>
- {item.type == 'note' && item.headline ? (
+ {item.type == "note" && item.headline ? (
<Paragraph numberOfLines={1} color={colors.icon} size={SIZE.xs + 1}>
{item.headline}
</Paragraph>
) : null}
</View>
- {item.type === 'topic' ? (
+ {item.type === "topic" ? (
<Paragraph
style={{
fontSize: SIZE.xs
@@ -145,7 +152,7 @@ export const MoveNotes = ({
customStyle={{
width: null,
height: null,
- backgroundColor: 'transparent'
+ backgroundColor: "transparent"
}}
name="check"
type="grayAccent"
@@ -163,7 +170,7 @@ export const MoveNotes = ({
<View
style={{
paddingHorizontal: 12,
- maxHeight: Platform.OS === 'ios' ? '96%' : '97%'
+ maxHeight: Platform.OS === "ios" ? "96%" : "97%"
}}
>
<Dialog context="local" />
@@ -174,30 +181,32 @@ export const MoveNotes = ({
}}
customStyle={{
paddingVertical: 12,
- justifyContent: 'space-between',
+ justifyContent: "space-between",
paddingHorizontal: 12,
marginBottom: 10,
- alignItems: 'flex-start'
+ alignItems: "flex-start"
}}
type="grayBg"
>
<View
style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
- width: '100%'
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
+ width: "100%"
}}
>
- <Heading size={SIZE.md}>Adding notes to {currentNotebook.title}</Heading>
+ <Heading size={SIZE.md}>
+ Adding notes to {currentNotebook.title}
+ </Heading>
</View>
<View
style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
- width: '100%',
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
+ width: "100%",
marginTop: 5
}}
>
@@ -219,7 +228,7 @@ export const MoveNotes = ({
paragraph={
topic
? `Select notes you would like to move to ${topic.title}.`
- : 'Select the topic in which you would like to move notes.'
+ : "Select the topic in which you would like to move notes."
}
/>
<Seperator />
@@ -235,12 +244,12 @@ export const MoveNotes = ({
<View
style={{
minHeight: 100,
- justifyContent: 'center',
- alignItems: 'center'
+ justifyContent: "center",
+ alignItems: "center"
}}
>
<Paragraph color={colors.icon}>
- {topic ? 'No notes to show' : 'No topics in this notebook'}
+ {topic ? "No notes to show" : "No topics in this notebook"}
</Paragraph>
{!topic && (
@@ -273,13 +282,13 @@ export const MoveNotes = ({
...selectedNoteIds
);
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes',
- 'Notebook',
- 'Notebooks'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes",
+ "Notebook",
+ "Notebooks"
);
SearchService.updateAndSearch();
eSendEvent(eCloseProgressDialog);
diff --git a/apps/mobile/app/components/sheets/new-feature/index.tsx b/apps/mobile/app/components/sheets/new-feature/index.tsx
index 0263e3627..77cae5d10 100644
--- a/apps/mobile/app/components/sheets/new-feature/index.tsx
+++ b/apps/mobile/app/components/sheets/new-feature/index.tsx
@@ -1,29 +1,29 @@
-import React from 'react';
-import { Platform, View } from 'react-native';
-import { APP_VERSION } from '../../../version';
-import { eSendEvent, presentSheet } from '../../../services/event-manager';
-import SettingsService from '../../../services/settings';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { eCloseProgressDialog } from '../../../utils/events';
-import { SIZE } from '../../../utils/size';
-import { Button } from '../../ui/button';
-import Seperator from '../../ui/seperator';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
-import { features } from '../../../features';
+import React from "react";
+import { Platform, View } from "react-native";
+import { APP_VERSION } from "../../../version";
+import { eSendEvent, presentSheet } from "../../../services/event-manager";
+import SettingsService from "../../../services/settings";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { eCloseProgressDialog } from "../../../utils/events";
+import { SIZE } from "../../../utils/size";
+import { Button } from "../../ui/button";
+import Seperator from "../../ui/seperator";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
+import { features } from "../../../features";
export type FeatureType = {
title: string;
body: string;
- platform?: 'ios' | 'android';
+ platform?: "ios" | "android";
};
const NewFeature = ({ features }: { features: FeatureType[] }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<View
style={{
- alignItems: 'center',
+ alignItems: "center",
paddingHorizontal: 12,
paddingTop: 12
}}
@@ -34,14 +34,14 @@ const NewFeature = ({ features }: { features: FeatureType[] }) => {
<Seperator />
- {features.map(item => (
+ {features.map((item) => (
<View
key={item.title}
style={{
backgroundColor: colors.nav,
padding: 12,
borderRadius: 10,
- width: '100%',
+ width: "100%",
marginBottom: 10
}}
>
@@ -79,7 +79,7 @@ NewFeature.present = () => {
version: APP_VERSION
});
let _features = features?.filter(
- feature => !feature.platform || feature.platform === Platform.OS
+ (feature) => !feature.platform || feature.platform === Platform.OS
);
if (_features.length === 0) return;
presentSheet({
diff --git a/apps/mobile/app/components/sheets/progress/index.tsx b/apps/mobile/app/components/sheets/progress/index.tsx
index 730e2faba..754cdd934 100644
--- a/apps/mobile/app/components/sheets/progress/index.tsx
+++ b/apps/mobile/app/components/sheets/progress/index.tsx
@@ -1,23 +1,23 @@
-import React, { useEffect, useState } from 'react';
-import { View } from 'react-native';
-import { presentSheet } from '../../../services/event-manager';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import useSyncProgress from '../../../hooks/use-sync-progress';
-import { SIZE } from '../../../utils/size';
-import Seperator from '../../ui/seperator';
-import { ProgressBarComponent } from '../../ui/svg/lazy';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
+import React, { useEffect, useState } from "react";
+import { View } from "react-native";
+import { presentSheet } from "../../../services/event-manager";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import useSyncProgress from "../../../hooks/use-sync-progress";
+import { SIZE } from "../../../utils/size";
+import Seperator from "../../ui/seperator";
+import { ProgressBarComponent } from "../../ui/svg/lazy";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
export const Progress = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const { progress } = useSyncProgress();
const [currentProgress, setCurrentProgress] = useState(0.1);
useEffect(() => {
let nextProgress = progress ? progress?.current / progress?.total : 0.1;
- setCurrentProgress(currentProgress => {
+ setCurrentProgress((currentProgress) => {
if (currentProgress > nextProgress) return currentProgress;
return progress ? progress?.current / progress?.total : 0.1;
});
@@ -26,9 +26,9 @@ export const Progress = () => {
return (
<View
style={{
- width: '100%',
- justifyContent: 'center',
- alignItems: 'center',
+ width: "100%",
+ justifyContent: "center",
+ alignItems: "center",
paddingTop: 25,
paddingBottom: 15
}}
@@ -55,8 +55,8 @@ export const Progress = () => {
{progress ? (
<Paragraph color={colors.icon}>
- {progress.type?.slice(0, 1).toUpperCase() + progress.type?.slice(1)}ing{' '}
- {progress?.current}/{progress?.total}
+ {progress.type?.slice(0, 1).toUpperCase() + progress.type?.slice(1)}
+ ing {progress?.current}/{progress?.total}
</Paragraph>
) : null}
</View>
@@ -67,6 +67,6 @@ Progress.present = () => {
presentSheet({
component: <Progress />,
disableClosing: true,
- context: 'sync_progress'
+ context: "sync_progress"
});
};
diff --git a/apps/mobile/app/components/sheets/publish-note/index.js b/apps/mobile/app/components/sheets/publish-note/index.js
index 3e3a8c1b5..d1eec4084 100644
--- a/apps/mobile/app/components/sheets/publish-note/index.js
+++ b/apps/mobile/app/components/sheets/publish-note/index.js
@@ -1,37 +1,45 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import React, { useEffect, useRef, useState } from 'react';
-import { ActivityIndicator, TouchableOpacity, View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { useAttachmentStore } from '../../../stores/use-attachment-store';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { db } from '../../../common/database';
-import { eClosePublishNoteDialog, eOpenPublishNoteDialog } from '../../../utils/events';
-import { openLinkInBrowser } from '../../../utils/functions';
-import { SIZE } from '../../../utils/size';
-import DialogHeader from '../../dialog/dialog-header';
-import { Button } from '../../ui/button';
-import { IconButton } from '../../ui/icon-button';
-import Input from '../../ui/input';
-import Seperator from '../../ui/seperator';
-import SheetWrapper from '../../ui/sheet';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
-import SearchService from '../../../services/search';
+import Clipboard from "@react-native-clipboard/clipboard";
+import React, { useEffect, useRef, useState } from "react";
+import { ActivityIndicator, TouchableOpacity, View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { useAttachmentStore } from "../../../stores/use-attachment-store";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent,
+ ToastEvent
+} from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { db } from "../../../common/database";
+import {
+ eClosePublishNoteDialog,
+ eOpenPublishNoteDialog
+} from "../../../utils/events";
+import { openLinkInBrowser } from "../../../utils/functions";
+import { SIZE } from "../../../utils/size";
+import DialogHeader from "../../dialog/dialog-header";
+import { Button } from "../../ui/button";
+import { IconButton } from "../../ui/icon-button";
+import Input from "../../ui/input";
+import Seperator from "../../ui/seperator";
+import SheetWrapper from "../../ui/sheet";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
+import SearchService from "../../../services/search";
let passwordValue = null;
const PublishNoteSheet = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [visible, setVisible] = useState(false);
const actionSheetRef = useRef();
- const loading = useAttachmentStore(state => state.loading);
+ const loading = useAttachmentStore((state) => state.loading);
const [selfDestruct, setSelfDestruct] = useState(false);
const [isLocked, setIsLocked] = useState(false);
const [note, setNote] = useState(null);
const [publishing, setPublishing] = useState(false);
const publishUrl =
- note && `https://monograph.notesnook.com/${db?.monographs.monograph(note?.id)}`;
+ note &&
+ `https://monograph.notesnook.com/${db?.monographs.monograph(note?.id)}`;
const isPublished = note && db?.monographs.isPublished(note?.id);
const pwdInput = useRef();
@@ -44,7 +52,7 @@ const PublishNoteSheet = () => {
};
}, []);
- const open = item => {
+ const open = (item) => {
setNote(item);
setPublishing(false);
setSelfDestruct(false);
@@ -77,19 +85,19 @@ const PublishNoteSheet = () => {
});
setNote(db.notes.note(note.id)?.data);
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes"
);
}
} catch (e) {
ToastEvent.show({
- heading: 'Could not publish note',
+ heading: "Could not publish note",
message: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
}
@@ -104,19 +112,19 @@ const PublishNoteSheet = () => {
await db.monographs.unpublish(note.id);
setNote(db.notes.note(note.id)?.data);
Navigation.queueRoutesForUpdate(
- 'Notes',
- 'Favorites',
- 'ColoredNotes',
- 'TaggedNotes',
- 'TopicNotes'
+ "Notes",
+ "Favorites",
+ "ColoredNotes",
+ "TaggedNotes",
+ "TopicNotes"
);
}
} catch (e) {
ToastEvent.show({
- heading: 'Could not unpublish note',
+ heading: "Could not unpublish note",
message: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
}
actionSheetRef.current?.hide();
@@ -136,35 +144,38 @@ const PublishNoteSheet = () => {
>
<View
style={{
- width: '100%',
- alignSelf: 'center',
+ width: "100%",
+ alignSelf: "center",
paddingHorizontal: 12
}}
>
<DialogHeader
title={note.title}
paragraph={`Anyone with the link${
- isLocked ? ' and password' : ''
+ isLocked ? " and password" : ""
} of the published note can view it.`}
/>
{publishing ? (
<View
style={{
- justifyContent: 'center',
- alignContent: 'center',
+ justifyContent: "center",
+ alignContent: "center",
height: 150,
- width: '100%'
+ width: "100%"
}}
>
<ActivityIndicator size={25} color={colors.accent} />
<Paragraph
style={{
- textAlign: 'center'
+ textAlign: "center"
}}
>
Please wait...
- {loading && `\nDownloading attachments (${loading?.current / loading?.total})`}
+ {loading &&
+ `\nDownloading attachments (${
+ loading?.current / loading?.total
+ })`}
</Paragraph>
</View>
) : (
@@ -172,8 +183,8 @@ const PublishNoteSheet = () => {
{isPublished && (
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
marginTop: 15,
backgroundColor: colors.nav,
padding: 12,
@@ -182,7 +193,7 @@ const PublishNoteSheet = () => {
>
<View
style={{
- width: '100%',
+ width: "100%",
flexShrink: 1
}}
>
@@ -202,7 +213,8 @@ const PublishNoteSheet = () => {
color: colors.pri
}}
>
- <Icon color={colors.accent} name="open-in-new" /> Open in browser
+ <Icon color={colors.accent} name="open-in-new" /> Open in
+ browser
</Paragraph>
</View>
@@ -210,9 +222,9 @@ const PublishNoteSheet = () => {
onPress={() => {
Clipboard.setString(publishUrl);
ToastEvent.show({
- heading: 'Note publish url copied',
- type: 'success',
- context: 'local'
+ heading: "Note publish url copied",
+ type: "success",
+ context: "local"
});
}}
color={colors.accent}
@@ -230,8 +242,8 @@ const PublishNoteSheet = () => {
}}
activeOpacity={0.9}
style={{
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
marginBottom: 10
}}
>
@@ -242,18 +254,23 @@ const PublishNoteSheet = () => {
}}
color={isLocked ? colors.accent : colors.icon}
size={SIZE.lg}
- name={isLocked ? 'check-circle-outline' : 'checkbox-blank-circle-outline'}
+ name={
+ isLocked
+ ? "check-circle-outline"
+ : "checkbox-blank-circle-outline"
+ }
/>
<View
style={{
- width: '100%',
+ width: "100%",
flexShrink: 1
}}
>
<Heading size={SIZE.md}>Password protection</Heading>
<Paragraph>
- Published note can only be viewed by someone with the password.
+ Published note can only be viewed by someone with the
+ password.
</Paragraph>
</View>
</TouchableOpacity>
@@ -264,8 +281,8 @@ const PublishNoteSheet = () => {
}}
activeOpacity={0.9}
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<IconButton
@@ -274,26 +291,31 @@ const PublishNoteSheet = () => {
}}
color={selfDestruct ? colors.accent : colors.icon}
size={SIZE.lg}
- name={selfDestruct ? 'check-circle-outline' : 'checkbox-blank-circle-outline'}
+ name={
+ selfDestruct
+ ? "check-circle-outline"
+ : "checkbox-blank-circle-outline"
+ }
/>
<View
style={{
- width: '100%',
+ width: "100%",
flexShrink: 1
}}
>
<Heading size={SIZE.md}>Self destruct</Heading>
<Paragraph>
- Published note link will be automatically deleted once it is viewed by someone.
+ Published note link will be automatically deleted once it is
+ viewed by someone.
</Paragraph>
</View>
</TouchableOpacity>
<View
style={{
- width: '100%',
- alignSelf: 'center',
+ width: "100%",
+ alignSelf: "center",
marginTop: 10
}}
>
@@ -301,7 +323,7 @@ const PublishNoteSheet = () => {
<>
<Input
fwdRef={pwdInput}
- onChangeText={value => (passwordValue = value)}
+ onChangeText={(value) => (passwordValue = value)}
blurOnSubmit
secureTextEntry
defaultValue={passwordValue}
@@ -320,7 +342,7 @@ const PublishNoteSheet = () => {
}}
height={50}
type="accent"
- title={isPublished ? 'Update published note' : 'Publish note'}
+ title={isPublished ? "Update published note" : "Publish note"}
/>
{isPublished && (
@@ -344,13 +366,16 @@ const PublishNoteSheet = () => {
color={colors.icon}
size={SIZE.xs}
style={{
- textAlign: 'center',
+ textAlign: "center",
marginTop: 5,
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
onPress={async () => {
try {
- await openLinkInBrowser('https://docs.notesnook.com/monographs/', colors.accent);
+ await openLinkInBrowser(
+ "https://docs.notesnook.com/monographs/",
+ colors.accent
+ );
} catch (e) {}
}}
>
diff --git a/apps/mobile/app/components/sheets/rate-app/index.js b/apps/mobile/app/components/sheets/rate-app/index.js
index c23a190a5..c512bb0d4 100644
--- a/apps/mobile/app/components/sheets/rate-app/index.js
+++ b/apps/mobile/app/components/sheets/rate-app/index.js
@@ -1,16 +1,19 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { Linking, View } from 'react-native';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
-import { clearMessage } from '../../../services/message';
-import SettingsService from '../../../services/settings';
-import { STORE_LINK } from '../../../utils/constants';
-import { eCloseRateDialog, eOpenRateDialog } from '../../../utils/events';
-import { SIZE } from '../../../utils/size';
-import { Button } from '../../ui/button';
-import Seperator from '../../ui/seperator';
-import SheetWrapper from '../../ui/sheet';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
+import React, { useEffect, useRef, useState } from "react";
+import { Linking, View } from "react-native";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../../services/event-manager";
+import { clearMessage } from "../../../services/message";
+import SettingsService from "../../../services/settings";
+import { STORE_LINK } from "../../../utils/constants";
+import { eCloseRateDialog, eOpenRateDialog } from "../../../utils/events";
+import { SIZE } from "../../../utils/size";
+import { Button } from "../../ui/button";
+import Seperator from "../../ui/seperator";
+import SheetWrapper from "../../ui/sheet";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
const RateAppSheet = () => {
const [visible, setVisible] = useState(false);
@@ -59,15 +62,15 @@ const RateAppSheet = () => {
<SheetWrapper centered={false} fwdRef={actionSheetRef} onClose={onClose}>
<View
style={{
- width: '100%',
- alignSelf: 'center',
+ width: "100%",
+ alignSelf: "center",
paddingHorizontal: 12
}}
>
<Heading>Do you enjoy using Notesnook?</Heading>
<Paragraph size={SIZE.md}>
- It took us a year to bring Notesnook to life. Share your experience and suggestions to
- help us improve it.
+ It took us a year to bring Notesnook to life. Share your experience
+ and suggestions to help us improve it.
</Paragraph>
<Seperator half />
@@ -81,12 +84,12 @@ const RateAppSheet = () => {
/>
<View
style={{
- alignItems: 'center',
- justifyContent: 'space-between',
- flexDirection: 'row',
+ alignItems: "center",
+ justifyContent: "space-between",
+ flexDirection: "row",
paddingTop: 12,
- width: '100%',
- alignSelf: 'center'
+ width: "100%",
+ alignSelf: "center"
}}
>
<Button
diff --git a/apps/mobile/app/components/sheets/recovery-key/index.js b/apps/mobile/app/components/sheets/recovery-key/index.js
index 0f328e098..e27362926 100644
--- a/apps/mobile/app/components/sheets/recovery-key/index.js
+++ b/apps/mobile/app/components/sheets/recovery-key/index.js
@@ -1,25 +1,29 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import React, { createRef } from 'react';
-import { Platform, View } from 'react-native';
-import FileViewer from 'react-native-file-viewer';
-import * as ScopedStorage from 'react-native-scoped-storage';
-import Share from 'react-native-share';
+import Clipboard from "@react-native-clipboard/clipboard";
+import React, { createRef } from "react";
+import { Platform, View } from "react-native";
+import FileViewer from "react-native-file-viewer";
+import * as ScopedStorage from "react-native-scoped-storage";
+import Share from "react-native-share";
//import { LOGO_BASE64 } from '../../../assets/images/assets';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
-import { clearMessage } from '../../../services/message';
-import SettingsService from '../../../services/settings';
-import { db } from '../../../common/database';
-import Storage from '../../../common/database/storage';
-import { eOpenRecoveryKeyDialog } from '../../../utils/events';
-import { sanitizeFilename } from '../../../utils/sanitizer';
-import { SIZE } from '../../../utils/size';
-import { sleep } from '../../../utils/time';
-import DialogHeader from '../../dialog/dialog-header';
-import { Button } from '../../ui/button';
-import Seperator from '../../ui/seperator';
-import SheetWrapper from '../../ui/sheet';
-import { QRCode } from '../../ui/svg/lazy';
-import Paragraph from '../../ui/typography/paragraph';
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent,
+ ToastEvent
+} from "../../../services/event-manager";
+import { clearMessage } from "../../../services/message";
+import SettingsService from "../../../services/settings";
+import { db } from "../../../common/database";
+import Storage from "../../../common/database/storage";
+import { eOpenRecoveryKeyDialog } from "../../../utils/events";
+import { sanitizeFilename } from "../../../utils/sanitizer";
+import { SIZE } from "../../../utils/size";
+import { sleep } from "../../../utils/time";
+import DialogHeader from "../../dialog/dialog-header";
+import { Button } from "../../ui/button";
+import Seperator from "../../ui/seperator";
+import SheetWrapper from "../../ui/sheet";
+import { QRCode } from "../../ui/svg/lazy";
+import Paragraph from "../../ui/typography/paragraph";
let RNFetchBlob;
@@ -37,7 +41,7 @@ class RecoveryKeySheet extends React.Component {
this.tapCount = 0;
}
- open = signup => {
+ open = (signup) => {
if (signup) {
this.signup = true;
}
@@ -54,10 +58,10 @@ class RecoveryKeySheet extends React.Component {
close = () => {
if (this.tapCount === 0) {
ToastEvent.show({
- heading: 'Did you save recovery key?',
- message: 'Tap one more time to confirm.',
- type: 'success',
- context: 'local'
+ heading: "Did you save recovery key?",
+ message: "Tap one more time to confirm.",
+ type: "success",
+ context: "local"
});
this.tapCount++;
return;
@@ -89,25 +93,31 @@ class RecoveryKeySheet extends React.Component {
}
saveQRCODE = async () => {
- this.svg.current?.toDataURL(async data => {
+ this.svg.current?.toDataURL(async (data) => {
try {
let path;
- RNFetchBlob = require('rn-fetch-blob').default;
- let fileName = 'nn_' + this.user.email + '_recovery_key_qrcode';
- fileName = sanitizeFilename(fileName, { replacement: '_' });
- fileName = fileName + '.png';
+ RNFetchBlob = require("rn-fetch-blob").default;
+ let fileName = "nn_" + this.user.email + "_recovery_key_qrcode";
+ fileName = sanitizeFilename(fileName, { replacement: "_" });
+ fileName = fileName + ".png";
- if (Platform.OS === 'android') {
- await ScopedStorage.createDocument(fileName, 'image/png', data, 'base64');
+ if (Platform.OS === "android") {
+ await ScopedStorage.createDocument(
+ fileName,
+ "image/png",
+ data,
+ "base64"
+ );
} else {
- path = await Storage.checkAndCreateDir('/');
- await RNFetchBlob.fs.writeFile(path + fileName, data, 'base64');
+ path = await Storage.checkAndCreateDir("/");
+ await RNFetchBlob.fs.writeFile(path + fileName, data, "base64");
}
ToastEvent.show({
- heading: 'Recovery key QR-Code saved',
- message: 'QR-Code image has been saved to Gallery at ' + path + fileName,
- type: 'success',
- context: 'local'
+ heading: "Recovery key QR-Code saved",
+ message:
+ "QR-Code image has been saved to Gallery at " + path + fileName,
+ type: "success",
+ context: "local"
});
} catch (e) {}
});
@@ -116,31 +126,31 @@ class RecoveryKeySheet extends React.Component {
saveToTextFile = async () => {
try {
let path;
- let fileName = 'nn_' + this.user?.email + '_recovery_key';
- fileName = sanitizeFilename(fileName, { replacement: '_' });
- fileName = fileName + '.txt';
+ let fileName = "nn_" + this.user?.email + "_recovery_key";
+ fileName = sanitizeFilename(fileName, { replacement: "_" });
+ fileName = fileName + ".txt";
- RNFetchBlob = require('rn-fetch-blob').default;
- if (Platform.OS === 'android') {
+ RNFetchBlob = require("rn-fetch-blob").default;
+ if (Platform.OS === "android") {
let file = await ScopedStorage.createDocument(
fileName,
- 'text/plain',
+ "text/plain",
this.state.key,
- 'utf8'
+ "utf8"
);
if (!file) return;
path = file.uri;
} else {
- path = await Storage.checkAndCreateDir('/');
- await RNFetchBlob.fs.writeFile(path + fileName, this.state.key, 'utf8');
+ path = await Storage.checkAndCreateDir("/");
+ await RNFetchBlob.fs.writeFile(path + fileName, this.state.key, "utf8");
path = path + fileName;
}
ToastEvent.show({
- heading: 'Recovery key text file saved',
- message: 'Recovery key saved in text file.',
- type: 'success',
- context: 'local'
+ heading: "Recovery key text file saved",
+ message: "Recovery key saved in text file.",
+ type: "success",
+ context: "local"
});
return path;
} catch (e) {
@@ -162,9 +172,9 @@ class RecoveryKeySheet extends React.Component {
let path = await this.saveToTextFile();
if (!path) return;
try {
- if (Platform.OS === 'ios') {
+ if (Platform.OS === "ios") {
Share.open({
- url: 'file:/' + path,
+ url: "file:/" + path,
failOnCancel: false
}).catch(console.log);
} else {
@@ -189,9 +199,9 @@ class RecoveryKeySheet extends React.Component {
>
<View
style={{
- width: '100%',
+ width: "100%",
backgroundColor: colors.bg,
- justifyContent: 'space-between',
+ justifyContent: "space-between",
paddingHorizontal: 12,
borderRadius: 10,
paddingTop: 10
@@ -216,11 +226,11 @@ class RecoveryKeySheet extends React.Component {
numberOfLines={2}
selectable
style={{
- width: '100%',
- maxWidth: '100%',
+ width: "100%",
+ maxWidth: "100%",
paddingRight: 10,
- textAlign: 'center',
- textDecorationLine: 'underline'
+ textAlign: "center",
+ textDecorationLine: "underline"
}}
>
{this.state.key}
@@ -230,12 +240,12 @@ class RecoveryKeySheet extends React.Component {
<View
style={{
- alignSelf: 'center',
+ alignSelf: "center",
marginBottom: 15,
- flexDirection: 'row',
- width: '100%',
- justifyContent: 'center',
- position: 'absolute',
+ flexDirection: "row",
+ width: "100%",
+ justifyContent: "center",
+ position: "absolute",
opacity: 0,
zIndex: -1
}}
@@ -255,9 +265,9 @@ class RecoveryKeySheet extends React.Component {
onPress={() => {
Clipboard.setString(this.state.key);
ToastEvent.show({
- heading: 'Recovery key copied!',
- type: 'success',
- context: 'local'
+ heading: "Recovery key copied!",
+ type: "success",
+ context: "local"
});
}}
icon="content-copy"
@@ -305,10 +315,10 @@ class RecoveryKeySheet extends React.Component {
size={SIZE.sm}
numberOfLines={2}
style={{
- width: '100%',
- maxWidth: '100%',
+ width: "100%",
+ maxWidth: "100%",
marginBottom: 5,
- textAlign: 'center'
+ textAlign: "center"
}}
>
Tap twice to confirm you have saved the recovery key.
diff --git a/apps/mobile/app/components/sheets/restore-data/index.js b/apps/mobile/app/components/sheets/restore-data/index.js
index c46825658..3ab12e354 100644
--- a/apps/mobile/app/components/sheets/restore-data/index.js
+++ b/apps/mobile/app/components/sheets/restore-data/index.js
@@ -1,26 +1,30 @@
-import React, { createRef, useEffect, useState } from 'react';
-import { ActivityIndicator, Platform, View } from 'react-native';
-import DocumentPicker from 'react-native-document-picker';
-import { FlatList } from 'react-native-gesture-handler';
-import * as ScopedStorage from 'react-native-scoped-storage';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { initialize } from '../../../stores';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../../services/event-manager';
-import { db } from '../../../common/database';
-import { MMKV } from '../../../common/database/mmkv';
-import storage from '../../../common/database/storage';
-import { eCloseRestoreDialog, eOpenRestoreDialog } from '../../../utils/events';
-import { SIZE } from '../../../utils/size';
-import { sleep, timeConverter } from '../../../utils/time';
-import { Dialog } from '../../dialog';
-import DialogHeader from '../../dialog/dialog-header';
-import { presentDialog } from '../../dialog/functions';
-import { Toast } from '../../toast';
-import { Button } from '../../ui/button';
-import Seperator from '../../ui/seperator';
-import SheetWrapper from '../../ui/sheet';
-import Paragraph from '../../ui/typography/paragraph';
-import SettingsService from '../../../services/settings';
+import React, { createRef, useEffect, useState } from "react";
+import { ActivityIndicator, Platform, View } from "react-native";
+import DocumentPicker from "react-native-document-picker";
+import { FlatList } from "react-native-gesture-handler";
+import * as ScopedStorage from "react-native-scoped-storage";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { initialize } from "../../../stores";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent,
+ ToastEvent
+} from "../../../services/event-manager";
+import { db } from "../../../common/database";
+import { MMKV } from "../../../common/database/mmkv";
+import storage from "../../../common/database/storage";
+import { eCloseRestoreDialog, eOpenRestoreDialog } from "../../../utils/events";
+import { SIZE } from "../../../utils/size";
+import { sleep, timeConverter } from "../../../utils/time";
+import { Dialog } from "../../dialog";
+import DialogHeader from "../../dialog/dialog-header";
+import { presentDialog } from "../../dialog/functions";
+import { Toast } from "../../toast";
+import { Button } from "../../ui/button";
+import Seperator from "../../ui/seperator";
+import SheetWrapper from "../../ui/sheet";
+import Paragraph from "../../ui/typography/paragraph";
+import SettingsService from "../../../services/settings";
const actionSheetRef = createRef();
let RNFetchBlob;
@@ -55,10 +59,10 @@ const RestoreDataSheet = () => {
const showIsWorking = () => {
ToastEvent.show({
- heading: 'Restoring Backup',
- message: 'Your backup data is being restored. please wait.',
- type: 'error',
- context: 'local'
+ heading: "Restoring Backup",
+ message: "Your backup data is being restored. please wait.",
+ type: "error",
+ context: "local"
});
};
@@ -69,7 +73,11 @@ const RestoreDataSheet = () => {
closeOnTouchBackdrop={!restoring}
onClose={close}
>
- <RestoreDataComponent close={close} restoring={restoring} setRestoring={setRestoring} />
+ <RestoreDataComponent
+ close={close}
+ restoring={restoring}
+ setRestoring={setRestoring}
+ />
<Toast context="local" />
</SheetWrapper>
);
@@ -78,7 +86,7 @@ const RestoreDataSheet = () => {
export default RestoreDataSheet;
const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [files, setFiles] = useState([]);
const [loading, setLoading] = useState(true);
const [backupDirectoryAndroid, setBackupDirectoryAndroid] = useState(false);
@@ -93,33 +101,33 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
}
try {
setRestoring(true);
- let prefix = Platform.OS === 'ios' ? '' : 'file:/';
+ let prefix = Platform.OS === "ios" ? "" : "file:/";
let backup;
- if (Platform.OS === 'android') {
- backup = await ScopedStorage.readFile(item.uri, 'utf8');
+ if (Platform.OS === "android") {
+ backup = await ScopedStorage.readFile(item.uri, "utf8");
} else {
- backup = await RNFetchBlob.fs.readFile(prefix + item.path, 'utf8');
+ backup = await RNFetchBlob.fs.readFile(prefix + item.path, "utf8");
}
backup = JSON.parse(backup);
- console.log('backup encrypted:', backup.data.iv && backup.data.salt);
+ console.log("backup encrypted:", backup.data.iv && backup.data.salt);
if (backup.data.iv && backup.data.salt) {
withPassword(
- async value => {
+ async (value) => {
try {
- console.log('password for backup:', value);
+ console.log("password for backup:", value);
await restoreBackup(backup, value);
close();
setRestoring(false);
return true;
} catch (e) {
backupError(e);
- console.log('return false');
+ console.log("return false");
return false;
}
},
() => {
- console.log('closed');
+ console.log("closed");
setRestoring(false);
}
);
@@ -135,24 +143,24 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
const withPassword = (onsubmit, onclose = () => {}) => {
presentDialog({
- context: 'local',
- title: 'Encrypted backup',
+ context: "local",
+ title: "Encrypted backup",
input: true,
- inputPlaceholder: 'Password',
- paragraph: 'Please enter password of this backup file to restore it',
- positiveText: 'Restore',
+ inputPlaceholder: "Password",
+ paragraph: "Please enter password of this backup file to restore it",
+ positiveText: "Restore",
secureTextEntry: true,
onClose: onclose,
- negativeText: 'Cancel',
- positivePress: async password => {
+ negativeText: "Cancel",
+ positivePress: async (password) => {
try {
return await onsubmit(password);
} catch (e) {
ToastEvent.show({
- heading: 'Failed to backup data',
+ heading: "Failed to backup data",
message: e.message,
- type: 'error',
- context: 'global'
+ type: "error",
+ context: "global"
});
return false;
}
@@ -163,7 +171,7 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
const checkBackups = async () => {
try {
let files = [];
- if (Platform.OS === 'android') {
+ if (Platform.OS === "android") {
let backupDirectory = SettingsService.get().backupDirectoryAndroid;
if (backupDirectory) {
setBackupDirectoryAndroid(backupDirectory);
@@ -173,8 +181,8 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
return;
}
} else {
- RNFetchBlob = require('rn-fetch-blob').default;
- let path = await storage.checkAndCreateDir('/backups/');
+ RNFetchBlob = require("rn-fetch-blob").default;
+ let path = await storage.checkAndCreateDir("/backups/");
files = await RNFetchBlob.fs.lstat(path);
}
files = files.sort(function (a, b) {
@@ -196,25 +204,25 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
<View
style={{
minHeight: 50,
- justifyContent: 'space-between',
- alignItems: 'center',
- width: '100%',
+ justifyContent: "space-between",
+ alignItems: "center",
+ width: "100%",
borderRadius: 0,
- flexDirection: 'row',
+ flexDirection: "row",
borderBottomWidth: 0.5,
borderBottomColor: colors.nav
}}
>
<View
style={{
- maxWidth: '75%'
+ maxWidth: "75%"
}}
>
- <Paragraph size={SIZE.sm} style={{ width: '100%', maxWidth: '100%' }}>
+ <Paragraph size={SIZE.sm} style={{ width: "100%", maxWidth: "100%" }}>
{timeConverter(item?.lastModified * 1)}
</Paragraph>
<Paragraph size={SIZE.xs}>
- {(item.filename || item.name).replace('.nnbackup', '')}
+ {(item.filename || item.name).replace(".nnbackup", "")}
</Paragraph>
</View>
<Button
@@ -232,47 +240,50 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
);
const restoreBackup = async (backup, password) => {
- console.log(password, 'password');
+ console.log(password, "password");
await db.backup.import(backup, password);
setRestoring(false);
initialize();
ToastEvent.show({
- heading: 'Backup restored successfully.',
- type: 'success',
- context: 'global'
+ heading: "Backup restored successfully.",
+ type: "success",
+ context: "global"
});
};
- const backupError = e => {
+ const backupError = (e) => {
ToastEvent.show({
- heading: 'Restore failed',
+ heading: "Restore failed",
message:
e.message ||
- 'The selected backup data file is invalid. You must select a *.nnbackup file to restore.',
- type: 'error',
- context: 'local'
+ "The selected backup data file is invalid. You must select a *.nnbackup file to restore.",
+ type: "error",
+ context: "local"
});
};
const button = {
- title: 'Restore from files',
+ title: "Restore from files",
onPress: () => {
if (restoring) {
return;
}
DocumentPicker.pickSingle()
- .then(r => {
+ .then((r) => {
setRestoring(true);
console.log(r.uri);
fetch(r.uri)
- .then(async r => {
+ .then(async (r) => {
try {
let backup = await r.json();
- console.log('backup encrypted:', backup.data.iv && backup.data.salt);
+ console.log(
+ "backup encrypted:",
+ backup.data.iv && backup.data.salt
+ );
if (backup.data.iv && backup.data.salt) {
withPassword(
- async value => {
+ async (value) => {
try {
await restoreBackup(backup, value);
setRestoring(false);
@@ -285,7 +296,7 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
}
},
() => {
- console.log('closed');
+ console.log("closed");
setRestoring(false);
}
);
@@ -310,18 +321,20 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
<Dialog context="local" />
<View
style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
+ flexDirection: "row",
+ justifyContent: "space-between",
paddingHorizontal: 8,
paddingRight: 8,
- alignItems: 'center',
+ alignItems: "center",
paddingTop: restoring ? 8 : 0
}}
>
<DialogHeader
title="Backups"
paragraph={`All the backups are stored in ${
- Platform.OS === 'ios' ? 'File Manager/Notesnook/Backups' : 'selected backups folder.'
+ Platform.OS === "ios"
+ ? "File Manager/Notesnook/Backups"
+ : "selected backups folder."
}`}
button={button}
/>
@@ -337,8 +350,8 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
loading ? (
<View
style={{
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
height: 100
}}
>
@@ -347,23 +360,25 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
) : (
<View
style={{
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
height: 100
}}
>
- {Platform.OS === 'android' && !backupDirectoryAndroid ? (
+ {Platform.OS === "android" && !backupDirectoryAndroid ? (
<>
<Button
title="Select backups folder"
icon="folder"
onPress={async () => {
- let folder = await ScopedStorage.openDocumentTree(true);
+ let folder = await ScopedStorage.openDocumentTree(
+ true
+ );
let subfolder;
- if (folder.name !== 'Notesnook backups') {
+ if (folder.name !== "Notesnook backups") {
subfolder = await ScopedStorage.createDirectory(
folder.uri,
- 'Notesnook backups'
+ "Notesnook backups"
);
} else {
subfolder = folder;
@@ -386,14 +401,15 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
<Paragraph
style={{
- textAlign: 'center',
+ textAlign: "center",
marginTop: 5
}}
size={SIZE.xs}
textBreakStrategy="balanced"
color={colors.icon}
>
- Select the folder that includes your backup files to list them here.
+ Select the folder that includes your backup files to
+ list them here.
</Paragraph>
</>
) : (
@@ -404,17 +420,19 @@ const RestoreDataComponent = ({ close, setRestoring, restoring }) => {
) : (
<View
style={{
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
height: 200
}}
>
<ActivityIndicator color={colors.accent} />
- <Paragraph color={colors.icon}>Restoring backup. Please wait.</Paragraph>
+ <Paragraph color={colors.icon}>
+ Restoring backup. Please wait.
+ </Paragraph>
</View>
)
}
- keyExtractor={item => item.name || item.filename}
+ keyExtractor={(item) => item.name || item.filename}
style={{
paddingHorizontal: 12
}}
diff --git a/apps/mobile/app/components/sheets/sort/index.js b/apps/mobile/app/components/sheets/sort/index.js
index 22aafd748..2bf140c40 100644
--- a/apps/mobile/app/components/sheets/sort/index.js
+++ b/apps/mobile/app/components/sheets/sort/index.js
@@ -1,29 +1,31 @@
-import React, { useState } from 'react';
-import { View } from 'react-native';
-import { eSendEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { GROUP, SORT } from '../../../utils/constants';
-import { db } from '../../../common/database';
-import { refreshNotesPage } from '../../../utils/events';
-import layoutmanager from '../../../utils/layout-manager';
-import { SIZE } from '../../../utils/size';
-import { Button } from '../../ui/button';
-import Seperator from '../../ui/seperator';
-import Heading from '../../ui/typography/heading';
+import React, { useState } from "react";
+import { View } from "react-native";
+import { eSendEvent } from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { GROUP, SORT } from "../../../utils/constants";
+import { db } from "../../../common/database";
+import { refreshNotesPage } from "../../../utils/events";
+import layoutmanager from "../../../utils/layout-manager";
+import { SIZE } from "../../../utils/size";
+import { Button } from "../../ui/button";
+import Seperator from "../../ui/seperator";
+import Heading from "../../ui/typography/heading";
const Sort = ({ type, screen }) => {
- const colors = useThemeStore(state => state.colors);
- const [groupOptions, setGroupOptions] = useState(db.settings.getGroupOptions(type));
+ const colors = useThemeStore((state) => state.colors);
+ const [groupOptions, setGroupOptions] = useState(
+ db.settings.getGroupOptions(type)
+ );
- const updateGroupOptions = async _groupOptions => {
+ const updateGroupOptions = async (_groupOptions) => {
await db.settings.setGroupOptions(type, _groupOptions);
layoutmanager.withSpringAnimation(600);
setGroupOptions(_groupOptions);
setTimeout(() => {
Navigation.queueRoutesForUpdate(screen);
- eSendEvent('groupOptionsUpdate');
+ eSendEvent("groupOptionsUpdate");
eSendEvent(refreshNotesPage);
}, 1);
};
@@ -31,7 +33,7 @@ const Sort = ({ type, screen }) => {
const setOrderBy = async () => {
let _groupOptions = {
...groupOptions,
- sortDirection: groupOptions.sortDirection === 'asc' ? 'desc' : 'asc'
+ sortDirection: groupOptions.sortDirection === "asc" ? "desc" : "asc"
};
await updateGroupOptions(_groupOptions);
};
@@ -39,23 +41,23 @@ const Sort = ({ type, screen }) => {
return (
<View
style={{
- width: '100%',
+ width: "100%",
backgroundColor: colors.bg,
- justifyContent: 'space-between'
+ justifyContent: "space-between"
}}
>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'space-between',
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "space-between",
paddingHorizontal: 12
}}
>
<Heading
size={SIZE.xl}
style={{
- alignSelf: 'center'
+ alignSelf: "center"
}}
>
Sort by
@@ -63,15 +65,21 @@ const Sort = ({ type, screen }) => {
<Button
title={
- groupOptions.sortDirection === 'asc'
- ? groupOptions.groupBy === 'abc' || groupOptions.sortBy === 'title'
- ? 'A - Z'
- : 'Old - New'
- : groupOptions.groupBy === 'abc' || groupOptions.sortBy === 'title'
- ? 'Z - A'
- : 'New - Old'
+ groupOptions.sortDirection === "asc"
+ ? groupOptions.groupBy === "abc" ||
+ groupOptions.sortBy === "title"
+ ? "A - Z"
+ : "Old - New"
+ : groupOptions.groupBy === "abc" ||
+ groupOptions.sortBy === "title"
+ ? "Z - A"
+ : "New - Old"
+ }
+ icon={
+ groupOptions.sortDirection === "asc"
+ ? "sort-ascending"
+ : "sort-descending"
}
- icon={groupOptions.sortDirection === 'asc' ? 'sort-ascending' : 'sort-descending'}
height={25}
iconPosition="right"
fontSize={SIZE.sm - 1}
@@ -91,50 +99,51 @@ const Sort = ({ type, screen }) => {
<View
style={{
- flexDirection: 'row',
- justifyContent: 'flex-start',
- flexWrap: 'wrap',
+ flexDirection: "row",
+ justifyContent: "flex-start",
+ flexWrap: "wrap",
borderBottomWidth: 1,
borderBottomColor: colors.nav,
marginBottom: 12,
paddingHorizontal: 12,
paddingBottom: 12,
- alignItems: 'center'
+ alignItems: "center"
}}
>
- {groupOptions.groupBy === 'abc' ? (
+ {groupOptions.groupBy === "abc" ? (
<Button
- type={'grayBg'}
+ type={"grayBg"}
title="Title"
height={40}
iconPosition="left"
- icon={'check'}
+ icon={"check"}
buttonType={{ text: colors.accent }}
fontSize={SIZE.sm}
iconSize={SIZE.md}
/>
) : (
Object.keys(SORT).map((item, index) =>
- item === 'title' && groupOptions.groupBy !== 'none' ? null : (
+ item === "title" && groupOptions.groupBy !== "none" ? null : (
<Button
key={item}
- type={groupOptions.sortBy === item ? 'grayBg' : 'gray'}
+ type={groupOptions.sortBy === item ? "grayBg" : "gray"}
title={SORT[item]}
height={40}
iconPosition="left"
- icon={groupOptions.sortBy === item ? 'check' : null}
+ icon={groupOptions.sortBy === item ? "check" : null}
style={{
marginRight: 10,
paddingHorizontal: 8
}}
buttonType={{
- text: groupOptions.sortBy === item ? colors.accent : colors.icon
+ text:
+ groupOptions.sortBy === item ? colors.accent : colors.icon
}}
fontSize={SIZE.sm}
onPress={async () => {
let _groupOptions = {
...groupOptions,
- sortBy: type === 'trash' ? 'dateDeleted' : item
+ sortBy: type === "trash" ? "dateDeleted" : item
};
await updateGroupOptions(_groupOptions);
}}
@@ -159,18 +168,21 @@ const Sort = ({ type, screen }) => {
<View
style={{
borderRadius: 0,
- flexDirection: 'row',
- flexWrap: 'wrap',
+ flexDirection: "row",
+ flexWrap: "wrap",
paddingHorizontal: 12
}}
>
{Object.keys(GROUP).map((item, index) => (
<Button
key={item}
- testID={'btn-' + item}
- type={groupOptions.groupBy === GROUP[item] ? 'grayBg' : 'gray'}
+ testID={"btn-" + item}
+ type={groupOptions.groupBy === GROUP[item] ? "grayBg" : "gray"}
buttonType={{
- text: groupOptions.groupBy === GROUP[item] ? colors.accent : colors.icon
+ text:
+ groupOptions.groupBy === GROUP[item]
+ ? colors.accent
+ : colors.icon
}}
onPress={async () => {
let _groupOptions = {
@@ -178,19 +190,19 @@ const Sort = ({ type, screen }) => {
groupBy: GROUP[item]
};
- if (item === 'abc') {
- _groupOptions.sortBy = 'title';
- _groupOptions.sortDirection = 'asc';
+ if (item === "abc") {
+ _groupOptions.sortBy = "title";
+ _groupOptions.sortDirection = "asc";
} else {
- if (groupOptions.sortBy === 'title') {
- _groupOptions.sortBy = 'dateEdited';
- _groupOptions.sortDirection = 'desc';
+ if (groupOptions.sortBy === "title") {
+ _groupOptions.sortBy = "dateEdited";
+ _groupOptions.sortDirection = "desc";
}
}
updateGroupOptions(_groupOptions);
}}
height={40}
- icon={groupOptions.groupBy === GROUP[item] ? 'check' : null}
+ icon={groupOptions.groupBy === GROUP[item] ? "check" : null}
title={item.slice(0, 1).toUpperCase() + item.slice(1, item.length)}
style={{
paddingHorizontal: 8,
diff --git a/apps/mobile/app/components/sheets/update/index.js b/apps/mobile/app/components/sheets/update/index.js
index 83bb81112..28a5942ec 100644
--- a/apps/mobile/app/components/sheets/update/index.js
+++ b/apps/mobile/app/components/sheets/update/index.js
@@ -1,35 +1,35 @@
-import React, { useEffect, useState } from 'react';
-import { ActivityIndicator, Linking, View } from 'react-native';
-import { ScrollView } from 'react-native-gesture-handler';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { STORE_LINK } from '../../../utils/constants';
-import { SIZE } from '../../../utils/size';
-import { Button } from '../../ui/button';
-import { SvgView } from '../../ui/svg';
-import Seperator from '../../ui/seperator';
-import Heading from '../../ui/typography/heading';
-import Paragraph from '../../ui/typography/paragraph';
-import Config from 'react-native-config';
-import deviceInfoModule from 'react-native-device-info';
-import { checkVersion } from 'react-native-check-version';
-import { ProgressBarComponent } from '../../ui/svg/lazy';
+import React, { useEffect, useState } from "react";
+import { ActivityIndicator, Linking, View } from "react-native";
+import { ScrollView } from "react-native-gesture-handler";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { STORE_LINK } from "../../../utils/constants";
+import { SIZE } from "../../../utils/size";
+import { Button } from "../../ui/button";
+import { SvgView } from "../../ui/svg";
+import Seperator from "../../ui/seperator";
+import Heading from "../../ui/typography/heading";
+import Paragraph from "../../ui/typography/paragraph";
+import Config from "react-native-config";
+import deviceInfoModule from "react-native-device-info";
+import { checkVersion } from "react-native-check-version";
+import { ProgressBarComponent } from "../../ui/svg/lazy";
-const UPDATE_SVG = color =>
+const UPDATE_SVG = (color) =>
`<svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="774" height="669.5" viewBox="0 0 774 669.5" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M938.2145,322.3829C936.73266,207.5841,878.16775,115.25,806.13079,115.25c-43.29082,0-81.71777,33.346-105.81477,84.87331l28.33157,71.08654-39.15446-43.81576c-9.876,29.64743-15.48115,63.49569-15.48115,99.44475a324.20917,324.20917,0,0,0,9.98686,80.80891l75.92761-12.24058-67.9507,37.99628c22.13728,60.69069,62.59851,102.1414,109.23586,104.87608l-8.988,244.5184,27.81449.99338-5.94527-245.75716c66.41162-6.32443,119.60967-91.20375,123.8712-197.42794l-45.89372-25.66252Z" transform="translate(-213 -115.25)" fill="#f0f0f0"/><rect x="157.51532" y="354.40187" width="6.60151" height="49.25266" fill="${color}"/><polygon points="187.815 376.276 182.98 380.779 160.823 356.936 138.658 380.779 133.823 376.276 160.823 347.243 187.815 376.276" fill="${color}"/><path d="M371.9876,543.6602a52.8121,52.8121,0,1,1,52.8121-52.81209A52.87183,52.87183,0,0,1,371.9876,543.6602Zm0-99.02268a46.21059,46.21059,0,1,0,46.21058,46.21059A46.26275,46.26275,0,0,0,371.9876,444.63752Z" transform="translate(-213 -115.25)" fill="${color}"/><rect x="212.75248" y="253.9314" width="3.63974" height="27.15545" fill="#e4e4e4"/><polygon points="229.458 265.992 226.793 268.475 214.576 255.328 202.356 268.475 199.69 265.992 214.576 249.984 229.458 265.992" fill="#e4e4e4"/><path d="M426.56422,409.9859a29.118,29.118,0,1,1,29.118-29.118A29.15089,29.15089,0,0,1,426.56422,409.9859Zm0-54.59616A25.47821,25.47821,0,1,0,452.04243,380.868,25.507,25.507,0,0,0,426.56422,355.38974Z" transform="translate(-213 -115.25)" fill="#e4e4e4"/><rect x="99.52274" y="186.73872" width="3.63974" height="27.15545" fill="#e4e4e4"/><polygon points="116.229 198.799 113.563 201.282 101.346 188.136 89.126 201.282 86.46 198.799 101.346 182.792 116.229 198.799" fill="#e4e4e4"/><path d="M313.33448,342.79321a29.118,29.118,0,1,1,29.118-29.118A29.15088,29.15088,0,0,1,313.33448,342.79321Zm0-54.59615a25.47821,25.47821,0,1,0,25.47821,25.4782A25.507,25.507,0,0,0,313.33448,288.19706Z" transform="translate(-213 -115.25)" fill="#e4e4e4"/><path d="M518.7325,635.91942a8.22484,8.22484,0,0,1,.958-12.302,9.56322,9.56322,0,0,1,1.26081-.83521l-6.99347-30.13439,16.26512,5.84042,4.14749,27.72073a8.21849,8.21849,0,0,1-2.21462,10.58849A10.12952,10.12952,0,0,1,518.7325,635.91942Z" transform="translate(-213 -115.25)" fill="#ffb8b8"/><path d="M516.88531,612.40706l-.08727-.29605c-8.79267-29.805-17.88169-60.6154-28.97824-94.16236l-.0728-.21977.2448-.13088c6.18493-3.30762,15.48114-3.08736,21.62358.51183,5.68293,3.33,8.55569,9.77159,7.0024,15.68347l8.09328,38.67327c3.29039,12.64158,6.69574,25.72668,9.95036,38.62892l.09229.36576-.504.0295c-5.92592.34536-12.04821.70254-16.95322.89973Z" transform="translate(-213 -115.25)" fill="#ccc"/><polygon points="229.16 657.57 217.627 657.57 212.138 616.801 229.16 616.801 229.16 657.57" fill="#ffb8b8"/><path d="M445.10175,783.06559H407.9141v-.43107c0-7.31472,6.49345-13.26551,14.47493-13.26551h22.71272Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><polygon points="337.837 648.851 326.848 652.06 308.113 614.743 324.331 610.006 337.837 648.851" fill="#ffb8b8"/><path d="M521.60173,783.39141l-.14262-.41086c-2.42325-6.96953,1.79234-14.4459,9.39693-16.66692l21.64062-6.31955,4.53736,13.05Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><ellipse cx="279.46347" cy="354.21043" rx="23.10522" ry="21.17504" fill="#ffb8b8"/><path d="M502.83713,465.536c.13132-8.54065-3.76885-16.99907-9.79916-21.25171a16.77762,16.77762,0,0,0-19.87954.322c-5.937,4.44645-9.65428,13.02823-9.33974,21.56167C477.12124,466.20257,490.42379,466.23726,502.83713,465.536Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M448.74454,759.69687l-.46255-.04125c-10.03358-.90255-20.40891-1.83457-30.21419-1.9415l-.5333-.00589.07281-.48411c2.32311-15.42,3.30793-31.45044,4.26037-46.9538.9405-15.308,1.91269-31.13682,4.17769-46.17039.95818-4.0257,1.892-8.00342,2.82264-11.96682,7.70037-32.79837,14.97378-63.77816,29.98728-94.44433l.14194-.28963.34381.03789c14.08679,1.56221,27.62283,6.27241,38.11391,13.26256l.20326.13513-.00988.23027a131.25944,131.25944,0,0,0-.10174,14.17269,44.82523,44.82523,0,0,1,7.48241,42.489c4.13084,12.65215,8.40154,25.73075,12.75907,38.63212,10.5818,26.587,21.53153,54.10056,32.75594,81.99045l.1842.45717-.51791.11114c-8.07587,1.73775-16.40668,3.52938-24.62518,4.22482l-.31028.0261-.14745-.25174a587.30717,587.30717,0,0,1-50.88262-112.12662c-2.80473,7.83882-6.84508,14.91443-10.75934,21.76819a157.11556,157.11556,0,0,0-9.86087,19.31354c-1.73239,13.0365-2.192,27.16078-2.63591,40.81947-.42007,12.91442-.81671,25.11236-2.19312,36.582Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M484.57528,444.67592c10.01507-1.97751,21.093-.09617,28.95819,6.09651s11.85919,16.9058,8.62805,26.09364-14.20114,15.65236-24.12,13.27969c2.84131-7.33881-.35623-16.34918-7.302-20.57639C482.50242,464.55626,480.23475,452.58775,484.57528,444.67592Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M496.73471,571.62025l-.36633-.15281c-12.77629-5.34207-25.30408-9.441-37.04181-13.18089l-.35989-.07114-.00092-.95644.23358.07451c.04915-.09935.1045-.21217.16008-.32456.16031-.325.26963-.54642.36264-.69292l-.00252-.00126c.97862-1.82742,1.75651-3.59337,2.50868-5.30123.77628-1.76259,1.5776-3.58243,2.61295-5.50793a15.68833,15.68833,0,0,1-4.02289-17.95719c2.593-5.63211,9.20424-10.01859,16.15083-10.74644,2.54543-6.42185,8.21712-19.91552,8.21712-19.91552s11.92674-.30015,16.72316-.85793l.08062-.00926.07923.016c10.4711,2.10273,19.213,11.1834,21.25846,22.08265,1.72665,9.199-.89525,19.721-7.38227,29.62807A128.7532,128.7532,0,0,1,504.93,561.61682c-2.92186,3.34837-5.68157,6.51067-7.97367,9.69571Z" transform="translate(-213 -115.25)" fill="#ccc"/><path d="M519.3919,459.10521v0Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M519.861,457.22412c-7.01076-.95907-12.51527-7.52688-11.71835-13.982s7.76344-11.72977,14.83079-11.22907,13.06654,6.694,12.77147,13.18459S528.81221,458.44864,519.861,457.22412Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M518.76646,453.03852c-7.01067-.95906-12.51516-7.52688-11.71821-13.98194.54524-4.41578,3.9788-8.27657,8.35539-10.11667-5.65378,1.13408-10.51956,5.64916-11.17757,10.97881-.79695,6.45506,4.70754,13.02288,11.71821,13.98195a14.465,14.465,0,0,0,7.6875-.98538A14.866,14.866,0,0,1,518.76646,453.03852Z" transform="translate(-213 -115.25)" fill="#2f2e41"/><path d="M382.77632,566.82181a9.99626,9.99626,0,0,1,12.97554-3.271,9.61149,9.61149,0,0,1,1.27935.81118l28.67233-16.08336-.58936,16.00057-27.13738,12.82a10.15042,10.15042,0,0,1-11.63139,1.61428A8.34216,8.34216,0,0,1,382.77632,566.82181Z" transform="translate(-213 -115.25)" fill="#ffb8b8"/><path d="M406.35053,557.3917l.2755-.17406c27.73394-17.52829,56.40359-35.64765,87.2197-56.41349l.20185-.13613.21621.16792c5.46363,4.24233,8.33439,12.34854,6.67808,18.85539-1.5324,6.02009-7.20243,10.64869-13.80215,11.27624L450.049,550.84631c-11.90943,7.05521-24.23685,14.35751-36.42636,21.46865l-.34555.20162-.19828-.42571c-2.32974-5.0055-4.73707-10.17674-6.57422-14.34943Z" transform="translate(-213 -115.25)" fill="#ccc"/><path d="M986,784.75H214a1,1,0,0,1,0-2H986a1,1,0,0,1,0,2Z" transform="translate(-213 -115.25)" fill="#cacaca"/></svg>`;
export const Update = ({ version: appVersion, fwdRef }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [version, setVersion] = useState(appVersion);
let notes = version?.notes
- ? version.notes.replace('Thank you for using Notesnook!', '').split('- ')
- : ['Bug fixes and performance improvements'];
- notes = notes?.map(n => n.replace(/\n/g, ''));
- const isGithubRelease = Config.GITHUB_RELEASE === 'true';
+ ? version.notes.replace("Thank you for using Notesnook!", "").split("- ")
+ : ["Bug fixes and performance improvements"];
+ notes = notes?.map((n) => n.replace(/\n/g, ""));
+ const isGithubRelease = Config.GITHUB_RELEASE === "true";
const getSupportedAbi = () => {
let abi = deviceInfoModule.supportedAbisSync();
- let armv8a = abi.find(a => a === 'arm64-v8a');
- let armv7 = abi.find(a => a === 'armeabi-v7a');
+ let armv8a = abi.find((a) => a === "arm64-v8a");
+ let armv7 = abi.find((a) => a === "armeabi-v7a");
return armv8a || armv7 || abi[0];
};
@@ -49,7 +49,7 @@ export const Update = ({ version: appVersion, fwdRef }) => {
if (!version) {
(async () => {
try {
- console.log('checking for new version');
+ console.log("checking for new version");
let v = await checkVersion();
setVersion(v);
} catch (e) {
@@ -64,11 +64,11 @@ export const Update = ({ version: appVersion, fwdRef }) => {
return (
<View
style={{
- alignSelf: 'center',
- alignItems: 'center',
- width: '100%',
+ alignSelf: "center",
+ alignItems: "center",
+ width: "100%",
paddingHorizontal: 12,
- maxHeight: '97%'
+ maxHeight: "97%"
}}
>
{!version || !version?.needsUpdate ? (
@@ -76,8 +76,8 @@ export const Update = ({ version: appVersion, fwdRef }) => {
<View
style={{
paddingVertical: 60,
- justifyContent: 'center',
- alignItems: 'center'
+ justifyContent: "center",
+ alignItems: "center"
}}
>
{!version ? (
@@ -108,10 +108,10 @@ export const Update = ({ version: appVersion, fwdRef }) => {
<>
<View
style={{
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- width: '100%',
+ flexDirection: "row",
+ alignItems: "flex-end",
+ justifyContent: "space-between",
+ width: "100%",
backgroundColor: colors.nav,
borderRadius: 10,
padding: 12
@@ -120,7 +120,8 @@ export const Update = ({ version: appVersion, fwdRef }) => {
<View>
<Heading>Update available</Heading>
<Paragraph>
- v{version.version} has been released {isGithubRelease ? 'on Github' : ''}
+ v{version.version} has been released{" "}
+ {isGithubRelease ? "on Github" : ""}
</Paragraph>
</View>
@@ -134,11 +135,11 @@ export const Update = ({ version: appVersion, fwdRef }) => {
fwdRef?.current?.handleChildScrollEnd();
}}
style={{
- width: '100%'
+ width: "100%"
}}
>
<Heading size={SIZE.md}>Release notes:</Heading>
- {notes.map(item => (
+ {notes.map((item) => (
<Paragraph
key={item}
color={colors.icon}
@@ -154,11 +155,13 @@ export const Update = ({ version: appVersion, fwdRef }) => {
<Button
title={isGithubRelease ? `Download update` : `Update now`}
onPress={() => {
- Linking.openURL(isGithubRelease ? GITHUB_URL : STORE_LINK).catch(console.log);
+ Linking.openURL(isGithubRelease ? GITHUB_URL : STORE_LINK).catch(
+ console.log
+ );
}}
type="accent"
style={{
- width: '100%'
+ width: "100%"
}}
/>
@@ -166,7 +169,7 @@ export const Update = ({ version: appVersion, fwdRef }) => {
size={12}
color={colors.icon}
style={{
- textDecorationLine: 'underline',
+ textDecorationLine: "underline",
marginTop: 10
}}
onPress={() => {
diff --git a/apps/mobile/app/components/side-menu/color-section.js b/apps/mobile/app/components/side-menu/color-section.js
index 74f02d094..7ea14c09a 100644
--- a/apps/mobile/app/components/side-menu/color-section.js
+++ b/apps/mobile/app/components/side-menu/color-section.js
@@ -1,24 +1,24 @@
-import React, { useEffect, useState } from 'react';
-import { View } from 'react-native';
-import Navigation from '../../services/navigation';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useMenuStore } from '../../stores/use-menu-store';
-import { useNoteStore } from '../../stores/use-notes-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { COLORS_NOTE } from '../../utils/color-scheme';
-import { db } from '../../common/database';
-import { normalize, SIZE } from '../../utils/size';
-import { presentDialog } from '../dialog/functions';
-import { PressableButton } from '../ui/pressable';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { ColoredNotes } from '../../screens/notes/colored';
+import React, { useEffect, useState } from "react";
+import { View } from "react-native";
+import Navigation from "../../services/navigation";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useMenuStore } from "../../stores/use-menu-store";
+import { useNoteStore } from "../../stores/use-notes-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { COLORS_NOTE } from "../../utils/color-scheme";
+import { db } from "../../common/database";
+import { normalize, SIZE } from "../../utils/size";
+import { presentDialog } from "../dialog/functions";
+import { PressableButton } from "../ui/pressable";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { ColoredNotes } from "../../screens/notes/colored";
export const ColorSection = React.memo(
() => {
- const colorNotes = useMenuStore(state => state.colorNotes);
- const loading = useNoteStore(state => state.loading);
- const setColorNotes = useMenuStore(state => state.setColorNotes);
+ const colorNotes = useMenuStore((state) => state.colorNotes);
+ const loading = useNoteStore((state) => state.loading);
+ const setColorNotes = useMenuStore((state) => state.setColorNotes);
useEffect(() => {
if (!loading) {
@@ -28,7 +28,9 @@ export const ColorSection = React.memo(
return colorNotes.map((item, index) => {
let alias = db.colors.alias(item.id);
- return <ColorItem key={item.id} alias={alias} item={item} index={index} />;
+ return (
+ <ColorItem key={item.id} alias={alias} item={item} index={index} />
+ );
});
},
() => true
@@ -36,12 +38,12 @@ export const ColorSection = React.memo(
const ColorItem = React.memo(
({ item, index, alias }) => {
- const colors = useThemeStore(state => state.colors);
- const setColorNotes = useMenuStore(state => state.setColorNotes);
+ const colors = useThemeStore((state) => state.colors);
+ const setColorNotes = useMenuStore((state) => state.setColorNotes);
const [headerTextState, setHeaderTextState] = useState(null);
- alias = db.colors.alias(item.id) || '';
+ alias = db.colors.alias(item.id) || "";
- const onHeaderStateChange = state => {
+ const onHeaderStateChange = (state) => {
setTimeout(() => {
let id = state.currentScreen?.id;
if (id === item.id) {
@@ -61,7 +63,7 @@ const ColorItem = React.memo(
};
}, [headerTextState]);
- const onPress = item => {
+ const onPress = (item) => {
ColoredNotes.navigate(item, false);
setImmediate(() => {
@@ -71,52 +73,54 @@ const ColorItem = React.memo(
const onLongPress = () => {
presentDialog({
- title: 'Rename color',
+ title: "Rename color",
input: true,
- inputPlaceholder: 'Enter name for this color',
+ inputPlaceholder: "Enter name for this color",
defaultValue: alias,
- paragraph: 'You are renaming the color ' + item.title,
- positivePress: async value => {
+ paragraph: "You are renaming the color " + item.title,
+ positivePress: async (value) => {
if (!value || value.trim().length === 0) return;
await db.colors.rename(item.id, value);
setColorNotes();
- console.log('color updated');
+ console.log("color updated");
},
- positiveText: 'Rename'
+ positiveText: "Rename"
});
};
return (
<PressableButton
- customColor={headerTextState?.id === item.id ? 'rgba(0,0,0,0.04)' : 'transparent'}
+ customColor={
+ headerTextState?.id === item.id ? "rgba(0,0,0,0.04)" : "transparent"
+ }
onLongPress={onLongPress}
customSelectedColor={COLORS_NOTE[item.title.toLowerCase()]}
customAlpha={!colors.night ? -0.02 : 0.02}
customOpacity={0.12}
onPress={() => onPress(item)}
customStyle={{
- width: '100%',
- alignSelf: 'center',
+ width: "100%",
+ alignSelf: "center",
borderRadius: 5,
- flexDirection: 'row',
+ flexDirection: "row",
paddingHorizontal: 8,
- justifyContent: 'space-between',
- alignItems: 'center',
+ justifyContent: "space-between",
+ alignItems: "center",
height: normalize(50),
marginBottom: 5
}}
>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<View
style={{
width: 30,
- justifyContent: 'center',
- alignItems: 'flex-start'
+ justifyContent: "center",
+ alignItems: "flex-start"
}}
>
<View
@@ -125,7 +129,7 @@ const ColorItem = React.memo(
height: SIZE.lg - 2,
backgroundColor: COLORS_NOTE[item.title.toLowerCase()],
borderRadius: 100,
- justifyContent: 'center',
+ justifyContent: "center",
marginRight: 10
}}
/>
diff --git a/apps/mobile/app/components/side-menu/index.js b/apps/mobile/app/components/side-menu/index.js
index 82f0e33c7..438ad00cb 100644
--- a/apps/mobile/app/components/side-menu/index.js
+++ b/apps/mobile/app/components/side-menu/index.js
@@ -1,61 +1,65 @@
-import React, { useCallback } from 'react';
-import { FlatList, View } from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { notesnook } from '../../../e2e/test.ids';
-import Settings from '../../screens/settings';
-import { DDS } from '../../services/device-detection';
-import { eSendEvent } from '../../services/event-manager';
-import { useUserStore } from '../../stores/use-user-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useNoteStore } from '../../stores/use-notes-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import umami from '../../common/analytics';
-import { toggleDarkMode } from '../../utils/color-scheme/utils';
-import { MenuItemsList, SUBSCRIPTION_STATUS } from '../../utils/constants';
-import { eOpenPremiumDialog } from '../../utils/events';
-import { ColorSection } from './color-section';
-import { MenuItem } from './menu-item';
-import { TagsSection } from './pinned-section';
-import { UserStatus } from './user-status';
-import Navigation from '../../services/navigation';
+import React, { useCallback } from "react";
+import { FlatList, View } from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { notesnook } from "../../../e2e/test.ids";
+import Settings from "../../screens/settings";
+import { DDS } from "../../services/device-detection";
+import { eSendEvent } from "../../services/event-manager";
+import { useUserStore } from "../../stores/use-user-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useNoteStore } from "../../stores/use-notes-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import umami from "../../common/analytics";
+import { toggleDarkMode } from "../../utils/color-scheme/utils";
+import { MenuItemsList, SUBSCRIPTION_STATUS } from "../../utils/constants";
+import { eOpenPremiumDialog } from "../../utils/events";
+import { ColorSection } from "./color-section";
+import { MenuItem } from "./menu-item";
+import { TagsSection } from "./pinned-section";
+import { UserStatus } from "./user-status";
+import Navigation from "../../services/navigation";
export const SideMenu = React.memo(
() => {
- const colors = useThemeStore(state => state.colors);
- const deviceMode = useSettingStore(state => state.deviceMode);
+ const colors = useThemeStore((state) => state.colors);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
const insets = useSafeAreaInsets();
- const subscriptionType = useUserStore(state => state.user?.subscription?.type);
- const loading = useNoteStore(state => state.loading);
- const introCompleted = useSettingStore(state => state.settings.introCompleted);
+ const subscriptionType = useUserStore(
+ (state) => state.user?.subscription?.type
+ );
+ const loading = useNoteStore((state) => state.loading);
+ const introCompleted = useSettingStore(
+ (state) => state.settings.introCompleted
+ );
const noTextMode = false;
const BottomItemsList = [
{
- name: colors.night ? 'Day' : 'Night',
- icon: 'theme-light-dark',
+ name: colors.night ? "Day" : "Night",
+ icon: "theme-light-dark",
func: toggleDarkMode,
switch: true,
on: !!colors.night,
close: false
},
{
- name: 'Settings',
- icon: 'cog-outline',
+ name: "Settings",
+ icon: "cog-outline",
close: true,
func: () => {
Navigation.navigate({
- name: 'Settings',
- title: 'Settings'
+ name: "Settings",
+ title: "Settings"
});
}
}
];
const pro = {
- name: 'Notesnook Pro',
- icon: 'crown',
+ name: "Notesnook Pro",
+ icon: "crown",
func: () => {
- umami.pageView('/pro-screen', '/sidemenu');
+ umami.pageView("/pro-screen", "/sidemenu");
eSendEvent(eOpenPremiumDialog);
}
};
@@ -64,7 +68,12 @@ export const SideMenu = React.memo(
() => (
<>
{MenuItemsList.map((item, index) => (
- <MenuItem key={item.name} item={item} testID={item.name} index={index} />
+ <MenuItem
+ key={item.name}
+ item={item}
+ testID={item.name}
+ index={index}
+ />
))}
<ColorSection noTextMode={noTextMode} />
<TagsSection />
@@ -76,16 +85,16 @@ export const SideMenu = React.memo(
return !loading && introCompleted ? (
<View
style={{
- height: '100%',
- width: '100%',
+ height: "100%",
+ width: "100%",
backgroundColor: colors.nav
}}
>
<View
style={{
- height: '100%',
- width: '100%',
- backgroundColor: deviceMode !== 'mobile' ? colors.nav : colors.bg,
+ height: "100%",
+ width: "100%",
+ backgroundColor: deviceMode !== "mobile" ? colors.nav : colors.bg,
paddingTop: insets.top,
borderRadius: 10
}}
@@ -96,13 +105,13 @@ export const SideMenu = React.memo(
flexGrow: 1
}}
style={{
- height: '100%',
- width: '100%',
+ height: "100%",
+ width: "100%",
paddingHorizontal: 12
}}
showsVerticalScrollIndicator={false}
data={[0]}
- keyExtractor={() => 'mainMenuView'}
+ keyExtractor={() => "mainMenuView"}
renderItem={renderItem}
/>
<View
@@ -112,26 +121,40 @@ export const SideMenu = React.memo(
>
{subscriptionType === SUBSCRIPTION_STATUS.TRIAL ||
subscriptionType === SUBSCRIPTION_STATUS.BASIC ? (
- <MenuItem testID={pro.name} key={pro.name} item={pro} index={0} ignore={true} />
- ) : null}
-
- {BottomItemsList.slice(DDS.isLargeTablet() ? 0 : 1, 3).map((item, index) => (
<MenuItem
- testID={item.name == 'Night mode' ? notesnook.ids.menu.nightmode : item.name}
- key={item.name}
- item={item}
- index={index}
+ testID={pro.name}
+ key={pro.name}
+ item={pro}
+ index={0}
ignore={true}
- rightBtn={
- DDS.isLargeTablet() || item.name === 'Notesnook Pro' ? null : BottomItemsList[0]
- }
/>
- ))}
+ ) : null}
+
+ {BottomItemsList.slice(DDS.isLargeTablet() ? 0 : 1, 3).map(
+ (item, index) => (
+ <MenuItem
+ testID={
+ item.name == "Night mode"
+ ? notesnook.ids.menu.nightmode
+ : item.name
+ }
+ key={item.name}
+ item={item}
+ index={index}
+ ignore={true}
+ rightBtn={
+ DDS.isLargeTablet() || item.name === "Notesnook Pro"
+ ? null
+ : BottomItemsList[0]
+ }
+ />
+ )
+ )}
</View>
<View
style={{
- width: '100%',
+ width: "100%",
paddingHorizontal: 0
}}
>
diff --git a/apps/mobile/app/components/side-menu/menu-item.js b/apps/mobile/app/components/side-menu/menu-item.js
index a5cfc2701..efde9932c 100644
--- a/apps/mobile/app/components/side-menu/menu-item.js
+++ b/apps/mobile/app/components/side-menu/menu-item.js
@@ -1,23 +1,23 @@
-import React, { useEffect, useState } from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import ToggleSwitch from 'toggle-switch-react-native';
-import Navigation from '../../services/navigation';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { normalize, SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import { PressableButton } from '../ui/pressable';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React, { useEffect, useState } from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import ToggleSwitch from "toggle-switch-react-native";
+import Navigation from "../../services/navigation";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { normalize, SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import { PressableButton } from "../ui/pressable";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
export const MenuItem = React.memo(
({ item, index, testID, rightBtn }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [headerTextState, setHeaderTextState] = useState(
useNavigationStore.getState().currentScreen
);
- const screenId = item.name.toLowerCase() + '_navigation';
+ const screenId = item.name.toLowerCase() + "_navigation";
let isFocused = headerTextState?.id === screenId;
const _onPress = () => {
@@ -33,7 +33,7 @@ export const MenuItem = React.memo(
}
};
- const onHeaderStateChange = state => {
+ const onHeaderStateChange = (state) => {
setTimeout(() => {
let id = state.currentScreen?.id;
if (id === screenId) {
@@ -58,33 +58,39 @@ export const MenuItem = React.memo(
testID={testID}
key={item.name + index}
onPress={_onPress}
- type={!isFocused ? 'gray' : 'grayBg'}
+ type={!isFocused ? "gray" : "grayBg"}
customStyle={{
- width: '100%',
- alignSelf: 'center',
+ width: "100%",
+ alignSelf: "center",
borderRadius: 5,
- flexDirection: 'row',
+ flexDirection: "row",
paddingHorizontal: 8,
- justifyContent: 'space-between',
- alignItems: 'center',
+ justifyContent: "space-between",
+ alignItems: "center",
height: normalize(50),
marginBottom: 5
}}
>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<Icon
style={{
width: 30,
- textAlignVertical: 'center',
- textAlign: 'left'
+ textAlignVertical: "center",
+ textAlign: "left"
}}
name={item.icon}
- color={item.icon === 'crown' ? colors.yellow : isFocused ? colors.accent : colors.pri}
+ color={
+ item.icon === "crown"
+ ? colors.yellow
+ : isFocused
+ ? colors.accent
+ : colors.pri
+ }
size={SIZE.lg - 2}
/>
{isFocused ? (
diff --git a/apps/mobile/app/components/side-menu/pinned-section.js b/apps/mobile/app/components/side-menu/pinned-section.js
index b1aa3a19a..b5091c055 100644
--- a/apps/mobile/app/components/side-menu/pinned-section.js
+++ b/apps/mobile/app/components/side-menu/pinned-section.js
@@ -1,30 +1,30 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { FlatList, View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import Notebook from '../../screens/notebook';
-import { TaggedNotes } from '../../screens/notes/tagged';
-import { TopicNotes } from '../../screens/notes/topic-notes';
-import Navigation from '../../services/navigation';
-import { useMenuStore } from '../../stores/use-menu-store';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useNoteStore } from '../../stores/use-notes-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { db } from '../../common/database';
-import { normalize, SIZE } from '../../utils/size';
-import { Properties } from '../properties';
-import { Button } from '../ui/button';
-import { Notice } from '../ui/notice';
-import { PressableButton } from '../ui/pressable';
-import Seperator from '../ui/seperator';
-import SheetWrapper from '../ui/sheet';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React, { useEffect, useRef, useState } from "react";
+import { FlatList, View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import Notebook from "../../screens/notebook";
+import { TaggedNotes } from "../../screens/notes/tagged";
+import { TopicNotes } from "../../screens/notes/topic-notes";
+import Navigation from "../../services/navigation";
+import { useMenuStore } from "../../stores/use-menu-store";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useNoteStore } from "../../stores/use-notes-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { db } from "../../common/database";
+import { normalize, SIZE } from "../../utils/size";
+import { Properties } from "../properties";
+import { Button } from "../ui/button";
+import { Notice } from "../ui/notice";
+import { PressableButton } from "../ui/pressable";
+import Seperator from "../ui/seperator";
+import SheetWrapper from "../ui/sheet";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
export const TagsSection = React.memo(
() => {
- const menuPins = useMenuStore(state => state.menuPins);
- const loading = useNoteStore(state => state.loading);
- const setMenuPins = useMenuStore(state => state.setMenuPins);
+ const menuPins = useMenuStore((state) => state.menuPins);
+ const loading = useNoteStore((state) => state.loading);
+ const setMenuPins = useMenuStore((state) => state.setMenuPins);
useEffect(() => {
if (!loading) {
@@ -32,10 +32,10 @@ export const TagsSection = React.memo(
}
}, [loading]);
- const onPress = item => {
- if (item.type === 'notebook') {
+ const onPress = (item) => {
+ if (item.type === "notebook") {
Notebook.navigate(item);
- } else if (item.type === 'tag') {
+ } else if (item.type === "tag") {
TaggedNotes.navigate(item);
} else {
TopicNotes.navigate(item);
@@ -46,7 +46,9 @@ export const TagsSection = React.memo(
};
const renderItem = ({ item, index }) => {
let alias = item.alias || item.title;
- return <PinItem item={item} index={index} alias={alias} onPress={onPress} />;
+ return (
+ <PinItem item={item} index={index} alias={alias} onPress={onPress} />
+ );
};
return (
@@ -81,15 +83,15 @@ export const TagsSection = React.memo(
export const PinItem = React.memo(
({ item, index, onPress, placeholder, alias }) => {
- const colors = useThemeStore(state => state.colors);
- const setMenuPins = useMenuStore(state => state.setMenuPins);
+ const colors = useThemeStore((state) => state.colors);
+ const setMenuPins = useMenuStore((state) => state.setMenuPins);
alias = item?.alias || item?.title;
const [visible, setVisible] = useState(false);
const [headerTextState, setHeaderTextState] = useState(null);
const color = headerTextState?.id === item.id ? colors.accent : colors.pri;
const fwdRef = useRef();
- const onHeaderStateChange = state => {
+ const onHeaderStateChange = (state) => {
setTimeout(() => {
let id = state.currentScreen?.id;
if (id === item.id) {
@@ -112,9 +114,9 @@ export const PinItem = React.memo(
}, [headerTextState]);
const icons = {
- topic: 'bookmark',
- notebook: 'book-outline',
- tag: 'pound'
+ topic: "bookmark",
+ notebook: "book-outline",
+ tag: "pound"
};
return (
@@ -147,28 +149,28 @@ export const PinItem = React.memo(
</SheetWrapper>
)}
<PressableButton
- type={headerTextState?.id === item.id ? 'grayBg' : 'gray'}
+ type={headerTextState?.id === item.id ? "grayBg" : "gray"}
onLongPress={() => {
if (placeholder) return;
Properties.present(item);
}}
onPress={() => onPress(item)}
customStyle={{
- width: '100%',
- alignSelf: 'center',
+ width: "100%",
+ alignSelf: "center",
borderRadius: 5,
- flexDirection: 'row',
+ flexDirection: "row",
paddingHorizontal: 8,
- justifyContent: 'space-between',
- alignItems: 'center',
+ justifyContent: "space-between",
+ alignItems: "center",
height: normalize(50),
marginBottom: 5
}}
>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
flexGrow: 1,
flex: 1
}}
@@ -176,13 +178,13 @@ export const PinItem = React.memo(
<View
style={{
width: 30,
- justifyContent: 'center'
+ justifyContent: "center"
}}
>
<Icon color={color} size={SIZE.lg - 2} name={icons[item.type]} />
<Icon
style={{
- position: 'absolute',
+ position: "absolute",
bottom: -6,
left: -6
}}
@@ -193,7 +195,7 @@ export const PinItem = React.memo(
</View>
<View
style={{
- alignItems: 'flex-start',
+ alignItems: "flex-start",
flexGrow: 1,
flex: 1
}}
@@ -201,7 +203,7 @@ export const PinItem = React.memo(
{headerTextState?.id === item.id ? (
<Heading
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
color={colors.heading}
size={SIZE.md}
diff --git a/apps/mobile/app/components/side-menu/user-status.js b/apps/mobile/app/components/side-menu/user-status.js
index 28bf7b5ed..cde9bfd73 100644
--- a/apps/mobile/app/components/side-menu/user-status.js
+++ b/apps/mobile/app/components/side-menu/user-status.js
@@ -1,45 +1,45 @@
-import React from 'react';
-import { ActivityIndicator, Platform, View } from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useUserStore } from '../../stores/use-user-store';
-import { eSendEvent } from '../../services/event-manager';
-import Sync from '../../services/sync';
-import { eOpenLoginDialog } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { PressableButton } from '../ui/pressable';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import { TimeSince } from '../ui/time-since';
-import useSyncProgress from '../../hooks/use-sync-progress';
-import Navigation from '../../services/navigation';
-import { tabBarRef } from '../../utils/global-refs';
-import { ProgressCircleComponent } from '../ui/svg/lazy';
+import React from "react";
+import { ActivityIndicator, Platform, View } from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useUserStore } from "../../stores/use-user-store";
+import { eSendEvent } from "../../services/event-manager";
+import Sync from "../../services/sync";
+import { eOpenLoginDialog } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { PressableButton } from "../ui/pressable";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import { TimeSince } from "../ui/time-since";
+import useSyncProgress from "../../hooks/use-sync-progress";
+import Navigation from "../../services/navigation";
+import { tabBarRef } from "../../utils/global-refs";
+import { ProgressCircleComponent } from "../ui/svg/lazy";
export const UserStatus = () => {
- const colors = useThemeStore(state => state.colors);
- const user = useUserStore(state => state.user);
- const syncing = useUserStore(state => state.syncing);
- const lastSynced = useUserStore(state => state.lastSynced);
+ const colors = useThemeStore((state) => state.colors);
+ const user = useUserStore((state) => state.user);
+ const syncing = useUserStore((state) => state.syncing);
+ const lastSynced = useUserStore((state) => state.lastSynced);
const insets = useSafeAreaInsets();
const { progress } = useSyncProgress();
- console.log('SYNC PROGRESS', progress);
+ console.log("SYNC PROGRESS", progress);
return (
<View
style={{
- width: '100%',
- alignSelf: 'center',
- paddingBottom: Platform.OS === 'ios' ? insets.bottom / 2 : null,
+ width: "100%",
+ alignSelf: "center",
+ paddingBottom: Platform.OS === "ios" ? insets.bottom / 2 : null,
borderTopWidth: 1,
borderTopColor: colors.nav
}}
>
<View
style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center'
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center"
}}
>
<PressableButton
@@ -53,8 +53,8 @@ export const UserStatus = () => {
}}
type="gray"
customStyle={{
- flexDirection: 'row',
- justifyContent: 'flex-start',
+ flexDirection: "row",
+ justifyContent: "flex-start",
padding: 12,
paddingHorizontal: 20,
borderRadius: 0
@@ -68,28 +68,30 @@ export const UserStatus = () => {
>
<Heading
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
size={SIZE.xs}
color={colors.icon}
>
{!user ? (
- 'You are not logged in'
+ "You are not logged in"
) : !syncing ? (
- lastSynced && lastSynced !== 'Never' ? (
+ lastSynced && lastSynced !== "Never" ? (
<>
- Last synced{' '}
+ Last synced{" "}
<TimeSince
style={{ fontSize: SIZE.xs, color: colors.icon }}
time={lastSynced}
/>
</>
) : (
- 'never'
+ "never"
)
) : (
- `Syncing your notes${progress ? ` (${progress.current}/${progress.total})` : ''}`
- )}{' '}
+ `Syncing your notes${
+ progress ? ` (${progress.current}/${progress.total})` : ""
+ }`
+ )}{" "}
<Icon
name="checkbox-blank-circle"
size={9}
@@ -99,11 +101,13 @@ export const UserStatus = () => {
<Paragraph
style={{
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
color={colors.heading}
>
- {!user ? 'Login to sync your notes.' : 'Tap here to sync your notes.'}
+ {!user
+ ? "Login to sync your notes."
+ : "Tap here to sync your notes."}
</Paragraph>
</View>
diff --git a/apps/mobile/app/components/tabs/index.tsx b/apps/mobile/app/components/tabs/index.tsx
index 8021fd5be..1e154220a 100644
--- a/apps/mobile/app/components/tabs/index.tsx
+++ b/apps/mobile/app/components/tabs/index.tsx
@@ -5,9 +5,9 @@ import React, {
useImperativeHandle,
useRef,
useState
-} from 'react';
-import { BackHandler, Platform, ViewProps } from 'react-native';
-import { Gesture, GestureDetector } from 'react-native-gesture-handler';
+} from "react";
+import { BackHandler, Platform, ViewProps } from "react-native";
+import { Gesture, GestureDetector } from "react-native-gesture-handler";
import Animated, {
runOnJS,
useAnimatedReaction,
@@ -16,10 +16,10 @@ import Animated, {
withSpring,
WithSpringConfig,
withTiming
-} from 'react-native-reanimated';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { eSendEvent } from '../../services/event-manager';
-import { eClearEditor } from '../../utils/events';
+} from "react-native-reanimated";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { eSendEvent } from "../../services/event-manager";
+import { eClearEditor } from "../../utils/events";
interface TabProps extends ViewProps {
dimensions: { width: number; height: number };
@@ -45,12 +45,22 @@ export interface TabsRef {
export const FluidTabs = forwardRef<TabsRef, TabProps>(
(
- { children, dimensions, widths, onChangeTab, onScroll, enabled, onDrawerStateChange }: TabProps,
+ {
+ children,
+ dimensions,
+ widths,
+ onChangeTab,
+ onScroll,
+ enabled,
+ onDrawerStateChange
+ }: TabProps,
ref
) => {
- const deviceMode = useSettingStore(state => state.deviceMode);
- const fullscreen = useSettingStore(state => state.fullscreen);
- const introCompleted = useSettingStore(state => state.settings.introCompleted);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
+ const fullscreen = useSettingStore((state) => state.fullscreen);
+ const introCompleted = useSettingStore(
+ (state) => state.settings.introCompleted
+ );
const translateX = useSharedValue(widths ? widths.a : 0);
const startX = useSharedValue(0);
const currentTab = useSharedValue(1);
@@ -64,19 +74,21 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(
const forcedLock = useSharedValue(false);
const [disabled, setDisabled] = useState(false);
const node = useRef<Animated.View>(null);
- const containerWidth = widths ? widths.a + widths.b + widths.c : dimensions.width;
+ const containerWidth = widths
+ ? widths.a + widths.b + widths.c
+ : dimensions.width;
const drawerPosition = 0;
const homePosition = widths.a;
const editorPosition = widths.a + widths.b;
- const isSmallTab = deviceMode === 'smallTablet';
+ const isSmallTab = deviceMode === "smallTablet";
const isLoaded = useRef(false);
const prevWidths = useRef(widths);
- const isIPhone = Platform.OS === 'ios';
+ const isIPhone = Platform.OS === "ios";
useEffect(() => {
if (introCompleted) {
- if (deviceMode === 'tablet' || fullscreen) {
+ if (deviceMode === "tablet" || fullscreen) {
translateX.value = 0;
} else {
if (prevWidths.current?.a !== widths.a) translateX.value = widths.a;
@@ -85,7 +97,7 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(
prevWidths.current = widths;
}
- const sub = BackHandler.addEventListener('hardwareBackPress', () => {
+ const sub = BackHandler.addEventListener("hardwareBackPress", () => {
if (isDrawerOpen.value) {
translateX.value = withTiming(homePosition);
onDrawerStateChange(false);
@@ -103,7 +115,7 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(
ref,
(): TabsRef => ({
goToPage: (page: number) => {
- if (deviceMode === 'tablet') {
+ if (deviceMode === "tablet") {
translateX.value = withTiming(0);
return;
}
@@ -119,7 +131,7 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(
}
},
goToIndex: (index: number) => {
- if (deviceMode === 'tablet') {
+ if (deviceMode === "tablet") {
translateX.value = withTiming(0);
return;
}
@@ -152,7 +164,7 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(
onDrawerStateChange(true);
},
closeDrawer: () => {
- if (deviceMode === 'tablet') {
+ if (deviceMode === "tablet") {
translateX.value = withTiming(0);
return;
}
@@ -169,7 +181,7 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(
useAnimatedReaction(
() => currentTab.value,
- result => {
+ (result) => {
if (setDisabled) {
if (result === 2) {
runOnJS(setDisabled)(!isIPhone);
@@ -187,7 +199,7 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(
useAnimatedReaction(
() => translateX.value,
- value => {
+ (value) => {
runOnJS(onScroll)(value);
},
[]
@@ -204,15 +216,15 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(
.enabled(enabled && !disabled)
.activeOffsetX([-5, 5])
.failOffsetY([-15, 15])
- .onBegin(event => {
+ .onBegin((event) => {
locked.value = false;
gestureStartValue.value = {
x: event.absoluteX,
y: event.absoluteY
};
})
- .onStart(event => {
- console.log('gesture activated');
+ .onStart((event) => {
+ console.log("gesture activated");
let diffX = gestureStartValue.value.x - event.absoluteX;
let diffY = gestureStartValue.value.y - event.absoluteY;
@@ -228,22 +240,25 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(
if (vx / vy < 1.5) locked.value = true;
startX.value = translateX.value;
})
- .onChange(event => {
+ .onChange((event) => {
if (locked.value || forcedLock.value) return;
let value = translateX.value + event.changeX * -1;
if (
value < 0 ||
- (currentTab.value === 2 && Platform.OS === 'android') ||
- (currentTab.value === 2 && gestureStartValue.value.x > 25 && Platform.OS === 'ios') ||
+ (currentTab.value === 2 && Platform.OS === "android") ||
+ (currentTab.value === 2 &&
+ gestureStartValue.value.x > 25 &&
+ Platform.OS === "ios") ||
(value >= homePosition && isSmallTab) ||
value > editorPosition
)
return;
translateX.value = value;
})
- .onEnd(event => {
- if (currentTab.value === 2 && Platform.OS === 'android') return;
- let velocityX = event.velocityX < 0 ? event.velocityX * -1 : event.velocityX;
+ .onEnd((event) => {
+ if (currentTab.value === 2 && Platform.OS === "android") return;
+ let velocityX =
+ event.velocityX < 0 ? event.velocityX * -1 : event.velocityX;
let isSwipeLeft = startX.value > translateX.value;
let finalValue = isSwipeLeft
? translateX.value - velocityX / 40.0
@@ -327,7 +342,7 @@ export const FluidTabs = forwardRef<TabsRef, TabProps>(
{
flex: 1,
width: containerWidth,
- flexDirection: 'row'
+ flexDirection: "row"
},
animatedStyles
]}
diff --git a/apps/mobile/app/components/tip/index.tsx b/apps/mobile/app/components/tip/index.tsx
index f2af38e52..e67291240 100644
--- a/apps/mobile/app/components/tip/index.tsx
+++ b/apps/mobile/app/components/tip/index.tsx
@@ -1,14 +1,14 @@
-import React from 'react';
-import { Image, TextStyle, View, ViewStyle } from 'react-native';
-import { eSendEvent, presentSheet } from '../../services/event-manager';
-import { TTip } from '../../services/tip-manager';
-import { ThemeStore, useThemeStore } from '../../stores/use-theme-store';
-import { MMKV } from '../../common/database/mmkv';
-import { eCloseProgressDialog } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import Seperator from '../ui/seperator';
-import Paragraph from '../ui/typography/paragraph';
+import React from "react";
+import { Image, TextStyle, View, ViewStyle } from "react-native";
+import { eSendEvent, presentSheet } from "../../services/event-manager";
+import { TTip } from "../../services/tip-manager";
+import { ThemeStore, useThemeStore } from "../../stores/use-theme-store";
+import { MMKV } from "../../common/database/mmkv";
+import { eCloseProgressDialog } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import Seperator from "../ui/seperator";
+import Paragraph from "../ui/typography/paragraph";
export const Tip = ({
tip,
@@ -23,9 +23,9 @@ export const Tip = ({
textStyle?: TextStyle;
neverShowAgain: boolean;
noImage?: boolean;
- color?: keyof ThemeStore['colors'];
+ color?: keyof ThemeStore["colors"];
}) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return tip ? (
<View
@@ -33,8 +33,8 @@ export const Tip = ({
{
borderRadius: 10,
padding: 12,
- width: '100%',
- alignSelf: 'center',
+ width: "100%",
+ alignSelf: "center",
paddingVertical: 12,
backgroundColor: colors.nav
},
@@ -43,8 +43,8 @@ export const Tip = ({
>
<View
style={{
- flexDirection: 'row',
- justifyContent: 'space-between'
+ flexDirection: "row",
+ justifyContent: "space-between"
}}
>
<Button
@@ -58,7 +58,7 @@ export const Tip = ({
width: null,
height: 22,
paddingHorizontal: 4,
- alignSelf: 'flex-start',
+ alignSelf: "flex-start",
borderRadius: 100,
borderWidth: 1,
//@ts-ignore
@@ -75,7 +75,7 @@ export const Tip = ({
fontSize={SIZE.xs}
iconSize={SIZE.xs}
onPress={() => {
- MMKV.setItem('neverShowSheetTips', 'true');
+ MMKV.setItem("neverShowSheetTips", "true");
eSendEvent(eCloseProgressDialog);
}}
//@ts-ignore
@@ -83,7 +83,7 @@ export const Tip = ({
width: null,
height: 25,
paddingHorizontal: 4,
- alignSelf: 'flex-start',
+ alignSelf: "flex-start",
borderRadius: 100,
borderWidth: 1,
borderColor: colors.icon
@@ -100,16 +100,16 @@ export const Tip = ({
<View
style={{
borderRadius: 10,
- overflow: 'hidden',
+ overflow: "hidden",
marginTop: 10
}}
>
<Image
source={{ uri: tip.image }}
style={{
- width: '100%',
+ width: "100%",
height: 230,
- alignSelf: 'center'
+ alignSelf: "center"
}}
/>
</View>
@@ -140,7 +140,7 @@ export const Tip = ({
Tip.present = async (tip: TTip) => {
if (!tip) return;
- let dontShow = MMKV.getString('neverShowSheetTips');
+ let dontShow = MMKV.getString("neverShowSheetTips");
if (dontShow) return;
presentSheet({
component: (
@@ -148,7 +148,7 @@ Tip.present = async (tip: TTip) => {
tip={tip}
neverShowAgain={true}
style={{
- backgroundColor: 'transparent',
+ backgroundColor: "transparent",
paddingHorizontal: 12
}}
/>
diff --git a/apps/mobile/app/components/toast/index.js b/apps/mobile/app/components/toast/index.js
index 9e8e2f7ec..e1984be5e 100644
--- a/apps/mobile/app/components/toast/index.js
+++ b/apps/mobile/app/components/toast/index.js
@@ -1,33 +1,36 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { Keyboard, View } from 'react-native';
-import Animated, { FadeInUp, FadeOutUp } from 'react-native-reanimated';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { notesnook } from '../../../e2e/test.ids';
-import { DDS } from '../../services/device-detection';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { getElevation } from '../../utils';
-import { eHideToast, eShowToast } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { Button } from '../ui/button';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React, { useEffect, useRef, useState } from "react";
+import { Keyboard, View } from "react-native";
+import Animated, { FadeInUp, FadeOutUp } from "react-native-reanimated";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { notesnook } from "../../../e2e/test.ids";
+import { DDS } from "../../services/device-detection";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { getElevation } from "../../utils";
+import { eHideToast, eShowToast } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { Button } from "../ui/button";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
let toastMessages = [];
-export const Toast = ({ context = 'global' }) => {
- const colors = useThemeStore(state => state.colors);
+export const Toast = ({ context = "global" }) => {
+ const colors = useThemeStore((state) => state.colors);
const [keyboard, setKeyboard] = useState(false);
const [data, setData] = useState({});
const insets = useSafeAreaInsets();
const hideTimeout = useRef();
const [visible, setVisible] = useState(false);
- const showToastFunc = async data => {
- console.log('toast show', data.message, toastMessages.length);
+ const showToastFunc = async (data) => {
+ console.log("toast show", data.message, toastMessages.length);
if (!data) return;
if (data.context !== context) return;
- if (toastMessages.findIndex(m => m.message === data.message) >= 0) {
- console.log('returning from here');
+ if (toastMessages.findIndex((m) => m.message === data.message) >= 0) {
+ console.log("returning from here");
return;
}
toastMessages.push(data);
@@ -43,7 +46,7 @@ export const Toast = ({ context = 'global' }) => {
}, data.duration);
};
- const showNext = data => {
+ const showNext = (data) => {
if (!data) {
hideToastFunc();
return;
@@ -91,8 +94,8 @@ export const Toast = ({ context = 'global' }) => {
useEffect(() => {
toastMessages = [];
- let sub1 = Keyboard.addListener('keyboardDidShow', _onKeyboardShow);
- let sub2 = Keyboard.addListener('keyboardDidHide', _onKeyboardHide);
+ let sub1 = Keyboard.addListener("keyboardDidShow", _onKeyboardShow);
+ let sub2 = Keyboard.addListener("keyboardDidHide", _onKeyboardHide);
eSubscribeEvent(eShowToast, showToastFunc);
eSubscribeEvent(eHideToast, hideToastFunc);
return () => {
@@ -120,12 +123,12 @@ export const Toast = ({ context = 'global' }) => {
}
}}
style={{
- width: DDS.isTab ? 400 : '100%',
- alignItems: 'center',
- alignSelf: 'center',
+ width: DDS.isTab ? 400 : "100%",
+ alignItems: "center",
+ alignSelf: "center",
minHeight: 30,
top: insets.top + 10,
- position: 'absolute',
+ position: "absolute",
zIndex: 999,
elevation: 15
}}
@@ -135,25 +138,25 @@ export const Toast = ({ context = 'global' }) => {
exiting={FadeOutUp}
style={{
...getElevation(5),
- maxWidth: '95%',
+ maxWidth: "95%",
backgroundColor: colors.nav,
- minWidth: data?.func ? '95%' : '50%',
- alignSelf: 'center',
+ minWidth: data?.func ? "95%" : "50%",
+ alignSelf: "center",
borderRadius: 5,
minHeight: 30,
paddingVertical: 10,
paddingLeft: 12,
paddingRight: 5,
- justifyContent: 'space-between',
- flexDirection: 'row',
- alignItems: 'center',
- width: '95%'
+ justifyContent: "space-between",
+ flexDirection: "row",
+ alignItems: "center",
+ width: "95%"
}}
>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
flexGrow: 1,
flex: 1
}}
@@ -162,15 +165,17 @@ export const Toast = ({ context = 'global' }) => {
style={{
height: 30,
borderRadius: 100,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
marginRight: 10
}}
>
<Icon
- name={data?.type === 'success' ? 'check' : 'close'}
+ name={data?.type === "success" ? "check" : "close"}
size={SIZE.lg}
- color={data?.type === 'error' ? colors.errorText : colors.accent}
+ color={
+ data?.type === "error" ? colors.errorText : colors.accent
+ }
/>
</View>
@@ -196,7 +201,7 @@ export const Toast = ({ context = 'global' }) => {
<Paragraph
color={colors.pri}
style={{
- maxWidth: '100%',
+ maxWidth: "100%",
paddingRight: 10
}}
onPress={() => {
@@ -213,7 +218,7 @@ export const Toast = ({ context = 'global' }) => {
<Button
testID={notesnook.toast.button}
fontSize={SIZE.md}
- type={data.type === 'error' ? 'errorShade' : 'transparent'}
+ type={data.type === "error" ? "errorShade" : "transparent"}
onPress={data.func}
title={data.actionText}
height={30}
diff --git a/apps/mobile/app/components/ui/animated-button.tsx/index.tsx b/apps/mobile/app/components/ui/animated-button.tsx/index.tsx
index 00a1bf380..916dc5a06 100644
--- a/apps/mobile/app/components/ui/animated-button.tsx/index.tsx
+++ b/apps/mobile/app/components/ui/animated-button.tsx/index.tsx
@@ -1,15 +1,20 @@
-import React from 'react';
-import { ActivityIndicator, ColorValue, TextStyle } from 'react-native';
-import Animated, { FadeIn, FadeOut, Layout, LightSpeedInLeft } from 'react-native-reanimated';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { showTooltip, TOOLTIP_POSITIONS } from '../../../utils';
-import { BUTTON_TYPES } from '../../../utils/constants';
-import { SIZE } from '../../../utils/size';
-import { ButtonProps } from '../button';
-import { PressableButton, PressableButtonProps } from '../pressable';
-import Heading from '../typography/heading';
-import Paragraph from '../typography/paragraph';
+import React from "react";
+import { ActivityIndicator, ColorValue, TextStyle } from "react-native";
+import Animated, {
+ FadeIn,
+ FadeOut,
+ Layout,
+ LightSpeedInLeft
+} from "react-native-reanimated";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { showTooltip, TOOLTIP_POSITIONS } from "../../../utils";
+import { BUTTON_TYPES } from "../../../utils/constants";
+import { SIZE } from "../../../utils/size";
+import { ButtonProps } from "../button";
+import { PressableButton, PressableButtonProps } from "../pressable";
+import Heading from "../typography/heading";
+import Paragraph from "../typography/paragraph";
const AnimatedIcon = Animated.createAnimatedComponent(Icon);
@@ -21,40 +26,44 @@ export const AnimatedButton = ({
title = null,
icon,
fontSize = SIZE.sm,
- type = 'transparent',
+ type = "transparent",
iconSize = SIZE.md,
style = {},
- accentColor = 'accent',
- accentText = 'light',
+ accentColor = "accent",
+ accentText = "light",
onLongPress,
tooltipText,
textStyle,
- iconPosition = 'left',
+ iconPosition = "left",
buttonType,
bold,
iconColor,
fwdRef,
...restProps
}: ButtonProps) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const textColor = buttonType?.text
? buttonType.text
: //@ts-ignore
colors[
- type === 'accent'
+ type === "accent"
? BUTTON_TYPES[type](accentColor, accentText).text
: BUTTON_TYPES[type].text
];
const Component = bold ? Heading : Paragraph;
return (
- <Animated.View entering={FadeIn} exiting={FadeOut} layout={Layout.springify()}>
+ <Animated.View
+ entering={FadeIn}
+ exiting={FadeOut}
+ layout={Layout.springify()}
+ >
<PressableButton
{...restProps}
fwdRef={fwdRef}
onPress={onPress}
- onLongPress={event => {
+ onLongPress={(event) => {
if (onLongPress) {
onLongPress(event);
return;
@@ -76,16 +85,18 @@ export const AnimatedButton = ({
width: width || null,
paddingHorizontal: 12,
borderRadius: 5,
- alignSelf: 'center',
- justifyContent: 'center',
- alignItems: 'center',
- flexDirection: 'row',
+ alignSelf: "center",
+ justifyContent: "center",
+ alignItems: "center",
+ flexDirection: "row",
//@ts-ignore
...style
}}
>
- {loading ? <ActivityIndicator color={textColor} size={fontSize + 4} /> : null}
- {icon && !loading && iconPosition === 'left' ? (
+ {loading ? (
+ <ActivityIndicator color={textColor} size={fontSize + 4} />
+ ) : null}
+ {icon && !loading && iconPosition === "left" ? (
<AnimatedIcon
exiting={FadeOut.duration(100)}
entering={LightSpeedInLeft}
@@ -108,8 +119,10 @@ export const AnimatedButton = ({
numberOfLines={1}
style={[
{
- marginLeft: icon || (loading && iconPosition === 'left') ? 5 : 0,
- marginRight: icon || (loading && iconPosition === 'right') ? 5 : 0
+ marginLeft:
+ icon || (loading && iconPosition === "left") ? 5 : 0,
+ marginRight:
+ icon || (loading && iconPosition === "right") ? 5 : 0
},
textStyle
]}
@@ -118,7 +131,7 @@ export const AnimatedButton = ({
</Component>
)}
- {icon && !loading && iconPosition === 'right' ? (
+ {icon && !loading && iconPosition === "right" ? (
<Icon
name={icon}
style={{
diff --git a/apps/mobile/app/components/ui/button/index.tsx b/apps/mobile/app/components/ui/button/index.tsx
index 7063c0588..1a67b043c 100644
--- a/apps/mobile/app/components/ui/button/index.tsx
+++ b/apps/mobile/app/components/ui/button/index.tsx
@@ -1,13 +1,13 @@
-import React from 'react';
-import { ActivityIndicator, ColorValue, TextStyle } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { showTooltip, TOOLTIP_POSITIONS } from '../../../utils';
-import { BUTTON_TYPES } from '../../../utils/constants';
-import { SIZE } from '../../../utils/size';
-import { PressableButton, PressableButtonProps } from '../pressable';
-import Heading from '../typography/heading';
-import Paragraph from '../typography/paragraph';
+import React from "react";
+import { ActivityIndicator, ColorValue, TextStyle } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { showTooltip, TOOLTIP_POSITIONS } from "../../../utils";
+import { BUTTON_TYPES } from "../../../utils/constants";
+import { SIZE } from "../../../utils/size";
+import { PressableButton, PressableButtonProps } from "../pressable";
+import Heading from "../typography/heading";
+import Paragraph from "../typography/paragraph";
export interface ButtonProps extends PressableButtonProps {
height?: number;
@@ -15,7 +15,7 @@ export interface ButtonProps extends PressableButtonProps {
fontSize?: number;
tooltipText?: string;
textStyle?: TextStyle;
- iconPosition?: 'left' | 'right';
+ iconPosition?: "left" | "right";
iconSize?: number;
title?: string | null;
loading?: boolean;
@@ -39,15 +39,15 @@ export const Button = ({
title = null,
icon,
fontSize = SIZE.sm,
- type = 'transparent',
+ type = "transparent",
iconSize = SIZE.md,
style = {},
- accentColor = 'accent',
- accentText = 'light',
+ accentColor = "accent",
+ accentText = "light",
onLongPress,
tooltipText,
textStyle,
- iconPosition = 'left',
+ iconPosition = "left",
buttonType,
bold,
iconColor,
@@ -55,13 +55,13 @@ export const Button = ({
iconStyle,
...restProps
}: ButtonProps) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const textColor = buttonType?.text
? buttonType.text
: //@ts-ignore
colors[
- type === 'accent'
+ type === "accent"
? BUTTON_TYPES[type](accentColor, accentText).text
: BUTTON_TYPES[type].text
];
@@ -72,7 +72,7 @@ export const Button = ({
{...restProps}
fwdRef={fwdRef}
onPress={onPress}
- onLongPress={event => {
+ onLongPress={(event) => {
if (onLongPress) {
onLongPress(event);
return;
@@ -94,16 +94,18 @@ export const Button = ({
width: width || null,
paddingHorizontal: 12,
borderRadius: 5,
- alignSelf: 'center',
- justifyContent: 'center',
- alignItems: 'center',
- flexDirection: 'row',
+ alignSelf: "center",
+ justifyContent: "center",
+ alignItems: "center",
+ flexDirection: "row",
//@ts-ignore
...style
}}
>
- {loading ? <ActivityIndicator color={textColor} size={fontSize + 4} /> : null}
- {icon && !loading && iconPosition === 'left' ? (
+ {loading ? (
+ <ActivityIndicator color={textColor} size={fontSize + 4} />
+ ) : null}
+ {icon && !loading && iconPosition === "left" ? (
<Icon
name={icon}
style={[{ marginRight: 0 }, iconStyle]}
@@ -120,8 +122,8 @@ export const Button = ({
numberOfLines={1}
style={[
{
- marginLeft: icon || (loading && iconPosition === 'left') ? 5 : 0,
- marginRight: icon || (loading && iconPosition === 'right') ? 5 : 0
+ marginLeft: icon || (loading && iconPosition === "left") ? 5 : 0,
+ marginRight: icon || (loading && iconPosition === "right") ? 5 : 0
},
textStyle
]}
@@ -130,7 +132,7 @@ export const Button = ({
</Component>
)}
- {icon && !loading && iconPosition === 'right' ? (
+ {icon && !loading && iconPosition === "right" ? (
<Icon
name={icon}
style={[{ marginLeft: 0 }, iconStyle]}
diff --git a/apps/mobile/app/components/ui/icon-button/index.tsx b/apps/mobile/app/components/ui/icon-button/index.tsx
index 2eb075c44..ed248a7c2 100644
--- a/apps/mobile/app/components/ui/icon-button/index.tsx
+++ b/apps/mobile/app/components/ui/icon-button/index.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { ColorValue, GestureResponderEvent, ViewStyle } from 'react-native';
+import React from "react";
+import { ColorValue, GestureResponderEvent, ViewStyle } from "react-native";
import Animated, {
FadeIn,
FadeOut,
@@ -7,13 +7,13 @@ import Animated, {
FlipInEasyY,
FlipOutEasyY,
Layout
-} from 'react-native-reanimated';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { showTooltip, TOOLTIP_POSITIONS } from '../../../utils';
-import { hexToRGBA, RGB_Linear_Shade } from '../../../utils/color-scheme/utils';
-import { SIZE } from '../../../utils/size';
-import { PressableButton, PressableButtonProps } from '../pressable';
+} from "react-native-reanimated";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { showTooltip, TOOLTIP_POSITIONS } from "../../../utils";
+import { hexToRGBA, RGB_Linear_Shade } from "../../../utils/color-scheme/utils";
+import { SIZE } from "../../../utils/size";
+import { PressableButton, PressableButtonProps } from "../pressable";
interface IconButtonProps extends PressableButtonProps {
name: string;
@@ -43,12 +43,12 @@ export const IconButton = ({
bottom = 10,
onLongPress,
tooltipText,
- type = 'gray',
+ type = "gray",
fwdRef,
tooltipPosition = TOOLTIP_POSITIONS.TOP,
...restProps
}: IconButtonProps) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const _onLongPress = (event: GestureResponderEvent) => {
if (onLongPress) {
@@ -71,8 +71,8 @@ export const IconButton = ({
customStyle={{
width: 40,
height: 40,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
borderRadius: 100,
...customStyle
}}
diff --git a/apps/mobile/app/components/ui/input/index.tsx b/apps/mobile/app/components/ui/input/index.tsx
index abab526d3..78c476950 100644
--- a/apps/mobile/app/components/ui/input/index.tsx
+++ b/apps/mobile/app/components/ui/input/index.tsx
@@ -1,4 +1,4 @@
-import React, { RefObject, useState } from 'react';
+import React, { RefObject, useState } from "react";
import {
TouchableOpacity,
TextInput,
@@ -7,26 +7,33 @@ import {
TextInputSubmitEditingEventData,
ColorValue,
ViewStyle
-} from 'react-native';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { useThemeStore } from '../../../stores/use-theme-store';
+} from "react-native";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { useThemeStore } from "../../../stores/use-theme-store";
import {
ERRORS_LIST,
validateEmail,
validatePass,
validateUsername
-} from '../../../services/validation';
-import { getElevation } from '../../../utils';
-import { SIZE } from '../../../utils/size';
-import { IconButton } from '../icon-button';
-import Paragraph from '../typography/paragraph';
+} from "../../../services/validation";
+import { getElevation } from "../../../utils";
+import { SIZE } from "../../../utils/size";
+import { IconButton } from "../icon-button";
+import Paragraph from "../typography/paragraph";
interface InputProps extends TextInputProps {
fwdRef?: RefObject<any>;
- validationType?: 'password' | 'email' | 'confirmPassword' | 'username' | 'phonenumber';
+ validationType?:
+ | "password"
+ | "email"
+ | "confirmPassword"
+ | "username"
+ | "phonenumber";
loading?: boolean;
- onSubmit?: (event: NativeSyntheticEvent<TextInputSubmitEditingEventData>) => void | undefined;
+ onSubmit?: (
+ event: NativeSyntheticEvent<TextInputSubmitEditingEventData>
+ ) => void | undefined;
onErrorCheck?: (error: boolean) => void;
errorMessage?: string;
customColor?: ColorValue;
@@ -46,7 +53,7 @@ interface InputProps extends TextInputProps {
onFocusInput?: () => void;
marginRight?: number;
buttonLeft?: React.ReactNode;
- inputStyle?: TextInputProps['style'];
+ inputStyle?: TextInputProps["style"];
containerStyle?: ViewStyle;
}
@@ -75,7 +82,7 @@ const Input = ({
containerStyle = {},
...restProps
}: InputProps) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [error, setError] = useState(false);
const [focus, setFocus] = useState(false);
const [secureEntry, setSecureEntry] = useState(true);
@@ -88,7 +95,11 @@ const Input = ({
// SPECIAL: true,
});
- const color = error ? colors.red : focus ? customColor || colors.accent : colors.nav;
+ const color = error
+ ? colors.red
+ : focus
+ ? customColor || colors.accent
+ : colors.nav;
const validate = async (value: string) => {
if (!validationType) return;
@@ -103,21 +114,21 @@ const Input = ({
let isError: any = null;
switch (validationType) {
- case 'password':
+ case "password":
isError = validatePass(value);
break;
- case 'email':
+ case "email":
isError = validateEmail(value);
break;
- case 'username':
+ case "username":
isError = validateUsername(value);
break;
- case 'confirmPassword':
+ case "confirmPassword":
isError = customValidator && value === customValidator();
break;
- case 'phonenumber':
+ case "phonenumber":
// eslint-disable-next-line no-case-declarations
- const phone = require('phone').default;
+ const phone = require("phone").default;
// eslint-disable-next-line no-case-declarations
let result = phone(value, {
strictDetection: true,
@@ -132,10 +143,10 @@ const Input = ({
break;
}
- if (validationType === 'password') {
+ if (validationType === "password") {
let hasError = false;
- Object.keys(isError).forEach(e => {
+ Object.keys(isError).forEach((e) => {
if (isError[e] === true) {
hasError = true;
}
@@ -173,9 +184,9 @@ const Input = ({
borderWidth: 1,
borderRadius: 5,
borderColor: color,
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
flexGrow: 1,
height: height || 50,
paddingHorizontal: 12,
@@ -183,7 +194,7 @@ const Input = ({
...containerStyle
};
- const textStyle: TextInputProps['style'] = {
+ const textStyle: TextInputProps["style"] = {
paddingHorizontal: 0,
fontSize: fontSize,
color: onPress && loading ? colors.accent : colors.pri,
@@ -192,7 +203,7 @@ const Input = ({
flexGrow: 1,
height: height || 50,
flexShrink: 1,
- fontFamily: 'OpenSans-Regular',
+ fontFamily: "OpenSans-Regular",
//@ts-ignore
...inputStyle
};
@@ -209,7 +220,12 @@ const Input = ({
marginRight: marginRight
}}
>
- <TouchableOpacity disabled={!loading} onPress={onPress} activeOpacity={1} style={style}>
+ <TouchableOpacity
+ disabled={!loading}
+ onPress={onPress}
+ activeOpacity={1}
+ style={style}
+ >
{buttonLeft && buttonLeft}
<TextInput
@@ -218,10 +234,14 @@ const Input = ({
editable={!loading}
onChangeText={onChange}
onBlur={onBlur}
- keyboardType={validationType === 'email' ? 'email-address' : restProps.keyboardType}
+ keyboardType={
+ validationType === "email"
+ ? "email-address"
+ : restProps.keyboardType
+ }
importantForAutofill="yes"
importantForAccessibility="yes"
- keyboardAppearance={colors.night ? 'dark' : 'light'}
+ keyboardAppearance={colors.night ? "dark" : "light"}
onFocus={onFocus}
onSubmitEditing={onSubmit}
style={textStyle}
@@ -231,10 +251,10 @@ const Input = ({
<View
style={{
- flexDirection: 'row',
- justifyContent: 'center',
+ flexDirection: "row",
+ justifyContent: "center",
height: 35 > height ? height : 35,
- alignItems: 'center'
+ alignItems: "center"
}}
>
{secureTextEntry && (
@@ -290,7 +310,7 @@ const Input = ({
{error && showError && errorMessage ? (
<View
style={{
- position: 'absolute',
+ position: "absolute",
backgroundColor: colors.nav,
paddingVertical: 3,
paddingHorizontal: 5,
@@ -302,11 +322,15 @@ const Input = ({
<Paragraph
size={SIZE.xs}
style={{
- textAlign: 'right',
- textAlignVertical: 'bottom'
+ textAlign: "right",
+ textAlignVertical: "bottom"
}}
>
- <Icon name="alert-circle-outline" size={SIZE.xs} color={colors.errorText} />{' '}
+ <Icon
+ name="alert-circle-outline"
+ size={SIZE.xs}
+ color={colors.errorText}
+ />{" "}
{errorMessage}
</Paragraph>
</View>
@@ -314,7 +338,7 @@ const Input = ({
</TouchableOpacity>
</View>
- {validationType === 'password' && focus && (
+ {validationType === "password" && focus && (
<View
style={{
marginTop: -5,
@@ -323,21 +347,22 @@ const Input = ({
>
{
//@ts-ignore
- Object.keys(errorList).filter(k => errorList[k] === true).length !== 0
- ? Object.keys(ERRORS_LIST).map(error => (
+ Object.keys(errorList).filter((k) => errorList[k] === true)
+ .length !== 0
+ ? Object.keys(ERRORS_LIST).map((error) => (
<View
//@ts-ignore
key={ERRORS_LIST[error]}
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<Icon
//@ts-ignore
- name={errorList[error] ? 'close' : 'check'}
+ name={errorList[error] ? "close" : "check"}
//@ts-ignore
- color={errorList[error] ? 'red' : 'green'}
+ color={errorList[error] ? "red" : "green"}
/>
<Paragraph style={{ marginLeft: 5 }} size={SIZE.xs}>
diff --git a/apps/mobile/app/components/ui/notice/index.tsx b/apps/mobile/app/components/ui/notice/index.tsx
index b9acc70f3..04a10eb2b 100644
--- a/apps/mobile/app/components/ui/notice/index.tsx
+++ b/apps/mobile/app/components/ui/notice/index.tsx
@@ -1,29 +1,34 @@
-import React from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { SIZE } from '../../../utils/size';
-import { IconButton } from '../icon-button';
-import Paragraph from '../typography/paragraph';
+import React from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { SIZE } from "../../../utils/size";
+import { IconButton } from "../icon-button";
+import Paragraph from "../typography/paragraph";
export interface NoticeProps {
- type?: 'alert' | 'information';
+ type?: "alert" | "information";
text: string;
- size?: 'small' | 'large';
+ size?: "small" | "large";
selectable?: boolean;
}
-export const Notice = ({ type = 'alert', text, size = 'large', selectable }: NoticeProps) => {
- const colors = useThemeStore(state => state.colors);
- const isSmall = size === 'small';
+export const Notice = ({
+ type = "alert",
+ text,
+ size = "large",
+ selectable
+}: NoticeProps) => {
+ const colors = useThemeStore((state) => state.colors);
+ const isSmall = size === "small";
return (
<View
style={{
padding: 12,
- flexDirection: 'row',
+ flexDirection: "row",
backgroundColor: colors.nav,
borderRadius: isSmall ? 5 : 10,
- alignItems: 'flex-start'
+ alignItems: "flex-start"
}}
>
<IconButton
@@ -32,9 +37,9 @@ export const Notice = ({ type = 'alert', text, size = 'large', selectable }: Not
customStyle={{
width: isSmall ? undefined : 40,
height: isSmall ? undefined : 40,
- alignSelf: 'flex-start'
+ alignSelf: "flex-start"
}}
- color={type === 'alert' ? colors.errorText : colors.accent}
+ color={type === "alert" ? colors.errorText : colors.accent}
/>
<Paragraph
style={{
diff --git a/apps/mobile/app/components/ui/pressable/index.tsx b/apps/mobile/app/components/ui/pressable/index.tsx
index 2f8f36f8a..8eec3e8dd 100644
--- a/apps/mobile/app/components/ui/pressable/index.tsx
+++ b/apps/mobile/app/components/ui/pressable/index.tsx
@@ -1,4 +1,4 @@
-import React, { RefObject, useCallback } from 'react';
+import React, { RefObject, useCallback } from "react";
import {
ColorValue,
Pressable,
@@ -6,19 +6,19 @@ import {
PressableStateCallbackType,
View,
ViewStyle
-} from 'react-native';
-import Animated from 'react-native-reanimated';
-import { ThemeStore, useThemeStore } from '../../../stores/use-theme-store';
-import { hexToRGBA, RGB_Linear_Shade } from '../../../utils/color-scheme/utils';
-import { BUTTON_TYPES } from '../../../utils/constants';
-import { br } from '../../../utils/size';
+} from "react-native";
+import Animated from "react-native-reanimated";
+import { ThemeStore, useThemeStore } from "../../../stores/use-theme-store";
+import { hexToRGBA, RGB_Linear_Shade } from "../../../utils/color-scheme/utils";
+import { BUTTON_TYPES } from "../../../utils/constants";
+import { br } from "../../../utils/size";
export interface PressableButtonProps extends PressableProps {
customStyle?: ViewStyle;
noborder?: boolean;
type?: keyof typeof BUTTON_TYPES;
- accentColor?: keyof ThemeStore['colors'];
- accentText?: keyof ThemeStore['colors'];
+ accentColor?: keyof ThemeStore["colors"];
+ accentText?: keyof ThemeStore["colors"];
customColor?: ColorValue;
customSelectedColor?: ColorValue;
customAlpha?: number;
@@ -35,10 +35,10 @@ export const PressableButton = ({
hitSlop,
testID,
disabled,
- type = 'gray',
+ type = "gray",
noborder,
- accentColor = 'accent',
- accentText = 'light',
+ accentColor = "accent",
+ accentText = "light",
customColor,
customSelectedColor,
customAlpha,
@@ -46,13 +46,13 @@ export const PressableButton = ({
fwdRef,
animatedViewProps
}: PressableButtonProps) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const selectedColor =
customSelectedColor ||
//@ts-ignore
colors[
- type === 'accent'
+ type === "accent"
? BUTTON_TYPES[type](accentColor, accentText).selected
: BUTTON_TYPES[type].selected
];
@@ -60,13 +60,13 @@ export const PressableButton = ({
customColor ||
//@ts-ignore
colors[
- type === 'accent'
+ type === "accent"
? BUTTON_TYPES[type](accentColor, accentText).primary
: BUTTON_TYPES[type].primary
];
const opacity = customOpacity
? customOpacity
- : type === 'accent'
+ : type === "accent"
? 1
: //@ts-ignore
BUTTON_TYPES[type].opacity;
@@ -78,11 +78,11 @@ export const PressableButton = ({
backgroundColor: pressed
? RGB_Linear_Shade(alpha, hexToRGBA(selectedColor, opacity || 1))
: hexToRGBA(primaryColor, opacity || 1 - 0.02),
- width: '100%',
- alignSelf: 'center',
+ width: "100%",
+ alignSelf: "center",
borderRadius: noborder ? 0 : br,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
marginBottom: 0
},
customStyle
diff --git a/apps/mobile/app/components/ui/seperator/index.tsx b/apps/mobile/app/components/ui/seperator/index.tsx
index 7f88e0598..338553089 100644
--- a/apps/mobile/app/components/ui/seperator/index.tsx
+++ b/apps/mobile/app/components/ui/seperator/index.tsx
@@ -1,5 +1,5 @@
-import React from 'react';
-import { View } from 'react-native';
+import React from "react";
+import { View } from "react-native";
const Seperator = ({ half = false }) => {
return (
diff --git a/apps/mobile/app/components/ui/sheet/index.js b/apps/mobile/app/components/ui/sheet/index.js
index f7a8d45a5..640a215e4 100644
--- a/apps/mobile/app/components/ui/sheet/index.js
+++ b/apps/mobile/app/components/ui/sheet/index.js
@@ -1,12 +1,12 @@
-import React from 'react';
-import { Platform, View } from 'react-native';
-import ActionSheet from 'react-native-actions-sheet';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useSettingStore } from '../../../stores/use-setting-store';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { PremiumToast } from '../../premium/premium-toast';
-import { Toast } from '../../toast';
-import { BouncingView } from '../transitions/bouncing-view';
+import React from "react";
+import { Platform, View } from "react-native";
+import ActionSheet from "react-native-actions-sheet";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { useSettingStore } from "../../../stores/use-setting-store";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { PremiumToast } from "../../premium/premium-toast";
+import { Toast } from "../../toast";
+import { BouncingView } from "../transitions/bouncing-view";
const SheetWrapper = ({
children,
@@ -20,13 +20,15 @@ const SheetWrapper = ({
overlay,
overlayOpacity = 0.3
}) => {
- const colors = useThemeStore(state => state.colors);
- const deviceMode = useSettingStore(state => state.deviceMode);
- const sheetKeyboardHandler = useSettingStore(state => state.sheetKeyboardHandler);
- const largeTablet = deviceMode === 'tablet';
- const smallTablet = deviceMode === 'smallTablet';
- const dimensions = useSettingStore(state => state.dimensions);
- const pitchBlack = useSettingStore(state => state.settings.pitchBlack);
+ const colors = useThemeStore((state) => state.colors);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
+ const sheetKeyboardHandler = useSettingStore(
+ (state) => state.sheetKeyboardHandler
+ );
+ const largeTablet = deviceMode === "tablet";
+ const smallTablet = deviceMode === "smallTablet";
+ const dimensions = useSettingStore((state) => state.dimensions);
+ const pitchBlack = useSettingStore((state) => state.settings.pitchBlack);
const insets = useSafeAreaInsets();
@@ -34,14 +36,14 @@ const SheetWrapper = ({
const style = React.useMemo(() => {
return {
- width: largeTablet || smallTablet ? width : '100%',
+ width: largeTablet || smallTablet ? width : "100%",
backgroundColor: colors.bg,
zIndex: 10,
paddingTop: 5,
paddingBottom: 0,
borderTopRightRadius: 10,
borderTopLeftRadius: 10,
- alignSelf: 'center',
+ alignSelf: "center",
borderBottomRightRadius: 0,
borderBottomLeftRadius: 0
};
@@ -61,7 +63,7 @@ const SheetWrapper = ({
<ActionSheet
ref={fwdRef}
testIDs={{
- backdrop: 'sheet-backdrop'
+ backdrop: "sheet-backdrop"
}}
drawUnderStatusBar={false}
containerStyle={style}
@@ -76,13 +78,17 @@ const SheetWrapper = ({
onOpen={_onOpen}
keyboardDismissMode="none"
defaultOverlayOpacity={overlayOpacity}
- overlayColor={pitchBlack ? '#585858' : '#000000'}
+ overlayColor={pitchBlack ? "#585858" : "#000000"}
keyboardShouldPersistTaps="always"
ExtraOverlayComponent={
<>
{overlay}
<Toast context="local" />
- <PremiumToast context="sheet" close={() => fwdRef?.current?.hide()} offset={50} />
+ <PremiumToast
+ context="sheet"
+ close={() => fwdRef?.current?.hide()}
+ offset={50}
+ />
</>
}
onClose={_onClose}
@@ -91,7 +97,10 @@ const SheetWrapper = ({
{children}
<View
style={{
- height: Platform.OS === 'ios' && insets.bottom !== 0 ? insets.bottom + 5 : 20
+ height:
+ Platform.OS === "ios" && insets.bottom !== 0
+ ? insets.bottom + 5
+ : 20
}}
/>
</BouncingView>
diff --git a/apps/mobile/app/components/ui/svg/index.tsx b/apps/mobile/app/components/ui/svg/index.tsx
index 47e820fa4..ceb482b10 100644
--- a/apps/mobile/app/components/ui/svg/index.tsx
+++ b/apps/mobile/app/components/ui/svg/index.tsx
@@ -1,6 +1,6 @@
-import React from 'react';
-import { View } from 'react-native';
-import { SvgXml } from './lazy';
+import React from "react";
+import { View } from "react-native";
+import { SvgXml } from "./lazy";
export const SvgView = ({
width = 250,
diff --git a/apps/mobile/app/components/ui/svg/lazy.js b/apps/mobile/app/components/ui/svg/lazy.js
index a190e56a7..d86427b8a 100644
--- a/apps/mobile/app/components/ui/svg/lazy.js
+++ b/apps/mobile/app/components/ui/svg/lazy.js
@@ -1,5 +1,5 @@
-import React from 'react';
-import module_svg from './module-svg';
+import React from "react";
+import module_svg from "./module-svg";
export const QRCode = module_svg.QRCode;
diff --git a/apps/mobile/app/components/ui/svg/module-svg.js b/apps/mobile/app/components/ui/svg/module-svg.js
index 6a34cac0f..653332c9f 100644
--- a/apps/mobile/app/components/ui/svg/module-svg.js
+++ b/apps/mobile/app/components/ui/svg/module-svg.js
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */
-import { Bar, Circle } from 'react-native-progress';
-import QRCode from 'react-native-qrcode-svg';
-import { SvgXml } from 'react-native-svg';
+import { Bar, Circle } from "react-native-progress";
+import QRCode from "react-native-qrcode-svg";
+import { SvgXml } from "react-native-svg";
const Progress = {
Bar,
diff --git a/apps/mobile/app/components/ui/time-since/index.tsx b/apps/mobile/app/components/ui/time-since/index.tsx
index e871931c0..2350b81fd 100644
--- a/apps/mobile/app/components/ui/time-since/index.tsx
+++ b/apps/mobile/app/components/ui/time-since/index.tsx
@@ -1,14 +1,18 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { TextProps } from 'react-native';
-import { timeSince } from '../../../utils/time';
-import Paragraph from '../typography/paragraph';
+import React, { useEffect, useRef, useState } from "react";
+import { TextProps } from "react-native";
+import { timeSince } from "../../../utils/time";
+import Paragraph from "../typography/paragraph";
interface TimeSinceProps extends TextProps {
updateFrequency: number;
time: number;
}
-export const TimeSince = ({ time, style, updateFrequency = 30000 }: TimeSinceProps) => {
+export const TimeSince = ({
+ time,
+ style,
+ updateFrequency = 30000
+}: TimeSinceProps) => {
const [timeAgo, setTimeAgo] = useState<string | null>(null);
const interval = useRef<NodeJS.Timer>();
diff --git a/apps/mobile/app/components/ui/transitions/bouncing-view.js b/apps/mobile/app/components/ui/transitions/bouncing-view.js
index 5ba82ff2a..7141e9f75 100644
--- a/apps/mobile/app/components/ui/transitions/bouncing-view.js
+++ b/apps/mobile/app/components/ui/transitions/bouncing-view.js
@@ -1,10 +1,10 @@
-import React, { useEffect } from 'react';
+import React, { useEffect } from "react";
import Animated, {
Easing,
useAnimatedStyle,
useSharedValue,
withTiming
-} from 'react-native-reanimated';
+} from "react-native-reanimated";
export const BouncingView = ({
children,
@@ -34,5 +34,7 @@ export const BouncingView = ({
});
}, []);
- return <Animated.View style={[style, animatedStyle]}>{children}</Animated.View>;
+ return (
+ <Animated.View style={[style, animatedStyle]}>{children}</Animated.View>
+ );
};
diff --git a/apps/mobile/app/components/ui/typography/heading.tsx b/apps/mobile/app/components/ui/typography/heading.tsx
index 2df48f7cd..f61ca7a20 100644
--- a/apps/mobile/app/components/ui/typography/heading.tsx
+++ b/apps/mobile/app/components/ui/typography/heading.tsx
@@ -1,9 +1,12 @@
-import React, { useMemo } from 'react';
-import { Platform, TextProps } from 'react-native';
-import { Text } from 'react-native';
-import Animated, { ComplexAnimationBuilder, Layout } from 'react-native-reanimated';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { SIZE } from '../../../utils/size';
+import React, { useMemo } from "react";
+import { Platform, TextProps } from "react-native";
+import { Text } from "react-native";
+import Animated, {
+ ComplexAnimationBuilder,
+ Layout
+} from "react-native-reanimated";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { SIZE } from "../../../utils/size";
interface HeadingProps extends TextProps {
color?: string;
@@ -14,8 +17,14 @@ interface HeadingProps extends TextProps {
const AnimatedText = Animated.createAnimatedComponent(Text);
-const Heading = ({ color, size = SIZE.xl, style, animated, ...restProps }: HeadingProps) => {
- const colors = useThemeStore(state => state.colors);
+const Heading = ({
+ color,
+ size = SIZE.xl,
+ style,
+ animated,
+ ...restProps
+}: HeadingProps) => {
+ const colors = useThemeStore((state) => state.colors);
const Component = useMemo(() => (animated ? AnimatedText : Text), [animated]);
return (
@@ -28,8 +37,9 @@ const Heading = ({ color, size = SIZE.xl, style, animated, ...restProps }: Headi
{
fontSize: size || SIZE.xl,
color: color || colors.heading,
- fontFamily: Platform.OS === 'android' ? 'OpenSans-SemiBold' : undefined,
- fontWeight: Platform.OS === 'ios' ? '600' : undefined
+ fontFamily:
+ Platform.OS === "android" ? "OpenSans-SemiBold" : undefined,
+ fontWeight: Platform.OS === "ios" ? "600" : undefined
},
style
]}
diff --git a/apps/mobile/app/components/ui/typography/paragraph.tsx b/apps/mobile/app/components/ui/typography/paragraph.tsx
index 641405cee..62a72377a 100644
--- a/apps/mobile/app/components/ui/typography/paragraph.tsx
+++ b/apps/mobile/app/components/ui/typography/paragraph.tsx
@@ -1,8 +1,11 @@
-import React, { useMemo } from 'react';
-import { Text, TextProps } from 'react-native';
-import Animated, { ComplexAnimationBuilder, Layout } from 'react-native-reanimated';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { SIZE } from '../../../utils/size';
+import React, { useMemo } from "react";
+import { Text, TextProps } from "react-native";
+import Animated, {
+ ComplexAnimationBuilder,
+ Layout
+} from "react-native-reanimated";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { SIZE } from "../../../utils/size";
interface ParagraphProps extends TextProps {
color?: string;
size?: number;
@@ -11,8 +14,14 @@ interface ParagraphProps extends TextProps {
}
const AnimatedText = Animated.createAnimatedComponent(Text);
-const Paragraph = ({ color, size = SIZE.sm, style, animated, ...restProps }: ParagraphProps) => {
- const colors = useThemeStore(state => state.colors);
+const Paragraph = ({
+ color,
+ size = SIZE.sm,
+ style,
+ animated,
+ ...restProps
+}: ParagraphProps) => {
+ const colors = useThemeStore((state) => state.colors);
const Component = useMemo(() => (animated ? AnimatedText : Text), [animated]);
return (
@@ -25,8 +34,8 @@ const Paragraph = ({ color, size = SIZE.sm, style, animated, ...restProps }: Par
{
fontSize: size || SIZE.sm,
color: color || colors.pri,
- fontWeight: '400',
- fontFamily: 'OpenSans-Regular'
+ fontWeight: "400",
+ fontFamily: "OpenSans-Regular"
},
style
]}
diff --git a/apps/mobile/app/components/walkthroughs/index.tsx b/apps/mobile/app/components/walkthroughs/index.tsx
index 0a79908be..75ce7fd08 100644
--- a/apps/mobile/app/components/walkthroughs/index.tsx
+++ b/apps/mobile/app/components/walkthroughs/index.tsx
@@ -1,22 +1,28 @@
-import React, { useState } from 'react';
-import { LayoutAnimation, View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eSendEvent, presentSheet } from '../../services/event-manager';
-import { eCloseProgressDialog } from '../../utils/events';
-import { MMKV } from '../../common/database/mmkv';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
-import { Button } from '../ui/button';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
-import walkthroughs, { TStep } from './walkthroughs';
+import React, { useState } from "react";
+import { LayoutAnimation, View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { eSendEvent, presentSheet } from "../../services/event-manager";
+import { eCloseProgressDialog } from "../../utils/events";
+import { MMKV } from "../../common/database/mmkv";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
+import { Button } from "../ui/button";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
+import walkthroughs, { TStep } from "./walkthroughs";
-export const Walkthrough = ({ steps, canSkip = true }: { steps: TStep[]; canSkip: boolean }) => {
- const colors = useThemeStore(state => state.colors);
+export const Walkthrough = ({
+ steps,
+ canSkip = true
+}: {
+ steps: TStep[];
+ canSkip: boolean;
+}) => {
+ const colors = useThemeStore((state) => state.colors);
const [step, setStep] = useState<TStep>(steps && steps[0]);
const next = () => {
- let index = steps.findIndex(s => s.text === step.text);
+ let index = steps.findIndex((s) => s.text === step.text);
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
setStep(steps[index + 1]);
};
@@ -24,8 +30,8 @@ export const Walkthrough = ({ steps, canSkip = true }: { steps: TStep[]; canSkip
return (
<View
style={{
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
padding: 12,
paddingBottom: 0
}}
@@ -36,9 +42,9 @@ export const Walkthrough = ({ steps, canSkip = true }: { steps: TStep[]; canSkip
{step.text ? (
<Paragraph
style={{
- textAlign: 'center',
- alignSelf: 'center',
- maxWidth: '80%'
+ textAlign: "center",
+ alignSelf: "center",
+ maxWidth: "80%"
}}
size={SIZE.md}
>
@@ -53,7 +59,7 @@ export const Walkthrough = ({ steps, canSkip = true }: { steps: TStep[]; canSkip
marginTop: 10
}}
textStyle={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
onPress={async () => {
step.actionButton?.action();
@@ -72,10 +78,10 @@ export const Walkthrough = ({ steps, canSkip = true }: { steps: TStep[]; canSkip
}}
onPress={async () => {
switch (step.button?.type) {
- case 'next':
+ case "next":
next();
return;
- case 'done':
+ case "done":
eSendEvent(eCloseProgressDialog);
await sleep(300);
step.button?.action && step.button.action();
@@ -95,7 +101,7 @@ export const Walkthrough = ({ steps, canSkip = true }: { steps: TStep[]; canSkip
marginTop: 10
}}
textStyle={{
- textDecorationLine: 'underline'
+ textDecorationLine: "underline"
}}
onPress={async () => {
eSendEvent(eCloseProgressDialog);
@@ -109,15 +115,17 @@ export const Walkthrough = ({ steps, canSkip = true }: { steps: TStep[]; canSkip
};
let walkthroughState: { [name: string]: boolean } = {};
-Walkthrough.update = async (id: 'notebooks' | 'trialstarted' | 'emailconfirmed' | 'prouser') => {
- console.log('walkthrough state', walkthroughState);
+Walkthrough.update = async (
+ id: "notebooks" | "trialstarted" | "emailconfirmed" | "prouser"
+) => {
+ console.log("walkthrough state", walkthroughState);
if (walkthroughState[id]) return;
walkthroughState[id] = true;
- MMKV.setItem('walkthroughState', JSON.stringify(walkthroughState));
+ MMKV.setItem("walkthroughState", JSON.stringify(walkthroughState));
};
Walkthrough.init = async () => {
- let json = MMKV.getString('walkthroughState');
+ let json = MMKV.getString("walkthroughState");
if (json) {
walkthroughState = JSON.parse(json);
console.log(walkthroughState);
@@ -125,13 +133,13 @@ Walkthrough.init = async () => {
};
Walkthrough.present = async (
- id: 'notebooks' | 'trialstarted' | 'emailconfirmed' | 'prouser',
+ id: "notebooks" | "trialstarted" | "emailconfirmed" | "prouser",
canSkip = true,
nopersist?: boolean
) => {
if (!nopersist) {
if (!walkthroughState || Object.keys(walkthroughState).length === 0) {
- console.log('late init of walkthrough state');
+ console.log("late init of walkthrough state");
await Walkthrough.init();
}
if (walkthroughState[id]) return;
diff --git a/apps/mobile/app/components/walkthroughs/walkthroughs.tsx b/apps/mobile/app/components/walkthroughs/walkthroughs.tsx
index c6488ddbb..1028889a7 100644
--- a/apps/mobile/app/components/walkthroughs/walkthroughs.tsx
+++ b/apps/mobile/app/components/walkthroughs/walkthroughs.tsx
@@ -1,27 +1,32 @@
-import React from 'react';
-import { Linking, View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { COMMUNITY_SVG, LAUNCH_ROCKET, SUPPORT_SVG, WELCOME_SVG } from '../../assets/images/assets';
-import { ThemeStore, useThemeStore } from '../../stores/use-theme-store';
-import { eSendEvent } from '../../services/event-manager';
-import { getElevation } from '../../utils';
-import { eOpenAddNotebookDialog } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import useRotator from '../../hooks/use-rotator';
-import { AccentColorPicker } from '../../screens/settings/appearance';
-import { Button } from '../ui/button';
-import { SvgView } from '../ui/svg';
-import { PinItem } from '../side-menu/pinned-section';
-import Seperator from '../ui/seperator';
-import Heading from '../ui/typography/heading';
-import Paragraph from '../ui/typography/paragraph';
+import React from "react";
+import { Linking, View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import {
+ COMMUNITY_SVG,
+ LAUNCH_ROCKET,
+ SUPPORT_SVG,
+ WELCOME_SVG
+} from "../../assets/images/assets";
+import { ThemeStore, useThemeStore } from "../../stores/use-theme-store";
+import { eSendEvent } from "../../services/event-manager";
+import { getElevation } from "../../utils";
+import { eOpenAddNotebookDialog } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import useRotator from "../../hooks/use-rotator";
+import { AccentColorPicker } from "../../screens/settings/appearance";
+import { Button } from "../ui/button";
+import { SvgView } from "../ui/svg";
+import { PinItem } from "../side-menu/pinned-section";
+import Seperator from "../ui/seperator";
+import Heading from "../ui/typography/heading";
+import Paragraph from "../ui/typography/paragraph";
export type TStep = {
text?: string;
- walkthroughItem: (colors: ThemeStore['colors']) => React.ReactNode;
+ walkthroughItem: (colors: ThemeStore["colors"]) => React.ReactNode;
title?: string;
button?: {
- type: 'next' | 'done';
+ type: "next" | "done";
title: string;
action?: () => void;
};
@@ -32,21 +37,21 @@ export type TStep = {
};
const NotebookWelcome = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const data = useRotator([
{
- title: 'Work and office',
- description: 'Everything related to my job',
+ title: "Work and office",
+ description: "Everything related to my job",
count: 2
},
{
- title: 'School work',
+ title: "School work",
description: "I don't like doing this but I have to.",
count: 5
},
{
- title: 'Recipies',
- description: 'I love cooking and collecting recipies',
+ title: "Recipies",
+ description: "I love cooking and collecting recipies",
count: 10
}
]);
@@ -54,7 +59,7 @@ const NotebookWelcome = () => {
return (
<View
style={{
- width: '100%',
+ width: "100%",
padding: 12,
backgroundColor: colors.nav,
borderRadius: 10
@@ -63,7 +68,7 @@ const NotebookWelcome = () => {
<View
style={{
padding: 12,
- width: '100%',
+ width: "100%",
backgroundColor: colors.bg,
...getElevation(3),
borderRadius: 10,
@@ -90,24 +95,24 @@ const NotebookWelcome = () => {
};
const notebooks: { id: string; steps: TStep[] } = {
- id: 'notebooks',
+ id: "notebooks",
steps: [
{
- title: 'Notebooks',
- text: 'Boost your productivity with Notebooks and organize your notes.',
+ title: "Notebooks",
+ text: "Boost your productivity with Notebooks and organize your notes.",
walkthroughItem: () => <NotebookWelcome />,
button: {
- type: 'next',
- title: 'Next'
+ type: "next",
+ title: "Next"
}
},
{
- title: 'Notebook > Topic > Notes',
- text: 'Every Notebook has various topics which are like sections that hold all your notes.',
- walkthroughItem: (colors: ThemeStore['colors']) => (
+ title: "Notebook > Topic > Notes",
+ text: "Every Notebook has various topics which are like sections that hold all your notes.",
+ walkthroughItem: (colors: ThemeStore["colors"]) => (
<View
style={{
- width: '100%',
+ width: "100%",
padding: 12,
backgroundColor: colors.nav,
borderRadius: 10
@@ -116,7 +121,7 @@ const notebooks: { id: string; steps: TStep[] } = {
<View
style={{
padding: 12,
- width: '100%',
+ width: "100%",
backgroundColor: colors.bg,
...getElevation(3),
borderRadius: 10,
@@ -141,71 +146,75 @@ const notebooks: { id: string; steps: TStep[] } = {
<View
style={{
padding: 12,
- width: '90%',
+ width: "90%",
backgroundColor: colors.bg,
borderRadius: 10,
- alignSelf: 'flex-end',
+ alignSelf: "flex-end",
marginBottom: 10
}}
>
<Paragraph color={colors.accent}>
- <Icon color={colors.accent} size={SIZE.sm} name="bookmark" /> Tasks
+ <Icon color={colors.accent} size={SIZE.sm} name="bookmark" />{" "}
+ Tasks
</Paragraph>
</View>
<View
style={{
padding: 12,
paddingVertical: 12,
- width: '80%',
+ width: "80%",
backgroundColor: colors.bg,
borderRadius: 5,
- alignSelf: 'flex-end',
+ alignSelf: "flex-end",
marginBottom: 10
}}
>
<Paragraph size={SIZE.xs}>
- <Icon color={colors.icon} size={SIZE.sm} name="note" /> Feburary 2022 Week 2
+ <Icon color={colors.icon} size={SIZE.sm} name="note" /> Feburary
+ 2022 Week 2
</Paragraph>
</View>
<View
style={{
padding: 12,
- width: '80%',
+ width: "80%",
backgroundColor: colors.bg,
borderRadius: 5,
paddingVertical: 12,
- alignSelf: 'flex-end',
+ alignSelf: "flex-end",
marginBottom: 10
}}
>
<Paragraph size={SIZE.xs}>
- <Icon color={colors.icon} size={SIZE.sm} name="note" /> Feburary 2022 Week 1
+ <Icon color={colors.icon} size={SIZE.sm} name="note" /> Feburary
+ 2022 Week 1
</Paragraph>
</View>
<View
style={{
padding: 12,
- width: '90%',
+ width: "90%",
backgroundColor: colors.bg,
borderRadius: 10,
- alignSelf: 'flex-end',
+ alignSelf: "flex-end",
marginBottom: 10
}}
>
<Paragraph color={colors.accent}>
- <Icon color={colors.accent} size={SIZE.sm} name="bookmark" /> Meetings
+ <Icon color={colors.accent} size={SIZE.sm} name="bookmark" />{" "}
+ Meetings
</Paragraph>
</View>
</View>
),
button: {
- type: 'next',
- title: 'Next'
+ type: "next",
+ title: "Next"
}
},
{
- title: 'Easy access',
- text: 'You can create shortcuts of frequently accessed notebooks or topics in Side Menu',
+ title: "Easy access",
+ text: "You can create shortcuts of frequently accessed notebooks or topics in Side Menu",
walkthroughItem: () => (
<View
style={{
@@ -217,8 +226,8 @@ const notebooks: { id: string; steps: TStep[] } = {
index={0}
placeholder={true}
item={{
- title: 'Tasks',
- type: 'topic'
+ title: "Tasks",
+ type: "topic"
}}
onPress={() => {}}
/>
@@ -227,16 +236,16 @@ const notebooks: { id: string; steps: TStep[] } = {
index={1}
placeholder={true}
item={{
- title: 'Work and office',
- type: 'notebook'
+ title: "Work and office",
+ type: "notebook"
}}
onPress={() => {}}
/>
</View>
),
button: {
- type: 'done',
- title: 'Add your first notebook',
+ type: "done",
+ title: "Add your first notebook",
action: () => {
eSendEvent(eOpenAddNotebookDialog);
}
@@ -246,13 +255,13 @@ const notebooks: { id: string; steps: TStep[] } = {
};
const ChooseTheme = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<View
style={{
maxHeight: 170,
- alignItems: 'center',
+ alignItems: "center",
marginTop: 20
}}
>
@@ -260,9 +269,9 @@ const ChooseTheme = () => {
<Paragraph
style={{
- textAlign: 'center',
- alignSelf: 'center',
- maxWidth: '80%'
+ textAlign: "center",
+ alignSelf: "center",
+ maxWidth: "80%"
}}
size={SIZE.md}
>
@@ -276,37 +285,37 @@ const ChooseTheme = () => {
};
const trialstarted: { id: string; steps: TStep[] } = {
- id: 'trialstarted',
+ id: "trialstarted",
steps: [
{
- title: 'Your trial is activated',
- text: 'You can use all permium features for free for the next 14 days',
- walkthroughItem: colors => <SvgView src={LAUNCH_ROCKET(colors.pri)} />,
+ title: "Your trial is activated",
+ text: "You can use all permium features for free for the next 14 days",
+ walkthroughItem: (colors) => <SvgView src={LAUNCH_ROCKET(colors.pri)} />,
button: {
- type: 'next',
- title: 'Next'
+ type: "next",
+ title: "Next"
}
},
{
walkthroughItem: () => <ChooseTheme />,
button: {
- type: 'next',
- title: 'Next'
+ type: "next",
+ title: "Next"
}
},
{
- title: 'Join the cause',
- text: 'Meet other privacy-minded people and talk to us directly about your concerns, issues and suggestions.',
- walkthroughItem: colors => <SvgView src={COMMUNITY_SVG(colors.pri)} />,
+ title: "Join the cause",
+ text: "Meet other privacy-minded people and talk to us directly about your concerns, issues and suggestions.",
+ walkthroughItem: (colors) => <SvgView src={COMMUNITY_SVG(colors.pri)} />,
button: {
- type: 'done',
- title: 'Continue'
+ type: "done",
+ title: "Continue"
},
actionButton: {
- text: 'Join Discord Community',
+ text: "Join Discord Community",
action: () => {
- Linking.openURL('https://discord.gg/zQBK97EE22').catch(console.log);
+ Linking.openURL("https://discord.gg/zQBK97EE22").catch(console.log);
}
}
}
@@ -314,50 +323,51 @@ const trialstarted: { id: string; steps: TStep[] } = {
};
const emailconfirmed: { id: string; steps: TStep[] } = {
- id: 'emailconfirmed',
+ id: "emailconfirmed",
steps: [
{
- title: 'Email confirmed',
- text: 'Your email was confirmed successfully. Thank you for choosing end-to-end encrypted note taking.',
- walkthroughItem: colors => <SvgView src={WELCOME_SVG(colors.pri)} />,
+ title: "Email confirmed",
+ text: "Your email was confirmed successfully. Thank you for choosing end-to-end encrypted note taking.",
+ walkthroughItem: (colors) => <SvgView src={WELCOME_SVG(colors.pri)} />,
button: {
- type: 'done',
- title: 'Continue'
+ type: "done",
+ title: "Continue"
}
}
]
};
const Support = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<View
style={{
- width: '100%',
- alignItems: 'center'
+ width: "100%",
+ alignItems: "center"
}}
>
<SvgView src={SUPPORT_SVG()} />
<Heading>Get Priority Support</Heading>
<Paragraph
style={{
- textAlign: 'center'
+ textAlign: "center"
}}
size={SIZE.md}
>
- You can reach out to us via multiple channels if you face an issue or want to just talk.
+ You can reach out to us via multiple channels if you face an issue or
+ want to just talk.
</Paragraph>
<Seperator />
<Button
style={{
- justifyContent: 'flex-start',
+ justifyContent: "flex-start",
marginBottom: 10,
- width: '90%'
+ width: "90%"
}}
onPress={() => {
- Linking.openURL('https://discord.gg/zQBK97EE22').catch(console.log);
+ Linking.openURL("https://discord.gg/zQBK97EE22").catch(console.log);
}}
icon="discord"
type="grayBg"
@@ -366,12 +376,12 @@ const Support = () => {
<Button
style={{
- justifyContent: 'flex-start',
+ justifyContent: "flex-start",
marginBottom: 10,
- width: '90%'
+ width: "90%"
}}
onPress={() => {
- Linking.openURL('https://t.me/notesnook').catch(console.log);
+ Linking.openURL("https://t.me/notesnook").catch(console.log);
}}
icon="telegram"
type="grayBg"
@@ -379,9 +389,9 @@ const Support = () => {
/>
<Button
style={{
- justifyContent: 'flex-start',
+ justifyContent: "flex-start",
marginBottom: 10,
- width: '90%'
+ width: "90%"
}}
icon="bug"
type="grayBg"
@@ -389,9 +399,9 @@ const Support = () => {
/>
<Button
style={{
- justifyContent: 'flex-start',
+ justifyContent: "flex-start",
marginBottom: 10,
- width: '90%'
+ width: "90%"
}}
icon="mail"
type="grayBg"
@@ -402,22 +412,22 @@ const Support = () => {
};
const prouser: { id: string; steps: TStep[] } = {
- id: 'prouser',
+ id: "prouser",
steps: [
{
- title: 'Welcome to Notesnook Pro',
- text: 'Thank you for reaffirming our idea that privacy comes first',
- walkthroughItem: colors => <SvgView src={LAUNCH_ROCKET(colors.pri)} />,
+ title: "Welcome to Notesnook Pro",
+ text: "Thank you for reaffirming our idea that privacy comes first",
+ walkthroughItem: (colors) => <SvgView src={LAUNCH_ROCKET(colors.pri)} />,
button: {
- type: 'next',
- title: 'Next'
+ type: "next",
+ title: "Next"
}
},
{
walkthroughItem: () => <Support />,
button: {
- type: 'done',
- title: 'Continue'
+ type: "done",
+ title: "Continue"
}
}
]
diff --git a/apps/mobile/app/features.ts b/apps/mobile/app/features.ts
index 1a22bf035..71f52a54d 100644
--- a/apps/mobile/app/features.ts
+++ b/apps/mobile/app/features.ts
@@ -1,3 +1,3 @@
-import { FeatureType } from './components/sheets/new-feature';
+import { FeatureType } from "./components/sheets/new-feature";
export const features: FeatureType[] = [];
diff --git a/apps/mobile/app/hooks/use-actions.js b/apps/mobile/app/hooks/use-actions.js
index d39863b50..fa515c341 100644
--- a/apps/mobile/app/hooks/use-actions.js
+++ b/apps/mobile/app/hooks/use-actions.js
@@ -1,12 +1,12 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import React, { useEffect, useState } from 'react';
-import { Platform } from 'react-native';
-import Share from 'react-native-share';
-import { editing, toTXT } from '../utils';
-import { notesnook } from '../../e2e/test.ids';
-import { presentDialog } from '../components/dialog/functions';
-import NoteHistory from '../components/note-history';
-import { MoveNotes } from '../components/sheets/move-notes/movenote';
+import Clipboard from "@react-native-clipboard/clipboard";
+import React, { useEffect, useState } from "react";
+import { Platform } from "react-native";
+import Share from "react-native-share";
+import { editing, toTXT } from "../utils";
+import { notesnook } from "../../e2e/test.ids";
+import { presentDialog } from "../components/dialog/functions";
+import NoteHistory from "../components/note-history";
+import { MoveNotes } from "../components/sheets/move-notes/movenote";
import {
eSendEvent,
eSubscribeEvent,
@@ -14,17 +14,17 @@ import {
openVault,
presentSheet,
ToastEvent
-} from '../services/event-manager';
-import Navigation from '../services/navigation';
-import Notifications from '../services/notifications';
-import { useEditorStore } from '../stores/use-editor-store';
-import { useMenuStore } from '../stores/use-menu-store';
-import { useSelectionStore } from '../stores/use-selection-store';
-import { useTagStore } from '../stores/use-tag-store';
-import { useThemeStore } from '../stores/use-theme-store';
-import { useUserStore } from '../stores/use-user-store';
-import { toggleDarkMode } from '../utils/color-scheme/utils';
-import { db } from '../common/database';
+} from "../services/event-manager";
+import Navigation from "../services/navigation";
+import Notifications from "../services/notifications";
+import { useEditorStore } from "../stores/use-editor-store";
+import { useMenuStore } from "../stores/use-menu-store";
+import { useSelectionStore } from "../stores/use-selection-store";
+import { useTagStore } from "../stores/use-tag-store";
+import { useThemeStore } from "../stores/use-theme-store";
+import { useUserStore } from "../stores/use-user-store";
+import { toggleDarkMode } from "../utils/color-scheme/utils";
+import { db } from "../common/database";
import {
eOpenAddNotebookDialog,
eOpenAddTopicDialog,
@@ -33,28 +33,31 @@ import {
eOpenLoginDialog,
eOpenMoveNoteDialog,
eOpenPublishNoteDialog
-} from '../utils/events';
-import { deleteItems } from '../utils/functions';
-import { sleep } from '../utils/time';
-import useNavigationStore from '../stores/use-navigation-store';
+} from "../utils/events";
+import { deleteItems } from "../utils/functions";
+import { sleep } from "../utils/time";
+import useNavigationStore from "../stores/use-navigation-store";
export const useActions = ({ close = () => null, item }) => {
- const colors = useThemeStore(state => state.colors);
- const clearSelection = useSelectionStore(state => state.clearSelection);
- const setSelectedItem = useSelectionStore(state => state.setSelectedItem);
- const setMenuPins = useMenuStore(state => state.setMenuPins);
- const [isPinnedToMenu, setIsPinnedToMenu] = useState(db.settings.isPinned(item.id));
- console.log(item.readonly, 'readonly');
- const user = useUserStore(state => state.user);
+ const colors = useThemeStore((state) => state.colors);
+ const clearSelection = useSelectionStore((state) => state.clearSelection);
+ const setSelectedItem = useSelectionStore((state) => state.setSelectedItem);
+ const setMenuPins = useMenuStore((state) => state.setMenuPins);
+ const [isPinnedToMenu, setIsPinnedToMenu] = useState(
+ db.settings.isPinned(item.id)
+ );
+ console.log(item.readonly, "readonly");
+ const user = useUserStore((state) => state.user);
const [notifPinned, setNotifPinned] = useState(null);
const alias = item.alias || item.title;
- const isPublished = item.type === 'note' && db.monographs.isPublished(item.id);
+ const isPublished =
+ item.type === "note" && db.monographs.isPublished(item.id);
useEffect(() => {
if (item.id === null) return;
checkNotifPinned();
- if (item.type !== 'note') {
+ if (item.type !== "note") {
setIsPinnedToMenu(db.settings.isPinned(item.id));
}
}, [item]);
@@ -66,7 +69,7 @@ export const useActions = ({ close = () => null, item }) => {
return;
}
- let index = pinned.findIndex(notif => notif.tag === item.id);
+ let index = pinned.findIndex((notif) => notif.tag === item.id);
if (index !== -1) {
setNotifPinned(pinned[index]);
} else {
@@ -76,15 +79,15 @@ export const useActions = ({ close = () => null, item }) => {
const isNoteInTopic = () => {
const currentScreen = useNavigationStore.getState().currentScreen;
- if (item.type !== 'note' || currentScreen.name !== 'TopicNotes') return;
+ if (item.type !== "note" || currentScreen.name !== "TopicNotes") return;
return db.notebooks
.notebook(currentScreen.notebookId)
.topics.topic(currentScreen.id)
.has(item.id);
};
- const onUpdate = async type => {
- if (type === 'unpin') {
+ const onUpdate = async (type) => {
+ if (type === "unpin") {
await sleep(1000);
await Notifications.get();
checkNotifPinned();
@@ -92,10 +95,10 @@ export const useActions = ({ close = () => null, item }) => {
};
useEffect(() => {
- eSubscribeEvent('onUpdate', onUpdate);
+ eSubscribeEvent("onUpdate", onUpdate);
return () => {
- eUnSubscribeEvent('onUpdate', onUpdate);
+ eUnSubscribeEvent("onUpdate", onUpdate);
};
}, [item]);
@@ -117,11 +120,11 @@ export const useActions = ({ close = () => null, item }) => {
close();
await db.notes.note(item.id).favorite();
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes"
);
}
@@ -132,25 +135,25 @@ export const useActions = ({ close = () => null, item }) => {
if (db[`${type}s`].pinned.length === 3 && !item.pinned) {
ToastEvent.show({
heading: `Cannot pin more than 3 ${type}s`,
- type: 'error'
+ type: "error"
});
return;
}
await db[`${type}s`][type](item.id).pin();
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes',
- 'Notebooks'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes",
+ "Notebooks"
);
}
async function pinToNotifications() {
if (!checkNoteSynced()) return;
- console.log('pinToNotifications');
- if (Platform.OS === 'ios') return;
+ console.log("pinToNotifications");
+ if (Platform.OS === "ios") return;
if (notifPinned !== null) {
Notifications.remove(item.id, notifPinned.identifier);
@@ -168,7 +171,7 @@ export const useActions = ({ close = () => null, item }) => {
subtitle: item.headline || text,
bigText: html,
ongoing: true,
- actions: ['UNPIN'],
+ actions: ["UNPIN"],
tag: item.id
});
await sleep(1000);
@@ -181,18 +184,21 @@ export const useActions = ({ close = () => null, item }) => {
close();
await db.trash.restore(item.id);
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes',
- 'Notebooks',
- 'Trash'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes",
+ "Notebooks",
+ "Trash"
);
- let type = item.type === 'trash' ? item.itemType : item.type;
+ let type = item.type === "trash" ? item.itemType : item.type;
ToastEvent.show({
- heading: type === 'note' ? 'Note restored from trash' : 'Notebook restored from trash',
- type: 'success'
+ heading:
+ type === "note"
+ ? "Note restored from trash"
+ : "Notebook restored from trash",
+ type: "success"
});
}
@@ -206,15 +212,15 @@ export const useActions = ({ close = () => null, item }) => {
novault: true,
locked: true,
item: item,
- title: 'Copy note',
- description: 'Unlock note to copy to clipboard.'
+ title: "Copy note",
+ description: "Unlock note to copy to clipboard."
});
} else {
Clipboard.setString(await toTXT(item));
ToastEvent.show({
- heading: 'Note copied to clipboard',
- type: 'success',
- context: 'local'
+ heading: "Note copied to clipboard",
+ type: "success",
+ context: "local"
});
}
}
@@ -223,30 +229,30 @@ export const useActions = ({ close = () => null, item }) => {
if (!checkNoteSynced()) return;
if (!user) {
ToastEvent.show({
- heading: 'Login required',
- message: 'Login to publish note',
- context: 'local',
+ heading: "Login required",
+ message: "Login to publish note",
+ context: "local",
func: () => {
eSendEvent(eOpenLoginDialog);
},
- actionText: 'Login'
+ actionText: "Login"
});
return;
}
if (!user?.isEmailConfirmed) {
ToastEvent.show({
- heading: 'Email is not verified',
- message: 'Please verify your email first.',
- context: 'local'
+ heading: "Email is not verified",
+ message: "Please verify your email first.",
+ context: "local"
});
return;
}
if (item.locked) {
ToastEvent.show({
- heading: 'Locked notes cannot be published',
- type: 'error',
- context: 'local'
+ heading: "Locked notes cannot be published",
+ type: "error",
+ context: "local"
});
return;
}
@@ -256,24 +262,24 @@ export const useActions = ({ close = () => null, item }) => {
}
const checkNoteSynced = () => {
- if (item.type !== 'note' || item.itemType !== 'note') return true;
- let isTrash = item.itemType === 'note';
+ if (item.type !== "note" || item.itemType !== "note") return true;
+ let isTrash = item.itemType === "note";
if (!isTrash && !db.notes.note(item.id).synced()) {
ToastEvent.show({
- context: 'local',
- heading: 'Note not synced',
- message: 'Please run sync before making changes',
- type: 'error'
+ context: "local",
+ heading: "Note not synced",
+ message: "Please run sync before making changes",
+ type: "error"
});
return false;
}
if (isTrash && !db.trash.synced(item.id)) {
ToastEvent.show({
- context: 'local',
- heading: 'Note not synced',
- message: 'Please run sync before making changes',
- type: 'error'
+ context: "local",
+ heading: "Note not synced",
+ message: "Please run sync before making changes",
+ type: "error"
});
return false;
}
@@ -292,8 +298,8 @@ export const useActions = ({ close = () => null, item }) => {
novault: true,
locked: true,
permanant: true,
- title: 'Unlock note',
- description: 'Remove note from the vault.'
+ title: "Unlock note",
+ description: "Remove note from the vault."
});
return;
}
@@ -303,11 +309,11 @@ export const useActions = ({ close = () => null, item }) => {
if (note.locked) {
close();
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes"
);
}
} catch (e) {
@@ -318,8 +324,8 @@ export const useActions = ({ close = () => null, item }) => {
openVault({
item: item,
novault: false,
- title: 'Create vault',
- description: 'Set a password to create a vault and lock note.'
+ title: "Create vault",
+ description: "Set a password to create a vault and lock note."
});
break;
case db.vault.ERRORS.vaultLocked:
@@ -327,8 +333,8 @@ export const useActions = ({ close = () => null, item }) => {
item: item,
novault: true,
locked: true,
- title: 'Lock note',
- description: 'Give access to vault to lock this note.'
+ title: "Lock note",
+ description: "Give access to vault to lock this note."
});
break;
}
@@ -341,7 +347,7 @@ export const useActions = ({ close = () => null, item }) => {
if (isPinnedToMenu) {
await db.settings.unpin(item.id);
} else {
- if (item.type === 'topic') {
+ if (item.type === "topic") {
await db.settings.pin(item.type, {
id: item.id,
notebookId: item.notebookId
@@ -359,26 +365,26 @@ export const useActions = ({ close = () => null, item }) => {
close();
await sleep(300);
presentDialog({
- title: 'Rename tag',
- paragraph: 'Change the title of the tag ' + alias,
- positivePress: async value => {
- if (!value || value === '' || value.trimStart().length == 0) return;
+ title: "Rename tag",
+ paragraph: "Change the title of the tag " + alias,
+ positivePress: async (value) => {
+ if (!value || value === "" || value.trimStart().length == 0) return;
await db.tags.rename(item.id, db.tags.sanitize(value));
useTagStore.getState().setTags();
useMenuStore.getState().setMenuPins();
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes',
- 'Tags'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes",
+ "Tags"
);
},
input: true,
defaultValue: alias,
- inputPlaceholder: 'Enter title of tag',
- positiveText: 'Save'
+ inputPlaceholder: "Enter title of tag",
+ positiveText: "Save"
});
}
@@ -392,12 +398,12 @@ export const useActions = ({ close = () => null, item }) => {
novault: true,
locked: true,
share: true,
- title: 'Share note',
- description: 'Unlock note to share it.'
+ title: "Share note",
+ description: "Unlock note to share it."
});
} else {
Share.open({
- title: 'Share note to',
+ title: "Share note to",
failOnCancel: false,
message: await toTXT(item)
});
@@ -407,25 +413,25 @@ export const useActions = ({ close = () => null, item }) => {
async function deleteItem() {
if (!checkNoteSynced()) return;
close();
- if (item.type === 'tag') {
+ if (item.type === "tag") {
await sleep(300);
presentDialog({
- title: 'Delete tag',
- paragraph: 'This tag will be removed from all notes.',
- positivePress: async value => {
+ title: "Delete tag",
+ paragraph: "This tag will be removed from all notes.",
+ positivePress: async (value) => {
await db.tags.remove(item.id);
useTagStore.getState().setTags();
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes',
- 'Tags'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes",
+ "Tags"
);
},
- positiveText: 'Delete',
- positiveType: 'errorShade'
+ positiveText: "Delete",
+ positiveType: "errorShade"
});
return;
}
@@ -436,32 +442,32 @@ export const useActions = ({ close = () => null, item }) => {
novault: true,
locked: true,
item: item,
- title: 'Delete note',
- description: 'Unlock note to delete it.'
+ title: "Delete note",
+ description: "Unlock note to delete it."
});
} else {
try {
close();
- console.log('moving note to trash');
+ console.log("moving note to trash");
await deleteItems(item);
} catch (e) {}
}
}
async function removeNoteFromTopic() {
const currentScreen = useNavigationStore.getState().currentScreen;
- if (currentScreen.name !== 'TopicNotes') return;
+ if (currentScreen.name !== "TopicNotes") return;
await db.notebooks
.notebook(currentScreen.notebookId)
.topics.topic(currentScreen.id)
.delete(item.id);
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes',
- 'Notebook',
- 'Notebooks'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes",
+ "Notebook",
+ "Notebooks"
);
close();
}
@@ -473,19 +479,19 @@ export const useActions = ({ close = () => null, item }) => {
presentDialog({
title: `Permanent delete`,
paragraph: `Are you sure you want to delete this ${item.itemType} permanantly from trash?`,
- positiveText: 'Delete',
- negativeText: 'Cancel',
+ positiveText: "Delete",
+ negativeText: "Cancel",
positivePress: async () => {
await db.trash.delete(item.id);
- Navigation.queueRoutesForUpdate('Trash');
+ Navigation.queueRoutesForUpdate("Trash");
useSelectionStore.getState().setSelectionMode(false);
ToastEvent.show({
- heading: 'Permanantly deleted items',
- type: 'success',
- context: 'local'
+ heading: "Permanantly deleted items",
+ type: "success",
+ context: "local"
});
},
- positiveType: 'errorShade'
+ positiveType: "errorShade"
});
}
@@ -493,7 +499,7 @@ export const useActions = ({ close = () => null, item }) => {
close();
await sleep(300);
presentSheet({
- component: ref => <NoteHistory fwdRef={ref} note={item} />
+ component: (ref) => <NoteHistory fwdRef={ref} note={item} />
});
}
@@ -513,11 +519,11 @@ export const useActions = ({ close = () => null, item }) => {
if (!checkNoteSynced() || !user) return;
db.notes.note(item.id).localOnly();
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes"
);
close();
}
@@ -530,11 +536,11 @@ export const useActions = ({ close = () => null, item }) => {
// tiny.call(EditorWebView, tiny.toogleReadMode(current ? 'readonly' : 'design'));
}
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes"
);
close();
};
@@ -543,26 +549,26 @@ export const useActions = ({ close = () => null, item }) => {
if (!checkNoteSynced()) return;
await db.notes.note(item.id).duplicate();
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes"
);
close();
};
- console.log('isNoteInTopic', isNoteInTopic());
+ console.log("isNoteInTopic", isNoteInTopic());
const actions = [
{
- name: 'Add to notebook',
- title: 'Add to notebook',
- icon: 'book-outline',
+ name: "Add to notebook",
+ title: "Add to notebook",
+ icon: "book-outline",
func: addTo
},
{
- name: 'Move notes',
- title: 'Add notes',
- icon: 'plus',
+ name: "Move notes",
+ title: "Add notes",
+ icon: "plus",
func: async () => {
close();
await sleep(500);
@@ -571,9 +577,9 @@ export const useActions = ({ close = () => null, item }) => {
},
{
- name: 'Pin',
- title: item.pinned ? 'Unpin' : 'Pin to top',
- icon: item.pinned ? 'pin-off-outline' : 'pin-outline',
+ name: "Pin",
+ title: item.pinned ? "Unpin" : "Pin to top",
+ icon: item.pinned ? "pin-off-outline" : "pin-outline",
func: pinItem,
close: false,
check: true,
@@ -582,29 +588,32 @@ export const useActions = ({ close = () => null, item }) => {
id: notesnook.ids.dialogs.actionsheet.pin
},
{
- name: 'Favorite',
- title: !item.favorite ? 'Favorite' : 'Unfavorite',
- icon: item.favorite ? 'star-off' : 'star-outline',
+ name: "Favorite",
+ title: !item.favorite ? "Favorite" : "Unfavorite",
+ icon: item.favorite ? "star-off" : "star-outline",
func: addToFavorites,
close: false,
check: true,
on: item.favorite,
nopremium: true,
id: notesnook.ids.dialogs.actionsheet.favorite,
- color: 'orange'
+ color: "orange"
},
{
- name: 'PinToNotif',
- title: notifPinned !== null ? 'Unpin from Notifications' : 'Pin to Notifications',
- icon: 'bell',
+ name: "PinToNotif",
+ title:
+ notifPinned !== null
+ ? "Unpin from Notifications"
+ : "Pin to Notifications",
+ icon: "bell",
on: notifPinned !== null,
func: pinToNotifications
},
{
- name: 'Edit Notebook',
- title: 'Edit notebook',
- icon: 'square-edit-outline',
+ name: "Edit Notebook",
+ title: "Edit notebook",
+ icon: "square-edit-outline",
func: async () => {
close();
await sleep(300);
@@ -612,9 +621,9 @@ export const useActions = ({ close = () => null, item }) => {
}
},
{
- name: 'Edit Topic',
- title: 'Edit topic',
- icon: 'square-edit-outline',
+ name: "Edit Topic",
+ title: "Edit topic",
+ icon: "square-edit-outline",
func: async () => {
close();
await sleep(300);
@@ -625,37 +634,37 @@ export const useActions = ({ close = () => null, item }) => {
}
},
{
- name: 'Copy',
- title: 'Copy',
- icon: 'content-copy',
+ name: "Copy",
+ title: "Copy",
+ icon: "content-copy",
func: copyContent
},
{
- name: 'Restore',
- title: 'Restore ' + item.itemType,
- icon: 'delete-restore',
+ name: "Restore",
+ title: "Restore " + item.itemType,
+ icon: "delete-restore",
func: restoreTrashItem
},
{
- name: 'Publish',
- title: isPublished ? 'Published' : 'Publish',
- icon: 'cloud-upload-outline',
+ name: "Publish",
+ title: isPublished ? "Published" : "Publish",
+ icon: "cloud-upload-outline",
on: isPublished,
func: publishNote
},
{
- name: 'Vault',
- title: item.locked ? 'Remove from vault' : 'Add to vault',
- icon: item.locked ? 'shield-off-outline' : 'shield-outline',
+ name: "Vault",
+ title: item.locked ? "Remove from vault" : "Add to vault",
+ icon: item.locked ? "shield-off-outline" : "shield-outline",
func: addToVault,
on: item.locked
},
{
- name: 'Add Shortcut',
- title: isPinnedToMenu ? 'Remove Shortcut' : 'Add Shortcut',
- icon: isPinnedToMenu ? 'link-variant-remove' : 'link-variant',
+ name: "Add Shortcut",
+ title: isPinnedToMenu ? "Remove Shortcut" : "Add Shortcut",
+ icon: isPinnedToMenu ? "link-variant-remove" : "link-variant",
func: createMenuShortcut,
close: false,
check: true,
@@ -664,81 +673,83 @@ export const useActions = ({ close = () => null, item }) => {
id: notesnook.ids.dialogs.actionsheet.pinMenu
},
{
- name: 'Rename Tag',
- title: 'Rename tag',
- icon: 'square-edit-outline',
+ name: "Rename Tag",
+ title: "Rename tag",
+ icon: "square-edit-outline",
func: renameTag
},
{
- name: 'Share',
- title: 'Share',
- icon: 'share-variant',
+ name: "Share",
+ title: "Share",
+ icon: "share-variant",
func: shareNote
},
{
- name: 'Attachments',
- title: 'Attachments',
- icon: 'attachment',
+ name: "Attachments",
+ title: "Attachments",
+ icon: "attachment",
func: showAttachments
},
{
- name: 'Export',
- title: 'Export',
- icon: 'export',
+ name: "Export",
+ title: "Export",
+ icon: "export",
func: exportNote
},
{
- name: 'RemoveTopic',
- title: 'Remove from topic',
+ name: "RemoveTopic",
+ title: "Remove from topic",
hidden: !isNoteInTopic(),
- icon: 'minus-circle-outline',
+ icon: "minus-circle-outline",
func: removeNoteFromTopic
},
{
- name: 'Delete',
+ name: "Delete",
title:
- item.type !== 'notebook' && item.type !== 'note' ? 'Delete ' + item.type : 'Move to trash',
- icon: 'delete-outline',
- type: 'error',
+ item.type !== "notebook" && item.type !== "note"
+ ? "Delete " + item.type
+ : "Move to trash",
+ icon: "delete-outline",
+ type: "error",
func: deleteItem
},
{
- name: 'PermDelete',
- title: 'Delete ' + item.itemType,
- icon: 'delete',
+ name: "PermDelete",
+ title: "Delete " + item.itemType,
+ icon: "delete",
func: deleteTrashItem
},
{
- name: 'ReadOnly',
- title: 'Read only',
- icon: 'pencil-lock',
+ name: "ReadOnly",
+ title: "Read only",
+ icon: "pencil-lock",
func: toggleReadyOnlyMode,
on: item.readonly
},
{
- name: 'Local only',
- title: 'Local only',
- icon: 'sync-off',
+ name: "Local only",
+ title: "Local only",
+ icon: "sync-off",
func: toggleLocalOnly,
on: item.localOnly
},
{
- name: 'History',
- title: 'History',
- icon: 'history',
+ name: "History",
+ title: "History",
+ icon: "history",
func: openHistory
},
{
- name: 'Duplicate',
- title: 'Duplicate',
- icon: 'content-duplicate',
+ name: "Duplicate",
+ title: "Duplicate",
+ icon: "content-duplicate",
func: duplicateNote
},
{
- name: 'Dark Mode',
- title: 'Dark mode',
- icon: 'theme-light-dark',
+ name: "Dark Mode",
+ title: "Dark mode",
+ icon: "theme-light-dark",
func: switchTheme,
switch: true,
on: colors.night ? true : false,
diff --git a/apps/mobile/app/hooks/use-app-events.js b/apps/mobile/app/hooks/use-app-events.js
index b77ef20ce..2dc31bd5e 100644
--- a/apps/mobile/app/hooks/use-app-events.js
+++ b/apps/mobile/app/hooks/use-app-events.js
@@ -1,6 +1,6 @@
-import NetInfo from '@react-native-community/netinfo';
-import { EV, EVENTS } from '@streetwriters/notesnook-core/common';
-import { useEffect, useRef } from 'react';
+import NetInfo from "@react-native-community/netinfo";
+import { EV, EVENTS } from "@streetwriters/notesnook-core/common";
+import { useEffect, useRef } from "react";
import {
Alert,
Appearance,
@@ -9,48 +9,52 @@ import {
NativeEventEmitter,
NativeModules,
Platform
-} from 'react-native';
-import * as RNIap from 'react-native-iap';
-import { enabled } from 'react-native-privacy-snapshot';
-import { Walkthrough } from '../components/walkthroughs';
-import { editorController, editorState } from '../screens/editor/tiptap/utils';
-import BiometricService from '../services/biometrics';
+} from "react-native";
+import * as RNIap from "react-native-iap";
+import { enabled } from "react-native-privacy-snapshot";
+import { Walkthrough } from "../components/walkthroughs";
+import { editorController, editorState } from "../screens/editor/tiptap/utils";
+import BiometricService from "../services/biometrics";
import {
clearMessage,
setEmailVerifyMessage,
setLoginMessage,
setRecoveryKeyMessage
-} from '../services/message';
-import PremiumService from '../services/premium';
-import SettingsService from '../services/settings';
-import { updateStatusBarColor } from '../utils/color-scheme';
-import { db } from '../common/database';
-import { MMKV } from '../common/database/mmkv';
-import { eClearEditor, eCloseProgressDialog, refreshNotesPage } from '../utils/events';
-import Sync from '../services/sync';
-import { clearAllStores, initAfterSync, initialize } from '../stores';
-import { useUserStore } from '../stores/use-user-store';
-import { useMessageStore } from '../stores/use-message-store';
-import { useSettingStore } from '../stores/use-setting-store';
-import { useAttachmentStore } from '../stores/use-attachment-store';
-import { useNoteStore } from '../stores/use-notes-store';
+} from "../services/message";
+import PremiumService from "../services/premium";
+import SettingsService from "../services/settings";
+import { updateStatusBarColor } from "../utils/color-scheme";
+import { db } from "../common/database";
+import { MMKV } from "../common/database/mmkv";
+import {
+ eClearEditor,
+ eCloseProgressDialog,
+ refreshNotesPage
+} from "../utils/events";
+import Sync from "../services/sync";
+import { clearAllStores, initAfterSync, initialize } from "../stores";
+import { useUserStore } from "../stores/use-user-store";
+import { useMessageStore } from "../stores/use-message-store";
+import { useSettingStore } from "../stores/use-setting-store";
+import { useAttachmentStore } from "../stores/use-attachment-store";
+import { useNoteStore } from "../stores/use-notes-store";
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent
-} from '../services/event-manager';
-import { useEditorStore } from '../stores/use-editor-store';
-import { useDragState } from '../screens/settings/editor/state';
-import { sleep } from '../utils/time';
+} from "../services/event-manager";
+import { useEditorStore } from "../stores/use-editor-store";
+import { useDragState } from "../screens/settings/editor/state";
+import { sleep } from "../utils/time";
const SodiumEventEmitter = new NativeEventEmitter(NativeModules.Sodium);
export const useAppEvents = () => {
- const loading = useNoteStore(state => state.loading);
- const setLastSynced = useUserStore(state => state.setLastSynced);
- const setUser = useUserStore(state => state.setUser);
+ const loading = useNoteStore((state) => state.loading);
+ const setLastSynced = useUserStore((state) => state.setLastSynced);
+ const setUser = useUserStore((state) => state.setUser);
const syncedOnLaunch = useRef(false);
- const verify = useUserStore(state => state.verifyUser);
+ const verify = useUserStore((state) => state.verifyUser);
const refValues = useRef({
subsriptionSuccessListener: null,
subsriptionErrorListener: null,
@@ -61,18 +65,22 @@ export const useAppEvents = () => {
isReconnecting: false
});
- const onLoadingAttachmentProgress = data => {
- console.log('loading', data);
- useAttachmentStore.getState().setLoading(data.total === data.current ? null : data);
+ const onLoadingAttachmentProgress = (data) => {
+ console.log("loading", data);
+ useAttachmentStore
+ .getState()
+ .setLoading(data.total === data.current ? null : data);
};
const onFileEncryptionProgress = ({ total, progress }) => {
- console.log('encryption progress: ', (progress / total).toFixed(2));
- useAttachmentStore.getState().setEncryptionProgress((progress / total).toFixed(2));
+ console.log("encryption progress: ", (progress / total).toFixed(2));
+ useAttachmentStore
+ .getState()
+ .setEncryptionProgress((progress / total).toFixed(2));
};
const onSyncProgress = ({ type, total, current }) => {
console.log(type, total, current);
- if (type !== 'download') return;
+ if (type !== "download") return;
if (total < 10 || current % 10 === 0) {
initAfterSync();
}
@@ -83,22 +91,31 @@ export const useAppEvents = () => {
const eventManager = db?.eventManager;
eventManager?.subscribe(EVENTS.syncCompleted, onSyncComplete);
db?.eventManager?.subscribe(EVENTS.syncProgress, onSyncProgress);
- db?.eventManager?.subscribe(EVENTS.databaseSyncRequested, onRequestPartialSync);
+ db?.eventManager?.subscribe(
+ EVENTS.databaseSyncRequested,
+ onRequestPartialSync
+ );
}
return () => {
const eventManager = db?.eventManager;
eventManager?.unsubscribe(EVENTS.syncCompleted, onSyncComplete);
eventManager?.unsubscribe(EVENTS.syncProgress, onSyncProgress);
- eventManager?.unsubscribe(EVENTS.databaseSyncRequested, onRequestPartialSync);
+ eventManager?.unsubscribe(
+ EVENTS.databaseSyncRequested,
+ onRequestPartialSync
+ );
};
}, [loading]);
useEffect(() => {
let subs = [
Appearance.addChangeListener(SettingsService.setTheme),
- Linking.addEventListener('url', onUrlRecieved),
- SodiumEventEmitter.addListener('onSodiumProgress', onFileEncryptionProgress)
+ Linking.addEventListener("url", onUrlRecieved),
+ SodiumEventEmitter.addListener(
+ "onSodiumProgress",
+ onFileEncryptionProgress
+ )
];
EV.subscribe(EVENTS.appRefreshRequested, onSyncComplete);
@@ -108,10 +125,10 @@ export const useAppEvents = () => {
EV.subscribe(EVENTS.userCheckStatus, PremiumService.onUserStatusCheck);
EV.subscribe(EVENTS.userSubscriptionUpdated, onAccountStatusChange);
EV.subscribe(EVENTS.attachmentsLoading, onLoadingAttachmentProgress);
- eSubscribeEvent('userLoggedIn', onUserUpdated);
+ eSubscribeEvent("userLoggedIn", onUserUpdated);
return () => {
- eUnSubscribeEvent('userLoggedIn', onUserUpdated);
+ eUnSubscribeEvent("userLoggedIn", onUserUpdated);
EV.unsubscribe(EVENTS.appRefreshRequested, onSyncComplete);
EV.unsubscribe(EVENTS.userSessionExpired, onSessionExpired);
@@ -122,7 +139,7 @@ export const useAppEvents = () => {
EV.unsubscribe(EVENTS.userSubscriptionUpdated, onAccountStatusChange);
EV.unsubscribeAll();
- subs.forEach(sub => sub?.remove());
+ subs.forEach((sub) => sub?.remove());
};
}, []);
@@ -130,26 +147,27 @@ export const useAppEvents = () => {
await SettingsService.set({
sessionExpired: true
});
- eSendEvent('session_expired');
+ eSendEvent("session_expired");
};
useEffect(() => {
let sub;
if (!loading && !verify) {
setTimeout(() => {
- sub = AppState.addEventListener('change', onAppStateChanged);
+ sub = AppState.addEventListener("change", onAppStateChanged);
}, 1000);
(async () => {
try {
let url = await Linking.getInitialURL();
- if (url?.startsWith('https://app.notesnook.com/account/verified')) {
+ if (url?.startsWith("https://app.notesnook.com/account/verified")) {
await onEmailVerified();
}
await onUserUpdated();
} catch (e) {}
})();
- refValues.current.removeInternetStateListener =
- NetInfo.addEventListener(onInternetStateChanged);
+ refValues.current.removeInternetStateListener = NetInfo.addEventListener(
+ onInternetStateChanged
+ );
}
return () => {
refValues.current?.removeInternetStateListener &&
@@ -159,16 +177,16 @@ export const useAppEvents = () => {
};
}, [loading, verify]);
- const onInternetStateChanged = async state => {
+ const onInternetStateChanged = async (state) => {
if (!syncedOnLaunch.current) return;
reconnectSSE(state);
};
const onSyncComplete = async () => {
- console.log('sync complete');
+ console.log("sync complete");
initAfterSync();
setLastSynced(await db.lastSynced());
- eSendEvent(eCloseProgressDialog, 'sync_progress');
+ eSendEvent(eCloseProgressDialog, "sync_progress");
let id = useEditorStore.getState().currentEditingNote;
let note = id && db.notes.note(id).data;
if (note) {
@@ -176,10 +194,10 @@ export const useAppEvents = () => {
}
};
- const onUrlRecieved = async res => {
- let url = res ? res.url : '';
+ const onUrlRecieved = async (res) => {
+ let url = res ? res.url : "";
try {
- if (url.startsWith('https://app.notesnook.com/account/verified')) {
+ if (url.startsWith("https://app.notesnook.com/account/verified")) {
await onEmailVerified();
} else {
return;
@@ -195,7 +213,7 @@ export const useAppEvents = () => {
userEmailConfirmed: true
});
await PremiumService.setPremiumStatus();
- Walkthrough.present('emailconfirmed', false, true);
+ Walkthrough.present("emailconfirmed", false, true);
if (user?.isEmailConfirmed) {
clearMessage();
}
@@ -203,7 +221,7 @@ export const useAppEvents = () => {
const attachIAPListeners = async () => {
await RNIap.initConnection()
- .catch(e => null)
+ .catch((e) => null)
.then(async () => {
refValues.current.subsriptionSuccessListener =
RNIap.purchaseUpdatedListener(onSuccessfulSubscription);
@@ -212,25 +230,25 @@ export const useAppEvents = () => {
});
};
- const onAccountStatusChange = async userStatus => {
+ const onAccountStatusChange = async (userStatus) => {
if (!PremiumService.get() && userStatus.type === 5) {
PremiumService.subscriptions.clear();
- Walkthrough.present('prouser', false, true);
+ Walkthrough.present("prouser", false, true);
}
await PremiumService.setPremiumStatus();
};
const onRequestPartialSync = async (full, force) => {
- console.log('auto sync request', full, force);
+ console.log("auto sync request", full, force);
if (full || force) {
- await Sync.run('global', force, full);
+ await Sync.run("global", force, full);
} else {
- await Sync.run('global', false, false);
+ await Sync.run("global", false, false);
}
};
- const onLogout = async reason => {
- console.log('LOGOUT', reason);
+ const onLogout = async (reason) => {
+ console.log("LOGOUT", reason);
};
const unsubIAP = () => {
@@ -244,7 +262,7 @@ export const useAppEvents = () => {
}
};
- const onUserUpdated = async login => {
+ const onUserUpdated = async (login) => {
console.log(`onUserUpdated: ${login}`);
let user;
try {
@@ -281,7 +299,7 @@ export const useAppEvents = () => {
});
}
} catch (e) {
- ToastEvent.error(e, 'An error occured', 'global');
+ ToastEvent.error(e, "An error occured", "global");
}
user = await db.user.getUser();
@@ -298,31 +316,31 @@ export const useAppEvents = () => {
syncedOnLaunch.current = true;
};
- const onSuccessfulSubscription = async subscription => {
+ const onSuccessfulSubscription = async (subscription) => {
await PremiumService.subscriptions.set(subscription);
await PremiumService.subscriptions.verify(subscription);
};
- const onSubscriptionError = async error => {
+ const onSubscriptionError = async (error) => {
ToastEvent.show({
- heading: 'Failed to subscribe',
- type: 'error',
+ heading: "Failed to subscribe",
+ type: "error",
message: error.message,
- context: 'local'
+ context: "local"
});
};
- const onAppStateChanged = async state => {
- console.log('onAppStateChanged');
- if (state === 'active') {
+ const onAppStateChanged = async (state) => {
+ console.log("onAppStateChanged");
+ if (state === "active") {
updateStatusBarColor();
if (
- SettingsService.get().appLockMode !== 'background' &&
+ SettingsService.get().appLockMode !== "background" &&
!SettingsService.get().privacyScreen
) {
enabled(false);
}
- if (SettingsService.get().appLockMode === 'background') {
+ if (SettingsService.get().appLockMode === "background") {
if (useSettingStore.getState().requestBiometrics) {
useSettingStore.getState().setRequestBiometrics(false);
return;
@@ -331,7 +349,7 @@ export const useAppEvents = () => {
await reconnectSSE();
await checkIntentState();
- MMKV.removeItem('appState');
+ MMKV.removeItem("appState");
let user = await db.user.getUser();
if (user && !user?.isEmailConfirmed) {
try {
@@ -344,12 +362,12 @@ export const useAppEvents = () => {
} else {
let id = useEditorStore.getState().currentEditingNote;
let note = id && db.notes.note(id).data;
- if (note?.locked && SettingsService.get().appLockMode === 'background') {
+ if (note?.locked && SettingsService.get().appLockMode === "background") {
eSendEvent(eClearEditor);
}
await storeAppState();
if (
- SettingsService.get().appLockMode === 'background' &&
+ SettingsService.get().appLockMode === "background" &&
!useSettingStore.getState().requestBiometrics &&
!useUserStore.getState().verifyUser
) {
@@ -357,7 +375,7 @@ export const useAppEvents = () => {
}
if (
SettingsService.get().privacyScreen ||
- SettingsService.get().appLockMode === 'background'
+ SettingsService.get().appLockMode === "background"
) {
!useSettingStore.getState().requestBiometrics ? enabled(true) : null;
}
@@ -375,7 +393,7 @@ export const useAppEvents = () => {
}
refValues.current.isReconnecting = true;
let state = connection;
- console.log('SSE:', 'TRYING TO RECONNECT');
+ console.log("SSE:", "TRYING TO RECONNECT");
try {
if (!state) {
state = await NetInfo.fetch();
@@ -402,32 +420,35 @@ export const useAppEvents = () => {
movedAway: editorState().movedAway,
timestamp: Date.now()
});
- MMKV.setString('appState', state);
+ MMKV.setString("appState", state);
}
}
async function checkIntentState() {
try {
- let notesAddedFromIntent = MMKV.getString('notesAddedFromIntent');
- let shareExtensionOpened = MMKV.getString('shareExtensionOpened');
+ let notesAddedFromIntent = MMKV.getString("notesAddedFromIntent");
+ let shareExtensionOpened = MMKV.getString("shareExtensionOpened");
if (notesAddedFromIntent) {
- if (Platform.OS === 'ios') {
+ if (Platform.OS === "ios") {
await db.init();
await db.notes.init();
}
useNoteStore.getState().setNotes();
eSendEvent(refreshNotesPage);
- MMKV.removeItem('notesAddedFromIntent');
+ MMKV.removeItem("notesAddedFromIntent");
initAfterSync();
eSendEvent(refreshNotesPage);
}
- console.log('CHECK INTENT STATE', notesAddedFromIntent || shareExtensionOpened);
+ console.log(
+ "CHECK INTENT STATE",
+ notesAddedFromIntent || shareExtensionOpened
+ );
if (notesAddedFromIntent || shareExtensionOpened) {
let id = useEditorStore.getState().currentEditingNote;
let note = id && db.notes.note(id).data;
- eSendEvent('loadingNote', note);
- eSendEvent('webview_reset');
- MMKV.removeItem('shareExtensionOpened');
+ eSendEvent("loadingNote", note);
+ eSendEvent("webview_reset");
+ MMKV.removeItem("shareExtensionOpened");
}
} catch (e) {
console.log(e);
diff --git a/apps/mobile/app/hooks/use-app-state.ts b/apps/mobile/app/hooks/use-app-state.ts
index fe0447461..577c5104b 100644
--- a/apps/mobile/app/hooks/use-app-state.ts
+++ b/apps/mobile/app/hooks/use-app-state.ts
@@ -1,5 +1,5 @@
-import { useEffect, useState } from 'react';
-import { AppState, AppStateStatus } from 'react-native';
+import { useEffect, useState } from "react";
+import { AppState, AppStateStatus } from "react-native";
export function useAppState() {
const currentState = AppState.currentState;
@@ -10,16 +10,16 @@ export function useAppState() {
setAppState(newState);
}
- const subscription = AppState.addEventListener('change', onChange);
+ const subscription = AppState.addEventListener("change", onChange);
return () => {
// @ts-expect-error - React Native >= 0.65
- if (typeof subscription?.remove === 'function') {
+ if (typeof subscription?.remove === "function") {
// @ts-expect-error - need update @types/[email protected]
subscription.remove();
} else {
// React Native < 0.65
- AppState.removeEventListener('change', onChange);
+ AppState.removeEventListener("change", onChange);
}
};
}, []);
diff --git a/apps/mobile/app/hooks/use-attachment-progress.js b/apps/mobile/app/hooks/use-attachment-progress.js
index 9e1530313..42ce51463 100644
--- a/apps/mobile/app/hooks/use-attachment-progress.js
+++ b/apps/mobile/app/hooks/use-attachment-progress.js
@@ -1,12 +1,12 @@
-import { useEffect, useState } from 'react';
-import { useAttachmentStore } from '../stores/use-attachment-store';
+import { useEffect, useState } from "react";
+import { useAttachmentStore } from "../stores/use-attachment-store";
export const useAttachmentProgress = (attachment, encryption) => {
- const progress = useAttachmentStore(state => state.progress);
+ const progress = useAttachmentStore((state) => state.progress);
const [currentProgress, setCurrentProgress] = useState(
encryption
? {
- type: 'encrypt'
+ type: "encrypt"
}
: null
);
@@ -15,14 +15,14 @@ export const useAttachmentProgress = (attachment, encryption) => {
let prog = progress[attachment.metadata.hash];
if (prog) {
let type = prog.type;
- let loaded = prog.type === 'download' ? prog.recieved : prog.sent;
+ let loaded = prog.type === "download" ? prog.recieved : prog.sent;
prog = loaded / prog.total;
prog = (prog * 100).toFixed(0);
- console.log('progress: ', prog);
+ console.log("progress: ", prog);
console.log(prog);
setCurrentProgress({
value: prog,
- percent: prog + '%',
+ percent: prog + "%",
type: type
});
} else {
diff --git a/apps/mobile/app/hooks/use-delay-layout.ts b/apps/mobile/app/hooks/use-delay-layout.ts
index 9d11a03b2..f432f9fa7 100644
--- a/apps/mobile/app/hooks/use-delay-layout.ts
+++ b/apps/mobile/app/hooks/use-delay-layout.ts
@@ -1,5 +1,5 @@
-import { useEffect, useState } from 'react';
-import { InteractionManager } from 'react-native';
+import { useEffect, useState } from "react";
+import { InteractionManager } from "react-native";
export const useDelayLayout = (delay: number) => {
const [loading, setLoading] = useState(true);
diff --git a/apps/mobile/app/hooks/use-editor-tags.ts b/apps/mobile/app/hooks/use-editor-tags.ts
index e288ff3ab..c380174b5 100644
--- a/apps/mobile/app/hooks/use-editor-tags.ts
+++ b/apps/mobile/app/hooks/use-editor-tags.ts
@@ -1,15 +1,17 @@
-import { useEffect, useState } from 'react';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../services/event-manager';
-import { useEditorStore } from '../stores/use-editor-store';
-import { useTagStore } from '../stores/use-tag-store';
-import { db } from '../common/database';
+import { useEffect, useState } from "react";
+import { eSubscribeEvent, eUnSubscribeEvent } from "../services/event-manager";
+import { useEditorStore } from "../stores/use-editor-store";
+import { useTagStore } from "../stores/use-tag-store";
+import { db } from "../common/database";
/**
* A hook that injects/removes tags from tags bar in editor
*/
const useEditorTags = () => {
- const currentEditingNote = useEditorStore(state => state.currentEditingNote);
- const tags = useTagStore(state => state.tags);
+ const currentEditingNote = useEditorStore(
+ (state) => state.currentEditingNote
+ );
+ const tags = useTagStore((state) => state.tags);
const [note, setNote] = useState<any>(null);
const [noteTags, setNoteTags] = useState([]);
@@ -35,9 +37,9 @@ const useEditorTags = () => {
}
useEffect(() => {
- eSubscribeEvent('updateTags', load);
+ eSubscribeEvent("updateTags", load);
return () => {
- eUnSubscribeEvent('updateTags', load);
+ eUnSubscribeEvent("updateTags", load);
};
}, [noteTags]);
diff --git a/apps/mobile/app/hooks/use-immediate.ts b/apps/mobile/app/hooks/use-immediate.ts
index 183328166..89e7bd0ec 100644
--- a/apps/mobile/app/hooks/use-immediate.ts
+++ b/apps/mobile/app/hooks/use-immediate.ts
@@ -1,4 +1,4 @@
-import { DependencyList, EffectCallback, useEffect } from 'react';
+import { DependencyList, EffectCallback, useEffect } from "react";
const useImmediateEffect = (callback: EffectCallback, deps: DependencyList) => {
useEffect(() => {
diff --git a/apps/mobile/app/hooks/use-is-floating-keyboard.ts b/apps/mobile/app/hooks/use-is-floating-keyboard.ts
index c429fcdfd..a58a35056 100644
--- a/apps/mobile/app/hooks/use-is-floating-keyboard.ts
+++ b/apps/mobile/app/hooks/use-is-floating-keyboard.ts
@@ -1,5 +1,5 @@
-import { useEffect, useState } from 'react';
-import { Keyboard, KeyboardEvent, useWindowDimensions } from 'react-native';
+import { useEffect, useState } from "react";
+import { Keyboard, KeyboardEvent, useWindowDimensions } from "react-native";
/**
* A hook that detects floating keyboard on iPad
@@ -15,7 +15,10 @@ const useIsFloatingKeyboard = () => {
};
useEffect(() => {
- let sub1 = Keyboard.addListener('keyboardWillChangeFrame', onKeyboardWillChangeFrame);
+ let sub1 = Keyboard.addListener(
+ "keyboardWillChangeFrame",
+ onKeyboardWillChangeFrame
+ );
return () => {
sub1?.remove();
};
diff --git a/apps/mobile/app/hooks/use-keyboard.ts b/apps/mobile/app/hooks/use-keyboard.ts
index 4cdf3bdb3..b9412a84a 100644
--- a/apps/mobile/app/hooks/use-keyboard.ts
+++ b/apps/mobile/app/hooks/use-keyboard.ts
@@ -1,5 +1,5 @@
-import { useEffect, useState } from 'react';
-import { Keyboard, KeyboardEventListener, ScreenRect } from 'react-native';
+import { useEffect, useState } from "react";
+import { Keyboard, KeyboardEventListener, ScreenRect } from "react-native";
const emptyCoordinates = Object.freeze({
screenX: 0,
@@ -20,18 +20,18 @@ export default function useKeyboard() {
}>(initialValue);
const [keyboardHeight, setKeyboardHeight] = useState<number>(0);
- const handleKeyboardWillShow: KeyboardEventListener = e => {
+ const handleKeyboardWillShow: KeyboardEventListener = (e) => {
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates });
};
- const handleKeyboardDidShow: KeyboardEventListener = e => {
+ const handleKeyboardDidShow: KeyboardEventListener = (e) => {
setShown(true);
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates });
setKeyboardHeight(e.endCoordinates.height);
};
- const handleKeyboardWillHide: KeyboardEventListener = e => {
+ const handleKeyboardWillHide: KeyboardEventListener = (e) => {
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates });
};
- const handleKeyboardDidHide: KeyboardEventListener = e => {
+ const handleKeyboardDidHide: KeyboardEventListener = (e) => {
setShown(false);
if (e) {
setCoordinates({ start: e.startCoordinates, end: e.endCoordinates });
@@ -43,14 +43,14 @@ export default function useKeyboard() {
useEffect(() => {
const subscriptions = [
- Keyboard.addListener('keyboardWillShow', handleKeyboardWillShow),
- Keyboard.addListener('keyboardDidShow', handleKeyboardDidShow),
- Keyboard.addListener('keyboardWillHide', handleKeyboardWillHide),
- Keyboard.addListener('keyboardDidHide', handleKeyboardDidHide)
+ Keyboard.addListener("keyboardWillShow", handleKeyboardWillShow),
+ Keyboard.addListener("keyboardDidShow", handleKeyboardDidShow),
+ Keyboard.addListener("keyboardWillHide", handleKeyboardWillHide),
+ Keyboard.addListener("keyboardDidHide", handleKeyboardDidHide)
];
return () => {
- subscriptions.forEach(subscription => subscription.remove());
+ subscriptions.forEach((subscription) => subscription.remove());
};
}, []);
return {
diff --git a/apps/mobile/app/hooks/use-navigation-focus.ts b/apps/mobile/app/hooks/use-navigation-focus.ts
index 07e35963a..d5ed52be0 100644
--- a/apps/mobile/app/hooks/use-navigation-focus.ts
+++ b/apps/mobile/app/hooks/use-navigation-focus.ts
@@ -1,5 +1,5 @@
-import { NativeStackNavigationProp } from '@react-navigation/native-stack';
-import { RefObject, useCallback, useEffect, useRef, useState } from 'react';
+import { NativeStackNavigationProp } from "@react-navigation/native-stack";
+import { RefObject, useCallback, useEffect, useRef, useState } from "react";
type NavigationFocus = {
onFocus?: (prev: RefObject<boolean>) => boolean;
@@ -19,7 +19,7 @@ export const useNavigationFocus = (
const _onFocus = useCallback(() => {
setTimeout(
() => {
- console.log('on focus', prev);
+ console.log("on focus", prev);
let shouldFocus = onFocus ? onFocus(prev) : true;
if (shouldFocus) {
setFocused(true);
@@ -45,11 +45,11 @@ export const useNavigationFocus = (
useEffect(() => {
if (!navigation) return;
const subs = [
- navigation.addListener('focus', _onFocus),
- navigation.addListener('blur', _onBlur)
+ navigation.addListener("focus", _onFocus),
+ navigation.addListener("blur", _onBlur)
];
return () => {
- subs.forEach(sub => sub());
+ subs.forEach((sub) => sub());
};
}, [navigation]);
diff --git a/apps/mobile/app/hooks/use-pricing.ts b/apps/mobile/app/hooks/use-pricing.ts
index 4481b703e..e27ba51fb 100644
--- a/apps/mobile/app/hooks/use-pricing.ts
+++ b/apps/mobile/app/hooks/use-pricing.ts
@@ -1,8 +1,8 @@
-import { useEffect, useState } from 'react';
-import { Platform } from 'react-native';
-import { Subscription } from 'react-native-iap';
-import PremiumService from '../services/premium';
-import { db } from '../common/database';
+import { useEffect, useState } from "react";
+import { Platform } from "react-native";
+import { Subscription } from "react-native-iap";
+import PremiumService from "../services/premium";
+import { db } from "../common/database";
type PurchaseInfo = {
country: string;
@@ -13,29 +13,39 @@ type PurchaseInfo = {
const skuInfos: { [name: string]: PurchaseInfo | undefined } = {};
-export const usePricing = (period: 'monthly' | 'yearly') => {
+export const usePricing = (period: "monthly" | "yearly") => {
const [current, setCurrent] = useState<{
period: string;
info?: PurchaseInfo;
product?: Subscription;
}>();
- const getDefaultSku = (period: 'monthly' | 'yearly') => {
- return period === 'monthly'
- ? 'com.streetwriters.notesnook.sub.mo'
- : 'com.streetwriters.notesnook.sub.yr';
+ const getDefaultSku = (period: "monthly" | "yearly") => {
+ return period === "monthly"
+ ? "com.streetwriters.notesnook.sub.mo"
+ : "com.streetwriters.notesnook.sub.yr";
};
useEffect(() => {
(async () => {
let skuInfo =
skuInfos[period] ||
- (await db.pricing?.sku(Platform.OS === 'android' ? 'android' : 'ios', period));
+ (await db.pricing?.sku(
+ Platform.OS === "android" ? "android" : "ios",
+ period
+ ));
skuInfos[period] = skuInfo;
let products = (await PremiumService.getProducts()) as Subscription[];
- let product = products.find(p => p.productId === skuInfo?.sku);
- if (!product) product = products.find(p => p.productId === getDefaultSku(period));
- console.log('skuInfos: ', skuInfos, product?.productId, product?.price, products.length);
+ let product = products.find((p) => p.productId === skuInfo?.sku);
+ if (!product)
+ product = products.find((p) => p.productId === getDefaultSku(period));
+ console.log(
+ "skuInfos: ",
+ skuInfos,
+ product?.productId,
+ product?.price,
+ products.length
+ );
setCurrent({
info: skuInfo,
period,
diff --git a/apps/mobile/app/hooks/use-rotator.ts b/apps/mobile/app/hooks/use-rotator.ts
index d793cc3ff..7bd25639a 100644
--- a/apps/mobile/app/hooks/use-rotator.ts
+++ b/apps/mobile/app/hooks/use-rotator.ts
@@ -1,4 +1,4 @@
-import { useEffect, useRef, useState } from 'react';
+import { useEffect, useRef, useState } from "react";
/**
* A hook that can be used to rotate values in an array.
diff --git a/apps/mobile/app/hooks/use-sync-progress.ts b/apps/mobile/app/hooks/use-sync-progress.ts
index 8b53978ad..833b80a37 100644
--- a/apps/mobile/app/hooks/use-sync-progress.ts
+++ b/apps/mobile/app/hooks/use-sync-progress.ts
@@ -1,10 +1,10 @@
//@ts-ignore
-import { EVENTS } from '@streetwriters/notesnook-core/common';
-import { createRef, useCallback, useEffect, useRef, useState } from 'react';
-import { db } from '../common/database';
+import { EVENTS } from "@streetwriters/notesnook-core/common";
+import { createRef, useCallback, useEffect, useRef, useState } from "react";
+import { db } from "../common/database";
export type SyncProgressEventType = {
- type: 'upload' | 'download';
+ type: "upload" | "download";
total: number;
current: number;
};
@@ -13,11 +13,14 @@ const useSyncProgress = () => {
const [progress, setProgress] = useState<SyncProgressEventType>();
const EV = db.eventManager;
- const onProgress = useCallback(({ type, current, total }: SyncProgressEventType) => {
- //@ts-ignore
+ const onProgress = useCallback(
+ ({ type, current, total }: SyncProgressEventType) => {
+ //@ts-ignore
- setProgress({ type, current, total });
- }, []);
+ setProgress({ type, current, total });
+ },
+ []
+ );
const onSyncComplete = () => {
setProgress(undefined);
diff --git a/apps/mobile/app/hooks/use-timer.ts b/apps/mobile/app/hooks/use-timer.ts
index c9dd2e96d..2b83f6c42 100644
--- a/apps/mobile/app/hooks/use-timer.ts
+++ b/apps/mobile/app/hooks/use-timer.ts
@@ -1,9 +1,9 @@
-import { useEffect, useRef, useState } from 'react';
+import { useEffect, useRef, useState } from "react";
const timers: { [name: string]: number } = {};
function getSecondsLeft(id?: string) {
- let endTime = timers[id || ''];
+ let endTime = timers[id || ""];
if (!endTime) return 0;
if (endTime < Date.now()) return 0;
console.log((endTime - Date.now()) / 1000);
@@ -16,10 +16,10 @@ const useTimer = (initialId?: string) => {
const interval = useRef<NodeJS.Timer>();
const start = (sec: number, currentId = id) => {
- console.log('started', sec, id);
+ console.log("started", sec, id);
if (!currentId) return;
timers[currentId] = Date.now() + sec * 1000;
- console.log('timers:', timers[currentId]);
+ console.log("timers:", timers[currentId]);
setSeconds(getSecondsLeft(id));
};
diff --git a/apps/mobile/app/hooks/use-tooltip.ts b/apps/mobile/app/hooks/use-tooltip.ts
index 1f0e7a12a..ca1f29511 100644
--- a/apps/mobile/app/hooks/use-tooltip.ts
+++ b/apps/mobile/app/hooks/use-tooltip.ts
@@ -1,11 +1,15 @@
-import { RefObject, useEffect, useRef } from 'react';
-import { Platform } from 'react-native';
+import { RefObject, useEffect, useRef } from "react";
+import { Platform } from "react-native";
//@ts-ignore
-import RNTooltips from 'react-native-tooltips';
-import { useThemeStore } from '../stores/use-theme-store';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../services/event-manager';
-import { Popup } from '../services/tip-manager';
-import useKeyboard from './use-keyboard';
+import RNTooltips from "react-native-tooltips";
+import { useThemeStore } from "../stores/use-theme-store";
+import {
+ eSendEvent,
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../services/event-manager";
+import { Popup } from "../services/tip-manager";
+import useKeyboard from "./use-keyboard";
let currentTargets: number[] = [];
let timers: NodeJS.Timeout[] = [];
@@ -14,10 +18,10 @@ let timers: NodeJS.Timeout[] = [];
* A function to hide all native tooltips
*/
export const hideAllTooltips = async () => {
- timers.forEach(t => t && clearTimeout(t));
+ timers.forEach((t) => t && clearTimeout(t));
for (let target of currentTargets) {
if (target) {
- console.log('dimissing targets', target);
+ console.log("dimissing targets", target);
RNTooltips.Dismiss(target);
target = -1;
}
@@ -30,7 +34,7 @@ export const hideAllTooltips = async () => {
* @returns
*/
const useTooltip = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const parent = useRef();
let keyboard = useKeyboard();
@@ -56,11 +60,11 @@ const useTooltip = () => {
currentTargets.push(target.current._nativeTag);
timers[timers.length] = setTimeout(() => {
//TipManager.markPopupUsed(popup.id);
- console.log('tooltip showing', popup.text);
+ console.log("tooltip showing", popup.text);
RNTooltips.Show(target.current, parent.current, {
text: popup.text,
- tintColor: colors.night ? colors.nav : '#404040',
- corner: Platform.OS === 'ios' ? 5 : 50,
+ tintColor: colors.night ? colors.nav : "#404040",
+ corner: Platform.OS === "ios" ? 5 : 50,
textSize: 15,
position: positions[position],
duration: duration || 10000,
@@ -74,12 +78,18 @@ const useTooltip = () => {
return { parent, show };
};
-type TTooltipIdentifiers = 'sectionheader' | 'searchreplace' | 'notebookshortcut';
+type TTooltipIdentifiers =
+ | "sectionheader"
+ | "searchreplace"
+ | "notebookshortcut";
/**
* A hook that helps in listening to tooltip show/hide requests and respond.
*/
-export const useTooltipHandler = (id: TTooltipIdentifiers, callback: () => void) => {
+export const useTooltipHandler = (
+ id: TTooltipIdentifiers,
+ callback: () => void
+) => {
useEffect(() => {
if (!id) return;
eSubscribeEvent(id, callback);
diff --git a/apps/mobile/app/hooks/use-vault-status.js b/apps/mobile/app/hooks/use-vault-status.js
index c34f00e39..2cd2d3f8c 100644
--- a/apps/mobile/app/hooks/use-vault-status.js
+++ b/apps/mobile/app/hooks/use-vault-status.js
@@ -1,7 +1,7 @@
-import React, { useCallback, useEffect } from 'react';
-import BiometicService from '../services/biometrics';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../services/event-manager';
-import { db } from '../common/database';
+import React, { useCallback, useEffect } from "react";
+import BiometicService from "../services/biometrics";
+import { eSubscribeEvent, eUnSubscribeEvent } from "../services/event-manager";
+import { db } from "../common/database";
const VaultStatusCache = {
exists: false,
@@ -13,7 +13,7 @@ export const useVaultStatus = () => {
const [vaultStatus, setVaultStatus] = React.useState(VaultStatusCache);
const checkVaultStatus = useCallback(() => {
- db.vault.exists().then(async exists => {
+ db.vault.exists().then(async (exists) => {
let available = await BiometicService.isBiometryAvailable();
let fingerprint = await BiometicService.hasInternetCredentials();
if (
@@ -32,9 +32,9 @@ export const useVaultStatus = () => {
useEffect(() => {
checkVaultStatus();
- eSubscribeEvent('vaultUpdated', () => checkVaultStatus());
+ eSubscribeEvent("vaultUpdated", () => checkVaultStatus());
return () => {
- eUnSubscribeEvent('vaultUpdated', () => checkVaultStatus());
+ eUnSubscribeEvent("vaultUpdated", () => checkVaultStatus());
};
}, []);
diff --git a/apps/mobile/app/navigation/index.js b/apps/mobile/app/navigation/index.js
index 79ec2332c..53ad6c5c5 100644
--- a/apps/mobile/app/navigation/index.js
+++ b/apps/mobile/app/navigation/index.js
@@ -1,19 +1,21 @@
-import React from 'react';
-import { SafeAreaView } from 'react-native';
-import DelayLayout from '../components/delay-layout';
-import DialogProvider from '../components/dialog-provider';
-import { Header } from '../components/header';
-import { Toast } from '../components/toast';
-import { useNoteStore } from '../stores/use-notes-store';
-import { useSettingStore } from '../stores/use-setting-store';
-import { useThemeStore } from '../stores/use-theme-store';
-import { TabsHolder } from './tabs-holder';
+import React from "react";
+import { SafeAreaView } from "react-native";
+import DelayLayout from "../components/delay-layout";
+import DialogProvider from "../components/dialog-provider";
+import { Header } from "../components/header";
+import { Toast } from "../components/toast";
+import { useNoteStore } from "../stores/use-notes-store";
+import { useSettingStore } from "../stores/use-setting-store";
+import { useThemeStore } from "../stores/use-theme-store";
+import { TabsHolder } from "./tabs-holder";
export const ApplicationHolder = React.memo(
() => {
- const loading = useNoteStore(state => state.loading);
- const introCompleted = useSettingStore(state => state.settings.introCompleted);
- const colors = useThemeStore(state => state.colors);
+ const loading = useNoteStore((state) => state.loading);
+ const introCompleted = useSettingStore(
+ (state) => state.settings.introCompleted
+ );
+ const colors = useThemeStore((state) => state.colors);
return (
<>
diff --git a/apps/mobile/app/navigation/navigation-stack.js b/apps/mobile/app/navigation/navigation-stack.js
index baf3076e3..d995ec772 100644
--- a/apps/mobile/app/navigation/navigation-stack.js
+++ b/apps/mobile/app/navigation/navigation-stack.js
@@ -1,32 +1,32 @@
-import { NavigationContainer } from '@react-navigation/native';
-import { createNativeStackNavigator } from '@react-navigation/native-stack';
-import * as React from 'react';
-import Container from '../components/container';
-import Intro from '../components/intro';
-import Favorites from '../screens/favorites';
-import Home from '../screens/home';
-import Notebook from '../screens/notebook';
-import Notebooks from '../screens/notebooks';
-import { ColoredNotes } from '../screens/notes/colored';
-import { Monographs } from '../screens/notes/monographs';
-import { TaggedNotes } from '../screens/notes/tagged';
-import { TopicNotes } from '../screens/notes/topic-notes';
-import { Search } from '../screens/search';
-import Settings from '../screens/settings';
-import AppLock from '../screens/settings/app-lock';
-import Tags from '../screens/tags';
-import Trash from '../screens/trash';
-import { eSendEvent } from '../services/event-manager';
-import SettingsService from '../services/settings';
-import useNavigationStore from '../stores/use-navigation-store';
-import { useSelectionStore } from '../stores/use-selection-store';
-import { useThemeStore } from '../stores/use-theme-store';
-import { history } from '../utils';
-import { rootNavigatorRef } from '../utils/global-refs';
-import { hideAllTooltips } from '../hooks/use-tooltip';
-import { useWindowDimensions } from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { useSettingStore } from '../stores/use-setting-store';
+import { NavigationContainer } from "@react-navigation/native";
+import { createNativeStackNavigator } from "@react-navigation/native-stack";
+import * as React from "react";
+import Container from "../components/container";
+import Intro from "../components/intro";
+import Favorites from "../screens/favorites";
+import Home from "../screens/home";
+import Notebook from "../screens/notebook";
+import Notebooks from "../screens/notebooks";
+import { ColoredNotes } from "../screens/notes/colored";
+import { Monographs } from "../screens/notes/monographs";
+import { TaggedNotes } from "../screens/notes/tagged";
+import { TopicNotes } from "../screens/notes/topic-notes";
+import { Search } from "../screens/search";
+import Settings from "../screens/settings";
+import AppLock from "../screens/settings/app-lock";
+import Tags from "../screens/tags";
+import Trash from "../screens/trash";
+import { eSendEvent } from "../services/event-manager";
+import SettingsService from "../services/settings";
+import useNavigationStore from "../stores/use-navigation-store";
+import { useSelectionStore } from "../stores/use-selection-store";
+import { useThemeStore } from "../stores/use-theme-store";
+import { history } from "../utils";
+import { rootNavigatorRef } from "../utils/global-refs";
+import { hideAllTooltips } from "../hooks/use-tooltip";
+import { useWindowDimensions } from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { useSettingStore } from "../stores/use-setting-store";
const NativeStack = createNativeStackNavigator();
const IntroStack = createNativeStackNavigator();
@@ -40,18 +40,18 @@ const IntroStack = createNativeStackNavigator();
*/
const IntroStackNavigator = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<IntroStack.Navigator
screenOptions={{
headerShown: false,
lazy: false,
- animation: 'none',
+ animation: "none",
contentStyle: {
backgroundColor: colors.bg
}
}}
- initialRouteName={'Intro'}
+ initialRouteName={"Intro"}
>
<NativeStack.Screen name="Intro" component={Intro} />
<NativeStack.Screen name="AppLock" component={AppLock} />
@@ -61,10 +61,12 @@ const IntroStackNavigator = () => {
const Tabs = React.memo(
() => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const homepage = SettingsService.get().homepage;
- const introCompleted = useSettingStore(state => state.settings.introCompleted);
- const height = useSettingStore(state => state.dimensions.height);
+ const introCompleted = useSettingStore(
+ (state) => state.settings.introCompleted
+ );
+ const height = useSettingStore((state) => state.dimensions.height);
const insets = useSafeAreaInsets();
const screenHeight = height - (50 + insets.top + insets.bottom);
React.useEffect(() => {
@@ -76,12 +78,12 @@ const Tabs = React.memo(
return (
<NativeStack.Navigator
tabBar={() => null}
- initialRouteName={!introCompleted ? 'Welcome' : homepage}
+ initialRouteName={!introCompleted ? "Welcome" : homepage}
backBehavior="history"
screenOptions={{
headerShown: false,
lazy: false,
- animation: 'none',
+ animation: "none",
contentStyle: {
backgroundColor: colors.bg,
height: !introCompleted ? undefined : screenHeight
@@ -91,16 +93,52 @@ const Tabs = React.memo(
<NativeStack.Screen name="Welcome" component={IntroStackNavigator} />
<NativeStack.Screen name="Notes" component={Home} />
<NativeStack.Screen name="Notebooks" component={Notebooks} />
- <NativeStack.Screen options={{ lazy: true }} name="Favorites" component={Favorites} />
- <NativeStack.Screen options={{ lazy: true }} name="Trash" component={Trash} />
- <NativeStack.Screen options={{ lazy: true }} name="Tags" component={Tags} />
+ <NativeStack.Screen
+ options={{ lazy: true }}
+ name="Favorites"
+ component={Favorites}
+ />
+ <NativeStack.Screen
+ options={{ lazy: true }}
+ name="Trash"
+ component={Trash}
+ />
+ <NativeStack.Screen
+ options={{ lazy: true }}
+ name="Tags"
+ component={Tags}
+ />
<NativeStack.Screen name="Settings" component={Settings} />
- <NativeStack.Screen options={{ lazy: true }} name="TaggedNotes" component={TaggedNotes} />
- <NativeStack.Screen options={{ lazy: true }} name="TopicNotes" component={TopicNotes} />
- <NativeStack.Screen options={{ lazy: true }} name="ColoredNotes" component={ColoredNotes} />
- <NativeStack.Screen options={{ lazy: true }} name="Monographs" component={Monographs} />
- <NativeStack.Screen options={{ lazy: true }} name="Notebook" component={Notebook} />
- <NativeStack.Screen options={{ lazy: true }} name="Search" component={Search} />
+ <NativeStack.Screen
+ options={{ lazy: true }}
+ name="TaggedNotes"
+ component={TaggedNotes}
+ />
+ <NativeStack.Screen
+ options={{ lazy: true }}
+ name="TopicNotes"
+ component={TopicNotes}
+ />
+ <NativeStack.Screen
+ options={{ lazy: true }}
+ name="ColoredNotes"
+ component={ColoredNotes}
+ />
+ <NativeStack.Screen
+ options={{ lazy: true }}
+ name="Monographs"
+ component={Monographs}
+ />
+ <NativeStack.Screen
+ options={{ lazy: true }}
+ name="Notebook"
+ component={Notebook}
+ />
+ <NativeStack.Screen
+ options={{ lazy: true }}
+ name="Search"
+ component={Search}
+ />
</NativeStack.Navigator>
);
},
@@ -109,19 +147,22 @@ const Tabs = React.memo(
export const NavigationStack = React.memo(
() => {
- const clearSelection = useSelectionStore(state => state.clearSelection);
+ const clearSelection = useSelectionStore((state) => state.clearSelection);
const onStateChange = React.useCallback(() => {
if (history.selectionMode) {
clearSelection(true);
}
hideAllTooltips();
- eSendEvent('navigate');
+ eSendEvent("navigate");
});
return (
<Container>
- <NavigationContainer onStateChange={onStateChange} ref={rootNavigatorRef}>
+ <NavigationContainer
+ onStateChange={onStateChange}
+ ref={rootNavigatorRef}
+ >
<Tabs />
</NavigationContainer>
</Container>
diff --git a/apps/mobile/app/navigation/tabs-holder.js b/apps/mobile/app/navigation/tabs-holder.js
index 31241edb8..93c15e317 100644
--- a/apps/mobile/app/navigation/tabs-holder.js
+++ b/apps/mobile/app/navigation/tabs-holder.js
@@ -1,58 +1,71 @@
-import { activateKeepAwake, deactivateKeepAwake } from '@sayem314/react-native-keep-awake';
-import React, { useEffect, useRef, useState } from 'react';
-import { Platform, View, StatusBar } from 'react-native';
+import {
+ activateKeepAwake,
+ deactivateKeepAwake
+} from "@sayem314/react-native-keep-awake";
+import React, { useEffect, useRef, useState } from "react";
+import { Platform, View, StatusBar } from "react-native";
import {
addSpecificOrientationListener,
getInitialOrientation,
getSpecificOrientation,
removeSpecificOrientationListener
-} from 'react-native-orientation';
-import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { notesnook } from '../../e2e/test.ids';
-import { SideMenu } from '../components/side-menu';
-import { FluidTabs } from '../components/tabs';
-import { editorController, editorState } from '../screens/editor/tiptap/utils';
-import { EditorWrapper } from '../screens/editor/wrapper';
-import { DDS } from '../services/device-detection';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../services/event-manager';
-import { useEditorStore } from '../stores/use-editor-store';
-import { useSettingStore } from '../stores/use-setting-store';
-import { useThemeStore } from '../stores/use-theme-store';
-import { setWidthHeight } from '../utils';
-import { db } from '../common/database';
+} from "react-native-orientation";
+import Animated, {
+ useAnimatedStyle,
+ useSharedValue,
+ withTiming
+} from "react-native-reanimated";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { notesnook } from "../../e2e/test.ids";
+import { SideMenu } from "../components/side-menu";
+import { FluidTabs } from "../components/tabs";
+import { editorController, editorState } from "../screens/editor/tiptap/utils";
+import { EditorWrapper } from "../screens/editor/wrapper";
+import { DDS } from "../services/device-detection";
+import {
+ eSendEvent,
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../services/event-manager";
+import { useEditorStore } from "../stores/use-editor-store";
+import { useSettingStore } from "../stores/use-setting-store";
+import { useThemeStore } from "../stores/use-theme-store";
+import { setWidthHeight } from "../utils";
+import { db } from "../common/database";
import {
eClearEditor,
eCloseFullscreenEditor,
eOnLoadNote,
eOpenFullscreenEditor
-} from '../utils/events';
-import { editorRef, tabBarRef } from '../utils/global-refs';
-import { hideAllTooltips } from '../hooks/use-tooltip';
-import { NavigationStack } from './navigation-stack';
+} from "../utils/events";
+import { editorRef, tabBarRef } from "../utils/global-refs";
+import { hideAllTooltips } from "../hooks/use-tooltip";
+import { NavigationStack } from "./navigation-stack";
export const TabsHolder = React.memo(
() => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
- const deviceMode = useSettingStore(state => state.deviceMode);
- const setFullscreen = useSettingStore(state => state.setFullscreen);
- const fullscreen = useSettingStore(state => state.fullscreen);
- const setDeviceModeState = useSettingStore(state => state.setDeviceMode);
- const dimensions = useSettingStore(state => state.dimensions);
- const setDimensions = useSettingStore(state => state.setDimensions);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
+ const setFullscreen = useSettingStore((state) => state.setFullscreen);
+ const fullscreen = useSettingStore((state) => state.fullscreen);
+ const setDeviceModeState = useSettingStore((state) => state.setDeviceMode);
+ const dimensions = useSettingStore((state) => state.dimensions);
+ const setDimensions = useSettingStore((state) => state.setDimensions);
const insets = useSafeAreaInsets();
const animatedOpacity = useSharedValue(0);
const animatedTranslateY = useSharedValue(-9999);
const overlayRef = useRef();
const [orientation, setOrientation] = useState(getInitialOrientation());
- const introCompleted = useSettingStore(state => state.settings.introCompleted);
+ const introCompleted = useSettingStore(
+ (state) => state.settings.introCompleted
+ );
const onOrientationChange = (o, o2) => {
setOrientation(o || o2);
};
useEffect(() => {
- if (Platform.OS === 'ios') {
+ if (Platform.OS === "ios") {
addSpecificOrientationListener(onOrientationChange);
getSpecificOrientation && getSpecificOrientation(onOrientationChange);
}
@@ -63,7 +76,7 @@ export const TabsHolder = React.memo(
const showFullScreenEditor = () => {
setFullscreen(true);
- if (deviceMode === 'smallTablet') {
+ if (deviceMode === "smallTablet") {
tabBarRef.current?.openDrawer();
}
editorRef.current?.setNativeProps({
@@ -71,13 +84,15 @@ export const TabsHolder = React.memo(
width: dimensions.width,
zIndex: 999,
paddingHorizontal:
- deviceMode === 'smallTablet' ? dimensions.width * 0 : dimensions.width * 0.15
+ deviceMode === "smallTablet"
+ ? dimensions.width * 0
+ : dimensions.width * 0.15
}
});
};
const closeFullScreenEditor = () => {
- if (deviceMode === 'smallTablet') {
+ if (deviceMode === "smallTablet") {
tabBarRef.current?.closeDrawer();
}
setFullscreen(false);
@@ -87,14 +102,15 @@ export const TabsHolder = React.memo(
editorRef.current?.setNativeProps({
style: {
width:
- deviceMode === 'smallTablet'
- ? dimensions.width - valueLimiter(dimensions.width * 0.4, 300, 450)
+ deviceMode === "smallTablet"
+ ? dimensions.width -
+ valueLimiter(dimensions.width * 0.4, 300, 450)
: dimensions.width * 0.55,
zIndex: null,
paddingHorizontal: 0
}
});
- if (deviceMode === 'smallTablet') {
+ if (deviceMode === "smallTablet") {
setTimeout(() => {
tabBarRef.current?.goToIndex(1);
}, 100);
@@ -114,8 +130,8 @@ export const TabsHolder = React.memo(
};
}, [deviceMode, dimensions, colors]);
- const _onLayout = async event => {
- console.log('layout called here');
+ const _onLayout = async (event) => {
+ console.log("layout called here");
if (layoutTimer) {
clearTimeout(layoutTimer);
layoutTimer = null;
@@ -138,17 +154,17 @@ export const TabsHolder = React.memo(
width: size.width,
height: size.height
});
- console.log('height change', size.width, size.height);
+ console.log("height change", size.width, size.height);
setWidthHeight(size);
DDS.setSize(size);
if (DDS.isLargeTablet()) {
- setDeviceMode('tablet', size);
+ setDeviceMode("tablet", size);
setTimeout(() => {
introCompleted && tabBarRef.current?.goToIndex(0);
}, 500);
} else if (DDS.isSmallTab) {
- setDeviceMode('smallTablet', size);
+ setDeviceMode("smallTablet", size);
if (!fullscreen) {
setTimeout(() => {
introCompleted && tabBarRef.current?.closeDrawer();
@@ -159,7 +175,7 @@ export const TabsHolder = React.memo(
}, 500);
}
} else {
- setDeviceMode('mobile', size);
+ setDeviceMode("mobile", size);
}
}
@@ -172,17 +188,18 @@ export const TabsHolder = React.memo(
style: {
width: size.width,
zIndex: 999,
- paddingHorizontal: current === 'smallTablet' ? size.width * 0 : size.width * 0.15
+ paddingHorizontal:
+ current === "smallTablet" ? size.width * 0 : size.width * 0.15
}
});
} else {
editorRef.current?.setNativeProps({
style: {
- position: 'relative',
+ position: "relative",
width:
- current === 'tablet'
+ current === "tablet"
? size.width * 0.55
- : current === 'smallTablet'
+ : current === "smallTablet"
? size.width - valueLimiter(size.width * 0.4, 300, 450)
: size.width,
zIndex: null,
@@ -194,20 +211,20 @@ export const TabsHolder = React.memo(
return;
}
setTimeout(() => {
- if (current === 'tablet') {
+ if (current === "tablet") {
tabBarRef.current?.goToIndex(0);
} else {
if (!editorState().movedAway) {
tabBarRef.current?.goToIndex(2);
} else {
- console.log('index one', editorState().movedAway);
+ console.log("index one", editorState().movedAway);
tabBarRef.current?.goToIndex(1);
}
}
}, 1);
}
- const onScroll = scrollOffset => {
+ const onScroll = (scrollOffset) => {
hideAllTooltips();
if (scrollOffset > offsets[deviceMode].a - 10) {
animatedOpacity.value = 0;
@@ -225,7 +242,7 @@ export const TabsHolder = React.memo(
}
};
- const toggleView = show => {
+ const toggleView = (show) => {
animatedTranslateY.value = show ? 0 : -9999;
};
@@ -249,8 +266,12 @@ export const TabsHolder = React.memo(
},
smallTablet: {
a: fullscreen ? 0 : valueLimiter(dimensions.width * 0.3, 300, 350),
- b: fullscreen ? 0 : dimensions.width + valueLimiter(dimensions.width * 0.3, 300, 350),
- c: fullscreen ? 0 : dimensions.width + valueLimiter(dimensions.width * 0.3, 300, 350)
+ b: fullscreen
+ ? 0
+ : dimensions.width + valueLimiter(dimensions.width * 0.3, 300, 350),
+ c: fullscreen
+ ? 0
+ : dimensions.width + valueLimiter(dimensions.width * 0.3, 300, 350)
},
tablet: {
a: 0,
@@ -295,14 +316,19 @@ export const TabsHolder = React.memo(
style={{
flex: 1,
backgroundColor: colors.bg,
- paddingBottom: Platform.OS === 'android' ? insets?.bottom : 0,
+ paddingBottom: Platform.OS === "android" ? insets?.bottom : 0,
marginRight:
- orientation === 'LANDSCAPE-RIGHT' && Platform.OS === 'ios' ? insets.right : 0,
- marginLeft: orientation === 'LANDSCAPE-LEFT' && Platform.OS === 'ios' ? insets.left : 0
+ orientation === "LANDSCAPE-RIGHT" && Platform.OS === "ios"
+ ? insets.right
+ : 0,
+ marginLeft:
+ orientation === "LANDSCAPE-LEFT" && Platform.OS === "ios"
+ ? insets.left
+ : 0
}}
>
<StatusBar
- barStyle={colors.night ? 'light-content' : 'dark-content'}
+ barStyle={colors.night ? "light-content" : "dark-content"}
translucent={true}
backgroundColor="transparent"
/>
@@ -311,17 +337,19 @@ export const TabsHolder = React.memo(
<FluidTabs
ref={tabBarRef}
dimensions={dimensions}
- widths={!introCompleted ? widths['mobile'] : widths[deviceMode]}
- enabled={deviceMode !== 'tablet' && !fullscreen}
+ widths={!introCompleted ? widths["mobile"] : widths[deviceMode]}
+ enabled={deviceMode !== "tablet" && !fullscreen}
onScroll={onScroll}
onChangeTab={onChangeTab}
- onDrawerStateChange={state => true}
+ onDrawerStateChange={(state) => true}
>
<View
key="1"
style={{
- height: '100%',
- width: fullscreen ? 0 : widths[!introCompleted ? 'mobile' : deviceMode]?.a
+ height: "100%",
+ width: fullscreen
+ ? 0
+ : widths[!introCompleted ? "mobile" : deviceMode]?.a
}}
>
<SideMenu />
@@ -330,11 +358,13 @@ export const TabsHolder = React.memo(
<View
key="2"
style={{
- height: '100%',
- width: fullscreen ? 0 : widths[!introCompleted ? 'mobile' : deviceMode]?.b
+ height: "100%",
+ width: fullscreen
+ ? 0
+ : widths[!introCompleted ? "mobile" : deviceMode]?.b
}}
>
- {deviceMode === 'mobile' ? (
+ {deviceMode === "mobile" ? (
<Animated.View
onTouchEnd={() => {
tabBarRef.current?.closeDrawer();
@@ -343,11 +373,11 @@ export const TabsHolder = React.memo(
}}
style={[
{
- position: 'absolute',
- width: '100%',
- height: '100%',
+ position: "absolute",
+ width: "100%",
+ height: "100%",
zIndex: 999,
- backgroundColor: 'rgba(0,0,0,0.2)'
+ backgroundColor: "rgba(0,0,0,0.2)"
},
animatedStyle
]}
@@ -368,20 +398,20 @@ export const TabsHolder = React.memo(
let layoutTimer = null;
-const onChangeTab = async obj => {
+const onChangeTab = async (obj) => {
if (obj.i === 2) {
editorState().movedAway = false;
editorState().isFocused = true;
activateKeepAwake();
if (!editorState().currentlyEditing) {
- eSendEvent(eOnLoadNote, { type: 'new' });
+ eSendEvent(eOnLoadNote, { type: "new" });
}
} else {
if (obj.from === 2) {
deactivateKeepAwake();
editorState().movedAway = true;
editorState().isFocused = false;
- eSendEvent(eClearEditor, 'removeHandler');
+ eSendEvent(eClearEditor, "removeHandler");
setTimeout(() => useEditorStore.getState().setSearchReplace(false), 1);
let id = useEditorStore.getState().currentEditingNote;
let note = db.notes.note(id);
diff --git a/apps/mobile/app/screens/editor/index.tsx b/apps/mobile/app/screens/editor/index.tsx
index b6a474d03..b288471a6 100755
--- a/apps/mobile/app/screens/editor/index.tsx
+++ b/apps/mobile/app/screens/editor/index.tsx
@@ -1,32 +1,41 @@
/* eslint-disable @typescript-eslint/no-var-requires */
-import { EV, EVENTS } from '@streetwriters/notesnook-core/common';
-import React, { forwardRef, ReactElement, useEffect, useImperativeHandle, useState } from 'react';
-import { Platform, ViewStyle } from 'react-native';
-import WebView from 'react-native-webview';
-import { ShouldStartLoadRequest } from 'react-native-webview/lib/WebViewTypes';
-import { notesnook } from '../../../e2e/test.ids';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import { useEditorStore } from '../../stores/use-editor-store';
-import { getElevation } from '../../utils';
-import { db } from '../../common/database';
-import { openLinkInBrowser } from '../../utils/functions';
-import { NoteType } from '../../utils/types';
-import { EDITOR_URI } from './source';
-import { EditorProps, useEditorType } from './tiptap/types';
-import { useEditor } from './tiptap/use-editor';
-import { useEditorEvents } from './tiptap/use-editor-events';
-import { editorController } from './tiptap/utils';
+import { EV, EVENTS } from "@streetwriters/notesnook-core/common";
+import React, {
+ forwardRef,
+ ReactElement,
+ useEffect,
+ useImperativeHandle,
+ useState
+} from "react";
+import { Platform, ViewStyle } from "react-native";
+import WebView from "react-native-webview";
+import { ShouldStartLoadRequest } from "react-native-webview/lib/WebViewTypes";
+import { notesnook } from "../../../e2e/test.ids";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import { useEditorStore } from "../../stores/use-editor-store";
+import { getElevation } from "../../utils";
+import { db } from "../../common/database";
+import { openLinkInBrowser } from "../../utils/functions";
+import { NoteType } from "../../utils/types";
+import { EDITOR_URI } from "./source";
+import { EditorProps, useEditorType } from "./tiptap/types";
+import { useEditor } from "./tiptap/use-editor";
+import { useEditorEvents } from "./tiptap/use-editor-events";
+import { editorController } from "./tiptap/utils";
const style: ViewStyle = {
- height: '100%',
- maxHeight: '100%',
- width: '100%',
- alignSelf: 'center',
- backgroundColor: 'transparent'
+ height: "100%",
+ maxHeight: "100%",
+ width: "100%",
+ alignSelf: "center",
+ backgroundColor: "transparent"
};
const onShouldStartLoadWithRequest = (request: ShouldStartLoadRequest) => {
- if (request.url.includes('https')) {
- if (Platform.OS === 'ios' && !request.isTopFrame) return true;
+ if (request.url.includes("https")) {
+ if (Platform.OS === "ios" && !request.isTopFrame) return true;
openLinkInBrowser(request.url);
return false;
} else {
@@ -47,14 +56,14 @@ const Editor = React.memo(
noToolbar = false,
noHeader = false,
withController = true,
- editorId = '',
+ editorId = "",
onLoad,
onChange,
theme
},
ref
) => {
- const editor = useEditor(editorId || '', readonly, onChange, theme);
+ const editor = useEditor(editorId || "", readonly, onChange, theme);
const onMessage = useEditorEvents(editor, {
readonly,
noToolbar,
@@ -74,7 +83,7 @@ const Editor = React.memo(
groupId: string;
src: string;
}) => {
- console.log('onMediaDownoaded', groupId);
+ console.log("onMediaDownoaded", groupId);
if (groupId !== editor.note.current?.id) return;
editor.commands.updateImage({
@@ -85,10 +94,10 @@ const Editor = React.memo(
useEffect(() => {
onLoad && onLoad();
- eSubscribeEvent('webview_reset', onError);
+ eSubscribeEvent("webview_reset", onError);
EV.subscribe(EVENTS.mediaAttachmentDownloaded, onMediaDownloaded);
return () => {
- eUnSubscribeEvent('webview_reset', onError);
+ eUnSubscribeEvent("webview_reset", onError);
EV.unsubscribe(EVENTS.mediaAttachmentDownloaded, onMediaDownloaded);
};
}, []);
@@ -99,11 +108,11 @@ const Editor = React.memo(
}
const onError = () => {
- console.log('RENDER PROCESS GONE!!!');
+ console.log("RENDER PROCESS GONE!!!");
editor.setLoading(true);
setTimeout(() => editor.setLoading(false), 10);
};
- console.log(editor.loading, 'loading editor');
+ console.log(editor.loading, "loading editor");
return editor.loading ? null : (
<>
<WebView
@@ -137,7 +146,7 @@ const Editor = React.memo(
hideKeyboardAccessoryView={false}
allowFileAccessFromFileURLs={true}
allowUniversalAccessFromFileURLs={true}
- originWhitelist={['*']}
+ originWhitelist={["*"]}
source={{
uri: __DEV__ ? EDITOR_URI : EDITOR_URI
}}
@@ -145,7 +154,9 @@ const Editor = React.memo(
autoManageStatusBarEnabled={false}
onMessage={onMessage || undefined}
/>
- {editorId === 'shareEditor' ? null : <AppSection editor={editor} editorId={editorId} />}
+ {editorId === "shareEditor" ? null : (
+ <AppSection editor={editor} editorId={editorId} />
+ )}
</>
);
}
@@ -164,25 +175,29 @@ const AppSection = ({ editor, editorId }) => {
const [loaded, setLoaded] = useState(false);
useEffect(() => {
//@ts-ignore
- EditorOverlay = require('./loading.js').default;
+ EditorOverlay = require("./loading.js").default;
//@ts-ignore
- IconButton = require('../../components/ui/icon-button/index.tsx').IconButton;
+ IconButton =
+ require("../../components/ui/icon-button/index.tsx").IconButton;
setLoaded(true);
}, []);
return loaded ? (
<>
- {EditorOverlay ? <EditorOverlay editorId={editorId || ''} editor={editor} /> : null}
+ {EditorOverlay ? (
+ <EditorOverlay editorId={editorId || ""} editor={editor} />
+ ) : null}
<ReadonlyButton editor={editor} />
</>
) : null;
};
const ReadonlyButton = ({ editor }: { editor: useEditorType }) => {
- const readonly = useEditorStore(state => state.readonly);
+ const readonly = useEditorStore((state) => state.readonly);
const onPress = async () => {
if (editor.note.current) {
await db.notes?.note(editor.note.current.id).readonly();
- editor.note.current = db.notes?.note(editor.note.current.id).data as NoteType;
+ editor.note.current = db.notes?.note(editor.note.current.id)
+ .data as NoteType;
useEditorStore.getState().setReadonly(false);
}
};
@@ -194,7 +209,7 @@ const ReadonlyButton = ({ editor }: { editor: useEditorType }) => {
onPress={onPress}
color="accent"
customStyle={{
- position: 'absolute',
+ position: "absolute",
bottom: 20,
width: 60,
height: 60,
diff --git a/apps/mobile/app/screens/editor/loading.js b/apps/mobile/app/screens/editor/loading.js
index d7f3cd950..528b3cbca 100644
--- a/apps/mobile/app/screens/editor/loading.js
+++ b/apps/mobile/app/screens/editor/loading.js
@@ -1,23 +1,31 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { View } from 'react-native';
-import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { Button } from '../../components/ui/button';
-import { IconButton } from '../../components/ui/icon-button';
-import Paragraph from '../../components/ui/typography/paragraph';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eClearEditor, eOnLoadNote } from '../../utils/events';
-import { SIZE } from '../../utils/size';
-import { editorState } from './tiptap/utils';
+import React, { useEffect, useRef, useState } from "react";
+import { View } from "react-native";
+import Animated, {
+ useAnimatedStyle,
+ useSharedValue,
+ withTiming
+} from "react-native-reanimated";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { Button } from "../../components/ui/button";
+import { IconButton } from "../../components/ui/icon-button";
+import Paragraph from "../../components/ui/typography/paragraph";
+import {
+ eSendEvent,
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { eClearEditor, eOnLoadNote } from "../../utils/events";
+import { SIZE } from "../../utils/size";
+import { editorState } from "./tiptap/utils";
-const EditorOverlay = ({ editorId = '', editor }) => {
- const colors = useThemeStore(state => state.colors);
+const EditorOverlay = ({ editorId = "", editor }) => {
+ const colors = useThemeStore((state) => state.colors);
const [error, setError] = useState(false);
const opacity = useSharedValue(1);
const translateValue = useSharedValue(6000);
const insets = useSafeAreaInsets();
- const isDefaultEditor = editorId === '';
+ const isDefaultEditor = editorId === "";
const timers = useRef({
loading: 0,
error: 0,
@@ -30,7 +38,7 @@ const EditorOverlay = ({ editorId = '', editor }) => {
clearTimeout(timers.current.closing);
};
- const load = async _loading => {
+ const load = async (_loading) => {
editorState().overlay = true;
clearTimers();
if (_loading) {
@@ -60,10 +68,10 @@ const EditorOverlay = ({ editorId = '', editor }) => {
};
useEffect(() => {
- eSubscribeEvent('loadingNote' + editorId, load);
+ eSubscribeEvent("loadingNote" + editorId, load);
return () => {
clearTimers();
- eUnSubscribeEvent('loadingNote' + editorId, load);
+ eUnSubscribeEvent("loadingNote" + editorId, load);
};
}, [editorId]);
@@ -82,12 +90,12 @@ const EditorOverlay = ({ editorId = '', editor }) => {
<Animated.View
style={[
{
- position: 'absolute',
- width: '100%',
- height: '100%',
+ position: "absolute",
+ width: "100%",
+ height: "100%",
backgroundColor: colors.bg,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
zIndex: 100
},
animatedStyle
@@ -95,22 +103,22 @@ const EditorOverlay = ({ editorId = '', editor }) => {
>
<View
style={{
- width: '100%',
+ width: "100%",
backgroundColor: colors.bg,
borderRadius: 5,
- height: '100%',
- alignItems: 'flex-start',
+ height: "100%",
+ alignItems: "flex-start",
paddingTop: insets.top
}}
>
{isDefaultEditor ? (
<View
style={{
- flexDirection: 'row',
+ flexDirection: "row",
height: 50,
- alignItems: 'center',
- justifyContent: 'space-between',
- width: '100%',
+ alignItems: "center",
+ justifyContent: "space-between",
+ width: "100%",
paddingLeft: 6,
paddingRight: 12
}}
@@ -127,9 +135,9 @@ const EditorOverlay = ({ editorId = '', editor }) => {
<View
style={{
- flexDirection: 'row',
+ flexDirection: "row",
height: 50,
- alignItems: 'center'
+ alignItems: "center"
}}
>
<IconButton name="dots-horizontal" color={colors.pri} />
@@ -140,8 +148,8 @@ const EditorOverlay = ({ editorId = '', editor }) => {
<View
style={{
paddingHorizontal: 12,
- width: '100%',
- alignItems: 'flex-start'
+ width: "100%",
+ alignItems: "flex-start"
}}
>
{isDefaultEditor ? (
@@ -151,9 +159,9 @@ const EditorOverlay = ({ editorId = '', editor }) => {
backgroundColor: colors.nav,
borderRadius: 100,
marginBottom: 10,
- justifyContent: 'flex-start',
- alignItems: 'center',
- flexDirection: 'row',
+ justifyContent: "flex-start",
+ alignItems: "center",
+ flexDirection: "row",
paddingHorizontal: 10,
marginTop: 10
}}
@@ -176,7 +184,7 @@ const EditorOverlay = ({ editorId = '', editor }) => {
<View
style={{
height: 25,
- width: '100%',
+ width: "100%",
backgroundColor: colors.nav,
borderRadius: 5
}}
@@ -185,9 +193,9 @@ const EditorOverlay = ({ editorId = '', editor }) => {
<View
style={{
height: 12,
- width: '100%',
+ width: "100%",
marginTop: 10,
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
<View
@@ -222,7 +230,7 @@ const EditorOverlay = ({ editorId = '', editor }) => {
<View
style={{
height: 16,
- width: '100%',
+ width: "100%",
backgroundColor: colors.nav,
borderRadius: 5,
marginTop: 10
@@ -232,7 +240,7 @@ const EditorOverlay = ({ editorId = '', editor }) => {
<View
style={{
height: 16,
- width: '100%',
+ width: "100%",
backgroundColor: colors.nav,
borderRadius: 5,
marginTop: 10
@@ -255,7 +263,7 @@ const EditorOverlay = ({ editorId = '', editor }) => {
type="error"
style={{
marginTop: 20,
- alignSelf: 'flex-start',
+ alignSelf: "flex-start",
borderRadius: 100,
height: 40
}}
@@ -271,11 +279,12 @@ const EditorOverlay = ({ editorId = '', editor }) => {
size={SIZE.xs}
color={colors.icon}
style={{
- maxWidth: '100%',
+ maxWidth: "100%",
marginTop: 5
}}
>
- If the editor fails to load even after reloading. Try restarting the app.
+ If the editor fails to load even after reloading. Try restarting
+ the app.
</Paragraph>
</>
) : null}
diff --git a/apps/mobile/app/screens/editor/progress.js b/apps/mobile/app/screens/editor/progress.js
index b99533650..b642d1955 100644
--- a/apps/mobile/app/screens/editor/progress.js
+++ b/apps/mobile/app/screens/editor/progress.js
@@ -1,14 +1,14 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useAttachmentStore } from '../../stores/use-attachment-store';
-import { SIZE } from '../../utils/size';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { ProgressBarComponent } from '../../components/ui/svg/lazy';
+import React, { useEffect, useRef, useState } from "react";
+import { View } from "react-native";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useAttachmentStore } from "../../stores/use-attachment-store";
+import { SIZE } from "../../utils/size";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { ProgressBarComponent } from "../../components/ui/svg/lazy";
export const ProgressBar = () => {
- const colors = useThemeStore(state => state.colors);
- const loading = useAttachmentStore(state => state.loading);
+ const colors = useThemeStore((state) => state.colors);
+ const loading = useAttachmentStore((state) => state.loading);
const [prog, setProg] = useState(0);
const [visible, setVisible] = useState(false);
const timer = useRef();
@@ -43,13 +43,13 @@ export const ProgressBar = () => {
return visible ? (
<View
style={{
- justifyContent: 'center',
- position: 'absolute',
+ justifyContent: "center",
+ position: "absolute",
zIndex: 1,
marginTop: insets.top + 45,
- width: '100%'
+ width: "100%"
}}
- onLayout={event => setWidth(event.nativeEvent.layout.width)}
+ onLayout={(event) => setWidth(event.nativeEvent.layout.width)}
>
<ProgressBarComponent
size={SIZE.xxl}
diff --git a/apps/mobile/app/screens/editor/source.ts b/apps/mobile/app/screens/editor/source.ts
index 86d8532c7..9f79d02b5 100644
--- a/apps/mobile/app/screens/editor/source.ts
+++ b/apps/mobile/app/screens/editor/source.ts
@@ -1,4 +1,6 @@
-import { Platform } from 'react-native';
+import { Platform } from "react-native";
export const EDITOR_URI =
- Platform.OS === 'android' ? 'file:///android_asset/index.html' : 'web.bundle/index.html';
+ Platform.OS === "android"
+ ? "file:///android_asset/index.html"
+ : "web.bundle/index.html";
diff --git a/apps/mobile/app/screens/editor/tiptap/commands.ts b/apps/mobile/app/screens/editor/tiptap/commands.ts
index 6d69b885c..1fad88c08 100644
--- a/apps/mobile/app/screens/editor/tiptap/commands.ts
+++ b/apps/mobile/app/screens/editor/tiptap/commands.ts
@@ -1,17 +1,17 @@
import type {
Attachment,
AttachmentProgress
-} from '@streetwriters/editor/dist/es/extensions/attachment/index';
-import type { ImageAttributes } from '@streetwriters/editor/dist/es/extensions/image/index';
-import { createRef, RefObject } from 'react';
-import { Platform } from 'react-native';
-import { EdgeInsets } from 'react-native-safe-area-context';
-import WebView from 'react-native-webview';
-import { db } from '../../../common/database';
-import { sleep } from '../../../utils/time';
-import { NoteType } from '../../../utils/types';
-import { Settings } from './types';
-import { getResponse, randId, textInput } from './utils';
+} from "@streetwriters/editor/dist/es/extensions/attachment/index";
+import type { ImageAttributes } from "@streetwriters/editor/dist/es/extensions/image/index";
+import { createRef, RefObject } from "react";
+import { Platform } from "react-native";
+import { EdgeInsets } from "react-native-safe-area-context";
+import WebView from "react-native-webview";
+import { db } from "../../../common/database";
+import { sleep } from "../../../utils/time";
+import { NoteType } from "../../../utils/types";
+import { Settings } from "./types";
+import { getResponse, randId, textInput } from "./utils";
type Action = { job: string; id: string };
@@ -19,15 +19,15 @@ async function call(webview: RefObject<WebView | undefined>, action?: Action) {
if (!webview.current || !action) return;
setImmediate(() => webview.current?.injectJavaScript(action.job));
let response = await getResponse(action.id);
- console.log('webview job: ', action.id, response ? response.value : response);
+ console.log("webview job: ", action.id, response ? response.value : response);
if (!response) {
- console.warn('webview job failed', action.id);
+ console.warn("webview job failed", action.id);
}
return response ? response.value : response;
}
const fn = (fn: string) => {
- let id = randId('fn_');
+ let id = randId("fn_");
return {
job: `(async () => {
try {
@@ -59,7 +59,7 @@ class Commands {
focus = async () => {
if (!this.ref.current) return;
- if (Platform.OS === 'android') {
+ if (Platform.OS === "android") {
//this.ref.current?.requestFocus();
setTimeout(async () => {
if (!this.ref) return;
@@ -92,7 +92,8 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa
);
};
- setSessionId = async (id: string | null) => await this.doAsync(`globalThis.sessionId = "${id}"`);
+ setSessionId = async (id: string | null) =>
+ await this.doAsync(`globalThis.sessionId = "${id}"`);
setStatus = async (date: string | undefined, saved: string) =>
await this.doAsync(
@@ -109,7 +110,7 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa
};
setInsets = async (insets: EdgeInsets) => {
- logger.info('setInsets', insets);
+ logger.info("setInsets", insets);
await this.doAsync(`
if (typeof safeAreaController !== "undefined") {
safeAreaController.update(${JSON.stringify(insets)})
@@ -125,7 +126,9 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa
};
await this.doAsync(`
if (typeof globalThis.settingsController !== "undefined") {
- globalThis.settingsController.update(${JSON.stringify(this.previousSettings)})
+ globalThis.settingsController.update(${JSON.stringify(
+ this.previousSettings
+ )})
}
`);
};
@@ -140,7 +143,7 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa
return;
}
}
- console.log('setSettings', JSON.stringify(settings));
+ console.log("setSettings", JSON.stringify(settings));
await this.doAsync(`
if (typeof globalThis.settingsController !== "undefined") {
globalThis.settingsController.update(${JSON.stringify(settings)})
@@ -154,7 +157,9 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa
? []
: note.tags
.map((t: any) =>
- db.tags?.tag(t) ? { title: db.tags.tag(t).title, alias: db.tags.tag(t).alias } : null
+ db.tags?.tag(t)
+ ? { title: db.tags.tag(t).title, alias: db.tags.tag(t).alias }
+ : null
)
.filter((t: any) => t !== null);
await this.doAsync(`
@@ -173,18 +178,26 @@ typeof globalThis.statusBar !== "undefined" && statusBar.current.set({date:"",sa
};
insertAttachment = async (attachment: Attachment) => {
- await this.doAsync(`editor && editor.commands.insertAttachment(${JSON.stringify(attachment)})`);
+ await this.doAsync(
+ `editor && editor.commands.insertAttachment(${JSON.stringify(
+ attachment
+ )})`
+ );
};
setAttachmentProgress = async (attachmentProgress: AttachmentProgress) => {
await this.doAsync(
- `editor && editor.commands.setAttachmentProgress(${JSON.stringify(attachmentProgress)})`
+ `editor && editor.commands.setAttachmentProgress(${JSON.stringify(
+ attachmentProgress
+ )})`
);
};
insertImage = async (image: ImageAttributes) => {
- console.log('image data', image);
- await this.doAsync(`editor && editor.commands.insertImage(${JSON.stringify(image)})`);
+ console.log("image data", image);
+ await this.doAsync(
+ `editor && editor.commands.insertImage(${JSON.stringify(image)})`
+ );
};
updateImage = async ({ src, hash }: ImageAttributes) => {
diff --git a/apps/mobile/app/screens/editor/tiptap/picker.js b/apps/mobile/app/screens/editor/tiptap/picker.js
index b1e6f8c1e..12a751186 100644
--- a/apps/mobile/app/screens/editor/tiptap/picker.js
+++ b/apps/mobile/app/screens/editor/tiptap/picker.js
@@ -1,25 +1,29 @@
-import React from 'react';
-import { Platform, View } from 'react-native';
-import DocumentPicker from 'react-native-document-picker';
-import { launchCamera, launchImageLibrary } from 'react-native-image-picker';
-import Sodium from 'react-native-sodium';
-import RNFetchBlob from 'rn-fetch-blob';
-import { AttachmentItem } from '../../../components/attachments/attachment-item';
-import { eSendEvent, presentSheet, ToastEvent } from '../../../services/event-manager';
-import PremiumService from '../../../services/premium';
-import { db } from '../../../common/database';
-import { eCloseProgressDialog } from '../../../utils/events';
-import { sleep } from '../../../utils/time';
-import { editorController, editorState } from './utils';
+import React from "react";
+import { Platform, View } from "react-native";
+import DocumentPicker from "react-native-document-picker";
+import { launchCamera, launchImageLibrary } from "react-native-image-picker";
+import Sodium from "react-native-sodium";
+import RNFetchBlob from "rn-fetch-blob";
+import { AttachmentItem } from "../../../components/attachments/attachment-item";
+import {
+ eSendEvent,
+ presentSheet,
+ ToastEvent
+} from "../../../services/event-manager";
+import PremiumService from "../../../services/premium";
+import { db } from "../../../common/database";
+import { eCloseProgressDialog } from "../../../utils/events";
+import { sleep } from "../../../utils/time";
+import { editorController, editorState } from "./utils";
const FILE_SIZE_LIMIT = 500 * 1024 * 1024;
const IMAGE_SIZE_LIMIT = 50 * 1024 * 1024;
-const showEncryptionSheet = file => {
+const showEncryptionSheet = (file) => {
presentSheet({
- title: 'Encrypting attachment',
- paragraph: 'Please wait while we encrypt file for upload',
- icon: 'attachment',
+ title: "Encrypting attachment",
+ paragraph: "Please wait while we encrypt file for upload",
+ icon: "attachment",
component: (
<View
style={{
@@ -40,24 +44,24 @@ const showEncryptionSheet = file => {
});
};
-const santizeUri = uri => {
+const santizeUri = (uri) => {
uri = decodeURI(uri);
- uri = Platform.OS === 'ios' ? uri.replace('file:///', '/') : uri;
+ uri = Platform.OS === "ios" ? uri.replace("file:///", "/") : uri;
return uri;
};
-const file = async fileOptions => {
+const file = async (fileOptions) => {
try {
const options = {
- mode: 'import',
+ mode: "import",
allowMultiSelection: false
};
- if (Platform.OS == 'ios') {
- options.copyTo = 'cachesDirectory';
+ if (Platform.OS == "ios") {
+ options.copyTo = "cachesDirectory";
}
- console.log('generate key for attachment');
+ console.log("generate key for attachment");
const key = await db.attachments.generateKey();
- console.log('generated key for attachments: ', key);
+ console.log("generated key for attachments: ", key);
let file;
try {
file = await DocumentPicker.pick(options);
@@ -66,42 +70,43 @@ const file = async fileOptions => {
}
file = file[0];
- if (file.type.startsWith('image')) {
+ if (file.type.startsWith("image")) {
ToastEvent.show({
- title: 'Type not supported',
- message: 'Please add images from gallery or camera picker.',
- type: 'error'
+ title: "Type not supported",
+ message: "Please add images from gallery or camera picker.",
+ type: "error"
});
return;
}
if (file.size > FILE_SIZE_LIMIT) {
ToastEvent.show({
- title: 'File too large',
- message: 'The maximum allowed size per file is 500 MB',
- type: 'error'
+ title: "File too large",
+ message: "The maximum allowed size per file is 500 MB",
+ type: "error"
});
return;
}
if (file.copyError) {
ToastEvent.show({
- heading: 'Failed to open file',
+ heading: "Failed to open file",
message: file.copyError,
- type: 'error',
- context: 'global'
+ type: "error",
+ context: "global"
});
return;
}
- let uri = Platform.OS === 'ios' ? file.fileCopyUri : file.uri;
- console.log('file uri: ', uri);
- uri = Platform.OS === 'ios' ? santizeUri(uri) : uri;
+ let uri = Platform.OS === "ios" ? file.fileCopyUri : file.uri;
+ console.log("file uri: ", uri);
+ uri = Platform.OS === "ios" ? santizeUri(uri) : uri;
showEncryptionSheet(file);
const hash = await Sodium.hashFile({
uri: uri,
- type: 'url'
+ type: "url"
});
- if (!(await attachFile(uri, hash, file.type, file.name, fileOptions))) return;
+ if (!(await attachFile(uri, hash, file.type, file.name, fileOptions)))
+ return;
editorController.current?.commands.insertAttachment({
hash: hash,
filename: file.name,
@@ -114,15 +119,15 @@ const file = async fileOptions => {
} catch (e) {
ToastEvent.show({
heading: e.message,
- message: 'You need internet access to attach a file',
- type: 'error',
- context: 'global'
+ message: "You need internet access to attach a file",
+ type: "error",
+ context: "global"
});
- console.log('attachment error: ', e);
+ console.log("attachment error: ", e);
}
};
-const camera = async options => {
+const camera = async (options) => {
try {
await db.attachments.generateKey();
eSendEvent(eCloseProgressDialog);
@@ -130,22 +135,22 @@ const camera = async options => {
launchCamera(
{
includeBase64: true,
- mediaType: 'photo'
+ mediaType: "photo"
},
- response => handleImageResponse(response, options)
+ (response) => handleImageResponse(response, options)
);
} catch (e) {
ToastEvent.show({
heading: e.message,
- message: 'You need internet access to attach a file',
- type: 'error',
- context: 'global'
+ message: "You need internet access to attach a file",
+ type: "error",
+ context: "global"
});
- console.log('attachment error:', e);
+ console.log("attachment error:", e);
}
};
-const gallery = async options => {
+const gallery = async (options) => {
try {
await db.attachments.generateKey();
eSendEvent(eCloseProgressDialog);
@@ -153,23 +158,23 @@ const gallery = async options => {
launchImageLibrary(
{
includeBase64: true,
- mediaType: 'photo',
+ mediaType: "photo",
selectionLimit: 1
},
- response => handleImageResponse(response, options)
+ (response) => handleImageResponse(response, options)
);
} catch (e) {
ToastEvent.show({
heading: e.message,
- message: 'You need internet access to attach a file',
- type: 'error',
- context: 'global'
+ message: "You need internet access to attach a file",
+ type: "error",
+ context: "global"
});
- console.log('attachment error:', e);
+ console.log("attachment error:", e);
}
};
-const pick = async options => {
+const pick = async (options) => {
if (!PremiumService.get()) {
let user = await db.user.getUser();
if (editorState().isFocused) {
@@ -182,9 +187,9 @@ const pick = async options => {
}
return;
}
- console.log('opening picker', options.type);
- if (options?.type.startsWith('image') || options?.type === 'camera') {
- if (options.type === 'image') {
+ console.log("opening picker", options.type);
+ if (options?.type.startsWith("image") || options?.type === "camera") {
+ if (options.type === "image") {
gallery(options);
} else {
camera(options);
@@ -207,9 +212,9 @@ const handleImageResponse = async (response, options) => {
let image = response.assets[0];
if (image.fileSize > IMAGE_SIZE_LIMIT) {
ToastEvent.show({
- title: 'File too large',
- message: 'The maximum allowed size per image is 50 MB',
- type: 'error'
+ title: "File too large",
+ message: "The maximum allowed size per image is 50 MB",
+ type: "error"
});
return;
}
@@ -217,7 +222,7 @@ const handleImageResponse = async (response, options) => {
const uri = decodeURI(image.uri);
const hash = await Sodium.hashFile({
uri: uri,
- type: 'url'
+ type: "url"
});
let fileName = image.originalFileName || image.fileName;
@@ -240,10 +245,10 @@ async function attachFile(uri, hash, type, filename, options) {
if (options?.hash && options.hash !== hash) {
ToastEvent.show({
- heading: 'Please select the same file for reuploading',
+ heading: "Please select the same file for reuploading",
message: `Expected hash ${options.hash} but got ${hash}.`,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
return false;
}
@@ -252,7 +257,7 @@ async function attachFile(uri, hash, type, filename, options) {
let key = await db.attachments.generateKey();
encryptionInfo = await Sodium.encryptFile(key, {
uri: uri,
- type: 'url',
+ type: "url",
hash: hash
});
encryptionInfo.type = type;
@@ -264,13 +269,16 @@ async function attachFile(uri, hash, type, filename, options) {
} else {
encryptionInfo = { hash: hash };
}
- await db.attachments.add(encryptionInfo, editorController.current?.note?.id);
- if (Platform.OS === 'ios') await RNFetchBlob.fs.unlink(uri);
+ await db.attachments.add(
+ encryptionInfo,
+ editorController.current?.note?.id
+ );
+ if (Platform.OS === "ios") await RNFetchBlob.fs.unlink(uri);
return true;
} catch (e) {
- console.log('attach file error: ', e);
- if (Platform.OS === 'ios') {
+ console.log("attach file error: ", e);
+ if (Platform.OS === "ios") {
await RNFetchBlob.fs.unlink(uri);
}
return false;
diff --git a/apps/mobile/app/screens/editor/tiptap/types.ts b/apps/mobile/app/screens/editor/tiptap/types.ts
index aa2e854e6..0ff7bebe2 100644
--- a/apps/mobile/app/screens/editor/tiptap/types.ts
+++ b/apps/mobile/app/screens/editor/tiptap/types.ts
@@ -1,6 +1,6 @@
-import { useEditor } from './use-editor';
-import type { ToolbarGroupDefinition } from '@streetwriters/editor/dist/es/toolbar/types';
-import { ThemeStore } from '../../../stores/use-theme-store';
+import { useEditor } from "./use-editor";
+import type { ToolbarGroupDefinition } from "@streetwriters/editor/dist/es/toolbar/types";
+import { ThemeStore } from "../../../stores/use-theme-store";
export type useEditorType = ReturnType<typeof useEditor>;
export type EditorState = {
@@ -8,7 +8,7 @@ export type EditorState = {
isFullscreen: boolean;
onNoteCreated?: ((id: string) => void) | null;
isFocused: boolean;
- focusType: 'title' | 'editor' | null;
+ focusType: "title" | "editor" | null;
movedAway: boolean;
tooltip: boolean;
isRestoringState: boolean;
@@ -37,7 +37,7 @@ export type EditorProps = {
editorId?: string;
onLoad?: () => void;
onChange?: (html: string) => void;
- theme?: ThemeStore['colors'];
+ theme?: ThemeStore["colors"];
};
export type EditorMessage = {
@@ -66,8 +66,8 @@ export type Content = {
export type SavePayload = {
title?: string;
id?: string | null;
- data?: Content['data'];
- type?: Content['type'];
+ data?: Content["data"];
+ type?: Content["type"];
sessionId?: string | null;
sessionHistoryId?: number;
};
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
index a35b47f84..adc34c6c7 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor-events.ts
@@ -1,23 +1,27 @@
/* eslint-disable no-case-declarations */
/* eslint-disable @typescript-eslint/no-var-requires */
-import { getDefaultPresets } from '@streetwriters/editor/dist/es/toolbar/tooldefinitions';
-import { useCallback, useEffect, useRef } from 'react';
-import { BackHandler, InteractionManager, NativeEventSubscription } from 'react-native';
-import { WebViewMessageEvent } from 'react-native-webview';
-import { DDS } from '../../../services/device-detection';
+import { getDefaultPresets } from "@streetwriters/editor/dist/es/toolbar/tooldefinitions";
+import { useCallback, useEffect, useRef } from "react";
+import {
+ BackHandler,
+ InteractionManager,
+ NativeEventSubscription
+} from "react-native";
+import { WebViewMessageEvent } from "react-native-webview";
+import { DDS } from "../../../services/device-detection";
import {
eSendEvent,
eSubscribeEvent,
eUnSubscribeEvent,
ToastEvent
-} from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { useEditorStore } from '../../../stores/use-editor-store';
-import { useSettingStore } from '../../../stores/use-setting-store';
-import { useTagStore } from '../../../stores/use-tag-store';
-import { useUserStore } from '../../../stores/use-user-store';
-import umami from '../../../common/analytics/index';
-import { db } from '../../../common/database';
+} from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { useEditorStore } from "../../../stores/use-editor-store";
+import { useSettingStore } from "../../../stores/use-setting-store";
+import { useTagStore } from "../../../stores/use-tag-store";
+import { useUserStore } from "../../../stores/use-user-store";
+import umami from "../../../common/analytics/index";
+import { db } from "../../../common/database";
import {
eClearEditor,
eCloseFullscreenEditor,
@@ -27,53 +31,53 @@ import {
eOpenPremiumDialog,
eOpenPublishNoteDialog,
eOpenTagsDialog
-} from '../../../utils/events';
-import filesystem from '../../../common/filesystem';
-import { tabBarRef } from '../../../utils/global-refs';
-import useKeyboard from '../../../hooks/use-keyboard';
-import { NoteType } from '../../../utils/types';
-import { useDragState } from '../../settings/editor/state';
-import { EditorMessage, EditorProps, useEditorType } from './types';
-import { EditorEvents, editorState } from './utils';
+} from "../../../utils/events";
+import filesystem from "../../../common/filesystem";
+import { tabBarRef } from "../../../utils/global-refs";
+import useKeyboard from "../../../hooks/use-keyboard";
+import { NoteType } from "../../../utils/types";
+import { useDragState } from "../../settings/editor/state";
+import { EditorMessage, EditorProps, useEditorType } from "./types";
+import { EditorEvents, editorState } from "./utils";
export const EventTypes = {
- selection: 'editor-event:selection',
- content: 'editor-event:content',
- title: 'editor-event:title',
- scroll: 'editor-event:scroll',
- history: 'editor-event:history',
- newtag: 'editor-event:newtag',
- tag: 'editor-event:tag',
- filepicker: 'editor-event:picker',
- download: 'editor-event:download-attachment',
- logger: 'native:logger',
- back: 'editor-event:back',
- pro: 'editor-event:pro',
- monograph: 'editor-event:monograph',
- properties: 'editor-event:properties',
- fullscreen: 'editor-event:fullscreen'
+ selection: "editor-event:selection",
+ content: "editor-event:content",
+ title: "editor-event:title",
+ scroll: "editor-event:scroll",
+ history: "editor-event:history",
+ newtag: "editor-event:newtag",
+ tag: "editor-event:tag",
+ filepicker: "editor-event:picker",
+ download: "editor-event:download-attachment",
+ logger: "native:logger",
+ back: "editor-event:back",
+ pro: "editor-event:pro",
+ monograph: "editor-event:monograph",
+ properties: "editor-event:properties",
+ fullscreen: "editor-event:fullscreen"
};
const publishNote = async (editor: useEditorType) => {
const user = useUserStore.getState().user;
if (!user) {
ToastEvent.show({
- heading: 'Login required',
- message: 'Login to publish',
- context: 'global',
+ heading: "Login required",
+ message: "Login to publish",
+ context: "global",
func: () => {
eSendEvent(eOpenLoginDialog);
},
- actionText: 'Login'
+ actionText: "Login"
});
return;
}
if (!user?.isEmailConfirmed) {
ToastEvent.show({
- heading: 'Email not verified',
- message: 'Please verify your email first.',
- context: 'global'
+ heading: "Email not verified",
+ message: "Please verify your email first.",
+ context: "global"
});
return;
}
@@ -82,9 +86,9 @@ const publishNote = async (editor: useEditorType) => {
let note = db.notes?.note(currentNote.id)?.data as NoteType;
if (note?.locked) {
ToastEvent.show({
- heading: 'Locked notes cannot be published',
- type: 'error',
- context: 'global'
+ heading: "Locked notes cannot be published",
+ type: "error",
+ context: "global"
});
return;
}
@@ -103,13 +107,13 @@ const showActionsheet = async (editor: useEditorType) => {
if (editorState().isFocused || editorState().isFocused) {
editorState().isFocused = true;
}
- const { Properties } = require('../../../components/properties/index.js');
- Properties.present(note, ['Dark Mode']);
+ const { Properties } = require("../../../components/properties/index.js");
+ Properties.present(note, ["Dark Mode"]);
} else {
ToastEvent.show({
- heading: 'Start writing to create a new note',
- type: 'success',
- context: 'global'
+ heading: "Start writing to create a new note",
+ type: "success",
+ context: "global"
});
}
};
@@ -118,20 +122,22 @@ export const useEditorEvents = (
editor: useEditorType,
{ readonly: editorPropReadonly, noHeader, noToolbar }: Partial<EditorProps>
) => {
- const deviceMode = useSettingStore(state => state.deviceMode);
- const fullscreen = useSettingStore(state => state.fullscreen);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
+ const fullscreen = useSettingStore((state) => state.fullscreen);
const handleBack = useRef<NativeEventSubscription>();
- const readonly = useEditorStore(state => state.readonly);
- const isPremium = useUserStore(state => state.premium);
- const doubleSpacedLines = useSettingStore(state => state.settings?.doubleSpacedLines);
- const tools = useDragState(state => state.data);
+ const readonly = useEditorStore((state) => state.readonly);
+ const isPremium = useUserStore((state) => state.premium);
+ const doubleSpacedLines = useSettingStore(
+ (state) => state.settings?.doubleSpacedLines
+ );
+ const tools = useDragState((state) => state.data);
const { keyboardShown } = useKeyboard();
if (!editor) return null;
useEffect(() => {
- console.log('keyboardShown', keyboardShown);
+ console.log("keyboardShown", keyboardShown);
editor.commands.setSettings({
- deviceMode: deviceMode || 'mobile',
+ deviceMode: deviceMode || "mobile",
fullscreen: fullscreen || false,
premium: isPremium,
readonly: readonly || editorPropReadonly,
@@ -157,25 +163,30 @@ export const useEditorEvents = (
const onBackPress = useCallback(async () => {
const editorHandledBack = await editor.commands.handleBack();
if (!editorHandledBack) {
- logger.info('editor handled back event', editorHandledBack);
+ logger.info("editor handled back event", editorHandledBack);
return;
}
setTimeout(async () => {
- if (deviceMode !== 'mobile' && fullscreen) {
+ if (deviceMode !== "mobile" && fullscreen) {
if (fullscreen) {
eSendEvent(eCloseFullscreenEditor);
}
return;
}
- if (deviceMode === 'mobile') {
+ if (deviceMode === "mobile") {
editorState().movedAway = true;
tabBarRef.current?.goToPage(0);
}
setImmediate(() => {
useEditorStore.getState().setCurrentlyEditingNote(null);
setTimeout(() => {
- Navigation.queueRoutesForUpdate('ColoredNotes', 'Notes', 'TaggedNotes', 'TopicNotes');
+ Navigation.queueRoutesForUpdate(
+ "ColoredNotes",
+ "Notes",
+ "TaggedNotes",
+ "TopicNotes"
+ );
}, 500);
});
editorState().currentlyEditing = false;
@@ -193,23 +204,29 @@ export const useEditorEvents = (
const onLoadNote = useCallback(async () => {
InteractionManager.runAfterInteractions(() => {
if (!DDS.isTab) {
- handleBack.current = BackHandler.addEventListener('hardwareBackPress', onHardwareBackPress);
+ handleBack.current = BackHandler.addEventListener(
+ "hardwareBackPress",
+ onHardwareBackPress
+ );
}
});
}, []);
const onCallClear = useCallback(async (value: string) => {
- if (value === 'removeHandler') {
+ if (value === "removeHandler") {
if (handleBack.current) {
handleBack.current.remove();
}
return;
}
- if (value === 'addHandler') {
+ if (value === "addHandler") {
if (handleBack.current) {
handleBack.current.remove();
}
- handleBack.current = BackHandler.addEventListener('hardwareBackPress', onHardwareBackPress);
+ handleBack.current = BackHandler.addEventListener(
+ "hardwareBackPress",
+ onHardwareBackPress
+ );
return;
}
if (editorState().currentlyEditing) {
@@ -219,7 +236,10 @@ export const useEditorEvents = (
useEffect(() => {
if (fullscreen && DDS.isTab) {
- handleBack.current = BackHandler.addEventListener('hardwareBackPress', onHardwareBackPress);
+ handleBack.current = BackHandler.addEventListener(
+ "hardwareBackPress",
+ onHardwareBackPress
+ );
}
return () => {
@@ -242,14 +262,14 @@ export const useEditorEvents = (
const data = event.nativeEvent.data;
let editorMessage = JSON.parse(data) as EditorMessage;
- logger.info('editor', editorMessage.type);
+ logger.info("editor", editorMessage.type);
if (
editorMessage.sessionId !== editor.sessionId &&
editorMessage.type !== EditorEvents.status
) {
logger.error(
- 'editor',
- 'invalid session',
+ "editor",
+ "invalid session",
editorMessage.type,
editor.sessionId,
editorMessage.sessionId
@@ -259,7 +279,7 @@ export const useEditorEvents = (
}
switch (editorMessage.type) {
case EventTypes.logger:
- logger.info('[WEBVIEW LOG]', editorMessage.value);
+ logger.info("[WEBVIEW LOG]", editorMessage.value);
break;
case EventTypes.content:
editor.saveContent({
@@ -290,28 +310,28 @@ export const useEditorEvents = (
useTagStore.getState().setTags();
await editor.commands.setTags(editor.note.current);
Navigation.queueRoutesForUpdate(
- 'ColoredNotes',
- 'Notes',
- 'TaggedNotes',
- 'TopicNotes',
- 'Tags'
+ "ColoredNotes",
+ "Notes",
+ "TaggedNotes",
+ "TopicNotes",
+ "Tags"
);
});
}
break;
case EventTypes.filepicker:
- const { pick } = require('./picker.js').default;
+ const { pick } = require("./picker.js").default;
pick({ type: editorMessage.value });
break;
case EventTypes.download:
- console.log('download attachment request', editorMessage.value);
+ console.log("download attachment request", editorMessage.value);
filesystem.downloadAttachment(editorMessage.value?.hash, true);
break;
case EventTypes.pro:
if (editor.state.current?.isFocused) {
editor.state.current.isFocused = true;
}
- umami.pageView('/pro-screen', '/editor');
+ umami.pageView("/pro-screen", "/editor");
eSendEvent(eOpenPremiumDialog);
break;
case EventTypes.monograph:
@@ -329,7 +349,7 @@ export const useEditorEvents = (
break;
default:
console.log(
- 'unhandled event recieved from editor: ',
+ "unhandled event recieved from editor: ",
editorMessage.type,
editorMessage.value
);
diff --git a/apps/mobile/app/screens/editor/tiptap/use-editor.ts b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
index 4b5928d67..a1f9bc0ee 100644
--- a/apps/mobile/app/screens/editor/tiptap/use-editor.ts
+++ b/apps/mobile/app/screens/editor/tiptap/use-editor.ts
@@ -1,21 +1,25 @@
-import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import WebView from 'react-native-webview';
-import { DDS } from '../../../services/device-detection';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
-import Navigation from '../../../services/navigation';
-import { TipManager } from '../../../services/tip-manager';
-import { useEditorStore } from '../../../stores/use-editor-store';
-import { useTagStore } from '../../../stores/use-tag-store';
-import { ThemeStore, useThemeStore } from '../../../stores/use-theme-store';
-import { db } from '../../../common/database';
-import { MMKV } from '../../../common/database/mmkv';
-import { eOnLoadNote } from '../../../utils/events';
-import { tabBarRef } from '../../../utils/global-refs';
-import { timeConverter } from '../../../utils/time';
-import { NoteType } from '../../../utils/types';
-import Commands from './commands';
-import { AppState, Content, EditorState, Note, SavePayload } from './types';
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import WebView from "react-native-webview";
+import { DDS } from "../../../services/device-detection";
+import {
+ eSendEvent,
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../../services/event-manager";
+import Navigation from "../../../services/navigation";
+import { TipManager } from "../../../services/tip-manager";
+import { useEditorStore } from "../../../stores/use-editor-store";
+import { useTagStore } from "../../../stores/use-tag-store";
+import { ThemeStore, useThemeStore } from "../../../stores/use-theme-store";
+import { db } from "../../../common/database";
+import { MMKV } from "../../../common/database/mmkv";
+import { eOnLoadNote } from "../../../utils/events";
+import { tabBarRef } from "../../../utils/global-refs";
+import { timeConverter } from "../../../utils/time";
+import { NoteType } from "../../../utils/types";
+import Commands from "./commands";
+import { AppState, Content, EditorState, Note, SavePayload } from "./types";
import {
defaultState,
EditorEvents,
@@ -23,13 +27,13 @@ import {
isEditorLoaded,
makeSessionId,
post
-} from './utils';
+} from "./utils";
export const useEditor = (
- editorId = '',
+ editorId = "",
readonly?: boolean,
onChange?: (html: string) => void,
- theme?: ThemeStore['colors']
+ theme?: ThemeStore["colors"]
) => {
const [loading, setLoading] = useState(false);
const [sessionId, setSessionId] = useState<string>(makeSessionId());
@@ -42,18 +46,21 @@ export const useEditor = (
const sessionHistoryId = useRef<number>();
const state = useRef<Partial<EditorState>>(defaultState);
const placeholderTip = useRef(TipManager.placeholderTip());
- const tags = useTagStore(state => state.tags);
+ const tags = useTagStore((state) => state.tags);
const insets = useSafeAreaInsets();
- const isDefaultEditor = editorId === '';
+ const isDefaultEditor = editorId === "";
const saveCount = useRef(0);
const postMessage = useCallback(
- async (type: string, data: any) => await post(editorRef, sessionIdRef.current, type, data),
+ async (type: string, data: any) =>
+ await post(editorRef, sessionIdRef.current, type, data),
[sessionIdRef]
);
useEffect(() => {
- commands.setInsets(isDefaultEditor ? insets : { top: 0, left: 0, right: 0, bottom: 0 });
+ commands.setInsets(
+ isDefaultEditor ? insets : { top: 0, left: 0, right: 0, bottom: 0 }
+ );
}, [insets]);
useEffect(() => {
@@ -66,7 +73,7 @@ export const useEditor = (
useEffect(() => {
if (theme) return;
- let unsub = useThemeStore.subscribe(state => {
+ let unsub = useThemeStore.subscribe((state) => {
postMessage(EditorEvents.theme, state.colors);
});
@@ -76,7 +83,7 @@ export const useEditor = (
}, []);
useEffect(() => {
- console.log('sessionId:', sessionId);
+ console.log("sessionId:", sessionId);
async () => {
await commands.setSessionId(sessionIdRef.current);
if (sessionIdRef.current) {
@@ -89,13 +96,16 @@ export const useEditor = (
};
}, [sessionId, loading]);
- const overlay = (show: boolean, data = { type: 'new' }) => {
- eSendEvent('loadingNote' + editorId, show ? currentNote.current || data : false);
+ const overlay = (show: boolean, data = { type: "new" }) => {
+ eSendEvent(
+ "loadingNote" + editorId,
+ show ? currentNote.current || data : false
+ );
};
const onReady = useCallback(async () => {
if (!(await isEditorLoaded(editorRef, sessionIdRef.current))) {
- console.log('ON READY CALLED');
+ console.log("ON READY CALLED");
overlay(true);
setLoading(true);
}
@@ -107,10 +117,13 @@ export const useEditor = (
}
}, [loading]);
- const withTimer = useCallback((id: string, fn: () => void, duration: number) => {
- clearTimeout(timers.current[id]);
- timers.current[id] = setTimeout(fn, duration);
- }, []);
+ const withTimer = useCallback(
+ (id: string, fn: () => void, duration: number) => {
+ clearTimeout(timers.current[id]);
+ timers.current[id] = setTimeout(fn, duration);
+ },
+ []
+ );
const reset = useCallback(async (resetState = true) => {
currentNote.current?.id && db.fs.cancel(currentNote.current.id);
@@ -119,12 +132,13 @@ export const useEditor = (
sessionHistoryId.current = undefined;
saveCount.current = 0;
useEditorStore.getState().setReadonly(false);
- postMessage(EditorEvents.title, '');
+ postMessage(EditorEvents.title, "");
await commands.clearContent();
await commands.clearTags();
- console.log('reset state: ', resetState);
+ console.log("reset state: ", resetState);
if (resetState) {
- isDefaultEditor && useEditorStore.getState().setCurrentlyEditingNote(null);
+ isDefaultEditor &&
+ useEditorStore.getState().setCurrentlyEditingNote(null);
placeholderTip.current = TipManager.placeholderTip();
await commands.setPlaceholder(placeholderTip.current);
}
@@ -139,12 +153,18 @@ export const useEditor = (
sessionId: currentSessionId,
sessionHistoryId: currentSessionHistoryId
}: SavePayload) => {
- if (readonly || useEditorStore.getState().readonly || currentNote.current?.readonly) return;
+ if (
+ readonly ||
+ useEditorStore.getState().readonly ||
+ currentNote.current?.readonly
+ )
+ return;
- console.log('saving note', id);
+ console.log("saving note", id);
try {
if (id && !db.notes?.note(id)) {
- isDefaultEditor && useEditorStore.getState().setCurrentlyEditingNote(null);
+ isDefaultEditor &&
+ useEditorStore.getState().setCurrentlyEditingNote(null);
await reset();
return;
}
@@ -181,11 +201,17 @@ export const useEditor = (
currentNote.current = db.notes?.note(id).data as NoteType;
state.current?.onNoteCreated && state.current.onNoteCreated(id);
if (!noteData.title) {
- postMessage(EditorEvents.titleplaceholder, currentNote.current.title);
+ postMessage(
+ EditorEvents.titleplaceholder,
+ currentNote.current.title
+ );
}
}
- if (useEditorStore.getState().currentEditingNote !== id && isDefaultEditor) {
+ if (
+ useEditorStore.getState().currentEditingNote !== id &&
+ isDefaultEditor
+ ) {
setTimeout(() => {
id && useEditorStore.getState().setCurrentlyEditingNote(id);
});
@@ -198,23 +224,29 @@ export const useEditor = (
}
console.log(id, sessionIdRef.current, currentSessionId);
if (id && sessionIdRef.current === currentSessionId) {
- console.log('updating state');
+ console.log("updating state");
note = db.notes?.note(id)?.data as Note;
- await commands.setStatus(timeConverter(note.dateEdited), 'Saved');
+ await commands.setStatus(timeConverter(note.dateEdited), "Saved");
if (
saveCount.current < 2 ||
currentNote.current?.title !== note.title ||
- currentNote.current?.headline?.slice(0, 200) !== note.headline?.slice(0, 200)
+ currentNote.current?.headline?.slice(0, 200) !==
+ note.headline?.slice(0, 200)
) {
- Navigation.queueRoutesForUpdate('ColoredNotes', 'Notes', 'TaggedNotes', 'TopicNotes');
+ Navigation.queueRoutesForUpdate(
+ "ColoredNotes",
+ "Notes",
+ "TaggedNotes",
+ "TopicNotes"
+ );
}
}
saveCount.current++;
return id;
} catch (e) {
- console.log('error saving: ', e);
+ console.log("error saving: ", e);
}
},
[commands, reset]
@@ -225,7 +257,7 @@ export const useEditor = (
if (note.locked || note.content) {
currentContent.current = {
data: note.content?.data,
- type: note.content?.type || 'tiny'
+ type: note.content?.type || "tiny"
};
} else {
currentContent.current = await db.content?.raw(note.contentId);
@@ -234,12 +266,12 @@ export const useEditor = (
const loadNote = useCallback(
async (item: NoteType) => {
- console.log('loading note', item.type, eOnLoadNote + editorId);
+ console.log("loading note", item.type, eOnLoadNote + editorId);
state.current.currentlyEditing = true;
const editorState = useEditorStore.getState();
//@ts-ignore todo
- if (item && item.type === 'new') {
+ if (item && item.type === "new") {
currentNote.current && (await reset());
let nextSessionId = makeSessionId(item);
setSessionId(nextSessionId);
@@ -261,7 +293,7 @@ export const useEditor = (
sessionIdRef.current = nextSessionId;
await commands.setSessionId(nextSessionId);
currentNote.current = item;
- await commands.setStatus(timeConverter(item.dateEdited), 'Saved');
+ await commands.setStatus(timeConverter(item.dateEdited), "Saved");
await postMessage(EditorEvents.title, item.title);
await postMessage(EditorEvents.html, currentContent.current?.data);
useEditorStore.getState().setReadonly(item.readonly);
@@ -280,9 +312,16 @@ export const useEditor = (
if (!currentNote.current?.id) return;
//@ts-ignore
if (currentNote.current?.content?.isPreview) {
- db.content?.downloadMedia(currentNote.current?.id, currentNote.current.content, true);
+ db.content?.downloadMedia(
+ currentNote.current?.id,
+ currentNote.current.content,
+ true
+ );
} else {
- const images = db.attachments?.ofNote(currentNote.current?.id, 'images');
+ const images = db.attachments?.ofNote(
+ currentNote.current?.id,
+ "images"
+ );
if (images && images.length > 0) {
db.attachments?.downloadImages(currentNote.current.id);
}
@@ -298,26 +337,38 @@ export const useEditor = (
}, [editorId]);
const saveContent = useCallback(
- ({ title, content, type }: { title?: string; content?: string; type: string }) => {
+ ({
+ title,
+ content,
+ type
+ }: {
+ title?: string;
+ content?: string;
+ type: string;
+ }) => {
if (type === EditorEvents.content) {
currentContent.current = {
data: content,
- type: 'tiptap'
+ type: "tiptap"
};
}
let params = {
title,
data: content,
- type: 'tiptap',
+ type: "tiptap",
sessionId,
id: currentNote.current?.id,
sessionHistoryId: sessionHistoryId.current
};
withTimer(
- currentNote.current?.id || 'newnote',
+ currentNote.current?.id || "newnote",
() => {
- if (currentNote.current && !params.id && params.sessionId === sessionId) {
+ if (
+ currentNote.current &&
+ !params.id &&
+ params.sessionId === sessionId
+ ) {
params.id = currentNote.current?.id;
}
if (onChange && params.data) {
@@ -333,13 +384,15 @@ export const useEditor = (
);
const onLoad = useCallback(async () => {
- console.log('on editor load');
+ console.log("on editor load");
state.current.ready = true;
onReady();
postMessage(EditorEvents.theme, theme || useThemeStore.getState().colors);
- commands.setInsets(isDefaultEditor ? insets : { top: 0, left: 0, right: 0, bottom: 0 });
+ commands.setInsets(
+ isDefaultEditor ? insets : { top: 0, left: 0, right: 0, bottom: 0 }
+ );
if (currentNote.current) {
- console.log('force reload note');
+ console.log("force reload note");
//@ts-ignore
loadNote({ ...currentNote.current, forced: true });
} else {
@@ -350,7 +403,7 @@ export const useEditor = (
}, [state, currentNote, loadNote]);
async function restoreEditorState() {
- let json = await MMKV.getItem('appState');
+ let json = await MMKV.getItem("appState");
if (json) {
let appState = JSON.parse(json) as AppState;
if (
@@ -366,15 +419,15 @@ export const useEditor = (
tabBarRef.current?.goToPage(1);
}
setTimeout(() => {
- console.log('restoring app state here');
+ console.log("restoring app state here");
if (appState.note) {
//@ts-ignore
loadNote(appState.note);
}
}, 1);
- MMKV.removeItem('appState');
+ MMKV.removeItem("appState");
state.current.movedAway = false;
- eSendEvent('load_overlay', 'hide_editor');
+ eSendEvent("load_overlay", "hide_editor");
state.current.isRestoringState = false;
return;
}
diff --git a/apps/mobile/app/screens/editor/tiptap/utils.ts b/apps/mobile/app/screens/editor/tiptap/utils.ts
index 3bca0c93f..c20abaaee 100644
--- a/apps/mobile/app/screens/editor/tiptap/utils.ts
+++ b/apps/mobile/app/screens/editor/tiptap/utils.ts
@@ -1,9 +1,12 @@
-import { createRef, RefObject } from 'react';
-import { TextInput } from 'react-native';
-import WebView from 'react-native-webview';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../../services/event-manager';
-import { NoteType } from '../../../utils/types';
-import { EditorState, useEditorType } from './types';
+import { createRef, RefObject } from "react";
+import { TextInput } from "react-native";
+import WebView from "react-native-webview";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../../services/event-manager";
+import { NoteType } from "../../../utils/types";
+import { EditorState, useEditorType } from "./types";
export const textInput = createRef<TextInput>();
export const editorController = createRef<useEditorType>();
@@ -13,37 +16,45 @@ export const defaultState: Partial<EditorState> = {
export function editorState() {
if (!editorController.current?.state.current) {
- console.warn('Editor state not ready');
+ console.warn("Editor state not ready");
}
return editorController.current?.state.current || defaultState;
}
export const EditorEvents: { [name: string]: string } = {
- html: 'native:html',
- title: 'native:title',
- theme: 'native:theme',
- titleplaceholder: 'native:titleplaceholder',
- logger: 'native:logger',
- status: 'native:status'
+ html: "native:html",
+ title: "native:title",
+ theme: "native:theme",
+ titleplaceholder: "native:titleplaceholder",
+ logger: "native:logger",
+ status: "native:status"
};
export function randId(prefix: string) {
return Math.random()
.toString(36)
- .replace('0.', prefix || '');
+ .replace("0.", prefix || "");
}
export function makeSessionId(item?: NoteType) {
- return item?.id ? item.id + randId('_session_') : randId('session_');
+ return item?.id ? item.id + randId("_session_") : randId("session_");
}
-export async function isEditorLoaded(ref: RefObject<WebView>, sessionId: string) {
+export async function isEditorLoaded(
+ ref: RefObject<WebView>,
+ sessionId: string
+) {
return await post(ref, sessionId, EditorEvents.status);
}
-export async function post(ref: RefObject<WebView>, sessionId: string, type: string, value = null) {
+export async function post(
+ ref: RefObject<WebView>,
+ sessionId: string,
+ type: string,
+ value = null
+) {
if (!sessionId) {
- console.warn('post called without sessionId of type:', type);
+ console.warn("post called without sessionId of type:", type);
return;
}
let message = {
@@ -53,7 +64,7 @@ export async function post(ref: RefObject<WebView>, sessionId: string, type: str
};
setImmediate(() => ref.current?.postMessage(JSON.stringify(message)));
let response = await getResponse(type);
- console.log('post: ', type, sessionId, 'result:', !!response);
+ console.log("post: ", type, sessionId, "result:", !!response);
return response;
}
@@ -64,8 +75,10 @@ type WebviewResponseData = {
value: any;
};
-export const getResponse = async (type: string): Promise<WebviewResponseData | false> => {
- return new Promise(resolve => {
+export const getResponse = async (
+ type: string
+): Promise<WebviewResponseData | false> => {
+ return new Promise((resolve) => {
let callback = (data: WebviewResponseData) => {
eUnSubscribeEvent(type, callback);
resolve(data);
@@ -80,10 +93,10 @@ export const getResponse = async (type: string): Promise<WebviewResponseData | f
export function isContentInvalid(content: string | undefined) {
return (
!content ||
- content === '' ||
- content.trim() === '' ||
- content === '<p></p>' ||
- content === '<p><br></p>' ||
- content === '<p>&nbsp;</p>'
+ content === "" ||
+ content.trim() === "" ||
+ content === "<p></p>" ||
+ content === "<p><br></p>" ||
+ content === "<p>&nbsp;</p>"
);
}
diff --git a/apps/mobile/app/screens/editor/wrapper.js b/apps/mobile/app/screens/editor/wrapper.js
index fd99f097d..98c3c443b 100644
--- a/apps/mobile/app/screens/editor/wrapper.js
+++ b/apps/mobile/app/screens/editor/wrapper.js
@@ -1,37 +1,45 @@
-import React, { useEffect } from 'react';
-import { AppState, KeyboardAvoidingView, Platform, TextInput, View } from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import Editor from '.';
-import { PremiumToast } from '../../components/premium/premium-toast';
-import { DDS } from '../../services/device-detection';
-import { useNoteStore } from '../../stores/use-notes-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { editorRef } from '../../utils/global-refs';
-import useIsFloatingKeyboard from '../../hooks/use-is-floating-keyboard';
-import useKeyboard from '../../hooks/use-keyboard';
-import { ProgressBar } from './progress';
-import { editorController, editorState, textInput } from './tiptap/utils';
+import React, { useEffect } from "react";
+import {
+ AppState,
+ KeyboardAvoidingView,
+ Platform,
+ TextInput,
+ View
+} from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import Editor from ".";
+import { PremiumToast } from "../../components/premium/premium-toast";
+import { DDS } from "../../services/device-detection";
+import { useNoteStore } from "../../stores/use-notes-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { editorRef } from "../../utils/global-refs";
+import useIsFloatingKeyboard from "../../hooks/use-is-floating-keyboard";
+import useKeyboard from "../../hooks/use-keyboard";
+import { ProgressBar } from "./progress";
+import { editorController, editorState, textInput } from "./tiptap/utils";
export const EditorWrapper = ({ width }) => {
- const colors = useThemeStore(state => state.colors);
- const deviceMode = useSettingStore(state => state.deviceMode);
- const loading = useNoteStore(state => state.loading);
+ const colors = useThemeStore((state) => state.colors);
+ const deviceMode = useSettingStore((state) => state.deviceMode);
+ const loading = useNoteStore((state) => state.loading);
const insets = useSafeAreaInsets();
const floating = useIsFloatingKeyboard();
- const introCompleted = useSettingStore(state => state.settings.introCompleted);
+ const introCompleted = useSettingStore(
+ (state) => state.settings.introCompleted
+ );
const keyboard = useKeyboard();
- const onAppStateChanged = async state => {
+ const onAppStateChanged = async (state) => {
if (editorState().movedAway) return;
- if (state === 'active') {
+ if (state === "active") {
editorController.current.onReady();
}
};
useEffect(() => {
if (loading) return;
- let sub = AppState.addEventListener('change', onAppStateChanged);
+ let sub = AppState.addEventListener("change", onAppStateChanged);
return () => {
sub?.remove();
};
@@ -41,7 +49,7 @@ export const EditorWrapper = ({ width }) => {
console.log(insets.top);
if (!keyboard.keyboardShown) return insets.bottom / 2;
if (Platform.isPad && !floating) return 16;
- if (Platform.OS === 'ios') return insets.bottom / 2;
+ if (Platform.OS === "ios") return insets.bottom / 2;
return 6;
};
@@ -50,16 +58,16 @@ export const EditorWrapper = ({ width }) => {
testID="editor-wrapper"
ref={editorRef}
style={{
- width: width[!introCompleted ? 'mobile' : deviceMode]?.c,
- height: '100%',
+ width: width[!introCompleted ? "mobile" : deviceMode]?.c,
+ height: "100%",
backgroundColor: colors.bg,
borderLeftWidth: DDS.isTab ? 1 : 0,
- borderLeftColor: DDS.isTab ? colors.nav : 'transparent'
+ borderLeftColor: DDS.isTab ? colors.nav : "transparent"
}}
>
{loading || !introCompleted ? null : (
<KeyboardAvoidingView
- behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
+ behavior={Platform.OS === "ios" ? "padding" : "height"}
style={{
flex: 1,
marginBottom: getMarginBottom()
@@ -71,7 +79,7 @@ export const EditorWrapper = ({ width }) => {
<TextInput
key="input"
ref={textInput}
- style={{ height: 1, padding: 0, width: 1, position: 'absolute' }}
+ style={{ height: 1, padding: 0, width: 1, position: "absolute" }}
blurOnSubmit={false}
/>
<ProgressBar />
diff --git a/apps/mobile/app/screens/favorites/index.tsx b/apps/mobile/app/screens/favorites/index.tsx
index 11f9b0834..782ed1da3 100644
--- a/apps/mobile/app/screens/favorites/index.tsx
+++ b/apps/mobile/app/screens/favorites/index.tsx
@@ -1,38 +1,44 @@
-import React from 'react';
-import DelayLayout from '../../components/delay-layout';
-import List from '../../components/list';
-import Navigation, { NavigationProps } from '../../services/navigation';
-import SearchService from '../../services/search';
-import SettingsService from '../../services/settings';
-import { useFavoriteStore } from '../../stores/use-favorite-store';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useNoteStore } from '../../stores/use-notes-store';
-import { db } from '../../common/database';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
+import React from "react";
+import DelayLayout from "../../components/delay-layout";
+import List from "../../components/list";
+import Navigation, { NavigationProps } from "../../services/navigation";
+import SearchService from "../../services/search";
+import SettingsService from "../../services/settings";
+import { useFavoriteStore } from "../../stores/use-favorite-store";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useNoteStore } from "../../stores/use-notes-store";
+import { db } from "../../common/database";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
const prepareSearch = () => {
SearchService.update({
- placeholder: 'Search in favorites',
- type: 'notes',
- title: 'Favorites',
+ placeholder: "Search in favorites",
+ type: "notes",
+ title: "Favorites",
get: () => db.notes?.favorites
});
};
const PLACEHOLDER_DATA = {
- heading: 'Your favorites',
- paragraph: 'You have not added any notes to favorites yet.',
+ heading: "Your favorites",
+ paragraph: "You have not added any notes to favorites yet.",
button: null,
- loading: 'Loading your favorites'
+ loading: "Loading your favorites"
};
-export const Favorites = ({ navigation, route }: NavigationProps<'Favorites'>) => {
- const favorites = useFavoriteStore(state => state.favorites);
- const setFavorites = useFavoriteStore(state => state.setFavorites);
- const loading = useNoteStore(state => state.loading);
+export const Favorites = ({
+ navigation,
+ route
+}: NavigationProps<"Favorites">) => {
+ const favorites = useFavoriteStore((state) => state.favorites);
+ const setFavorites = useFavoriteStore((state) => state.setFavorites);
+ const loading = useNoteStore((state) => state.loading);
const isFocused = useNavigationFocus(navigation, {
- onFocus: prev => {
- Navigation.routeNeedsUpdate(route.name, Navigation.routeUpdateFunctions[route.name]);
+ onFocus: (prev) => {
+ Navigation.routeNeedsUpdate(
+ route.name,
+ Navigation.routeUpdateFunctions[route.name]
+ );
useNavigationStore.getState().update({
name: route.name
});
@@ -55,7 +61,7 @@ export const Favorites = ({ navigation, route }: NavigationProps<'Favorites'>) =
loading={loading || !isFocused}
placeholderData={PLACEHOLDER_DATA}
headerProps={{
- heading: 'Favorites'
+ heading: "Favorites"
}}
/>
</DelayLayout>
diff --git a/apps/mobile/app/screens/home/index.tsx b/apps/mobile/app/screens/home/index.tsx
index 16a794a94..db4fd5166 100755
--- a/apps/mobile/app/screens/home/index.tsx
+++ b/apps/mobile/app/screens/home/index.tsx
@@ -1,39 +1,42 @@
-import React from 'react';
-import { db } from '../../common/database';
-import { FloatingButton } from '../../components/container/floating-button';
-import DelayLayout from '../../components/delay-layout';
-import List from '../../components/list';
-import Navigation, { NavigationProps } from '../../services/navigation';
-import SearchService from '../../services/search';
-import SettingsService from '../../services/settings';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useNoteStore } from '../../stores/use-notes-store';
-import { openEditor } from '../notes/common';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
+import React from "react";
+import { db } from "../../common/database";
+import { FloatingButton } from "../../components/container/floating-button";
+import DelayLayout from "../../components/delay-layout";
+import List from "../../components/list";
+import Navigation, { NavigationProps } from "../../services/navigation";
+import SearchService from "../../services/search";
+import SettingsService from "../../services/settings";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useNoteStore } from "../../stores/use-notes-store";
+import { openEditor } from "../notes/common";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
const prepareSearch = () => {
SearchService.update({
- placeholder: 'Type a keyword to search in notes',
- type: 'notes',
- title: 'Notes',
+ placeholder: "Type a keyword to search in notes",
+ type: "notes",
+ title: "Notes",
get: () => db.notes?.all
});
};
const PLACEHOLDER_DATA = {
- heading: 'Notes',
- paragraph: 'You have not added any notes yet.',
- button: 'Add your first note',
+ heading: "Notes",
+ paragraph: "You have not added any notes yet.",
+ button: "Add your first note",
action: openEditor,
- loading: 'Loading your notes'
+ loading: "Loading your notes"
};
-export const Home = ({ navigation, route }: NavigationProps<'Notes'>) => {
- const notes = useNoteStore(state => state.notes);
- const loading = useNoteStore(state => state.loading);
+export const Home = ({ navigation, route }: NavigationProps<"Notes">) => {
+ const notes = useNoteStore((state) => state.notes);
+ const loading = useNoteStore((state) => state.loading);
const isFocused = useNavigationFocus(navigation, {
- onFocus: prev => {
- console.log('updating', route.name, 'on focus');
- Navigation.routeNeedsUpdate(route.name, Navigation.routeUpdateFunctions[route.name]);
+ onFocus: (prev) => {
+ console.log("updating", route.name, "on focus");
+ Navigation.routeNeedsUpdate(
+ route.name,
+ Navigation.routeUpdateFunctions[route.name]
+ );
useNavigationStore.getState().update({
name: route.name
});
@@ -53,7 +56,7 @@ export const Home = ({ navigation, route }: NavigationProps<'Notes'>) => {
screen="Notes"
loading={loading || !isFocused}
headerProps={{
- heading: 'Notes'
+ heading: "Notes"
}}
placeholderData={PLACEHOLDER_DATA}
/>
diff --git a/apps/mobile/app/screens/notebook/index.tsx b/apps/mobile/app/screens/notebook/index.tsx
index 545e17c47..2dfb3a8a8 100644
--- a/apps/mobile/app/screens/notebook/index.tsx
+++ b/apps/mobile/app/screens/notebook/index.tsx
@@ -1,22 +1,36 @@
-import { groupArray } from '@streetwriters/notesnook-core/utils/grouping';
-import { qclone } from 'qclone';
-import React, { useEffect, useRef, useState } from 'react';
-import { db } from '../../common/database';
-import { FloatingButton } from '../../components/container/floating-button';
-import DelayLayout from '../../components/delay-layout';
-import List from '../../components/list';
-import { NotebookHeader } from '../../components/list-items/headers/notebook-header';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
-import { eSendEvent, eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import Navigation, { NavigationProps, NotebookScreenParams } from '../../services/navigation';
-import SearchService from '../../services/search';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { eOnNewTopicAdded, eOpenAddNotebookDialog, eOpenAddTopicDialog } from '../../utils/events';
-import { NotebookType } from '../../utils/types';
+import { groupArray } from "@streetwriters/notesnook-core/utils/grouping";
+import { qclone } from "qclone";
+import React, { useEffect, useRef, useState } from "react";
+import { db } from "../../common/database";
+import { FloatingButton } from "../../components/container/floating-button";
+import DelayLayout from "../../components/delay-layout";
+import List from "../../components/list";
+import { NotebookHeader } from "../../components/list-items/headers/notebook-header";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
+import {
+ eSendEvent,
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import Navigation, {
+ NavigationProps,
+ NotebookScreenParams
+} from "../../services/navigation";
+import SearchService from "../../services/search";
+import useNavigationStore from "../../stores/use-navigation-store";
+import {
+ eOnNewTopicAdded,
+ eOpenAddNotebookDialog,
+ eOpenAddTopicDialog
+} from "../../utils/events";
+import { NotebookType } from "../../utils/types";
-const Notebook = ({ route, navigation }: NavigationProps<'Notebook'>) => {
+const Notebook = ({ route, navigation }: NavigationProps<"Notebook">) => {
const [topics, setTopics] = useState(
- groupArray(qclone(route?.params.item?.topics) || [], db.settings?.getGroupOptions('topics'))
+ groupArray(
+ qclone(route?.params.item?.topics) || [],
+ db.settings?.getGroupOptions("topics")
+ )
);
const params = useRef<NotebookScreenParams>(route?.params);
useNavigationFocus(navigation, {
@@ -35,7 +49,7 @@ const Notebook = ({ route, navigation }: NavigationProps<'Notebook'>) => {
name: route.name,
title: params.current?.title,
id: params.current?.item?.id,
- type: 'notebook'
+ type: "notebook"
},
params.current?.canGoBack
);
@@ -46,10 +60,16 @@ const Notebook = ({ route, navigation }: NavigationProps<'Notebook'>) => {
if (data) params.current = data;
params.current.title = params.current.item.title;
try {
- let notebook = db.notebooks?.notebook(params?.current?.item?.id)?.data as NotebookType;
+ let notebook = db.notebooks?.notebook(params?.current?.item?.id)
+ ?.data as NotebookType;
if (notebook) {
params.current.item = notebook;
- setTopics(groupArray(qclone(notebook.topics), db.settings?.getGroupOptions('topics')));
+ setTopics(
+ groupArray(
+ qclone(notebook.topics),
+ db.settings?.getGroupOptions("topics")
+ )
+ );
syncWithNavigation();
}
} catch (e) {}
@@ -65,10 +85,11 @@ const Notebook = ({ route, navigation }: NavigationProps<'Notebook'>) => {
const prepareSearch = () => {
SearchService.update({
placeholder: `Search in "${params.current.title}"`,
- type: 'topics',
+ type: "topics",
title: params.current.title,
get: () => {
- let notebook = db.notebooks?.notebook(params?.current?.item?.id)?.data as NotebookType;
+ let notebook = db.notebooks?.notebook(params?.current?.item?.id)
+ ?.data as NotebookType;
return notebook?.topics;
}
});
@@ -81,10 +102,10 @@ const Notebook = ({ route, navigation }: NavigationProps<'Notebook'>) => {
const PLACEHOLDER_DATA = {
heading: params.current.item?.title,
- paragraph: 'You have not added any topics yet.',
- button: 'Add first topic',
+ paragraph: "You have not added any topics yet.",
+ button: "Add first topic",
action: onPressFloatingButton,
- loading: 'Loading notebook topics'
+ loading: "Loading notebook topics"
};
return (
@@ -117,12 +138,12 @@ const Notebook = ({ route, navigation }: NavigationProps<'Notebook'>) => {
Notebook.navigate = (item: NotebookType, canGoBack: boolean) => {
if (!item) return;
- Navigation.navigate<'Notebook'>(
+ Navigation.navigate<"Notebook">(
{
title: item.title,
- name: 'Notebook',
+ name: "Notebook",
id: item.id,
- type: 'notebook'
+ type: "notebook"
},
{
title: item.title,
diff --git a/apps/mobile/app/screens/notebooks/index.tsx b/apps/mobile/app/screens/notebooks/index.tsx
index 211b84921..e646eef02 100644
--- a/apps/mobile/app/screens/notebooks/index.tsx
+++ b/apps/mobile/app/screens/notebooks/index.tsx
@@ -1,16 +1,16 @@
-import React from 'react';
-import { db } from '../../common/database';
-import { FloatingButton } from '../../components/container/floating-button';
-import DelayLayout from '../../components/delay-layout';
-import { AddNotebookEvent } from '../../components/dialog-provider/recievers';
-import List from '../../components/list';
-import { Walkthrough } from '../../components/walkthroughs';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
-import Navigation, { NavigationProps } from '../../services/navigation';
-import SearchService from '../../services/search';
-import SettingsService from '../../services/settings';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useNotebookStore } from '../../stores/use-notebook-store';
+import React from "react";
+import { db } from "../../common/database";
+import { FloatingButton } from "../../components/container/floating-button";
+import DelayLayout from "../../components/delay-layout";
+import { AddNotebookEvent } from "../../components/dialog-provider/recievers";
+import List from "../../components/list";
+import { Walkthrough } from "../../components/walkthroughs";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
+import Navigation, { NavigationProps } from "../../services/navigation";
+import SearchService from "../../services/search";
+import SettingsService from "../../services/settings";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useNotebookStore } from "../../stores/use-notebook-store";
const onPressFloatingButton = () => {
AddNotebookEvent();
@@ -18,26 +18,32 @@ const onPressFloatingButton = () => {
const prepareSearch = () => {
SearchService.update({
- placeholder: 'Type a keyword to search in notebooks',
- type: 'notebooks',
- title: 'Notebooks',
+ placeholder: "Type a keyword to search in notebooks",
+ type: "notebooks",
+ title: "Notebooks",
get: () => db.notebooks?.all
});
};
const PLACEHOLDER_DATA = {
- heading: 'Your notebooks',
- paragraph: 'You have not added any notebooks yet.',
- button: 'Add your first notebook',
+ heading: "Your notebooks",
+ paragraph: "You have not added any notebooks yet.",
+ button: "Add your first notebook",
action: onPressFloatingButton,
- loading: 'Loading your notebooks'
+ loading: "Loading your notebooks"
};
-export const Notebooks = ({ navigation, route }: NavigationProps<'Notebooks'>) => {
- const notebooks = useNotebookStore(state => state.notebooks);
+export const Notebooks = ({
+ navigation,
+ route
+}: NavigationProps<"Notebooks">) => {
+ const notebooks = useNotebookStore((state) => state.notebooks);
const isFocused = useNavigationFocus(navigation, {
- onFocus: prev => {
- Navigation.routeNeedsUpdate(route.name, Navigation.routeUpdateFunctions[route.name]);
+ onFocus: (prev) => {
+ Navigation.routeNeedsUpdate(
+ route.name,
+ Navigation.routeUpdateFunctions[route.name]
+ );
useNavigationStore.getState().update({
name: route.name
});
@@ -45,9 +51,9 @@ export const Notebooks = ({ navigation, route }: NavigationProps<'Notebooks'>) =
useNavigationStore.getState().setButtonAction(onPressFloatingButton);
if (notebooks.length === 0) {
- Walkthrough.present('notebooks');
+ Walkthrough.present("notebooks");
} else {
- Walkthrough.update('notebooks');
+ Walkthrough.update("notebooks");
}
return !prev?.current;
@@ -65,12 +71,15 @@ export const Notebooks = ({ navigation, route }: NavigationProps<'Notebooks'>) =
loading={!isFocused}
placeholderData={PLACEHOLDER_DATA}
headerProps={{
- heading: 'Notebooks'
+ heading: "Notebooks"
}}
/>
{!notebooks || notebooks.length === 0 || !isFocused ? null : (
- <FloatingButton title="Create a new notebook" onPress={onPressFloatingButton} />
+ <FloatingButton
+ title="Create a new notebook"
+ onPress={onPressFloatingButton}
+ />
)}
</DelayLayout>
);
diff --git a/apps/mobile/app/screens/notes/colored.tsx b/apps/mobile/app/screens/notes/colored.tsx
index d9633d7dd..4fb8f4535 100644
--- a/apps/mobile/app/screens/notes/colored.tsx
+++ b/apps/mobile/app/screens/notes/colored.tsx
@@ -1,12 +1,18 @@
-import { groupArray } from '@streetwriters/notesnook-core/utils/grouping';
-import React from 'react';
-import NotesPage, { PLACEHOLDER_DATA } from '.';
-import Navigation, { NavigationProps, NotesScreenParams } from '../../services/navigation';
-import { db } from '../../common/database';
-import { ColorType, TagType } from '../../utils/types';
-import { getAlias, openEditor, toCamelCase } from './common';
+import { groupArray } from "@streetwriters/notesnook-core/utils/grouping";
+import React from "react";
+import NotesPage, { PLACEHOLDER_DATA } from ".";
+import Navigation, {
+ NavigationProps,
+ NotesScreenParams
+} from "../../services/navigation";
+import { db } from "../../common/database";
+import { ColorType, TagType } from "../../utils/types";
+import { getAlias, openEditor, toCamelCase } from "./common";
-export const ColoredNotes = ({ navigation, route }: NavigationProps<'ColoredNotes'>) => {
+export const ColoredNotes = ({
+ navigation,
+ route
+}: NavigationProps<"ColoredNotes">) => {
return (
<NotesPage
navigation={navigation}
@@ -22,20 +28,22 @@ export const ColoredNotes = ({ navigation, route }: NavigationProps<'ColoredNote
ColoredNotes.get = (params: NotesScreenParams, grouped = true) => {
let notes = db.notes?.colored(params.item.id) || [];
- return grouped ? groupArray(notes, db.settings?.getGroupOptions('notes')) : notes;
+ return grouped
+ ? groupArray(notes, db.settings?.getGroupOptions("notes"))
+ : notes;
};
ColoredNotes.navigate = (item: ColorType, canGoBack: boolean) => {
if (!item) return;
//@ts-ignore TODO
let alias = getAlias({ item: item });
- Navigation.navigate<'ColoredNotes'>(
+ Navigation.navigate<"ColoredNotes">(
{
- name: 'ColoredNotes',
+ name: "ColoredNotes",
alias: toCamelCase(alias),
title: toCamelCase(item.title),
id: item.id,
- type: 'color',
+ type: "color",
//@ts-ignore
color: item.title?.toLowerCase()
},
diff --git a/apps/mobile/app/screens/notes/common.ts b/apps/mobile/app/screens/notes/common.ts
index c4c20f2f1..0498d7b9e 100644
--- a/apps/mobile/app/screens/notes/common.ts
+++ b/apps/mobile/app/screens/notes/common.ts
@@ -1,20 +1,20 @@
-import { DDS } from '../../services/device-detection';
-import { eSendEvent } from '../../services/event-manager';
-import Navigation, { NotesScreenParams } from '../../services/navigation';
-import { useMenuStore } from '../../stores/use-menu-store';
-import { useTagStore } from '../../stores/use-tag-store';
-import { db } from '../../common/database';
-import { eOnLoadNote } from '../../utils/events';
-import { openLinkInBrowser } from '../../utils/functions';
-import { tabBarRef } from '../../utils/global-refs';
-import { editorController, editorState } from '../editor/tiptap/utils';
+import { DDS } from "../../services/device-detection";
+import { eSendEvent } from "../../services/event-manager";
+import Navigation, { NotesScreenParams } from "../../services/navigation";
+import { useMenuStore } from "../../stores/use-menu-store";
+import { useTagStore } from "../../stores/use-tag-store";
+import { db } from "../../common/database";
+import { eOnLoadNote } from "../../utils/events";
+import { openLinkInBrowser } from "../../utils/functions";
+import { tabBarRef } from "../../utils/global-refs";
+import { editorController, editorState } from "../editor/tiptap/utils";
export function toCamelCase(title: string) {
return title.slice(0, 1).toUpperCase() + title.slice(1);
}
export function getAlias(params: NotesScreenParams) {
- if (!params) return '';
+ if (!params) return "";
const { item } = params;
//@ts-ignore
return item.alias || item.title;
@@ -22,20 +22,20 @@ export function getAlias(params: NotesScreenParams) {
export function openMonographsWebpage() {
try {
- openLinkInBrowser('https://docs.notesnook.com/monographs/');
+ openLinkInBrowser("https://docs.notesnook.com/monographs/");
} catch (e) {}
}
export function openEditor() {
if (!DDS.isTab) {
if (editorController.current?.note) {
- eSendEvent(eOnLoadNote, { type: 'new' });
+ eSendEvent(eOnLoadNote, { type: "new" });
editorState().currentlyEditing = true;
editorState().movedAway = false;
}
tabBarRef.current?.goToPage(1);
} else {
- eSendEvent(eOnLoadNote, { type: 'new' });
+ eSendEvent(eOnLoadNote, { type: "new" });
}
}
@@ -59,14 +59,16 @@ export const setOnFirstSave = (
return;
}
//@ts-ignore
- editorState().onNoteCreated = id => onNoteCreated(id, data);
+ editorState().onNoteCreated = (id) => onNoteCreated(id, data);
};
export function isSynced(params: NotesScreenParams) {
- if (params.item.type === 'topic') {
+ if (params.item.type === "topic") {
console.log(params.item.type);
- let topic = db.notebooks?.notebook(params.item.notebookId)?.topics.topic(params.item.id);
- console.log(topic?.synced(), 'sycned');
+ let topic = db.notebooks
+ ?.notebook(params.item.notebookId)
+ ?.topics.topic(params.item.id);
+ console.log(topic?.synced(), "sycned");
return !topic ? true : topic?.synced();
}
return true;
@@ -75,7 +77,7 @@ export function isSynced(params: NotesScreenParams) {
async function onNoteCreated(id: string, params: FirstSaveData) {
if (!params) return;
switch (params.type) {
- case 'topic': {
+ case "topic": {
await db.notes?.move(
{
topic: params.id,
@@ -85,37 +87,37 @@ async function onNoteCreated(id: string, params: FirstSaveData) {
);
editorState().onNoteCreated = null;
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes',
- 'Notebook'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes",
+ "Notebook"
);
break;
}
- case 'tag': {
+ case "tag": {
await db.notes?.note(id).tag(params.id);
editorState().onNoteCreated = null;
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes"
);
useTagStore.getState().setTags();
break;
}
- case 'color': {
+ case "color": {
await db.notes?.note(id).color(params.color);
editorState().onNoteCreated = null;
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes"
);
useMenuStore.getState().setColorNotes();
break;
diff --git a/apps/mobile/app/screens/notes/index.tsx b/apps/mobile/app/screens/notes/index.tsx
index 4ff4e0838..4cc60a792 100644
--- a/apps/mobile/app/screens/notes/index.tsx
+++ b/apps/mobile/app/screens/notes/index.tsx
@@ -1,14 +1,23 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { FloatingButton } from '../../components/container/floating-button';
-import DelayLayout from '../../components/delay-layout';
-import List from '../../components/list';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import Navigation, { NavigationProps, NotesScreenParams } from '../../services/navigation';
-import SearchService from '../../services/search';
-import useNavigationStore, { HeaderRightButton, RouteName } from '../../stores/use-navigation-store';
-import { useNoteStore } from '../../stores/use-notes-store';
-import { NoteType } from '../../utils/types';
+import React, { useEffect, useRef, useState } from "react";
+import { FloatingButton } from "../../components/container/floating-button";
+import DelayLayout from "../../components/delay-layout";
+import List from "../../components/list";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import Navigation, {
+ NavigationProps,
+ NotesScreenParams
+} from "../../services/navigation";
+import SearchService from "../../services/search";
+import useNavigationStore, {
+ HeaderRightButton,
+ RouteName
+} from "../../stores/use-navigation-store";
+import { useNoteStore } from "../../stores/use-notes-store";
+import { NoteType } from "../../utils/types";
import {
getAlias,
isSynced,
@@ -16,28 +25,28 @@ import {
openMonographsWebpage,
setOnFirstSave,
toCamelCase
-} from './common';
+} from "./common";
export const WARNING_DATA = {
- title: 'Some notes in this topic are not synced'
+ title: "Some notes in this topic are not synced"
};
export const PLACEHOLDER_DATA = {
- heading: 'Your notes',
- paragraph: 'You have not added any notes yet.',
- button: 'Add your first Note',
+ heading: "Your notes",
+ paragraph: "You have not added any notes yet.",
+ button: "Add your first Note",
action: openEditor,
- loading: 'Loading your notes.'
+ loading: "Loading your notes."
};
export const MONOGRAPH_PLACEHOLDER_DATA = {
- heading: 'Your monographs',
- paragraph: 'You have not published any notes as monographs yet.',
- button: 'Learn more about monographs',
+ heading: "Your monographs",
+ paragraph: "You have not published any notes as monographs yet.",
+ button: "Learn more about monographs",
action: openMonographsWebpage,
- loading: 'Loading published notes.',
- type: 'monographs',
- buttonIcon: 'information-outline'
+ loading: "Loading published notes.",
+ type: "monographs",
+ buttonIcon: "information-outline"
};
export interface RouteProps<T extends RouteName> extends NavigationProps<T> {
@@ -50,11 +59,11 @@ export interface RouteProps<T extends RouteName> extends NavigationProps<T> {
}
function getItemType(routeName: RouteName) {
- if (routeName === 'TaggedNotes') return 'tag';
- if (routeName === 'ColoredNotes') return 'color';
- if (routeName === 'TopicNotes') return 'topic';
- if (routeName === 'Monographs') return 'monograph';
- return 'note';
+ if (routeName === "TaggedNotes") return "tag";
+ if (routeName === "ColoredNotes") return "color";
+ if (routeName === "TopicNotes") return "topic";
+ if (routeName === "Monographs") return "monograph";
+ return "note";
}
const NotesPage = ({
@@ -66,18 +75,20 @@ const NotesPage = ({
focusControl = true,
canGoBack,
rightButtons
-}: RouteProps<'NotesPage' | 'TaggedNotes' | 'Monographs' | 'ColoredNotes' | 'TopicNotes'>) => {
+}: RouteProps<
+ "NotesPage" | "TaggedNotes" | "Monographs" | "ColoredNotes" | "TopicNotes"
+>) => {
const params = useRef<NotesScreenParams>(route?.params);
const [notes, setNotes] = useState<NoteType[]>(get(route.params, true));
const [warning, setWarning] = useState(!isSynced(route.params));
- const loading = useNoteStore(state => state.loading);
+ const loading = useNoteStore((state) => state.loading);
const [loadingNotes, setLoadingNotes] = useState(false);
const alias = getAlias(params.current);
- const isMonograph = route.name === 'Monographs';
- console.log(warning, 'isWarning', isSynced(route.params));
+ const isMonograph = route.name === "Monographs";
+ console.log(warning, "isWarning", isSynced(route.params));
const isFocused = useNavigationFocus(navigation, {
- onFocus: prev => {
+ onFocus: (prev) => {
Navigation.routeNeedsUpdate(route.name, onRequestUpdate);
syncWithNavigation();
if (focusControl) return !prev.current;
@@ -94,18 +105,19 @@ const NotesPage = ({
const { item, title } = params.current;
//@ts-ignore
let alias = getAlias(params.current);
- console.log(alias, title, 'syncWithNavigation', params.current);
+ console.log(alias, title, "syncWithNavigation", params.current);
useNavigationStore.getState().update(
{
name: route.name,
title: alias || title,
id: item?.id,
- type: 'notes',
+ type: "notes",
//@ts-ignore
notebookId: item?.notebookId,
- alias: route.name === 'ColoredNotes' ? toCamelCase(alias) : alias,
+ alias: route.name === "ColoredNotes" ? toCamelCase(alias) : alias,
//@ts-ignore
- color: route.name === 'ColoredNotes' ? item.title?.toLowerCase() : undefined
+ color:
+ route.name === "ColoredNotes" ? item.title?.toLowerCase() : undefined
},
params.current.canGoBack,
rightButtons && rightButtons(params.current)
@@ -131,10 +143,13 @@ const NotesPage = ({
try {
if (isNew) setLoadingNotes(true);
let notes = get(params.current, true) as NoteType[];
- if ((item.type === 'tag' || item.type === 'color') && (!notes || notes.length === 0)) {
+ if (
+ (item.type === "tag" || item.type === "color") &&
+ (!notes || notes.length === 0)
+ ) {
return Navigation.goBack();
}
- if (item.type === 'topic') setWarning(!isSynced(params.current));
+ if (item.type === "topic") setWarning(!isSynced(params.current));
setNotes(notes);
syncWithNavigation();
} catch (e) {}
@@ -158,8 +173,8 @@ const NotesPage = ({
const { item } = params.current;
SearchService.update({
placeholder: `Search in ${alias}`,
- type: 'notes',
- title: item.type === 'tag' ? '#' + alias : toCamelCase(item.title),
+ type: "notes",
+ title: item.type === "tag" ? "#" + alias : toCamelCase(item.title),
get: () => {
return get(params.current, false);
}
@@ -168,7 +183,11 @@ const NotesPage = ({
return (
<DelayLayout
- color={route.name === 'ColoredNotes' ? params.current?.item.title.toLowerCase() : undefined}
+ color={
+ route.name === "ColoredNotes"
+ ? params.current?.item.title.toLowerCase()
+ : undefined
+ }
wait={loading || loadingNotes}
>
<List
@@ -180,7 +199,10 @@ const NotesPage = ({
screen="Notes"
headerProps={{
heading: params.current.title,
- color: route.name === 'ColoredNotes' ? params.current?.item.title.toLowerCase() : null
+ color:
+ route.name === "ColoredNotes"
+ ? params.current?.item.title.toLowerCase()
+ : null
}}
placeholderData={placeholderData}
/>
diff --git a/apps/mobile/app/screens/notes/monographs.tsx b/apps/mobile/app/screens/notes/monographs.tsx
index 5509e7e76..c16c69e4d 100644
--- a/apps/mobile/app/screens/notes/monographs.tsx
+++ b/apps/mobile/app/screens/notes/monographs.tsx
@@ -1,12 +1,18 @@
-import { groupArray } from '@streetwriters/notesnook-core/utils/grouping';
-import React from 'react';
-import NotesPage, { PLACEHOLDER_DATA } from '.';
-import Navigation, { NavigationProps, NotesScreenParams } from '../../services/navigation';
-import { db } from '../../common/database';
-import { MonographType } from '../../utils/types';
-import { openMonographsWebpage } from './common';
+import { groupArray } from "@streetwriters/notesnook-core/utils/grouping";
+import React from "react";
+import NotesPage, { PLACEHOLDER_DATA } from ".";
+import Navigation, {
+ NavigationProps,
+ NotesScreenParams
+} from "../../services/navigation";
+import { db } from "../../common/database";
+import { MonographType } from "../../utils/types";
+import { openMonographsWebpage } from "./common";
-export const Monographs = ({ navigation, route }: NavigationProps<'Monographs'>) => {
+export const Monographs = ({
+ navigation,
+ route
+}: NavigationProps<"Monographs">) => {
return (
<NotesPage
navigation={navigation}
@@ -22,20 +28,22 @@ export const Monographs = ({ navigation, route }: NavigationProps<'Monographs'>)
Monographs.get = (params: NotesScreenParams, grouped = true) => {
let notes = db.monographs?.all || [];
- return grouped ? groupArray(notes, db.settings?.getGroupOptions('notes')) : notes;
+ return grouped
+ ? groupArray(notes, db.settings?.getGroupOptions("notes"))
+ : notes;
};
Monographs.navigate = (item: MonographType, canGoBack: boolean) => {
- Navigation.navigate<'Monographs'>(
+ Navigation.navigate<"Monographs">(
{
- name: 'Monographs',
- type: 'monograph'
+ name: "Monographs",
+ type: "monograph"
},
{
//@ts-ignore
- item: { type: 'monograph' },
+ item: { type: "monograph" },
canGoBack,
- title: 'Monographs'
+ title: "Monographs"
}
);
};
diff --git a/apps/mobile/app/screens/notes/tagged.tsx b/apps/mobile/app/screens/notes/tagged.tsx
index e71632d32..cc0cad9c5 100644
--- a/apps/mobile/app/screens/notes/tagged.tsx
+++ b/apps/mobile/app/screens/notes/tagged.tsx
@@ -1,12 +1,18 @@
-import { groupArray } from '@streetwriters/notesnook-core/utils/grouping';
-import React from 'react';
-import NotesPage, { PLACEHOLDER_DATA } from '.';
-import Navigation, { NavigationProps, NotesScreenParams } from '../../services/navigation';
-import { db } from '../../common/database';
-import { TagType } from '../../utils/types';
-import { getAlias, openEditor } from './common';
+import { groupArray } from "@streetwriters/notesnook-core/utils/grouping";
+import React from "react";
+import NotesPage, { PLACEHOLDER_DATA } from ".";
+import Navigation, {
+ NavigationProps,
+ NotesScreenParams
+} from "../../services/navigation";
+import { db } from "../../common/database";
+import { TagType } from "../../utils/types";
+import { getAlias, openEditor } from "./common";
-export const TaggedNotes = ({ navigation, route }: NavigationProps<'TaggedNotes'>) => {
+export const TaggedNotes = ({
+ navigation,
+ route
+}: NavigationProps<"TaggedNotes">) => {
return (
<NotesPage
navigation={navigation}
@@ -22,20 +28,22 @@ export const TaggedNotes = ({ navigation, route }: NavigationProps<'TaggedNotes'
TaggedNotes.get = (params: NotesScreenParams, grouped = true) => {
let notes = db.notes?.tagged(params.item.id) || [];
- return grouped ? groupArray(notes, db.settings?.getGroupOptions('notes')) : notes;
+ return grouped
+ ? groupArray(notes, db.settings?.getGroupOptions("notes"))
+ : notes;
};
TaggedNotes.navigate = (item: TagType, canGoBack: boolean) => {
if (!item) return;
//@ts-ignore TODO
let alias = getAlias({ item: item });
- Navigation.navigate<'TaggedNotes'>(
+ Navigation.navigate<"TaggedNotes">(
{
- name: 'TaggedNotes',
+ name: "TaggedNotes",
alias: alias,
title: item.title,
id: item.id,
- type: 'tag'
+ type: "tag"
},
{
item: item,
diff --git a/apps/mobile/app/screens/notes/topic-notes.tsx b/apps/mobile/app/screens/notes/topic-notes.tsx
index 5cd94d108..2987fb276 100644
--- a/apps/mobile/app/screens/notes/topic-notes.tsx
+++ b/apps/mobile/app/screens/notes/topic-notes.tsx
@@ -1,20 +1,23 @@
-import { groupArray } from '@streetwriters/notesnook-core/utils/grouping';
-import React from 'react';
-import NotesPage, { PLACEHOLDER_DATA } from '.';
-import { MoveNotes } from '../../components/sheets/move-notes/movenote';
-import { eSendEvent } from '../../services/event-manager';
-import Navigation, { NavigationProps, NotesScreenParams } from '../../services/navigation';
-import { db } from '../../common/database';
-import { eOpenAddTopicDialog } from '../../utils/events';
-import { TopicType } from '../../utils/types';
-import { openEditor } from './common';
+import { groupArray } from "@streetwriters/notesnook-core/utils/grouping";
+import React from "react";
+import NotesPage, { PLACEHOLDER_DATA } from ".";
+import { MoveNotes } from "../../components/sheets/move-notes/movenote";
+import { eSendEvent } from "../../services/event-manager";
+import Navigation, {
+ NavigationProps,
+ NotesScreenParams
+} from "../../services/navigation";
+import { db } from "../../common/database";
+import { eOpenAddTopicDialog } from "../../utils/events";
+import { TopicType } from "../../utils/types";
+import { openEditor } from "./common";
const headerRightButtons = (params: NotesScreenParams) => [
{
- title: 'Edit topic',
+ title: "Edit topic",
onPress: () => {
const { item } = params;
- if (item.type !== 'topic') return;
+ if (item.type !== "topic") return;
eSendEvent(eOpenAddTopicDialog, {
notebookId: item.notebookId,
toEdit: item
@@ -22,16 +25,19 @@ const headerRightButtons = (params: NotesScreenParams) => [
}
},
{
- title: 'Move notes',
+ title: "Move notes",
onPress: () => {
const { item } = params;
- if (item?.type !== 'topic') return;
+ if (item?.type !== "topic") return;
MoveNotes.present(db.notebooks?.notebook(item.notebookId).data, item);
}
}
];
-export const TopicNotes = ({ navigation, route }: NavigationProps<'TopicNotes'>) => {
+export const TopicNotes = ({
+ navigation,
+ route
+}: NavigationProps<"TopicNotes">) => {
return (
<NotesPage
navigation={navigation}
@@ -50,17 +56,19 @@ TopicNotes.get = (params: NotesScreenParams, grouped = true) => {
//@ts-ignore
const { id, notebookId } = params.item;
let notes = db.notebooks?.notebook(notebookId)?.topics.topic(id)?.all || [];
- return grouped ? groupArray(notes, db.settings?.getGroupOptions('notes')) : notes;
+ return grouped
+ ? groupArray(notes, db.settings?.getGroupOptions("notes"))
+ : notes;
};
TopicNotes.navigate = (item: TopicType, canGoBack: boolean) => {
if (!item) return;
- Navigation.navigate<'TopicNotes'>(
+ Navigation.navigate<"TopicNotes">(
{
- name: 'TopicNotes',
+ name: "TopicNotes",
title: item.title,
id: item.id,
- type: 'topic',
+ type: "topic",
notebookId: item.notebookId
},
{
diff --git a/apps/mobile/app/screens/search/index.js b/apps/mobile/app/screens/search/index.js
index e2e330d50..46c0fb7d2 100644
--- a/apps/mobile/app/screens/search/index.js
+++ b/apps/mobile/app/screens/search/index.js
@@ -1,19 +1,19 @@
-import React, { useEffect } from 'react';
-import DelayLayout from '../../components/delay-layout';
-import List from '../../components/list';
-import SearchService from '../../services/search';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useSearchStore } from '../../stores/use-search-store';
-import { inputRef } from '../../utils/global-refs';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
-import { sleep } from '../../utils/time';
+import React, { useEffect } from "react";
+import DelayLayout from "../../components/delay-layout";
+import List from "../../components/list";
+import SearchService from "../../services/search";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useSearchStore } from "../../stores/use-search-store";
+import { inputRef } from "../../utils/global-refs";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
+import { sleep } from "../../utils/time";
export const Search = ({ navigation, route }) => {
- const searchResults = useSearchStore(state => state.searchResults);
- const searching = useSearchStore(state => state.searching);
- const searchStatus = useSearchStore(state => state.searchStatus);
- const setSearchResults = useSearchStore(state => state.setSearchResults);
- const setSearchStatus = useSearchStore(state => state.setSearchStatus);
+ const searchResults = useSearchStore((state) => state.searchResults);
+ const searching = useSearchStore((state) => state.searching);
+ const searchStatus = useSearchStore((state) => state.searchStatus);
+ const setSearchResults = useSearchStore((state) => state.setSearchResults);
+ const setSearchStatus = useSearchStore((state) => state.setSearchStatus);
useNavigationFocus(navigation, {
onFocus: () => {
@@ -45,12 +45,14 @@ export const Search = ({ navigation, route }) => {
loading={searching}
CustomHeader={true}
placeholderData={{
- heading: 'Search',
+ heading: "Search",
paragraph:
searchStatus ||
- `Type a keyword to search in ${SearchService.getSearchInformation().title}`,
+ `Type a keyword to search in ${
+ SearchService.getSearchInformation().title
+ }`,
button: null,
- loading: 'Searching...'
+ loading: "Searching..."
}}
/>
</DelayLayout>
diff --git a/apps/mobile/app/screens/search/search-bar.js b/apps/mobile/app/screens/search/search-bar.js
index a3b3fc77d..cf9c6aa7c 100644
--- a/apps/mobile/app/screens/search/search-bar.js
+++ b/apps/mobile/app/screens/search/search-bar.js
@@ -1,23 +1,27 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { Platform, View } from 'react-native';
-import { TextInput } from 'react-native-gesture-handler';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import { IconButton } from '../../components/ui/icon-button';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useSearchStore } from '../../stores/use-search-store';
-import { eSubscribeEvent, eUnSubscribeEvent, ToastEvent } from '../../services/event-manager';
-import Navigation from '../../services/navigation';
-import SearchService from '../../services/search';
-import { eScrollEvent } from '../../utils/events';
-import { normalize, SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
+import React, { useEffect, useRef, useState } from "react";
+import { Platform, View } from "react-native";
+import { TextInput } from "react-native-gesture-handler";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import { IconButton } from "../../components/ui/icon-button";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useSearchStore } from "../../stores/use-search-store";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent,
+ ToastEvent
+} from "../../services/event-manager";
+import Navigation from "../../services/navigation";
+import SearchService from "../../services/search";
+import { eScrollEvent } from "../../utils/events";
+import { normalize, SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
export const SearchBar = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const [value, setValue] = useState(null);
const inputRef = useRef();
- const setSearchResults = useSearchStore(state => state.setSearchResults);
- const setSearchStatus = useSearchStore(state => state.setSearchStatus);
+ const setSearchResults = useSearchStore((state) => state.setSearchResults);
+ const setSearchStatus = useSearchStore((state) => state.setSearchStatus);
const searchingRef = useRef(0);
const insets = useSafeAreaInsets();
const onClear = () => {
@@ -35,7 +39,7 @@ export const SearchBar = () => {
});
}, []);
- const onScroll = event => {
+ const onScroll = (event) => {
console.log(event);
};
useEffect(() => {
@@ -45,16 +49,16 @@ export const SearchBar = () => {
};
}, []);
- const onChangeText = value => {
+ const onChangeText = (value) => {
setValue(value);
search(value);
};
- const search = value => {
+ const search = (value) => {
clearTimeout(searchingRef.current);
searchingRef.current = setTimeout(async () => {
try {
- if (value === '' || !value) {
+ if (value === "" || !value) {
setSearchResults([]);
setSearchStatus(false, null);
return;
@@ -66,9 +70,9 @@ export const SearchBar = () => {
} catch (e) {
console.log(e);
ToastEvent.show({
- heading: 'Error occured while searching',
+ heading: "Error occured while searching",
message: e.message,
- type: 'error'
+ type: "error"
});
}
}, 300);
@@ -78,10 +82,10 @@ export const SearchBar = () => {
<View
style={{
height: 50,
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
flexShrink: 1,
- width: '100%'
+ width: "100%"
}}
>
<IconButton
@@ -107,9 +111,9 @@ export const SearchBar = () => {
testID="search-input"
style={{
fontSize: SIZE.md + 1,
- fontFamily: 'OpenSans-Regular',
+ fontFamily: "OpenSans-Regular",
flexGrow: 1,
- height: '100%',
+ height: "100%",
color: colors.pri
}}
onChangeText={onChangeText}
diff --git a/apps/mobile/app/screens/settings/2fa.tsx b/apps/mobile/app/screens/settings/2fa.tsx
index c857d29ae..c1d153e7f 100644
--- a/apps/mobile/app/screens/settings/2fa.tsx
+++ b/apps/mobile/app/screens/settings/2fa.tsx
@@ -1,52 +1,62 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import React, { Dispatch, SetStateAction, useEffect, useRef, useState } from 'react';
-import { ActivityIndicator, Linking, Platform, View } from 'react-native';
-import { FlatList } from 'react-native-gesture-handler';
-import * as ScopedStorage from 'react-native-scoped-storage';
-import RNFetchBlob from 'rn-fetch-blob';
-import DialogHeader from '../../components/dialog/dialog-header';
-import { Button } from '../../components/ui/button';
-import { IconButton } from '../../components/ui/icon-button';
-import Input from '../../components/ui/input';
-import { PressableButton } from '../../components/ui/pressable';
-import Seperator from '../../components/ui/seperator';
-import { SvgView } from '../../components/ui/svg';
-import Heading from '../../components/ui/typography/heading';
-import Paragraph from '../../components/ui/typography/paragraph';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
-import { useUserStore } from '../../stores/use-user-store';
-import { ThemeStore, useThemeStore } from '../../stores/use-theme-store';
-import { db } from '../../common/database';
-import Storage from '../../common/database/storage';
-import { eCloseProgressDialog } from '../../utils/events';
-import useTimer from '../../hooks/use-timer';
-import { sanitizeFilename } from '../../utils/sanitizer';
-import { SIZE } from '../../utils/size';
-import { sleep } from '../../utils/time';
+import Clipboard from "@react-native-clipboard/clipboard";
+import React, {
+ Dispatch,
+ SetStateAction,
+ useEffect,
+ useRef,
+ useState
+} from "react";
+import { ActivityIndicator, Linking, Platform, View } from "react-native";
+import { FlatList } from "react-native-gesture-handler";
+import * as ScopedStorage from "react-native-scoped-storage";
+import RNFetchBlob from "rn-fetch-blob";
+import DialogHeader from "../../components/dialog/dialog-header";
+import { Button } from "../../components/ui/button";
+import { IconButton } from "../../components/ui/icon-button";
+import Input from "../../components/ui/input";
+import { PressableButton } from "../../components/ui/pressable";
+import Seperator from "../../components/ui/seperator";
+import { SvgView } from "../../components/ui/svg";
+import Heading from "../../components/ui/typography/heading";
+import Paragraph from "../../components/ui/typography/paragraph";
+import {
+ eSendEvent,
+ presentSheet,
+ ToastEvent
+} from "../../services/event-manager";
+import { useUserStore } from "../../stores/use-user-store";
+import { ThemeStore, useThemeStore } from "../../stores/use-theme-store";
+import { db } from "../../common/database";
+import Storage from "../../common/database/storage";
+import { eCloseProgressDialog } from "../../utils/events";
+import useTimer from "../../hooks/use-timer";
+import { sanitizeFilename } from "../../utils/sanitizer";
+import { SIZE } from "../../utils/size";
+import { sleep } from "../../utils/time";
const mfaMethods: MFAMethod[] = [
{
- id: 'app',
- title: 'Setup using an Authenticator app',
- body: 'Use an authenticator app like Google Authenticator on your phone to get authentication codes',
- icon: 'cellphone-key',
+ id: "app",
+ title: "Setup using an Authenticator app",
+ body: "Use an authenticator app like Google Authenticator on your phone to get authentication codes",
+ icon: "cellphone-key",
recommended: true
},
{
- id: 'sms',
- title: 'Set up using SMS',
- body: 'Notesnook will send you an SMS with a 2FA code when prompted',
- icon: 'message-plus-outline'
+ id: "sms",
+ title: "Set up using SMS",
+ body: "Notesnook will send you an SMS with a 2FA code when prompted",
+ icon: "message-plus-outline"
},
{
- id: 'email',
- title: 'Set up using Email',
- body: 'Notesnook will send you a 2FA code on your email when prompted',
- icon: 'email-outline'
+ id: "email",
+ title: "Set up using Email",
+ body: "Notesnook will send you a 2FA code on your email when prompted",
+ icon: "email-outline"
}
];
type MFAMethod = {
- id: 'email' | 'sms' | 'app';
+ id: "email" | "sms" | "app";
title?: string;
body?: string;
icon?: string;
@@ -66,12 +76,12 @@ type MFAStepProps = {
isSetup?: boolean;
};
export const MFAMethodsPickerStep = ({ recovery, onSuccess }: MFAStepProps) => {
- const colors = useThemeStore(state => state.colors);
- const user = useUserStore(state => state.user);
+ const colors = useThemeStore((state) => state.colors);
+ const user = useUserStore((state) => state.user);
const getMethods = () => {
if (!recovery) return mfaMethods;
- return mfaMethods.filter(m => m.id !== user?.mfa?.primaryMethod);
+ return mfaMethods.filter((m) => m.id !== user?.mfa?.primaryMethod);
};
return (
@@ -82,7 +92,7 @@ export const MFAMethodsPickerStep = ({ recovery, onSuccess }: MFAStepProps) => {
padding={12}
/>
<Seperator />
- {getMethods().map(item => (
+ {getMethods().map((item) => (
<PressableButton
key={item.title}
onPress={() => {
@@ -93,9 +103,9 @@ export const MFAMethodsPickerStep = ({ recovery, onSuccess }: MFAStepProps) => {
paddingVertical: 12,
marginTop: 0,
marginBottom: 12,
- flexDirection: 'row',
+ flexDirection: "row",
borderRadius: 0,
- alignItems: 'flex-start'
+ alignItems: "flex-start"
}}
>
<IconButton
@@ -123,9 +133,14 @@ export const MFAMethodsPickerStep = ({ recovery, onSuccess }: MFAStepProps) => {
);
};
-export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps) => {
- const colors = useThemeStore(state => state.colors);
- const user = useUserStore(state => state.user);
+export const MFASetup = ({
+ method,
+ onSuccess,
+ setStep,
+ recovery
+}: MFAStepProps) => {
+ const colors = useThemeStore((state) => state.colors);
+ const user = useUserStore((state) => state.user);
const [authenticatorDetails, setAuthenticatorDetails] = useState({
sharedKey: null,
authenticatorUri: null
@@ -134,14 +149,14 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
const phoneNumber = useRef<string>();
const { seconds, setId, start } = useTimer(method?.id);
- const [loading, setLoading] = useState(method?.id === 'app' ? true : false);
+ const [loading, setLoading] = useState(method?.id === "app" ? true : false);
const [enabling, setEnabling] = useState(false);
const [sending, setSending] = useState(false);
const [error, setError] = useState(false);
useEffect(() => {
- if (method?.id === 'app') {
- db.mfa?.setup('app').then(data => {
+ if (method?.id === "app") {
+ db.mfa?.setup("app").then((data) => {
setAuthenticatorDetails(data);
setLoading(false);
});
@@ -149,9 +164,10 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
}, []);
const codeHelpText = {
- app: 'After putting the above code in authenticator app, the app will display a code that you can enter below.',
- sms: 'You will receive a 2FA code on your phone number which you can enter below',
- email: 'You will receive a 2FA code on your email address which you can enter below'
+ app: "After putting the above code in authenticator app, the app will display a code that you can enter below.",
+ sms: "You will receive a 2FA code on your phone number which you can enter below",
+ email:
+ "You will receive a 2FA code on your email address which you can enter below"
};
const onNext = async () => {
@@ -160,10 +176,10 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
if (!method) return;
setEnabling(true);
if (recovery) {
- console.log('enabling secondary method for 2FA');
+ console.log("enabling secondary method for 2FA");
await db.mfa?.enableFallback(method.id, code.current);
} else {
- console.log('enabling primary method for 2FA');
+ console.log("enabling primary method for 2FA");
await db.mfa?.enable(method.id, code.current);
}
@@ -173,60 +189,71 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
setEnabling(false);
} catch (e) {
const error = e as Error;
- console.log('2fa submit code:', error.message);
- ToastEvent.error(error, 'Error submitting 2fa code');
+ console.log("2fa submit code:", error.message);
+ ToastEvent.error(error, "Error submitting 2fa code");
setEnabling(false);
}
};
const onSendCode = async () => {
- console.log('send code');
+ console.log("send code");
if (error) return;
if (!method || sending) return;
- if (method.id === 'app' && authenticatorDetails.sharedKey) {
+ if (method.id === "app" && authenticatorDetails.sharedKey) {
Clipboard.setString(authenticatorDetails.sharedKey);
if (authenticatorDetails.authenticatorUri) {
- await Linking.openURL(authenticatorDetails.authenticatorUri).catch(console.log);
+ await Linking.openURL(authenticatorDetails.authenticatorUri).catch(
+ console.log
+ );
}
ToastEvent.show({
heading: `Code copied!`,
- type: 'success',
- context: 'local'
+ type: "success",
+ context: "local"
});
return;
}
try {
- console.log('seconds', seconds);
- if (seconds) throw new Error('Please wait a few seconds before resending code');
- if (method.id === 'sms' && !phoneNumber.current) throw new Error('Phone number not entered');
+ console.log("seconds", seconds);
+ if (seconds)
+ throw new Error("Please wait a few seconds before resending code");
+ if (method.id === "sms" && !phoneNumber.current)
+ throw new Error("Phone number not entered");
setSending(true);
await db.mfa?.setup(method?.id, phoneNumber.current);
- if (method.id === 'sms') {
+ if (method.id === "sms") {
console.log(phoneNumber.current);
setId(method.id + phoneNumber.current);
}
await sleep(300);
- start(60, method.id === 'sms' ? method.id + phoneNumber.current : method.id);
+ start(
+ 60,
+ method.id === "sms" ? method.id + phoneNumber.current : method.id
+ );
setSending(false);
ToastEvent.show({
heading: `2FA code sent via ${method.id}.`,
- type: 'success',
- context: 'local'
+ type: "success",
+ context: "local"
});
} catch (e) {
setSending(false);
const error = e as Error;
- console.log('Send code:', error.message);
- ToastEvent.error(error, 'Error sending 2FA code');
+ console.log("Send code:", error.message);
+ ToastEvent.error(error, "Error sending 2FA code");
}
};
return !method ? null : (
<View>
- <DialogHeader title={method?.title} paragraph={method?.body} padding={12} />
+ <DialogHeader
+ title={method?.title}
+ paragraph={method?.body}
+ padding={12}
+ />
<Seperator />
<View
@@ -237,9 +264,9 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
{loading ? (
<View
style={{
- justifyContent: 'center',
- alignItems: 'center',
- width: '100%',
+ justifyContent: "center",
+ alignItems: "center",
+ width: "100%",
marginBottom: 50
}}
>
@@ -254,24 +281,26 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
) : (
<>
<Input
- loading={method?.id !== 'sms' ? true : false}
+ loading={method?.id !== "sms" ? true : false}
value={
- method?.id === 'email'
+ method?.id === "email"
? //@ts-ignore
user.email
- : method?.id === 'app'
- ? authenticatorDetails?.sharedKey || ''
+ : method?.id === "app"
+ ? authenticatorDetails?.sharedKey || ""
: undefined
}
- multiline={method.id === 'app'}
- onChangeText={value => {
+ multiline={method.id === "app"}
+ onChangeText={(value) => {
phoneNumber.current = value;
}}
- placeholder={method?.id === 'email' ? 'Enter email address' : '+1234567890'}
+ placeholder={
+ method?.id === "email" ? "Enter email address" : "+1234567890"
+ }
onSubmit={() => {
onSendCode();
}}
- onErrorCheck={e => setError(e)}
+ onErrorCheck={(e) => setError(e)}
validationType="phonenumber"
keyboardType="phone-pad"
errorMessage="Please enter a valid phone number with country code"
@@ -283,9 +312,13 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
title={
sending
? null
- : method.id === 'app'
- ? 'Copy'
- : `${seconds ? `Resend code in (${seconds})` : 'Send code'}`
+ : method.id === "app"
+ ? "Copy"
+ : `${
+ seconds
+ ? `Resend code in (${seconds})`
+ : "Send code"
+ }`
}
/>
)
@@ -301,12 +334,12 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
loading={loading}
textAlign="center"
keyboardType="numeric"
- onChangeText={value => (code.current = value)}
+ onChangeText={(value) => (code.current = value)}
//@ts-ignore
inputStyle={{
fontSize: SIZE.lg,
height: 60,
- textAlign: 'center',
+ textAlign: "center",
letterSpacing: 10,
width: null
}}
@@ -319,7 +352,7 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
/>
<Seperator />
<Button
- title={enabling ? null : 'Next'}
+ title={enabling ? null : "Next"}
type="accent"
width={250}
onPress={onNext}
@@ -337,7 +370,7 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
onPress={() => {
setStep &&
setStep({
- id: 'mfapick',
+ id: "mfapick",
props: {
recovery: recovery
}
@@ -351,8 +384,13 @@ export const MFASetup = ({ method, onSuccess, setStep, recovery }: MFAStepProps)
);
};
-export const MFARecoveryCodes = ({ method, recovery, onSuccess, isSetup = true }: MFAStepProps) => {
- const colors = useThemeStore(state => state.colors);
+export const MFARecoveryCodes = ({
+ method,
+ recovery,
+ onSuccess,
+ isSetup = true
+}: MFAStepProps) => {
+ const colors = useThemeStore((state) => state.colors);
const [codes, setCodes] = useState([]);
const [loading, setLoading] = useState(true);
@@ -364,7 +402,7 @@ export const MFARecoveryCodes = ({ method, recovery, onSuccess, isSetup = true }
setLoading(false);
} catch (e) {
const error = e as Error;
- ToastEvent.error(error, 'Error getting codes', 'local');
+ ToastEvent.error(error, "Error getting codes", "local");
setLoading(false);
}
})();
@@ -376,7 +414,11 @@ export const MFARecoveryCodes = ({ method, recovery, onSuccess, isSetup = true }
centered={true}
title="Save your recovery codes"
paragraph={`If you lose access to your ${
- method?.id === 'email' ? 'email' : method?.id === 'sms' ? 'phone' : 'auth app'
+ method?.id === "email"
+ ? "email"
+ : method?.id === "sms"
+ ? "phone"
+ : "auth app"
}, you can login to Notesnook using your recovery codes. Each code can only be used once.`}
padding={12}
/>
@@ -385,9 +427,9 @@ export const MFARecoveryCodes = ({ method, recovery, onSuccess, isSetup = true }
{loading ? (
<View
style={{
- justifyContent: 'center',
- alignItems: 'center',
- width: '100%',
+ justifyContent: "center",
+ alignItems: "center",
+ width: "100%",
marginBottom: 50
}}
>
@@ -404,12 +446,16 @@ export const MFARecoveryCodes = ({ method, recovery, onSuccess, isSetup = true }
<FlatList
data={codes}
contentContainerStyle={{
- alignItems: 'center'
+ alignItems: "center"
}}
numColumns={2}
renderItem={({ item, index }) => (
<Heading
- style={{ marginHorizontal: 15, marginVertical: 5, fontFamily: 'monospace' }}
+ style={{
+ marginHorizontal: 15,
+ marginVertical: 5,
+ fontFamily: "monospace"
+ }}
size={SIZE.lg}
>
{item}
@@ -420,8 +466,8 @@ export const MFARecoveryCodes = ({ method, recovery, onSuccess, isSetup = true }
<View
style={{
- flexDirection: 'row',
- justifyContent: 'center',
+ flexDirection: "row",
+ justifyContent: "center",
marginBottom: 10
}}
>
@@ -429,12 +475,12 @@ export const MFARecoveryCodes = ({ method, recovery, onSuccess, isSetup = true }
title="Copy codes"
fontSize={SIZE.md}
onPress={() => {
- let codeString = codes.join('\n');
+ let codeString = codes.join("\n");
Clipboard.setString(codeString);
ToastEvent.show({
- heading: 'Recovery codes copied!',
- type: 'success',
- context: 'global'
+ heading: "Recovery codes copied!",
+ type: "success",
+ context: "global"
});
}}
style={{
@@ -448,29 +494,33 @@ export const MFARecoveryCodes = ({ method, recovery, onSuccess, isSetup = true }
onPress={async () => {
try {
let path;
- let fileName = 'notesnook_recoverycodes';
- fileName = sanitizeFilename(fileName, { replacement: '_' });
- fileName = fileName + '.txt';
- const codeString = codes.join('\n');
- if (Platform.OS === 'android') {
+ let fileName = "notesnook_recoverycodes";
+ fileName = sanitizeFilename(fileName, { replacement: "_" });
+ fileName = fileName + ".txt";
+ const codeString = codes.join("\n");
+ if (Platform.OS === "android") {
let file = await ScopedStorage.createDocument(
fileName,
- 'text/plain',
+ "text/plain",
codeString,
- 'utf8'
+ "utf8"
);
if (!file) return;
path = file.uri;
} else {
- path = await Storage.checkAndCreateDir('/');
- await RNFetchBlob.fs.writeFile(path + fileName, codeString, 'utf8');
+ path = await Storage.checkAndCreateDir("/");
+ await RNFetchBlob.fs.writeFile(
+ path + fileName,
+ codeString,
+ "utf8"
+ );
path = path + fileName;
}
ToastEvent.show({
- heading: 'Recovery codes saved to text file',
- type: 'success',
- context: 'local'
+ heading: "Recovery codes saved to text file",
+ type: "success",
+ context: "local"
});
return path;
} catch (e) {}
@@ -479,7 +529,7 @@ export const MFARecoveryCodes = ({ method, recovery, onSuccess, isSetup = true }
</View>
<Button
- title={isSetup ? 'Next' : 'Done'}
+ title={isSetup ? "Next" : "Done"}
type="accent"
width={250}
onPress={() => {
@@ -500,14 +550,14 @@ export const MFARecoveryCodes = ({ method, recovery, onSuccess, isSetup = true }
);
};
-MFARecoveryCodes.present = (methodId: MFAMethod['id']) => {
+MFARecoveryCodes.present = (methodId: MFAMethod["id"]) => {
presentSheet({
component: <MFARecoveryCodes method={{ id: methodId }} isSetup={false} />
});
};
const mfaSvg = (
- colors: ThemeStore['colors']
+ colors: ThemeStore["colors"]
) => `<svg xmlns="http://www.w3.org/2000/svg" data-name="Layer 1" viewBox="0 0 382.94 405.93">
<path fill="${colors.pri}" d="M192.58 405.92a75.19 75.19 0 0 1-18.64-2.41l-1.2-.33-1.12-.56c-40.24-20.18-74.19-46.83-100.9-79.21a299.86 299.86 0 0 1-50.95-90.47A348.21 348.21 0 0 1 .07 110.27l.04-2.02c0-20.29 11.26-38.09 28.7-45.35C42.13 57.34 163.24 7.6 172 4c16.48-8.26 34.06-1.36 36.87-.16 6.31 2.58 118.28 48.38 142.47 59.9 24.94 11.87 31.6 33.2 31.6 43.93 0 48.6-8.43 94-25.02 134.97a312.52 312.52 0 0 1-56.16 90.51c-45.85 51.6-91.7 69.89-92.15 70.05a50.11 50.11 0 0 1-17.04 2.72zm-10.79-26.71c3.98.89 13.13 2.22 19.1.05 7.58-2.77 45.96-22.67 81.83-63.03 49.55-55.77 74.7-125.88 74.74-208.38-.1-1.67-1.28-13.59-17.07-21.1-23.72-11.3-140.1-58.89-141.27-59.37l-.32-.14c-2.44-1.02-10.2-3.17-15.55-.37l-1.08.5c-1.3.54-129.86 53.34-143.57 59.05-9.6 4-13 13.9-13 21.83 0 .58-.02 1.43-.05 2.52-1.1 56.44 11.97 195.34 156.24 268.44z"/>
<path fill="${colors.nav}" d="M177.33 15.59S47.61 68.87 33.71 74.66c-13.9 5.79-20.85 19.7-20.85 33.6 0 13.9-10.45 195.26 164.47 282.96 0 0 15.88 4.39 27.92 0 12.04-4.39 164.96-78.52 164.96-283.55 0 0 0-20.85-24.33-32.43C321.55 63.66 203.94 15.6 203.94 15.6s-14.44-6.37-26.6 0z"/>
@@ -516,11 +566,11 @@ const mfaSvg = (
</svg>`;
const MFASuccess = ({ recovery }: MFAStepProps) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<View
style={{
- alignItems: 'center'
+ alignItems: "center"
}}
>
<Seperator />
@@ -528,7 +578,11 @@ const MFASuccess = ({ recovery }: MFAStepProps) => {
<Seperator />
<DialogHeader
centered={true}
- title={recovery ? 'Fallback method for 2FA enabled' : 'Two-factor authentication enabled!'}
+ title={
+ recovery
+ ? "Fallback method for 2FA enabled"
+ : "Two-factor authentication enabled!"
+ }
paragraph="Your account is now 100% secure against unauthorized logins."
padding={12}
/>
@@ -563,7 +617,7 @@ const MFASuccess = ({ recovery }: MFAStepProps) => {
export const MFASheet = ({ recovery }: { recovery?: boolean }) => {
const [step, setStep] = useState<MFAStep>({
- id: 'mfapick',
+ id: "mfapick",
props: {
recovery: recovery
}
@@ -573,9 +627,9 @@ export const MFASheet = ({ recovery }: { recovery?: boolean }) => {
mfapick: (
<MFAMethodsPickerStep
recovery={recovery}
- onSuccess={method => {
+ onSuccess={(method) => {
setStep({
- id: 'setup',
+ id: "setup",
props: {
method: method
}
@@ -588,9 +642,9 @@ export const MFASheet = ({ recovery }: { recovery?: boolean }) => {
recovery={recovery}
setStep={setStep}
{...step.props}
- onSuccess={method => {
+ onSuccess={(method) => {
setStep({
- id: 'recoveryCodes',
+ id: "recoveryCodes",
props: {
method: method
}
@@ -602,9 +656,9 @@ export const MFASheet = ({ recovery }: { recovery?: boolean }) => {
<MFARecoveryCodes
recovery={recovery}
{...step.props}
- onSuccess={method => {
+ onSuccess={(method) => {
setStep({
- id: 'success',
+ id: "success",
props: {
method: method
}
diff --git a/apps/mobile/app/screens/settings/app-lock.js b/apps/mobile/app/screens/settings/app-lock.js
index e24a972cc..f6823eb8f 100644
--- a/apps/mobile/app/screens/settings/app-lock.js
+++ b/apps/mobile/app/screens/settings/app-lock.js
@@ -1,53 +1,53 @@
-import React, { useState } from 'react';
-import { Dimensions, LayoutAnimation, Platform, View } from 'react-native';
-import Animated, { FadeInDown, FadeOutUp } from 'react-native-reanimated';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { SVG_Z } from '../../components/intro';
-import { WelcomeNotice } from '../../components/intro/welcome';
-import { Button } from '../../components/ui/button';
-import { PressableButton } from '../../components/ui/pressable';
-import Seperator from '../../components/ui/seperator';
-import { SvgView } from '../../components/ui/svg';
-import { BouncingView } from '../../components/ui/transitions/bouncing-view';
-import Heading from '../../components/ui/typography/heading';
-import Paragraph from '../../components/ui/typography/paragraph';
-import { DDS } from '../../services/device-detection';
-import { presentSheet, ToastEvent } from '../../services/event-manager';
-import SettingsService from '../../services/settings';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { getElevation } from '../../utils';
-import umami from '../../common/analytics';
-import { SIZE } from '../../utils/size';
-import BiometicService from '../../services/biometrics';
-import { useUserStore } from '../../stores/use-user-store';
+import React, { useState } from "react";
+import { Dimensions, LayoutAnimation, Platform, View } from "react-native";
+import Animated, { FadeInDown, FadeOutUp } from "react-native-reanimated";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { SVG_Z } from "../../components/intro";
+import { WelcomeNotice } from "../../components/intro/welcome";
+import { Button } from "../../components/ui/button";
+import { PressableButton } from "../../components/ui/pressable";
+import Seperator from "../../components/ui/seperator";
+import { SvgView } from "../../components/ui/svg";
+import { BouncingView } from "../../components/ui/transitions/bouncing-view";
+import Heading from "../../components/ui/typography/heading";
+import Paragraph from "../../components/ui/typography/paragraph";
+import { DDS } from "../../services/device-detection";
+import { presentSheet, ToastEvent } from "../../services/event-manager";
+import SettingsService from "../../services/settings";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { getElevation } from "../../utils";
+import umami from "../../common/analytics";
+import { SIZE } from "../../utils/size";
+import BiometicService from "../../services/biometrics";
+import { useUserStore } from "../../stores/use-user-store";
const AppLock = ({ navigation, route }) => {
- const colors = useThemeStore(state => state.colors);
- const appLockMode = useSettingStore(state => state.settings.appLockMode);
+ const colors = useThemeStore((state) => state.colors);
+ const appLockMode = useSettingStore((state) => state.settings.appLockMode);
const [step, setStep] = useState(0);
const welcome = route?.params?.welcome;
const modes = [
{
- title: 'No privacy',
- value: 'none',
- desc: 'Your notes are always unlocked. Anyone who has access to your phone can read them.',
+ title: "No privacy",
+ value: "none",
+ desc: "Your notes are always unlocked. Anyone who has access to your phone can read them.",
activeColor: colors.errorText
},
{
- title: 'Medium privacy',
- value: 'launch',
- desc: 'Your notes are locked when you exit the app but remain unlocked when you switch to other apps or background.',
+ title: "Medium privacy",
+ value: "launch",
+ desc: "Your notes are locked when you exit the app but remain unlocked when you switch to other apps or background.",
activeColor: colors.accent
},
{
- title: 'Maximum privacy (Recommended)',
- value: 'background',
+ title: "Maximum privacy (Recommended)",
+ value: "background",
desc: `Your notes are locked immediately when you switch to other apps or background. ${
- Platform.OS === 'ios'
- ? 'App contents are hidden in app switcher'
- : 'Screenshots are disabled and app contents are hidden in app switcher.'
+ Platform.OS === "ios"
+ ? "App contents are hidden in app switcher"
+ : "Screenshots are disabled and app contents are hidden in app switcher."
}`,
activeColor: colors.accent
}
@@ -59,25 +59,25 @@ const AppLock = ({ navigation, route }) => {
exiting={!welcome ? undefined : FadeOutUp}
entering={!welcome ? undefined : FadeInDown}
style={{
- justifyContent: !welcome ? undefined : 'center',
- height: !welcome ? undefined : '100%',
- width: !welcome ? undefined : '100%'
+ justifyContent: !welcome ? undefined : "center",
+ height: !welcome ? undefined : "100%",
+ width: !welcome ? undefined : "100%"
}}
>
{step === 0 ? (
<>
<View
style={{
- flexDirection: 'row',
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- width: DDS.isTab && welcome ? '50%' : '95%',
+ flexDirection: "row",
+ alignItems: "flex-end",
+ justifyContent: "space-between",
+ width: DDS.isTab && welcome ? "50%" : "95%",
paddingVertical: 12,
paddingHorizontal: 0,
- alignSelf: 'center',
+ alignSelf: "center",
minHeight: 125,
borderBottomWidth: 1,
- borderBottomColor: welcome ? 'transparent' : colors.nav
+ borderBottomColor: welcome ? "transparent" : colors.nav
}}
>
<Icon
@@ -85,7 +85,7 @@ const AppLock = ({ navigation, route }) => {
color={colors.border}
size={100}
style={{
- position: 'absolute',
+ position: "absolute",
right: 0,
top: 6
}}
@@ -93,14 +93,14 @@ const AppLock = ({ navigation, route }) => {
<View
style={{
- alignItems: !welcome ? undefined : 'center',
- width: '100%'
+ alignItems: !welcome ? undefined : "center",
+ width: "100%"
}}
>
<Heading>Protect your notes</Heading>
<Paragraph
style={{
- textAlign: !welcome ? undefined : 'center'
+ textAlign: !welcome ? undefined : "center"
}}
size={SIZE.md}
>
@@ -112,53 +112,60 @@ const AppLock = ({ navigation, route }) => {
<View
style={{
paddingHorizontal: 12,
- width: DDS.isTab && welcome ? '50%' : undefined,
- alignSelf: 'center'
+ width: DDS.isTab && welcome ? "50%" : undefined,
+ alignSelf: "center"
}}
>
- {modes.map(item => (
+ {modes.map((item) => (
<PressableButton
key={item.title}
- type={appLockMode === item.value ? 'grayBg' : 'transparent'}
+ type={appLockMode === item.value ? "grayBg" : "transparent"}
onPress={async () => {
if (
!(await BiometicService.isBiometryAvailable()) &&
!useUserStore.getState().user
) {
ToastEvent.show({
- heading: 'Biometrics not enrolled',
- type: 'error',
+ heading: "Biometrics not enrolled",
+ type: "error",
message:
- 'To use app lock, you must enable biometrics such as Fingerprint lock or Face ID on your phone or create an account.'
+ "To use app lock, you must enable biometrics such as Fingerprint lock or Face ID on your phone or create an account."
});
return;
}
SettingsService.set({ appLockMode: item.value });
}}
customStyle={{
- justifyContent: 'flex-start',
- alignItems: 'flex-start',
+ justifyContent: "flex-start",
+ alignItems: "flex-start",
paddingHorizontal: 12,
paddingVertical: 12,
marginTop: 0,
marginBottom: 12,
borderWidth: 1,
- borderColor: appLockMode === item.value ? item.activeColor : colors.nav
+ borderColor:
+ appLockMode === item.value ? item.activeColor : colors.nav
}}
style={{
marginBottom: 10
}}
>
<Heading
- color={appLockMode === item.value ? item.activeColor : colors.pri}
- style={{ maxWidth: '95%' }}
+ color={
+ appLockMode === item.value ? item.activeColor : colors.pri
+ }
+ style={{ maxWidth: "95%" }}
size={SIZE.md}
>
{item.title}
</Heading>
<Paragraph
- color={appLockMode === item.value ? item.activeColor : colors.icon}
- style={{ maxWidth: '95%' }}
+ color={
+ appLockMode === item.value
+ ? item.activeColor
+ : colors.icon
+ }
+ style={{ maxWidth: "95%" }}
size={SIZE.sm}
>
{item.desc}
@@ -176,16 +183,16 @@ const AppLock = ({ navigation, route }) => {
...LayoutAnimation.Presets.linear,
delete: {
duration: 50,
- property: 'opacity',
- type: 'linear'
+ property: "opacity",
+ type: "linear"
}
});
- umami.pageView('/privacymode', '/welcome');
+ umami.pageView("/privacymode", "/welcome");
setStep(1);
}}
style={{
paddingHorizontal: 24,
- alignSelf: 'center',
+ alignSelf: "center",
borderRadius: 100,
...getElevation(5),
marginTop: 30
@@ -203,7 +210,7 @@ const AppLock = ({ navigation, route }) => {
{welcome ? (
<BouncingView
style={{
- position: 'absolute',
+ position: "absolute",
bottom: DDS.isTab ? -300 : -130,
zIndex: -1
}}
@@ -211,8 +218,8 @@ const AppLock = ({ navigation, route }) => {
duration={3000}
>
<SvgView
- width={Dimensions.get('window').width}
- height={Dimensions.get('window').width}
+ width={Dimensions.get("window").width}
+ height={Dimensions.get("window").width}
src={SVG_Z}
/>
</BouncingView>
@@ -222,7 +229,7 @@ const AppLock = ({ navigation, route }) => {
);
};
-AppLock.present = async isWelcome => {
+AppLock.present = async (isWelcome) => {
presentSheet({
component: <AppLock welcome={isWelcome} s={0} />,
disableClosing: isWelcome
diff --git a/apps/mobile/app/screens/settings/appearance.js b/apps/mobile/app/screens/settings/appearance.js
index 982a20abc..cc152b494 100644
--- a/apps/mobile/app/screens/settings/appearance.js
+++ b/apps/mobile/app/screens/settings/appearance.js
@@ -1,32 +1,36 @@
-import React, { useRef, useState } from 'react';
-import { View } from 'react-native';
-import { ScrollView } from 'react-native-gesture-handler';
-import Menu, { MenuItem } from 'react-native-reanimated-material-menu';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { PressableButton } from '../../components/ui/pressable';
-import Paragraph from '../../components/ui/typography/paragraph';
-import { DDS } from '../../services/device-detection';
-import { ToastEvent } from '../../services/event-manager';
-import PremiumService from '../../services/premium';
-import SettingsService from '../../services/settings';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { hexToRGBA, RGB_Linear_Shade, switchAccentColor } from '../../utils/color-scheme/utils';
-import { MenuItemsList } from '../../utils/constants';
-import { pv, SIZE } from '../../utils/size';
+import React, { useRef, useState } from "react";
+import { View } from "react-native";
+import { ScrollView } from "react-native-gesture-handler";
+import Menu, { MenuItem } from "react-native-reanimated-material-menu";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { PressableButton } from "../../components/ui/pressable";
+import Paragraph from "../../components/ui/typography/paragraph";
+import { DDS } from "../../services/device-detection";
+import { ToastEvent } from "../../services/event-manager";
+import PremiumService from "../../services/premium";
+import SettingsService from "../../services/settings";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import {
+ hexToRGBA,
+ RGB_Linear_Shade,
+ switchAccentColor
+} from "../../utils/color-scheme/utils";
+import { MenuItemsList } from "../../utils/constants";
+import { pv, SIZE } from "../../utils/size";
export const HomagePageSelector = () => {
- const colors = useThemeStore(state => state.colors);
- const settings = useSettingStore(state => state.settings);
+ const colors = useThemeStore((state) => state.colors);
+ const settings = useSettingStore((state) => state.settings);
const menuRef = useRef();
const [width, setWidth] = useState(0);
return (
<View
- onLayout={event => {
+ onLayout={(event) => {
setWidth(event.nativeEvent.layout.width);
}}
style={{
- width: '100%'
+ width: "100%"
}}
>
<Menu
@@ -48,11 +52,11 @@ export const HomagePageSelector = () => {
}}
type="grayBg"
customStyle={{
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
marginTop: 10,
- width: '100%',
- justifyContent: 'space-between',
+ width: "100%",
+ justifyContent: "space-between",
padding: 12
}}
>
@@ -62,27 +66,31 @@ export const HomagePageSelector = () => {
}
>
{MenuItemsList.slice(0, MenuItemsList.length - 1).map(
- item =>
- item.name !== 'Monographs' && (
+ (item) =>
+ item.name !== "Monographs" && (
<MenuItem
key={item.name}
onPress={async () => {
menuRef.current?.hide();
await SettingsService.set({ homepage: item.name });
ToastEvent.show({
- heading: 'Homepage set to ' + item.name,
- message: 'Restart the app for changes to take effect.',
- type: 'success'
+ heading: "Homepage set to " + item.name,
+ message: "Restart the app for changes to take effect.",
+ type: "success"
});
}}
style={{
- backgroundColor: settings.homepage === item.name ? colors.nav : 'transparent',
- width: '100%',
+ backgroundColor:
+ settings.homepage === item.name
+ ? colors.nav
+ : "transparent",
+ width: "100%",
maxWidth: width
}}
textStyle={{
fontSize: SIZE.md,
- color: settings.homepage === item.name ? colors.accent : colors.pri
+ color:
+ settings.homepage === item.name ? colors.accent : colors.pri
}}
>
{item.name}
@@ -95,7 +103,7 @@ export const HomagePageSelector = () => {
};
export const AccentColorPicker = ({ settings = true, wrap = true }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
function changeAccentColor(color) {
switchAccentColor(color);
}
@@ -103,26 +111,26 @@ export const AccentColorPicker = ({ settings = true, wrap = true }) => {
return (
<View
style={{
- flexDirection: 'row',
- flexWrap: 'wrap',
- alignItems: 'center',
- width: '100%'
+ flexDirection: "row",
+ flexWrap: "wrap",
+ alignItems: "center",
+ width: "100%"
}}
>
{[
- '#FF5722',
- '#FFA000',
- '#1B5E20',
- '#008837',
- '#757575',
- '#0560ff',
- '#009688',
- '#2196F3',
- '#880E4F',
- '#9C27B0',
- '#FF1744',
- '#B71C1C'
- ].map(item => (
+ "#FF5722",
+ "#FFA000",
+ "#1B5E20",
+ "#008837",
+ "#757575",
+ "#0560ff",
+ "#009688",
+ "#2196F3",
+ "#880E4F",
+ "#9C27B0",
+ "#FF1744",
+ "#B71C1C"
+ ].map((item) => (
<PressableButton
key={item}
customColor={
@@ -145,9 +153,9 @@ export const AccentColorPicker = ({ settings = true, wrap = true }) => {
});
}}
customStyle={{
- flexDirection: 'row',
- justifyContent: 'center',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "center",
+ alignItems: "center",
marginRight: 10,
marginVertical: 5,
width: DDS.isLargeTablet() ? 40 : 50,
@@ -156,7 +164,11 @@ export const AccentColorPicker = ({ settings = true, wrap = true }) => {
}}
>
{colors.accent === item ? (
- <Icon size={DDS.isLargeTablet() ? SIZE.lg : SIZE.xxl} color="white" name="check" />
+ <Icon
+ size={DDS.isLargeTablet() ? SIZE.lg : SIZE.xxl}
+ color="white"
+ name="check"
+ />
) : null}
</PressableButton>
))}
diff --git a/apps/mobile/app/screens/settings/backup-restore.js b/apps/mobile/app/screens/settings/backup-restore.js
index 4b75799b3..7b89b573c 100644
--- a/apps/mobile/app/screens/settings/backup-restore.js
+++ b/apps/mobile/app/screens/settings/backup-restore.js
@@ -1,18 +1,18 @@
-import React from 'react';
-import { Platform, TouchableOpacity, View } from 'react-native';
-import Paragraph from '../../components/ui/typography/paragraph';
-import Backup from '../../services/backup';
-import PremiumService from '../../services/premium';
-import SettingsService from '../../services/settings';
-import { useUserStore } from '../../stores/use-user-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
+import React from "react";
+import { Platform, TouchableOpacity, View } from "react-native";
+import Paragraph from "../../components/ui/typography/paragraph";
+import Backup from "../../services/backup";
+import PremiumService from "../../services/premium";
+import SettingsService from "../../services/settings";
+import { useUserStore } from "../../stores/use-user-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
export const AutomaticBackupsSelector = () => {
- const colors = useThemeStore(state => state.colors);
- const settings = useSettingStore(state => state.settings);
- const user = useUserStore(state => state.user);
+ const colors = useThemeStore((state) => state.colors);
+ const settings = useSettingStore((state) => state.settings);
+ const user = useUserStore((state) => state.user);
const updateAskForBackup = async () => {
SettingsService.set({
nextBackupRequestTime: Date.now() + 86400000 * 3
@@ -22,42 +22,42 @@ export const AutomaticBackupsSelector = () => {
return (
<View
style={{
- flexDirection: 'row',
+ flexDirection: "row",
borderRadius: 5,
- overflow: 'hidden',
+ overflow: "hidden",
flexShrink: 1,
- width: '100%'
+ width: "100%"
}}
>
{[
{
- title: 'Never',
- value: 'useroff'
+ title: "Never",
+ value: "useroff"
},
{
- title: 'Daily',
- value: 'daily'
+ title: "Daily",
+ value: "daily"
},
{
- title: 'Weekly',
- value: 'weekly'
+ title: "Weekly",
+ value: "weekly"
},
{
- title: 'Monthly',
- value: 'monthly'
+ title: "Monthly",
+ value: "monthly"
}
].map((item, index) => (
<TouchableOpacity
activeOpacity={0.9}
onPress={async () => {
- if (item.value === 'useroff') {
+ if (item.value === "useroff") {
await SettingsService.set({ reminder: item.value });
} else {
await PremiumService.verify(async () => {
- if (Platform.OS === 'android') {
+ if (Platform.OS === "android") {
let granted = await Backup.checkBackupDirExists();
if (!granted) {
- console.log('returning');
+ console.log("returning");
return;
}
}
@@ -68,17 +68,18 @@ export const AutomaticBackupsSelector = () => {
}}
key={item.value}
style={{
- backgroundColor: settings.reminder === item.value ? colors.accent : colors.nav,
- justifyContent: 'center',
- alignItems: 'center',
- width: '25%',
+ backgroundColor:
+ settings.reminder === item.value ? colors.accent : colors.nav,
+ justifyContent: "center",
+ alignItems: "center",
+ width: "25%",
height: 35,
borderRightWidth: index !== 3 ? 1 : 0,
borderRightColor: colors.border
}}
>
<Paragraph
- color={settings.reminder === item.value ? 'white' : colors.icon}
+ color={settings.reminder === item.value ? "white" : colors.icon}
size={SIZE.sm - 1}
>
{item.title}
diff --git a/apps/mobile/app/screens/settings/components.tsx b/apps/mobile/app/screens/settings/components.tsx
index fc55fca78..4b9deb40b 100644
--- a/apps/mobile/app/screens/settings/components.tsx
+++ b/apps/mobile/app/screens/settings/components.tsx
@@ -1,9 +1,9 @@
-import React, { ReactElement } from 'react';
-import { AccentColorPicker, HomagePageSelector } from './appearance';
-import { AutomaticBackupsSelector } from './backup-restore';
-import DebugLogs from './debug';
-import { ConfigureToolbar } from './editor/configure-toolbar';
-import { Subscription } from './subscription';
+import React, { ReactElement } from "react";
+import { AccentColorPicker, HomagePageSelector } from "./appearance";
+import { AutomaticBackupsSelector } from "./backup-restore";
+import DebugLogs from "./debug";
+import { ConfigureToolbar } from "./editor/configure-toolbar";
+import { Subscription } from "./subscription";
export const components: { [name: string]: ReactElement } = {
colorpicker: <AccentColorPicker wrap={true} />,
@@ -11,5 +11,5 @@ export const components: { [name: string]: ReactElement } = {
autobackups: <AutomaticBackupsSelector />,
subscription: <Subscription />,
configuretoolbar: <ConfigureToolbar />,
- 'debug-logs': <DebugLogs />
+ "debug-logs": <DebugLogs />
};
diff --git a/apps/mobile/app/screens/settings/debug.tsx b/apps/mobile/app/screens/settings/debug.tsx
index a26a5512a..1e599e4de 100644
--- a/apps/mobile/app/screens/settings/debug.tsx
+++ b/apps/mobile/app/screens/settings/debug.tsx
@@ -1,19 +1,23 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import { format, LogLevel, logManager } from '@streetwriters/notesnook-core/logger';
-import React, { useEffect, useState } from 'react';
-import { FlatList, Platform, TouchableOpacity, View } from 'react-native';
-import * as ScopedStorage from 'react-native-scoped-storage';
-import RNFetchBlob from 'rn-fetch-blob';
-import { presentDialog } from '../../components/dialog/functions';
-import { IconButton } from '../../components/ui/icon-button';
-import { Notice } from '../../components/ui/notice';
-import Paragraph from '../../components/ui/typography/paragraph';
-import { ToastEvent } from '../../services/event-manager';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { hexToRGBA } from '../../utils/color-scheme/utils';
-import Storage from '../../common/database/storage';
-import useTimer from '../../hooks/use-timer';
-import { sanitizeFilename } from '../../utils/sanitizer';
+import Clipboard from "@react-native-clipboard/clipboard";
+import {
+ format,
+ LogLevel,
+ logManager
+} from "@streetwriters/notesnook-core/logger";
+import React, { useEffect, useState } from "react";
+import { FlatList, Platform, TouchableOpacity, View } from "react-native";
+import * as ScopedStorage from "react-native-scoped-storage";
+import RNFetchBlob from "rn-fetch-blob";
+import { presentDialog } from "../../components/dialog/functions";
+import { IconButton } from "../../components/ui/icon-button";
+import { Notice } from "../../components/ui/notice";
+import Paragraph from "../../components/ui/typography/paragraph";
+import { ToastEvent } from "../../services/event-manager";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { hexToRGBA } from "../../utils/color-scheme/utils";
+import Storage from "../../common/database/storage";
+import useTimer from "../../hooks/use-timer";
+import { sanitizeFilename } from "../../utils/sanitizer";
// function getLevelString(level: number) {
// switch (level) {
@@ -33,8 +37,8 @@ import { sanitizeFilename } from '../../utils/sanitizer';
// }
export default function DebugLogs() {
- const colors = useThemeStore(state => state.colors);
- const { seconds, start } = useTimer('debug_logs_timer');
+ const colors = useThemeStore((state) => state.colors);
+ const { seconds, start } = useTimer("debug_logs_timer");
const [logs, setLogs] = useState<
{
key: string;
@@ -49,13 +53,13 @@ export default function DebugLogs() {
useEffect(() => {
(async () => {
if (seconds === 0) {
- start(5, 'debug_logs_timer');
+ start(5, "debug_logs_timer");
let logs = await logManager?.get();
if (!logs) return;
if (logs.length > 0 && !currentLog) {
setCurrentLog(logs[0]);
} else {
- setCurrentLog(logs[logs.findIndex(l => l.key === currentLog?.key)]);
+ setCurrentLog(logs[logs.findIndex((l) => l.key === currentLog?.key)]);
}
setLogs(logs);
}
@@ -68,7 +72,7 @@ export default function DebugLogs() {
? hexToRGBA(colors.red, 0.2)
: item.level === LogLevel.Warn
? hexToRGBA(colors.orange, 0.2)
- : 'transparent';
+ : "transparent";
const color =
item.level === LogLevel.Error || item.level === LogLevel.Fatal
@@ -83,9 +87,9 @@ export default function DebugLogs() {
onLongPress={() => {
Clipboard.setString(format(item));
ToastEvent.show({
- heading: 'Debug log copied!',
- context: 'global',
- type: 'success'
+ heading: "Debug log copied!",
+ context: "global",
+ type: "success"
});
}}
style={{
@@ -100,8 +104,8 @@ export default function DebugLogs() {
<Paragraph
style={{
flexShrink: 1,
- flexWrap: 'wrap',
- fontFamily: Platform.OS === 'ios' ? 'Menlo' : 'monospace'
+ flexWrap: "wrap",
+ fontFamily: Platform.OS === "ios" ? "Menlo" : "monospace"
}}
size={12}
color={color}
@@ -117,31 +121,31 @@ export default function DebugLogs() {
let path = null;
const fileName = sanitizeFilename(`notesnook_logs_${Date.now()}`);
const data = currentLog?.logs
- .map(log => {
- return !log ? '' : format(log);
+ .map((log) => {
+ return !log ? "" : format(log);
})
.join(`\n`);
if (!data) return;
- if (Platform.OS === 'android') {
+ if (Platform.OS === "android") {
let file = await ScopedStorage.createDocument(
- fileName + '.txt',
- 'text/plain',
+ fileName + ".txt",
+ "text/plain",
data,
- 'utf8'
+ "utf8"
);
if (!file) return;
path = file.uri;
} else {
- path = await Storage.checkAndCreateDir('/');
- await RNFetchBlob.fs.writeFile(path + fileName + '.txt', data, 'utf8');
+ path = await Storage.checkAndCreateDir("/");
+ await RNFetchBlob.fs.writeFile(path + fileName + ".txt", data, "utf8");
path = path + fileName;
}
if (path) {
ToastEvent.show({
- heading: 'Debug logs downloaded',
- context: 'global',
- type: 'success'
+ heading: "Debug logs downloaded",
+ context: "global",
+ type: "success"
});
}
} catch (e) {
@@ -151,28 +155,28 @@ export default function DebugLogs() {
const copyLogs = () => {
const data = currentLog?.logs
- .map(log => {
- return !log ? '' : format(log);
+ .map((log) => {
+ return !log ? "" : format(log);
})
.join(`\n`);
if (!data) return;
Clipboard.setString(data);
ToastEvent.show({
- heading: 'Debug log copied!',
- context: 'global',
- type: 'success'
+ heading: "Debug log copied!",
+ context: "global",
+ type: "success"
});
};
const clearLogs = () => {
if (!currentLog) return;
presentDialog({
- title: 'Clear logs',
+ title: "Clear logs",
paragraph: `Are you sure you want to delete all logs from ${currentLog.key}?`,
- negativeText: 'Cancel',
- positiveText: 'Clear',
+ negativeText: "Cancel",
+ positiveText: "Clear",
positivePress: () => {
- let index = logs.findIndex(l => (l.key = currentLog.key));
+ let index = logs.findIndex((l) => (l.key = currentLog.key));
logManager?.delete(currentLog.key);
if (logs.length > 1) {
if (logs.length - 1 === index) {
@@ -211,16 +215,16 @@ export default function DebugLogs() {
style={{
paddingHorizontal: 12,
marginBottom: 10,
- flexDirection: 'row',
- alignItems: 'center',
+ flexDirection: "row",
+ alignItems: "center",
backgroundColor: colors.bg,
- justifyContent: 'space-between'
+ justifyContent: "space-between"
}}
>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<Paragraph>{currentLog.key}</Paragraph>
@@ -232,7 +236,7 @@ export default function DebugLogs() {
marginHorizontal: 5
}}
onPress={() => {
- let index = logs.findIndex(l => l.key === currentLog.key);
+ let index = logs.findIndex((l) => l.key === currentLog.key);
if (index === 0) return;
setCurrentLog(logs[index - 1]);
}}
@@ -247,7 +251,7 @@ export default function DebugLogs() {
height: 30
}}
onPress={() => {
- let index = logs.findIndex(l => l.key === currentLog.key);
+ let index = logs.findIndex((l) => l.key === currentLog.key);
if (index === logs.length - 1) return;
setCurrentLog(logs[index + 1]);
}}
@@ -259,7 +263,7 @@ export default function DebugLogs() {
<View
style={{
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
<IconButton
@@ -301,7 +305,7 @@ export default function DebugLogs() {
}
style={{
flex: 1,
- width: '100%'
+ width: "100%"
}}
stickyHeaderIndices={[0]}
ListFooterComponent={
diff --git a/apps/mobile/app/screens/settings/editor/common.tsx b/apps/mobile/app/screens/settings/editor/common.tsx
index 6c7dd7cc5..8980d7fe1 100644
--- a/apps/mobile/app/screens/settings/editor/common.tsx
+++ b/apps/mobile/app/screens/settings/editor/common.tsx
@@ -1,9 +1,13 @@
-import React from 'react';
-import { Group } from './group';
-import { DraggableItem } from './state';
-import { Tool } from './tool';
+import React from "react";
+import { Group } from "./group";
+import { DraggableItem } from "./state";
+import { Tool } from "./tool";
-export const renderTool = ({ item, groupIndex, parentIndex }: DraggableItem) => {
+export const renderTool = ({
+ item,
+ groupIndex,
+ parentIndex
+}: DraggableItem) => {
const data = item as string[];
if (!data) return null;
@@ -21,8 +25,8 @@ export const renderTool = ({ item, groupIndex, parentIndex }: DraggableItem) =>
if (Array.isArray(data[0])) {
tools.unshift(
<Tool
- key={'dummy'}
- item={'dummy'}
+ key={"dummy"}
+ item={"dummy"}
index={-1}
groupIndex={groupIndex}
parentIndex={parentIndex}
diff --git a/apps/mobile/app/screens/settings/editor/configure-toolbar.tsx b/apps/mobile/app/screens/settings/editor/configure-toolbar.tsx
index 43d66db6b..881d93b8c 100644
--- a/apps/mobile/app/screens/settings/editor/configure-toolbar.tsx
+++ b/apps/mobile/app/screens/settings/editor/configure-toolbar.tsx
@@ -1,27 +1,33 @@
-import * as React from 'react';
-import { StyleSheet, View } from 'react-native';
-import { DraxProvider, DraxScrollView } from 'react-native-drax';
-import Animated, { FadeInDown, FadeOutDown } from 'react-native-reanimated';
-import { Button } from '../../../components/ui/button';
-import { Notice } from '../../../components/ui/notice';
-import Paragraph from '../../../components/ui/typography/paragraph';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { SIZE } from '../../../utils/size';
-import { Group } from './group';
-import { useDragState } from './state';
+import * as React from "react";
+import { StyleSheet, View } from "react-native";
+import { DraxProvider, DraxScrollView } from "react-native-drax";
+import Animated, { FadeInDown, FadeOutDown } from "react-native-reanimated";
+import { Button } from "../../../components/ui/button";
+import { Notice } from "../../../components/ui/notice";
+import Paragraph from "../../../components/ui/typography/paragraph";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { SIZE } from "../../../utils/size";
+import { Group } from "./group";
+import { useDragState } from "./state";
export const ConfigureToolbar = () => {
- const data = useDragState(state => state.data);
- const preset = useDragState(state => state.preset);
- const colors = useThemeStore(state => state.colors);
+ const data = useDragState((state) => state.data);
+ const preset = useDragState((state) => state.preset);
+ const colors = useThemeStore((state) => state.colors);
const renderGroups = () => {
- return data.map((item, index) => <Group key={`group-${index}`} item={item} index={index} />);
+ return data.map((item, index) => (
+ <Group key={`group-${index}`} item={item} index={index} />
+ ));
};
return (
<DraxProvider>
- <Animated.View entering={FadeInDown} exiting={FadeOutDown} style={styles.container}>
+ <Animated.View
+ entering={FadeInDown}
+ exiting={FadeOutDown}
+ style={styles.container}
+ >
<View
style={{
paddingVertical: 12
@@ -44,28 +50,28 @@ export const ConfigureToolbar = () => {
<View
style={{
- flexDirection: 'row',
- flexWrap: 'wrap',
- width: '100%',
+ flexDirection: "row",
+ flexWrap: "wrap",
+ width: "100%",
marginTop: 10
}}
>
{[
{
- id: 'default',
- name: 'Default'
+ id: "default",
+ name: "Default"
},
{
- id: 'minimal',
- name: 'Minimal'
+ id: "minimal",
+ name: "Minimal"
},
{
- id: 'custom',
- name: 'Custom'
+ id: "custom",
+ name: "Custom"
}
- ].map(item => (
+ ].map((item) => (
<Button
- type={preset === item.id ? 'accent' : 'grayAccent'}
+ type={preset === item.id ? "accent" : "grayAccent"}
style={{
borderRadius: 100,
height: 35,
@@ -100,7 +106,7 @@ export const ConfigureToolbar = () => {
type="grayAccent"
icon="plus"
style={{
- width: '100%'
+ width: "100%"
}}
onPress={() => {
const _data = data.slice();
@@ -119,7 +125,7 @@ const styles = StyleSheet.create({
container: {
flex: 1,
paddingHorizontal: 12,
- width: '100%'
+ width: "100%"
}
});
diff --git a/apps/mobile/app/screens/settings/editor/group.tsx b/apps/mobile/app/screens/settings/editor/group.tsx
index 28469eef6..8af723b56 100644
--- a/apps/mobile/app/screens/settings/editor/group.tsx
+++ b/apps/mobile/app/screens/settings/editor/group.tsx
@@ -1,23 +1,30 @@
-import * as React from 'react';
-import { View } from 'react-native';
-import { DraxDragWithReceiverEventData, DraxView } from 'react-native-drax';
-import Animated, { Layout } from 'react-native-reanimated';
-import { presentDialog } from '../../../components/dialog/functions';
-import { IconButton } from '../../../components/ui/icon-button';
-import Paragraph from '../../../components/ui/typography/paragraph';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { getElevation } from '../../../utils';
-import { SIZE } from '../../../utils/size';
-import { renderTool } from './common';
-import { DraggableItem, useDragState } from './state';
-import ToolSheet from './tool-sheet';
+import * as React from "react";
+import { View } from "react-native";
+import { DraxDragWithReceiverEventData, DraxView } from "react-native-drax";
+import Animated, { Layout } from "react-native-reanimated";
+import { presentDialog } from "../../../components/dialog/functions";
+import { IconButton } from "../../../components/ui/icon-button";
+import Paragraph from "../../../components/ui/typography/paragraph";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { getElevation } from "../../../utils";
+import { SIZE } from "../../../utils/size";
+import { renderTool } from "./common";
+import { DraggableItem, useDragState } from "./state";
+import ToolSheet from "./tool-sheet";
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) => {
- const setData = useDragState(state => state.setData);
- const [dragged, setDragged] = useDragState(state => [state.dragged, state.setDragged]);
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+export const Group = ({
+ item,
+ index: groupIndex,
+ parentIndex
+}: DraggableItem) => {
+ const setData = useDragState((state) => state.setData);
+ const [dragged, setDragged] = useDragState((state) => [
+ state.dragged,
+ state.setDragged
+ ]);
const [recieving, setRecieving] = React.useState(false);
- const [recievePosition, setRecievePosition] = React.useState('above');
+ const [recievePosition, setRecievePosition] = React.useState("above");
const isDragged =
dragged &&
Array.isArray(dragged?.item) &&
@@ -29,7 +36,7 @@ export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) =
height: 0,
width: 0
});
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
if (isDragged) {
console.log(dimensions.current.height, dimensions.current.width);
@@ -41,31 +48,39 @@ export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) =
const reciever = data.receiver.payload;
let _data = useDragState.getState().data.slice();
- if (dragged.type === 'group') {
+ if (dragged.type === "group") {
const fromIndex = dragged.index;
- const toIndex = isDroppedAbove ? Math.max(0, reciever.index) : reciever.index + 1;
+ const toIndex = isDroppedAbove
+ ? Math.max(0, reciever.index)
+ : reciever.index + 1;
- _data.splice(toIndex > fromIndex ? toIndex - 1 : toIndex, 0, _data.splice(fromIndex, 1)[0]);
+ _data.splice(
+ toIndex > fromIndex ? toIndex - 1 : toIndex,
+ 0,
+ _data.splice(fromIndex, 1)[0]
+ );
}
// Always insert sub group at the end of the group.
- if (dragged.type === 'subgroup') {
+ if (dragged.type === "subgroup") {
const fromIndex = dragged.index;
- const toIndex = isDroppedAbove ? Math.max(0, reciever.index) : reciever.index + 1;
+ const toIndex = isDroppedAbove
+ ? Math.max(0, reciever.index)
+ : reciever.index + 1;
const insertAt = _data[reciever.index] as string[];
const insertFrom = _data[dragged.groupIndex] as string[];
- if (typeof insertAt[insertAt.length - 1] !== 'string') {
+ if (typeof insertAt[insertAt.length - 1] !== "string") {
setRecieving(false);
return data.dragAbsolutePosition;
}
insertAt.push(insertFrom.splice(fromIndex, 1)[0]);
}
- if (dragged.type === 'tool') {
+ if (dragged.type === "tool") {
const insertFrom =
- typeof dragged.parentIndex === 'number'
+ typeof dragged.parentIndex === "number"
? (_data[dragged.parentIndex][dragged.groupIndex] as string[])
: (_data[dragged.groupIndex] as string[]);
//@ts-ignore
@@ -79,23 +94,24 @@ export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) =
const onRecieveData = (data: DraxDragWithReceiverEventData) => {
setRecieving(true);
- if (data.dragged.payload.type !== 'group') return setRecievePosition('below');
+ if (data.dragged.payload.type !== "group")
+ return setRecievePosition("below");
if (data.receiver.receiveOffsetRatio.y < 0.5) {
- setRecievePosition('above');
+ setRecievePosition("above");
} else {
- setRecievePosition('below');
+ setRecievePosition("below");
}
};
const buttons = [
{
- name: 'minus',
+ name: "minus",
onPress: () => {
presentDialog({
- context: 'global',
- title: 'Delete group?',
- positiveText: 'Delete',
- paragraph: 'All tools in the collapsed section will also be removed.',
+ context: "global",
+ title: "Delete group?",
+ positiveText: "Delete",
+ paragraph: "All tools in the collapsed section will also be removed.",
positivePress: () => {
if (groupIndex === undefined) return;
const _data = useDragState.getState().data.slice();
@@ -108,7 +124,7 @@ export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) =
}
},
{
- name: 'plus',
+ name: "plus",
onPress: () => {
ToolSheet.present({
item,
@@ -123,13 +139,13 @@ export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) =
return (
<View
- onLayout={event => {
+ onLayout={(event) => {
if (hover) return;
if (!isDragged) dimensions.current = event.nativeEvent.layout;
}}
style={[
{
- width: isDragged ? dimensions.current?.width : '100%',
+ width: isDragged ? dimensions.current?.width : "100%",
backgroundColor: colors.bg,
borderRadius: 10,
...getElevation(hover ? 5 : 0),
@@ -140,17 +156,17 @@ export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) =
{isSubgroup ? null : (
<View
style={{
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
height: 40,
marginBottom: 5
}}
>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
<Icon size={SIZE.md} name="drag" color={colors.icon} />
@@ -167,11 +183,11 @@ export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) =
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
- {buttons.map(item => (
+ {buttons.map((item) => (
<IconButton
top={0}
left={0}
@@ -193,7 +209,12 @@ export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) =
{isDragged && hover
? null
- : renderTool({ item, index: groupIndex, groupIndex, parentIndex: parentIndex })}
+ : renderTool({
+ item,
+ index: groupIndex,
+ groupIndex,
+ parentIndex: parentIndex
+ })}
</View>
);
};
@@ -203,11 +224,13 @@ export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) =
<DraxView
longPressDelay={500}
receptive={
- (dragged.type === 'subgroup' && dragged.groupIndex === groupIndex) ||
- (dragged.type === 'tool' && item.length > 0) ||
- (dragged.type === 'group' && isSubgroup) ||
- (dragged.type === 'subgroup' && isSubgroup) ||
- (dragged.type === 'subgroup' && dragged.item && dragged.item[0] === item[0])
+ (dragged.type === "subgroup" && dragged.groupIndex === groupIndex) ||
+ (dragged.type === "tool" && item.length > 0) ||
+ (dragged.type === "group" && isSubgroup) ||
+ (dragged.type === "subgroup" && isSubgroup) ||
+ (dragged.type === "subgroup" &&
+ dragged.item &&
+ dragged.item[0] === item[0])
? false
: true
}
@@ -215,30 +238,30 @@ export const Group = ({ item, index: groupIndex, parentIndex }: DraggableItem) =
item,
index: groupIndex,
parentIndex,
- type: 'group'
+ type: "group"
}}
onDragStart={() => {
setDragged({
item,
- type: 'group',
+ type: "group",
...dimensions.current
});
}}
- onDragDrop={data => {
+ onDragDrop={(data) => {
setDragged({});
}}
- onDragEnd={data => {
+ onDragEnd={(data) => {
setDragged({});
}}
hoverDragReleasedStyle={{
opacity: 0
}}
receivingStyle={{
- paddingBottom: recievePosition === 'below' ? 50 : 0,
- paddingTop: recievePosition === 'above' ? 50 : 0,
- backgroundColor: dragged.type === 'subgroup' ? colors.nav : undefined,
- marginTop: recievePosition === 'above' ? 10 : 0,
- marginBottom: recievePosition === 'below' ? 10 : 0,
+ paddingBottom: recievePosition === "below" ? 50 : 0,
+ paddingTop: recievePosition === "above" ? 50 : 0,
+ backgroundColor: dragged.type === "subgroup" ? colors.nav : undefined,
+ marginTop: recievePosition === "above" ? 10 : 0,
+ marginBottom: recievePosition === "below" ? 10 : 0,
borderRadius: 10
}}
renderHoverContent={({ dimensions: { width } }) => renderGroup(true)}
diff --git a/apps/mobile/app/screens/settings/editor/state.ts b/apps/mobile/app/screens/settings/editor/state.ts
index 497373774..039462ec8 100644
--- a/apps/mobile/app/screens/settings/editor/state.ts
+++ b/apps/mobile/app/screens/settings/editor/state.ts
@@ -1,16 +1,16 @@
-import type { ToolbarGroupDefinition } from '@streetwriters/editor/dist/es/toolbar/types';
-import create, { State } from 'zustand';
-import { persist } from 'zustand/middleware';
-import { useNoteStore } from '../../../stores/use-notes-store';
-import { useSettingStore } from '../../../stores/use-setting-store';
-import { db } from '../../../common/database';
-import { MMKV } from '../../../common/database/mmkv';
-import { presets } from './toolbar-definition';
+import type { ToolbarGroupDefinition } from "@streetwriters/editor/dist/es/toolbar/types";
+import create, { State } from "zustand";
+import { persist } from "zustand/middleware";
+import { useNoteStore } from "../../../stores/use-notes-store";
+import { useSettingStore } from "../../../stores/use-setting-store";
+import { db } from "../../../common/database";
+import { MMKV } from "../../../common/database/mmkv";
+import { presets } from "./toolbar-definition";
export type ToolDefinition = string | string[];
export type DraggedItem = {
item?: ToolDefinition | ToolDefinition[];
- type?: 'tool' | 'group' | 'subgroup';
+ type?: "tool" | "group" | "subgroup";
height?: number;
groupIndex?: number;
};
@@ -28,8 +28,8 @@ export interface DragState extends State {
data: ToolbarGroupDefinition[];
customPresetData: ToolbarGroupDefinition[];
setData: (data: ToolbarGroupDefinition[]) => void;
- preset: 'default' | 'minimal' | 'custom';
- setPreset: (preset: 'default' | 'minimal' | 'custom') => void;
+ preset: "default" | "minimal" | "custom";
+ setPreset: (preset: "default" | "minimal" | "custom") => void;
init: () => Promise<void>;
}
@@ -40,60 +40,83 @@ function clone(value: any[]) {
export const useDragState = create<DragState>(
persist(
(set, get) => ({
- preset: 'default',
+ preset: "default",
dragged: {},
- setDragged: dragged => {
+ setDragged: (dragged) => {
set({ dragged });
},
- data: presets['default'],
- customPresetData: presets['custom'],
- setData: data => {
+ data: presets["default"],
+ customPresetData: presets["custom"],
+ setData: (data) => {
const _data = clone(data);
- presets['custom'] = _data;
- db.settings?.setToolbarConfig(useSettingStore.getState().deviceMode || 'mobile', {
- preset: 'custom',
- config: clone(_data)
- });
- set({ data: _data, preset: 'custom', customPresetData: _data });
+ presets["custom"] = _data;
+ db.settings?.setToolbarConfig(
+ useSettingStore.getState().deviceMode || "mobile",
+ {
+ preset: "custom",
+ config: clone(_data)
+ }
+ );
+ set({ data: _data, preset: "custom", customPresetData: _data });
},
- setPreset: preset => {
- db.settings?.setToolbarConfig(useSettingStore.getState().deviceMode || 'mobile', {
- preset,
- config: preset === 'custom' ? clone(get().customPresetData) : []
- });
+ setPreset: (preset) => {
+ db.settings?.setToolbarConfig(
+ useSettingStore.getState().deviceMode || "mobile",
+ {
+ preset,
+ config: preset === "custom" ? clone(get().customPresetData) : []
+ }
+ );
set({
preset,
- data: preset === 'custom' ? clone(get().customPresetData) : clone(presets[preset])
+ data:
+ preset === "custom"
+ ? clone(get().customPresetData)
+ : clone(presets[preset])
});
},
init: async () => {
const user = await db.user?.getUser();
if (!user) return;
const toolbarConfig = db.settings?.getToolbarConfig(
- useSettingStore.getState().deviceMode || 'mobile'
+ useSettingStore.getState().deviceMode || "mobile"
);
if (!toolbarConfig) {
- logger.info('DragState', 'No user defined toolbar config was found');
+ logger.info("DragState", "No user defined toolbar config was found");
return;
}
- const preset = toolbarConfig?.preset as DragState['preset'];
- logger.info('DragState', 'Init user toolbar config', preset, toolbarConfig?.config);
+ const preset = toolbarConfig?.preset as DragState["preset"];
+ logger.info(
+ "DragState",
+ "Init user toolbar config",
+ preset,
+ toolbarConfig?.config
+ );
set({
//@ts-ignore
preset: preset,
- data: preset === 'custom' ? clone(toolbarConfig?.config) : clone(presets[preset]),
+ data:
+ preset === "custom"
+ ? clone(toolbarConfig?.config)
+ : clone(presets[preset]),
customPresetData:
- preset === 'custom' ? clone(toolbarConfig?.config) : clone(presets['custom'])
+ preset === "custom"
+ ? clone(toolbarConfig?.config)
+ : clone(presets["custom"])
});
}
}),
{
- name: 'drag-state-storage', // unique name
+ name: "drag-state-storage", // unique name
//@ts-ignore
getStorage: () => MMKV,
onRehydrateStorage: () => {
return () => {
- logger.info('DragState', 'rehydrated drag state', useNoteStore.getState().loading);
+ logger.info(
+ "DragState",
+ "rehydrated drag state",
+ useNoteStore.getState().loading
+ );
if (!useNoteStore.getState().loading) {
useDragState.getState().init();
} else {
diff --git a/apps/mobile/app/screens/settings/editor/tool-sheet.tsx b/apps/mobile/app/screens/settings/editor/tool-sheet.tsx
index 592350cf5..4b0b7df4a 100644
--- a/apps/mobile/app/screens/settings/editor/tool-sheet.tsx
+++ b/apps/mobile/app/screens/settings/editor/tool-sheet.tsx
@@ -1,16 +1,20 @@
-import { ToolId } from '@streetwriters/editor/dist/es/toolbar';
-import React, { RefObject } from 'react';
-import { View } from 'react-native';
-import ActionSheet from 'react-native-actions-sheet';
-import { ScrollView } from 'react-native-gesture-handler';
-import { PressableButton } from '../../../components/ui/pressable';
-import { SvgView } from '../../../components/ui/svg';
-import Paragraph from '../../../components/ui/typography/paragraph';
-import { presentSheet } from '../../../services/event-manager';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { SIZE } from '../../../utils/size';
-import { DraggableItem, useDragState } from './state';
-import { findToolById, getToolIcon, getUngroupedTools } from './toolbar-definition';
+import { ToolId } from "@streetwriters/editor/dist/es/toolbar";
+import React, { RefObject } from "react";
+import { View } from "react-native";
+import ActionSheet from "react-native-actions-sheet";
+import { ScrollView } from "react-native-gesture-handler";
+import { PressableButton } from "../../../components/ui/pressable";
+import { SvgView } from "../../../components/ui/svg";
+import Paragraph from "../../../components/ui/typography/paragraph";
+import { presentSheet } from "../../../services/event-manager";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { SIZE } from "../../../utils/size";
+import { DraggableItem, useDragState } from "./state";
+import {
+ findToolById,
+ getToolIcon,
+ getUngroupedTools
+} from "./toolbar-definition";
export default function ToolSheet({
group,
@@ -19,8 +23,8 @@ export default function ToolSheet({
group: DraggableItem;
fwdRef: RefObject<ActionSheet>;
}) {
- const colors = useThemeStore(state => state.colors);
- const data = useDragState(state => state.data);
+ const colors = useThemeStore((state) => state.colors);
+ const data = useDragState((state) => state.data);
const ungrouped = getUngroupedTools(data) as ToolId[];
const renderTool = React.useCallback((item: ToolId) => {
@@ -44,23 +48,25 @@ export default function ToolSheet({
}}
customStyle={{
marginBottom: 10,
- width: '100%',
+ width: "100%",
height: 50,
paddingHorizontal: 12,
paddingRight: 0,
borderRadius: 5,
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'flex-start'
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "flex-start"
}}
>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
- {iconSvgString ? <SvgView width={23} height={23} src={iconSvgString} /> : null}
+ {iconSvgString ? (
+ <SvgView width={23} height={23} src={iconSvgString} />
+ ) : null}
<Paragraph
style={{
marginLeft: iconSvgString ? 10 : 0
@@ -78,7 +84,7 @@ export default function ToolSheet({
return (
<View
style={{
- maxHeight: '100%',
+ maxHeight: "100%",
padding: 12
}}
>
@@ -91,7 +97,7 @@ export default function ToolSheet({
{!ungrouped || ungrouped.length === 0 ? (
<Paragraph
style={{
- alignSelf: 'center'
+ alignSelf: "center"
}}
color={colors.icon}
>
@@ -112,6 +118,6 @@ export default function ToolSheet({
ToolSheet.present = (payload: DraggableItem) => {
presentSheet({
- component: ref => <ToolSheet fwdRef={ref} group={payload} />
+ component: (ref) => <ToolSheet fwdRef={ref} group={payload} />
});
};
diff --git a/apps/mobile/app/screens/settings/editor/tool.tsx b/apps/mobile/app/screens/settings/editor/tool.tsx
index 9f0fb3dd2..f06a5f2a6 100644
--- a/apps/mobile/app/screens/settings/editor/tool.tsx
+++ b/apps/mobile/app/screens/settings/editor/tool.tsx
@@ -1,31 +1,39 @@
-import * as React from 'react';
-import { View } from 'react-native';
-import { DraxDragWithReceiverEventData, DraxView } from 'react-native-drax';
-import Animated, { Layout } from 'react-native-reanimated';
-import { presentDialog } from '../../../components/dialog/functions';
-import { IconButton } from '../../../components/ui/icon-button';
-import { SvgView } from '../../../components/ui/svg';
-import Paragraph from '../../../components/ui/typography/paragraph';
-import { useThemeStore } from '../../../stores/use-theme-store';
-import { getElevation } from '../../../utils';
-import { SIZE } from '../../../utils/size';
-import { renderGroup } from './common';
-import { DraggableItem, useDragState } from './state';
-import { findToolById, getToolIcon } from './toolbar-definition';
-import ToolSheet from './tool-sheet';
+import * as React from "react";
+import { View } from "react-native";
+import { DraxDragWithReceiverEventData, DraxView } from "react-native-drax";
+import Animated, { Layout } from "react-native-reanimated";
+import { presentDialog } from "../../../components/dialog/functions";
+import { IconButton } from "../../../components/ui/icon-button";
+import { SvgView } from "../../../components/ui/svg";
+import Paragraph from "../../../components/ui/typography/paragraph";
+import { useThemeStore } from "../../../stores/use-theme-store";
+import { getElevation } from "../../../utils";
+import { SIZE } from "../../../utils/size";
+import { renderGroup } from "./common";
+import { DraggableItem, useDragState } from "./state";
+import { findToolById, getToolIcon } from "./toolbar-definition";
+import ToolSheet from "./tool-sheet";
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) => {
- const setData = useDragState(state => state.setData);
- const [dragged, setDragged] = useDragState(state => [state.dragged, state.setDragged]);
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+export const Tool = ({
+ item,
+ index,
+ groupIndex,
+ parentIndex
+}: DraggableItem) => {
+ const setData = useDragState((state) => state.setData);
+ const [dragged, setDragged] = useDragState((state) => [
+ state.dragged,
+ state.setDragged
+ ]);
const [recieving, setRecieving] = React.useState(false);
- const [recievePosition, setRecievePosition] = React.useState('above');
- const colors = useThemeStore(state => state.colors);
- const isSubgroup = typeof item === 'object';
+ const [recievePosition, setRecievePosition] = React.useState("above");
+ const colors = useThemeStore((state) => state.colors);
+ const isSubgroup = typeof item === "object";
const isDragged =
dragged &&
dragged.item &&
- ((dragged.type === 'tool' && dragged?.item === item) ||
+ ((dragged.type === "tool" && dragged?.item === item) ||
(isSubgroup && dragged?.item[0] === item[0]));
const dimensions = React.useRef({
@@ -33,22 +41,23 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
width: 0
});
//@ts-ignore
- const tool = isSubgroup || item === 'dummy' ? null : findToolById(item);
+ const tool = isSubgroup || item === "dummy" ? null : findToolById(item);
//@ts-ignore
const iconSvgString = isSubgroup || !tool ? null : getToolIcon(tool.icon);
const buttons = isSubgroup
? [
{
- name: 'minus',
+ name: "minus",
onPress: () => {
presentDialog({
- context: 'global',
- title: 'Delete collapsed section?',
- positiveText: 'Delete',
- paragraph: 'All tools in the collapsed section will also be removed.',
+ context: "global",
+ title: "Delete collapsed section?",
+ positiveText: "Delete",
+ paragraph:
+ "All tools in the collapsed section will also be removed.",
positivePress: () => {
- if (typeof groupIndex !== 'number') return;
+ if (typeof groupIndex !== "number") return;
const _data = useDragState.getState().data.slice();
_data[groupIndex].splice(index, 1);
setData(_data);
@@ -57,7 +66,7 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
}
},
{
- name: 'plus',
+ name: "plus",
onPress: () => {
ToolSheet.present({
item,
@@ -70,16 +79,20 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
]
: [
{
- name: 'minus',
+ name: "minus",
onPress: () => {
- if (typeof groupIndex !== 'number') return;
+ if (typeof groupIndex !== "number") return;
const _data = useDragState.getState().data.slice();
- if (typeof parentIndex !== 'number') {
- const index = _data[groupIndex].findIndex(tool => tool === item);
+ if (typeof parentIndex !== "number") {
+ const index = _data[groupIndex].findIndex(
+ (tool) => tool === item
+ );
_data[groupIndex].splice(index, 1);
} else {
//@ts-ignore
- const index = _data[parentIndex][groupIndex].findIndex(tool => tool === item);
+ const index = _data[parentIndex][groupIndex].findIndex(
+ (tool) => tool === item
+ );
//@ts-ignore
_data[parentIndex][groupIndex].splice(index, 1);
}
@@ -91,14 +104,18 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
if (parentIndex === undefined && !isSubgroup) {
buttons.unshift({
- name: 'unfold-less-horizontal',
+ name: "unfold-less-horizontal",
onPress: () => {
if (groupIndex === undefined) return;
const _data = useDragState.getState().data.slice();
- const hasSubGroup = Array.isArray(_data[groupIndex][_data[groupIndex].length - 1]);
+ const hasSubGroup = Array.isArray(
+ _data[groupIndex][_data[groupIndex].length - 1]
+ );
const _item = _data[groupIndex].splice(index, 1)[0];
if (hasSubGroup) {
- const subgroup = _data[groupIndex][_data[groupIndex].length - 1] as string[];
+ const subgroup = _data[groupIndex][
+ _data[groupIndex].length - 1
+ ] as string[];
//@ts-ignore
subgroup.unshift(_item);
} else {
@@ -116,7 +133,7 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
(hover?: boolean) => (
<>
<View
- onLayout={event => {
+ onLayout={(event) => {
if (hover) return;
if (!isDragged) dimensions.current = event.nativeEvent.layout;
}}
@@ -125,30 +142,35 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
borderWidth: isSubgroup ? 0 : 1,
borderColor: isSubgroup ? undefined : colors.nav,
marginBottom: 10,
- width: isDragged ? dimensions.current.width : '100%',
+ width: isDragged ? dimensions.current.width : "100%",
paddingTop: isSubgroup ? 15 : 0,
height: 40,
paddingHorizontal: isSubgroup ? 0 : 12,
paddingRight: 0,
borderRadius: 5,
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'space-between',
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "space-between",
paddingLeft: isSubgroup ? 30 : 12,
...getElevation(hover ? 3 : 0)
}}
>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
{!isSubgroup && iconSvgString ? (
<SvgView width={23} height={23} src={iconSvgString} />
) : null}
{isSubgroup && (
- <Icon style={{ marginRight: 5 }} size={SIZE.md} name="drag" color={colors.icon} />
+ <Icon
+ style={{ marginRight: 5 }}
+ size={SIZE.md}
+ name="drag"
+ color={colors.icon}
+ />
)}
<Paragraph
style={{
@@ -157,17 +179,17 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
color={isSubgroup ? colors.icon : colors.pri}
size={isSubgroup ? SIZE.xs : SIZE.sm - 1}
>
- {isSubgroup ? 'COLLAPSED' : tool?.title}
+ {isSubgroup ? "COLLAPSED" : tool?.title}
</Paragraph>
</View>
<View
style={{
- flexDirection: 'row',
- alignItems: 'center'
+ flexDirection: "row",
+ alignItems: "center"
}}
>
- {buttons.map(item => (
+ {buttons.map((item) => (
<IconButton
top={0}
left={0}
@@ -206,14 +228,16 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
const reciever = data.receiver.payload;
let _data = useDragState.getState().data.slice();
- const isFromSubgroup = typeof dragged.parentIndex === 'number';
- const isDroppedAtSubgroup = typeof reciever.parentIndex === 'number';
+ const isFromSubgroup = typeof dragged.parentIndex === "number";
+ const isDroppedAtSubgroup = typeof reciever.parentIndex === "number";
- if (dragged.type === 'tool') {
+ if (dragged.type === "tool") {
const fromIndex = dragged.index;
- const toIndex = isDroppedAbove ? Math.max(0, reciever.index) : reciever.index + 1;
+ const toIndex = isDroppedAbove
+ ? Math.max(0, reciever.index)
+ : reciever.index + 1;
- console.log('indexes', reciever.parentIndex, reciever.groupIndex);
+ console.log("indexes", reciever.parentIndex, reciever.groupIndex);
const insertAt = isDroppedAtSubgroup
? (_data[reciever.parentIndex][reciever.groupIndex] as string[])
@@ -230,7 +254,10 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
// Remove the group or subgroup if it is empty.
if (insertFrom.length === 0) {
isFromSubgroup
- ? _data[dragged.parentIndex].splice(_data[dragged.parentIndex].length - 1, 1)
+ ? _data[dragged.parentIndex].splice(
+ _data[dragged.parentIndex].length - 1,
+ 1
+ )
: _data.splice(dragged.groupIndex, 1);
}
}
@@ -243,9 +270,9 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
const onRecieveData = (data: DraxDragWithReceiverEventData) => {
setRecieving(true);
if (data.receiver.receiveOffsetRatio.y < 0.5) {
- setRecievePosition('above');
+ setRecievePosition("above");
} else {
- setRecievePosition('below');
+ setRecievePosition("below");
}
};
@@ -256,14 +283,14 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
item,
index,
groupIndex,
- type: isSubgroup ? 'subgroup' : 'tool',
+ type: isSubgroup ? "subgroup" : "tool",
parentIndex
}}
receptive={
- dragged.type === 'group' ||
- (dragged.type !== 'tool' && isSubgroup) ||
- (dragged.type === 'tool' && isSubgroup) ||
- (!isSubgroup && dragged.type === 'subgroup') ||
+ dragged.type === "group" ||
+ (dragged.type !== "tool" && isSubgroup) ||
+ (dragged.type === "tool" && isSubgroup) ||
+ (!isSubgroup && dragged.type === "subgroup") ||
(dragged.item && dragged.item?.indexOf(item as string) > -1)
? false
: true
@@ -272,25 +299,25 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
onDragStart={() => {
setDragged({
item,
- type: isSubgroup ? 'subgroup' : 'tool',
+ type: isSubgroup ? "subgroup" : "tool",
...dimensions.current,
groupIndex: groupIndex
});
}}
receivingStyle={{
- paddingBottom: recievePosition === 'below' ? 50 : 0,
- paddingTop: recievePosition === 'above' ? 50 : 0,
- backgroundColor: dragged.type === 'subgroup' ? colors.nav : undefined,
- marginTop: recievePosition === 'above' ? 5 : 0,
- marginBottom: recievePosition === 'below' ? 5 : 0,
+ paddingBottom: recievePosition === "below" ? 50 : 0,
+ paddingTop: recievePosition === "above" ? 50 : 0,
+ backgroundColor: dragged.type === "subgroup" ? colors.nav : undefined,
+ marginTop: recievePosition === "above" ? 5 : 0,
+ marginBottom: recievePosition === "below" ? 5 : 0,
borderRadius: 10
}}
renderHoverContent={() => renderChild(true)}
- draggable={item !== 'dummy'}
- onDragDrop={data => {
+ draggable={item !== "dummy"}
+ onDragDrop={(data) => {
setDragged({});
}}
- onDragEnd={data => {
+ onDragEnd={(data) => {
setDragged({});
}}
hoverDragReleasedStyle={{
@@ -303,11 +330,11 @@ export const Tool = ({ item, index, groupIndex, parentIndex }: DraggableItem) =>
}}
onReceiveDragEnter={onRecieveData}
>
- {isDragged || item === 'dummy' ? (
+ {isDragged || item === "dummy" ? (
<View
style={{
- width: '100%',
- height: item === 'dummy' ? 10 : 0
+ width: "100%",
+ height: item === "dummy" ? 10 : 0
}}
/>
) : (
diff --git a/apps/mobile/app/screens/settings/editor/toolbar-definition.ts b/apps/mobile/app/screens/settings/editor/toolbar-definition.ts
index 66500ded5..07dad8e91 100644
--- a/apps/mobile/app/screens/settings/editor/toolbar-definition.ts
+++ b/apps/mobile/app/screens/settings/editor/toolbar-definition.ts
@@ -1,11 +1,11 @@
-import { Icons } from '@streetwriters/editor/dist/es/toolbar/icons';
+import { Icons } from "@streetwriters/editor/dist/es/toolbar/icons";
import {
getDefaultPresets,
getAllTools
-} from '@streetwriters/editor/dist/es/toolbar/tooldefinitions';
-import { ToolId } from '@streetwriters/editor/dist/es/toolbar/tools';
-import { ToolbarGroupDefinition } from '@streetwriters/editor/dist/es/toolbar/index';
-import { useThemeStore } from '../../../stores/use-theme-store';
+} from "@streetwriters/editor/dist/es/toolbar/tooldefinitions";
+import { ToolId } from "@streetwriters/editor/dist/es/toolbar/tools";
+import { ToolbarGroupDefinition } from "@streetwriters/editor/dist/es/toolbar/index";
+import { useThemeStore } from "../../../stores/use-theme-store";
export const tools = getAllTools();
export const presets: { [name: string]: ToolbarGroupDefinition[] } = {
@@ -14,7 +14,10 @@ export const presets: { [name: string]: ToolbarGroupDefinition[] } = {
custom: []
};
-export function findToolById(id: keyof typeof tools): { title: string; icon: string } {
+export function findToolById(id: keyof typeof tools): {
+ title: string;
+ icon: string;
+} {
return tools[id];
}
@@ -23,14 +26,16 @@ export function getToolIcon(id: keyof typeof tools) {
const icon = Icons[id];
const colors = useThemeStore.getState().colors;
//@ts-ignore
- return id === 'none'
+ return id === "none"
? null
: `<svg width="20" height="20" >
<path d="${icon}" fill="${colors.icon}" />
</svg>`;
}
-export function getUngroupedTools(toolDefinition: (string | string[])[][]): string[] {
+export function getUngroupedTools(
+ toolDefinition: (string | string[])[][]
+): string[] {
let keys = Object.keys(tools);
console.log(keys);
const ungrouped = [];
diff --git a/apps/mobile/app/screens/settings/functions.js b/apps/mobile/app/screens/settings/functions.js
index 597b6aa07..7dc58b930 100644
--- a/apps/mobile/app/screens/settings/functions.js
+++ b/apps/mobile/app/screens/settings/functions.js
@@ -1,21 +1,27 @@
-import { presentDialog } from '../../components/dialog/functions';
-import { ToastEvent } from '../../services/event-manager';
-import { db } from '../../common/database';
-import { sleep } from '../../utils/time';
+import { presentDialog } from "../../components/dialog/functions";
+import { ToastEvent } from "../../services/event-manager";
+import { db } from "../../common/database";
+import { sleep } from "../../utils/time";
-export async function verifyUser(context, onsuccess, disableBackdropClosing, onclose, closeText) {
+export async function verifyUser(
+ context,
+ onsuccess,
+ disableBackdropClosing,
+ onclose,
+ closeText
+) {
presentDialog({
context: context,
title: "Verify it's you",
input: true,
- inputPlaceholder: 'Enter account password',
- paragraph: 'Please enter your account password',
- positiveText: 'Verify',
+ inputPlaceholder: "Enter account password",
+ paragraph: "Please enter your account password",
+ positiveText: "Verify",
secureTextEntry: true,
disableBackdropClosing: disableBackdropClosing,
onClose: onclose,
- negativeText: closeText || 'Cancel',
- positivePress: async value => {
+ negativeText: closeText || "Cancel",
+ positivePress: async (value) => {
try {
let verified = await db.user.verifyPassword(value);
if (verified) {
@@ -24,19 +30,19 @@ export async function verifyUser(context, onsuccess, disableBackdropClosing, onc
});
} else {
ToastEvent.show({
- heading: 'Incorrect password',
- message: 'The account password you entered is incorrect',
- type: 'error',
- context: 'global'
+ heading: "Incorrect password",
+ message: "The account password you entered is incorrect",
+ type: "error",
+ context: "global"
});
return false;
}
} catch (e) {
ToastEvent.show({
- heading: 'Failed to backup data',
+ heading: "Failed to backup data",
message: e.message,
- type: 'error',
- context: 'global'
+ type: "error",
+ context: "global"
});
return false;
}
diff --git a/apps/mobile/app/screens/settings/group.tsx b/apps/mobile/app/screens/settings/group.tsx
index b88227386..79f2ae411 100644
--- a/apps/mobile/app/screens/settings/group.tsx
+++ b/apps/mobile/app/screens/settings/group.tsx
@@ -1,25 +1,32 @@
-import { NativeStackScreenProps } from '@react-navigation/native-stack';
-import React, { useEffect } from 'react';
-import { FlatList, View } from 'react-native';
-import Animated, { FadeInDown, FadeOut, FadeOutDown } from 'react-native-reanimated';
-import DelayLayout from '../../components/delay-layout';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { tabBarRef } from '../../utils/global-refs';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
-import { components } from './components';
-import { SectionItem } from './section-item';
-import { RouteParams, SettingSection } from './types';
+import { NativeStackScreenProps } from "@react-navigation/native-stack";
+import React, { useEffect } from "react";
+import { FlatList, View } from "react-native";
+import Animated, {
+ FadeInDown,
+ FadeOut,
+ FadeOutDown
+} from "react-native-reanimated";
+import DelayLayout from "../../components/delay-layout";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { tabBarRef } from "../../utils/global-refs";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
+import { components } from "./components";
+import { SectionItem } from "./section-item";
+import { RouteParams, SettingSection } from "./types";
const keyExtractor = (item: SettingSection, index: number) => item.id;
-const Group = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'SettingsGroup'>) => {
+const Group = ({
+ navigation,
+ route
+}: NativeStackScreenProps<RouteParams, "SettingsGroup">) => {
useNavigationFocus(navigation, {
onFocus: () => {
tabBarRef.current?.lock();
- console.log('called');
+ console.log("called");
useNavigationStore.getState().update(
{
- name: 'SettingsGroup',
+ name: "SettingsGroup",
//@ts-ignore
title: route.params.name
},
@@ -33,9 +40,13 @@ const Group = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'Setti
tabBarRef.current?.unlock();
};
}, []);
- const renderItem = ({ item, index }: { item: SettingSection; index: number }) => (
- <SectionItem item={item} />
- );
+ const renderItem = ({
+ item,
+ index
+ }: {
+ item: SettingSection;
+ index: number;
+ }) => <SectionItem item={item} />;
return (
<DelayLayout type="settings" delay={300}>
diff --git a/apps/mobile/app/screens/settings/home.tsx b/apps/mobile/app/screens/settings/home.tsx
index 9e6c1cfe7..3a649bcff 100644
--- a/apps/mobile/app/screens/settings/home.tsx
+++ b/apps/mobile/app/screens/settings/home.tsx
@@ -1,45 +1,61 @@
-import { NativeStackScreenProps } from '@react-navigation/native-stack';
-import React, { useEffect, useRef, useState } from 'react';
-import { FlatList, View } from 'react-native';
-import Animated, { FadeInDown, FadeOutDown } from 'react-native-reanimated';
-import DelayLayout from '../../components/delay-layout';
-import BaseDialog from '../../components/dialog/base-dialog';
-import { ProgressBarComponent } from '../../components/ui/svg/lazy';
-import Heading from '../../components/ui/typography/heading';
-import Paragraph from '../../components/ui/typography/paragraph';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../../services/event-manager';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
-import { SIZE } from '../../utils/size';
-import { SectionGroup } from './section-group';
-import { settingsGroups } from './settings-data';
-import { RouteParams, SettingSection } from './types';
-import SettingsUserSection from './user-section';
+import { NativeStackScreenProps } from "@react-navigation/native-stack";
+import React, { useEffect, useRef, useState } from "react";
+import { FlatList, View } from "react-native";
+import Animated, { FadeInDown, FadeOutDown } from "react-native-reanimated";
+import DelayLayout from "../../components/delay-layout";
+import BaseDialog from "../../components/dialog/base-dialog";
+import { ProgressBarComponent } from "../../components/ui/svg/lazy";
+import Heading from "../../components/ui/typography/heading";
+import Paragraph from "../../components/ui/typography/paragraph";
+import {
+ eSubscribeEvent,
+ eUnSubscribeEvent
+} from "../../services/event-manager";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
+import { SIZE } from "../../utils/size";
+import { SectionGroup } from "./section-group";
+import { settingsGroups } from "./settings-data";
+import { RouteParams, SettingSection } from "./types";
+import SettingsUserSection from "./user-section";
const keyExtractor = (item: SettingSection, index: number) => item.id;
-const Home = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'SettingsHome'>) => {
- const colors = useThemeStore(state => state.colors);
+const Home = ({
+ navigation,
+ route
+}: NativeStackScreenProps<RouteParams, "SettingsHome">) => {
+ const colors = useThemeStore((state) => state.colors);
const [loading, setLoading] = useState(false);
useNavigationFocus(navigation, {
onFocus: () => {
useNavigationStore.getState().update({
- name: 'Settings'
+ name: "Settings"
});
return false;
},
focusOnInit: true
});
- const renderItem = ({ item, index }: { item: SettingSection; index: number }) =>
- item.name === 'account' ? <SettingsUserSection item={item} /> : <SectionGroup item={item} />;
+ const renderItem = ({
+ item,
+ index
+ }: {
+ item: SettingSection;
+ index: number;
+ }) =>
+ item.name === "account" ? (
+ <SettingsUserSection item={item} />
+ ) : (
+ <SectionGroup item={item} />
+ );
useEffect(() => {
- eSubscribeEvent('settings-loading', setLoading);
+ eSubscribeEvent("settings-loading", setLoading);
return () => {
- eUnSubscribeEvent('settings-loading', setLoading);
+ eUnSubscribeEvent("settings-loading", setLoading);
};
}, []);
@@ -51,11 +67,11 @@ const Home = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'Settin
<BaseDialog animated={false} bounce={false} visible={true}>
<View
style={{
- width: '100%',
- height: '100%',
+ width: "100%",
+ height: "100%",
backgroundColor: colors.bg,
- justifyContent: 'center',
- alignItems: 'center'
+ justifyContent: "center",
+ alignItems: "center"
}}
>
<Heading color={colors.pri} size={SIZE.lg}>
@@ -66,7 +82,7 @@ const Home = ({ navigation, route }: NativeStackScreenProps<RouteParams, 'Settin
</Paragraph>
<View
style={{
- flexDirection: 'row',
+ flexDirection: "row",
width: 100,
marginTop: 15
}}
diff --git a/apps/mobile/app/screens/settings/index.tsx b/apps/mobile/app/screens/settings/index.tsx
index cf40a88be..824e8c0eb 100644
--- a/apps/mobile/app/screens/settings/index.tsx
+++ b/apps/mobile/app/screens/settings/index.tsx
@@ -1,19 +1,22 @@
-import { createNativeStackNavigator, NativeStackScreenProps } from '@react-navigation/native-stack';
-import React from 'react';
-import DelayLayout from '../../components/delay-layout';
-import { Header } from '../../components/header';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import Group from './group';
-import Home from './home';
-import { RouteParams } from './types';
+import {
+ createNativeStackNavigator,
+ NativeStackScreenProps
+} from "@react-navigation/native-stack";
+import React from "react";
+import DelayLayout from "../../components/delay-layout";
+import { Header } from "../../components/header";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import Group from "./group";
+import Home from "./home";
+import { RouteParams } from "./types";
const SettingsStack = createNativeStackNavigator();
const screenListeners = {
//@ts-ignore
- beforeRemove: e => {
- if (e.target?.startsWith('SettingsGroup')) {
- useNavigationStore.getState().update({ name: 'Settings' }, false);
+ beforeRemove: (e) => {
+ if (e.target?.startsWith("SettingsGroup")) {
+ useNavigationStore.getState().update({ name: "Settings" }, false);
}
}
};
@@ -47,13 +50,13 @@ const screenListeners = {
// };
export const Settings = () => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
return (
<SettingsStack.Navigator
initialRouteName="SettingsHome"
screenListeners={screenListeners}
screenOptions={{
- animation: 'none',
+ animation: "none",
headerShown: false,
contentStyle: {
backgroundColor: colors.bg
diff --git a/apps/mobile/app/screens/settings/section-group.tsx b/apps/mobile/app/screens/settings/section-group.tsx
index 041d708c5..de5a6c428 100644
--- a/apps/mobile/app/screens/settings/section-group.tsx
+++ b/apps/mobile/app/screens/settings/section-group.tsx
@@ -1,13 +1,13 @@
-import React from 'react';
-import { View } from 'react-native';
-import Heading from '../../components/ui/typography/heading';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import { SectionItem } from './section-item';
-import { SettingSection } from './types';
+import React from "react";
+import { View } from "react-native";
+import Heading from "../../components/ui/typography/heading";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import { SectionItem } from "./section-item";
+import { SettingSection } from "./types";
export const SectionGroup = ({ item }: { item: SettingSection }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
const current = item.useHook && item.useHook();
const isHidden = item.hidden && item.hidden(current);
return isHidden ? null : (
@@ -28,7 +28,7 @@ export const SectionGroup = ({ item }: { item: SettingSection }) => {
</Heading>
) : null}
- {item.sections?.map(item => (
+ {item.sections?.map((item) => (
<SectionItem key={item.name} item={item} />
))}
</View>
diff --git a/apps/mobile/app/screens/settings/section-item.tsx b/apps/mobile/app/screens/settings/section-item.tsx
index 439a2119a..82b06d3fe 100644
--- a/apps/mobile/app/screens/settings/section-item.tsx
+++ b/apps/mobile/app/screens/settings/section-item.tsx
@@ -1,23 +1,27 @@
-import { NavigationProp, StackActions, useNavigation } from '@react-navigation/native';
-import React from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import ToggleSwitch from 'toggle-switch-react-native';
-import { PressableButton } from '../../components/ui/pressable';
-import Seperator from '../../components/ui/seperator';
-import Paragraph from '../../components/ui/typography/paragraph';
-import SettingsService from '../../services/settings';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SIZE } from '../../utils/size';
-import { components } from './components';
-import { RouteParams, SettingSection } from './types';
+import {
+ NavigationProp,
+ StackActions,
+ useNavigation
+} from "@react-navigation/native";
+import React from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import ToggleSwitch from "toggle-switch-react-native";
+import { PressableButton } from "../../components/ui/pressable";
+import Seperator from "../../components/ui/seperator";
+import Paragraph from "../../components/ui/typography/paragraph";
+import SettingsService from "../../services/settings";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SIZE } from "../../utils/size";
+import { components } from "./components";
+import { RouteParams, SettingSection } from "./types";
export const SectionItem = React.memo(
({ item }: { item: SettingSection }) => {
- const colors = useThemeStore(state => state.colors);
- const settings = useSettingStore(state => state.settings);
+ const colors = useThemeStore((state) => state.colors);
+ const settings = useSettingStore((state) => state.settings);
const navigation = useNavigation<NavigationProp<RouteParams>>();
const current = item.useHook && item.useHook(item);
const isHidden = item.hidden && item.hidden(item.property || current);
@@ -36,7 +40,7 @@ export const SectionItem = React.memo(
};
const styles =
- item.type === 'danger'
+ item.type === "danger"
? {
backgroundColor: colors.errorBg
}
@@ -44,29 +48,32 @@ export const SectionItem = React.memo(
return isHidden ? null : (
<PressableButton
- disabled={item.type === 'component'}
+ disabled={item.type === "component"}
customStyle={{
- width: '100%',
- alignItems: 'center',
+ width: "100%",
+ alignItems: "center",
padding: 12,
- flexDirection: 'row',
- justifyContent: 'space-between',
+ flexDirection: "row",
+ justifyContent: "space-between",
paddingVertical: 20,
...styles
}}
onPress={() => {
switch (item.type) {
- case 'screen':
- navigation.dispatch(StackActions.push('SettingsGroup', item));
+ case "screen":
+ navigation.dispatch(StackActions.push("SettingsGroup", item));
useNavigationStore.getState().update(
{
- name: 'SettingsGroup',
- title: typeof item.name === 'function' ? item.name(current) : item.name
+ name: "SettingsGroup",
+ title:
+ typeof item.name === "function"
+ ? item.name(current)
+ : item.name
},
true
);
break;
- case 'switch':
+ case "switch":
onChangeSettings();
break;
default:
@@ -77,7 +84,7 @@ export const SectionItem = React.memo(
>
<View
style={{
- flexDirection: 'row',
+ flexDirection: "row",
flexShrink: 1
}}
>
@@ -85,16 +92,17 @@ export const SectionItem = React.memo(
style={{
width: 40,
height: 40,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
marginRight: 12,
- backgroundColor: item.component === 'colorpicker' ? colors.accent : undefined,
+ backgroundColor:
+ item.component === "colorpicker" ? colors.accent : undefined,
borderRadius: 100
}}
>
{!!item.icon && (
<Icon
- color={item.type === 'danger' ? colors.errorText : colors.icon}
+ color={item.type === "danger" ? colors.errorText : colors.icon}
name={item.icon}
size={30}
/>
@@ -104,27 +112,27 @@ export const SectionItem = React.memo(
<View
style={{
flexShrink: 1,
- paddingRight: item.type === 'switch' ? 10 : 0
+ paddingRight: item.type === "switch" ? 10 : 0
}}
>
<Paragraph
- color={item.type === 'danger' ? colors.errorText : colors.heading}
+ color={item.type === "danger" ? colors.errorText : colors.heading}
size={SIZE.md + 1}
>
- {typeof item.name === 'function' ? item.name(current) : item.name}
+ {typeof item.name === "function" ? item.name(current) : item.name}
</Paragraph>
{!!item.description && (
<Paragraph
- color={item.type === 'danger' ? colors.errorText : colors.pri}
+ color={item.type === "danger" ? colors.errorText : colors.pri}
size={SIZE.sm}
>
- {typeof item.description === 'function'
+ {typeof item.description === "function"
? item.description(current)
: item.description}
</Paragraph>
)}
- {!!item.component && item.type !== 'screen' && (
+ {!!item.component && item.type !== "screen" && (
<>
<Seperator half />
{components[item.component]}
@@ -133,10 +141,14 @@ export const SectionItem = React.memo(
</View>
</View>
- {item.type === 'switch' && item.property && (
+ {item.type === "switch" && item.property && (
<ToggleSwitch
//@ts-ignore
- isOn={item.getter ? item.getter(item.property || current) : settings[item.property]}
+ isOn={
+ item.getter
+ ? item.getter(item.property || current)
+ : settings[item.property]
+ }
onColor={colors.accent}
offColor={colors.icon}
size="small"
diff --git a/apps/mobile/app/screens/settings/settings-data.tsx b/apps/mobile/app/screens/settings/settings-data.tsx
index 18260e2f6..7c748796c 100644
--- a/apps/mobile/app/screens/settings/settings-data.tsx
+++ b/apps/mobile/app/screens/settings/settings-data.tsx
@@ -1,31 +1,36 @@
-import dayjs from 'dayjs';
-import React from 'react';
-import { Linking, Platform } from 'react-native';
-import * as RNIap from 'react-native-iap';
-import { enabled } from 'react-native-privacy-snapshot';
-import { APP_VERSION } from '../../version';
-import { ChangePassword } from '../../components/auth/change-password';
-import { presentDialog } from '../../components/dialog/functions';
-import { Issue } from '../../components/sheets/github/issue';
-import { Progress } from '../../components/sheets/progress';
-import { Update } from '../../components/sheets/update';
-import BackupService from '../../services/backup';
-import BiometicService from '../../services/biometrics';
-import { eSendEvent, openVault, presentSheet, ToastEvent } from '../../services/event-manager';
-import { setLoginMessage } from '../../services/message';
-import Navigation from '../../services/navigation';
-import Notifications from '../../services/notifications';
-import PremiumService from '../../services/premium';
-import SettingsService from '../../services/settings';
-import Sync from '../../services/sync';
-import { clearAllStores } from '../../stores';
-import { useSettingStore } from '../../stores/use-setting-store';
-import { useUserStore } from '../../stores/use-user-store';
-import { AndroidModule } from '../../utils';
-import { getColorScheme, toggleDarkMode } from '../../utils/color-scheme/utils';
-import { SUBSCRIPTION_STATUS } from '../../utils/constants';
-import { db } from '../../common/database';
-import { MMKV } from '../../common/database/mmkv';
+import dayjs from "dayjs";
+import React from "react";
+import { Linking, Platform } from "react-native";
+import * as RNIap from "react-native-iap";
+import { enabled } from "react-native-privacy-snapshot";
+import { APP_VERSION } from "../../version";
+import { ChangePassword } from "../../components/auth/change-password";
+import { presentDialog } from "../../components/dialog/functions";
+import { Issue } from "../../components/sheets/github/issue";
+import { Progress } from "../../components/sheets/progress";
+import { Update } from "../../components/sheets/update";
+import BackupService from "../../services/backup";
+import BiometicService from "../../services/biometrics";
+import {
+ eSendEvent,
+ openVault,
+ presentSheet,
+ ToastEvent
+} from "../../services/event-manager";
+import { setLoginMessage } from "../../services/message";
+import Navigation from "../../services/navigation";
+import Notifications from "../../services/notifications";
+import PremiumService from "../../services/premium";
+import SettingsService from "../../services/settings";
+import Sync from "../../services/sync";
+import { clearAllStores } from "../../stores";
+import { useSettingStore } from "../../stores/use-setting-store";
+import { useUserStore } from "../../stores/use-user-store";
+import { AndroidModule } from "../../utils";
+import { getColorScheme, toggleDarkMode } from "../../utils/color-scheme/utils";
+import { SUBSCRIPTION_STATUS } from "../../utils/constants";
+import { db } from "../../common/database";
+import { MMKV } from "../../common/database/mmkv";
import {
eCloseProgressDialog,
eCloseSimpleDialog,
@@ -33,231 +38,242 @@ import {
eOpenLoginDialog,
eOpenRecoveryKeyDialog,
eOpenRestoreDialog
-} from '../../utils/events';
-import { useVaultStatus } from '../../hooks/use-vault-status';
-import { sleep } from '../../utils/time';
-import { MFARecoveryCodes, MFASheet } from './2fa';
-import AppLock from './app-lock';
-import { useDragState } from './editor/state';
-import { verifyUser } from './functions';
-import { SettingSection } from './types';
-import { getTimeLeft } from './user-section';
+} from "../../utils/events";
+import { useVaultStatus } from "../../hooks/use-vault-status";
+import { sleep } from "../../utils/time";
+import { MFARecoveryCodes, MFASheet } from "./2fa";
+import AppLock from "./app-lock";
+import { useDragState } from "./editor/state";
+import { verifyUser } from "./functions";
+import { SettingSection } from "./types";
+import { getTimeLeft } from "./user-section";
const format = (ver: number) => {
- let parts = ver.toString().split('');
- return `v${parts[0]}.${parts[1]}.${parts[2]?.startsWith('0') ? '' : parts[2]}${
- !parts[3] ? '' : parts[3]
- } `;
+ let parts = ver.toString().split("");
+ return `v${parts[0]}.${parts[1]}.${
+ parts[2]?.startsWith("0") ? "" : parts[2]
+ }${!parts[3] ? "" : parts[3]} `;
};
export const settingsGroups: SettingSection[] = [
{
- id: 'account',
- name: 'account',
- useHook: () => useUserStore(state => state.user),
- hidden: current => !current,
+ id: "account",
+ name: "account",
+ useHook: () => useUserStore((state) => state.user),
+ hidden: (current) => !current,
sections: [
{
- id: 'subscription-status',
- useHook: () => useUserStore(state => state.user),
- hidden: current => !current,
- name: current => {
+ id: "subscription-status",
+ useHook: () => useUserStore((state) => state.user),
+ hidden: (current) => !current,
+ name: (current) => {
const user = current;
const isBasic = user.subscription?.type === SUBSCRIPTION_STATUS.BASIC;
const isTrial = user.subscription?.type === SUBSCRIPTION_STATUS.TRIAL;
return isBasic
- ? 'Subscribe to Pro'
+ ? "Subscribe to Pro"
: isTrial
- ? 'Your free trial has started'
- : 'Subscription details';
+ ? "Your free trial has started"
+ : "Subscription details";
},
- type: 'component',
- component: 'subscription',
- icon: 'crown',
- description: current => {
+ type: "component",
+ component: "subscription",
+ icon: "crown",
+ description: (current) => {
const user = current;
- const subscriptionDaysLeft = user && getTimeLeft(parseInt(user.subscription?.expiry));
- const expiryDate = dayjs(user?.subscription?.expiry).format('MMMM D, YYYY');
- const startDate = dayjs(user?.subscription?.start).format('MMMM D, YYYY');
+ const subscriptionDaysLeft =
+ user && getTimeLeft(parseInt(user.subscription?.expiry));
+ const expiryDate = dayjs(user?.subscription?.expiry).format(
+ "MMMM D, YYYY"
+ );
+ const startDate = dayjs(user?.subscription?.start).format(
+ "MMMM D, YYYY"
+ );
return user.subscription?.type === 2
- ? 'You signed up on ' + startDate
+ ? "You signed up on " + startDate
: user.subscription?.type === 1
- ? 'Your free trial will end on ' + expiryDate
+ ? "Your free trial will end on " + expiryDate
: user.subscription?.type === 6
? subscriptionDaysLeft.time < -3
- ? 'Your subscription has ended'
- : 'Your account will be downgraded to Basic in 3 days'
+ ? "Your subscription has ended"
+ : "Your account will be downgraded to Basic in 3 days"
: user.subscription?.type === 7
? `Your subscription will end on ${expiryDate}.`
: user.subscription?.type === 5
? `Your subscription will renew on ${expiryDate}.`
- : 'Never hesitate to choose privacy';
+ : "Never hesitate to choose privacy";
}
},
{
- id: 'account-settings',
- type: 'screen',
- name: 'Account Settings',
- icon: 'account-cog',
- description: 'Manage account',
+ id: "account-settings",
+ type: "screen",
+ name: "Account Settings",
+ icon: "account-cog",
+ description: "Manage account",
sections: [
{
- id: 'recovery-key',
- name: 'Save data recovery key',
+ id: "recovery-key",
+ name: "Save data recovery key",
modifer: async () => {
verifyUser(null, async () => {
await sleep(300);
eSendEvent(eOpenRecoveryKeyDialog);
});
},
- description: 'Recover your data using the recovery key if your password is lost.'
+ description:
+ "Recover your data using the recovery key if your password is lost."
},
{
- id: 'manage-attachments',
- name: 'Manage attachments',
- icon: 'attachment',
+ id: "manage-attachments",
+ name: "Manage attachments",
+ icon: "attachment",
modifer: () => {
eSendEvent(eOpenAttachmentsDialog);
},
- description: 'Manage all attachments in one place.'
+ description: "Manage all attachments in one place."
},
{
- id: 'change-password',
- name: 'Change password',
+ id: "change-password",
+ name: "Change password",
modifer: async () => {
ChangePassword.present();
},
- description: 'Setup a new password for your account.'
+ description: "Setup a new password for your account."
},
{
- id: '2fa-settings',
- type: 'screen',
- name: 'Two factor authentication',
- description: 'Manage 2FA settings',
- icon: 'two-factor-authentication',
+ id: "2fa-settings",
+ type: "screen",
+ name: "Two factor authentication",
+ description: "Manage 2FA settings",
+ icon: "two-factor-authentication",
sections: [
{
- id: 'enable-2fa',
- name: 'Enable two-factor authentication',
+ id: "enable-2fa",
+ name: "Enable two-factor authentication",
modifer: () => {
- verifyUser('global', async () => {
+ verifyUser("global", async () => {
MFASheet.present();
});
},
- useHook: () => useUserStore(state => state.user),
- hidden: user => {
+ useHook: () => useUserStore((state) => state.user),
+ hidden: (user) => {
return !!user?.mfa?.isEnabled;
},
- description: 'Increased security for your account'
+ description: "Increased security for your account"
},
{
- id: '2fa-fallback',
- name: 'Add fallback 2FA method',
- useHook: () => useUserStore(state => state.user),
- hidden: user => {
+ id: "2fa-fallback",
+ name: "Add fallback 2FA method",
+ useHook: () => useUserStore((state) => state.user),
+ hidden: (user) => {
return !!user?.mfa?.secondaryMethod || !user?.mfa?.isEnabled;
},
modifer: () => {
- verifyUser('global', async () => {
+ verifyUser("global", async () => {
MFASheet.present(true);
});
},
description:
- 'You can use fallback 2FA method incase you are unable to login via primary method'
+ "You can use fallback 2FA method incase you are unable to login via primary method"
},
{
- id: 'change-2fa-method',
- name: 'Reconfigure fallback 2FA method',
- useHook: () => useUserStore(state => state.user),
- hidden: user => {
+ id: "change-2fa-method",
+ name: "Reconfigure fallback 2FA method",
+ useHook: () => useUserStore((state) => state.user),
+ hidden: (user) => {
return !user?.mfa?.secondaryMethod || !user?.mfa?.isEnabled;
},
modifer: () => {
- verifyUser('global', async () => {
+ verifyUser("global", async () => {
MFASheet.present(true);
});
},
description:
- 'You can use fallback 2FA method incase you are unable to login via primary method'
+ "You can use fallback 2FA method incase you are unable to login via primary method"
},
{
- id: 'view-2fa-codes',
- name: 'View recovery codes',
+ id: "view-2fa-codes",
+ name: "View recovery codes",
modifer: () => {
- verifyUser('global', async () => {
- MFARecoveryCodes.present('sms');
+ verifyUser("global", async () => {
+ MFARecoveryCodes.present("sms");
});
},
- useHook: () => useUserStore(state => state.user),
- hidden: user => {
+ useHook: () => useUserStore((state) => state.user),
+ hidden: (user) => {
return !user?.mfa?.isEnabled;
},
- description: 'View and save recovery codes for to recover your account'
+ description:
+ "View and save recovery codes for to recover your account"
},
{
- id: 'disabled-2fa',
- name: 'Disable two-factor authentication',
+ id: "disabled-2fa",
+ name: "Disable two-factor authentication",
modifer: () => {
- verifyUser('global', async () => {
+ verifyUser("global", async () => {
await db.mfa?.disable();
let user = await db.user?.fetchUser();
useUserStore.getState().setUser(user);
});
},
- useHook: () => useUserStore(state => state.user),
- hidden: user => {
+ useHook: () => useUserStore((state) => state.user),
+ hidden: (user) => {
return !user?.mfa?.isEnabled;
},
- description: 'Decreased security for your account'
+ description: "Decreased security for your account"
}
]
},
{
- id: 'subscription-not-active',
- name: 'Subscription not activated?',
- hidden: () => Platform.OS !== 'ios',
+ id: "subscription-not-active",
+ name: "Subscription not activated?",
+ hidden: () => Platform.OS !== "ios",
modifer: async () => {
- if (Platform.OS === 'android') return;
+ if (Platform.OS === "android") return;
presentSheet({
- title: 'Loading subscriptions',
+ title: "Loading subscriptions",
paragraph: `Please wait while we fetch your subscriptions.`
});
let subscriptions = await RNIap.getPurchaseHistory();
- subscriptions.sort((a, b) => b.transactionDate - a.transactionDate);
+ subscriptions.sort(
+ (a, b) => b.transactionDate - a.transactionDate
+ );
let currentSubscription = subscriptions[0];
presentSheet({
- title: 'Notesnook Pro',
+ title: "Notesnook Pro",
paragraph: `You subscribed to Notesnook Pro on ${new Date(
currentSubscription.transactionDate
).toLocaleString()}. Verify this subscription?`,
action: async () => {
presentSheet({
- title: 'Verifying subscription',
+ title: "Verifying subscription",
paragraph: `Please wait while we verify your subscription.`
});
- await PremiumService.subscriptions.verify(currentSubscription);
+ await PremiumService.subscriptions.verify(
+ currentSubscription
+ );
eSendEvent(eCloseProgressDialog);
},
- icon: 'information-outline',
- actionText: 'Verify'
+ icon: "information-outline",
+ actionText: "Verify"
});
},
- description: 'Verify your subscription to Notesnook Pro'
+ description: "Verify your subscription to Notesnook Pro"
},
{
- id: 'logout',
- name: 'Log out',
- description: 'Clear all your data and reset the app.',
- icon: 'logout',
+ id: "logout",
+ name: "Log out",
+ description: "Clear all your data and reset the app.",
+ icon: "logout",
modifer: () => {
presentDialog({
- title: 'Logout',
- paragraph: 'Clear all your data and reset the app.',
- positiveText: 'Logout',
+ title: "Logout",
+ paragraph: "Clear all your data and reset the app.",
+ positiveText: "Logout",
positivePress: async () => {
try {
- eSendEvent('settings-loading', true);
+ eSendEvent("settings-loading", true);
setImmediate(async () => {
eSendEvent(eCloseSimpleDialog);
Navigation.popToTop();
@@ -278,37 +294,37 @@ export const settingsGroups: SettingSection[] = [
useUserStore.getState().setSyncing(false);
Navigation.goBack();
Navigation.popToTop();
- eSendEvent('settings-loading', false);
+ eSendEvent("settings-loading", false);
});
} catch (e) {
- ToastEvent.error(e as Error, 'Error logging out');
- eSendEvent('settings-loading', false);
+ ToastEvent.error(e as Error, "Error logging out");
+ eSendEvent("settings-loading", false);
}
}
});
}
},
{
- id: 'delete-account',
- type: 'danger',
- name: 'Delete account',
- icon: 'alert',
+ id: "delete-account",
+ type: "danger",
+ name: "Delete account",
+ icon: "alert",
description: `All your data will be removed permanantly. Make sure you have saved backup of your notes. This action is IRREVERSIBLE.`,
modifer: () => {
presentDialog({
- title: 'Delete account',
- paragraphColor: 'red',
+ title: "Delete account",
+ paragraphColor: "red",
paragraph:
- 'All your data will be removed permanantly. Make sure you have saved backup of your notes. This action is IRREVERSIBLE.',
- positiveType: 'errorShade',
+ "All your data will be removed permanantly. Make sure you have saved backup of your notes. This action is IRREVERSIBLE.",
+ positiveType: "errorShade",
input: true,
- inputPlaceholder: 'Enter account password',
- positiveText: 'Delete',
- positivePress: async value => {
+ inputPlaceholder: "Enter account password",
+ positiveText: "Delete",
+ positivePress: async (value) => {
try {
let verified = await db.user?.verifyPassword(value);
if (verified) {
- eSendEvent('settings-loading', true);
+ eSendEvent("settings-loading", true);
await db.user?.deleteUser(value);
await BiometicService.resetCredentials();
SettingsService.set({
@@ -316,18 +332,23 @@ export const settingsGroups: SettingSection[] = [
});
} else {
ToastEvent.show({
- heading: 'Incorrect password',
- message: 'The account password you entered is incorrect',
- type: 'error',
- context: 'global'
+ heading: "Incorrect password",
+ message:
+ "The account password you entered is incorrect",
+ type: "error",
+ context: "global"
});
}
- eSendEvent('settings-loading', false);
+ eSendEvent("settings-loading", false);
} catch (e) {
- eSendEvent('settings-loading', false);
+ eSendEvent("settings-loading", false);
console.log(e);
- ToastEvent.error(e as Error, 'Failed to delete account', 'global');
+ ToastEvent.error(
+ e as Error,
+ "Failed to delete account",
+ "global"
+ );
}
}
});
@@ -336,21 +357,21 @@ export const settingsGroups: SettingSection[] = [
]
},
{
- id: 'sync-issues-fix',
- name: 'Having problems with sync',
- description: 'Try force sync to resolve issues with syncing',
- icon: 'sync-alert',
+ id: "sync-issues-fix",
+ name: "Having problems with sync",
+ description: "Try force sync to resolve issues with syncing",
+ icon: "sync-alert",
modifer: async () => {
presentDialog({
- title: 'Force sync',
+ title: "Force sync",
paragraph: `If your data on two devices is out of sync even after trying to sync normally. You can run force sync to solve such problems. Usually you should never need to run this otherwise. Force sync means that all your data on this device is reuploaded to the server.`,
- negativeText: 'Cancel',
- positiveText: 'Start',
+ negativeText: "Cancel",
+ positiveText: "Start",
positivePress: async () => {
eSendEvent(eCloseProgressDialog);
await sleep(300);
Progress.present();
- Sync.run('global', true, true, () => {
+ Sync.run("global", true, true, () => {
eSendEvent(eCloseProgressDialog);
});
}
@@ -360,208 +381,211 @@ export const settingsGroups: SettingSection[] = [
]
},
{
- id: 'customize',
- name: 'Customize',
+ id: "customize",
+ name: "Customize",
sections: [
{
- id: 'personalization',
- type: 'screen',
- name: 'Theme',
- description: 'Change app look and feel',
- icon: 'shape',
+ id: "personalization",
+ type: "screen",
+ name: "Theme",
+ description: "Change app look and feel",
+ icon: "shape",
sections: [
{
- id: 'accent-color-picker',
- type: 'component',
- name: 'Accent color',
- description: 'Pick the color that matches your mood',
- component: 'colorpicker'
+ id: "accent-color-picker",
+ type: "component",
+ name: "Accent color",
+ description: "Pick the color that matches your mood",
+ component: "colorpicker"
},
{
- id: 'use-system-theme',
- type: 'switch',
- name: 'Use system theme',
- description: 'Automatically switch to dark mode when system theme changes',
- property: 'useSystemTheme',
- icon: 'circle-half'
+ id: "use-system-theme",
+ type: "switch",
+ name: "Use system theme",
+ description:
+ "Automatically switch to dark mode when system theme changes",
+ property: "useSystemTheme",
+ icon: "circle-half"
},
{
- id: 'enable-dark-mode',
- type: 'switch',
- name: 'Dark mode',
- description: 'Strain your eyes no more at night',
- property: 'theme',
- icon: 'brightness-6',
+ id: "enable-dark-mode",
+ type: "switch",
+ name: "Dark mode",
+ description: "Strain your eyes no more at night",
+ property: "theme",
+ icon: "brightness-6",
modifer: () => {
toggleDarkMode();
},
getter: () => useSettingStore.getState().settings.theme.dark
},
{
- id: 'pitch-black',
- type: 'switch',
- name: 'Pitch black',
- description: 'Save battery on device with amoled screen at night.',
- property: 'pitchBlack',
+ id: "pitch-black",
+ type: "switch",
+ name: "Pitch black",
+ description: "Save battery on device with amoled screen at night.",
+ property: "pitchBlack",
modifer: () => {
SettingsService.set({
pitchBlack: !SettingsService.get().pitchBlack
});
getColorScheme();
},
- icon: 'brightness-1'
+ icon: "brightness-1"
}
]
},
{
- id: 'behaviour',
- type: 'screen',
- name: 'Behaviour',
- description: 'Change app homepage',
+ id: "behaviour",
+ type: "screen",
+ name: "Behaviour",
+ description: "Change app homepage",
sections: [
{
- id: 'default-home',
- type: 'component',
- name: 'Homepage',
- description: 'Default screen to open on app startup',
- component: 'homeselector'
+ id: "default-home",
+ type: "component",
+ name: "Homepage",
+ description: "Default screen to open on app startup",
+ component: "homeselector"
}
]
}
]
},
{
- id: 'privacy-security',
- name: 'Privacy and security',
+ id: "privacy-security",
+ name: "Privacy and security",
sections: [
{
- id: 'temeltery',
- type: 'switch',
- name: 'Telemetry',
- icon: 'radar',
+ id: "temeltery",
+ type: "switch",
+ name: "Telemetry",
+ icon: "radar",
description:
- 'Contribute towards a better Notesnook. All tracking information is anonymous.',
- property: 'telemetry'
+ "Contribute towards a better Notesnook. All tracking information is anonymous.",
+ property: "telemetry"
},
{
- id: 'vault',
- type: 'screen',
- name: 'Vault',
- description: 'Multi-layer encryption to most important notes',
- icon: 'key',
+ id: "vault",
+ type: "screen",
+ name: "Vault",
+ description: "Multi-layer encryption to most important notes",
+ icon: "key",
sections: [
{
- id: 'create-vault',
- name: 'Create vault',
- description: 'Set a password to create vault and lock notes.',
- icon: 'key',
+ id: "create-vault",
+ name: "Create vault",
+ description: "Set a password to create vault and lock notes.",
+ icon: "key",
useHook: useVaultStatus,
- hidden: current => current?.exists,
+ hidden: (current) => current?.exists,
modifer: () => {
PremiumService.verify(() => {
openVault({
item: {},
novault: false,
- title: 'Create vault',
- description: 'Set a password to create vault and lock notes.'
+ title: "Create vault",
+ description: "Set a password to create vault and lock notes."
});
});
}
},
{
- id: 'change-vault-password',
+ id: "change-vault-password",
useHook: useVaultStatus,
- name: 'Change vault password',
- description: 'Setup a new password for your vault.',
- hidden: current => !current?.exists,
+ name: "Change vault password",
+ description: "Setup a new password for your vault.",
+ hidden: (current) => !current?.exists,
modifer: () =>
openVault({
item: {},
changePassword: true,
novault: true,
- title: 'Change vault password',
- description: 'Set a new password for your vault.'
+ title: "Change vault password",
+ description: "Set a new password for your vault."
})
},
{
- id: 'clear-vault',
+ id: "clear-vault",
useHook: useVaultStatus,
- name: 'Clear vault',
- description: 'Unlock all locked notes',
- hidden: current => !current?.exists,
+ name: "Clear vault",
+ description: "Unlock all locked notes",
+ hidden: (current) => !current?.exists,
modifer: () => {
openVault({
item: {},
clearVault: true,
novault: true,
- title: 'Clear vault',
- description: 'Enter vault password to unlock and remove all notes from the vault.'
+ title: "Clear vault",
+ description:
+ "Enter vault password to unlock and remove all notes from the vault."
});
}
},
{
- id: 'delete-vault',
- name: 'Delete vault',
- description: 'Delete vault (and optionally remove all notes).',
+ id: "delete-vault",
+ name: "Delete vault",
+ description: "Delete vault (and optionally remove all notes).",
useHook: useVaultStatus,
- hidden: current => !current?.exists,
+ hidden: (current) => !current?.exists,
modifer: () => {
openVault({
item: {},
deleteVault: true,
novault: true,
- title: 'Delete vault',
- description: 'Enter your account password to delete your vault.'
+ title: "Delete vault",
+ description: "Enter your account password to delete your vault."
});
}
},
{
- id: 'biometic-unlock',
- type: 'switch',
- name: 'Biometric unlocking',
- icon: 'fingerprint',
+ id: "biometic-unlock",
+ type: "switch",
+ name: "Biometric unlocking",
+ icon: "fingerprint",
useHook: useVaultStatus,
- description: 'Access notes in vault using biometrics',
- hidden: current => !current?.exists || !current?.isBiometryAvailable,
- getter: current => current?.biometryEnrolled,
- modifer: current => {
+ description: "Access notes in vault using biometrics",
+ hidden: (current) =>
+ !current?.exists || !current?.isBiometryAvailable,
+ getter: (current) => current?.biometryEnrolled,
+ modifer: (current) => {
openVault({
item: {},
fingerprintAccess: !current.biometryEnrolled,
revokeFingerprintAccess: current.biometryEnrolled,
novault: true,
title: current.biometryEnrolled
- ? 'Revoke biometric unlocking'
- : 'Enable biometery unlock',
+ ? "Revoke biometric unlocking"
+ : "Enable biometery unlock",
description: current.biometryEnrolled
- ? 'Disable biometric unlocking for notes in vault'
- : 'Enable biometric unlocking for notes in vault'
+ ? "Disable biometric unlocking for notes in vault"
+ : "Enable biometric unlocking for notes in vault"
});
}
}
]
},
{
- id: 'privacy-mode',
- type: 'switch',
- icon: 'eye-off-outline',
- name: 'Privacy mode',
+ id: "privacy-mode",
+ type: "switch",
+ icon: "eye-off-outline",
+ name: "Privacy mode",
description: `Hide app contents when you switch to other apps. This will also disable screenshot taking in the app.`,
modifer: () => {
const settings = SettingsService.get();
- Platform.OS === 'android'
+ Platform.OS === "android"
? AndroidModule.setSecureMode(!settings.privacyScreen)
: enabled(true);
SettingsService.set({ privacyScreen: !settings.privacyScreen });
},
- property: 'privacyScreen'
+ property: "privacyScreen"
},
{
- id: 'app-lock',
- name: 'App lock',
- description: 'Change app lock mode to suit your needs',
- icon: 'fingerprint',
+ id: "app-lock",
+ name: "App lock",
+ description: "Change app lock mode to suit your needs",
+ icon: "fingerprint",
modifer: () => {
AppLock.present();
}
@@ -569,20 +593,20 @@ export const settingsGroups: SettingSection[] = [
]
},
{
- id: 'back-restore',
- name: 'Backup and restore',
+ id: "back-restore",
+ name: "Backup and restore",
sections: [
{
- id: 'backups',
- type: 'screen',
- name: 'Backups',
- icon: 'backup-restore',
- description: 'Create a backup or change backup settings',
+ id: "backups",
+ type: "screen",
+ name: "Backups",
+ icon: "backup-restore",
+ description: "Create a backup or change backup settings",
sections: [
{
- id: 'backup-now',
- name: 'Backup now',
- description: 'Create a backup of your data',
+ id: "backup-now",
+ name: "Backup now",
+ description: "Create a backup of your data",
modifer: async () => {
const user = useUserStore.getState().user;
if (!user) {
@@ -593,20 +617,22 @@ export const settingsGroups: SettingSection[] = [
}
},
{
- id: 'auto-backups',
- type: 'component',
- name: 'Automatic backups',
- description: 'Backup your data once every week or daily automatically.',
- component: 'autobackups'
+ id: "auto-backups",
+ type: "component",
+ name: "Automatic backups",
+ description:
+ "Backup your data once every week or daily automatically.",
+ component: "autobackups"
},
{
- id: 'select-backup-dir',
- name: 'Select backup directory',
- description: 'Select directory to store backups',
- icon: 'folder',
+ id: "select-backup-dir",
+ name: "Select backup directory",
+ description: "Select directory to store backups",
+ icon: "folder",
hidden: () =>
- !!SettingsService.get().backupDirectoryAndroid || Platform.OS !== 'android',
- property: 'backupDirectoryAndroid',
+ !!SettingsService.get().backupDirectoryAndroid ||
+ Platform.OS !== "android",
+ property: "backupDirectoryAndroid",
modifer: async () => {
let dir;
try {
@@ -615,21 +641,23 @@ export const settingsGroups: SettingSection[] = [
} finally {
if (!dir) {
ToastEvent.show({
- heading: 'No directory selected',
- type: 'error'
+ heading: "No directory selected",
+ type: "error"
});
}
}
}
},
{
- id: 'change-backup-dir',
- name: 'Change backup directory',
- description: () => SettingsService.get().backupDirectoryAndroid?.name || '',
- icon: 'folder',
+ id: "change-backup-dir",
+ name: "Change backup directory",
+ description: () =>
+ SettingsService.get().backupDirectoryAndroid?.name || "",
+ icon: "folder",
hidden: () =>
- !SettingsService.get().backupDirectoryAndroid || Platform.OS !== 'android',
- property: 'backupDirectoryAndroid',
+ !SettingsService.get().backupDirectoryAndroid ||
+ Platform.OS !== "android",
+ property: "backupDirectoryAndroid",
modifer: async () => {
let dir;
try {
@@ -638,51 +666,53 @@ export const settingsGroups: SettingSection[] = [
} finally {
if (!dir) {
ToastEvent.show({
- heading: 'No directory selected',
- type: 'error'
+ heading: "No directory selected",
+ type: "error"
});
}
}
}
},
{
- id: 'enable-backup-encryption',
- type: 'switch',
- name: 'Backup encryption',
- description: 'Encrypt all your backups.',
- icon: 'lock',
- property: 'encryptedBackup',
+ id: "enable-backup-encryption",
+ type: "switch",
+ name: "Backup encryption",
+ description: "Encrypt all your backups.",
+ icon: "lock",
+ property: "encryptedBackup",
modifer: async () => {
const user = useUserStore.getState().user;
const settings = SettingsService.get();
if (!user) {
ToastEvent.show({
- heading: 'Login required to enable encryption',
- type: 'error',
+ heading: "Login required to enable encryption",
+ type: "error",
func: () => {
eSendEvent(eOpenLoginDialog);
},
- actionText: 'Login'
+ actionText: "Login"
});
return;
}
- SettingsService.set({ encryptedBackup: !settings.encryptedBackup });
+ SettingsService.set({
+ encryptedBackup: !settings.encryptedBackup
+ });
}
}
]
},
{
- id: 'restore-backup',
- name: 'Restore backup',
+ id: "restore-backup",
+ name: "Restore backup",
description: `Restore backup from phone storage.`,
modifer: () => {
const user = useUserStore.getState().user;
if (!user || !user?.email) {
ToastEvent.show({
- heading: 'Login required',
- message: 'Please log in to your account to restore backup',
- type: 'error',
- context: 'global'
+ heading: "Login required",
+ message: "Please log in to your account to restore backup",
+ type: "error",
+ context: "global"
});
return;
}
@@ -692,20 +722,20 @@ export const settingsGroups: SettingSection[] = [
]
},
{
- id: 'productivity',
- name: 'Productivity',
- hidden: () => Platform.OS !== 'android',
+ id: "productivity",
+ name: "Productivity",
+ hidden: () => Platform.OS !== "android",
sections: [
{
- id: 'notification-notes',
- type: 'switch',
- name: 'Notes in notifications',
+ id: "notification-notes",
+ type: "switch",
+ name: "Notes in notifications",
description: `Add quick notes from notifications without opening the app.`,
- property: 'notifNotes',
- icon: 'form-textbox',
+ property: "notifNotes",
+ icon: "form-textbox",
modifer: () => {
const settings = SettingsService.get();
- console.log('called me now', settings.notifNotes);
+ console.log("called me now", settings.notifNotes);
if (settings.notifNotes) {
Notifications.unpinQuickNote();
} else {
@@ -719,213 +749,219 @@ export const settingsGroups: SettingSection[] = [
]
},
{
- id: 'editor',
- name: 'Editor',
+ id: "editor",
+ name: "Editor",
sections: [
{
- id: 'configure-toolbar',
- type: 'screen',
- name: 'Configure toolbar',
+ id: "configure-toolbar",
+ type: "screen",
+ name: "Configure toolbar",
description: `Make the toolbar adaptable to your needs.`,
- component: 'configuretoolbar'
+ component: "configuretoolbar"
},
{
- id: 'reset-toolbar',
- name: 'Reset toolbar',
+ id: "reset-toolbar",
+ name: "Reset toolbar",
description: `Reset toolbar configuration to default`,
modifer: () => {
- useDragState.getState().setPreset('default');
+ useDragState.getState().setPreset("default");
}
},
{
- id: 'double-spaced-lines',
- name: 'Use double spaced lines',
+ id: "double-spaced-lines",
+ name: "Use double spaced lines",
description: `New lines will be double spaced (old ones won't be affected).`,
- type: 'switch',
- property: 'doubleSpacedLines',
- icon: 'format-line-spacing',
- onChange: property => {
+ type: "switch",
+ property: "doubleSpacedLines",
+ icon: "format-line-spacing",
+ onChange: (property) => {
ToastEvent.show({
- heading: 'Line spacing changed',
- type: 'success',
+ heading: "Line spacing changed",
+ type: "success",
message:
- 'Close and reopen the current opened note or restart the app for changes to take affect.'
+ "Close and reopen the current opened note or restart the app for changes to take affect."
});
}
}
]
},
{
- id: 'help-support',
- name: 'Help and support',
+ id: "help-support",
+ name: "Help and support",
sections: [
{
- id: 'report-issue',
- name: 'Report an issue',
- icon: 'bug',
+ id: "report-issue",
+ name: "Report an issue",
+ icon: "bug",
modifer: () => {
presentSheet({
component: <Issue />
});
},
- description: 'Faced an issue or have a suggestion? Click here to create a bug report'
+ description:
+ "Faced an issue or have a suggestion? Click here to create a bug report"
},
{
- id: 'docs-link',
- name: 'Documentation',
+ id: "docs-link",
+ name: "Documentation",
modifer: async () => {
- Linking.openURL('https://docs.notesnook.com');
+ Linking.openURL("https://docs.notesnook.com");
},
- description: 'Learn about every feature and how it works.',
- icon: 'file-document'
+ description: "Learn about every feature and how it works.",
+ icon: "file-document"
},
{
- id: 'debugging',
- name: 'Debugging',
- description: 'Get helpful debug info about the app to help us find bugs.',
- type: 'screen',
- icon: 'bug',
+ id: "debugging",
+ name: "Debugging",
+ description:
+ "Get helpful debug info about the app to help us find bugs.",
+ type: "screen",
+ icon: "bug",
sections: [
{
- id: 'debug-mode',
- type: 'switch',
- name: 'Debug mode',
- description: 'Show debug options on items',
- property: 'devMode'
+ id: "debug-mode",
+ type: "switch",
+ name: "Debug mode",
+ description: "Show debug options on items",
+ property: "devMode"
},
{
- id: 'debug-logs',
- type: 'screen',
- name: 'Debug logs',
- description: 'View debug logs from the app',
- component: 'debug-logs'
+ id: "debug-logs",
+ type: "screen",
+ name: "Debug logs",
+ description: "View debug logs from the app",
+ component: "debug-logs"
}
]
}
]
},
{
- id: 'community',
- name: 'community',
+ id: "community",
+ name: "community",
sections: [
{
- id: 'join-telegram',
- name: 'Join our Telegram group',
+ id: "join-telegram",
+ name: "Join our Telegram group",
description: "We are on telegram, let's talk",
// icon: 'telegram',
modifer: () => {
- Linking.openURL('https://t.me/notesnook').catch(console.log);
+ Linking.openURL("https://t.me/notesnook").catch(console.log);
}
},
{
- id: 'join-twitter',
- name: 'Follow us on twitter',
- description: 'Stay updated with the latest news about Notesnook',
- icon: 'twitter',
+ id: "join-twitter",
+ name: "Follow us on twitter",
+ description: "Stay updated with the latest news about Notesnook",
+ icon: "twitter",
modifer: () => {
- Linking.openURL('https://twitter.com/notesnook').catch(console.log);
+ Linking.openURL("https://twitter.com/notesnook").catch(console.log);
}
},
{
- id: 'join-discord',
- name: 'Join our Discord community',
- icon: 'discord',
+ id: "join-discord",
+ name: "Join our Discord community",
+ icon: "discord",
modifer: async () => {
presentSheet({
- title: 'Join our Discord Community',
- iconColor: 'discord',
- paragraph: 'We are not ghosts, chat with us and share your experience.',
+ title: "Join our Discord Community",
+ iconColor: "discord",
+ paragraph:
+ "We are not ghosts, chat with us and share your experience.",
valueArray: [
- 'Talk with us anytime.',
- 'Follow the development process',
- 'Give suggestions and report issues.',
- 'Get early access to new features',
- 'Meet other people using Notesnook'
+ "Talk with us anytime.",
+ "Follow the development process",
+ "Give suggestions and report issues.",
+ "Get early access to new features",
+ "Meet other people using Notesnook"
],
- icon: 'discord',
+ icon: "discord",
action: async () => {
try {
- Linking.openURL('https://discord.gg/zQBK97EE22').catch(console.log);
+ Linking.openURL("https://discord.gg/zQBK97EE22").catch(
+ console.log
+ );
} catch (e) {}
},
- actionText: 'Join Now'
+ actionText: "Join Now"
});
},
- description: 'We are not ghosts, chat with us and share your experience.'
+ description:
+ "We are not ghosts, chat with us and share your experience."
}
]
},
{
- id: 'legal',
- name: 'legal',
+ id: "legal",
+ name: "legal",
sections: [
{
- id: 'tos',
- name: 'Terms of service',
+ id: "tos",
+ name: "Terms of service",
modifer: async () => {
try {
- await Linking.openURL('https://notesnook.com/tos');
+ await Linking.openURL("https://notesnook.com/tos");
} catch (e) {}
},
- description: 'Read our terms of service'
+ description: "Read our terms of service"
},
{
- id: 'privacy-policy',
- name: 'Privacy policy',
+ id: "privacy-policy",
+ name: "Privacy policy",
modifer: async () => {
try {
- await Linking.openURL('https://notesnook.com/privacy');
+ await Linking.openURL("https://notesnook.com/privacy");
} catch (e) {}
},
- description: 'Read our privacy policy'
+ description: "Read our privacy policy"
}
]
},
{
- id: 'about',
- name: 'about',
+ id: "about",
+ name: "about",
sections: [
{
- id: 'download',
- name: 'Download on desktop',
- icon: 'monitor',
+ id: "download",
+ name: "Download on desktop",
+ icon: "monitor",
modifer: async () => {
try {
- await Linking.openURL('https://notesnook.com/downloads');
+ await Linking.openURL("https://notesnook.com/downloads");
} catch (e) {}
},
- description: 'Get Notesnook app on your desktop and access all notes'
+ description: "Get Notesnook app on your desktop and access all notes"
},
{
- id: 'roadmap',
- name: 'Roadmap',
- icon: 'chart-timeline',
+ id: "roadmap",
+ name: "Roadmap",
+ icon: "chart-timeline",
modifer: async () => {
try {
- await Linking.openURL('https://notesnook.com/roadmap/');
+ await Linking.openURL("https://notesnook.com/roadmap/");
} catch (e) {}
},
- description: 'See what the future of Notesnook is going to be like.'
+ description: "See what the future of Notesnook is going to be like."
},
{
- id: 'check-for-updates',
- name: 'Check for updates',
- icon: 'cellphone-arrow-down',
- description: 'Check for new version of Notesnook',
+ id: "check-for-updates",
+ name: "Check for updates",
+ icon: "cellphone-arrow-down",
+ description: "Check for new version of Notesnook",
modifer: async () => {
presentSheet({
//@ts-ignore
- component: ref => <Update fwdRef={ref} />
+ component: (ref) => <Update fwdRef={ref} />
});
}
},
{
- id: 'app-version',
- name: 'App version',
- icon: 'alpha-v',
+ id: "app-version",
+ name: "App version",
+ icon: "alpha-v",
modifer: async () => {
try {
- await Linking.openURL('https://notesnook.com');
+ await Linking.openURL("https://notesnook.com");
} catch (e) {}
},
description: format(APP_VERSION)
diff --git a/apps/mobile/app/screens/settings/subscription.js b/apps/mobile/app/screens/settings/subscription.js
index 755bc1df8..c1b8bffc6 100644
--- a/apps/mobile/app/screens/settings/subscription.js
+++ b/apps/mobile/app/screens/settings/subscription.js
@@ -1,22 +1,30 @@
-import React from 'react';
-import { Linking, Platform, View } from 'react-native';
-import { Button } from '../../components/ui/button';
-import { eSendEvent, presentSheet, ToastEvent } from '../../services/event-manager';
-import PremiumService from '../../services/premium';
-import { useUserStore } from '../../stores/use-user-store';
-import { SUBSCRIPTION_PROVIDER, SUBSCRIPTION_STATUS } from '../../utils/constants';
-import { eOpenPremiumDialog } from '../../utils/events';
-import { usePricing } from '../../hooks/use-pricing';
-import { SIZE } from '../../utils/size';
+import React from "react";
+import { Linking, Platform, View } from "react-native";
+import { Button } from "../../components/ui/button";
+import {
+ eSendEvent,
+ presentSheet,
+ ToastEvent
+} from "../../services/event-manager";
+import PremiumService from "../../services/premium";
+import { useUserStore } from "../../stores/use-user-store";
+import {
+ SUBSCRIPTION_PROVIDER,
+ SUBSCRIPTION_STATUS
+} from "../../utils/constants";
+import { eOpenPremiumDialog } from "../../utils/events";
+import { usePricing } from "../../hooks/use-pricing";
+import { SIZE } from "../../utils/size";
export const Subscription = () => {
- const user = useUserStore(state => state.user);
- const monthlyPlan = usePricing('monthly');
+ const user = useUserStore((state) => state.user);
+ const monthlyPlan = usePricing("monthly");
const isNotPro =
user?.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM &&
user?.subscription?.type !== SUBSCRIPTION_STATUS.BETA;
- const subscriptionProviderInfo = SUBSCRIPTION_PROVIDER[user?.subscription?.provider];
+ const subscriptionProviderInfo =
+ SUBSCRIPTION_PROVIDER[user?.subscription?.provider];
const manageSubscription = () => {
if (!user?.isEmailConfirmed) {
@@ -25,17 +33,17 @@ export const Subscription = () => {
}
if (
user?.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED &&
- Platform.OS === 'android'
+ Platform.OS === "android"
) {
if (user.subscription?.provider === 3) {
ToastEvent.show({
- heading: 'Subscribed on web',
- message: 'Open your web browser to manage your subscription.',
- type: 'success'
+ heading: "Subscribed on web",
+ message: "Open your web browser to manage your subscription.",
+ type: "success"
});
return;
}
- Linking.openURL('https://play.google.com/store/account/subscriptions');
+ Linking.openURL("https://play.google.com/store/account/subscriptions");
/**
*
@@ -56,19 +64,21 @@ export const Subscription = () => {
style={{
borderRadius: 100,
paddingHorizontal: 16,
- alignSelf: 'flex-start'
+ alignSelf: "flex-start"
}}
fontSize={SIZE.sm}
type="accent"
onPress={manageSubscription}
title={
!user?.isEmailConfirmed
- ? 'Confirm your email'
+ ? "Confirm your email"
: user.subscription?.provider === 3 &&
- user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED
- ? 'Manage subscription from desktop app'
- : user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED &&
- Platform.OS === 'android'
+ user.subscription?.type ===
+ SUBSCRIPTION_STATUS.PREMIUM_CANCELLED
+ ? "Manage subscription from desktop app"
+ : user.subscription?.type ===
+ SUBSCRIPTION_STATUS.PREMIUM_CANCELLED &&
+ Platform.OS === "android"
? `Resubscribe from Google Playstore`
: user.subscription?.type === SUBSCRIPTION_STATUS.PREMIUM_EXPIRED
? `Resubscribe to Pro (${monthlyPlan?.product?.localizedPrice} / mo)`
@@ -89,7 +99,7 @@ export const Subscription = () => {
});
}}
style={{
- alignSelf: 'flex-start',
+ alignSelf: "flex-start",
borderRadius: 100
}}
fontSize={SIZE.sm}
diff --git a/apps/mobile/app/screens/settings/types.ts b/apps/mobile/app/screens/settings/types.ts
index 23d6ebf8b..449a52e5a 100644
--- a/apps/mobile/app/screens/settings/types.ts
+++ b/apps/mobile/app/screens/settings/types.ts
@@ -1,8 +1,8 @@
-import { Settings } from '../../stores/interfaces';
+import { Settings } from "../../stores/interfaces";
export type SettingSection = {
id: string;
- type?: 'screen' | 'switch' | 'component' | 'danger';
+ type?: "screen" | "switch" | "component" | "danger";
name?: string | ((current?: any) => string);
description?: string | ((current: any) => string);
icon?: string;
diff --git a/apps/mobile/app/screens/settings/user-section.js b/apps/mobile/app/screens/settings/user-section.js
index 365321497..fba9af077 100644
--- a/apps/mobile/app/screens/settings/user-section.js
+++ b/apps/mobile/app/screens/settings/user-section.js
@@ -1,29 +1,30 @@
-import dayjs from 'dayjs';
-import React from 'react';
-import { View } from 'react-native';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { TimeSince } from '../../components/ui/time-since';
-import Heading from '../../components/ui/typography/heading';
-import Paragraph from '../../components/ui/typography/paragraph';
-import { useUserStore } from '../../stores/use-user-store';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { SUBSCRIPTION_STATUS_STRINGS } from '../../utils/constants';
-import { SIZE } from '../../utils/size';
-import { SectionItem } from './section-item';
+import dayjs from "dayjs";
+import React from "react";
+import { View } from "react-native";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { TimeSince } from "../../components/ui/time-since";
+import Heading from "../../components/ui/typography/heading";
+import Paragraph from "../../components/ui/typography/paragraph";
+import { useUserStore } from "../../stores/use-user-store";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { SUBSCRIPTION_STATUS_STRINGS } from "../../utils/constants";
+import { SIZE } from "../../utils/size";
+import { SectionItem } from "./section-item";
-export const getTimeLeft = t2 => {
- let daysRemaining = dayjs(t2).diff(dayjs(), 'days');
+export const getTimeLeft = (t2) => {
+ let daysRemaining = dayjs(t2).diff(dayjs(), "days");
return {
- time: dayjs(t2).diff(dayjs(), daysRemaining === 0 ? 'hours' : 'days'),
+ time: dayjs(t2).diff(dayjs(), daysRemaining === 0 ? "hours" : "days"),
isHour: daysRemaining === 0
};
};
const SettingsUserSection = ({ item }) => {
- const colors = useThemeStore(state => state.colors);
+ const colors = useThemeStore((state) => state.colors);
- const user = useUserStore(state => state.user);
- const subscriptionDaysLeft = user && getTimeLeft(parseInt(user.subscription?.expiry));
+ const user = useUserStore((state) => state.user);
+ const subscriptionDaysLeft =
+ user && getTimeLeft(parseInt(user.subscription?.expiry));
// const isExpired = user && subscriptionDaysLeft.time < 0;
// const expiryDate = dayjs(user?.subscription?.expiry).format('MMMM D, YYYY');
// const startDate = dayjs(user?.subscription?.start).format('MMMM D, YYYY');
@@ -35,7 +36,7 @@ const SettingsUserSection = ({ item }) => {
// user?.subscription?.type !== SUBSCRIPTION_STATUS.PREMIUM &&
// user?.subscription?.type !== SUBSCRIPTION_STATUS.BETA;
- const lastSynced = useUserStore(state => state.lastSynced);
+ const lastSynced = useUserStore((state) => state.lastSynced);
return (
<>
@@ -49,8 +50,8 @@ const SettingsUserSection = ({ item }) => {
>
<View
style={{
- alignSelf: 'center',
- width: '100%',
+ alignSelf: "center",
+ width: "100%",
paddingVertical: 12,
backgroundColor: colors.bg,
borderRadius: 5
@@ -58,26 +59,26 @@ const SettingsUserSection = ({ item }) => {
>
<View
style={{
- justifyContent: 'space-between',
- flexDirection: 'row',
+ justifyContent: "space-between",
+ flexDirection: "row",
paddingBottom: 4
}}
>
<View
style={{
- flexDirection: 'row',
- width: '100%',
- justifyContent: 'space-between'
+ flexDirection: "row",
+ width: "100%",
+ justifyContent: "space-between"
}}
>
<View
style={{
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
<View
style={{
- alignItems: 'center'
+ alignItems: "center"
}}
>
<View
@@ -86,11 +87,15 @@ const SettingsUserSection = ({ item }) => {
borderRadius: 100,
width: 50,
height: 50,
- alignItems: 'center',
- justifyContent: 'center'
+ alignItems: "center",
+ justifyContent: "center"
}}
>
- <Icon size={SIZE.xl} color={colors.accent} name="account-outline" />
+ <Icon
+ size={SIZE.xl}
+ color={colors.accent}
+ name="account-outline"
+ />
</View>
</View>
@@ -101,14 +106,16 @@ const SettingsUserSection = ({ item }) => {
}}
>
<Heading color={colors.accent} size={SIZE.xs + 1}>
- {SUBSCRIPTION_STATUS_STRINGS[user.subscription?.type].toUpperCase()}
+ {SUBSCRIPTION_STATUS_STRINGS[
+ user.subscription?.type
+ ].toUpperCase()}
</Heading>
<Paragraph color={colors.heading} size={SIZE.sm}>
{user?.email}
</Paragraph>
<Paragraph color={colors.icon} size={SIZE.xs}>
- Last synced{' '}
+ Last synced{" "}
<TimeSince
style={{ fontSize: SIZE.xs, color: colors.icon }}
time={lastSynced}
@@ -207,7 +214,7 @@ const SettingsUserSection = ({ item }) => {
</View>
</View>
- {item.sections.map(item => (
+ {item.sections.map((item) => (
<SectionItem key={item.name} item={item} />
))}
</>
diff --git a/apps/mobile/app/screens/tags/index.tsx b/apps/mobile/app/screens/tags/index.tsx
index 316499eac..57f629423 100644
--- a/apps/mobile/app/screens/tags/index.tsx
+++ b/apps/mobile/app/screens/tags/index.tsx
@@ -1,35 +1,38 @@
-import React from 'react';
-import DelayLayout from '../../components/delay-layout';
-import List from '../../components/list';
-import Navigation, { NavigationProps } from '../../services/navigation';
-import SearchService from '../../services/search';
-import SettingsService from '../../services/settings';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useTagStore } from '../../stores/use-tag-store';
-import { db } from '../../common/database';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
+import React from "react";
+import DelayLayout from "../../components/delay-layout";
+import List from "../../components/list";
+import Navigation, { NavigationProps } from "../../services/navigation";
+import SearchService from "../../services/search";
+import SettingsService from "../../services/settings";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useTagStore } from "../../stores/use-tag-store";
+import { db } from "../../common/database";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
const prepareSearch = () => {
SearchService.update({
- placeholder: 'Search in tags',
- type: 'tags',
- title: 'Tags',
+ placeholder: "Search in tags",
+ type: "tags",
+ title: "Tags",
get: () => db.tags?.all
});
};
const PLACEHOLDER_DATA = {
- heading: 'Your tags',
- paragraph: 'You have not created any tags for your notes yet.',
+ heading: "Your tags",
+ paragraph: "You have not created any tags for your notes yet.",
button: null,
- loading: 'Loading your tags.'
+ loading: "Loading your tags."
};
-export const Tags = ({ navigation, route }: NavigationProps<'Tags'>) => {
- const tags = useTagStore(state => state.tags);
+export const Tags = ({ navigation, route }: NavigationProps<"Tags">) => {
+ const tags = useTagStore((state) => state.tags);
const isFocused = useNavigationFocus(navigation, {
- onFocus: prev => {
- Navigation.routeNeedsUpdate(route.name, Navigation.routeUpdateFunctions[route.name]);
+ onFocus: (prev) => {
+ Navigation.routeNeedsUpdate(
+ route.name,
+ Navigation.routeUpdateFunctions[route.name]
+ );
useNavigationStore.getState().update({
name: route.name
});
@@ -47,7 +50,7 @@ export const Tags = ({ navigation, route }: NavigationProps<'Tags'>) => {
listData={tags}
type="tags"
headerProps={{
- heading: 'Tags'
+ heading: "Tags"
}}
loading={!isFocused}
screen="Tags"
diff --git a/apps/mobile/app/screens/trash/index.tsx b/apps/mobile/app/screens/trash/index.tsx
index 961160873..ac8c065b7 100644
--- a/apps/mobile/app/screens/trash/index.tsx
+++ b/apps/mobile/app/screens/trash/index.tsx
@@ -1,60 +1,64 @@
-import React from 'react';
-import { FloatingButton } from '../../components/container/floating-button';
-import DelayLayout from '../../components/delay-layout';
-import { presentDialog } from '../../components/dialog/functions';
-import List from '../../components/list';
-import { ToastEvent } from '../../services/event-manager';
-import Navigation, { NavigationProps } from '../../services/navigation';
-import SearchService from '../../services/search';
-import SettingsService from '../../services/settings';
-import useNavigationStore from '../../stores/use-navigation-store';
-import { useSelectionStore } from '../../stores/use-selection-store';
-import { useTrashStore } from '../../stores/use-trash-store';
-import { db } from '../../common/database';
-import { useNavigationFocus } from '../../hooks/use-navigation-focus';
+import React from "react";
+import { FloatingButton } from "../../components/container/floating-button";
+import DelayLayout from "../../components/delay-layout";
+import { presentDialog } from "../../components/dialog/functions";
+import List from "../../components/list";
+import { ToastEvent } from "../../services/event-manager";
+import Navigation, { NavigationProps } from "../../services/navigation";
+import SearchService from "../../services/search";
+import SettingsService from "../../services/settings";
+import useNavigationStore from "../../stores/use-navigation-store";
+import { useSelectionStore } from "../../stores/use-selection-store";
+import { useTrashStore } from "../../stores/use-trash-store";
+import { db } from "../../common/database";
+import { useNavigationFocus } from "../../hooks/use-navigation-focus";
const prepareSearch = () => {
SearchService.update({
- placeholder: 'Search in trash',
- type: 'trash',
- title: 'Trash',
+ placeholder: "Search in trash",
+ type: "trash",
+ title: "Trash",
get: () => db.trash?.all
});
};
const onPressFloatingButton = () => {
presentDialog({
- title: 'Clear trash',
- paragraph: 'Are you sure you want to clear the trash?',
- positiveText: 'Clear',
- negativeText: 'Cancel',
+ title: "Clear trash",
+ paragraph: "Are you sure you want to clear the trash?",
+ positiveText: "Clear",
+ negativeText: "Cancel",
positivePress: async () => {
await db.trash?.clear();
useTrashStore.getState().setTrash();
useSelectionStore.getState().clearSelection(true);
ToastEvent.show({
- heading: 'Trash cleared',
- message: 'All notes and notebooks in the trash have been removed permanantly.',
- type: 'success',
- context: 'local'
+ heading: "Trash cleared",
+ message:
+ "All notes and notebooks in the trash have been removed permanantly.",
+ type: "success",
+ context: "local"
});
},
- positiveType: 'errorShade'
+ positiveType: "errorShade"
});
};
const PLACEHOLDER_DATA = {
- heading: 'Trash',
- paragraph: 'Items in the trash will be permanently deleted after 7 days.',
+ heading: "Trash",
+ paragraph: "Items in the trash will be permanently deleted after 7 days.",
button: null,
- loading: 'Loading trash items'
+ loading: "Loading trash items"
};
-export const Trash = ({ navigation, route }: NavigationProps<'Trash'>) => {
- const trash = useTrashStore(state => state.trash);
+export const Trash = ({ navigation, route }: NavigationProps<"Trash">) => {
+ const trash = useTrashStore((state) => state.trash);
const isFocused = useNavigationFocus(navigation, {
- onFocus: prev => {
- Navigation.routeNeedsUpdate(route.name, Navigation.routeUpdateFunctions[route.name]);
+ onFocus: (prev) => {
+ Navigation.routeNeedsUpdate(
+ route.name,
+ Navigation.routeUpdateFunctions[route.name]
+ );
useNavigationStore.getState().update({
name: route.name
});
@@ -76,12 +80,16 @@ export const Trash = ({ navigation, route }: NavigationProps<'Trash'>) => {
loading={!isFocused}
placeholderData={PLACEHOLDER_DATA}
headerProps={{
- heading: 'Trash'
+ heading: "Trash"
}}
/>
{trash && trash.length !== 0 ? (
- <FloatingButton title="Clear all trash" onPress={onPressFloatingButton} shouldShow={true} />
+ <FloatingButton
+ title="Clear all trash"
+ onPress={onPressFloatingButton}
+ shouldShow={true}
+ />
) : null}
</DelayLayout>
);
diff --git a/apps/mobile/app/services/backup.js b/apps/mobile/app/services/backup.js
index 1fd971ffb..e6bf35d69 100644
--- a/apps/mobile/app/services/backup.js
+++ b/apps/mobile/app/services/backup.js
@@ -1,16 +1,16 @@
-import { Platform } from 'react-native';
-import FileViewer from 'react-native-file-viewer';
-import * as ScopedStorage from 'react-native-scoped-storage';
-import Share from 'react-native-share';
-import RNFetchBlob from 'rn-fetch-blob';
-import { presentDialog } from '../components/dialog/functions';
-import { db } from '../common/database';
-import storage from '../common/database/storage';
-import { eCloseProgressDialog } from '../utils/events';
-import { sanitizeFilename } from '../utils/sanitizer';
-import { sleep } from '../utils/time';
-import { eSendEvent, presentSheet, ToastEvent } from './event-manager';
-import SettingsService from './settings';
+import { Platform } from "react-native";
+import FileViewer from "react-native-file-viewer";
+import * as ScopedStorage from "react-native-scoped-storage";
+import Share from "react-native-share";
+import RNFetchBlob from "rn-fetch-blob";
+import { presentDialog } from "../components/dialog/functions";
+import { db } from "../common/database";
+import storage from "../common/database/storage";
+import { eCloseProgressDialog } from "../utils/events";
+import { sanitizeFilename } from "../utils/sanitizer";
+import { sleep } from "../utils/time";
+import { eSendEvent, presentSheet, ToastEvent } from "./event-manager";
+import SettingsService from "./settings";
const MS_DAY = 86400000;
const MS_WEEK = MS_DAY * 7;
@@ -20,16 +20,19 @@ async function getDirectoryAndroid() {
let folder = await ScopedStorage.openDocumentTree(true);
if (!folder) return null;
let subfolder;
- if (!folder.name.includes('Notesnook backups')) {
+ if (!folder.name.includes("Notesnook backups")) {
let folderFiles = await ScopedStorage.listFiles(folder.uri);
for (let f of folderFiles) {
- if (f.type === 'directory' && f.name === 'Notesnook backups') {
- console.log('folder already exists. reusing');
+ if (f.type === "directory" && f.name === "Notesnook backups") {
+ console.log("folder already exists. reusing");
subfolder = f;
}
}
if (!subfolder) {
- subfolder = await ScopedStorage.createDirectory(folder.uri, 'Notesnook backups');
+ subfolder = await ScopedStorage.createDirectory(
+ folder.uri,
+ "Notesnook backups"
+ );
}
} else {
subfolder = folder;
@@ -40,13 +43,13 @@ async function getDirectoryAndroid() {
return subfolder;
}
-async function checkBackupDirExists(reset = false, context = 'global') {
- if (Platform.OS === 'ios') return true;
+async function checkBackupDirExists(reset = false, context = "global") {
+ if (Platform.OS === "ios") return true;
let dir = SettingsService.get().backupDirectoryAndroid;
if (reset) dir = null;
if (dir) {
let allDirs = await ScopedStorage.getPersistedUriPermissions();
- let exists = allDirs.findIndex(d => {
+ let exists = allDirs.findIndex((d) => {
return d === dir.uri || dir.uri.includes(d);
});
exists = exists !== -1;
@@ -54,21 +57,22 @@ async function checkBackupDirExists(reset = false, context = 'global') {
}
if (!dir) {
// eslint-disable-next-line no-async-promise-executor
- dir = await new Promise(async resolve => {
+ dir = await new Promise(async (resolve) => {
if (reset) {
resolve(await getDirectoryAndroid());
return;
}
presentDialog({
- title: 'Select backup folder',
- paragraph: 'Please select a folder where you would like to store backup files.',
+ title: "Select backup folder",
+ paragraph:
+ "Please select a folder where you would like to store backup files.",
positivePress: async () => {
resolve(await getDirectoryAndroid());
},
onClose: () => {
resolve(null);
},
- positiveText: 'Select',
+ positiveText: "Select",
context: context
});
});
@@ -79,21 +83,21 @@ async function checkBackupDirExists(reset = false, context = 'global') {
async function presentBackupCompleteSheet(backupFilePath) {
presentSheet({
- title: 'Backup complete',
- icon: 'cloud-upload',
+ title: "Backup complete",
+ icon: "cloud-upload",
paragraph: `${
- Platform.OS === 'android'
+ Platform.OS === "android"
? 'Backup file saved in "Notesnook backups" folder on your phone'
- : 'Backup file is saved in File Manager/Notesnook folder'
+ : "Backup file is saved in File Manager/Notesnook folder"
}. Share your backup to your cloud so you do not lose it.`,
- actionText: 'Share backup',
+ actionText: "Share backup",
actionsArray: [
{
action: () => {
- if (Platform.OS === 'ios') {
+ if (Platform.OS === "ios") {
console.log(backupFilePath);
Share.open({
- url: 'file:/' + backupFilePath,
+ url: "file:/" + backupFilePath,
failOnCancel: false
}).catch(console.log);
} else {
@@ -104,7 +108,7 @@ async function presentBackupCompleteSheet(backupFilePath) {
}).catch(console.log);
}
},
- actionText: 'Share'
+ actionText: "Share"
},
{
action: async () => {
@@ -113,8 +117,8 @@ async function presentBackupCompleteSheet(backupFilePath) {
showBackupCompleteSheet: false
});
},
- actionText: 'Never ask again',
- type: 'grayBg'
+ actionText: "Never ask again",
+ type: "grayBg"
}
]
});
@@ -135,39 +139,44 @@ async function run(progress, context) {
if (progress) {
presentSheet({
- title: 'Backing up your data',
- paragraph: "All your backups are stored in 'Phone Storage/Notesnook/backups/' folder",
+ title: "Backing up your data",
+ paragraph:
+ "All your backups are stored in 'Phone Storage/Notesnook/backups/' folder",
progress: true
});
}
try {
- backup = await db.backup.export('mobile', SettingsService.get().encryptedBackup);
+ backup = await db.backup.export(
+ "mobile",
+ SettingsService.get().encryptedBackup
+ );
if (!backup) throw new Error(`Backup returned empty.`);
} catch (e) {
await sleep(300);
eSendEvent(eCloseProgressDialog);
- ToastEvent.error(e, 'Backup failed!');
+ ToastEvent.error(e, "Backup failed!");
return null;
}
try {
- let backupName = 'notesnook_backup_' + Date.now();
- backupName = sanitizeFilename(backupName, { replacement: '_' }) + '.nnbackup';
+ let backupName = "notesnook_backup_" + Date.now();
+ backupName =
+ sanitizeFilename(backupName, { replacement: "_" }) + ".nnbackup";
let path;
let backupFilePath;
- if (Platform.OS === 'ios') {
- path = await storage.checkAndCreateDir('/backups/');
- await RNFetchBlob.fs.writeFile(path + backupName, backup, 'utf8');
+ if (Platform.OS === "ios") {
+ path = await storage.checkAndCreateDir("/backups/");
+ await RNFetchBlob.fs.writeFile(path + backupName, backup, "utf8");
backupFilePath = path + backupName;
} else {
backupFilePath = await ScopedStorage.writeFile(
androidBackupDirectory.uri,
backup,
backupName,
- 'nnbackup/json',
- 'utf8',
+ "nnbackup/json",
+ "utf8",
false
);
}
@@ -175,10 +184,10 @@ async function run(progress, context) {
updateNextBackupTime();
ToastEvent.show({
- heading: 'Backup successful',
- message: 'Your backup is stored in Notesnook folder on your phone.',
- type: 'success',
- context: 'global'
+ heading: "Backup successful",
+ message: "Your backup is stored in Notesnook folder on your phone.",
+ type: "success",
+ context: "global"
});
let showBackupCompleteSheet = SettingsService.get().showBackupCompleteSheet;
@@ -193,7 +202,7 @@ async function run(progress, context) {
return backupFilePath;
} catch (e) {
progress && eSendEvent(eCloseProgressDialog);
- ToastEvent.error(e, 'Backup failed!');
+ ToastEvent.error(e, "Backup failed!");
return null;
}
}
@@ -203,24 +212,24 @@ async function getLastBackupDate() {
}
async function checkBackupRequired(type) {
- if (type === 'off' || type === 'useroff') return;
+ if (type === "off" || type === "useroff") return;
let now = Date.now();
let lastBackupDate = await getLastBackupDate();
- if (!lastBackupDate || lastBackupDate === 'never') {
+ if (!lastBackupDate || lastBackupDate === "never") {
return true;
}
lastBackupDate = parseInt(lastBackupDate);
- if (type === 'daily' && lastBackupDate + MS_DAY < now) {
- console.log('daily backup started');
+ if (type === "daily" && lastBackupDate + MS_DAY < now) {
+ console.log("daily backup started");
return true;
- } else if (type === 'weekly' && lastBackupDate + MS_WEEK < now) {
- console.log('weekly backup started');
+ } else if (type === "weekly" && lastBackupDate + MS_WEEK < now) {
+ console.log("weekly backup started");
return true;
- } else if (type === 'monthly' && lastBackupDate + MONTH < now) {
- console.log('monthly backup started');
+ } else if (type === "monthly" && lastBackupDate + MONTH < now) {
+ console.log("monthly backup started");
return true;
}
- console.log('no need', lastBackupDate);
+ console.log("no need", lastBackupDate);
return false;
}
diff --git a/apps/mobile/app/services/biometrics.ts b/apps/mobile/app/services/biometrics.ts
index c8de5390c..4e98dd763 100644
--- a/apps/mobile/app/services/biometrics.ts
+++ b/apps/mobile/app/services/biometrics.ts
@@ -1,10 +1,10 @@
-import { Platform } from 'react-native';
-import FingerprintScanner from 'react-native-fingerprint-scanner';
-import * as Keychain from 'react-native-keychain';
-import { useSettingStore } from '../stores/use-setting-store';
-import { MMKV } from '../common/database/mmkv';
-import Storage from '../common/database/storage';
-import { ShowToastEvent, ToastEvent } from './event-manager';
+import { Platform } from "react-native";
+import FingerprintScanner from "react-native-fingerprint-scanner";
+import * as Keychain from "react-native-keychain";
+import { useSettingStore } from "../stores/use-setting-store";
+import { MMKV } from "../common/database/mmkv";
+import Storage from "../common/database/storage";
+import { ShowToastEvent, ToastEvent } from "./event-manager";
const KeychainConfig = Platform.select({
ios: {
@@ -23,23 +23,28 @@ async function isBiometryAvailable() {
async function enableFingerprintAuth() {
if (!isBiometryAvailable()) return;
- await Storage.write('fingerprintAuthEnabled', 'enabled');
+ await Storage.write("fingerprintAuthEnabled", "enabled");
}
async function isFingerprintAuthEnabled() {
- return await MMKV.getStringAsync('fingerprintAuthEnabled');
+ return await MMKV.getStringAsync("fingerprintAuthEnabled");
}
async function storeCredentials(password: string) {
- await Keychain.setInternetCredentials('nn_vault', 'notesnookvault', password, KeychainConfig);
+ await Keychain.setInternetCredentials(
+ "nn_vault",
+ "notesnookvault",
+ password,
+ KeychainConfig
+ );
}
async function resetCredentials() {
- return await Keychain.resetInternetCredentials('nn_vault');
+ return await Keychain.resetInternetCredentials("nn_vault");
}
async function hasInternetCredentials() {
- return await Keychain.hasInternetCredentials('nn_vault');
+ return await Keychain.hasInternetCredentials("nn_vault");
}
async function getCredentials(title?: string, description?: string) {
@@ -63,31 +68,31 @@ async function getCredentials(title?: string, description?: string) {
useSettingStore.getState().setRequestBiometrics(false);
}, 1000);
FingerprintScanner.release();
- return await Keychain.getInternetCredentials('nn_vault');
+ return await Keychain.getInternetCredentials("nn_vault");
} catch (e) {
useSettingStore.getState().setRequestBiometrics(false);
FingerprintScanner.release();
let message: ShowToastEvent = {
- heading: 'Authentication with biometrics failed.',
+ heading: "Authentication with biometrics failed.",
message: 'Tap "Biometric Unlock" to try again.',
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
};
//@ts-ignore
- if (e.name === 'DeviceLocked') {
+ if (e.name === "DeviceLocked") {
message = {
- heading: 'Biometrics authentication failed.',
- message: 'Wait 30 seconds to try again.',
- type: 'error',
- context: 'local'
+ heading: "Biometrics authentication failed.",
+ message: "Wait 30 seconds to try again.",
+ type: "error",
+ context: "local"
};
//@ts-ignore
- } else if (e.name === 'UserFallback') {
+ } else if (e.name === "UserFallback") {
message = {
- heading: 'Authentication cancelled by user.',
+ heading: "Authentication cancelled by user.",
message: 'Tap "Biometric Unlock" to try again.',
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
};
}
@@ -117,19 +122,19 @@ async function validateUser(title: string, description?: string) {
} catch (e) {
FingerprintScanner.release();
//@ts-ignore
- if (e.name === 'DeviceLocked') {
+ if (e.name === "DeviceLocked") {
ToastEvent.show({
- heading: 'Biometrics authentication failed.',
- message: 'Wait 30 seconds to try again.',
- type: 'error',
- context: 'local'
+ heading: "Biometrics authentication failed.",
+ message: "Wait 30 seconds to try again.",
+ type: "error",
+ context: "local"
});
} else {
ToastEvent.show({
- heading: 'Authentication failed.',
- message: 'Tap to try again.',
- type: 'error',
- context: 'local'
+ heading: "Authentication failed.",
+ message: "Tap to try again.",
+ type: "error",
+ context: "local"
});
}
return false;
diff --git a/apps/mobile/app/services/device-detection.js b/apps/mobile/app/services/device-detection.js
index c13735b97..76691c398 100644
--- a/apps/mobile/app/services/device-detection.js
+++ b/apps/mobile/app/services/device-detection.js
@@ -1,7 +1,7 @@
-import { Dimensions, PixelRatio, Platform } from 'react-native';
-import DeviceInfo from 'react-native-device-info';
+import { Dimensions, PixelRatio, Platform } from "react-native";
+import DeviceInfo from "react-native-device-info";
-let windowSize = Dimensions.get('window');
+let windowSize = Dimensions.get("window");
export class DeviceDetectionService {
constructor() {
@@ -9,7 +9,7 @@ export class DeviceDetectionService {
}
setNewValues() {
- windowSize = Dimensions.get('window');
+ windowSize = Dimensions.get("window");
this.pixelDensity = PixelRatio.get();
this.width = windowSize.width;
this.height = windowSize.height;
@@ -30,7 +30,7 @@ export class DeviceDetectionService {
this.isPhoneOrTablet();
this.isIosOrAndroid();
this.detectIphoneX();
- this.checkSmallTab(size.width > size.height ? 'LANDSCAPE' : 'PORTRAIT');
+ this.checkSmallTab(size.width > size.height ? "LANDSCAPE" : "PORTRAIT");
}
getDeviceSize = () => {
@@ -44,18 +44,22 @@ export class DeviceDetectionService {
};
checkSmallTab(orientation) {
- this.width = Dimensions.get('screen').width;
- this.height = Dimensions.get('screen').height;
+ this.width = Dimensions.get("screen").width;
+ this.height = Dimensions.get("screen").height;
let deviceSize = this.getDeviceSize();
if (
- (!DeviceInfo.isTablet() && orientation === 'LANDSCAPE') ||
- (DeviceInfo.isTablet() && (orientation === 'PORTRAIT' || deviceSize < 9))
+ (!DeviceInfo.isTablet() && orientation === "LANDSCAPE") ||
+ (DeviceInfo.isTablet() && (orientation === "PORTRAIT" || deviceSize < 9))
) {
this.isTab = true;
this.isPhone = false;
this.isSmallTab = true;
- } else if (DeviceInfo.isTablet() && orientation === 'LANDSCAPE' && deviceSize > 9) {
+ } else if (
+ DeviceInfo.isTablet() &&
+ orientation === "LANDSCAPE" &&
+ deviceSize > 9
+ ) {
this.isTab = true;
this.isPhone = false;
this.isSmallTab = false;
@@ -83,7 +87,7 @@ export class DeviceDetectionService {
}
isIosOrAndroid() {
- if (Platform.OS === 'ios') {
+ if (Platform.OS === "ios") {
this.isIos = true;
this.isAndroid = false;
} else {
@@ -94,7 +98,7 @@ export class DeviceDetectionService {
detectIphoneX() {
this.isIphoneX =
- Platform.OS === 'ios' &&
+ Platform.OS === "ios" &&
!Platform.isTVOS &&
!Platform.isTVOS &&
(windowSize.height === 812 || windowSize.width === 812);
diff --git a/apps/mobile/app/services/event-manager.ts b/apps/mobile/app/services/event-manager.ts
index 46517ace5..b7b831023 100644
--- a/apps/mobile/app/services/event-manager.ts
+++ b/apps/mobile/app/services/event-manager.ts
@@ -1,23 +1,29 @@
-import Clipboard from '@react-native-clipboard/clipboard';
-import EventManager from '@streetwriters/notesnook-core/utils/event-manager';
-import { RefObject } from 'react';
-import ActionSheet from 'react-native-actions-sheet';
-import { Config } from 'react-native-config';
+import Clipboard from "@react-native-clipboard/clipboard";
+import EventManager from "@streetwriters/notesnook-core/utils/event-manager";
+import { RefObject } from "react";
+import ActionSheet from "react-native-actions-sheet";
+import { Config } from "react-native-config";
import {
eHideToast,
eOnNoteEdited,
eOpenProgressDialog,
eOpenVaultDialog,
eShowToast
-} from '../utils/events';
+} from "../utils/events";
const eventManager = new EventManager();
-export const eSubscribeEvent = (eventName: string, action?: (data: any) => void) => {
+export const eSubscribeEvent = (
+ eventName: string,
+ action?: (data: any) => void
+) => {
eventManager.subscribe(eventName, action);
};
-export const eUnSubscribeEvent = (eventName: string, action?: (data: any) => void) => {
+export const eUnSubscribeEvent = (
+ eventName: string,
+ action?: (data: any) => void
+) => {
eventManager.unsubscribe(eventName, action);
};
@@ -70,7 +76,9 @@ type SheetAction = {
export type PresentSheetOptions = {
context: string;
- component: JSX.Element | ((ref: RefObject<ActionSheet>, close?: () => void) => JSX.Element);
+ component:
+ | JSX.Element
+ | ((ref: RefObject<ActionSheet>, close?: () => void) => JSX.Element);
disableClosing: boolean;
onClose: () => void;
progress: boolean;
@@ -93,8 +101,8 @@ export function presentSheet(data: Partial<PresentSheetOptions>) {
export type ShowToastEvent = {
heading?: string;
message?: string;
- context?: 'global' | 'local';
- type?: 'error' | 'success';
+ context?: "global" | "local";
+ type?: "error" | "success";
duration?: number;
func?: () => void;
actionText?: string;
@@ -104,8 +112,8 @@ export const ToastEvent = {
show: ({
heading,
message,
- type = 'error',
- context = 'global',
+ type = "error",
+ context = "global",
duration = 3000,
func,
actionText
@@ -122,20 +130,20 @@ export const ToastEvent = {
});
},
hide: () => eSendEvent(eHideToast),
- error: (e: Error, title?: string, context?: 'global' | 'local') => {
+ error: (e: Error, title?: string, context?: "global" | "local") => {
ToastEvent.show({
heading: title,
- message: e?.message || '',
- type: 'error',
- context: context || 'global',
- actionText: 'Copy logs',
+ message: e?.message || "",
+ type: "error",
+ context: context || "global",
+ actionText: "Copy logs",
duration: 6000,
func: () => {
- Clipboard.setString(e?.stack || '');
+ Clipboard.setString(e?.stack || "");
ToastEvent.show({
- heading: 'Logs copied!',
- type: 'success',
- context: 'global',
+ heading: "Logs copied!",
+ type: "success",
+ context: "global",
duration: 5000
});
}
diff --git a/apps/mobile/app/services/exporter.js b/apps/mobile/app/services/exporter.js
index a8a231ce0..1a747cebc 100644
--- a/apps/mobile/app/services/exporter.js
+++ b/apps/mobile/app/services/exporter.js
@@ -1,12 +1,12 @@
-import { decode, EntityLevel } from 'entities';
-import { Platform } from 'react-native';
-import RNHTMLtoPDF from 'react-native-html-to-pdf-lite';
-import * as ScopedStorage from 'react-native-scoped-storage';
-import RNFetchBlob from 'rn-fetch-blob';
-import { toTXT } from '../utils';
-import { sanitizeFilename } from '../utils/sanitizer';
-import Storage from '../common/database/storage';
-import db from '../common/database';
+import { decode, EntityLevel } from "entities";
+import { Platform } from "react-native";
+import RNHTMLtoPDF from "react-native-html-to-pdf-lite";
+import * as ScopedStorage from "react-native-scoped-storage";
+import RNFetchBlob from "rn-fetch-blob";
+import { toTXT } from "../utils";
+import { sanitizeFilename } from "../utils/sanitizer";
+import Storage from "../common/database/storage";
+import db from "../common/database";
const defaultStyle = `<style>
.img_size_one {
@@ -197,8 +197,8 @@ table[data-mce-selected]
table[data-mce-selected]
tr[data-mce-active]
th:not([data-mce-active]) {
- border-bottom: 1px solid ${'#008837' + 'B3'} !important;
- border-top: 1px solid ${'#008837' + 'B3'} !important;
+ border-bottom: 1px solid ${"#008837" + "B3"} !important;
+ border-top: 1px solid ${"#008837" + "B3"} !important;
}
table[data-mce-selected]
@@ -207,7 +207,7 @@ table[data-mce-selected]
table[data-mce-selected]
tr[data-mce-active]
th:not([data-mce-active]):first-child {
- border-left: 1px solid ${'#008837' + 'B3'} !important;
+ border-left: 1px solid ${"#008837" + "B3"} !important;
}
table[data-mce-selected]
@@ -216,12 +216,12 @@ table[data-mce-selected]
table[data-mce-selected]
tr[data-mce-active]
th:not([data-mce-active]):last-child {
- border-right: 1px solid ${'#008837' + 'B3'} !important;
+ border-right: 1px solid ${"#008837" + "B3"} !important;
}
table[data-mce-selected] td[data-mce-active],
table[data-mce-selected] th[data-mce-active] {
- border: 2px solid ${'#008837' + 'B3'} !important;
+ border: 2px solid ${"#008837" + "B3"} !important;
background-color: #00883712;
}
@@ -322,49 +322,51 @@ async function releasePermissions(path) {
}
async function saveToPDF(note) {
- let androidSavePath = '/Notesnook/exported/PDF';
- if (Platform.OS === 'android') {
+ let androidSavePath = "/Notesnook/exported/PDF";
+ if (Platform.OS === "android") {
let file = await ScopedStorage.openDocumentTree(true);
if (!file) return;
androidSavePath = file.uri;
}
- Platform.OS === 'ios' && (await Storage.checkAndCreateDir('/exported/PDF/'));
+ Platform.OS === "ios" && (await Storage.checkAndCreateDir("/exported/PDF/"));
- let html = await db.notes.note(note).export('html');
+ let html = await db.notes.note(note).export("html");
html = decode(html, {
level: EntityLevel.HTML
});
- let fileName = sanitizeFilename(note.title + Date.now(), { replacement: '_' });
+ let fileName = sanitizeFilename(note.title + Date.now(), {
+ replacement: "_"
+ });
let html3 = html;
- if (html.indexOf('<head>') > -1) {
- let html1 = html.substring(0, html.indexOf('<head>') + 6);
- let html2 = html.substring(html.indexOf('<head>') + 6);
+ if (html.indexOf("<head>") > -1) {
+ let html1 = html.substring(0, html.indexOf("<head>") + 6);
+ let html2 = html.substring(html.indexOf("<head>") + 6);
html3 = html1 + defaultStyle + html2;
}
let options = {
html: html3,
- fileName: Platform.OS === 'ios' ? '/exported/PDF/' + fileName : fileName,
+ fileName: Platform.OS === "ios" ? "/exported/PDF/" + fileName : fileName,
width: 595,
height: 852,
- bgColor: '#FFFFFF',
+ bgColor: "#FFFFFF",
padding: 30,
- base64: Platform.OS === 'android'
+ base64: Platform.OS === "android"
};
- if (Platform.OS === 'ios') {
- options.directory = 'Documents';
+ if (Platform.OS === "ios") {
+ options.directory = "Documents";
}
let res = await RNHTMLtoPDF.convert(options);
let fileUri;
- if (Platform.OS === 'android') {
+ if (Platform.OS === "android") {
fileUri = await ScopedStorage.writeFile(
androidSavePath,
res.base64,
fileName,
- 'application/pdf',
- 'base64',
+ "application/pdf",
+ "base64",
false
);
@@ -377,119 +379,131 @@ async function saveToPDF(note) {
return {
filePath: fileUri || res.filePath,
- type: 'application/pdf',
- name: 'PDF',
+ type: "application/pdf",
+ name: "PDF",
fileName: fileName
};
}
async function saveToMarkdown(note) {
- let path = Platform.OS === 'ios' && (await Storage.checkAndCreateDir('/exported/Markdown/'));
- if (Platform.OS === 'android') {
+ let path =
+ Platform.OS === "ios" &&
+ (await Storage.checkAndCreateDir("/exported/Markdown/"));
+ if (Platform.OS === "android") {
let file = await ScopedStorage.openDocumentTree(true);
if (!file) return;
path = file.uri;
}
- let markdown = await db.notes.note(note.id).export('md');
- let fileName = sanitizeFilename(note.title + Date.now(), { replacement: '_' });
+ let markdown = await db.notes.note(note.id).export("md");
+ let fileName = sanitizeFilename(note.title + Date.now(), {
+ replacement: "_"
+ });
let fileUri;
- if (Platform.OS === 'android') {
+ if (Platform.OS === "android") {
fileUri = await ScopedStorage.writeFile(
path,
markdown,
- fileName + '.md',
- 'text/markdown',
- 'utf8',
+ fileName + ".md",
+ "text/markdown",
+ "utf8",
false
);
await releasePermissions(path);
} else {
- path = path + fileName + '.md';
- await RNFetchBlob.fs.writeFile(path, markdown, 'utf8');
+ path = path + fileName + ".md";
+ await RNFetchBlob.fs.writeFile(path, markdown, "utf8");
}
return {
filePath: fileUri || path,
- type: 'text/markdown',
- name: 'Markdown',
+ type: "text/markdown",
+ name: "Markdown",
fileName: fileName
};
}
async function saveToText(note) {
- let path = Platform.OS === 'ios' && (await Storage.checkAndCreateDir('/exported/Text/'));
- if (Platform.OS === 'android') {
+ let path =
+ Platform.OS === "ios" &&
+ (await Storage.checkAndCreateDir("/exported/Text/"));
+ if (Platform.OS === "android") {
let file = await ScopedStorage.openDocumentTree(true);
if (!file) return;
path = file.uri;
}
let text = await toTXT(note);
- let fileName = sanitizeFilename(note.title + Date.now(), { replacement: '_' });
+ let fileName = sanitizeFilename(note.title + Date.now(), {
+ replacement: "_"
+ });
let fileUri;
- if (Platform.OS === 'android') {
+ if (Platform.OS === "android") {
fileUri = await ScopedStorage.writeFile(
path,
text,
- fileName + '.txt',
- 'text/plain',
- 'utf8',
+ fileName + ".txt",
+ "text/plain",
+ "utf8",
false
);
await releasePermissions(path);
} else {
- path = path + fileName + '.txt';
- await RNFetchBlob.fs.writeFile(path, text, 'utf8');
+ path = path + fileName + ".txt";
+ await RNFetchBlob.fs.writeFile(path, text, "utf8");
}
return {
filePath: fileUri || path,
- type: 'text/plain',
- name: 'Text',
+ type: "text/plain",
+ name: "Text",
fileName: fileName
};
}
async function saveToHTML(note) {
- let path = Platform.OS === 'ios' && (await Storage.checkAndCreateDir('/exported/Html/'));
- if (Platform.OS === 'android') {
+ let path =
+ Platform.OS === "ios" &&
+ (await Storage.checkAndCreateDir("/exported/Html/"));
+ if (Platform.OS === "android") {
let file = await ScopedStorage.openDocumentTree(true);
if (!file) return;
path = file.uri;
}
- let html = await db.notes.note(note.id).export('html');
- let fileName = sanitizeFilename(note.title + Date.now(), { replacement: '_' });
+ let html = await db.notes.note(note.id).export("html");
+ let fileName = sanitizeFilename(note.title + Date.now(), {
+ replacement: "_"
+ });
let html3 = html;
- if (html.indexOf('<head>') > -1) {
- let html1 = html.substring(0, html.indexOf('<head>') + 6);
- let html2 = html.substring(html.indexOf('<head>') + 6);
+ if (html.indexOf("<head>") > -1) {
+ let html1 = html.substring(0, html.indexOf("<head>") + 6);
+ let html2 = html.substring(html.indexOf("<head>") + 6);
html3 = html1 + defaultStyle + html2;
}
let fileUri;
- if (Platform.OS === 'android') {
+ if (Platform.OS === "android") {
fileUri = await ScopedStorage.writeFile(
path,
html3,
- fileName + '.html',
- 'text/html',
- 'utf8',
+ fileName + ".html",
+ "text/html",
+ "utf8",
false
);
await releasePermissions(path);
} else {
- path = path + fileName + '.html';
- await RNFetchBlob.fs.writeFile(path, html3, 'utf8');
+ path = path + fileName + ".html";
+ await RNFetchBlob.fs.writeFile(path, html3, "utf8");
}
return {
filePath: fileUri || path,
- type: 'text/html',
- name: 'Html',
+ type: "text/html",
+ name: "Html",
fileName: fileName
};
}
diff --git a/apps/mobile/app/services/message.js b/apps/mobile/app/services/message.js
index de7d56fae..0f965f701 100644
--- a/apps/mobile/app/services/message.js
+++ b/apps/mobile/app/services/message.js
@@ -1,23 +1,29 @@
-import { useMessageStore } from '../stores/use-message-store';
-import { eOpenLoginDialog, eOpenRateDialog, eOpenRecoveryKeyDialog } from '../utils/events';
-import { eSendEvent } from './event-manager';
-import PremiumService from './premium';
-import { verifyUser } from '../screens/settings/functions';
-import { MMKV } from '../common/database/mmkv';
-import { Platform } from 'react-native';
-import umami from '../common/analytics';
-import SettingsService from './settings';
+import { useMessageStore } from "../stores/use-message-store";
+import {
+ eOpenLoginDialog,
+ eOpenRateDialog,
+ eOpenRecoveryKeyDialog
+} from "../utils/events";
+import { eSendEvent } from "./event-manager";
+import PremiumService from "./premium";
+import { verifyUser } from "../screens/settings/functions";
+import { MMKV } from "../common/database/mmkv";
+import { Platform } from "react-native";
+import umami from "../common/analytics";
+import SettingsService from "./settings";
const rateAppMessage = {
visible: true,
- message: 'We would love to know what you think',
- actionText: 'Rate Notesnook on ' + `${Platform.OS === 'ios' ? 'App store' : 'Play store'}`,
+ message: "We would love to know what you think",
+ actionText:
+ "Rate Notesnook on " +
+ `${Platform.OS === "ios" ? "App store" : "Play store"}`,
onPress: () => {
eSendEvent(eOpenRateDialog);
},
data: {},
- icon: 'star',
- type: 'normal'
+ icon: "star",
+ type: "normal"
};
export function setRateAppMessage() {
@@ -26,8 +32,8 @@ export function setRateAppMessage() {
const recoveryKeyMessage = {
visible: true,
- message: 'Keep your data safe if you lose password',
- actionText: 'Save your account recovery key',
+ message: "Keep your data safe if you lose password",
+ actionText: "Save your account recovery key",
onPress: () => {
verifyUser(
null,
@@ -41,12 +47,12 @@ const recoveryKeyMessage = {
});
clearMessage();
},
- 'I have saved my key already'
+ "I have saved my key already"
);
},
data: {},
- icon: 'key',
- type: 'normal'
+ icon: "key",
+ type: "normal"
};
export function setRecoveryKeyMessage() {
@@ -55,15 +61,15 @@ export function setRecoveryKeyMessage() {
const loginMessage = {
visible: true,
- message: 'You are not logged in',
- actionText: 'Login to encrypt and sync notes',
+ message: "You are not logged in",
+ actionText: "Login to encrypt and sync notes",
onPress: () => {
- umami.pageView('/signup', '/welcome/home');
+ umami.pageView("/signup", "/welcome/home");
eSendEvent(eOpenLoginDialog);
},
data: {},
- icon: 'account-outline',
- type: 'normal'
+ icon: "account-outline",
+ type: "normal"
};
export function setLoginMessage() {
@@ -72,14 +78,14 @@ export function setLoginMessage() {
const emailMessage = {
visible: true,
- message: 'Email not confirmed',
- actionText: 'Please confirm your email to sync notes.',
+ message: "Email not confirmed",
+ actionText: "Please confirm your email to sync notes.",
onPress: () => {
PremiumService.showVerifyEmailDialog();
},
data: {},
- icon: 'email',
- type: 'error'
+ icon: "email",
+ type: "error"
};
export function setEmailVerifyMessage() {
@@ -88,11 +94,11 @@ export function setEmailVerifyMessage() {
const noMessage = {
visible: false,
- message: '',
- actionText: '',
+ message: "",
+ actionText: "",
onPress: null,
data: {},
- icon: 'account-outline'
+ icon: "account-outline"
};
export function clearMessage() {
diff --git a/apps/mobile/app/services/navigation.ts b/apps/mobile/app/services/navigation.ts
index 3ba40a78f..f2ac752a6 100755
--- a/apps/mobile/app/services/navigation.ts
+++ b/apps/mobile/app/services/navigation.ts
@@ -1,16 +1,20 @@
-import { StackActions } from '@react-navigation/native';
-import { NativeStackScreenProps } from '@react-navigation/native-stack';
-import { useFavoriteStore } from '../stores/use-favorite-store';
-import useNavigationStore, { CurrentScreen, Route, RouteName } from '../stores/use-navigation-store';
-import { useNotebookStore } from '../stores/use-notebook-store';
-import { useNoteStore } from '../stores/use-notes-store';
-import { useTagStore } from '../stores/use-tag-store';
-import { useTrashStore } from '../stores/use-trash-store';
-import { eOnNewTopicAdded } from '../utils/events';
-import { rootNavigatorRef, tabBarRef } from '../utils/global-refs';
-import { ColorType, NotebookType, TagType, TopicType } from '../utils/types';
-import { eSendEvent } from './event-manager';
-import SettingsService from './settings';
+import { StackActions } from "@react-navigation/native";
+import { NativeStackScreenProps } from "@react-navigation/native-stack";
+import { useFavoriteStore } from "../stores/use-favorite-store";
+import useNavigationStore, {
+ CurrentScreen,
+ Route,
+ RouteName
+} from "../stores/use-navigation-store";
+import { useNotebookStore } from "../stores/use-notebook-store";
+import { useNoteStore } from "../stores/use-notes-store";
+import { useTagStore } from "../stores/use-tag-store";
+import { useTrashStore } from "../stores/use-trash-store";
+import { eOnNewTopicAdded } from "../utils/events";
+import { rootNavigatorRef, tabBarRef } from "../utils/global-refs";
+import { ColorType, NotebookType, TagType, TopicType } from "../utils/types";
+import { eSendEvent } from "./event-manager";
+import SettingsService from "./settings";
/**
* Routes that should be updated on focus
@@ -18,25 +22,25 @@ import SettingsService from './settings';
let routesUpdateQueue: Route[] = [];
const routeNames = {
- Notes: 'Notes',
- Notebooks: 'Notebooks',
- Notebook: 'Notebook',
- NotesPage: 'NotesPage',
- Tags: 'Tags',
- Favorites: 'Favorites',
- Trash: 'Trash',
- Search: 'Search',
- Settings: 'Settings',
- TaggedNotes: 'TaggedNotes',
- ColoredNotes: 'ColoredNotes',
- TopicNotes: 'TopicNotes',
- Monographs: 'Monographs',
- Auth: 'Auth',
- Intro: 'Intro',
- Welcome: 'Welcome',
- AppLock: 'AppLock',
- Login: 'Login',
- Signup: 'Signup'
+ Notes: "Notes",
+ Notebooks: "Notebooks",
+ Notebook: "Notebook",
+ NotesPage: "NotesPage",
+ Tags: "Tags",
+ Favorites: "Favorites",
+ Trash: "Trash",
+ Search: "Search",
+ Settings: "Settings",
+ TaggedNotes: "TaggedNotes",
+ ColoredNotes: "ColoredNotes",
+ TopicNotes: "TopicNotes",
+ Monographs: "Monographs",
+ Auth: "Auth",
+ Intro: "Intro",
+ Welcome: "Welcome",
+ AppLock: "AppLock",
+ Login: "Login",
+ Signup: "Signup"
};
type GenericRouteParam = { [name: string]: never };
@@ -79,7 +83,10 @@ export type RouteParams = {
Auth: AuthParams;
};
-export type NavigationProps<T extends RouteName> = NativeStackScreenProps<RouteParams, T>;
+export type NavigationProps<T extends RouteName> = NativeStackScreenProps<
+ RouteParams,
+ T
+>;
/**
* Functions to update each route when required.
@@ -90,12 +97,14 @@ const routeUpdateFunctions: { [name: string]: (...args: any[]) => void } = {
Tags: () => useTagStore.getState().setTags(),
Favorites: () => useFavoriteStore.getState().setFavorites(),
Trash: () => useTrashStore.getState().setTrash(),
- Notebook: (params: NotebookScreenParams) => eSendEvent(eOnNewTopicAdded, params),
- NotesPage: (params: NotesScreenParams) => eSendEvent('NotesPage', params),
- TaggedNotes: (params: NotesScreenParams) => eSendEvent('TaggedNotes', params),
- ColoredNotes: (params: NotesScreenParams) => eSendEvent('ColoredNotes', params),
- TopicNotes: (params: NotesScreenParams) => eSendEvent('TopicNotes', params),
- Monographs: (params: NotesScreenParams) => eSendEvent('Monographs', params)
+ Notebook: (params: NotebookScreenParams) =>
+ eSendEvent(eOnNewTopicAdded, params),
+ NotesPage: (params: NotesScreenParams) => eSendEvent("NotesPage", params),
+ TaggedNotes: (params: NotesScreenParams) => eSendEvent("TaggedNotes", params),
+ ColoredNotes: (params: NotesScreenParams) =>
+ eSendEvent("ColoredNotes", params),
+ TopicNotes: (params: NotesScreenParams) => eSendEvent("TopicNotes", params),
+ Monographs: (params: NotesScreenParams) => eSendEvent("Monographs", params)
};
function clearRouteFromQueue(routeName: Route) {
@@ -109,16 +118,20 @@ function clearRouteFromQueue(routeName: Route) {
* Check if a route needs update
*/
function routeNeedsUpdate(routeName: Route, callback: () => void) {
- console.log('routeNeedsUpdate', routesUpdateQueue, routesUpdateQueue.indexOf(routeName));
+ console.log(
+ "routeNeedsUpdate",
+ routesUpdateQueue,
+ routesUpdateQueue.indexOf(routeName)
+ );
if (routesUpdateQueue.indexOf(routeName) > -1) {
clearRouteFromQueue(routeName);
- console.log('CALL ROUTE UPDATE');
+ console.log("CALL ROUTE UPDATE");
callback();
}
}
function queueRoutesForUpdate(...routes: Route[]) {
- console.log('updating routes', routes);
+ console.log("updating routes", routes);
const currentScreen = useNavigationStore.getState().currentScreen;
// const routeHistory = rootNavigatorRef.current?.getRootState()?.routes || [
// { key: currentScreen.name }
@@ -131,7 +144,7 @@ function queueRoutesForUpdate(...routes: Route[]) {
// );
if (routes.indexOf(currentScreen.name) > -1) {
- console.log('updating current route');
+ console.log("updating current route");
routeUpdateFunctions[currentScreen.name]();
clearRouteFromQueue(currentScreen.name);
// Remove focused screen from queue
@@ -144,10 +157,13 @@ function queueRoutesForUpdate(...routes: Route[]) {
//console.log(routesUpdateQueue);
}
-function navigate<T extends RouteName>(screen: CurrentScreen, params: RouteParams[T]) {
+function navigate<T extends RouteName>(
+ screen: CurrentScreen,
+ params: RouteParams[T]
+) {
useNavigationStore.getState().update(screen, params?.canGoBack);
- if (screen.name === 'Notebook') routeUpdateFunctions['Notebook'](params);
- if (screen.name.endsWith('Notes') && screen.name !== 'Notes')
+ if (screen.name === "Notebook") routeUpdateFunctions["Notebook"](params);
+ if (screen.name.endsWith("Notes") && screen.name !== "Notes")
routeUpdateFunctions[screen.name](params);
//@ts-ignore
rootNavigatorRef.current?.navigate(screen.name, params);
@@ -163,7 +179,10 @@ function push(screen: CurrentScreen, params: { [name: string]: any }) {
rootNavigatorRef.current?.dispatch(StackActions.push(name, params));
}
-function replace<T extends RouteName>(screen: CurrentScreen, params: RouteParams[T]) {
+function replace<T extends RouteName>(
+ screen: CurrentScreen,
+ params: RouteParams[T]
+) {
useNavigationStore.getState().update(screen, params?.canGoBack);
//@ts-ignore
rootNavigatorRef.current?.dispatch(StackActions.replace(screen.name, params));
@@ -172,7 +191,7 @@ function replace<T extends RouteName>(screen: CurrentScreen, params: RouteParams
function popToTop() {
rootNavigatorRef.current?.dispatch(StackActions.popToTop());
useNavigationStore.getState().update({
- name: SettingsService.get().homepage || 'Notes'
+ name: SettingsService.get().homepage || "Notes"
});
}
diff --git a/apps/mobile/app/services/notifications.ts b/apps/mobile/app/services/notifications.ts
index 52bd9176d..d340f25a2 100644
--- a/apps/mobile/app/services/notifications.ts
+++ b/apps/mobile/app/services/notifications.ts
@@ -1,30 +1,30 @@
-import { Platform } from 'react-native';
+import { Platform } from "react-native";
import PushNotification, {
Importance,
PushNotificationDeliveredObject
-} from 'react-native-push-notification';
-import { editing } from '../utils';
-import { db } from '../common/database';
-import { MMKV } from '../common/database/mmkv';
-import { eOnLoadNote } from '../utils/events';
-import { tabBarRef } from '../utils/global-refs';
-import { useNoteStore } from '../stores/use-notes-store';
-import { DDS } from './device-detection';
-import { eSendEvent } from './event-manager';
-import SettingsService from './settings';
-import { editorState } from '../screens/editor/tiptap/utils';
+} from "react-native-push-notification";
+import { editing } from "../utils";
+import { db } from "../common/database";
+import { MMKV } from "../common/database/mmkv";
+import { eOnLoadNote } from "../utils/events";
+import { tabBarRef } from "../utils/global-refs";
+import { useNoteStore } from "../stores/use-notes-store";
+import { DDS } from "./device-detection";
+import { eSendEvent } from "./event-manager";
+import SettingsService from "./settings";
+import { editorState } from "../screens/editor/tiptap/utils";
-const NOTIFICATION_TAG = 'notesnook';
-const CHANNEL_ID = 'com.streetwriters.notesnook';
+const NOTIFICATION_TAG = "notesnook";
+const CHANNEL_ID = "com.streetwriters.notesnook";
let pinned: PushNotificationDeliveredObject[] = [];
function loadNote(id: string, jump: boolean) {
- if (!id || id === 'notesnook_note_input') return;
+ if (!id || id === "notesnook_note_input") return;
let note = db.notes?.note(id).data;
if (!DDS.isTab && jump) {
tabBarRef.current?.goToPage(1);
}
- eSendEvent('loadingNote', note);
+ eSendEvent("loadingNote", note);
setTimeout(() => {
eSendEvent(eOnLoadNote, note);
if (!jump && !DDS.isTab) {
@@ -34,11 +34,11 @@ function loadNote(id: string, jump: boolean) {
}
function init() {
- if (Platform.OS === 'ios') return;
+ if (Platform.OS === "ios") return;
PushNotification.configure({
onNotification: async function (notification) {
editorState().movedAway = false;
- MMKV.removeItem('appState');
+ MMKV.removeItem("appState");
if (useNoteStore?.getState()?.loading === false) {
//@ts-ignore
await db.init();
@@ -50,42 +50,42 @@ function init() {
}
let unsub = useNoteStore.subscribe(
- loading => {
+ (loading) => {
if (loading === false) {
//@ts-ignore
loadNote(notification.tag, true);
}
unsub();
},
- state => state.loading
+ (state) => state.loading
);
},
onAction: async function (notification) {
- console.log('ACTION: ', notification.action);
+ console.log("ACTION: ", notification.action);
switch (notification.action) {
- case 'UNPIN':
+ case "UNPIN":
//@ts-ignore
remove(notification.tag, notification.id);
break;
- case 'Hide':
+ case "Hide":
unpinQuickNote();
break;
- case 'ReplyInput':
- console.log('texto', notification);
+ case "ReplyInput":
+ console.log("texto", notification);
present({
- title: 'Quick note',
+ title: "Quick note",
message: 'Tap on "Take note" to add a note.',
ongoing: true,
- actions: ['ReplyInput', 'Hide'],
- tag: 'notesnook_note_input',
- reply_button_text: 'Take note',
- reply_placeholder_text: 'Write something...',
+ actions: ["ReplyInput", "Hide"],
+ tag: "notesnook_note_input",
+ reply_button_text: "Take note",
+ reply_placeholder_text: "Write something...",
id: 256266
});
await db.init();
await db.notes?.add({
content: {
- type: 'tiptap',
+ type: "tiptap",
//@ts-ignore
data: `<p>${notification.reply_text} </p>`
}
@@ -100,51 +100,54 @@ function init() {
},
popInitialNotification: true,
//@ts-ignore
- requestPermissions: Platform.OS === 'ios'
+ requestPermissions: Platform.OS === "ios"
});
PushNotification.createChannel(
{
channelId: CHANNEL_ID,
- channelName: 'Notesnook',
+ channelName: "Notesnook",
playSound: false,
- soundName: 'default',
+ soundName: "default",
importance: Importance.HIGH,
vibrate: true
},
- created => console.log(`createChannel returned '${created}'`)
+ (created) => console.log(`createChannel returned '${created}'`)
);
}
function remove(tag: string, id: string) {
- PushNotification.clearLocalNotification(tag || NOTIFICATION_TAG, parseInt(id));
+ PushNotification.clearLocalNotification(
+ tag || NOTIFICATION_TAG,
+ parseInt(id)
+ );
get().then(() => {
- eSendEvent('onUpdate', 'unpin');
+ eSendEvent("onUpdate", "unpin");
});
}
function pinQuickNote(launch: boolean) {
- get().then(items => {
- let notif = items.filter(i => i.tag === 'notesnook_note_input');
+ get().then((items) => {
+ let notif = items.filter((i) => i.tag === "notesnook_note_input");
if (notif && launch) {
return;
}
- console.log('showing');
+ console.log("showing");
present({
- title: 'Quick note',
+ title: "Quick note",
message: 'Tap on "Take note" to add a note.',
ongoing: true,
- actions: ['ReplyInput', 'Hide'],
- tag: 'notesnook_note_input',
- reply_button_text: 'Take note',
- reply_placeholder_text: 'Write something...',
+ actions: ["ReplyInput", "Hide"],
+ tag: "notesnook_note_input",
+ reply_button_text: "Take note",
+ reply_placeholder_text: "Write something...",
id: 256266
});
});
}
async function unpinQuickNote() {
- remove('notesnook_note_input', 256266 + '');
+ remove("notesnook_note_input", 256266 + "");
SettingsService.set({ notifNotes: false });
}
@@ -176,7 +179,7 @@ function present({
channelId: CHANNEL_ID,
tag: tag || NOTIFICATION_TAG,
ongoing: ongoing,
- visibility: 'private',
+ visibility: "private",
ignoreInForeground: false,
actions: actions,
title: title,
@@ -185,7 +188,7 @@ function present({
message: message,
invokeApp: false,
autoCancel: false,
- smallIcon: 'ic_stat_name',
+ smallIcon: "ic_stat_name",
//@ts-ignore
reply_placeholder_text,
reply_button_text
@@ -202,9 +205,9 @@ function getPinnedNotes(): PushNotificationDeliveredObject[] {
}
function get(): Promise<PushNotificationDeliveredObject[]> {
- return new Promise(resolve => {
- if (Platform.OS === 'ios') resolve([]);
- PushNotification.getDeliveredNotifications(n => {
+ return new Promise((resolve) => {
+ if (Platform.OS === "ios") resolve([]);
+ PushNotification.getDeliveredNotifications((n) => {
pinned = n;
resolve(n);
});
diff --git a/apps/mobile/app/services/premium.js b/apps/mobile/app/services/premium.js
index 309294863..a0be9f240 100644
--- a/apps/mobile/app/services/premium.js
+++ b/apps/mobile/app/services/premium.js
@@ -1,18 +1,22 @@
-import { CHECK_IDS } from '@streetwriters/notesnook-core/common';
-import React from 'react';
-import { Platform } from 'react-native';
-import * as RNIap from 'react-native-iap';
-import DialogHeader from '../components/dialog/dialog-header';
-import { CompactFeatures } from '../components/premium/compact-features';
-import { PricingPlans } from '../components/premium/pricing-plans';
-import Seperator from '../components/ui/seperator';
-import { useUserStore } from '../stores/use-user-store';
-import { itemSkus, SUBSCRIPTION_STATUS } from '../utils/constants';
-import { db } from '../common/database';
-import { eOpenPremiumDialog, eOpenTrialEndingDialog, eShowGetPremium } from '../utils/events';
-import { MMKV } from '../common/database/mmkv';
-import { eSendEvent, presentSheet, ToastEvent } from './event-manager';
-import SettingsService from './settings';
+import { CHECK_IDS } from "@streetwriters/notesnook-core/common";
+import React from "react";
+import { Platform } from "react-native";
+import * as RNIap from "react-native-iap";
+import DialogHeader from "../components/dialog/dialog-header";
+import { CompactFeatures } from "../components/premium/compact-features";
+import { PricingPlans } from "../components/premium/pricing-plans";
+import Seperator from "../components/ui/seperator";
+import { useUserStore } from "../stores/use-user-store";
+import { itemSkus, SUBSCRIPTION_STATUS } from "../utils/constants";
+import { db } from "../common/database";
+import {
+ eOpenPremiumDialog,
+ eOpenTrialEndingDialog,
+ eShowGetPremium
+} from "../utils/events";
+import { MMKV } from "../common/database/mmkv";
+import { eSendEvent, presentSheet, ToastEvent } from "./event-manager";
+import SettingsService from "./settings";
let premiumStatus = 0;
let products = [];
@@ -44,16 +48,18 @@ async function setPremiumStatus() {
await RNIap.initConnection();
products = await RNIap.getSubscriptions(itemSkus);
} catch (e) {
- console.log('subscriptions: ', e);
+ console.log("subscriptions: ", e);
}
}
}
function getMontlySub() {
- let _product = products.find(p => p.productId === 'com.streetwriters.notesnook.sub.mo');
+ let _product = products.find(
+ (p) => p.productId === "com.streetwriters.notesnook.sub.mo"
+ );
if (!_product) {
_product = {
- localizedPrice: '$4.49'
+ localizedPrice: "$4.49"
};
}
console.log(_product.localizedPrice);
@@ -83,19 +89,19 @@ async function verify(callback, error) {
eSendEvent(eOpenPremiumDialog);
return;
}
- if (!callback) console.warn('You must provide a callback function');
+ if (!callback) console.warn("You must provide a callback function");
await callback();
} catch (e) {}
}
-const onUserStatusCheck = async type => {
+const onUserStatusCheck = async (type) => {
let user = await db.user.getUser();
let userstore = useUserStore.getState();
premiumStatus = user?.subscription?.type || 0;
if (userstore?.premium !== get()) {
userstore.setPremium(get());
}
- console.log('status check: ', type, get());
+ console.log("status check: ", type, get());
let status = get();
let message = null;
@@ -103,23 +109,23 @@ const onUserStatusCheck = async type => {
switch (type) {
case CHECK_IDS.noteColor:
message = {
- context: 'sheet',
- title: 'Get Notesnook Pro',
- desc: 'To assign colors to a note get Notesnook Pro today.'
+ context: "sheet",
+ title: "Get Notesnook Pro",
+ desc: "To assign colors to a note get Notesnook Pro today."
};
break;
case CHECK_IDS.noteExport:
message = {
- context: 'export',
- title: 'Export in PDF, MD & HTML',
- desc: 'Get Notesnook Pro to export your notes in PDF, Markdown and HTML formats!'
+ context: "export",
+ title: "Export in PDF, MD & HTML",
+ desc: "Get Notesnook Pro to export your notes in PDF, Markdown and HTML formats!"
};
break;
case CHECK_IDS.noteTag:
message = {
- context: 'sheet',
- title: 'Get Notesnook Pro',
- desc: 'To create more tags for your notes become a Pro user today.'
+ context: "sheet",
+ title: "Get Notesnook Pro",
+ desc: "To create more tags for your notes become a Pro user today."
};
break;
case CHECK_IDS.notebookAdd:
@@ -127,9 +133,9 @@ const onUserStatusCheck = async type => {
break;
case CHECK_IDS.vaultAdd:
message = {
- context: 'sheet',
- title: 'Add Notes to Vault',
- desc: 'With Notesnook Pro you can add notes to your vault and do so much more! Get it now.'
+ context: "sheet",
+ title: "Add Notes to Vault",
+ desc: "With Notesnook Pro you can add notes to your vault and do so much more! Get it now."
};
break;
case CHECK_IDS.databaseSync:
@@ -146,20 +152,24 @@ const onUserStatusCheck = async type => {
const showVerifyEmailDialog = () => {
presentSheet({
- title: 'Confirm your email',
- icon: 'email',
+ title: "Confirm your email",
+ icon: "email",
paragraph:
- 'We have sent you an email confirmation link. Please check your email inbox. If you cannot find the email, check your spam folder.',
+ "We have sent you an email confirmation link. Please check your email inbox. If you cannot find the email, check your spam folder.",
action: async () => {
try {
- let lastVerificationEmailTime = SettingsService.get().lastVerificationEmailTime;
- if (lastVerificationEmailTime && Date.now() - lastVerificationEmailTime < 60000 * 2) {
+ let lastVerificationEmailTime =
+ SettingsService.get().lastVerificationEmailTime;
+ if (
+ lastVerificationEmailTime &&
+ Date.now() - lastVerificationEmailTime < 60000 * 2
+ ) {
ToastEvent.show({
- heading: 'Please wait before requesting another email',
- type: 'error',
- context: 'local'
+ heading: "Please wait before requesting another email",
+ type: "error",
+ context: "local"
});
- console.log('error');
+ console.log("error");
return;
}
await db.user.sendVerificationEmail();
@@ -168,105 +178,115 @@ const showVerifyEmailDialog = () => {
});
ToastEvent.show({
- heading: 'Verification email sent!',
+ heading: "Verification email sent!",
message:
- 'We have sent you an email confirmation link. Please check your email inbox to verify your account. If you cannot find the email, check your spam folder.',
- type: 'success',
- context: 'local'
+ "We have sent you an email confirmation link. Please check your email inbox to verify your account. If you cannot find the email, check your spam folder.",
+ type: "success",
+ context: "local"
});
} catch (e) {
ToastEvent.show({
- heading: 'Could not send email',
+ heading: "Could not send email",
message: e.message,
- type: 'error',
- context: 'local'
+ type: "error",
+ context: "local"
});
}
},
- actionText: 'Resend Confirmation Link'
+ actionText: "Resend Confirmation Link"
});
};
const subscriptions = {
get: async () => {
- if (Platform.OS === 'android') return;
- let _subscriptions = MMKV.getString('subscriptionsIOS');
+ if (Platform.OS === "android") return;
+ let _subscriptions = MMKV.getString("subscriptionsIOS");
if (!_subscriptions) return [];
return JSON.parse(_subscriptions);
},
- set: async subscription => {
- if (Platform.OS === 'android') return;
- let _subscriptions = MMKV.getString('subscriptionsIOS');
+ set: async (subscription) => {
+ if (Platform.OS === "android") return;
+ let _subscriptions = MMKV.getString("subscriptionsIOS");
if (_subscriptions) {
_subscriptions = JSON.parse(_subscriptions);
} else {
_subscriptions = [];
}
- let index = _subscriptions.findIndex(s => s.transactionId === subscription.transactionId);
+ let index = _subscriptions.findIndex(
+ (s) => s.transactionId === subscription.transactionId
+ );
if (index === -1) {
_subscriptions.unshift(subscription);
} else {
_subscriptions[index] = subscription;
}
- MMKV.setString('subscriptionsIOS', JSON.stringify(_subscriptions));
+ MMKV.setString("subscriptionsIOS", JSON.stringify(_subscriptions));
},
- remove: async transactionId => {
- if (Platform.OS === 'android') return;
- let _subscriptions = MMKV.getString('subscriptionsIOS');
+ remove: async (transactionId) => {
+ if (Platform.OS === "android") return;
+ let _subscriptions = MMKV.getString("subscriptionsIOS");
if (_subscriptions) {
_subscriptions = JSON.parse(_subscriptions);
} else {
_subscriptions = [];
}
- let index = _subscriptions.findIndex(s => s.transactionId === transactionId);
+ let index = _subscriptions.findIndex(
+ (s) => s.transactionId === transactionId
+ );
if (index !== -1) {
_subscriptions.splice(index);
- MMKV.setString('subscriptionsIOS', JSON.stringify(_subscriptions));
+ MMKV.setString("subscriptionsIOS", JSON.stringify(_subscriptions));
}
},
- verify: async subscription => {
- if (Platform.OS === 'android') return;
- console.log('verifying: ', new Date(subscription.transactionDate).toLocaleString());
+ verify: async (subscription) => {
+ if (Platform.OS === "android") return;
+ console.log(
+ "verifying: ",
+ new Date(subscription.transactionDate).toLocaleString()
+ );
if (subscription.transactionReceipt) {
- if (Platform.OS === 'ios') {
+ if (Platform.OS === "ios") {
let user = await db.user.getUser();
if (!user) return;
let requestData = {
- method: 'POST',
+ method: "POST",
body: JSON.stringify({
receipt_data: subscription.transactionReceipt,
user_id: user.id
}),
headers: {
- 'Content-Type': 'application/json'
+ "Content-Type": "application/json"
}
};
try {
- let result = await fetch('https://payments.streetwriters.co/apple/verify', requestData);
+ let result = await fetch(
+ "https://payments.streetwriters.co/apple/verify",
+ requestData
+ );
let text = await result.text();
console.log(text);
if (!result.ok) {
- if (text === 'Receipt already expired.') {
+ if (text === "Receipt already expired.") {
await subscriptions.clear(subscription);
- console.log('clearing because expired');
+ console.log("clearing because expired");
}
return;
}
} catch (e) {
- console.log('subscription error', e);
+ console.log("subscription error", e);
}
}
}
},
- clear: async _subscription => {
- if (Platform.OS === 'android') return;
+ clear: async (_subscription) => {
+ if (Platform.OS === "android") return;
let _subscriptions = await subscriptions.get();
let subscription = null;
if (_subscription) {
subscription = _subscription;
- console.log('got id to clear');
+ console.log("got id to clear");
} else {
subscription = _subscriptions.length > 0 ? _subscriptions[0] : null;
}
@@ -274,7 +294,7 @@ const subscriptions = {
await RNIap.finishTransactionIOS(subscription.transactionId);
await RNIap.clearTransactionIOS();
await subscriptions.remove(subscription.transactionId);
- console.log('clearing subscriptions');
+ console.log("clearing subscriptions");
}
}
};
@@ -288,25 +308,25 @@ async function getRemainingTrialDaysStatus() {
let current = Date.now() - user.subscription.start;
current = (current / total) * 100;
console.log(current);
- let lastTrialDialogShownAt = MMKV.getString('lastTrialDialogShownAt');
+ let lastTrialDialogShownAt = MMKV.getString("lastTrialDialogShownAt");
- if (current > 75 && isTrial && lastTrialDialogShownAt !== 'ending') {
+ if (current > 75 && isTrial && lastTrialDialogShownAt !== "ending") {
eSendEvent(eOpenTrialEndingDialog, {
- title: 'Your trial is ending soon',
+ title: "Your trial is ending soon",
offer: null,
extend: false
});
- MMKV.setItem('lastTrialDialogShownAt', 'ending');
+ MMKV.setItem("lastTrialDialogShownAt", "ending");
return true;
}
- if (!premium && lastTrialDialogShownAt !== 'expired') {
+ if (!premium && lastTrialDialogShownAt !== "expired") {
eSendEvent(eOpenTrialEndingDialog, {
- title: 'Your trial has expired',
+ title: "Your trial has expired",
offer: 30,
extend: false
});
- MMKV.setItem('lastTrialDialogShownAt', 'expired');
+ MMKV.setItem("lastTrialDialogShownAt", "expired");
return true;
}
return false;
@@ -314,29 +334,30 @@ async function getRemainingTrialDaysStatus() {
const features_list = [
{
- content: 'Unlock unlimited notebooks, tags, colors. Organize like a pro'
+ content: "Unlock unlimited notebooks, tags, colors. Organize like a pro"
},
{
- content: 'Attach files upto 500MB, upload 4K images with unlimited storage'
+ content: "Attach files upto 500MB, upload 4K images with unlimited storage"
},
{
- content: 'Instantly sync to unlimited devices'
+ content: "Instantly sync to unlimited devices"
},
{
- content: 'A private vault to keep everything imporant always locked'
+ content: "A private vault to keep everything imporant always locked"
},
{
- content: 'Rich note editing experience with markdown, tables, checklists and more'
+ content:
+ "Rich note editing experience with markdown, tables, checklists and more"
},
{
- content: 'Export your notes in Pdf, markdown and html formats'
+ content: "Export your notes in Pdf, markdown and html formats"
}
];
const sheet = (context, promo, trial) => {
presentSheet({
context: context,
- component: ref => (
+ component: (ref) => (
<>
<DialogHeader
centered
@@ -346,7 +367,12 @@ const sheet = (context, promo, trial) => {
padding={12}
/>
<Seperator />
- <CompactFeatures scrollRef={ref} maxHeight={300} features={features_list} vertical />
+ <CompactFeatures
+ scrollRef={ref}
+ maxHeight={300}
+ features={features_list}
+ vertical
+ />
<Seperator half />
<PricingPlans trial={trial} compact heading={false} promo={promo} />
</>
diff --git a/apps/mobile/app/services/search.js b/apps/mobile/app/services/search.js
index fe8adccbd..b6ca1bf2c 100644
--- a/apps/mobile/app/services/search.js
+++ b/apps/mobile/app/services/search.js
@@ -1,12 +1,12 @@
-import { useSearchStore } from '../stores/use-search-store';
-import { db } from '../common/database';
+import { useSearchStore } from "../stores/use-search-store";
+import { db } from "../common/database";
let prepareSearch = () => {};
let searchInformation = {
- placeholder: 'Search in all notes',
+ placeholder: "Search in all notes",
data: [],
- type: 'notes',
+ type: "notes",
get: () => null
};
@@ -29,7 +29,10 @@ async function search(silent) {
return;
}
if (!silent) {
- searchstore.setSearchStatus(true, `Searching for "${term}" in ${searchInformation.title}`);
+ searchstore.setSearchStatus(
+ true,
+ `Searching for "${term}" in ${searchInformation.title}`
+ );
}
let results;
@@ -54,7 +57,7 @@ function getSearchInformation() {
}
function updateAndSearch() {
- if (!keyword || keyword === '') return;
+ if (!keyword || keyword === "") return;
search(true);
}
diff --git a/apps/mobile/app/services/settings.ts b/apps/mobile/app/services/settings.ts
index 892a74336..232108854 100644
--- a/apps/mobile/app/services/settings.ts
+++ b/apps/mobile/app/services/settings.ts
@@ -1,108 +1,109 @@
-import { Platform } from 'react-native';
-import { enabled } from 'react-native-privacy-snapshot';
-import { SettingStore } from '../stores/use-setting-store';
-import { useSettingStore } from '../stores/use-setting-store';
-import { AndroidModule } from '../utils';
-import { getColorScheme } from '../utils/color-scheme/utils';
-import { MMKV } from '../common/database/mmkv';
-import { scale, updateSize } from '../utils/size';
-import Notifications from './notifications';
-import Orientation from 'react-native-orientation';
-import { DDS } from './device-detection';
-
-function migrate(settings: SettingStore['settings']) {
+import { Platform } from "react-native";
+import { enabled } from "react-native-privacy-snapshot";
+import { SettingStore } from "../stores/use-setting-store";
+import { useSettingStore } from "../stores/use-setting-store";
+import { AndroidModule } from "../utils";
+import { getColorScheme } from "../utils/color-scheme/utils";
+import { MMKV } from "../common/database/mmkv";
+import { scale, updateSize } from "../utils/size";
+import Notifications from "./notifications";
+import Orientation from "react-native-orientation";
+import { DDS } from "./device-detection";
+
+function migrate(settings: SettingStore["settings"]) {
if (settings.migrated) return true;
- let introCompleted = MMKV.getString('introCompleted');
+ let introCompleted = MMKV.getString("introCompleted");
if (!introCompleted) {
- console.log('no need to migrate');
+ console.log("no need to migrate");
settings.migrated = true;
set(settings);
return;
}
settings.introCompleted = true;
- MMKV.removeItem('introCompleted');
- console.log('migrated introCompleted', introCompleted);
+ MMKV.removeItem("introCompleted");
+ console.log("migrated introCompleted", introCompleted);
- let askForRating = MMKV.getString('askForRating');
+ let askForRating = MMKV.getString("askForRating");
if (askForRating) {
- if (askForRating === 'completed' || askForRating === 'never') {
+ if (askForRating === "completed" || askForRating === "never") {
settings.rateApp = false;
} else {
askForRating = JSON.parse(askForRating);
//@ts-ignore
settings.rateApp = askForRating.timestamp;
}
- console.log('migrated askForRating', askForRating);
- MMKV.removeItem('askForRating');
+ console.log("migrated askForRating", askForRating);
+ MMKV.removeItem("askForRating");
}
- let askForBackup = MMKV.getString('askForBackup');
+ let askForBackup = MMKV.getString("askForBackup");
if (askForBackup) {
askForBackup = JSON.parse(askForBackup);
//@ts-ignore
settings.rateApp = askForBackup.timestamp;
- MMKV.removeItem('askForBackup');
- console.log('migrated askForBackup', askForBackup);
+ MMKV.removeItem("askForBackup");
+ console.log("migrated askForBackup", askForBackup);
}
- let lastBackupDate = MMKV.getString('backupDate');
+ let lastBackupDate = MMKV.getString("backupDate");
if (lastBackupDate) settings.lastBackupDate = parseInt(lastBackupDate);
- MMKV.removeItem('backupDate');
- console.log('migrated backupDate', lastBackupDate);
+ MMKV.removeItem("backupDate");
+ console.log("migrated backupDate", lastBackupDate);
- let isUserEmailConfirmed = MMKV.getString('isUserEmailConfirmed');
- if (isUserEmailConfirmed === 'yes') settings.userEmailConfirmed = true;
- if (isUserEmailConfirmed === 'no') settings.userEmailConfirmed = false;
- console.log('migrated useEmailConfirmed', isUserEmailConfirmed);
+ let isUserEmailConfirmed = MMKV.getString("isUserEmailConfirmed");
+ if (isUserEmailConfirmed === "yes") settings.userEmailConfirmed = true;
+ if (isUserEmailConfirmed === "no") settings.userEmailConfirmed = false;
+ console.log("migrated useEmailConfirmed", isUserEmailConfirmed);
- MMKV.removeItem('isUserEmailConfirmed');
+ MMKV.removeItem("isUserEmailConfirmed");
- let userHasSavedRecoveryKey = MMKV.getString('userHasSavedRecoveryKey');
+ let userHasSavedRecoveryKey = MMKV.getString("userHasSavedRecoveryKey");
if (userHasSavedRecoveryKey) settings.recoveryKeySaved = true;
- MMKV.removeItem('userHasSavedRecoveryKey');
- console.log('migrated userHasSavedRecoveryKey', userHasSavedRecoveryKey);
+ MMKV.removeItem("userHasSavedRecoveryKey");
+ console.log("migrated userHasSavedRecoveryKey", userHasSavedRecoveryKey);
- let accentColor = MMKV.getString('accentColor');
+ let accentColor = MMKV.getString("accentColor");
if (accentColor) settings.theme.accent = accentColor;
- MMKV.removeItem('accentColor');
- console.log('migrated accentColor', accentColor);
+ MMKV.removeItem("accentColor");
+ console.log("migrated accentColor", accentColor);
- let theme = MMKV.getString('theme');
+ let theme = MMKV.getString("theme");
if (theme) {
theme = JSON.parse(theme);
//@ts-ignore
if (theme.night) settings.theme.dark = true;
- MMKV.removeItem('theme');
+ MMKV.removeItem("theme");
}
- console.log('migrated theme', theme);
+ console.log("migrated theme", theme);
- let backupStorageDir = MMKV.getString('backupStorageDir');
- if (backupStorageDir) settings.backupDirectoryAndroid = JSON.parse(backupStorageDir);
- MMKV.removeItem('backupStorageDir');
- console.log('migrated backupStorageDir', backupStorageDir);
+ let backupStorageDir = MMKV.getString("backupStorageDir");
+ if (backupStorageDir)
+ settings.backupDirectoryAndroid = JSON.parse(backupStorageDir);
+ MMKV.removeItem("backupStorageDir");
+ console.log("migrated backupStorageDir", backupStorageDir);
- let dontShowCompleteSheet = MMKV.getString('dontShowCompleteSheet');
+ let dontShowCompleteSheet = MMKV.getString("dontShowCompleteSheet");
if (dontShowCompleteSheet) settings.showBackupCompleteSheet = false;
- MMKV.removeItem('dontShowCompleteSheet');
- console.log('migrated dontShowCompleteSheet', dontShowCompleteSheet);
+ MMKV.removeItem("dontShowCompleteSheet");
+ console.log("migrated dontShowCompleteSheet", dontShowCompleteSheet);
settings.migrated = true;
set(settings);
- console.log('migrated completed');
+ console.log("migrated completed");
return true;
}
function init() {
scale.fontScale = 1;
- let settingsJson = MMKV.getString('appSettings');
+ let settingsJson = MMKV.getString("appSettings");
let settings = get();
if (!settingsJson) {
- MMKV.setString('appSettings', JSON.stringify(settings));
+ MMKV.setString("appSettings", JSON.stringify(settings));
} else {
settings = {
...settings,
@@ -124,15 +125,15 @@ function init() {
return;
}
-function setPrivacyScreen(settings: SettingStore['settings']) {
- if (settings.privacyScreen || settings.appLockMode === 'background') {
- if (Platform.OS === 'android') {
+function setPrivacyScreen(settings: SettingStore["settings"]) {
+ if (settings.privacyScreen || settings.appLockMode === "background") {
+ if (Platform.OS === "android") {
AndroidModule.setSecureMode(true);
} else {
enabled(true);
}
} else {
- if (Platform.OS === 'android') {
+ if (Platform.OS === "android") {
AndroidModule.setSecureMode(false);
} else {
enabled(false);
@@ -140,7 +141,7 @@ function setPrivacyScreen(settings: SettingStore['settings']) {
}
}
-function set(next: Partial<SettingStore['settings']>) {
+function set(next: Partial<SettingStore["settings"]>) {
let settings = get();
settings = {
...settings,
@@ -148,19 +149,22 @@ function set(next: Partial<SettingStore['settings']>) {
};
useSettingStore.getState().setSettings(settings);
- setTimeout(async () => MMKV.setString('appSettings', JSON.stringify(settings)), 1);
+ setTimeout(
+ async () => MMKV.setString("appSettings", JSON.stringify(settings)),
+ 1
+ );
}
-function toggle(id: keyof SettingStore['settings']) {
+function toggle(id: keyof SettingStore["settings"]) {
let settings = get();
- if (typeof settings[id] !== 'boolean') return;
+ if (typeof settings[id] !== "boolean") return;
settings = {
...settings
};
//@ts-ignore
settings[id] = !settings[id];
useSettingStore.getState().setSettings(settings);
- MMKV.setString('appSettings', JSON.stringify(settings));
+ MMKV.setString("appSettings", JSON.stringify(settings));
}
function get() {
@@ -182,10 +186,18 @@ function checkOrientation() {
Orientation.getOrientation((e, r) => {
DDS.checkSmallTab(r);
//@ts-ignore
- useSettingStore.getState().setDimensions({ width: DDS.width, height: DDS.height });
useSettingStore
.getState()
- .setDeviceMode(DDS.isLargeTablet() ? 'tablet' : DDS.isSmallTab ? 'smallTablet' : 'mobile');
+ .setDimensions({ width: DDS.width, height: DDS.height });
+ useSettingStore
+ .getState()
+ .setDeviceMode(
+ DDS.isLargeTablet()
+ ? "tablet"
+ : DDS.isSmallTab
+ ? "smallTablet"
+ : "mobile"
+ );
});
}
diff --git a/apps/mobile/app/services/sync.js b/apps/mobile/app/services/sync.js
index 568a7fc63..f5207708f 100644
--- a/apps/mobile/app/services/sync.js
+++ b/apps/mobile/app/services/sync.js
@@ -1,36 +1,41 @@
-import NetInfo from '@react-native-community/netinfo';
-import { EVENTS } from '@streetwriters/notesnook-core/common';
-import { initAfterSync } from '../stores/index';
-import { useUserStore } from '../stores/use-user-store';
-import { doInBackground } from '../utils';
-import { db } from '../common/database';
-import { DatabaseLogger } from '../common/database/index';
-import { ToastEvent } from './event-manager';
+import NetInfo from "@react-native-community/netinfo";
+import { EVENTS } from "@streetwriters/notesnook-core/common";
+import { initAfterSync } from "../stores/index";
+import { useUserStore } from "../stores/use-user-store";
+import { doInBackground } from "../utils";
+import { db } from "../common/database";
+import { DatabaseLogger } from "../common/database/index";
+import { ToastEvent } from "./event-manager";
NetInfo.configure({
- reachabilityUrl: 'https://bing.com',
- reachabilityTest: response => {
+ reachabilityUrl: "https://bing.com",
+ reachabilityTest: (response) => {
if (!response) return false;
return response?.status >= 200 && response?.status < 300;
}
});
export const ignoredMessages = [
- 'Sync already running',
- 'Not allowed to start service intent',
- 'WebSocket failed to connect',
- 'Failed to start the HttpConnection before'
+ "Sync already running",
+ "Not allowed to start service intent",
+ "WebSocket failed to connect",
+ "Failed to start the HttpConnection before"
];
let syncTimer = 0;
-const run = async (context = 'global', forced = false, full = true, onCompleted) => {
+const run = async (
+ context = "global",
+ forced = false,
+ full = true,
+ onCompleted
+) => {
clearTimeout(syncTimer);
syncTimer = setTimeout(async () => {
const status = await NetInfo.fetch();
const userstore = useUserStore.getState();
const user = await db.user.getUser();
if (!status.isInternetReachable) {
- DatabaseLogger.warn('Internet not reachable');
+ DatabaseLogger.warn("Internet not reachable");
}
if (!user || !status.isInternetReachable) {
initAfterSync();
@@ -38,12 +43,12 @@ const run = async (context = 'global', forced = false, full = true, onCompleted)
}
userstore.setSyncing(true);
let error = null;
- console.log('Sync.run started');
+ console.log("Sync.run started");
try {
- console.log('DO IN BACKGROUND START');
+ console.log("DO IN BACKGROUND START");
let res = await doInBackground(async () => {
try {
- console.log('DO IN BACKGROUND');
+ console.log("DO IN BACKGROUND");
await db.sync(full, forced);
return true;
} catch (e) {
@@ -56,18 +61,21 @@ const run = async (context = 'global', forced = false, full = true, onCompleted)
userstore.setSyncing(false);
return onCompleted?.(false);
}
- if (typeof res === 'string') throw error;
+ if (typeof res === "string") throw error;
userstore.setSyncing(false);
return onCompleted?.(true);
} catch (e) {
- if (!ignoredMessages.find(im => e.message?.includes(im)) && userstore.user) {
+ if (
+ !ignoredMessages.find((im) => e.message?.includes(im)) &&
+ userstore.user
+ ) {
userstore.setSyncing(false);
console.log(status.isConnected, status.isInternetReachable);
if (status.isConnected && status.isInternetReachable) {
- ToastEvent.error(e, 'Sync failed', context);
+ ToastEvent.error(e, "Sync failed", context);
}
}
- DatabaseLogger.error(e, '[Client] Failed to sync');
+ DatabaseLogger.error(e, "[Client] Failed to sync");
onCompleted?.(false);
} finally {
userstore.setSyncing(false);
diff --git a/apps/mobile/app/services/tip-manager.ts b/apps/mobile/app/services/tip-manager.ts
index fe049ca49..818869ee8 100644
--- a/apps/mobile/app/services/tip-manager.ts
+++ b/apps/mobile/app/services/tip-manager.ts
@@ -1,5 +1,5 @@
-import { useEffect, useRef, useState } from 'react';
-import { MMKV } from '../common/database/mmkv';
+import { useEffect, useRef, useState } from "react";
+import { MMKV } from "../common/database/mmkv";
//@ts-ignore
Array.prototype.sample = function () {
@@ -13,20 +13,20 @@ export type TipButton = {
icon?: string;
};
type Context =
- | 'list'
- | 'notes'
- | 'notebooks'
- | 'notebook'
- | 'tags'
- | 'open-editor'
- | 'exit-editor'
- | 'sidemenu'
- | 'properties'
- | 'first-note'
- | 'first-editor-launch'
- | 'monographs'
- | 'trash'
- | 'topics';
+ | "list"
+ | "notes"
+ | "notebooks"
+ | "notebook"
+ | "tags"
+ | "open-editor"
+ | "exit-editor"
+ | "sidemenu"
+ | "properties"
+ | "first-note"
+ | "first-editor-launch"
+ | "monographs"
+ | "trash"
+ | "topics";
export type TTip = {
text: string;
@@ -40,14 +40,14 @@ export type Popup = {
text: string;
};
-const destructiveContexts = ['first-note'];
+const destructiveContexts = ["first-note"];
let tipState: { [name: string]: boolean } = {};
let popState: { [name: string]: boolean } = {};
export class TipManager {
static init() {
- let tipStateJson = MMKV.getString('tipState');
+ let tipStateJson = MMKV.getString("tipState");
if (tipStateJson) {
tipState = JSON.parse(tipStateJson);
} else {
@@ -55,7 +55,7 @@ export class TipManager {
tipState = {};
}
- let popStateJson = MMKV.getString('popupState');
+ let popStateJson = MMKV.getString("popupState");
if (popStateJson) {
popState = JSON.parse(popStateJson);
} else {
@@ -70,17 +70,17 @@ export class TipManager {
if (tipState[context]) return;
//@ts-ignore
tipState[context] = true;
- MMKV.setString('tipState', JSON.stringify(tipState));
+ MMKV.setString("tipState", JSON.stringify(tipState));
}
- let tipsForCtx = tips.filter(tip => tip.contexts.indexOf(context) > -1);
+ let tipsForCtx = tips.filter((tip) => tip.contexts.indexOf(context) > -1);
//@ts-ignore
return tipsForCtx.sample();
}
static popup(id: string) {
- let pop = popups.find(p => p.id === id);
+ let pop = popups.find((p) => p.id === id);
//@ts-ignore
// if (popState[id]) return null;
@@ -90,7 +90,7 @@ export class TipManager {
static markPopupUsed(id: string) {
//@ts-ignore
popState[id] = true;
- MMKV.setString('popupState', JSON.stringify(popState));
+ MMKV.setString("popupState", JSON.stringify(popState));
}
static placeholderTip() {
@@ -107,7 +107,9 @@ export const useTip = (
delay: number;
}
) => {
- const [tip, setTip] = useState(TipManager.tip(context) || TipManager.tip(fallback));
+ const [tip, setTip] = useState(
+ TipManager.tip(context) || TipManager.tip(fallback)
+ );
const intervalRef = useRef<any>(null);
useEffect(() => {
@@ -129,67 +131,67 @@ export const useTip = (
const tips: TTip[] = [
{
- text: 'You can swipe left anywhere in the app to start a new note',
- contexts: ['notes', 'first-note']
+ text: "You can swipe left anywhere in the app to start a new note",
+ contexts: ["notes", "first-note"]
},
{
- text: 'Long press on any item in list to open quick actions menu.',
- contexts: ['notes', 'notebook', 'notebook', 'tags', 'topics']
+ text: "Long press on any item in list to open quick actions menu.",
+ contexts: ["notes", "notebook", "notebook", "tags", "topics"]
},
{
- text: 'Monographs enable you to share your notes in a secure and private way',
- contexts: ['monographs']
+ text: "Monographs enable you to share your notes in a secure and private way",
+ contexts: ["monographs"]
},
{
- text: 'Monographs can be encrypted with a secret key and shared with anyone',
- contexts: ['monographs']
+ text: "Monographs can be encrypted with a secret key and shared with anyone",
+ contexts: ["monographs"]
},
{
- text: 'Frequently accessed notebooks can be pinned to Side Menu so that they are easily accessible',
- contexts: ['notebook', 'notebooks']
+ text: "Frequently accessed notebooks can be pinned to Side Menu so that they are easily accessible",
+ contexts: ["notebook", "notebooks"]
},
{
- text: 'A notebook can have unlimited topics with unlimited notes.',
- contexts: ['notebook', 'topics']
+ text: "A notebook can have unlimited topics with unlimited notes.",
+ contexts: ["notebook", "topics"]
},
{
- text: 'You can multi-select notes and move them to a notebook at once',
- contexts: ['notebook', 'topics']
+ text: "You can multi-select notes and move them to a notebook at once",
+ contexts: ["notebook", "topics"]
},
{
- text: 'Items in trash are kept for 7 days after which they are permanently deleted.',
- contexts: ['trash']
+ text: "Items in trash are kept for 7 days after which they are permanently deleted.",
+ contexts: ["trash"]
},
{
- text: 'Mark important notes by adding them to favorites',
- contexts: ['notes']
+ text: "Mark important notes by adding them to favorites",
+ contexts: ["notes"]
},
{
- text: 'Have to scroll down a lot to open a note you are working on? Pin it to top from properties.',
- contexts: ['notes']
+ text: "Have to scroll down a lot to open a note you are working on? Pin it to top from properties.",
+ contexts: ["notes"]
}
];
const popups: Popup[] = [
{
- id: 'sortmenu',
- text: 'Tap here to change sorting'
+ id: "sortmenu",
+ text: "Tap here to change sorting"
},
{
- id: 'jumpto',
- text: 'Tap here to jump to a section'
+ id: "jumpto",
+ text: "Tap here to jump to a section"
},
{
- id: 'compactmode',
- text: 'Try compact mode to fit more items on screen'
+ id: "compactmode",
+ text: "Try compact mode to fit more items on screen"
},
{
- id: 'searchreplace',
- text: 'Switch to search/replace mode'
+ id: "searchreplace",
+ text: "Switch to search/replace mode"
},
{
- id: 'notebookshortcut',
- text: 'Create shortcut of this notebook in side menu'
+ id: "notebookshortcut",
+ text: "Create shortcut of this notebook in side menu"
}
];
@@ -197,14 +199,14 @@ const placeholderTips = [
`Want to remember something\? Pin an important note in notifications.`,
`Privacy is power. What people don\'t know they cant ruin`,
`If you read someone else\'s diary, you get what you deserve. - David Sedaris`,
- 'Take quick notes from notifications. Enable the option in Settings to try',
- 'Get Notesnook on all your devices. Or even open it in browser by going to https://app.notesnook.com to access all your notes',
+ "Take quick notes from notifications. Enable the option in Settings to try",
+ "Get Notesnook on all your devices. Or even open it in browser by going to https://app.notesnook.com to access all your notes",
`With note history, you can restore back to an older version of the note if you accidently deleted something.`,
`When your heart speaks\, take good notes. - Judith Campbell`,
"You can publish a note and share it with anyone. Even if they don't use Notesnook!",
- 'Published notes can be encrypted. Which means only you and the person you share the password with can read them.',
- 'You can change default font size from editor settings at the end of toolbar',
- 'The editor toolbar can be scrolled horizontally to add more formats and blocks',
+ "Published notes can be encrypted. Which means only you and the person you share the password with can read them.",
+ "You can change default font size from editor settings at the end of toolbar",
+ "The editor toolbar can be scrolled horizontally to add more formats and blocks",
`To be left alone is the most precious thing one can ask of the modern world. - Anthony Burgess`,
`Arguing that you don't care about the right to privacy because you have nothing to hide is no different than saying you don't care about free speech because you have nothing to say.” ― Edward Snowden `,
`Privacy is not something that I'm merely entitled to, it's an absolute prerequisite.” ― Marlon Brando `,
diff --git a/apps/mobile/app/services/validation.js b/apps/mobile/app/services/validation.js
index 06fec7e5e..a2a399c78 100644
--- a/apps/mobile/app/services/validation.js
+++ b/apps/mobile/app/services/validation.js
@@ -1,4 +1,4 @@
-import isEmail from 'validator/lib/isEmail';
+import isEmail from "validator/lib/isEmail";
export function validateEmail(email) {
if (email && email.length > 0) {
@@ -9,7 +9,7 @@ export function validateEmail(email) {
}
export const ERRORS_LIST = {
- SHORT_PASS: 'Atleast 8 characters'
+ SHORT_PASS: "Atleast 8 characters"
};
export function validatePass(password) {
diff --git a/apps/mobile/app/stores/index.ts b/apps/mobile/app/stores/index.ts
index 911932070..d872a3adb 100644
--- a/apps/mobile/app/stores/index.ts
+++ b/apps/mobile/app/stores/index.ts
@@ -1,17 +1,19 @@
//@ts-ignore
-import { db } from '../common/database';
-import { useNoteStore } from './use-notes-store';
-import { useFavoriteStore } from './use-favorite-store';
-import { useMenuStore } from './use-menu-store';
-import { useNotebookStore } from './use-notebook-store';
-import { useTagStore } from './use-tag-store';
-import { useTrashStore } from './use-trash-store';
-import Navigation from '../services/navigation';
+import { db } from "../common/database";
+import { useNoteStore } from "./use-notes-store";
+import { useFavoriteStore } from "./use-favorite-store";
+import { useMenuStore } from "./use-menu-store";
+import { useNotebookStore } from "./use-notebook-store";
+import { useTagStore } from "./use-tag-store";
+import { useTrashStore } from "./use-trash-store";
+import Navigation from "../services/navigation";
export function initAfterSync() {
useMenuStore.getState().setColorNotes();
useMenuStore.getState().setMenuPins();
- Navigation.queueRoutesForUpdate(...Object.keys(Navigation.routeUpdateFunctions));
+ Navigation.queueRoutesForUpdate(
+ ...Object.keys(Navigation.routeUpdateFunctions)
+ );
}
export function initialize() {
diff --git a/apps/mobile/app/stores/use-attachment-store.ts b/apps/mobile/app/stores/use-attachment-store.ts
index 7811299bc..3ed7e6cb0 100644
--- a/apps/mobile/app/stores/use-attachment-store.ts
+++ b/apps/mobile/app/stores/use-attachment-store.ts
@@ -1,6 +1,6 @@
//@ts-ignore
-import create from 'zustand';
-import { editorController } from '../screens/editor/tiptap/utils';
+import create from "zustand";
+import { editorController } from "../screens/editor/tiptap/utils";
interface AttachmentStore {
progress?: {
@@ -9,7 +9,7 @@ interface AttachmentStore {
total: number;
hash: string;
recieved: number;
- type: 'upload' | 'download';
+ type: "upload" | "download";
} | null;
};
encryptionProgress: number;
@@ -20,7 +20,7 @@ interface AttachmentStore {
total: number,
hash: string,
recieved: number,
- type: 'upload' | 'download'
+ type: "upload" | "download"
) => void;
loading: { total: number; current: number };
setLoading: (data: { total: number; current: number }) => void;
@@ -28,13 +28,13 @@ interface AttachmentStore {
export const useAttachmentStore = create<AttachmentStore>((set, get) => ({
progress: {},
- remove: hash => {
+ remove: (hash) => {
let progress = get().progress;
if (!progress) return;
editorController.current?.commands.setAttachmentProgress({
hash: hash,
progress: 100,
- type: progress[hash]?.type || 'download'
+ type: progress[hash]?.type || "download"
});
progress[hash] = null;
set({ progress: { ...progress } });
@@ -43,7 +43,8 @@ export const useAttachmentStore = create<AttachmentStore>((set, get) => ({
let progress = get().progress;
if (!progress) return;
progress[hash] = { sent, total, hash, recieved, type };
- const progressPercentage = type === 'upload' ? sent / total : recieved / total;
+ const progressPercentage =
+ type === "upload" ? sent / total : recieved / total;
editorController.current?.commands.setAttachmentProgress({
hash: hash,
progress: Math.round(Math.max(progressPercentage * 100, 0)),
@@ -52,7 +53,8 @@ export const useAttachmentStore = create<AttachmentStore>((set, get) => ({
set({ progress: { ...progress } });
},
encryptionProgress: 0,
- setEncryptionProgress: encryptionProgress => set({ encryptionProgress: encryptionProgress }),
+ setEncryptionProgress: (encryptionProgress) =>
+ set({ encryptionProgress: encryptionProgress }),
loading: { total: 0, current: 0 },
- setLoading: data => set({ loading: data ? { ...data } : data })
+ setLoading: (data) => set({ loading: data ? { ...data } : data })
}));
diff --git a/apps/mobile/app/stores/use-editor-store.ts b/apps/mobile/app/stores/use-editor-store.ts
index 94c4b8d31..21d9bc928 100644
--- a/apps/mobile/app/stores/use-editor-store.ts
+++ b/apps/mobile/app/stores/use-editor-store.ts
@@ -1,6 +1,6 @@
//@ts-ignore
-import create, { State } from 'zustand';
-import { eSubscribeEvent, eUnSubscribeEvent } from '../services/event-manager';
+import create, { State } from "zustand";
+import { eSubscribeEvent, eUnSubscribeEvent } from "../services/event-manager";
export interface EditorStore extends State {
currentEditingNote: string | null;
@@ -16,34 +16,34 @@ export interface EditorStore extends State {
export const useEditorStore = create<EditorStore>((set, get) => ({
currentEditingNote: null,
- setCurrentlyEditingNote: note => set({ currentEditingNote: note }),
+ setCurrentlyEditingNote: (note) => set({ currentEditingNote: note }),
sessionId: null,
- setSessionId: sessionId => {
- console.log(sessionId, 'session id');
+ setSessionId: (sessionId) => {
+ console.log(sessionId, "session id");
// tiny.call(EditorWebView, `sessionId="${sessionId}";`);
set({ sessionId });
},
searchReplace: false,
searchSelection: null,
readonly: false,
- setReadonly: readonly => {
+ setReadonly: (readonly) => {
set({ readonly: readonly });
},
- setSearchReplace: searchReplace => {
+ setSearchReplace: (searchReplace) => {
if (!searchReplace) {
set({ searchSelection: null, searchReplace: false });
return;
}
let func = (value: string) => {
- eUnSubscribeEvent('selectionvalue', func);
- console.log('setSearchReplace:', value, value.length);
+ eUnSubscribeEvent("selectionvalue", func);
+ console.log("setSearchReplace:", value, value.length);
if (!value && get().searchReplace) {
// endSearch();
return;
}
set({ searchSelection: value, searchReplace: true });
};
- eSubscribeEvent('selectionvalue', func);
+ eSubscribeEvent("selectionvalue", func);
// tiny.call(
// EditorWebView,
// `(function() {
diff --git a/apps/mobile/app/stores/use-favorite-store.ts b/apps/mobile/app/stores/use-favorite-store.ts
index ee885d0b6..e0c324570 100644
--- a/apps/mobile/app/stores/use-favorite-store.ts
+++ b/apps/mobile/app/stores/use-favorite-store.ts
@@ -1,8 +1,8 @@
//@ts-ignore
-import { groupArray } from '@streetwriters/notesnook-core/utils/grouping';
-import create, { State } from 'zustand';
-import { db } from '../common/database';
-import { NoteType } from '../utils/types';
+import { groupArray } from "@streetwriters/notesnook-core/utils/grouping";
+import create, { State } from "zustand";
+import { db } from "../common/database";
+import { NoteType } from "../utils/types";
export interface FavoriteStore extends State {
favorites: NoteType[];
@@ -12,17 +12,20 @@ export interface FavoriteStore extends State {
export const useFavoriteStore = create<FavoriteStore>((set, get) => ({
favorites: [],
- setFavorites: items => {
+ setFavorites: (items) => {
if (!items) {
set({
- favorites: groupArray(db?.notes?.favorites || [], db.settings?.getGroupOptions('favorites'))
+ favorites: groupArray(
+ db?.notes?.favorites || [],
+ db.settings?.getGroupOptions("favorites")
+ )
});
return;
}
let prev = get().favorites;
for (let i = 0; i < items.length; i++) {
let item = items[i];
- let index = prev.findIndex(v => v.id === item.id);
+ let index = prev.findIndex((v) => v.id === item.id);
if (index !== -1) {
prev[index] = item;
}
diff --git a/apps/mobile/app/stores/use-menu-store.ts b/apps/mobile/app/stores/use-menu-store.ts
index f4f5f4e96..934eafad2 100644
--- a/apps/mobile/app/stores/use-menu-store.ts
+++ b/apps/mobile/app/stores/use-menu-store.ts
@@ -1,6 +1,6 @@
//@ts-ignore
-import create, { State } from 'zustand';
-import { db } from '../common/database';
+import create, { State } from "zustand";
+import { db } from "../common/database";
export interface MenuStore extends State {
menuPins: object[];
diff --git a/apps/mobile/app/stores/use-message-store.ts b/apps/mobile/app/stores/use-message-store.ts
index ef3995bf0..c6b99137f 100644
--- a/apps/mobile/app/stores/use-message-store.ts
+++ b/apps/mobile/app/stores/use-message-store.ts
@@ -1,12 +1,12 @@
//@ts-ignore
-import { Platform } from 'react-native';
-import create, { State } from 'zustand';
-import { APP_VERSION } from '../version';
-import PremiumService from '../services/premium';
-import { SUBSCRIPTION_STATUS } from '../utils/constants';
-import { db } from '../common/database';
-import { MMKV } from '../common/database/mmkv';
-import layoutmanager from '../utils/layout-manager';
+import { Platform } from "react-native";
+import create, { State } from "zustand";
+import { APP_VERSION } from "../version";
+import PremiumService from "../services/premium";
+import { SUBSCRIPTION_STATUS } from "../utils/constants";
+import { db } from "../common/database";
+import { MMKV } from "../common/database/mmkv";
+import layoutmanager from "../utils/layout-manager";
export interface MessageStore extends State {
message: Message;
setMessage: (message: Message) => void;
@@ -34,19 +34,19 @@ export type Action = {
export type Style = {
marginTop?: number;
marginBottom?: number;
- textAlign?: 'center' | 'left' | 'right';
+ textAlign?: "center" | "left" | "right";
};
export type BodyItem = {
type:
- | 'image'
- | 'title'
- | 'description'
- | 'body'
- | 'list'
- | 'features'
- | 'poll'
- | 'subheading'
- | 'shapes';
+ | "image"
+ | "title"
+ | "description"
+ | "body"
+ | "list"
+ | "features"
+ | "poll"
+ | "subheading"
+ | "shapes";
src?: string;
caption?: string;
text?: string;
@@ -57,7 +57,7 @@ export type BodyItem = {
};
export type Announcement = {
- type: 'dialog' | 'inline';
+ type: "dialog" | "inline";
body: BodyItem[];
id: string;
callToActions: Action[];
@@ -75,10 +75,10 @@ export const useMessageStore = create<MessageStore>((set, get) => ({
actionText: null,
onPress: () => null,
data: {},
- icon: 'account-outline'
+ icon: "account-outline"
},
- setMessage: message => {
- console.log('setting message');
+ setMessage: (message) => {
+ console.log("setting message");
setTimeout(() => {
if (get().message.visible || message.visible) {
layoutmanager.withAnimation();
@@ -88,13 +88,15 @@ export const useMessageStore = create<MessageStore>((set, get) => ({
}, 1);
},
announcements: [],
- remove: async id => {
- MMKV.setItem(id, 'removed');
+ remove: async (id) => {
+ MMKV.setItem(id, "removed");
const inlineCopy = get().announcements.slice();
const dialogsCopy = get().dialogs.slice();
- const index = inlineCopy.findIndex(announcement => announcement.id === id);
- const dialogIndex = dialogsCopy.findIndex(dialog => dialog.id === id);
+ const index = inlineCopy.findIndex(
+ (announcement) => announcement.id === id
+ );
+ const dialogIndex = dialogsCopy.findIndex((dialog) => dialog.id === id);
if (index >= -1) {
dialogsCopy.splice(dialogIndex, 1);
@@ -111,19 +113,19 @@ export const useMessageStore = create<MessageStore>((set, get) => ({
announcements = [];
}
} catch (e) {
- console.log('ERROR', e);
+ console.log("ERROR", e);
set({ announcements: [] });
} finally {
let all = await getFiltered(announcements);
setTimeout(() => {
- if (all.filter(a => a.type === 'inline').length !== 0) {
- console.log('with setAnnouncement ');
+ if (all.filter((a) => a.type === "inline").length !== 0) {
+ console.log("with setAnnouncement ");
layoutmanager.withAnimation();
}
set({
- announcements: all.filter(a => a.type === 'inline'),
- dialogs: all.filter(a => a.type === 'dialog')
+ announcements: all.filter((a) => a.type === "inline"),
+ dialogs: all.filter((a) => a.type === "dialog")
});
}, 1);
}
@@ -141,13 +143,15 @@ const getFiltered = async (announcements: Announcement[]) => {
return filtered;
};
-export const allowedPlatforms = ['all', 'mobile', Platform.OS];
+export const allowedPlatforms = ["all", "mobile", Platform.OS];
async function shouldShowAnnouncement(announcement: Announcement) {
if (!announcement) return false;
- let removed = (await MMKV.getStringAsync(announcement.id)) === 'removed';
+ let removed = (await MMKV.getStringAsync(announcement.id)) === "removed";
if (removed) return false;
- let show = announcement.platforms.some(platform => allowedPlatforms.indexOf(platform) > -1);
+ let show = announcement.platforms.some(
+ (platform) => allowedPlatforms.indexOf(platform) > -1
+ );
if (announcement.appVersion) {
return announcement.appVersion === APP_VERSION;
@@ -157,28 +161,28 @@ async function shouldShowAnnouncement(announcement: Announcement) {
if (!show) return false;
const user = (await db.user?.getUser()) as User;
const subStatus = user?.subscription?.type || SUBSCRIPTION_STATUS.BASIC;
- show = announcement.userTypes.some(userType => {
+ show = announcement.userTypes.some((userType) => {
switch (userType) {
- case 'pro':
+ case "pro":
return PremiumService.get();
- case 'trial':
+ case "trial":
return subStatus === SUBSCRIPTION_STATUS.TRIAL;
- case 'trialExpired':
+ case "trialExpired":
return subStatus === SUBSCRIPTION_STATUS.BASIC;
- case 'loggedOut':
+ case "loggedOut":
return !user;
- case 'verified':
+ case "verified":
return user?.isEmailConfirmed;
- case 'loggedIn':
+ case "loggedIn":
return !!user;
- case 'unverified':
+ case "unverified":
return !user?.isEmailConfirmed;
- case 'proExpired':
+ case "proExpired":
return (
subStatus === SUBSCRIPTION_STATUS.PREMIUM_EXPIRED ||
subStatus === SUBSCRIPTION_STATUS.PREMIUM_CANCELLED
);
- case 'any':
+ case "any":
default:
return false;
}
diff --git a/apps/mobile/app/stores/use-navigation-store.ts b/apps/mobile/app/stores/use-navigation-store.ts
index 67fd8f703..bb29fa6d1 100644
--- a/apps/mobile/app/stores/use-navigation-store.ts
+++ b/apps/mobile/app/stores/use-navigation-store.ts
@@ -1,21 +1,21 @@
-import create, { State } from 'zustand';
-import { COLORS_NOTE } from '../utils/color-scheme';
-import { LiteralUnion } from '../utils/types';
+import create, { State } from "zustand";
+import { COLORS_NOTE } from "../utils/color-scheme";
+import { LiteralUnion } from "../utils/types";
export type RouteName =
- | 'Notes'
- | 'Notebooks'
- | 'Notebook'
- | 'NotesPage'
- | 'Tags'
- | 'Favorites'
- | 'Trash'
- | 'Search'
- | 'Settings'
- | 'TaggedNotes'
- | 'ColoredNotes'
- | 'TopicNotes'
- | 'Monographs';
+ | "Notes"
+ | "Notebooks"
+ | "Notebook"
+ | "NotesPage"
+ | "Tags"
+ | "Favorites"
+ | "Trash"
+ | "Search"
+ | "Settings"
+ | "TaggedNotes"
+ | "ColoredNotes"
+ | "TopicNotes"
+ | "Monographs";
export type Route = LiteralUnion<RouteName>;
@@ -50,22 +50,26 @@ interface NavigationStore extends State {
const useNavigationStore = create<NavigationStore>((set, get) => ({
currentScreen: {
- name: 'Notes',
- id: 'notes_navigation',
- title: 'Notes',
- type: 'notes'
+ name: "Notes",
+ id: "notes_navigation",
+ title: "Notes",
+ type: "notes"
},
- currentScreenRaw: { name: 'notes' },
+ currentScreenRaw: { name: "notes" },
canGoBack: false,
update: (currentScreen, canGoBack, headerRightButtons) => {
//@ts-ignore
const color = COLORS_NOTE[currentScreen.color?.toLowerCase()];
- if (JSON.stringify(currentScreen) === JSON.stringify(get().currentScreenRaw)) return;
+ if (
+ JSON.stringify(currentScreen) === JSON.stringify(get().currentScreenRaw)
+ )
+ return;
set({
currentScreen: {
name: currentScreen.name,
- id: currentScreen.id || currentScreen.name.toLowerCase() + '_navigation',
+ id:
+ currentScreen.id || currentScreen.name.toLowerCase() + "_navigation",
title: currentScreen.alias || currentScreen.title || currentScreen.name,
type: currentScreen.type,
color: color,
@@ -78,7 +82,7 @@ const useNavigationStore = create<NavigationStore>((set, get) => ({
},
headerRightButtons: [],
buttonAction: () => null,
- setButtonAction: buttonAction => set({ buttonAction })
+ setButtonAction: (buttonAction) => set({ buttonAction })
}));
export default useNavigationStore;
diff --git a/apps/mobile/app/stores/use-notebook-store.ts b/apps/mobile/app/stores/use-notebook-store.ts
index 39141c1b9..b27768453 100644
--- a/apps/mobile/app/stores/use-notebook-store.ts
+++ b/apps/mobile/app/stores/use-notebook-store.ts
@@ -1,8 +1,8 @@
//@ts-ignore
-import { groupArray } from '@streetwriters/notesnook-core/utils/grouping';
-import create, { State } from 'zustand';
-import { db } from '../common/database';
-import { NotebookType } from '../utils/types';
+import { groupArray } from "@streetwriters/notesnook-core/utils/grouping";
+import create, { State } from "zustand";
+import { db } from "../common/database";
+import { NotebookType } from "../utils/types";
export interface NotebookStore extends State {
notebooks: NotebookType[];
setNotebooks: (items?: NotebookType[]) => void;
@@ -11,12 +11,12 @@ export interface NotebookStore extends State {
export const useNotebookStore = create<NotebookStore>((set, get) => ({
notebooks: [],
- setNotebooks: items => {
+ setNotebooks: (items) => {
if (!items) {
set({
notebooks: groupArray(
(db?.notebooks?.all as NotebookType[]) || [],
- db.settings?.getGroupOptions('notebooks')
+ db.settings?.getGroupOptions("notebooks")
)
});
return;
@@ -24,7 +24,7 @@ export const useNotebookStore = create<NotebookStore>((set, get) => ({
let prev = get().notebooks;
for (let i = 0; i < items.length; i++) {
let item = items[i];
- let index = prev.findIndex(v => v.id === item.id);
+ let index = prev.findIndex((v) => v.id === item.id);
if (index !== -1) {
prev[index] = item;
}
diff --git a/apps/mobile/app/stores/use-notes-store.ts b/apps/mobile/app/stores/use-notes-store.ts
index a3aea62c7..c5deddabc 100644
--- a/apps/mobile/app/stores/use-notes-store.ts
+++ b/apps/mobile/app/stores/use-notes-store.ts
@@ -1,8 +1,8 @@
//@ts-ignore
-import { groupArray } from '@streetwriters/notesnook-core/utils/grouping';
-import create, { State } from 'zustand';
-import { db } from '../common/database';
-import { NoteType } from '../utils/types';
+import { groupArray } from "@streetwriters/notesnook-core/utils/grouping";
+import create, { State } from "zustand";
+import { db } from "../common/database";
+import { NoteType } from "../utils/types";
export interface NoteStore extends State {
notes: NoteType[];
@@ -15,19 +15,22 @@ export interface NoteStore extends State {
export const useNoteStore = create<NoteStore>((set, get) => ({
notes: [],
loading: true,
- setLoading: loading => set({ loading: loading }),
+ setLoading: (loading) => set({ loading: loading }),
- setNotes: items => {
+ setNotes: (items) => {
if (!items) {
set({
- notes: groupArray((db.notes?.all as NoteType[]) || [], db.settings?.getGroupOptions('home'))
+ notes: groupArray(
+ (db.notes?.all as NoteType[]) || [],
+ db.settings?.getGroupOptions("home")
+ )
});
return;
}
let prev = get().notes;
for (let i = 0; i < items.length; i++) {
let item = items[i];
- let index = prev.findIndex(v => v.id === item.id);
+ let index = prev.findIndex((v) => v.id === item.id);
if (index !== -1) {
prev[index] = item;
}
diff --git a/apps/mobile/app/stores/use-search-store.ts b/apps/mobile/app/stores/use-search-store.ts
index 98f553f50..71d4dc791 100644
--- a/apps/mobile/app/stores/use-search-store.ts
+++ b/apps/mobile/app/stores/use-search-store.ts
@@ -1,5 +1,5 @@
//@ts-ignore
-import create, { State } from 'zustand';
+import create, { State } from "zustand";
export interface SearchStore extends State {
searchResults: object[];
searching: boolean;
@@ -12,6 +12,7 @@ export const useSearchStore = create<SearchStore>((set, get) => ({
searchResults: [],
searching: false,
searchStatus: null,
- setSearchResults: results => set({ searchResults: results }),
- setSearchStatus: (searching, status) => set({ searching, searchStatus: status })
+ setSearchResults: (results) => set({ searchResults: results }),
+ setSearchStatus: (searching, status) =>
+ set({ searching, searchStatus: status })
}));
diff --git a/apps/mobile/app/stores/use-selection-store.ts b/apps/mobile/app/stores/use-selection-store.ts
index c75444fcd..74943f801 100644
--- a/apps/mobile/app/stores/use-selection-store.ts
+++ b/apps/mobile/app/stores/use-selection-store.ts
@@ -1,6 +1,6 @@
//@ts-ignore
-import create, { State } from 'zustand';
-import { history } from '../utils';
+import create, { State } from "zustand";
+import { history } from "../utils";
type Item = {
id: string;
@@ -18,12 +18,12 @@ export interface SelectionStore extends State {
export const useSelectionStore = create<SelectionStore>((set, get) => ({
selectedItemsList: [],
selectionMode: false,
- setAll: all => {
+ setAll: (all) => {
//@ts-ignore
history.selectedItemsList = all;
set({ selectedItemsList: all });
},
- setSelectionMode: mode => {
+ setSelectionMode: (mode) => {
if (!mode) {
history.selectedItemsList = [];
history.selectionMode = false;
@@ -35,7 +35,7 @@ export const useSelectionStore = create<SelectionStore>((set, get) => ({
selectedItemsList: mode ? get().selectedItemsList : []
});
},
- setSelectedItem: item => {
+ setSelectedItem: (item) => {
let selectedItems = get().selectedItemsList;
let index = selectedItems.findIndex((i: any) => i.id === item.id);
if (index !== -1) {
@@ -46,13 +46,14 @@ export const useSelectionStore = create<SelectionStore>((set, get) => ({
selectedItems = [...new Set(selectedItems)];
//@ts-ignore
history.selectedItemsList = selectedItems;
- history.selectionMode = selectedItems.length > 0 ? get().selectionMode : false;
+ history.selectionMode =
+ selectedItems.length > 0 ? get().selectionMode : false;
set({
selectedItemsList: selectedItems,
selectionMode: history.selectionMode
});
},
- clearSelection: noanimation => {
+ clearSelection: (noanimation) => {
history.selectedItemsList = [];
history.selectionMode = false;
set({ selectionMode: false, selectedItemsList: [] });
diff --git a/apps/mobile/app/stores/use-setting-store.ts b/apps/mobile/app/stores/use-setting-store.ts
index 3ec95661e..cc5c52926 100644
--- a/apps/mobile/app/stores/use-setting-store.ts
+++ b/apps/mobile/app/stores/use-setting-store.ts
@@ -1,9 +1,9 @@
//@ts-ignore
-import { Dimensions } from 'react-native';
-import Config from 'react-native-config';
-import { FileType } from 'react-native-scoped-storage';
-import create, { State } from 'zustand';
-import { ACCENT } from '../utils/color-scheme';
+import { Dimensions } from "react-native";
+import Config from "react-native-config";
+import { FileType } from "react-native-scoped-storage";
+import create, { State } from "zustand";
+import { ACCENT } from "../utils/color-scheme";
export type Settings = {
showToolbarOnTop?: boolean;
@@ -20,8 +20,8 @@ export type Settings = {
privacyScreen?: boolean;
appLockMode?: string;
telemetry?: boolean;
- notebooksListMode?: 'normal' | 'compact';
- notesListMode?: 'normal' | 'compact';
+ notebooksListMode?: "normal" | "compact";
+ notesListMode?: "normal" | "compact";
devMode?: boolean;
notifNotes?: boolean;
pitchBlack?: boolean;
@@ -68,7 +68,7 @@ export interface SettingStore extends State {
setRequestBiometrics: (requestBiometrics: boolean) => void;
}
-let { width, height } = Dimensions.get('window');
+let { width, height } = Dimensions.get("window");
export const useSettingStore = create<SettingStore>((set, get) => ({
settings: {
@@ -77,17 +77,17 @@ export const useSettingStore = create<SettingStore>((set, get) => ({
fontScale: 1,
forcePortraitOnTablet: false,
useSystemTheme: false,
- reminder: 'off',
+ reminder: "off",
encryptedBackup: false,
- homepage: 'Notes',
- sort: 'default',
- sortOrder: 'desc',
+ homepage: "Notes",
+ sort: "default",
+ sortOrder: "desc",
screenshotMode: true,
privacyScreen: false,
- appLockMode: 'none',
+ appLockMode: "none",
telemetry: true,
- notebooksListMode: 'normal',
- notesListMode: 'normal',
+ notebooksListMode: "normal",
+ notesListMode: "normal",
devMode: false,
notifNotes: false,
pitchBlack: false,
@@ -110,15 +110,16 @@ export const useSettingStore = create<SettingStore>((set, get) => ({
},
sheetKeyboardHandler: true,
fullscreen: false,
- deviceMode: 'mobile',
+ deviceMode: "mobile",
dimensions: { width, height },
appLoading: true,
- setSettings: settings => set({ settings }),
- setFullscreen: fullscreen => set({ fullscreen }),
- setDeviceMode: mode => set({ deviceMode: mode }),
- setDimensions: dimensions => set({ dimensions: dimensions }),
- setAppLoading: appLoading => set({ appLoading }),
- setSheetKeyboardHandler: sheetKeyboardHandler => set({ sheetKeyboardHandler }),
+ setSettings: (settings) => set({ settings }),
+ setFullscreen: (fullscreen) => set({ fullscreen }),
+ setDeviceMode: (mode) => set({ deviceMode: mode }),
+ setDimensions: (dimensions) => set({ dimensions: dimensions }),
+ setAppLoading: (appLoading) => set({ appLoading }),
+ setSheetKeyboardHandler: (sheetKeyboardHandler) =>
+ set({ sheetKeyboardHandler }),
requestBiometrics: false,
- setRequestBiometrics: requestBiometrics => set({ requestBiometrics })
+ setRequestBiometrics: (requestBiometrics) => set({ requestBiometrics })
}));
diff --git a/apps/mobile/app/stores/use-tag-store.ts b/apps/mobile/app/stores/use-tag-store.ts
index 66521f29c..53da39d2b 100644
--- a/apps/mobile/app/stores/use-tag-store.ts
+++ b/apps/mobile/app/stores/use-tag-store.ts
@@ -1,9 +1,9 @@
//@ts-ignore
-import '@streetwriters/notesnook-core/types';
-import { groupArray } from '@streetwriters/notesnook-core/utils/grouping';
-import create, { State } from 'zustand';
-import { db } from '../common/database';
-import { TagType } from '../utils/types';
+import "@streetwriters/notesnook-core/types";
+import { groupArray } from "@streetwriters/notesnook-core/utils/grouping";
+import create, { State } from "zustand";
+import { db } from "../common/database";
+import { TagType } from "../utils/types";
export interface TagStore extends State {
tags: TagType[];
@@ -13,17 +13,20 @@ export interface TagStore extends State {
export const useTagStore = create<TagStore>((set, get) => ({
tags: [],
- setTags: items => {
+ setTags: (items) => {
if (!items) {
set({
- tags: groupArray((db?.tags?.all as TagType[]) || [], db.settings?.getGroupOptions('tags'))
+ tags: groupArray(
+ (db?.tags?.all as TagType[]) || [],
+ db.settings?.getGroupOptions("tags")
+ )
});
return;
}
let prev = get().tags;
for (let i = 0; i < items.length; i++) {
let item = items[i];
- let index = prev.findIndex(v => v.id === item.id);
+ let index = prev.findIndex((v) => v.id === item.id);
if (index !== -1) {
prev[index] = item;
}
diff --git a/apps/mobile/app/stores/use-theme-store.ts b/apps/mobile/app/stores/use-theme-store.ts
index 3dd5f8185..20888ffeb 100644
--- a/apps/mobile/app/stores/use-theme-store.ts
+++ b/apps/mobile/app/stores/use-theme-store.ts
@@ -1,8 +1,8 @@
-import { Appearance } from 'react-native';
-import create, { State } from 'zustand';
-import { COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT } from '../utils/color-scheme';
+import { Appearance } from "react-native";
+import create, { State } from "zustand";
+import { COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT } from "../utils/color-scheme";
-const darkScheme = Appearance.getColorScheme() === 'dark';
+const darkScheme = Appearance.getColorScheme() === "dark";
export interface ThemeStore extends State {
colors: typeof COLOR_SCHEME_LIGHT;
setColors: (colors: typeof COLOR_SCHEME_LIGHT) => void;
@@ -10,7 +10,7 @@ export interface ThemeStore extends State {
export const useThemeStore = create<ThemeStore>((set, get) => ({
colors: darkScheme ? COLOR_SCHEME_DARK : COLOR_SCHEME_LIGHT,
- setColors: colors => {
+ setColors: (colors) => {
set({ colors });
}
}));
diff --git a/apps/mobile/app/stores/use-trash-store.ts b/apps/mobile/app/stores/use-trash-store.ts
index 94a25b52a..c90dc00cc 100644
--- a/apps/mobile/app/stores/use-trash-store.ts
+++ b/apps/mobile/app/stores/use-trash-store.ts
@@ -1,8 +1,8 @@
//@ts-ignore
-import { groupArray } from '@streetwriters/notesnook-core/utils/grouping';
-import create, { State } from 'zustand';
-import { db } from '../common/database';
-import { TrashType } from '../utils/types';
+import { groupArray } from "@streetwriters/notesnook-core/utils/grouping";
+import create, { State } from "zustand";
+import { db } from "../common/database";
+import { TrashType } from "../utils/types";
export interface TrashStore extends State {
trash: Array<TrashType>;
@@ -12,17 +12,20 @@ export interface TrashStore extends State {
export const useTrashStore = create<TrashStore>((set, get) => ({
trash: [],
- setTrash: items => {
+ setTrash: (items) => {
if (!items) {
set({
- trash: groupArray(db?.trash?.all || [], db.settings?.getGroupOptions('trash'))
+ trash: groupArray(
+ db?.trash?.all || [],
+ db.settings?.getGroupOptions("trash")
+ )
});
return;
}
let prev = get().trash;
for (let i = 0; i < items.length; i++) {
let item = items[i];
- let index = prev.findIndex(v => v.id === item.id);
+ let index = prev.findIndex((v) => v.id === item.id);
if (index !== -1) {
prev[index] = item;
}
diff --git a/apps/mobile/app/stores/use-user-store.ts b/apps/mobile/app/stores/use-user-store.ts
index 43b3ba11a..ec1bc0fc9 100644
--- a/apps/mobile/app/stores/use-user-store.ts
+++ b/apps/mobile/app/stores/use-user-store.ts
@@ -1,5 +1,5 @@
//@ts-ignore
-import create, { State } from 'zustand';
+import create, { State } from "zustand";
export interface UserStore extends State {
user: User | null | undefined;
@@ -17,12 +17,12 @@ export interface UserStore extends State {
export const useUserStore = create<UserStore>((set, get) => ({
user: null,
premium: false,
- lastSynced: 'Never',
+ lastSynced: "Never",
syncing: false,
verifyUser: false,
- setUser: user => set({ user: user }),
- setPremium: premium => set({ premium: premium }),
- setSyncing: syncing => set({ syncing: syncing }),
- setLastSynced: lastSynced => set({ lastSynced: lastSynced }),
- setVerifyUser: verified => set({ verifyUser: verified })
+ setUser: (user) => set({ user: user }),
+ setPremium: (premium) => set({ premium: premium }),
+ setSyncing: (syncing) => set({ syncing: syncing }),
+ setLastSynced: (lastSynced) => set({ lastSynced: lastSynced }),
+ setVerifyUser: (verified) => set({ verifyUser: verified })
}));
diff --git a/apps/mobile/app/utils/color-scheme/index.js b/apps/mobile/app/utils/color-scheme/index.js
index 5234b4352..2c09bb97d 100644
--- a/apps/mobile/app/utils/color-scheme/index.js
+++ b/apps/mobile/app/utils/color-scheme/index.js
@@ -1,107 +1,107 @@
-import { Platform, StatusBar } from 'react-native';
-import { AndroidModule } from '..';
-import { eSendEvent } from '../../services/event-manager';
-import { useThemeStore } from '../../stores/use-theme-store';
-import { eThemeUpdated } from '../events';
+import { Platform, StatusBar } from "react-native";
+import { AndroidModule } from "..";
+import { eSendEvent } from "../../services/event-manager";
+import { useThemeStore } from "../../stores/use-theme-store";
+import { eThemeUpdated } from "../events";
export const ACCENT = {
- color: '#008837',
- shade: '#00883712'
+ color: "#008837",
+ shade: "#00883712"
};
export const COLORS_NOTE = {
- red: '#f44336',
- orange: '#FF9800',
- yellow: '#F9D71C',
- green: '#4CAF50',
- blue: '#2196F3',
- purple: '#673AB7',
- gray: '#9E9E9E'
+ red: "#f44336",
+ orange: "#FF9800",
+ yellow: "#F9D71C",
+ green: "#4CAF50",
+ blue: "#2196F3",
+ purple: "#673AB7",
+ gray: "#9E9E9E"
};
const fixedColors = {
accent: ACCENT.color,
shade: ACCENT.shade,
fg: ACCENT.color,
- normal: 'black',
- icon: 'gray',
- transGray: '#00000010',
- errorBg: '#f4433620',
- errorText: '#ff6961',
- successBg: '#DFF2BF',
- successText: '#4F8A10',
- warningBg: '#FF990020',
- warningText: '#FF9900',
- red: '#f44336',
- orange: '#FF9800',
- yellow: '#FFD600',
- green: '#4CAF50',
- blue: '#2196F3',
- purple: '#673AB7',
- gray: '#9E9E9E',
- discord: '#5865F2'
+ normal: "black",
+ icon: "gray",
+ transGray: "#00000010",
+ errorBg: "#f4433620",
+ errorText: "#ff6961",
+ successBg: "#DFF2BF",
+ successText: "#4F8A10",
+ warningBg: "#FF990020",
+ warningText: "#FF9900",
+ red: "#f44336",
+ orange: "#FF9800",
+ yellow: "#FFD600",
+ green: "#4CAF50",
+ blue: "#2196F3",
+ purple: "#673AB7",
+ gray: "#9E9E9E",
+ discord: "#5865F2"
};
export var COLOR_SCHEME = {
...fixedColors,
night: false,
- bg: '#ffffff',
- navbg: '#f7f7f7',
- nav: '#f7f7f7',
- input: 'transparent',
- heading: '#212121',
- pri: '#505050',
- sec: '#ffffff',
- light: '#ffffff',
- transGray: '#00000010',
- border: '#E8E8E8',
- placeholder: '#a9a9a9'
+ bg: "#ffffff",
+ navbg: "#f7f7f7",
+ nav: "#f7f7f7",
+ input: "transparent",
+ heading: "#212121",
+ pri: "#505050",
+ sec: "#ffffff",
+ light: "#ffffff",
+ transGray: "#00000010",
+ border: "#E8E8E8",
+ placeholder: "#a9a9a9"
};
export const COLOR_SCHEME_LIGHT = {
...fixedColors,
night: false,
- bg: '#ffffff',
- navbg: '#f7f7f7',
- nav: '#f7f7f7',
- input: 'transparent',
- heading: '#212121',
- pri: '#505050',
- sec: '#ffffff',
- light: '#ffffff',
- transGray: '#00000010',
- border: '#E8E8E8',
- placeholder: '#a9a9a9'
+ bg: "#ffffff",
+ navbg: "#f7f7f7",
+ nav: "#f7f7f7",
+ input: "transparent",
+ heading: "#212121",
+ pri: "#505050",
+ sec: "#ffffff",
+ light: "#ffffff",
+ transGray: "#00000010",
+ border: "#E8E8E8",
+ placeholder: "#a9a9a9"
};
export const COLOR_SCHEME_PITCH_BLACK = {
...fixedColors,
night: true,
- bg: '#000000',
- navbg: '#2b2b2b',
- input: '#2d2d2d',
- nav: '#1a1a1a',
- heading: '#E8E8E8',
- pri: '#C0C0C0',
- sec: 'black',
- light: '#ffffff',
- transGray: '#ffffff10',
- border: '#383838',
- placeholder: '#404040'
+ bg: "#000000",
+ navbg: "#2b2b2b",
+ input: "#2d2d2d",
+ nav: "#1a1a1a",
+ heading: "#E8E8E8",
+ pri: "#C0C0C0",
+ sec: "black",
+ light: "#ffffff",
+ transGray: "#ffffff10",
+ border: "#383838",
+ placeholder: "#404040"
};
export const COLOR_SCHEME_DARK = {
...fixedColors,
night: true,
- bg: '#1f1f1f',
- navbg: '#2b2b2b',
- input: '#2d2d2d',
- nav: '#2b2b2b',
- heading: '#E8E8E8',
- pri: '#C0C0C0',
- sec: 'black',
- light: '#ffffff',
- transGray: '#ffffff10',
- border: '#383838',
- placeholder: '#404040'
+ bg: "#1f1f1f",
+ navbg: "#2b2b2b",
+ input: "#2d2d2d",
+ nav: "#2b2b2b",
+ heading: "#E8E8E8",
+ pri: "#C0C0C0",
+ sec: "black",
+ light: "#ffffff",
+ transGray: "#ffffff10",
+ border: "#383838",
+ placeholder: "#404040"
};
export function getCurrentColors() {
@@ -113,10 +113,13 @@ export function setColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
useThemeStore.getState().setColors({ ...COLOR_SCHEME });
- StatusBar.setBarStyle(COLOR_SCHEME.night ? 'light-content' : 'dark-content', false);
- if (Platform.OS === 'android') {
+ StatusBar.setBarStyle(
+ COLOR_SCHEME.night ? "light-content" : "dark-content",
+ false
+ );
+ if (Platform.OS === "android") {
AndroidModule.setBackgroundColor(COLOR_SCHEME.bg);
- StatusBar.setBackgroundColor('transparent', false);
+ StatusBar.setBackgroundColor("transparent", false);
StatusBar.setTranslucent(true, false);
}
eSendEvent(eThemeUpdated);
@@ -126,15 +129,18 @@ export function setColorScheme(colors = COLOR_SCHEME, accent = ACCENT) {
export function setAccentColor(color) {
ACCENT.color = color;
- ACCENT.shade = color + '12';
+ ACCENT.shade = color + "12";
return ACCENT;
}
export function updateStatusBarColor() {
- StatusBar.setBarStyle(COLOR_SCHEME.night ? 'light-content' : 'dark-content', true);
- if (Platform.OS === 'android') {
- StatusBar.setBackgroundColor('transparent', true);
+ StatusBar.setBarStyle(
+ COLOR_SCHEME.night ? "light-content" : "dark-content",
+ true
+ );
+ if (Platform.OS === "android") {
+ StatusBar.setBackgroundColor("transparent", true);
StatusBar.setTranslucent(true, true);
}
}
diff --git a/apps/mobile/app/utils/color-scheme/utils.js b/apps/mobile/app/utils/color-scheme/utils.js
index 9e0af519d..2415e3cc7 100644
--- a/apps/mobile/app/utils/color-scheme/utils.js
+++ b/apps/mobile/app/utils/color-scheme/utils.js
@@ -1,4 +1,4 @@
-import { Appearance } from 'react-native';
+import { Appearance } from "react-native";
import {
COLOR_SCHEME,
COLOR_SCHEME_DARK,
@@ -6,17 +6,19 @@ import {
COLOR_SCHEME_PITCH_BLACK,
setAccentColor,
setColorScheme
-} from '.';
-import SettingsService from '../../services/settings';
+} from ".";
+import SettingsService from "../../services/settings";
-const isValidHex = hex => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
-const getChunksFromString = (st, chunkSize) => st.match(new RegExp(`.{${chunkSize}}`, 'g'));
-const convertHexUnitTo256 = hexStr => parseInt(hexStr.repeat(2 / hexStr.length), 16);
+const isValidHex = (hex) => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
+const getChunksFromString = (st, chunkSize) =>
+ st.match(new RegExp(`.{${chunkSize}}`, "g"));
+const convertHexUnitTo256 = (hexStr) =>
+ parseInt(hexStr.repeat(2 / hexStr.length), 16);
const getAlphaFloat = (a, alpha) => {
- if (typeof a !== 'undefined') {
+ if (typeof a !== "undefined") {
return a / 256;
}
- if (typeof alpha !== 'undefined') {
+ if (typeof alpha !== "undefined") {
if (1 < alpha && alpha <= 100) {
return alpha / 100;
}
@@ -27,8 +29,8 @@ const getAlphaFloat = (a, alpha) => {
return 1;
};
const rgbRes = {
- color: '',
- result: ''
+ color: "",
+ result: ""
};
export const hexToRGBA = (hex, alpha) => {
if (rgbRes.color === hex) return rgbRes.result;
@@ -41,9 +43,9 @@ export const hexToRGBA = (hex, alpha) => {
return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`;
};
const shadeRes = {
- color: '',
+ color: "",
alpha: 0,
- result: ''
+ result: ""
};
export const RGB_Linear_Shade = (p, rgba) => {
if (shadeRes.color === rgba && shadeRes.alpha === p) return shadeRes.result;
@@ -51,17 +53,17 @@ export const RGB_Linear_Shade = (p, rgba) => {
r = Math.round,
P = p < 0,
t = P ? 0 : 255 * p,
- [a, b, c, d] = rgba.split(',');
+ [a, b, c, d] = rgba.split(",");
P = P ? 1 + p : 1 - p;
return (
- 'rgb' +
- (d ? 'a(' : '(') +
- r(i(a[3] === 'a' ? a.slice(5) : a.slice(4)) * P + t) +
- ',' +
+ "rgb" +
+ (d ? "a(" : "(") +
+ r(i(a[3] === "a" ? a.slice(5) : a.slice(4)) * P + t) +
+ "," +
r(i(b) * P + t) +
- ',' +
+ "," +
r(i(c) * P + t) +
- (d ? ',' + d : ')')
+ (d ? "," + d : ")")
);
};
@@ -71,24 +73,24 @@ export function getColorScheme(overrideSystemTheme) {
if (useSystemTheme && !overrideSystemTheme) {
setAccentColor(theme.accent);
- Appearance.getColorScheme() === 'dark'
+ Appearance.getColorScheme() === "dark"
? setColorScheme(darkTheme)
: setColorScheme(COLOR_SCHEME_LIGHT);
SettingsService.set({
theme: {
...theme,
- dark: Appearance.getColorScheme() === 'dark'
+ dark: Appearance.getColorScheme() === "dark"
}
});
return COLOR_SCHEME;
}
- console.log('override system theme');
+ console.log("override system theme");
setAccentColor(theme.accent);
setColorScheme(theme.dark ? darkTheme : COLOR_SCHEME_LIGHT);
return COLOR_SCHEME;
}
-export const switchAccentColor = async color => {
+export const switchAccentColor = async (color) => {
setAccentColor(color);
let settings = SettingsService.get();
SettingsService.set({
diff --git a/apps/mobile/app/utils/constants.js b/apps/mobile/app/utils/constants.js
index f7f08b4c2..5a7da5b2b 100644
--- a/apps/mobile/app/utils/constants.js
+++ b/apps/mobile/app/utils/constants.js
@@ -1,43 +1,43 @@
-import { Platform } from 'react-native';
-import { Monographs } from '../screens/notes/monographs';
-import { eSendEvent } from '../services/event-manager';
-import Navigation from '../services/navigation';
-import { refreshNotesPage } from './events';
+import { Platform } from "react-native";
+import { Monographs } from "../screens/notes/monographs";
+import { eSendEvent } from "../services/event-manager";
+import Navigation from "../services/navigation";
+import { refreshNotesPage } from "./events";
export const STORE_LINK =
- Platform.OS === 'ios'
- ? 'https://apps.apple.com/us/app/notesnook/id1544027013'
- : 'https://play.google.com/store/apps/details?id=com.streetwriters.notesnook';
+ Platform.OS === "ios"
+ ? "https://apps.apple.com/us/app/notesnook/id1544027013"
+ : "https://play.google.com/store/apps/details?id=com.streetwriters.notesnook";
export const GROUP = {
- default: 'default',
- None: 'none',
- abc: 'abc',
- year: 'year',
- week: 'week',
- month: 'month'
+ default: "default",
+ None: "none",
+ abc: "abc",
+ year: "year",
+ week: "week",
+ month: "month"
};
export const SORT = {
- dateEdited: 'Date edited',
- dateCreated: 'Date created',
- title: 'Title'
+ dateEdited: "Date edited",
+ dateCreated: "Date created",
+ title: "Title"
};
export const itemSkus = [
- 'com.streetwriters.notesnook.sub.mo',
- 'com.streetwriters.notesnook.sub.yr',
- 'com.streetwriters.notesnook.sub.yr.15',
- 'com.streetwriters.notesnook.sub.mo.15',
- 'com.streetwriters.notesnook.sub.mo.ofr',
- 'com.streetwriters.notesnook.sub.yr.trialoffer',
- 'com.streetwriters.notesnook.sub.mo.trialoffer',
- 'com.streetwriters.notesnook.sub.mo.tier1',
- 'com.streetwriters.notesnook.sub.yr.tier1',
- 'com.streetwriters.notesnook.sub.mo.tier2',
- 'com.streetwriters.notesnook.sub.yr.tier2',
- 'com.streetwriters.notesnook.sub.mo.tier3',
- 'com.streetwriters.notesnook.sub.yr.tier3'
+ "com.streetwriters.notesnook.sub.mo",
+ "com.streetwriters.notesnook.sub.yr",
+ "com.streetwriters.notesnook.sub.yr.15",
+ "com.streetwriters.notesnook.sub.mo.15",
+ "com.streetwriters.notesnook.sub.mo.ofr",
+ "com.streetwriters.notesnook.sub.yr.trialoffer",
+ "com.streetwriters.notesnook.sub.mo.trialoffer",
+ "com.streetwriters.notesnook.sub.mo.tier1",
+ "com.streetwriters.notesnook.sub.yr.tier1",
+ "com.streetwriters.notesnook.sub.mo.tier2",
+ "com.streetwriters.notesnook.sub.yr.tier2",
+ "com.streetwriters.notesnook.sub.mo.tier3",
+ "com.streetwriters.notesnook.sub.yr.tier3"
];
export const SUBSCRIPTION_STATUS = {
@@ -50,92 +50,92 @@ export const SUBSCRIPTION_STATUS = {
};
export const SUBSCRIPTION_STATUS_STRINGS = {
- 0: 'Basic',
- 1: 'Trial',
- 2: Platform.OS === 'ios' ? 'Pro' : 'Beta',
- 5: 'Pro',
- 6: 'Expired',
- 7: 'Pro'
+ 0: "Basic",
+ 1: "Trial",
+ 2: Platform.OS === "ios" ? "Pro" : "Beta",
+ 5: "Pro",
+ 6: "Expired",
+ 7: "Pro"
};
export const SUBSCRIPTION_PROVIDER = {
0: null,
1: {
- type: 'iOS',
- title: 'Subscribed on iOS',
- desc: 'You subscribed to Notesnook Pro on iOS using Apple In App Purchase. You can cancel anytime with your iTunes Account settings.',
- icon: 'ios'
+ type: "iOS",
+ title: "Subscribed on iOS",
+ desc: "You subscribed to Notesnook Pro on iOS using Apple In App Purchase. You can cancel anytime with your iTunes Account settings.",
+ icon: "ios"
},
2: {
- type: 'Android',
- title: 'Subscribed on Android',
- desc: 'You subscribed to Notesnook Pro on Android Phone/Tablet using Google In App Purchase.',
- icon: 'android'
+ type: "Android",
+ title: "Subscribed on Android",
+ desc: "You subscribed to Notesnook Pro on Android Phone/Tablet using Google In App Purchase.",
+ icon: "android"
},
3: {
- type: 'Web',
- title: 'Subscribed on Web',
- desc: 'You subscribed to Notesnook Pro on the Web/Desktop App.',
- icon: 'web'
+ type: "Web",
+ title: "Subscribed on Web",
+ desc: "You subscribed to Notesnook Pro on the Web/Desktop App.",
+ icon: "web"
}
};
export const MenuItemsList = [
{
- name: 'Notes',
- icon: 'home-variant-outline',
+ name: "Notes",
+ icon: "home-variant-outline",
close: true
},
{
- name: 'Notebooks',
- icon: 'book-outline',
+ name: "Notebooks",
+ icon: "book-outline",
close: true
},
{
- name: 'Favorites',
- icon: 'star-outline',
+ name: "Favorites",
+ icon: "star-outline",
close: true
},
{
- name: 'Tags',
- icon: 'pound',
+ name: "Tags",
+ icon: "pound",
close: true
},
{
- name: 'Monographs',
- icon: 'text-box-multiple-outline',
+ name: "Monographs",
+ icon: "text-box-multiple-outline",
close: true,
func: () => {
Monographs.navigate();
}
},
{
- name: 'Trash',
- icon: 'delete-outline',
+ name: "Trash",
+ icon: "delete-outline",
close: true
}
];
export const BUTTON_TYPES = {
transparent: {
- primary: 'transparent',
- text: 'accent',
- selected: 'nav'
+ primary: "transparent",
+ text: "accent",
+ selected: "nav"
},
gray: {
- primary: 'transparent',
- text: 'icon',
- selected: 'transGray'
+ primary: "transparent",
+ text: "icon",
+ selected: "transGray"
},
grayBg: {
- primary: 'nav',
- text: 'icon',
- selected: 'nav'
+ primary: "nav",
+ text: "icon",
+ selected: "nav"
},
grayAccent: {
- primary: 'nav',
- text: 'accent',
- selected: 'nav'
+ primary: "nav",
+ text: "accent",
+ selected: "nav"
},
accent: (themeColor, text) => ({
primary: themeColor,
@@ -143,49 +143,49 @@ export const BUTTON_TYPES = {
selected: themeColor
}),
inverted: {
- primary: 'bg',
- text: 'accent',
- selected: 'bg'
+ primary: "bg",
+ text: "accent",
+ selected: "bg"
},
white: {
- primary: 'transparent',
- text: 'light',
- selected: 'transGray'
+ primary: "transparent",
+ text: "light",
+ selected: "transGray"
},
shade: {
- primary: 'shade',
- text: 'accent',
- selected: 'accent',
+ primary: "shade",
+ text: "accent",
+ selected: "accent",
opacity: 0.12
},
error: {
- primary: 'red',
- text: 'red',
- selected: 'red',
+ primary: "red",
+ text: "red",
+ selected: "red",
opacity: 0.12
},
errorShade: {
- primary: 'transparent',
- text: 'red',
- selected: 'red',
+ primary: "transparent",
+ text: "red",
+ selected: "red",
opacity: 0.12
},
warn: {
- primary: 'warningBg',
- text: 'warningText',
- selected: 'warningBg',
+ primary: "warningBg",
+ text: "warningText",
+ selected: "warningBg",
opacity: 0.12
}
};
export const bgTaskOptions = {
- taskName: 'notesnookSync',
- taskTitle: 'Notesnook Sync',
- taskDesc: 'Syncing your notes.',
+ taskName: "notesnookSync",
+ taskTitle: "Notesnook Sync",
+ taskDesc: "Syncing your notes.",
taskIcon: {
- name: 'ic_stat_name',
- type: 'drawable'
+ name: "ic_stat_name",
+ type: "drawable"
},
- color: '#ffffff',
- linkingURI: 'com.streetwriters.notesnook://launch'
+ color: "#ffffff",
+ linkingURI: "com.streetwriters.notesnook://launch"
};
diff --git a/apps/mobile/app/utils/events.js b/apps/mobile/app/utils/events.js
index 52959daf2..47fadfebc 100644
--- a/apps/mobile/app/utils/events.js
+++ b/apps/mobile/app/utils/events.js
@@ -1,138 +1,138 @@
-export const eOnLoadNote = '500';
+export const eOnLoadNote = "500";
-export const eOpenActionSheet = '501';
+export const eOpenActionSheet = "501";
-export const eCloseActionSheet = '502';
+export const eCloseActionSheet = "502";
-export const eOpenSimpleDialog = '503';
+export const eOpenSimpleDialog = "503";
-export const eCloseSimpleDialog = '504';
+export const eCloseSimpleDialog = "504";
-export const eOpenMoveNoteDialog = '505';
+export const eOpenMoveNoteDialog = "505";
-export const eCloseMoveNoteDialog = '506';
+export const eCloseMoveNoteDialog = "506";
-export const eOpenAddNotebookDialog = '507';
+export const eOpenAddNotebookDialog = "507";
-export const eCloseAddNotebookDialog = '508';
+export const eCloseAddNotebookDialog = "508";
-export const eOpenAddTopicDialog = '509';
+export const eOpenAddTopicDialog = "509";
-export const eCloseAddTopicDialog = '510';
+export const eCloseAddTopicDialog = "510";
-export const eOpenLoginDialog = '511';
+export const eOpenLoginDialog = "511";
-export const eCloseLoginDialog = '512';
+export const eCloseLoginDialog = "512";
-export const eLoginDialogNavigateBack = '514';
+export const eLoginDialogNavigateBack = "514";
-export const eOpenSideMenu = '515';
+export const eOpenSideMenu = "515";
-export const eCloseSideMenu = '516';
+export const eCloseSideMenu = "516";
-export const eOpenFullscreenEditor = '517';
+export const eOpenFullscreenEditor = "517";
-export const eCloseFullscreenEditor = '518';
+export const eCloseFullscreenEditor = "518";
-export const eEnableGestures = '519';
+export const eEnableGestures = "519";
-export const eDisableGestures = '520';
+export const eDisableGestures = "520";
-export const eOpenModalMenu = '521';
+export const eOpenModalMenu = "521";
-export const eCloseModalMenu = '522';
+export const eCloseModalMenu = "522";
-export const eSendSideMenuOverlayRef = '523';
+export const eSendSideMenuOverlayRef = "523";
-export const eMoveNoteDialogNavigateBack = '524';
+export const eMoveNoteDialogNavigateBack = "524";
-export const eShowToast = '525';
+export const eShowToast = "525";
-export const eHideToast = '526';
+export const eHideToast = "526";
-export const eThemeUpdated = '527';
+export const eThemeUpdated = "527";
-export const eScrollEvent = '528';
+export const eScrollEvent = "528";
-export const eOnNewTopicAdded = '529';
+export const eOnNewTopicAdded = "529";
-export const eOpenVaultDialog = '530';
+export const eOpenVaultDialog = "530";
-export const eCloseVaultDialog = '531';
+export const eCloseVaultDialog = "531";
-export const refreshNotesPage = '532';
+export const refreshNotesPage = "532";
-export const eClearSearch = '533';
+export const eClearSearch = "533";
-export const eClearEditor = '534';
+export const eClearEditor = "534";
-export const eApplyChanges = '535';
+export const eApplyChanges = "535";
-export const eShowMergeDialog = '536';
+export const eShowMergeDialog = "536";
-export const eSwitchNightMode = '537';
+export const eSwitchNightMode = "537";
-export const eStartSyncer = '538';
+export const eStartSyncer = "538";
-export const eSetModalNavigator = '539';
+export const eSetModalNavigator = "539";
-export const eOpenPremiumDialog = '540';
+export const eOpenPremiumDialog = "540";
-export const eClosePremiumDialog = '541';
+export const eClosePremiumDialog = "541";
-export const eResetApp = '542';
+export const eResetApp = "542";
-export const eOpenExportDialog = '543';
+export const eOpenExportDialog = "543";
-export const eCloseExportDialog = '544';
+export const eCloseExportDialog = "544";
-export const eOpenRecoveryKeyDialog = '545';
+export const eOpenRecoveryKeyDialog = "545";
-export const eCloseRecoveryKeyDialog = '546';
+export const eCloseRecoveryKeyDialog = "546";
-export const eOpenPendingDialog = '547';
+export const eOpenPendingDialog = "547";
-export const eClosePendingDialog = '548';
+export const eClosePendingDialog = "548";
-export const eOpenPremiumStatusDialog = '549';
+export const eOpenPremiumStatusDialog = "549";
-export const eClosePremiumStatusDialog = '550';
+export const eClosePremiumStatusDialog = "550";
-export const eOpenProgressDialog = '551';
+export const eOpenProgressDialog = "551";
-export const eCloseProgressDialog = '552';
+export const eCloseProgressDialog = "552";
-export const eOpenRestoreDialog = '553';
+export const eOpenRestoreDialog = "553";
-export const eCloseRestoreDialog = '554';
+export const eCloseRestoreDialog = "554";
-export const eOnNoteEdited = '555';
+export const eOnNoteEdited = "555";
-export const eUpdateSearchState = '556';
+export const eUpdateSearchState = "556";
-export const eOpenResultDialog = '557';
-export const eCloseResultDialog = '558';
+export const eOpenResultDialog = "557";
+export const eCloseResultDialog = "558";
-export const eOpenSortDialog = '559';
-export const eCloseSortDialog = '560';
+export const eOpenSortDialog = "559";
+export const eCloseSortDialog = "560";
-export const eOpenJumpToDialog = '561';
-export const eCloseJumpToDialog = '562';
+export const eOpenJumpToDialog = "561";
+export const eCloseJumpToDialog = "562";
-export const eShowGetPremium = '563';
-export const eOpenRateDialog = '564';
-export const eCloseRateDialog = '565';
+export const eShowGetPremium = "563";
+export const eOpenRateDialog = "564";
+export const eCloseRateDialog = "565";
-export const eOpenPublishNoteDialog = '566';
-export const eClosePublishNoteDialog = '567';
+export const eOpenPublishNoteDialog = "566";
+export const eClosePublishNoteDialog = "567";
-export const eOpenTagsDialog = '568';
-export const eCloseTagsDialog = '569';
+export const eOpenTagsDialog = "568";
+export const eCloseTagsDialog = "569";
-export const eOpenAttachmentsDialog = '600';
-export const eCloseAttachmentDialog = '601';
+export const eOpenAttachmentsDialog = "600";
+export const eCloseAttachmentDialog = "601";
-export const eOpenTrialEndingDialog = '602';
+export const eOpenTrialEndingDialog = "602";
-export const eOpenAnnouncementDialog = '603';
-export const eCloseAnnouncementDialog = '604';
+export const eOpenAnnouncementDialog = "603";
+export const eCloseAnnouncementDialog = "604";
diff --git a/apps/mobile/app/utils/functions.js b/apps/mobile/app/utils/functions.js
index 92ad9c35c..13b156172 100644
--- a/apps/mobile/app/utils/functions.js
+++ b/apps/mobile/app/utils/functions.js
@@ -1,20 +1,20 @@
-import { Linking } from 'react-native';
-import { history } from '.';
-import { eSendEvent, ToastEvent } from '../services/event-manager';
-import Navigation from '../services/navigation';
-import SearchService from '../services/search';
-import { useSelectionStore } from '../stores/use-selection-store';
-import { useMenuStore } from '../stores/use-menu-store';
-import { db } from '../common/database';
-import { eClearEditor } from './events';
+import { Linking } from "react-native";
+import { history } from ".";
+import { eSendEvent, ToastEvent } from "../services/event-manager";
+import Navigation from "../services/navigation";
+import SearchService from "../services/search";
+import { useSelectionStore } from "../stores/use-selection-store";
+import { useMenuStore } from "../stores/use-menu-store";
+import { db } from "../common/database";
+import { eClearEditor } from "./events";
-export const deleteItems = async item => {
+export const deleteItems = async (item) => {
if (item && db.monographs.isPublished(item.id)) {
ToastEvent.show({
- heading: 'Can not delete note',
- message: 'Unpublish note to delete it',
- type: 'error',
- context: 'global'
+ heading: "Can not delete note",
+ message: "Unpublish note to delete it",
+ type: "error",
+ context: "global"
});
return;
}
@@ -23,35 +23,37 @@ export const deleteItems = async item => {
history.selectedItemsList.push(item);
}
- let notes = history.selectedItemsList.filter(i => i.type === 'note');
- let notebooks = history.selectedItemsList.filter(i => i.type === 'notebook');
- let topics = history.selectedItemsList.filter(i => i.type === 'topic');
+ let notes = history.selectedItemsList.filter((i) => i.type === "note");
+ let notebooks = history.selectedItemsList.filter(
+ (i) => i.type === "notebook"
+ );
+ let topics = history.selectedItemsList.filter((i) => i.type === "topic");
if (notes?.length > 0) {
let ids = notes
- .map(i => {
+ .map((i) => {
if (db.monographs.isPublished(i.id)) {
ToastEvent.show({
- heading: 'Some notes are published',
- message: 'Unpublish published notes to delete them',
- type: 'error',
- context: 'global'
+ heading: "Some notes are published",
+ message: "Unpublish published notes to delete them",
+ type: "error",
+ context: "global"
});
return null;
}
return i.id;
})
- .filter(n => n !== null);
+ .filter((n) => n !== null);
await db.notes.delete(...ids);
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes',
- 'Trash'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes",
+ "Trash"
);
eSendEvent(eClearEditor);
}
@@ -62,73 +64,73 @@ export const deleteItems = async item => {
}
// layoutmanager.withAnimation(150);
- Navigation.queueRoutesForUpdate('Notebook', 'Notebooks');
+ Navigation.queueRoutesForUpdate("Notebook", "Notebooks");
useMenuStore.getState().setMenuPins();
ToastEvent.show({
- heading: 'Topics deleted',
- type: 'success'
+ heading: "Topics deleted",
+ type: "success"
});
}
if (notebooks?.length > 0) {
- let ids = notebooks.map(i => i.id);
+ let ids = notebooks.map((i) => i.id);
await db.notebooks.delete(...ids);
//layoutmanager.withAnimation(150);
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes',
- 'Notebooks',
- 'Trash'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes",
+ "Notebooks",
+ "Trash"
);
useMenuStore.getState().setMenuPins();
}
- let msgPart = history.selectedItemsList.length === 1 ? ' item' : ' items';
- let message = history.selectedItemsList.length + msgPart + ' moved to trash.';
+ let msgPart = history.selectedItemsList.length === 1 ? " item" : " items";
+ let message = history.selectedItemsList.length + msgPart + " moved to trash.";
let itemsCopy = [...history.selectedItemsList];
if (topics.length === 0 && (notes.length > 0 || notebooks.length > 0)) {
ToastEvent.show({
heading: message,
- type: 'success',
+ type: "success",
func: async () => {
let trash = db.trash.all;
let ids = [];
for (var i = 0; i < itemsCopy.length; i++) {
let it = itemsCopy[i];
- let trashItem = trash.find(item => item.id === it.id);
+ let trashItem = trash.find((item) => item.id === it.id);
ids.push(trashItem.id);
}
await db.trash.restore(...ids);
//layoutmanager.withAnimation(150);
Navigation.queueRoutesForUpdate(
- 'TaggedNotes',
- 'ColoredNotes',
- 'TopicNotes',
- 'Favorites',
- 'Notes',
- 'Notebook',
- 'Notebooks',
- 'Trash'
+ "TaggedNotes",
+ "ColoredNotes",
+ "TopicNotes",
+ "Favorites",
+ "Notes",
+ "Notebook",
+ "Notebooks",
+ "Trash"
);
useMenuStore.getState().setMenuPins();
useMenuStore.getState().setColorNotes();
ToastEvent.hide();
},
- actionText: 'Undo'
+ actionText: "Undo"
});
}
history.selectedItemsList = [];
- Navigation.queueRoutesForUpdate('Trash');
+ Navigation.queueRoutesForUpdate("Trash");
useSelectionStore.getState().clearSelection(true);
useMenuStore.getState().setMenuPins();
useMenuStore.getState().setColorNotes();
- console.log('running search again');
+ console.log("running search again");
SearchService.updateAndSearch();
};
diff --git a/apps/mobile/app/utils/global-refs.ts b/apps/mobile/app/utils/global-refs.ts
index 648a82c40..6e74f56c2 100644
--- a/apps/mobile/app/utils/global-refs.ts
+++ b/apps/mobile/app/utils/global-refs.ts
@@ -1,7 +1,7 @@
-import { createNavigationContainerRef } from '@react-navigation/native';
-import { createRef } from 'react';
-import { TextInput, View } from 'react-native';
-import { TabsRef } from '../components/tabs';
+import { createNavigationContainerRef } from "@react-navigation/native";
+import { createRef } from "react";
+import { TextInput, View } from "react-native";
+import { TabsRef } from "../components/tabs";
export const inputRef = createRef<TextInput>();
export const rootNavigatorRef = createNavigationContainerRef();
diff --git a/apps/mobile/app/utils/index.js b/apps/mobile/app/utils/index.js
index cc9ab579e..312f143f3 100755
--- a/apps/mobile/app/utils/index.js
+++ b/apps/mobile/app/utils/index.js
@@ -1,8 +1,11 @@
-import { AppState, Dimensions, NativeModules, Platform } from 'react-native';
-import { beginBackgroundTask, endBackgroundTask } from 'react-native-begin-background-task';
-import RNTooltips from 'react-native-tooltips';
-import { db } from '../common/database';
-import { tabBarRef } from './global-refs';
+import { AppState, Dimensions, NativeModules, Platform } from "react-native";
+import {
+ beginBackgroundTask,
+ endBackgroundTask
+} from "react-native-begin-background-task";
+import RNTooltips from "react-native-tooltips";
+import { db } from "../common/database";
+import { tabBarRef } from "./global-refs";
let prevTarget = null;
let htmlToText;
@@ -15,11 +18,11 @@ export const TOOLTIP_POSITIONS = {
};
export const sortSettings = {
- sort: 'default',
+ sort: "default",
/**
* @type {"desc" | "asc"}
*/
- sortOrder: 'desc'
+ sortOrder: "desc"
};
export const editing = {
@@ -46,21 +49,21 @@ export const history = {
};
export function formatBytes(bytes, decimals = 2) {
- if (bytes === 0) return '0 Bytes';
+ if (bytes === 0) return "0 Bytes";
const k = 1024;
const dm = decimals < 0 ? 0 : decimals;
- const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
const i = Math.floor(Math.log(bytes) / Math.log(k));
- return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
+ return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + " " + sizes[i];
}
export const AndroidModule = NativeModules.NNativeModule;
-export let dWidth = Dimensions.get('window').width;
-export let dHeight = Dimensions.get('window').height;
+export let dWidth = Dimensions.get("window").width;
+export let dHeight = Dimensions.get("window").height;
export const InteractionManager = {
runAfterInteractions: (func, time = 300) => setTimeout(func, time)
@@ -69,7 +72,7 @@ export const InteractionManager = {
export function getElevation(elevation) {
return {
elevation,
- shadowColor: 'black',
+ shadowColor: "black",
shadowOffset: { width: 0.3 * elevation, height: 0.5 * elevation },
shadowOpacity: 0.2,
shadowRadius: 0.7 * elevation
@@ -77,7 +80,7 @@ export function getElevation(elevation) {
}
export async function doInBackground(cb) {
- if (Platform.OS === 'ios') {
+ if (Platform.OS === "ios") {
let bgTaskId;
try {
bgTaskId = await beginBackgroundTask();
@@ -91,7 +94,7 @@ export async function doInBackground(cb) {
// eslint-disable-next-line no-async-promise-executor
return new Promise(async (res, rej) => {
try {
- console.log('APP STATE AT SYNC: ', AppState.currentState);
+ console.log("APP STATE AT SYNC: ", AppState.currentState);
let result = await cb();
res(result);
} catch (e) {
@@ -107,8 +110,8 @@ export function setWidthHeight(size) {
}
export function getTotalNotes(notebook) {
- if (!notebook || notebook.type === 'header') return 0;
- if (notebook.type === 'topic') {
+ if (!notebook || notebook.type === "header") return 0;
+ if (notebook.type === "topic") {
if (!notebook.notes) return 0;
return notebook.notes.length;
}
@@ -126,9 +129,9 @@ export async function toTXT(note, notitle) {
} else {
text = await db.notes.note(note.id).content();
}
- htmlToText = htmlToText || require('html-to-text');
+ htmlToText = htmlToText || require("html-to-text");
text = htmlToText.convert(text, {
- selectors: [{ selector: 'img', format: 'skip' }]
+ selectors: [{ selector: "img", format: "skip" }]
});
if (!notitle) {
text = `${note.title}\n \n ${text}`;
@@ -143,8 +146,8 @@ export function showTooltip(event, text, position = 2) {
prevTarget = event._targetInst.ref.current;
RNTooltips.Show(prevTarget, tabBarRef.current?.node?.current, {
text: text,
- tintColor: '#000000',
- corner: Platform.OS === 'ios' ? 5 : 40,
+ tintColor: "#000000",
+ corner: Platform.OS === "ios" ? 5 : 40,
textSize: 14,
position: position,
duration: 1000,
diff --git a/apps/mobile/app/utils/sanitizer/index.js b/apps/mobile/app/utils/sanitizer/index.js
index e32f64c3c..a19e63d14 100644
--- a/apps/mobile/app/utils/sanitizer/index.js
+++ b/apps/mobile/app/utils/sanitizer/index.js
@@ -35,8 +35,8 @@ var windowsTrailingRe = /[. ]+$/;
var whitespace = /\W+/g;
function sanitize(input, replacement) {
- if (typeof input !== 'string') {
- throw new Error('Input must be string');
+ if (typeof input !== "string") {
+ throw new Error("Input must be string");
}
var sanitized = input
.replace(whitespace, replacement)
@@ -49,6 +49,6 @@ function sanitize(input, replacement) {
}
export function sanitizeFilename(input, options) {
- var replacement = (options && options.replacement) || '';
+ var replacement = (options && options.replacement) || "";
return sanitize(input, replacement);
}
diff --git a/apps/mobile/app/utils/size/index.js b/apps/mobile/app/utils/size/index.js
index 4cab23deb..2722c1234 100644
--- a/apps/mobile/app/utils/size/index.js
+++ b/apps/mobile/app/utils/size/index.js
@@ -1,10 +1,10 @@
-import { Dimensions, PixelRatio, Platform } from 'react-native';
-import { DDS } from '../../services/device-detection';
+import { Dimensions, PixelRatio, Platform } from "react-native";
+import { DDS } from "../../services/device-detection";
export const scale = {
fontScale: 1
};
-let windowSize = Dimensions.get('window');
+let windowSize = Dimensions.get("window");
let adjustedWidth = windowSize.width * PixelRatio.get();
let adjustedHeight = windowSize.height * PixelRatio.get();
const pixelDensity = PixelRatio.get();
@@ -18,7 +18,7 @@ export const getDeviceSize = () => {
return Platform.isPad ? diagonalSize + 2 : diagonalSize;
};
-const getDpi = pd => {
+const getDpi = (pd) => {
return 160 * pd;
};
const correction = (size, multiplier) => {
@@ -26,7 +26,7 @@ const correction = (size, multiplier) => {
if (dSize >= 4 && dSize <= 5.3 && pixelDensity <= 3) {
return size * 0.93;
} else if (dSize > 5.3 && dSize < 7 && pixelDensity < 3 && !DDS.isTab) {
- if (Platform.OS === 'ios') {
+ if (Platform.OS === "ios") {
return size;
}
return size * 0.97;
@@ -46,7 +46,7 @@ const correction = (size, multiplier) => {
return size;
}
};
-export const normalize = size => {
+export const normalize = (size) => {
let pd = pixelDensity;
if (pd === 1 || pd < 1) {
return correction(size, 0.82);
diff --git a/apps/mobile/app/utils/sse/even-source-ios.js b/apps/mobile/app/utils/sse/even-source-ios.js
index 176347532..50f44f5e5 100644
--- a/apps/mobile/app/utils/sse/even-source-ios.js
+++ b/apps/mobile/app/utils/sse/even-source-ios.js
@@ -22,9 +22,9 @@
* @format
*
*/
-'use strict';
-import _reactNative from 'react-native';
-import _eventTargetShim from 'event-target-shim';
+"use strict";
+import _reactNative from "react-native";
+import _eventTargetShim from "event-target-shim";
function _defineProperty(obj, key, value) {
if (key in obj) {
@@ -40,7 +40,7 @@ function _defineProperty(obj, key, value) {
return obj;
}
-const EVENT_SOURCE_EVENTS = ['error', 'message', 'open', 'connection-error']; // char codes
+const EVENT_SOURCE_EVENTS = ["error", "message", "open", "connection-error"]; // char codes
const bom = [239, 187, 191]; // byte order mark
@@ -55,7 +55,9 @@ const reTrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g;
* https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
*/
-class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS) {
+class EventSource extends (0, _eventTargetShim.default)(
+ ...EVENT_SOURCE_EVENTS
+) {
// Properties
// Default, retry over a minute per 2.5s.
// Buffers for event stream parsing
@@ -76,55 +78,55 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
constructor(url, eventSourceInitDict) {
super();
- _defineProperty(this, 'readyState', EventSource.CONNECTING);
+ _defineProperty(this, "readyState", EventSource.CONNECTING);
- _defineProperty(this, 'withCredentials', false);
+ _defineProperty(this, "withCredentials", false);
- _defineProperty(this, 'maxRetryEvents', 24);
+ _defineProperty(this, "maxRetryEvents", 24);
- _defineProperty(this, 'reconnectIntervalMs', 2500);
+ _defineProperty(this, "reconnectIntervalMs", 2500);
- _defineProperty(this, '_isFirstChunk', false);
+ _defineProperty(this, "_isFirstChunk", false);
- _defineProperty(this, '_discardNextLineFeed', false);
+ _defineProperty(this, "_discardNextLineFeed", false);
- _defineProperty(this, '_lineBuf', '');
+ _defineProperty(this, "_lineBuf", "");
- _defineProperty(this, '_dataBuf', '');
+ _defineProperty(this, "_dataBuf", "");
- _defineProperty(this, '_eventTypeBuf', '');
+ _defineProperty(this, "_eventTypeBuf", "");
- _defineProperty(this, '_lastEventIdBuf', '');
+ _defineProperty(this, "_lastEventIdBuf", "");
- _defineProperty(this, '_headers', {});
+ _defineProperty(this, "_headers", {});
- _defineProperty(this, '_lastEventId', '');
+ _defineProperty(this, "_lastEventId", "");
- _defineProperty(this, '_trackingName', 'unknown');
+ _defineProperty(this, "_trackingName", "unknown");
- _defineProperty(this, '_retryAttempts', 0);
+ _defineProperty(this, "_retryAttempts", 0);
if (!url) {
- throw new Error('Cannot open an SSE stream on an empty url');
+ throw new Error("Cannot open an SSE stream on an empty url");
}
this.url = url;
- this._headers['Cache-Control'] = 'no-cache';
- this._headers.Accept = 'text/event-stream';
+ this._headers["Cache-Control"] = "no-cache";
+ this._headers.Accept = "text/event-stream";
if (this._lastEventId) {
- this._headers['Last-Event-ID'] = this._lastEventId;
+ this._headers["Last-Event-ID"] = this._lastEventId;
} // This is an upsetting hack that appears to only show on Android even though it is HIGHLY not recommended.
- if (_reactNative.Platform.OS === 'android') {
- this._headers['X-Requested-With'] = 'XMLHttpRequest';
+ if (_reactNative.Platform.OS === "android") {
+ this._headers["X-Requested-With"] = "XMLHttpRequest";
}
if (eventSourceInitDict) {
if (eventSourceInitDict.headers) {
- if (eventSourceInitDict.headers['Last-Event-ID']) {
- this._lastEventId = eventSourceInitDict.headers['Last-Event-ID'];
- delete eventSourceInitDict.headers['Last-Event-ID'];
+ if (eventSourceInitDict.headers["Last-Event-ID"]) {
+ this._lastEventId = eventSourceInitDict.headers["Last-Event-ID"];
+ delete eventSourceInitDict.headers["Last-Event-ID"];
}
for (var headerKey in eventSourceInitDict.headers) {
@@ -137,8 +139,8 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
}
if (eventSourceInitDict.disableAndroidXRequestedWith) {
- if (_reactNative.Platform.OS === 'android') {
- delete this._headers['X-Requested-With'];
+ if (_reactNative.Platform.OS === "android") {
+ delete this._headers["X-Requested-With"];
}
}
@@ -148,11 +150,13 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
if (eventSourceInitDict.reconnectOptions) {
if (eventSourceInitDict.reconnectOptions.reconnectIntervalMs) {
- this.reconnectIntervalMs = eventSourceInitDict.reconnectOptions.reconnectIntervalMs;
+ this.reconnectIntervalMs =
+ eventSourceInitDict.reconnectOptions.reconnectIntervalMs;
}
if (eventSourceInitDict.reconnectOptions.maxRetryEvents) {
- this.maxRetryEvents = eventSourceInitDict.reconnectOptions.maxRetryEvents;
+ this.maxRetryEvents =
+ eventSourceInitDict.reconnectOptions.maxRetryEvents;
}
}
}
@@ -160,20 +164,22 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
this._subscriptions = [];
this._subscriptions.push(
- _reactNative.Networking.addListener('didReceiveNetworkResponse', args =>
+ _reactNative.Networking.addListener("didReceiveNetworkResponse", (args) =>
this.__didReceiveResponse(...args)
)
);
this._subscriptions.push(
- _reactNative.Networking.addListener('didReceiveNetworkIncrementalData', args =>
- this.__didReceiveIncrementalData(...args)
+ _reactNative.Networking.addListener(
+ "didReceiveNetworkIncrementalData",
+ (args) => this.__didReceiveIncrementalData(...args)
)
);
this._subscriptions.push(
- _reactNative.Networking.addListener('didCompleteNetworkResponse', args =>
- this.__didCompleteResponse(...args)
+ _reactNative.Networking.addListener(
+ "didCompleteNetworkResponse",
+ (args) => this.__didCompleteResponse(...args)
)
);
@@ -185,7 +191,7 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
_reactNative.Networking.abortRequest(this._requestId);
} // clean up Networking subscriptions
- (this._subscriptions || []).forEach(sub => {
+ (this._subscriptions || []).forEach((sub) => {
if (sub) {
sub.remove();
}
@@ -193,7 +199,7 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
this._subscriptions = [];
this.readyState = EventSource.CLOSED;
this.dispatchEvent({
- type: 'close'
+ type: "close"
});
}
@@ -204,16 +210,16 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
}
if (this._lastEventId) {
- this._headers['Last-Event-ID'] = this._lastEventId;
+ this._headers["Last-Event-ID"] = this._lastEventId;
}
_reactNative.Networking.sendRequest(
- 'GET', // EventSource always GETs the resource
+ "GET", // EventSource always GETs the resource
this._trackingName,
this.url,
this._headers,
- '', // body for EventSource request is always empty
- 'text', // SSE is a text protocol
+ "", // body for EventSource request is always empty
+ "text", // SSE is a text protocol
true, // we want incremental events
0, // there is no timeout defined in the WHATWG spec for EventSource
this.__didCreateRequest.bind(this),
@@ -223,14 +229,14 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
__reconnect(reason) {
this.readyState = EventSource.CONNECTING;
- let errorEventMessage = 'reestablishing connection';
+ let errorEventMessage = "reestablishing connection";
if (reason) {
- errorEventMessage += ': ' + reason;
+ errorEventMessage += ": " + reason;
}
this.dispatchEvent({
- type: 'error',
+ type: "error",
data: errorEventMessage
});
@@ -286,15 +292,15 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
__processEventStreamLine() {
const line = this._lineBuf; // clear the line buffer
- this._lineBuf = ''; // Dispatch the buffered event if this is an empty line
+ this._lineBuf = ""; // Dispatch the buffered event if this is an empty line
- if (line === '') {
+ if (line === "") {
this.__dispatchBufferedEvent();
return;
}
- const colonPos = line.indexOf(':');
+ const colonPos = line.indexOf(":");
let field;
let value;
@@ -302,7 +308,7 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
// this is a comment line and should be ignored
return;
} else if (colonPos > 0) {
- if (line[colonPos + 1] === ' ') {
+ if (line[colonPos + 1] === " ") {
field = line.slice(0, colonPos);
value = line.slice(colonPos + 2); // ignores the first space from the value
} else {
@@ -311,27 +317,27 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
}
} else {
field = line;
- value = '';
+ value = "";
}
switch (field) {
- case 'event':
+ case "event":
// Set the type of this event
this._eventTypeBuf = value;
break;
- case 'data':
+ case "data":
// Append the line to the data buffer along with an LF (U+000A)
this._dataBuf += value;
this._dataBuf += String.fromCodePoint(lf);
break;
- case 'id':
+ case "id":
// Update the last seen event id
this._lastEventIdBuf = value;
break;
- case 'retry':
+ case "retry":
// Set a new reconnect interval value
// But I don't like this.
@@ -352,12 +358,12 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
this._lastEventId = this._lastEventIdBuf; // If the data buffer is an empty string, set the event type buffer to
// empty string and return
- if (this._dataBuf === '') {
- this._eventTypeBuf = '';
+ if (this._dataBuf === "") {
+ this._eventTypeBuf = "";
return;
} // Dispatch the event
- const eventType = this._eventTypeBuf || 'message';
+ const eventType = this._eventTypeBuf || "message";
this.dispatchEvent({
type: eventType,
data: this._dataBuf.slice(0, -1),
@@ -366,8 +372,8 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
lastEventId: this._lastEventId
}); // Reset the data and event type buffers
- this._dataBuf = '';
- this._eventTypeBuf = '';
+ this._dataBuf = "";
+ this._eventTypeBuf = "";
} // Networking callbacks, exposed for testing
__didCreateRequest(requestId) {
@@ -401,8 +407,8 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
return;
} else {
this.dispatchEvent({
- type: 'error',
- data: 'got redirect with no location'
+ type: "error",
+ data: "got redirect with no location"
});
return this.close();
}
@@ -410,22 +416,27 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
if (status !== 200) {
this.dispatchEvent({
- type: 'error',
- data: 'unexpected HTTP status ' + status
+ type: "error",
+ data: "unexpected HTTP status " + status
});
return this.close();
}
- if (responseHeaders && responseHeaders['content-type'] !== 'text/event-stream') {
+ if (
+ responseHeaders &&
+ responseHeaders["content-type"] !== "text/event-stream"
+ ) {
this.dispatchEvent({
- type: 'error',
- data: 'unsupported MIME type in response: ' + responseHeaders['content-type']
+ type: "error",
+ data:
+ "unsupported MIME type in response: " +
+ responseHeaders["content-type"]
});
return this.close();
} else if (!responseHeaders) {
this.dispatchEvent({
- type: 'error',
- data: 'no MIME type in response'
+ type: "error",
+ data: "no MIME type in response"
});
return this.close();
} // reset the connection retry attempt counter
@@ -434,13 +445,13 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
this._isFirstChunk = false;
this._discardNextLineFeed = false;
- this._lineBuf = '';
- this._dataBuf = '';
- this._eventTypeBuf = '';
- this._lastEventIdBuf = '';
+ this._lineBuf = "";
+ this._dataBuf = "";
+ this._eventTypeBuf = "";
+ this._lastEventIdBuf = "";
this.readyState = EventSource.OPEN;
this.dispatchEvent({
- type: 'open'
+ type: "open"
});
}
@@ -473,22 +484,22 @@ class EventSource extends (0, _eventTargetShim.default)(...EVENT_SOURCE_EVENTS)
this.__reconnect(error);
} else {
this.dispatchEvent({
- type: 'error',
- data: 'could not reconnect after ' + this.maxRetryAttempts + ' attempts'
+ type: "error",
+ data: "could not reconnect after " + this.maxRetryAttempts + " attempts"
});
this.close();
}
}
}
-_defineProperty(EventSource, 'CONNECTING', 0);
+_defineProperty(EventSource, "CONNECTING", 0);
-_defineProperty(EventSource, 'OPEN', 1);
+_defineProperty(EventSource, "OPEN", 1);
-_defineProperty(EventSource, 'CLOSED', 2);
+_defineProperty(EventSource, "CLOSED", 2);
-_defineProperty(EventSource, 'XMLHTTP_LOADING', 3);
+_defineProperty(EventSource, "XMLHTTP_LOADING", 3);
-_defineProperty(EventSource, 'XMLHTTP_DONE', 4);
+_defineProperty(EventSource, "XMLHTTP_DONE", 4);
export default EventSource;
diff --git a/apps/mobile/app/utils/sse/event-source.js b/apps/mobile/app/utils/sse/event-source.js
index ee1c22962..923882f05 100644
--- a/apps/mobile/app/utils/sse/event-source.js
+++ b/apps/mobile/app/utils/sse/event-source.js
@@ -1,7 +1,9 @@
-import { NativeEventEmitter, NativeModules, Platform } from 'react-native';
+import { NativeEventEmitter, NativeModules, Platform } from "react-native";
-const NativeEventSource = Platform.OS === 'ios' ? null : NativeModules.EventSource;
-const EventEmitter = Platform.OS === 'ios' ? null : new NativeEventEmitter(NativeEventSource);
+const NativeEventSource =
+ Platform.OS === "ios" ? null : NativeModules.EventSource;
+const EventEmitter =
+ Platform.OS === "ios" ? null : new NativeEventEmitter(NativeEventSource);
export default class EventSource {
constructor(url, options) {
@@ -24,11 +26,11 @@ export default class EventSource {
}
registerEvents() {
- this.open = EventEmitter.addListener('open', () => {
+ this.open = EventEmitter.addListener("open", () => {
this.onopen();
});
- this.message = EventEmitter.addListener('message', ev => {
+ this.message = EventEmitter.addListener("message", (ev) => {
const { message } = ev;
const eventData = { data: message };
this.onmessage(eventData);
diff --git a/apps/mobile/app/utils/time/index.ts b/apps/mobile/app/utils/time/index.ts
index ffd1efaab..e8d7a51a1 100644
--- a/apps/mobile/app/utils/time/index.ts
+++ b/apps/mobile/app/utils/time/index.ts
@@ -1,60 +1,73 @@
export const sleep = (duration: number) =>
- new Promise(resolve => setTimeout(() => resolve(true), duration));
+ new Promise((resolve) => setTimeout(() => resolve(true), duration));
export function timeSince(date: number) {
let seconds = Math.floor((Date.now() - date) / 1000);
let interval = Math.floor(seconds / 31536000);
if (interval > 0.9) {
- return interval < 2 ? interval + 'yr ago' : interval + 'yr ago';
+ return interval < 2 ? interval + "yr ago" : interval + "yr ago";
}
interval = Math.floor(seconds / 2592000);
if (interval > 0.9) {
- return interval < 2 ? interval + 'mo ago' : interval + 'mo ago';
+ return interval < 2 ? interval + "mo ago" : interval + "mo ago";
}
interval = Math.floor(seconds / (86400 * 7));
if (interval > 0.9) {
- if (interval === 4) return '1mo ago';
- return interval < 2 ? interval + 'w ago' : interval + 'w ago';
+ if (interval === 4) return "1mo ago";
+ return interval < 2 ? interval + "w ago" : interval + "w ago";
}
interval = Math.floor(seconds / 86400);
if (interval > 0.9) {
- return interval < 2 ? interval + 'd ago' : interval + 'd ago';
+ return interval < 2 ? interval + "d ago" : interval + "d ago";
}
interval = Math.floor(seconds / 3600);
if (interval > 0.9) {
- return interval < 2 ? interval + 'h ago' : interval + 'h ago';
+ return interval < 2 ? interval + "h ago" : interval + "h ago";
}
interval = Math.floor(seconds / 60);
if (interval > 0.9) {
- return interval < 2 ? interval + 'm ago' : interval + 'm ago';
+ return interval < 2 ? interval + "m ago" : interval + "m ago";
}
- return Math.floor(seconds) < 0 ? '0s ago' : Math.floor(seconds) + 's ago';
+ return Math.floor(seconds) < 0 ? "0s ago" : Math.floor(seconds) + "s ago";
}
export const timeConverter = (timestamp: number | undefined | null) => {
if (!timestamp) return;
let d = new Date(timestamp), // Convert the passed timestamp to milliseconds
yyyy = d.getFullYear(),
- mm = ('0' + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0.
- dd = ('0' + d.getDate()).slice(-2), // Add leading 0.
+ mm = ("0" + (d.getMonth() + 1)).slice(-2), // Months are zero based. Add leading 0.
+ dd = ("0" + d.getDate()).slice(-2), // Add leading 0.
currentDay = d.getDay(),
hh = d.getHours(),
h = hh,
- min = ('0' + d.getMinutes()).slice(-2), // Add leading 0.
- ampm = 'AM',
+ min = ("0" + d.getMinutes()).slice(-2), // Add leading 0.
+ ampm = "AM",
time;
- let days = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
- let months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
+ let days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
+ let months = [
+ "Jan",
+ "Feb",
+ "Mar",
+ "Apr",
+ "May",
+ "Jun",
+ "Jul",
+ "Aug",
+ "Sep",
+ "Oct",
+ "Nov",
+ "Dec"
+ ];
if (hh > 12) {
h = hh - 12;
- ampm = 'PM';
+ ampm = "PM";
} else if (hh === 12) {
h = 12;
- ampm = 'PM';
+ ampm = "PM";
} else if (hh === 0) {
h = 12;
}
@@ -62,17 +75,17 @@ export const timeConverter = (timestamp: number | undefined | null) => {
// ie: 2013-02-18, 8:35 AM
time =
days[currentDay] +
- ' ' +
+ " " +
dd +
- ' ' +
+ " " +
months[d.getMonth()] +
- ', ' +
+ ", " +
yyyy +
- ', ' +
+ ", " +
h +
- ':' +
+ ":" +
min +
- ' ' +
+ " " +
ampm;
return time;
diff --git a/apps/mobile/app/utils/types.ts b/apps/mobile/app/utils/types.ts
index c1fa7c85f..498802fe9 100644
--- a/apps/mobile/app/utils/types.ts
+++ b/apps/mobile/app/utils/types.ts
@@ -2,32 +2,44 @@
export type LiteralUnion<T extends U, U = string> = T | (U & {});
// types from notesnook-core
-export type CollectionTypes = 'notes' | 'notebooks' | 'attachments' | 'content' | 'tags' | 'colors';
+export type CollectionTypes =
+ | "notes"
+ | "notebooks"
+ | "attachments"
+ | "content"
+ | "tags"
+ | "colors";
export type EntityTypes =
- | 'note'
- | 'notebook'
- | 'tiny'
- | 'topic'
- | 'attachment'
- | 'settings'
- | 'trash'
- | 'tag'
- | 'color'
- | 'header';
+ | "note"
+ | "notebook"
+ | "tiny"
+ | "topic"
+ | "attachment"
+ | "settings"
+ | "trash"
+ | "tag"
+ | "color"
+ | "header";
export type CollectionEntityTypeMap = {
- notes: 'note';
- notebooks: 'notebook';
- attachments: 'attachment';
- content: 'tiny';
- tags: 'tag';
- colors: 'color';
+ notes: "note";
+ notebooks: "notebook";
+ attachments: "attachment";
+ content: "tiny";
+ tags: "tag";
+ colors: "color";
};
-export type Item = NoteType | NotebookType | TopicType | AttachmentType | TagType | TrashType;
+export type Item =
+ | NoteType
+ | NotebookType
+ | TopicType
+ | AttachmentType
+ | TagType
+ | TrashType;
export type MonographType = {
- type: 'monograph';
+ type: "monograph";
};
export interface Entity<TType extends EntityTypes> {
@@ -47,7 +59,7 @@ export type NotebookReference = {
topics: string[];
};
-export interface NoteType extends Entity<'note'> {
+export interface NoteType extends Entity<"note"> {
title: string;
notebooks: NotebookReference[];
tags: string[];
@@ -70,7 +82,7 @@ export interface NoteType extends Entity<'note'> {
};
}
-export interface NotebookType extends Entity<'notebook'> {
+export interface NotebookType extends Entity<"notebook"> {
title: string;
description?: string;
dateCreated: number;
@@ -79,7 +91,7 @@ export interface NotebookType extends Entity<'notebook'> {
topics: TopicType[];
}
-export interface TopicType extends Entity<'topic'> {
+export interface TopicType extends Entity<"topic"> {
title: string;
notebookId: string;
notes: string[];
@@ -87,7 +99,7 @@ export interface TopicType extends Entity<'topic'> {
dateEdited: number;
}
-export interface AttachmentType extends Entity<'attachment'> {
+export interface AttachmentType extends Entity<"attachment"> {
noteIds: string[];
iv: string;
salt: string;
@@ -113,24 +125,25 @@ export interface AttachmentType extends Entity<'attachment'> {
dateDeleted: number;
}
-interface BaseTag<TType extends 'tag' | 'color'> extends Entity<TType> {
+interface BaseTag<TType extends "tag" | "color"> extends Entity<TType> {
title: string;
alias?: string;
noteIds: string[];
}
-export type TagType = BaseTag<'tag'>;
-export type ColorType = BaseTag<'color'>;
+export type TagType = BaseTag<"tag">;
+export type ColorType = BaseTag<"color">;
-type TrashItem<TItem extends Entity<'note' | 'notebook'>> = Entity<'trash'> & {
+type TrashItem<TItem extends Entity<"note" | "notebook">> = Entity<"trash"> & {
title: string;
- itemType: TItem['type'];
+ itemType: TItem["type"];
dateDeleted: number;
deleted: boolean;
-} & Omit<TItem, 'id' | 'type'>;
+} & Omit<TItem, "id" | "type">;
export type TrashType = TrashItem<NoteType> | TrashItem<NotebookType>;
-export interface GroupHeader extends Omit<Entity<'header'>, 'id' | 'dateCreated' | 'dateModified'> {
+export interface GroupHeader
+ extends Omit<Entity<"header">, "id" | "dateCreated" | "dateModified"> {
title: string;
}
diff --git a/apps/mobile/codemagic.yaml b/apps/mobile/codemagic.yaml
index 18a9371ca..338b0a7dc 100644
--- a/apps/mobile/codemagic.yaml
+++ b/apps/mobile/codemagic.yaml
@@ -11,9 +11,9 @@ workflows:
- github_token
vars:
- XCODE_WORKSPACE: 'Notesnook.xcworkspace' # <-- Put the name of your Xcode workspace here
- XCODE_SCHEME: 'Notesnook' # <-- Put the name of your Xcode scheme here
- BUNDLE_ID: 'org.streetwriters.notesnook' # <-- Put your Bundle Id here e.g com.domain.myapp
+ XCODE_WORKSPACE: "Notesnook.xcworkspace" # <-- Put the name of your Xcode workspace here
+ XCODE_SCHEME: "Notesnook" # <-- Put the name of your Xcode scheme here
+ BUNDLE_ID: "org.streetwriters.notesnook" # <-- Put your Bundle Id here e.g com.domain.myapp
APP_STORE_APP_ID: 1544027013 # <-- Put the app id number here. This is found in App Store Connect > App > General > App Information
node: 16.13.2
@@ -31,7 +31,7 @@ workflows:
- name: Setup yarnrc
script: echo "\"@streetwriters:registry\" \"https://npm.pkg.github.com\"" > .yarnrc
-
+
- name: Install npm dependencies
script: |
yarn install --network-concurrency 1
diff --git a/apps/mobile/e2e/environment.js b/apps/mobile/e2e/environment.js
index 428f68818..7e232f79f 100644
--- a/apps/mobile/e2e/environment.js
+++ b/apps/mobile/e2e/environment.js
@@ -2,7 +2,7 @@ const {
DetoxCircusEnvironment,
SpecReporter,
WorkerAssignReporter
-} = require('detox/runners/jest-circus');
+} = require("detox/runners/jest-circus");
class CustomDetoxEnvironment extends DetoxCircusEnvironment {
constructor(config, context) {
diff --git a/apps/mobile/e2e/test.ids.js b/apps/mobile/e2e/test.ids.js
index 312350562..56b09650b 100644
--- a/apps/mobile/e2e/test.ids.js
+++ b/apps/mobile/e2e/test.ids.js
@@ -1,114 +1,114 @@
const notesnook = {
editor: {
- back: 'editor.back',
- id: 'editor.id'
+ back: "editor.back",
+ id: "editor.id"
},
buttons: {
- add: 'buttons.add'
+ add: "buttons.add"
},
toast: {
- button: 'toast.button'
+ button: "toast.button"
},
listitem: {
- menu: 'listitem.menu'
+ menu: "listitem.menu"
},
list: {
- id: 'list.id'
+ id: "list.id"
},
ids: {
default: {
- root: 'root',
- menu: 'menu',
+ root: "root",
+ menu: "menu",
dialog: {
- yes: 'yes',
- no: 'no'
+ yes: "yes",
+ no: "no"
},
- editor: 'editor',
+ editor: "editor",
header: {
buttons: {
- left: 'left',
- right: 'right',
- back: 'back'
+ left: "left",
+ right: "right",
+ back: "back"
}
},
- actionsheetBackdrop: 'backdrop',
- loginToSync: 'login_to_sync',
- addBtn: 'btn-add-item'
+ actionsheetBackdrop: "backdrop",
+ loginToSync: "login_to_sync",
+ addBtn: "btn-add-item"
},
dialogs: {
notebook: {
inputs: {
- title: 'title',
- description: 'description',
- topic: 'topic'
+ title: "title",
+ description: "description",
+ topic: "topic"
},
buttons: {
- add: 'add'
+ add: "add"
}
},
export: {
- pdf: 'pdf',
- text: 'text',
- md: 'md',
- html: 'html'
+ pdf: "pdf",
+ text: "text",
+ md: "md",
+ html: "html"
},
vault: {
- changePwd: 'change_pwd',
- pwd: 'pwd',
- confirmPwd: 'pwd',
- pwdAlt: 'pwd_alt',
- fingerprint: 'fingerprint'
+ changePwd: "change_pwd",
+ pwd: "pwd",
+ confirmPwd: "pwd",
+ pwdAlt: "pwd_alt",
+ fingerprint: "fingerprint"
},
sortBy: {
- order: 'orderby',
- default: 'btn-default',
- alphabetical: 'btn-alphabetical',
- year: 'btn-year',
- week: 'btn-week',
- month: 'btn-month'
+ order: "orderby",
+ default: "btn-default",
+ alphabetical: "btn-alphabetical",
+ year: "btn-year",
+ week: "btn-week",
+ month: "btn-month"
},
addTo: {
- addNotebook: 'input-addNotebook',
- addTopic: 'input-addTopic',
- btnNotebook: 'btn-addNotebook',
- btnTopic: 'btn-addTopic'
+ addNotebook: "input-addNotebook",
+ addTopic: "input-addTopic",
+ btnNotebook: "btn-addNotebook",
+ btnTopic: "btn-addTopic"
},
actionsheet: {
- delete: 'icon-Delete',
- hashtagInput: 'hashtag_input',
- export: 'icon-Export',
- addTo: 'icon-Add to',
- pin: 'item_pin',
- pinMenu: 'item_pin_menu',
- favorite: 'note_favorite',
- vault: 'vault_btn',
- copy: 'icon-Copy',
- sync: 'btn-sync-now',
- night: 'nightswitch',
- color: color => 'icon-color-' + color
+ delete: "icon-Delete",
+ hashtagInput: "hashtag_input",
+ export: "icon-Export",
+ addTo: "icon-Add to",
+ pin: "item_pin",
+ pinMenu: "item_pin_menu",
+ favorite: "note_favorite",
+ vault: "vault_btn",
+ copy: "icon-Copy",
+ sync: "btn-sync-now",
+ night: "nightswitch",
+ color: (color) => "icon-color-" + color
}
},
menu: {
- nightmode: 'night'
+ nightmode: "night"
},
note: {
- menu: 'note_menu',
- get: index => 'note-item-' + index
+ menu: "note_menu",
+ get: (index) => "note-item-" + index
},
notebook: {
- menu: 'notebook_menu',
- get: index => 'notebook-item-' + index
+ menu: "notebook_menu",
+ get: (index) => "notebook-item-" + index
},
topic: {
- menu: 'topic_menu',
- get: index => 'topic-item-' + index
+ menu: "topic_menu",
+ get: (index) => "topic-item-" + index
},
tag: {
- menu: 'tag_menu',
- get: index => 'tag-item-' + index
+ menu: "tag_menu",
+ get: (index) => "tag-item-" + index
},
list: {
- getByType: type => 'list-' + type
+ getByType: (type) => "list-" + type
}
}
};
diff --git a/apps/mobile/e2e/tests/auth.e2e.js b/apps/mobile/e2e/tests/auth.e2e.js
index b40adeb83..8896131c2 100644
--- a/apps/mobile/e2e/tests/auth.e2e.js
+++ b/apps/mobile/e2e/tests/auth.e2e.js
@@ -1,4 +1,4 @@
-const { notesnook } = require('../test.ids');
+const { notesnook } = require("../test.ids");
const {
navigate,
tapByText,
@@ -6,42 +6,42 @@ const {
openSideMenu,
elementById,
visibleByText
-} = require('./utils');
-const { sleep } = require('./utils');
+} = require("./utils");
+const { sleep } = require("./utils");
const credentials = {
- username: '[email protected]',
- password: 'testaccount@123'
+ username: "[email protected]",
+ password: "testaccount@123"
};
async function login() {
- await tapByText('Login to sync your notes.');
- await elementById('input.email').typeText(credentials.username);
- await elementById('input.password').typeText(credentials.password);
- await elementById('input.password').tapReturnKey();
+ await tapByText("Login to sync your notes.");
+ await elementById("input.email").typeText(credentials.username);
+ await elementById("input.password").typeText(credentials.password);
+ await elementById("input.password").tapReturnKey();
}
async function deleteAccount() {
- await tapByText('Account Settings');
+ await tapByText("Account Settings");
await sleep(2000);
- await tapByText('Delete account');
- await elementById('input-value').typeText(credentials.password);
- await tapByText('Delete');
+ await tapByText("Delete account");
+ await elementById("input-value").typeText(credentials.password);
+ await tapByText("Delete");
await sleep(5000);
}
async function signup() {
- await tapByText('Login to sync your notes.');
+ await tapByText("Login to sync your notes.");
await sleep(500);
await tapByText(`Don't have an account? Sign up`);
- await elementById('input.email').typeText(credentials.username);
- await elementById('input.password').typeText(credentials.password);
- await elementById('input.confirmPassword').typeText(credentials.password);
- await elementById('input.confirmPassword').tapReturnKey();
+ await elementById("input.email").typeText(credentials.username);
+ await elementById("input.password").typeText(credentials.password);
+ await elementById("input.confirmPassword").typeText(credentials.password);
+ await elementById("input.confirmPassword").tapReturnKey();
}
-describe('AUTH', () => {
- it('Sign up', async () => {
+describe("AUTH", () => {
+ it("Sign up", async () => {
await prepare();
await openSideMenu();
await signup();
@@ -49,25 +49,25 @@ describe('AUTH', () => {
await device.pressBack();
await sleep(5000);
await openSideMenu();
- await visibleByText('Tap here to sync your notes.');
+ await visibleByText("Tap here to sync your notes.");
});
- it('Login to account', async () => {
+ it("Login to account", async () => {
await prepare();
await openSideMenu();
await login();
await sleep(10000);
await openSideMenu();
- await visibleByText('Tap here to sync your notes.');
+ await visibleByText("Tap here to sync your notes.");
});
- it('Delete account', async () => {
+ it("Delete account", async () => {
await prepare();
await openSideMenu();
await login();
await sleep(15000);
await openSideMenu();
- await tapByText('Settings');
+ await tapByText("Settings");
await sleep(1000);
await deleteAccount();
});
diff --git a/apps/mobile/e2e/tests/index.e2e.js b/apps/mobile/e2e/tests/index.e2e.js
index 37ca2f04d..d9c711b6a 100644
--- a/apps/mobile/e2e/tests/index.e2e.js
+++ b/apps/mobile/e2e/tests/index.e2e.js
@@ -1,20 +1,20 @@
-const { navigate, tapByText, prepare, sleep } = require('./utils');
+const { navigate, tapByText, prepare, sleep } = require("./utils");
-describe('APP LAUNCH AND NAVIGATION', () => {
- it('App should launch successfully & hide welcome screen', async () => {
+describe("APP LAUNCH AND NAVIGATION", () => {
+ it("App should launch successfully & hide welcome screen", async () => {
await prepare();
});
- it('Basic navigation should work', async () => {
+ it("Basic navigation should work", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await navigate('Favorites');
- await navigate('Trash');
- await navigate('Tags');
- await navigate('Settings');
- await navigate('Monographs');
- await navigate('Notes');
+ await navigate("Favorites");
+ await navigate("Trash");
+ await navigate("Tags");
+ await navigate("Settings");
+ await navigate("Monographs");
+ await navigate("Notes");
});
});
diff --git a/apps/mobile/e2e/tests/note.e2e.js b/apps/mobile/e2e/tests/note.e2e.js
index d821dc8dc..e1b44e19d 100644
--- a/apps/mobile/e2e/tests/note.e2e.js
+++ b/apps/mobile/e2e/tests/note.e2e.js
@@ -1,4 +1,4 @@
-const { notesnook } = require('../test.ids');
+const { notesnook } = require("../test.ids");
const {
navigate,
tapById,
@@ -10,104 +10,106 @@ const {
sleep,
exitEditor,
tapByText
-} = require('./utils');
+} = require("./utils");
-describe('NOTE TESTS', () => {
- it('Create a note in editor', async () => {
+describe("NOTE TESTS", () => {
+ it("Create a note in editor", async () => {
await prepare();
await createNote();
});
- it('Open and close a note', async () => {
+ it("Open and close a note", async () => {
await prepare();
await createNote();
await tapById(notesnook.ids.note.get(1));
await exitEditor();
});
- it('Notes properties should show', async () => {
+ it("Notes properties should show", async () => {
await prepare();
let note = await createNote();
await tapById(notesnook.listitem.menu);
await visibleByText(note.body);
});
- it('Favorite and unfavorite a note', async () => {
+ it("Favorite and unfavorite a note", async () => {
await prepare();
let note = await createNote();
await tapById(notesnook.listitem.menu);
- await tapById('icon-Favorite');
- await visibleById('icon-star');
- await navigate('Favorites');
+ await tapById("icon-Favorite");
+ await visibleById("icon-star");
+ await navigate("Favorites");
await visibleByText(note.body);
await tapById(notesnook.listitem.menu);
- await tapById('icon-Favorite');
+ await tapById("icon-Favorite");
await expect(element(by.text(note.body))).not.toBeVisible();
- await navigate('Notes');
+ await navigate("Notes");
});
- it('Pin a note to top', async () => {
+ it("Pin a note to top", async () => {
await prepare();
await createNote();
await tapById(notesnook.listitem.menu);
- await tapById('icon-Pin');
- await visibleByText('Pinned');
- await visibleById('icon-pinned');
+ await tapById("icon-Pin");
+ await visibleByText("Pinned");
+ await visibleById("icon-pinned");
await tapById(notesnook.listitem.menu);
- await tapById('icon-Pin');
- expect(element(by.id('icon-pinned'))).not.toBeVisible();
+ await tapById("icon-Pin");
+ expect(element(by.id("icon-pinned"))).not.toBeVisible();
});
- it('Pin a note in notifications', async () => {
+ it("Pin a note in notifications", async () => {
await prepare();
await createNote();
await tapById(notesnook.listitem.menu);
- await tapById('icon-PinToNotif');
- await visibleByText('Unpin from Notifications');
+ await tapById("icon-PinToNotif");
+ await visibleByText("Unpin from Notifications");
await sleep(500);
- await tapById('icon-PinToNotif');
- await visibleByText('Pin to Notifications');
+ await tapById("icon-PinToNotif");
+ await visibleByText("Pin to Notifications");
});
- it('Copy note', async () => {
+ it("Copy note", async () => {
await prepare();
await createNote();
await tapById(notesnook.listitem.menu);
- await tapById('icon-Copy');
- await visibleByText('Note copied to clipboard');
+ await tapById("icon-Copy");
+ await visibleByText("Note copied to clipboard");
});
- it('Export note dialog should show', async () => {
+ it("Export note dialog should show", async () => {
await prepare();
await createNote();
await tapById(notesnook.listitem.menu);
- await tapById('icon-Export');
- await visibleByText('PDF');
+ await tapById("icon-Export");
+ await visibleByText("PDF");
});
- it('Assign colors to a note', async () => {
+ it("Assign colors to a note", async () => {
await prepare();
let note = await createNote();
await tapById(notesnook.listitem.menu);
- await tapById(notesnook.ids.dialogs.actionsheet.color('red'));
- await visibleById('icon-check');
- await tapById(notesnook.ids.dialogs.actionsheet.color('red'));
- await notVisibleById('icon-check');
- await tapById(notesnook.ids.dialogs.actionsheet.color('green'));
+ await tapById(notesnook.ids.dialogs.actionsheet.color("red"));
+ await visibleById("icon-check");
+ await tapById(notesnook.ids.dialogs.actionsheet.color("red"));
+ await notVisibleById("icon-check");
+ await tapById(notesnook.ids.dialogs.actionsheet.color("green"));
await device.pressBack();
- await navigate('Green');
+ await navigate("Green");
await visibleByText(note.body);
});
- it('Delete & restore a note', async () => {
+ it("Delete & restore a note", async () => {
await prepare();
await createNote();
await tapById(notesnook.listitem.menu);
- await tapById('icon-Delete');
- await navigate('Trash');
+ await tapById("icon-Delete");
+ await navigate("Trash");
await tapById(notesnook.listitem.menu);
- await tapByText('Restore note');
+ await tapByText("Restore note");
await device.pressBack();
- await visibleByText('Test note description that is very long and should not fit in text.');
+ await visibleByText(
+ "Test note description that is very long and should not fit in text."
+ );
});
});
diff --git a/apps/mobile/e2e/tests/notebook.e2e.js b/apps/mobile/e2e/tests/notebook.e2e.js
index dfd3cab26..51d56ef4c 100644
--- a/apps/mobile/e2e/tests/notebook.e2e.js
+++ b/apps/mobile/e2e/tests/notebook.e2e.js
@@ -1,5 +1,5 @@
-const detox = require('detox');
-const { notesnook } = require('../test.ids');
+const detox = require("detox");
+const { notesnook } = require("../test.ids");
const {
tapById,
elementById,
@@ -13,250 +13,264 @@ const {
notVisibleById,
navigate,
elementByText
-} = require('./utils');
-const { sleep } = require('./utils');
+} = require("./utils");
+const { sleep } = require("./utils");
-async function createNotebook(title = 'Notebook 1', description = true, topic = true) {
- await tapByText('Add your first notebook');
- await elementById(notesnook.ids.dialogs.notebook.inputs.title).typeText(title);
+async function createNotebook(
+ title = "Notebook 1",
+ description = true,
+ topic = true
+) {
+ await tapByText("Add your first notebook");
+ await elementById(notesnook.ids.dialogs.notebook.inputs.title).typeText(
+ title
+ );
if (description) {
- await elementById(notesnook.ids.dialogs.notebook.inputs.description).typeText(
- `Description of ${title}`
- );
+ await elementById(
+ notesnook.ids.dialogs.notebook.inputs.description
+ ).typeText(`Description of ${title}`);
}
if (topic) {
- await elementById(notesnook.ids.dialogs.notebook.inputs.topic).typeText('Topic');
- await tapById('topic-add-button');
+ await elementById(notesnook.ids.dialogs.notebook.inputs.topic).typeText(
+ "Topic"
+ );
+ await tapById("topic-add-button");
}
- await tapByText('Create notebook');
+ await tapByText("Create notebook");
await sleep(500);
}
-async function addTopic(title = 'Topic') {
+async function addTopic(title = "Topic") {
await tapById(notesnook.buttons.add);
- await elementById('input-title').typeText(title);
- await tapByText('Add');
+ await elementById("input-title").typeText(title);
+ await tapByText("Add");
await sleep(500);
}
-describe('NOTEBOOKS', () => {
- it('Create a notebook with title only', async () => {
+describe("NOTEBOOKS", () => {
+ it("Create a notebook with title only", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', false, false);
+ await createNotebook("Notebook 1", false, false);
await sleep(500);
await device.pressBack();
await sleep(500);
- await visibleByText('Notebook 1');
+ await visibleByText("Notebook 1");
});
- it('Create a notebook title & description', async () => {
+ it("Create a notebook title & description", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', true, false);
+ await createNotebook("Notebook 1", true, false);
await sleep(500);
await device.pressBack();
await sleep(500);
- await visibleByText('Notebook 1');
+ await visibleByText("Notebook 1");
});
- it('Create a notebook with description and topics', async () => {
+ it("Create a notebook with description and topics", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', false, false);
+ await createNotebook("Notebook 1", false, false);
await sleep(500);
await device.pressBack();
await sleep(500);
- await visibleByText('Notebook 1');
+ await visibleByText("Notebook 1");
});
- it('Create a notebook, add topic, move notes', async () => {
+ it("Create a notebook, add topic, move notes", async () => {
await prepare();
let note = await createNote();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', true, true);
+ await createNotebook("Notebook 1", true, true);
await sleep(500);
- await tapByText('Topic');
+ await tapByText("Topic");
await sleep(500);
- await tapById('listitem.select');
- await tapByText('Move selected notes');
+ await tapById("listitem.select");
+ await tapByText("Move selected notes");
await sleep(500);
- await tapByText('Topic');
+ await tapByText("Topic");
await sleep(500);
await visibleByText(note.body);
});
- it('Add new topic to notebook', async () => {
+ it("Add new topic to notebook", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', true, false);
+ await createNotebook("Notebook 1", true, false);
await sleep(500);
await device.pressBack();
await sleep(500);
- await tapByText('Notebook 1');
+ await tapByText("Notebook 1");
await tapById(notesnook.buttons.add);
- await elementById('input-title').typeText('Topic');
- await tapByText('Add');
+ await elementById("input-title").typeText("Topic");
+ await tapByText("Add");
await sleep(500);
- await visibleByText('Topic');
+ await visibleByText("Topic");
});
- it('Edit topic', async () => {
+ it("Edit topic", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', true, true);
+ await createNotebook("Notebook 1", true, true);
await sleep(500);
await device.pressBack();
await sleep(500);
- await tapByText('Notebook 1');
+ await tapByText("Notebook 1");
await sleep(300);
- await visibleByText('Topic');
+ await visibleByText("Topic");
await tapById(notesnook.ids.notebook.menu);
- await tapByText('Edit topic');
- await elementById('input-title').typeText(' (edited)');
- await tapByText('Save');
- await visibleByText('Topic (edited)');
+ await tapByText("Edit topic");
+ await elementById("input-title").typeText(" (edited)");
+ await tapByText("Save");
+ await visibleByText("Topic (edited)");
});
- it('Add new note to topic', async () => {
+ it("Add new note to topic", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', true, true);
+ await createNotebook("Notebook 1", true, true);
await sleep(500);
await device.pressBack();
await sleep(500);
- await tapByText('Topic');
+ await tapByText("Topic");
await createNote();
});
- it('Remove note from topic', async () => {
+ it("Remove note from topic", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', true, true);
+ await createNotebook("Notebook 1", true, true);
await sleep(500);
await device.pressBack();
await sleep(500);
- await tapByText('Topic');
+ await tapByText("Topic");
let note = await createNote();
await elementByText(note.body).longPress();
- await tapByText('Select');
- await tapById('select-minus');
+ await tapByText("Select");
+ await tapById("select-minus");
await notVisibleById(note.title);
});
- it('Add/Remove note to notebook from home', async () => {
+ it("Add/Remove note to notebook from home", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', true, true);
+ await createNotebook("Notebook 1", true, true);
await sleep(500);
await device.pressBack();
await sleep(500);
- await navigate('Notes');
+ await navigate("Notes");
let note = await createNote();
await tapById(notesnook.listitem.menu);
- await tapById('icon-Add to notebook');
+ await tapById("icon-Add to notebook");
await sleep(500);
- await tapByText('Notebook 1');
- await tapByText('Topic');
- await visibleById('icon-check');
- await tapByText('Topic');
- await notVisibleById('icon-check');
+ await tapByText("Notebook 1");
+ await tapByText("Topic");
+ await visibleById("icon-check");
+ await tapByText("Topic");
+ await notVisibleById("icon-check");
});
- it('Edit notebook title, description and add a topic', async () => {
+ it("Edit notebook title, description and add a topic", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
await createNotebook();
await sleep(500);
await device.pressBack();
await sleep(500);
- await visibleByText('Notebook 1');
+ await visibleByText("Notebook 1");
await tapById(notesnook.ids.notebook.menu);
- await tapByText('Edit notebook');
+ await tapByText("Edit notebook");
await sleep(500);
- await elementById(notesnook.ids.dialogs.notebook.inputs.title).typeText(' (Edited)');
- await elementById(notesnook.ids.dialogs.notebook.inputs.description).clearText();
- await elementById(notesnook.ids.dialogs.notebook.inputs.description).typeText(
- 'Description of Notebook 1 (Edited)'
+ await elementById(notesnook.ids.dialogs.notebook.inputs.title).typeText(
+ " (Edited)"
+ );
+ await elementById(
+ notesnook.ids.dialogs.notebook.inputs.description
+ ).clearText();
+ await elementById(
+ notesnook.ids.dialogs.notebook.inputs.description
+ ).typeText("Description of Notebook 1 (Edited)");
+ await elementById(notesnook.ids.dialogs.notebook.inputs.topic).typeText(
+ "Topic 2"
);
- await elementById(notesnook.ids.dialogs.notebook.inputs.topic).typeText('Topic 2');
- await tapById('topic-add-button');
- await tapByText('Save changes');
+ await tapById("topic-add-button");
+ await tapByText("Save changes");
await sleep(500);
- await visibleByText('Notebook 1 (Edited)');
- await visibleByText('Description of Notebook 1 (Edited)');
- await visibleByText('Topic 2');
+ await visibleByText("Notebook 1 (Edited)");
+ await visibleByText("Description of Notebook 1 (Edited)");
+ await visibleByText("Topic 2");
});
- it('Move notebook to trash', async () => {
+ it("Move notebook to trash", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', false, false);
+ await createNotebook("Notebook 1", false, false);
await sleep(500);
await device.pressBack();
await sleep(500);
- await visibleByText('Notebook 1');
+ await visibleByText("Notebook 1");
await tapById(notesnook.ids.notebook.menu);
- await tapByText('Move to trash');
+ await tapByText("Move to trash");
await sleep(4000);
- await navigate('Trash');
- await visibleByText('Notebook 1');
+ await navigate("Trash");
+ await visibleByText("Notebook 1");
});
- it('Pin notebook to side menu', async () => {
+ it("Pin notebook to side menu", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1', false, false);
+ await createNotebook("Notebook 1", false, false);
await sleep(500);
await device.pressBack();
await sleep(500);
- await visibleByText('Notebook 1');
+ await visibleByText("Notebook 1");
await tapById(notesnook.ids.notebook.menu);
- await tapByText('Add Shortcut');
+ await tapByText("Add Shortcut");
let menu = elementById(notesnook.ids.default.header.buttons.left);
await menu.tap();
- await visibleByText('Notebook 1');
+ await visibleByText("Notebook 1");
});
- it.only('Pin topic to side menu', async () => {
+ it.only("Pin topic to side menu", async () => {
await prepare();
- await navigate('Notebooks');
- await tapByText('Skip introduction');
+ await navigate("Notebooks");
+ await tapByText("Skip introduction");
await sleep(500);
- await createNotebook('Notebook 1');
+ await createNotebook("Notebook 1");
await sleep(500);
await device.pressBack();
await sleep(500);
- await tapByText('Notebook 1');
+ await tapByText("Notebook 1");
await tapById(notesnook.ids.notebook.menu);
- await tapByText('Add Shortcut');
+ await tapByText("Add Shortcut");
let menu = elementById(notesnook.ids.default.header.buttons.left);
await menu.tap();
await menu.tap();
- await visibleByText('Topic');
+ await visibleByText("Topic");
});
});
diff --git a/apps/mobile/e2e/tests/search.e2e.js b/apps/mobile/e2e/tests/search.e2e.js
index ba7e0ce6b..0313c2d45 100644
--- a/apps/mobile/e2e/tests/search.e2e.js
+++ b/apps/mobile/e2e/tests/search.e2e.js
@@ -1,4 +1,4 @@
-const { notesnook } = require('../test.ids');
+const { notesnook } = require("../test.ids");
const {
navigate,
tapById,
@@ -10,16 +10,16 @@ const {
elementById,
tapByText,
notVisibleByText
-} = require('./utils');
-const { sleep } = require('./utils');
+} = require("./utils");
+const { sleep } = require("./utils");
-describe('Search', () => {
- it('Search for a note', async () => {
+describe("Search", () => {
+ it("Search for a note", async () => {
await prepare();
let note = await createNote();
- await tapById('icon-search');
+ await tapById("icon-search");
await sleep(300);
- await elementById('search-input').typeText('n');
+ await elementById("search-input").typeText("n");
await sleep(1000);
await visibleByText(note.body);
});
diff --git a/apps/mobile/e2e/tests/sort.e2e.js b/apps/mobile/e2e/tests/sort.e2e.js
index 7835a7dcc..9a07914f3 100644
--- a/apps/mobile/e2e/tests/sort.e2e.js
+++ b/apps/mobile/e2e/tests/sort.e2e.js
@@ -1,4 +1,4 @@
-const { notesnook } = require('../test.ids');
+const { notesnook } = require("../test.ids");
const {
navigate,
tapById,
@@ -10,92 +10,94 @@ const {
elementById,
tapByText,
notVisibleByText
-} = require('./utils');
-const { sleep } = require('./utils');
+} = require("./utils");
+const { sleep } = require("./utils");
-async function sortBy(sorting, elementText = 'Default') {
+async function sortBy(sorting, elementText = "Default") {
await tapByText(elementText);
await tapByText(sorting);
await device.pressBack();
}
-describe('Sort & filter', () => {
- it('Sort by date-edited/date-created', async () => {
+describe("Sort & filter", () => {
+ it("Sort by date-edited/date-created", async () => {
await prepare();
- let note1 = await createNote('Note 1', 'Note 1');
- let note2 = await createNote('Note 2', 'Note 2');
+ let note1 = await createNote("Note 1", "Note 1");
+ let note2 = await createNote("Note 2", "Note 2");
await sleep(300);
- await tapByText('Note 1');
+ await tapByText("Note 1");
await sleep(500);
let webview = web(by.id(notesnook.editor.id));
- await expect(webview.element(by.web.className('ProseMirror'))).toExist();
- await webview.element(by.web.className('ProseMirror')).tap();
- await webview.element(by.web.className('ProseMirror')).typeText('Edited ', true);
+ await expect(webview.element(by.web.className("ProseMirror"))).toExist();
+ await webview.element(by.web.className("ProseMirror")).tap();
+ await webview
+ .element(by.web.className("ProseMirror"))
+ .typeText("Edited ", true);
await device.pressBack();
await device.pressBack();
- await sortBy('Date created');
+ await sortBy("Date created");
await tapById(notesnook.listitem.menu);
- await visibleByText('Note 2');
+ await visibleByText("Note 2");
await device.pressBack();
- await sortBy('Date edited');
+ await sortBy("Date edited");
await tapById(notesnook.listitem.menu);
- await visibleByText('Edited Note 1');
+ await visibleByText("Edited Note 1");
await device.pressBack();
});
- it('Disable grouping', async () => {
+ it("Disable grouping", async () => {
await prepare();
- let note1 = await createNote('Note 1', 'Note 1');
+ let note1 = await createNote("Note 1", "Note 1");
await sleep(300);
- await sortBy('None');
+ await sortBy("None");
await sleep(300);
- await visibleByText('None');
+ await visibleByText("None");
});
- it('Group by Abc', async () => {
+ it("Group by Abc", async () => {
await prepare();
- let note1 = await createNote('Note 1', 'Note 1');
+ let note1 = await createNote("Note 1", "Note 1");
await sleep(300);
- await sortBy('Abc');
- await visibleByText('N');
+ await sortBy("Abc");
+ await visibleByText("N");
});
- it('Group by Year', async () => {
+ it("Group by Year", async () => {
await prepare();
- let note1 = await createNote('Note 1', 'Note 1');
+ let note1 = await createNote("Note 1", "Note 1");
await sleep(300);
- await sortBy('Year');
+ await sortBy("Year");
await sleep(300);
- await visibleByText('Year');
+ await visibleByText("Year");
});
- it('Group by Week', async () => {
+ it("Group by Week", async () => {
await prepare();
- let note1 = await createNote('Note 1', 'Note 1');
+ let note1 = await createNote("Note 1", "Note 1");
await sleep(300);
- await sortBy('Week');
+ await sortBy("Week");
await sleep(300);
- await visibleByText('Week');
+ await visibleByText("Week");
});
- it('Group by Month', async () => {
+ it("Group by Month", async () => {
await prepare();
- let note1 = await createNote('Note 1', 'Note 1');
+ let note1 = await createNote("Note 1", "Note 1");
await sleep(300);
- await sortBy('Month');
+ await sortBy("Month");
await sleep(300);
- await visibleByText('Month');
+ await visibleByText("Month");
});
- it('Compact mode', async () => {
+ it("Compact mode", async () => {
await prepare();
- let note1 = await createNote('Note 1', 'Note 1');
+ let note1 = await createNote("Note 1", "Note 1");
await sleep(300);
- await tapById('icon-compact-mode');
+ await tapById("icon-compact-mode");
await sleep(300);
- await notVisibleByText('Note 1');
- await tapById('icon-compact-mode');
+ await notVisibleByText("Note 1");
+ await tapById("icon-compact-mode");
await sleep(300);
- await visibleByText('Note 1');
+ await visibleByText("Note 1");
});
});
diff --git a/apps/mobile/e2e/tests/tag.e2e.js b/apps/mobile/e2e/tests/tag.e2e.js
index 60164124a..c0f10f0b1 100644
--- a/apps/mobile/e2e/tests/tag.e2e.js
+++ b/apps/mobile/e2e/tests/tag.e2e.js
@@ -1,4 +1,4 @@
-const { notesnook } = require('../test.ids');
+const { notesnook } = require("../test.ids");
const {
navigate,
tapById,
@@ -10,77 +10,77 @@ const {
elementById,
tapByText,
notVisibleByText
-} = require('./utils');
-const { sleep } = require('./utils');
+} = require("./utils");
+const { sleep } = require("./utils");
-describe('Tags', () => {
- it('Tag a note', async () => {
+describe("Tags", () => {
+ it("Tag a note", async () => {
await prepare();
let note = await createNote();
await tapById(notesnook.listitem.menu);
- await tapByText('Add tags');
- await elementById('tag-input').typeText('testtag');
+ await tapByText("Add tags");
+ await elementById("tag-input").typeText("testtag");
await tapByText(`Add "#testtag"`);
- await visibleByText('#testtag');
+ await visibleByText("#testtag");
await device.pressBack();
await device.pressBack();
- await navigate('Tags');
- await tapByText('#testtag');
+ await navigate("Tags");
+ await tapByText("#testtag");
await visibleByText(note.body);
});
- it('Untag a note', async () => {
+ it("Untag a note", async () => {
await prepare();
let note = await createNote();
await tapById(notesnook.listitem.menu);
- await tapByText('Add tags');
- await elementById('tag-input').typeText('testtag');
+ await tapByText("Add tags");
+ await elementById("tag-input").typeText("testtag");
await tapByText(`Add "#testtag"`);
- await visibleByText('#testtag');
- await tapByText('#testtag');
+ await visibleByText("#testtag");
+ await tapByText("#testtag");
await device.pressBack();
await device.pressBack();
- await notVisibleByText('#testtag');
- await navigate('Tags');
- await notVisibleByText('#testtag');
+ await notVisibleByText("#testtag");
+ await navigate("Tags");
+ await notVisibleByText("#testtag");
});
- it('Creat shortcut of a tag', async () => {
+ it("Creat shortcut of a tag", async () => {
await prepare();
let note = await createNote();
await tapById(notesnook.listitem.menu);
- await tapByText('Add tags');
- await elementById('tag-input').typeText('testtag');
+ await tapByText("Add tags");
+ await elementById("tag-input").typeText("testtag");
await tapByText(`Add "#testtag"`);
- await visibleByText('#testtag');
+ await visibleByText("#testtag");
await device.pressBack();
await device.pressBack();
- await navigate('Tags');
+ await navigate("Tags");
await tapById(notesnook.ids.tag.menu);
- await tapByText('Add Shortcut');
+ await tapByText("Add Shortcut");
let menu = elementById(notesnook.ids.default.header.buttons.left);
await menu.tap();
- await visibleByText('#testtag');
+ await visibleByText("#testtag");
});
- it('Rename a tag', async () => {
+ it("Rename a tag", async () => {
await prepare();
let note = await createNote();
await tapById(notesnook.listitem.menu);
- await tapByText('Add tags');
- await elementById('tag-input').typeText('testtag');
+ await tapByText("Add tags");
+ await elementById("tag-input").typeText("testtag");
await tapByText(`Add "#testtag"`);
- await visibleByText('#testtag');
+ await visibleByText("#testtag");
await device.pressBack();
await device.pressBack();
- await navigate('Tags');
+ await navigate("Tags");
await tapById(notesnook.ids.tag.menu);
await sleep(500);
- await tapByText('Rename tag');
+ await tapByText("Rename tag");
await sleep(500);
- await elementById('input-value').clearText();
- await elementById('input-value').typeText('testtag_edited');
- await tapByText('Save');
- await visibleByText('#testtag_edited');
+ await elementById("input-value").clearText();
+ await elementById("input-value").typeText("testtag_edited");
+ await tapByText("Save");
+ await visibleByText("#testtag_edited");
});
});
diff --git a/apps/mobile/e2e/tests/utils.js b/apps/mobile/e2e/tests/utils.js
index cbd457670..bc8c865a4 100644
--- a/apps/mobile/e2e/tests/utils.js
+++ b/apps/mobile/e2e/tests/utils.js
@@ -1,14 +1,14 @@
-const { notesnook } = require('../test.ids');
-const fs = require('fs');
-const { expect: jestExpect } = require('@jest/globals');
-const { toMatchImageSnapshot } = require('jest-image-snapshot');
-const detox = require('detox');
+const { notesnook } = require("../test.ids");
+const fs = require("fs");
+const { expect: jestExpect } = require("@jest/globals");
+const { toMatchImageSnapshot } = require("jest-image-snapshot");
+const detox = require("detox");
jestExpect.extend({ toMatchImageSnapshot });
-const sleep = duration =>
- new Promise(resolve =>
+const sleep = (duration) =>
+ new Promise((resolve) =>
setTimeout(() => {
- console.log('Sleeping for ' + duration / 1000 + ' secs');
+ console.log("Sleeping for " + duration / 1000 + " secs");
resolve();
}, duration)
);
@@ -56,14 +56,16 @@ async function exitEditor() {
}
async function createNote(_title, _body) {
- let title = _title || 'Test note description that ';
- let body = _body || 'Test note description that is very long and should not fit in text.';
+ let title = _title || "Test note description that ";
+ let body =
+ _body ||
+ "Test note description that is very long and should not fit in text.";
await tapById(notesnook.buttons.add);
let webview = web(by.id(notesnook.editor.id));
- await expect(webview.element(by.web.className('ProseMirror'))).toExist();
- await webview.element(by.web.className('ProseMirror')).tap();
- await webview.element(by.web.className('ProseMirror')).typeText(body, true);
+ await expect(webview.element(by.web.className("ProseMirror"))).toExist();
+ await webview.element(by.web.className("ProseMirror")).tap();
+ await webview.element(by.web.className("ProseMirror")).typeText(body, true);
await exitEditor();
await expect(element(by.text(body))).toBeVisible();
@@ -90,7 +92,7 @@ const testvars = {
async function prepare() {
if (testvars.isFirstTest) {
- console.log('Launching App Directly without reset');
+ console.log("Launching App Directly without reset");
testvars.isFirstTest = false;
return await LaunchApp();
}
diff --git a/apps/mobile/e2e/tests/vault.e2e.js b/apps/mobile/e2e/tests/vault.e2e.js
index 83e9a9dab..c096bc7da 100644
--- a/apps/mobile/e2e/tests/vault.e2e.js
+++ b/apps/mobile/e2e/tests/vault.e2e.js
@@ -1,4 +1,4 @@
-const { notesnook } = require('../test.ids');
+const { notesnook } = require("../test.ids");
const {
tapById,
elementById,
@@ -12,111 +12,111 @@ const {
notVisibleById,
navigate,
openSideMenu
-} = require('./utils');
-const { sleep } = require('./utils');
+} = require("./utils");
+const { sleep } = require("./utils");
async function lockNote() {
await tapById(notesnook.listitem.menu);
- await tapById('icon-Vault');
+ await tapById("icon-Vault");
await sleep(1000);
- await visibleByText('Lock');
- await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');
- await elementById(notesnook.ids.dialogs.vault.pwdAlt).typeText('1234');
- await tapByText('Lock');
+ await visibleByText("Lock");
+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText("1234");
+ await elementById(notesnook.ids.dialogs.vault.pwdAlt).typeText("1234");
+ await tapByText("Lock");
await sleep(500);
- await visibleById('note-locked-icon');
+ await visibleById("note-locked-icon");
}
async function removeFromVault() {
await tapById(notesnook.listitem.menu);
- await tapById('icon-Vault');
+ await tapById("icon-Vault");
await sleep(1000);
- await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');
- await tapByText('Unlock');
+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText("1234");
+ await tapByText("Unlock");
await sleep(1000);
- await notVisibleById('note-locked-icon');
+ await notVisibleById("note-locked-icon");
}
async function openLockedNote(pwd) {
await tapById(notesnook.ids.note.get(1));
await sleep(1000);
- await visibleByText('Open');
- await elementById(notesnook.ids.dialogs.vault.pwd).typeText(pwd || '1234');
- await tapByText('Open');
+ await visibleByText("Open");
+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText(pwd || "1234");
+ await tapByText("Open");
await sleep(1000);
- await matchSnapshot(elementById('editor-wrapper'), `note-after-vault-unlock`);
+ await matchSnapshot(elementById("editor-wrapper"), `note-after-vault-unlock`);
}
async function goToPrivacySecuritySettings() {
- await navigate('Settings');
- await tapByText('Vault');
+ await navigate("Settings");
+ await tapByText("Vault");
}
-describe('VAULT', () => {
- it('Create vault from settings', async () => {
+describe("VAULT", () => {
+ it("Create vault from settings", async () => {
await prepare();
await goToPrivacySecuritySettings();
- await tapByText('Create vault');
- await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');
- await elementById(notesnook.ids.dialogs.vault.pwdAlt).typeText('1234');
- await tapByText('Create');
+ await tapByText("Create vault");
+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText("1234");
+ await elementById(notesnook.ids.dialogs.vault.pwdAlt).typeText("1234");
+ await tapByText("Create");
await sleep(500);
- await visibleByText('Clear vault');
+ await visibleByText("Clear vault");
});
- it('Change vault password', async () => {
+ it("Change vault password", async () => {
await prepare();
await createNote();
await lockNote();
await goToPrivacySecuritySettings();
- await tapByText('Change vault password');
- await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');
- await elementById(notesnook.ids.dialogs.vault.changePwd).typeText('2362');
- await tapByText('Change');
+ await tapByText("Change vault password");
+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText("1234");
+ await elementById(notesnook.ids.dialogs.vault.changePwd).typeText("2362");
+ await tapByText("Change");
await device.pressBack();
await device.pressBack();
- await openLockedNote('2362');
+ await openLockedNote("2362");
});
- it('Delete vault', async () => {
+ it("Delete vault", async () => {
await prepare();
await createNote();
await lockNote();
await goToPrivacySecuritySettings();
- await tapByText('Delete vault');
- await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');
- await tapByText('Delete');
+ await tapByText("Delete vault");
+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText("1234");
+ await tapByText("Delete");
await sleep(500);
- await visibleByText('Create vault');
+ await visibleByText("Create vault");
await device.pressBack();
await device.pressBack();
await visibleById(notesnook.listitem.menu);
});
- it('Delete vault with locked notes', async () => {
+ it("Delete vault with locked notes", async () => {
await prepare();
await createNote();
await lockNote();
await goToPrivacySecuritySettings();
- await tapByText('Delete vault');
- await elementById(notesnook.ids.dialogs.vault.pwd).typeText('1234');
- await tapByText('Delete all notes');
- await tapByText('Delete');
+ await tapByText("Delete vault");
+ await elementById(notesnook.ids.dialogs.vault.pwd).typeText("1234");
+ await tapByText("Delete all notes");
+ await tapByText("Delete");
await sleep(500);
- await visibleByText('Create vault');
+ await visibleByText("Create vault");
await device.pressBack();
await device.pressBack();
await notVisibleById(notesnook.listitem.menu);
});
- it('Add a note to vault', async () => {
+ it("Add a note to vault", async () => {
await prepare();
await createNote();
await lockNote();
await openLockedNote();
});
- it('Remove note from vault', async () => {
+ it("Remove note from vault", async () => {
await prepare();
await createNote();
await lockNote();
diff --git a/apps/mobile/share/index.js b/apps/mobile/share/index.js
index 4a9b5fc22..19da17826 100644
--- a/apps/mobile/share/index.js
+++ b/apps/mobile/share/index.js
@@ -1,11 +1,11 @@
-import React, { Fragment } from 'react';
-import { Modal, Platform } from 'react-native';
-import ShareView from './share';
-const Wrapper = Platform.OS === 'android' ? Modal : Fragment;
+import React, { Fragment } from "react";
+import { Modal, Platform } from "react-native";
+import ShareView from "./share";
+const Wrapper = Platform.OS === "android" ? Modal : Fragment;
const outerProps =
- Platform.OS === 'android'
+ Platform.OS === "android"
? {
- animationType: 'fade',
+ animationType: "fade",
transparent: true,
visible: true
}
diff --git a/apps/mobile/share/quick-note.js b/apps/mobile/share/quick-note.js
index 39492c222..bd452b817 100644
--- a/apps/mobile/share/quick-note.js
+++ b/apps/mobile/share/quick-note.js
@@ -3,7 +3,7 @@ import { Appearance, SafeAreaView } from "react-native";
import RNBootSplash from "react-native-bootsplash";
import {
COLOR_SCHEME_DARK,
- COLOR_SCHEME_LIGHT,
+ COLOR_SCHEME_LIGHT
} from "../app/utils/color-scheme";
import NotesnookShare from "./index";
@@ -15,7 +15,7 @@ export default class QuickNoteIOS extends Component {
Appearance.getColorScheme() === "dark"
? COLOR_SCHEME_DARK
: COLOR_SCHEME_LIGHT,
- height: 0,
+ height: 0
};
}
@@ -30,7 +30,7 @@ export default class QuickNoteIOS extends Component {
width: "100%",
height: "100%",
justifyContent: "flex-start",
- backgroundColor: this.state.colors.nav,
+ backgroundColor: this.state.colors.nav
}}
>
<NotesnookShare quicknote={true} />
diff --git a/apps/mobile/share/search.js b/apps/mobile/share/search.js
index 878b3a273..0597c996b 100644
--- a/apps/mobile/share/search.js
+++ b/apps/mobile/share/search.js
@@ -1,5 +1,5 @@
-import React, { useEffect, useRef, useState } from 'react';
-import { StatusBar } from 'react-native';
+import React, { useEffect, useRef, useState } from "react";
+import { StatusBar } from "react-native";
import {
ActivityIndicator,
FlatList,
@@ -9,16 +9,16 @@ import {
TouchableOpacity,
useWindowDimensions,
View
-} from 'react-native';
-import { useSafeAreaInsets } from 'react-native-safe-area-context';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import { getElevation } from '../app/utils';
-import { db } from '../app/common/database';
-import { useShareStore } from './store';
+} from "react-native";
+import { useSafeAreaInsets } from "react-native-safe-area-context";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import { getElevation } from "../app/utils";
+import { db } from "../app/common/database";
+import { useShareStore } from "./store";
export const Search = ({ close, getKeyboardHeight, quicknote }) => {
- const colors = useShareStore(state => state.colors);
- const setAppendNote = useShareStore(state => state.setAppendNote);
+ const colors = useShareStore((state) => state.colors);
+ const setAppendNote = useShareStore((state) => state.setAppendNote);
const [results, setResults] = useState([]);
const [searching, setSearching] = useState(false);
const searchKeyword = useRef(null);
@@ -26,9 +26,12 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {
const notes = useRef(null);
const timer = useRef(null);
const inputRef = useRef();
- const insets = Platform.OS === 'android' ? { top: StatusBar.currentHeight } : useSafeAreaInsets();
+ const insets =
+ Platform.OS === "android"
+ ? { top: StatusBar.currentHeight }
+ : useSafeAreaInsets();
- const onSelectItem = async item => {
+ const onSelectItem = async (item) => {
if (item.locked) {
return;
}
@@ -84,7 +87,7 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {
numberOfLines={1}
style={{
color: colors.pri,
- fontFamily: 'OpenSans-SemiBold',
+ fontFamily: "OpenSans-SemiBold",
fontSize: 15
}}
>
@@ -96,7 +99,7 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {
style={{
color: colors.icon,
fontSize: 12,
- fontFamily: 'OpenSans-Regular'
+ fontFamily: "OpenSans-Regular"
}}
>
{item.headline}
@@ -113,14 +116,14 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {
return (
<View
style={{
- position: 'absolute',
- top: Platform.OS === 'android' ? 20 : 0,
+ position: "absolute",
+ top: Platform.OS === "android" ? 20 : 0,
backgroundColor: colors.bg,
borderRadius: quicknote ? 0 : 10,
- width: quicknote ? '100%' : '95%',
+ width: quicknote ? "100%" : "95%",
minHeight: 250,
- alignSelf: 'center',
- overflow: 'hidden',
+ alignSelf: "center",
+ overflow: "hidden",
zIndex: 999,
...getElevation(quicknote ? 1 : 5),
...extra
@@ -129,9 +132,9 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {
<View
style={{
flexShrink: 1,
- flexDirection: 'row',
- justifyContent: 'space-between',
- alignItems: 'center',
+ flexDirection: "row",
+ justifyContent: "space-between",
+ alignItems: "center",
paddingHorizontal: 12,
marginBottom: 10,
height: 50
@@ -143,10 +146,10 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {
placeholderTextColor={colors.placeholder}
style={{
fontSize: 15,
- fontFamily: 'OpenSans-Regular',
- width: '85%'
+ fontFamily: "OpenSans-Regular",
+ width: "85%"
}}
- onChangeText={value => {
+ onChangeText={(value) => {
searchKeyword.current = value;
onSearch();
}}
@@ -155,7 +158,12 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {
{searching ? (
<ActivityIndicator size={25} color={colors.icon} />
) : (
- <Icon name="magnify" color={colors.pri} size={25} onPress={onSearch} />
+ <Icon
+ name="magnify"
+ color={colors.pri}
+ size={25}
+ onPress={onSearch}
+ />
)}
</View>
@@ -166,20 +174,20 @@ export const Search = ({ close, getKeyboardHeight, quicknote }) => {
}}
keyboardShouldPersistTaps="always"
keyboardDismissMode="none"
- keyExtractor={item => item.id}
+ keyExtractor={(item) => item.id}
renderItem={renderItem}
ListEmptyComponent={
<View
style={{
flex: 1,
- justifyContent: 'center',
- alignItems: 'center',
+ justifyContent: "center",
+ alignItems: "center",
height: 200
}}
>
<Text
style={{
- fontFamily: 'OpenSans-Regular',
+ fontFamily: "OpenSans-Regular",
color: colors.icon
}}
>
diff --git a/apps/mobile/share/share.js b/apps/mobile/share/share.js
index a05783bc3..e9bc83e2a 100644
--- a/apps/mobile/share/share.js
+++ b/apps/mobile/share/share.js
@@ -1,7 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */
-import { getPreviewData } from '@flyerhq/react-native-link-preview';
-import { parseHTML } from '@streetwriters/notesnook-core/utils/htmlparser';
-import React, { useEffect, useRef, useState } from 'react';
+import { getPreviewData } from "@flyerhq/react-native-link-preview";
+import { parseHTML } from "@streetwriters/notesnook-core/utils/htmlparser";
+import React, { useEffect, useRef, useState } from "react";
import {
ActivityIndicator,
Alert,
@@ -14,20 +14,23 @@ import {
TouchableOpacity,
useWindowDimensions,
View
-} from 'react-native';
-import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
-import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
-import ShareExtension from 'rn-extensions-share';
-import isURL from 'validator/lib/isURL';
-import Editor from '../app/screens/editor';
-import { eSendEvent } from '../app/services/event-manager';
-import { getElevation } from '../app/utils';
-import { db } from '../app/common/database';
-import Storage from '../app/common/database/storage';
-import { eOnLoadNote } from '../app/utils/events';
-import { Search } from './search';
-import { useShareStore } from './store';
-const getLinkPreview = url => {
+} from "react-native";
+import {
+ SafeAreaProvider,
+ useSafeAreaInsets
+} from "react-native-safe-area-context";
+import Icon from "react-native-vector-icons/MaterialCommunityIcons";
+import ShareExtension from "rn-extensions-share";
+import isURL from "validator/lib/isURL";
+import Editor from "../app/screens/editor";
+import { eSendEvent } from "../app/services/event-manager";
+import { getElevation } from "../app/utils";
+import { db } from "../app/common/database";
+import Storage from "../app/common/database/storage";
+import { eOnLoadNote } from "../app/utils/events";
+import { Search } from "./search";
+import { useShareStore } from "./store";
+const getLinkPreview = (url) => {
return getPreviewData(url, 5000);
};
async function sanitizeHtml(site) {
@@ -36,7 +39,7 @@ async function sanitizeHtml(site) {
html = await html.text();
return sanitize(html, site);
} catch (e) {
- return '';
+ return "";
}
}
@@ -45,51 +48,51 @@ function makeHtmlFromUrl(url) {
}
function makeHtmlFromPlainText(text) {
- if (!text) return '';
+ if (!text) return "";
return `<p style="overflow-wrap:anywhere;white-space:pre-wrap" >${text.replace(
/(?:\r\n|\r|\n)/g,
- '<br>'
+ "<br>"
)}</p>`;
}
function getBaseUrl(site) {
- var url = site.split('/').slice(0, 3).join('/');
+ var url = site.split("/").slice(0, 3).join("/");
return url;
}
function wrapTablesWithDiv(document) {
- const tables = document.getElementsByTagName('table');
+ const tables = document.getElementsByTagName("table");
for (let table of tables) {
- table.setAttribute('contenteditable', 'true');
- const div = document.createElement('div');
- div.setAttribute('contenteditable', 'false');
+ table.setAttribute("contenteditable", "true");
+ const div = document.createElement("div");
+ div.setAttribute("contenteditable", "false");
div.innerHTML = table.outerHTML;
- div.classList.add('table-container');
+ div.classList.add("table-container");
table.replaceWith(div);
}
return document;
}
let elementBlacklist = [
- 'script',
- 'button',
- 'input',
- 'textarea',
- 'style',
- 'form',
- 'link',
- 'head',
- 'nav',
- 'iframe',
- 'canvas',
- 'select',
- 'dialog',
- 'footer'
+ "script",
+ "button",
+ "input",
+ "textarea",
+ "style",
+ "form",
+ "link",
+ "head",
+ "nav",
+ "iframe",
+ "canvas",
+ "select",
+ "dialog",
+ "footer"
];
function removeInvalidElements(document) {
- let elements = document.querySelectorAll(elementBlacklist.join(','));
+ let elements = document.querySelectorAll(elementBlacklist.join(","));
for (let element of elements) {
element.remove();
}
@@ -97,34 +100,34 @@ function removeInvalidElements(document) {
}
function replaceSrcWithAbsoluteUrls(document, baseUrl) {
- let images = document.querySelectorAll('img');
+ let images = document.querySelectorAll("img");
console.log(images.length);
for (var i = 0; i < images.length; i++) {
let img = images[i];
let url = getBaseUrl(baseUrl);
- let src = img.getAttribute('src');
- if (src.startsWith('/')) {
- if (src.startsWith('//')) {
- src = src.replace('//', 'https://');
+ let src = img.getAttribute("src");
+ if (src.startsWith("/")) {
+ if (src.startsWith("//")) {
+ src = src.replace("//", "https://");
} else {
src = url + src;
}
}
- if (src.startsWith('data:')) {
+ if (src.startsWith("data:")) {
img.remove();
} else {
- img.setAttribute('src', src);
+ img.setAttribute("src", src);
}
}
- console.log('end');
+ console.log("end");
return document;
}
function fixCodeBlocks(document) {
- let elements = document.querySelectorAll('code,pre');
+ let elements = document.querySelectorAll("code,pre");
for (let element of elements) {
- element.classList.add('.hljs');
+ element.classList.add(".hljs");
}
return document;
}
@@ -144,33 +147,33 @@ let defaultNote = {
title: null,
id: null,
content: {
- type: 'tiptap',
+ type: "tiptap",
data: null
}
};
const modes = {
1: {
- type: 'text',
- title: 'Plain text',
- icon: 'card-text-outline'
+ type: "text",
+ title: "Plain text",
+ icon: "card-text-outline"
},
2: {
- type: 'clip',
- title: 'Web clip',
- icon: 'web'
+ type: "clip",
+ title: "Web clip",
+ icon: "web"
},
3: {
- type: 'link',
- title: 'Link',
- icon: 'link'
+ type: "link",
+ title: "Link",
+ icon: "link"
}
};
const ShareView = ({ quicknote = false }) => {
- const colors = useShareStore(state => state.colors);
- const accent = useShareStore(state => state.accent);
- const appendNote = useShareStore(state => state.appendNote);
+ const colors = useShareStore((state) => state.colors);
+ const accent = useShareStore((state) => state.accent);
+ const appendNote = useShareStore((state) => state.appendNote);
const [note, setNote] = useState({ ...defaultNote });
const noteContent = useRef();
const [loadingIntent, setLoadingIntent] = useState(true);
@@ -184,32 +187,41 @@ const ShareView = ({ quicknote = false }) => {
const [mode, setMode] = useState(1);
const keyboardHeight = useRef(0);
const { width, height } = useWindowDimensions();
- const insets = Platform.OS === 'android' ? { top: StatusBar.currentHeight } : useSafeAreaInsets();
+ const insets =
+ Platform.OS === "android"
+ ? { top: StatusBar.currentHeight }
+ : useSafeAreaInsets();
const [showSearch, setShowSearch] = useState(false);
const [kh, setKh] = useState(0);
const editorRef = useRef();
- const onKeyboardDidShow = event => {
+ const onKeyboardDidShow = (event) => {
let kHeight = event.endCoordinates.height;
keyboardHeight.current = kHeight;
setKh(kHeight);
- console.log('keyboard show/hide');
+ console.log("keyboard show/hide");
};
const onKeyboardDidHide = () => {
keyboardHeight.current = 0;
setKh(0);
- console.log('keyboard hide');
+ console.log("keyboard hide");
};
useEffect(() => {
useShareStore.getState().setAccent();
let keyboardWillChangeFrame = Keyboard.addListener(
- 'keyboardWillChangeFrame',
+ "keyboardWillChangeFrame",
onKeyboardWillChangeFrame
);
- let keyboardDidShow = Keyboard.addListener('keyboardDidShow', onKeyboardDidShow);
- let keyboardDidHide = Keyboard.addListener('keyboardDidHide', onKeyboardDidHide);
+ let keyboardDidShow = Keyboard.addListener(
+ "keyboardDidShow",
+ onKeyboardDidShow
+ );
+ let keyboardDidHide = Keyboard.addListener(
+ "keyboardDidHide",
+ onKeyboardDidHide
+ );
return () => {
keyboardWillChangeFrame?.remove();
keyboardDidShow?.remove();
@@ -217,7 +229,7 @@ const ShareView = ({ quicknote = false }) => {
};
}, []);
- const onKeyboardWillChangeFrame = event => {
+ const onKeyboardWillChangeFrame = (event) => {
setFloating(event.endCoordinates.width !== width);
};
@@ -240,14 +252,14 @@ const ShareView = ({ quicknote = false }) => {
const data = await ShareExtension.data();
if (!data || data.length === 0) {
setRawData({
- value: ''
+ value: ""
});
setLoadingIntent(false);
return;
}
let note = { ...defaultNote };
for (let item of data) {
- if (item.type === 'text') {
+ if (item.type === "text") {
setRawData(item);
if (isURL(item.value)) {
note = await showLinkPreview(note, item.value);
@@ -258,7 +270,7 @@ const ShareView = ({ quicknote = false }) => {
}
}
setNote({ ...note });
- console.log(data, 'share data');
+ console.log(data, "share data");
onLoad();
} catch (e) {}
setLoadingIntent(false);
@@ -278,21 +290,21 @@ const ShareView = ({ quicknote = false }) => {
setLoadingIntent(true);
setLoadingExtension(true);
if (quicknote) {
- ShareExtension.openURL('ShareMedia://MainApp');
+ ShareExtension.openURL("ShareMedia://MainApp");
} else {
ShareExtension.close();
}
};
- const onLoad = editor => {
+ const onLoad = (editor) => {
if (editor) {
- Storage.write('shareExtensionOpened', 'opened');
+ Storage.write("shareExtensionOpened", "opened");
return loadData();
}
- eSendEvent(eOnLoadNote + 'shareEditor', {
+ eSendEvent(eOnLoadNote + "shareEditor", {
id: null,
content: {
- type: 'tiptap',
+ type: "tiptap",
data: noteContent.current
},
forced: true
@@ -306,7 +318,7 @@ const ShareView = ({ quicknote = false }) => {
if (appendNote && !db.notes.note(appendNote.id)) {
useShareStore.getState().setAppendNote(null);
- Alert.alert('The note you are trying to append to has been deleted.');
+ Alert.alert("The note you are trying to append to has been deleted.");
return;
}
@@ -315,8 +327,8 @@ const ShareView = ({ quicknote = false }) => {
let raw = await db.content.raw(appendNote.contentId);
_note = {
content: {
- data: raw.data + '\n' + noteContent.current,
- type: 'tiptap'
+ data: raw.data + "\n" + noteContent.current,
+ type: "tiptap"
},
id: appendNote.id,
sessionId: Date.now()
@@ -327,7 +339,7 @@ const ShareView = ({ quicknote = false }) => {
_note.sessionId = Date.now();
}
await db.notes.add(_note);
- await Storage.write('notesAddedFromIntent', 'added');
+ await Storage.write("notesAddedFromIntent", "added");
close();
setLoading(false);
};
@@ -336,14 +348,14 @@ const ShareView = ({ quicknote = false }) => {
useShareStore.getState().setColors();
}, [note]);
- const changeMode = async m => {
+ const changeMode = async (m) => {
setMode(m);
setLoading(true);
try {
if (m === 2) {
let html = await sanitizeHtml(rawData.value);
- setNote(note => {
+ setNote((note) => {
note.content.data = html;
noteContent.current = html;
onLoad();
@@ -353,7 +365,7 @@ const ShareView = ({ quicknote = false }) => {
let html = isURL(rawData.value)
? makeHtmlFromUrl(rawData.value)
: makeHtmlFromPlainText(rawData.value);
- setNote(note => {
+ setNote((note) => {
note.content.data = html;
noteContent.current = html;
onLoad();
@@ -371,22 +383,22 @@ const ShareView = ({ quicknote = false }) => {
style={{
width: width > 500 ? 500 : width,
height: quicknote ? height : height - kh,
- alignSelf: 'center',
- justifyContent: quicknote ? 'flex-start' : 'flex-end'
+ alignSelf: "center",
+ justifyContent: quicknote ? "flex-start" : "flex-end"
}}
>
{quicknote && !showSearch ? (
<View
style={{
- width: '100%',
+ width: "100%",
backgroundColor: colors.bg,
height: 50 + insets.top,
paddingTop: insets.top,
...getElevation(1),
marginTop: -insets.top,
- flexDirection: 'row',
- alignItems: 'center',
- justifyContent: 'space-between'
+ flexDirection: "row",
+ alignItems: "center",
+ justifyContent: "space-between"
}}
>
<Button
@@ -395,7 +407,7 @@ const ShareView = ({ quicknote = false }) => {
iconColor={colors.pri}
onPress={() => {
if (showSearch) {
- console.log('hide search');
+ console.log("hide search");
setShowSearch(false);
} else {
close();
@@ -413,7 +425,7 @@ const ShareView = ({ quicknote = false }) => {
style={{
color: colors.pri,
fontSize: 17,
- fontFamily: 'OpenSans-Regular'
+ fontFamily: "OpenSans-Regular"
}}
>
Quick note
@@ -437,23 +449,23 @@ const ShareView = ({ quicknote = false }) => {
activeOpacity={1}
onPress={() => {
if (showSearch) {
- console.log('hide search');
+ console.log("hide search");
setShowSearch(false);
} else {
close();
}
}}
style={{
- width: '100%',
- height: '100%',
- position: 'absolute'
+ width: "100%",
+ height: "100%",
+ position: "absolute"
}}
>
<View
style={{
- width: '100%',
- height: '100%',
- backgroundColor: 'white',
+ width: "100%",
+ height: "100%",
+ backgroundColor: "white",
opacity: 0.01
}}
/>
@@ -474,28 +486,28 @@ const ShareView = ({ quicknote = false }) => {
<View
style={{
paddingVertical: 25,
- backgroundColor: 'transparent',
+ backgroundColor: "transparent",
marginBottom: insets.top,
- display: showSearch ? 'none' : 'flex'
+ display: showSearch ? "none" : "flex"
}}
>
<View
style={{
- maxHeight: '100%',
+ maxHeight: "100%",
paddingHorizontal: 12
}}
>
<ScrollView
horizontal
contentContainerStyle={{
- alignItems: 'center',
+ alignItems: "center",
height: 50
}}
style={{
- width: '100%',
+ width: "100%",
height: 50,
borderRadius: 10,
- flexDirection: 'row',
+ flexDirection: "row",
bottom: -10
}}
>
@@ -528,7 +540,9 @@ const ShareView = ({ quicknote = false }) => {
icon="text-short"
iconSize={18}
iconColor={appendNote ? accent.color : colors.icon}
- title={`${appendNote ? appendNote.title.slice(0, 25) : 'Append to note'}`}
+ title={`${
+ appendNote ? appendNote.title.slice(0, 25) : "Append to note"
+ }`}
textColor={appendNote ? accent.color : colors.icon}
type="rounded"
textStyle={{
@@ -544,7 +558,7 @@ const ShareView = ({ quicknote = false }) => {
<View
style={{
- width: '100%'
+ width: "100%"
}}
>
<View
@@ -554,12 +568,12 @@ const ShareView = ({ quicknote = false }) => {
borderRadius: 10,
...getElevation(quicknote ? 1 : 5),
backgroundColor: colors.bg,
- overflow: 'hidden'
+ overflow: "hidden"
}}
>
<View
style={{
- width: '100%',
+ width: "100%",
height: height * 0.3,
paddingBottom: 15,
borderRadius: 10
@@ -585,7 +599,7 @@ const ShareView = ({ quicknote = false }) => {
onLoad={() => {
onLoad(true);
}}
- onChange={html => {
+ onChange={(html) => {
noteContent.current = html;
}}
/>
@@ -598,37 +612,37 @@ const ShareView = ({ quicknote = false }) => {
style={{
fontSize: 12,
color: colors.icon,
- fontFamily: 'OpenSans-Regular',
+ fontFamily: "OpenSans-Regular",
paddingHorizontal: 12,
marginBottom: 10,
- flexWrap: 'wrap'
+ flexWrap: "wrap"
}}
>
- Above content will append to{' '}
+ Above content will append to{" "}
<Text
style={{
color: accent.color,
- fontFamily: 'OpenSans-SemiBold'
+ fontFamily: "OpenSans-SemiBold"
}}
>
"{appendNote.title}"
- </Text>{' '}
+ </Text>{" "}
. Click on "New note" to create a new note.
</Text>
) : null}
<View
style={{
- flexDirection: 'row',
+ flexDirection: "row",
paddingHorizontal: 12,
- alignItems: 'flex-end',
- justifyContent: 'space-between',
- width: '100%'
+ alignItems: "flex-end",
+ justifyContent: "space-between",
+ width: "100%"
}}
>
<View
style={{
- flexDirection: 'row'
+ flexDirection: "row"
}}
>
{rawData.value && isURL(rawData.value) ? (
@@ -680,7 +694,7 @@ const ShareView = ({ quicknote = false }) => {
<View
style={{
- height: Platform.isPad ? 150 : Platform.OS === 'ios' ? 110 : 0
+ height: Platform.isPad ? 150 : Platform.OS === "ios" ? 110 : 0
}}
/>
</View>
@@ -698,9 +712,9 @@ const Button = ({
textStyle,
icon,
iconSize = 22,
- type = 'button',
- iconColor = 'gray',
- textColor = 'white',
+ type = "button",
+ iconColor = "gray",
+ textColor = "white",
fontSize = 18
}) => {
const types = {
@@ -718,9 +732,9 @@ const Button = ({
style: {
height: 50,
borderRadius: 5,
- justifyContent: 'center',
- alignItems: 'center',
- flexDirection: 'row',
+ justifyContent: "center",
+ alignItems: "center",
+ flexDirection: "row",
marginBottom: 10,
minWidth: 80,
paddingHorizontal: 20
@@ -751,9 +765,9 @@ const Button = ({
backgroundColor: color,
height: 50,
borderRadius: 5,
- justifyContent: 'center',
- alignItems: 'center',
- flexDirection: 'row',
+ justifyContent: "center",
+ alignItems: "center",
+ flexDirection: "row",
marginBottom: 10,
minWidth: 80,
paddingHorizontal: 20
@@ -764,14 +778,16 @@ const Button = ({
>
{loading ? <ActivityIndicator color={iconColor} /> : null}
- {icon && !loading ? <Icon name={icon} size={iconSize} color={iconColor || 'white'} /> : null}
+ {icon && !loading ? (
+ <Icon name={icon} size={iconSize} color={iconColor || "white"} />
+ ) : null}
{title ? (
<Text
style={[
{
fontSize: fontSize || 18,
- fontFamily: 'OpenSans-Regular',
+ fontFamily: "OpenSans-Regular",
color: textColor,
marginLeft: loading ? 10 : 0
},
diff --git a/apps/mobile/share/store.js b/apps/mobile/share/store.js
index 9b633696d..0ed43ac2b 100644
--- a/apps/mobile/share/store.js
+++ b/apps/mobile/share/store.js
@@ -1,13 +1,20 @@
-import { Appearance } from 'react-native';
-import create from 'zustand';
-import { ACCENT, COLOR_SCHEME_DARK, COLOR_SCHEME_LIGHT } from '../app/utils/color-scheme';
-import { MMKV } from '../app/common/database/mmkv';
+import { Appearance } from "react-native";
+import create from "zustand";
+import {
+ ACCENT,
+ COLOR_SCHEME_DARK,
+ COLOR_SCHEME_LIGHT
+} from "../app/utils/color-scheme";
+import { MMKV } from "../app/common/database/mmkv";
export const useShareStore = create((set, get) => ({
- colors: Appearance.getColorScheme() === 'dark' ? COLOR_SCHEME_DARK : COLOR_SCHEME_LIGHT,
+ colors:
+ Appearance.getColorScheme() === "dark"
+ ? COLOR_SCHEME_DARK
+ : COLOR_SCHEME_LIGHT,
accent: ACCENT,
setAccent: async () => {
- let appSettings = MMKV.getString('appSettings');
+ let appSettings = MMKV.getString("appSettings");
if (appSettings) {
appSettings = JSON.parse(appSettings);
@@ -15,23 +22,26 @@ export const useShareStore = create((set, get) => ({
let accent = {
color: accentColor,
- shade: accentColor + '12'
+ shade: accentColor + "12"
};
set({ accent: accent });
}
},
setColors: () => {
set({
- colors: Appearance.getColorScheme() === 'dark' ? COLOR_SCHEME_DARK : COLOR_SCHEME_LIGHT
+ colors:
+ Appearance.getColorScheme() === "dark"
+ ? COLOR_SCHEME_DARK
+ : COLOR_SCHEME_LIGHT
});
},
appendNote: null,
- setAppendNote: note => {
- MMKV.setItem('shareMenuAppendNote', JSON.stringify(note));
+ setAppendNote: (note) => {
+ MMKV.setItem("shareMenuAppendNote", JSON.stringify(note));
set({ appendNote: note });
},
restoreAppendNote: async () => {
- let note = MMKV.getString('shareMenuAppendNote');
+ let note = MMKV.getString("shareMenuAppendNote");
if (note) {
note = JSON.parse(note);
set({ appendNote: note });
diff --git a/apps/web/.env-cmdrc.js b/apps/web/.env-cmdrc.js
index f0f5fe793..b9dad8075 100644
--- a/apps/web/.env-cmdrc.js
+++ b/apps/web/.env-cmdrc.js
@@ -11,10 +11,10 @@ console.log("App version:", APP_VERSION);
console.log("Ip address:", ip.address());
module.exports = {
beta: {
- REACT_APP_BETA: true,
+ REACT_APP_BETA: true
},
test: {
- TEST_ALL: true,
+ TEST_ALL: true
},
all: {
UV_THREADPOOL_SIZE: IS_CI ? NUM_CPUS : 2,
@@ -22,27 +22,27 @@ module.exports = {
INLINE_RUNTIME_CHUNK: false,
DISABLE_ESLINT_PLUGIN: true,
REACT_APP_GIT_HASH: gitHash,
- REACT_APP_VERSION: APP_VERSION,
+ REACT_APP_VERSION: APP_VERSION
},
dev: {
REACT_APP_LOCALHOST: ip.address(),
- REACT_APP_CI: "true",
+ REACT_APP_CI: "true"
},
web: {
- REACT_APP_PLATFORM: "web",
+ REACT_APP_PLATFORM: "web"
},
debug: {
PWDEBUG: 1,
- DEBUG: "pw:api",
+ DEBUG: "pw:api"
},
silent: {
REACT_APP_TEST: true,
DISABLE_ESLINT_PLUGIN: "true",
FAST_REFRESH: "false",
- BROWSER: "none",
+ BROWSER: "none"
},
desktop: {
BROWSER: "none",
- REACT_APP_PLATFORM: "desktop",
- },
+ REACT_APP_PLATFORM: "desktop"
+ }
};
diff --git a/apps/web/__e2e__/checkout.test.js b/apps/web/__e2e__/checkout.test.js
index 909d38006..8a4ad7c65 100644
--- a/apps/web/__e2e__/checkout.test.js
+++ b/apps/web/__e2e__/checkout.test.js
@@ -16,7 +16,7 @@ test.beforeEach(async ({ page: _page, baseURL }) => {
const plans = [
{ key: "monthly", title: "Monthly", coupon: "INTRO50" },
- { key: "yearly", title: "Yearly", coupon: "YEAR15" },
+ { key: "yearly", title: "Yearly", coupon: "YEAR15" }
];
const pricingItems = ["subtotal", "tax", "discount", "total"];
@@ -159,7 +159,7 @@ test("changing locale should show localized prices", async ({ page }, info) => {
});
test("applying coupon should change discount & total price", async ({
- page,
+ page
}, info) => {
info.setTimeout(0);
@@ -180,7 +180,7 @@ test("applying coupon should change discount & total price", async ({
await getPaddleFrame();
await page.waitForSelector(getTestId(`checkout-plan-coupon-applied`), {
- state: "attached",
+ state: "attached"
});
const prices = roundOffPrices((await getPrices()).join("\n"));
@@ -201,7 +201,7 @@ test("apply coupon through url", async ({ page }, info) => {
await getPaddleFrame();
await page.waitForSelector(getTestId(`checkout-plan-coupon-applied`), {
- state: "attached",
+ state: "attached"
});
const prices = roundOffPrices((await getPrices()).join("\n"));
@@ -233,7 +233,7 @@ test("apply coupon after changing country", async ({ page }, info) => {
await getPaddleFrame();
await page.waitForSelector(getTestId(`checkout-plan-coupon-applied`), {
- state: "attached",
+ state: "attached"
});
const prices = roundOffPrices((await getPrices()).join("\n"));
diff --git a/apps/web/__e2e__/editor.test.js b/apps/web/__e2e__/editor.test.js
index e356c4b98..327e79a2f 100644
--- a/apps/web/__e2e__/editor.test.js
+++ b/apps/web/__e2e__/editor.test.js
@@ -7,11 +7,11 @@ const {
getEditorTitle,
getEditorContent,
getEditorContentAsHTML,
- editNote,
+ editNote
} = require("./utils");
const {
checkNotePresence,
- createNoteAndCheckPresence,
+ createNoteAndCheckPresence
} = require("./utils/conditions");
/**
* @type {Page}
@@ -153,7 +153,7 @@ test("opening an empty titled note should empty out editor contents", async () =
await createNoteAndCheckPresence();
const onlyTitle = await createNoteAndCheckPresence({
- title: "Only a title",
+ title: "Only a title"
});
await page.click(getTestId("notes-action-button"));
@@ -234,16 +234,16 @@ test.skip("last line doesn't get saved if it's font is different", async () => {
});
test("editing a note and switching immediately to another note and making an edit shouldn't overlap both notes", async ({
- page,
+ page
}, { setTimeout }) => {
await createNoteAndCheckPresence({
title: "Test note 1",
- content: "53ad8e4e40ebebd0f400498d",
+ content: "53ad8e4e40ebebd0f400498d"
});
await createNoteAndCheckPresence({
title: "Test note 2",
- content: "f054d19e9a2f46eff7b9bb25",
+ content: "f054d19e9a2f46eff7b9bb25"
});
const selector1 = `[data-item-index="1"] div`;
@@ -273,17 +273,17 @@ test("editing a note and switching immediately to another note and making an edi
});
test("editing a note and switching immediately to another note and editing the title shouldn't overlap both notes", async ({
- page,
+ page
}, testInfo) => {
testInfo.setTimeout(0);
await createNoteAndCheckPresence({
title: "Test note 1",
- content: "53ad8e4e40ebebd0f400498d",
+ content: "53ad8e4e40ebebd0f400498d"
});
await createNoteAndCheckPresence({
title: "Test note 2",
- content: "f054d19e9a2f46eff7b9bb25",
+ content: "f054d19e9a2f46eff7b9bb25"
});
const selector1 = `[data-item-index="1"] div`;
diff --git a/apps/web/__e2e__/importer.test.js b/apps/web/__e2e__/importer.test.js
index 0cc9f0ddf..b7e238584 100644
--- a/apps/web/__e2e__/importer.test.js
+++ b/apps/web/__e2e__/importer.test.js
@@ -27,7 +27,7 @@ test("login user & import notes", async () => {
const [fileChooser] = await Promise.all([
page.waitForEvent("filechooser"),
- page.click(getTestId("import-dialog-select-files")),
+ page.click(getTestId("import-dialog-select-files"))
]);
await fileChooser.setFiles(path.join(__dirname, "data", "importer-data.zip"));
diff --git a/apps/web/__e2e__/navigation.test.js b/apps/web/__e2e__/navigation.test.js
index 2fb2f289b..2771b8f1e 100644
--- a/apps/web/__e2e__/navigation.test.js
+++ b/apps/web/__e2e__/navigation.test.js
@@ -19,13 +19,13 @@ const routes = [
createRoute("monographs", "Monographs"),
createRoute("tags", "Tags"),
createRoute("trash", "Trash"),
- createRoute("settings", "Settings"),
+ createRoute("settings", "Settings")
];
for (let route of routes) {
test(`navigating to ${route.header}`, async ({ page }) => {
await page.waitForSelector(getTestId(route.buttonId), {
- state: "visible",
+ state: "visible"
});
await page.click(getTestId(route.buttonId));
await expect(page.inputValue(getTestId("routeHeader"))).resolves.toBe(
diff --git a/apps/web/__e2e__/notebooks.test.js b/apps/web/__e2e__/notebooks.test.js
index d0ed3fcc8..e98866748 100644
--- a/apps/web/__e2e__/notebooks.test.js
+++ b/apps/web/__e2e__/notebooks.test.js
@@ -6,14 +6,14 @@ const {
openContextMenu,
useContextMenu,
clickMenuItem,
- confirmDialog,
+ confirmDialog
} = require("./utils/actions");
const List = require("./utils/listitemidbuilder");
const Menu = require("./utils/menuitemidbuilder");
const {
checkNotePresence,
isPresent,
- checkMenuItemText,
+ checkMenuItemText
} = require("./utils/conditions");
/**
@@ -136,7 +136,7 @@ test("edit a notebook", async () => {
const notebook = {
title: "An Edited Notebook",
description: "A new edited description",
- topics: ["Topic 1", "Topic 2", "Topic 3"],
+ topics: ["Topic 1", "Topic 2", "Topic 3"]
};
await page.fill(getTestId("and-name"), notebook.title);
diff --git a/apps/web/__e2e__/notes.test.js b/apps/web/__e2e__/notes.test.js
index 9b6f22689..32712f6a5 100644
--- a/apps/web/__e2e__/notes.test.js
+++ b/apps/web/__e2e__/notes.test.js
@@ -14,7 +14,7 @@ const {
editNote,
getEditorTitle,
getEditorContent,
- isTestAll,
+ isTestAll
} = require("./utils");
const {
navigateTo,
@@ -22,7 +22,7 @@ const {
openContextMenu,
confirmDialog,
closeContextMenu,
- useContextMenu,
+ useContextMenu
} = require("./utils/actions");
const {
isToastPresent,
@@ -30,7 +30,7 @@ const {
isAbsent,
checkNotePresence,
createNoteAndCheckPresence,
- checkMenuItemText,
+ checkMenuItemText
} = require("./utils/conditions");
const List = require("./utils/listitemidbuilder");
const Menu = require("./utils/menuitemidbuilder");
diff --git a/apps/web/__e2e__/tags.test.js b/apps/web/__e2e__/tags.test.js
index 4d36e8fb6..f20791de3 100644
--- a/apps/web/__e2e__/tags.test.js
+++ b/apps/web/__e2e__/tags.test.js
@@ -4,7 +4,7 @@ const { getTestId, createNote, NOTE } = require("./utils");
const {
navigateTo,
useContextMenu,
- clickMenuItem,
+ clickMenuItem
} = require("./utils/actions");
const { checkNotePresence } = require("./utils/conditions");
const List = require("./utils/listitemidbuilder");
@@ -108,7 +108,7 @@ test("create a note inside a tag", async ({ page }) => {
});
test("edit a tag and make sure all its references on note are updated", async ({
- page,
+ page
}) => {
let tagSelector = await createTagAndCheckPresence("helloworld");
@@ -135,7 +135,7 @@ test("edit a tag and make sure all its references on note are updated", async ({
});
test("delete a tag and make sure all associated notes are untagged", async ({
- page,
+ page
}) => {
const tagSelector = await createTagAndCheckPresence("helloworld");
@@ -207,7 +207,7 @@ test("delete a shortcut of a tag", async ({ page }) => {
});
test("delete the last note of a tag that is also a shortcut", async ({
- page,
+ page
}) => {
const tagSelector = await createTagAndCheckPresence("helloworld");
diff --git a/apps/web/__e2e__/user.test.js b/apps/web/__e2e__/user.test.js
index 91e435e61..a426ad575 100644
--- a/apps/web/__e2e__/user.test.js
+++ b/apps/web/__e2e__/user.test.js
@@ -48,7 +48,7 @@ test("logout user", async () => {
test("login user and change password repeatedly", async ({
page,
- browserName,
+ browserName
}) => {
test.setTimeout(2 * 60 * 1000);
test.skip(browserName !== "chromium", "Cannot run in parallel.");
@@ -58,47 +58,44 @@ test("login user and change password repeatedly", async ({
let email = USER.email;
for (let i = 0; i < 3; i++) {
- await test.step(
- `login user using password ${currentPassword} (${i})`,
- async () => {
- await loginUser({
- email,
- password: currentPassword,
- });
+ await test.step(`login user using password ${currentPassword} (${i})`, async () => {
+ await loginUser({
+ email,
+ password: currentPassword
+ });
- await page.waitForSelector(getTestId("sync-status-synced"));
+ await page.waitForSelector(getTestId("sync-status-synced"));
- await page.click(getTestId("navitem-settings"));
+ await page.click(getTestId("navitem-settings"));
- await page.click(getTestId("settings-change-password"));
+ await page.click(getTestId("settings-change-password"));
- await page.waitForSelector(getTestId("dialog-yes"));
+ await page.waitForSelector(getTestId("dialog-yes"));
- await page.fill(getTestId("dialog-password"), currentPassword);
+ await page.fill(getTestId("dialog-password"), currentPassword);
- await page.fill(getTestId("dialog-new-password"), newPassword);
+ await page.fill(getTestId("dialog-new-password"), newPassword);
- await page.click(getTestId("dialog-yes"));
+ await page.click(getTestId("dialog-yes"));
- expect(await isAbsent(getTestId("dialog-yes"), 60 * 1000)).toBe(true);
+ expect(await isAbsent(getTestId("dialog-yes"), 60 * 1000)).toBe(true);
- await logoutUser();
+ await logoutUser();
- await page.reload();
+ await page.reload();
- await page.waitForTimeout(2000);
+ await page.waitForTimeout(2000);
- const cPassword = currentPassword;
- currentPassword = newPassword;
- newPassword = cPassword;
- }
- );
+ const cPassword = currentPassword;
+ currentPassword = newPassword;
+ newPassword = cPassword;
+ });
}
});
test("reset user password using recovery key", async ({
page,
- browserName,
+ browserName
}) => {
test.setTimeout(2 * 60 * 1000);
test.skip(browserName !== "chromium", "Cannot run in parallel.");
@@ -116,7 +113,7 @@ test("reset user password using recovery key", async ({
test("reset user password after session expiry", async ({
page,
- browserName,
+ browserName
}) => {
test.setTimeout(2 * 60 * 1000);
test.skip(browserName !== "chromium", "Cannot run in parallel.");
@@ -173,7 +170,7 @@ test("reset user password after session expiry", async ({
test("reset user password using old password", async ({
page,
- browserName,
+ browserName
}) => {
test.setTimeout(2 * 60 * 1000);
test.skip(browserName !== "chromium", "Cannot run in parallel.");
diff --git a/apps/web/__e2e__/utils/actions.js b/apps/web/__e2e__/utils/actions.js
index f2c9509f1..93a272494 100644
--- a/apps/web/__e2e__/utils/actions.js
+++ b/apps/web/__e2e__/utils/actions.js
@@ -9,7 +9,7 @@ async function navigateTo(pageId) {
async function clickMenuItem(itemId) {
await page.click(Menu.new("menuitem").item(itemId).build(), {
button: "left",
- force: true,
+ force: true
});
}
@@ -39,5 +39,5 @@ module.exports = {
openContextMenu,
confirmDialog,
closeContextMenu,
- useContextMenu,
+ useContextMenu
};
diff --git a/apps/web/__e2e__/utils/conditions.js b/apps/web/__e2e__/utils/conditions.js
index edfe4f09c..3cbdd9436 100644
--- a/apps/web/__e2e__/utils/conditions.js
+++ b/apps/web/__e2e__/utils/conditions.js
@@ -72,5 +72,5 @@ module.exports = {
isToastPresent,
checkNotePresence,
createNoteAndCheckPresence,
- checkMenuItemText,
+ checkMenuItemText
};
diff --git a/apps/web/__e2e__/utils/index.js b/apps/web/__e2e__/utils/index.js
index 82f87d4d6..f3868fb12 100644
--- a/apps/web/__e2e__/utils/index.js
+++ b/apps/web/__e2e__/utils/index.js
@@ -9,12 +9,12 @@ const USER = {
email: process.env.USER_EMAIL,
NEW: {
password: process.env.NEW_USER_PASSWORD,
- key: process.env.NEW_USER_KEY,
+ key: process.env.NEW_USER_KEY
},
CURRENT: {
password: process.env.CURRENT_USER_PASSWORD,
- key: process.env.CURRENT_USER_KEY,
- },
+ key: process.env.CURRENT_USER_KEY
+ }
};
async function loginUser(user = USER, navigate = true) {
@@ -35,12 +35,12 @@ async function loginUser(user = USER, navigate = true) {
const NOTEBOOK = {
title: "Test notebook 1",
description: "This is test notebook 1",
- topics: ["Topic 1", "Very long topic 2", "Topic 3"],
+ topics: ["Topic 1", "Very long topic 2", "Topic 3"]
};
const NOTE = {
title: "Test 1",
- content: "This is " + "Test 1".repeat(10),
+ content: "This is " + "Test 1".repeat(10)
};
const PASSWORD = "123abc123abc";
@@ -63,7 +63,7 @@ async function editNote(title, content, noDelay = false) {
if (title)
await page.fill(getTestId("editor-title"), title, {
strict: true,
- force: true,
+ force: true
});
if (content) {
@@ -118,5 +118,5 @@ module.exports = {
getEditorContent,
getEditorContentAsHTML,
isTestAll,
- loginUser,
+ loginUser
};
diff --git a/apps/web/desktop/autoupdate.js b/apps/web/desktop/autoupdate.js
index 7aa6e6918..a64c77dff 100644
--- a/apps/web/desktop/autoupdate.js
+++ b/apps/web/desktop/autoupdate.js
@@ -7,7 +7,7 @@ async function configureAutoUpdater() {
autoUpdater.setFeedURL({
provider: "generic",
url: `https://notesnook.com/releases/${process.platform}/`,
- useMultipleRangeRequest: false,
+ useMultipleRangeRequest: false
});
autoUpdater.autoDownload = false;
diff --git a/apps/web/desktop/changelog.js b/apps/web/desktop/changelog.js
index 59287eab9..ade346d2c 100644
--- a/apps/web/desktop/changelog.js
+++ b/apps/web/desktop/changelog.js
@@ -9,7 +9,7 @@ module.exports.getChangelog = async function (tag) {
const url = `https://api.github.com/repos/streetwriters/notesnook/releases/tags/v${tag}`;
const response = await fetch(url, {
- headers: { Accept: "application/json" },
+ headers: { Accept: "application/json" }
});
if (!response.ok) return "No changelog found.";
diff --git a/apps/web/desktop/config/windowstate.js b/apps/web/desktop/config/windowstate.js
index 1565281ad..947182d45 100644
--- a/apps/web/desktop/config/windowstate.js
+++ b/apps/web/desktop/config/windowstate.js
@@ -11,7 +11,7 @@ class WindowState {
storageKey: "windowState",
maximize: true,
fullScreen: true,
- ...options,
+ ...options
};
// Load previous state
@@ -24,7 +24,7 @@ class WindowState {
this.state = {
width: this.config.defaultWidth || 800,
height: this.config.defaultHeight || 600,
- ...this.state,
+ ...this.state
};
}
@@ -53,7 +53,7 @@ class WindowState {
height: this.config.defaultHeight || 600,
x: 0,
y: 0,
- displayBounds,
+ displayBounds
};
}
diff --git a/apps/web/desktop/electron.js b/apps/web/desktop/electron.js
index b86e25b03..b7231c0f3 100644
--- a/apps/web/desktop/electron.js
+++ b/apps/web/desktop/electron.js
@@ -50,8 +50,8 @@ async function createWindow() {
contextIsolation: true,
nativeWindowOpen: true,
spellcheck: false,
- preload: __dirname + "/preload.js",
- },
+ preload: __dirname + "/preload.js"
+ }
});
mainWindowState.manage(mainWindow);
global.win = mainWindow;
@@ -79,7 +79,7 @@ async function createWindow() {
nativeTheme.on("updated", () => {
if (getTheme() === "system") {
sendMessageToRenderer(EVENTS.themeChanged, {
- theme: nativeTheme.shouldUseDarkColors ? "dark" : "light",
+ theme: nativeTheme.shouldUseDarkColors ? "dark" : "light"
});
}
});
diff --git a/apps/web/desktop/events.js b/apps/web/desktop/events.js
index 95b809815..483f5f96d 100644
--- a/apps/web/desktop/events.js
+++ b/apps/web/desktop/events.js
@@ -4,5 +4,5 @@ module.exports.EVENTS = {
updateDownloadProgress: "updateDownloadProgress",
updateDownloadCompleted: "updateDownloadCompleted",
updateNotAvailable: "updateNotAvailable",
- themeChanged: "themeChanged",
+ themeChanged: "themeChanged"
};
diff --git a/apps/web/desktop/ipc/actions/index.js b/apps/web/desktop/ipc/actions/index.js
index 4ccd2da36..c56f13104 100644
--- a/apps/web/desktop/ipc/actions/index.js
+++ b/apps/web/desktop/ipc/actions/index.js
@@ -13,7 +13,7 @@ const actions = {
installUpdate,
open,
saveFile,
- setZoomFactor,
+ setZoomFactor
};
module.exports.getAction = function getAction(actionName) {
diff --git a/apps/web/desktop/ipc/calls/index.js b/apps/web/desktop/ipc/calls/index.js
index 7f67556fb..1450156eb 100644
--- a/apps/web/desktop/ipc/calls/index.js
+++ b/apps/web/desktop/ipc/calls/index.js
@@ -3,7 +3,7 @@ const selectDirectory = require("./selectDirectory");
const calls = {
getZoomFactor,
- selectDirectory,
+ selectDirectory
};
module.exports.getCall = function getAction(callName) {
diff --git a/apps/web/desktop/ipc/calls/selectDirectory.js b/apps/web/desktop/ipc/calls/selectDirectory.js
index 28abeb609..c8f99554a 100644
--- a/apps/web/desktop/ipc/calls/selectDirectory.js
+++ b/apps/web/desktop/ipc/calls/selectDirectory.js
@@ -8,7 +8,7 @@ module.exports = async function (args, win) {
title,
buttonLabel,
properties: ["openDirectory"],
- defaultPath: resolvePath(defaultPath),
+ defaultPath: resolvePath(defaultPath)
});
if (result.canceled) return;
diff --git a/apps/web/desktop/logger.js b/apps/web/desktop/logger.js
index 7c77e17ec..0c353be68 100644
--- a/apps/web/desktop/logger.js
+++ b/apps/web/desktop/logger.js
@@ -9,7 +9,7 @@ enable("native");
const LOG_FILE_PATH = path.join(app.getPath("logs"), "notesnook.log");
const logFileStream = fs.createWriteStream(LOG_FILE_PATH, {
autoClose: true,
- flags: "a",
+ flags: "a"
});
const native = diary("native", (e) => {
@@ -25,7 +25,7 @@ function logFileReporter(e) {
hour12: true,
hour: "2-digit",
minute: "2-digit",
- second: "2-digit",
+ second: "2-digit"
});
const extra = e.extra.map((ex) => JSON.stringify(ex)).join(" ");
let str = `[${time}] | ${e.level} | ${e.message} ${extra}\n`;
diff --git a/apps/web/desktop/menu.js b/apps/web/desktop/menu.js
index f23eaf63e..1ffb12b5a 100644
--- a/apps/web/desktop/menu.js
+++ b/apps/web/desktop/menu.js
@@ -13,7 +13,7 @@ function setupMenu(mainWindow) {
label: "Undo",
role: "undo",
enabled: params.isEditable,
- accelerator: "CommandOrControl+Z",
+ accelerator: "CommandOrControl+Z"
})
);
@@ -22,13 +22,13 @@ function setupMenu(mainWindow) {
label: "Redo",
role: "redo",
enabled: params.isEditable,
- accelerator: "CommandOrControl+Y",
+ accelerator: "CommandOrControl+Y"
})
);
menu.append(
new MenuItem({
- type: "separator",
+ type: "separator"
})
);
}
@@ -39,7 +39,7 @@ function setupMenu(mainWindow) {
label: "Cut",
role: "cut",
enabled: params.selectionText.length > 0,
- accelerator: "CommandOrControl+X",
+ accelerator: "CommandOrControl+X"
})
);
@@ -48,7 +48,7 @@ function setupMenu(mainWindow) {
label: "Copy",
role: "copy",
enabled: params.selectionText.length > 0,
- accelerator: "CommandOrControl+C",
+ accelerator: "CommandOrControl+C"
})
);
@@ -58,7 +58,7 @@ function setupMenu(mainWindow) {
label: "Paste",
role: "pasteAndMatchStyle",
enabled: clipboard.readText("clipboard").length > 0,
- accelerator: "CommandOrControl+V",
+ accelerator: "CommandOrControl+V"
})
);
diff --git a/apps/web/desktop/paths.js b/apps/web/desktop/paths.js
index ec532033a..706293946 100644
--- a/apps/web/desktop/paths.js
+++ b/apps/web/desktop/paths.js
@@ -1,4 +1,4 @@
module.exports.PATHS = {
backupsDirectory: "documents/Notesnook/backups",
- logsDirectory: "logs/",
+ logsDirectory: "logs/"
};
diff --git a/apps/web/desktop/preload.js b/apps/web/desktop/preload.js
index b611c34fb..2d41f68cc 100644
--- a/apps/web/desktop/preload.js
+++ b/apps/web/desktop/preload.js
@@ -19,7 +19,7 @@ contextBridge.exposeInMainWorld("api", {
func(args);
});
}
- },
+ }
});
// Expose protected methods that allow the renderer process to use
@@ -27,9 +27,9 @@ contextBridge.exposeInMainWorld("api", {
contextBridge.exposeInMainWorld("config", {
zoomFactor: () => {
return ipcRenderer.invoke("fromRenderer", {
- type: "getZoomFactor",
+ type: "getZoomFactor"
});
- },
+ }
});
contextBridge.exposeInMainWorld("native", {
@@ -38,7 +38,7 @@ contextBridge.exposeInMainWorld("native", {
type: "selectDirectory",
title,
buttonLabel,
- defaultPath,
+ defaultPath
});
- },
+ }
});
diff --git a/apps/web/desktop/protocol.js b/apps/web/desktop/protocol.js
index 751c1d7e7..ee578dcbf 100644
--- a/apps/web/desktop/protocol.js
+++ b/apps/web/desktop/protocol.js
@@ -15,7 +15,7 @@ const extensionToMimeType = {
js: "application/javascript",
css: "text/css",
svg: "image/svg+xml",
- png: "image/png",
+ png: "image/png"
};
function registerProtocol() {
@@ -45,7 +45,7 @@ function registerProtocol() {
const data = fs.createReadStream(filePath);
callback({
data,
- mimeType: extensionToMimeType[fileExtension],
+ mimeType: extensionToMimeType[fileExtension]
});
} else {
var response;
@@ -56,9 +56,9 @@ function registerProtocol() {
body,
headers: {
...request.headers,
- origin: `${PROTOCOL}://${HOSTNAME}/`,
+ origin: `${PROTOCOL}://${HOSTNAME}/`
},
- redirect: "manual",
+ redirect: "manual"
});
} catch (e) {
console.error(e);
@@ -70,7 +70,7 @@ function registerProtocol() {
statusCode: response.status,
data: response.body,
headers: Object.fromEntries(response.headers.entries()),
- mimeType: response.headers.get("Content-Type"),
+ mimeType: response.headers.get("Content-Type")
});
}
}
diff --git a/apps/web/playwright.config.js b/apps/web/playwright.config.js
index ef94b343f..952c4f82b 100644
--- a/apps/web/playwright.config.js
+++ b/apps/web/playwright.config.js
@@ -4,20 +4,20 @@ const projects = IS_CI
? [
{
name: "Firefox",
- use: { browserName: "firefox" },
+ use: { browserName: "firefox" }
},
{
name: "WebKit",
- use: { browserName: "webkit" },
- },
+ use: { browserName: "webkit" }
+ }
]
: [
{
name: "Chromium",
use: {
- browserName: "chromium",
- },
- },
+ browserName: "chromium"
+ }
+ }
// {
// name: "Firefox",
// use: { browserName: "firefox" },
@@ -33,7 +33,7 @@ module.exports = {
command: "npm run debug",
port: 3000,
timeout: 60 * 1000,
- reuseExistingServer: true, //!IS_CI,
+ reuseExistingServer: true //!IS_CI,
},
// Look for test files in thcleare "tests" directory, relative to this configuration file
testDir: "__e2e__",
@@ -54,12 +54,12 @@ module.exports = {
viewport: {
width: 1280,
- height: 720,
+ height: 720
},
screen: {
width: 1280,
- height: 720,
- },
+ height: 720
+ }
},
- projects,
+ projects
};
diff --git a/apps/web/public/diff.worker.js b/apps/web/public/diff.worker.js
index bea5e1fd8..1f2fec0b3 100644
--- a/apps/web/public/diff.worker.js
+++ b/apps/web/public/diff.worker.js
@@ -106,7 +106,7 @@ function Match(start_in_before, start_in_after, length) {
function return_dual_pane(before, after) {
return {
before: before,
- after: after,
+ after: after
};
}
@@ -163,7 +163,7 @@ function html_to_tokens(html, components_search_rule) {
end: 0,
tagOpen: false,
whitespaceOpen: false,
- ampersandOpen: false,
+ ampersandOpen: false
};
for (var i = 0; i < html.length; ++i) {
const s = html[i];
@@ -428,7 +428,7 @@ function find_matching_blocks(before_tokens, after_tokens) {
var index_of_before_locations_in_after_tokens = create_index({
find_these: before_tokens,
- in_these: after_tokens,
+ in_these: after_tokens
});
return recursively_find_matching_blocks(
@@ -475,7 +475,7 @@ function calculate_operations(before_tokens, after_tokens) {
"false,false": "replace",
"true,false": "insert",
"false,true": "delete",
- "true,true": "none",
+ "true,true": "none"
};
var matches = find_matching_blocks(before_tokens, after_tokens);
matches.push(new Match(before_tokens.length, after_tokens.length, 0));
@@ -490,7 +490,7 @@ function calculate_operations(before_tokens, after_tokens) {
action_map[
[
match_starts_at_current_position_in_before,
- match_starts_at_current_position_in_after,
+ match_starts_at_current_position_in_after
].toString()
];
if (action_up_to_match_positions !== "none") {
@@ -505,7 +505,7 @@ function calculate_operations(before_tokens, after_tokens) {
end_in_after:
action_up_to_match_positions !== "delete"
? match.start_in_after - 1
- : void 0,
+ : void 0
});
}
if (match.length !== 0) {
@@ -514,7 +514,7 @@ function calculate_operations(before_tokens, after_tokens) {
start_in_before: match.start_in_before,
end_in_before: match.end_in_before,
start_in_after: match.start_in_after,
- end_in_after: match.end_in_after,
+ end_in_after: match.end_in_after
});
}
position_in_before = match.end_in_before + 1;
@@ -523,7 +523,7 @@ function calculate_operations(before_tokens, after_tokens) {
var post_processed = [];
var last_op = {
- action: "none",
+ action: "none"
};
function is_single_whitespace(op) {
@@ -649,13 +649,13 @@ var op_map = {
delete: function (op, before_tokens, after_tokens, class_name) {
var val = before_tokens.slice(op.start_in_before, op.end_in_before + 1);
return wrap("del", val, class_name);
- },
+ }
};
op_map.replace = function (op, before_tokens, after_tokens, class_name) {
return [
op_map["delete"](op, before_tokens, after_tokens, class_name),
- op_map.insert(op, before_tokens, after_tokens, class_name),
+ op_map.insert(op, before_tokens, after_tokens, class_name)
];
};
diff --git a/apps/web/scripts/analyze.js b/apps/web/scripts/analyze.js
index 4abcbcd5e..969249969 100644
--- a/apps/web/scripts/analyze.js
+++ b/apps/web/scripts/analyze.js
@@ -1,8 +1,8 @@
process.env.NODE_ENV = "production";
const webpack = require("webpack");
-const BundleAnalyzerPlugin = require("webpack-bundle-analyzer")
- .BundleAnalyzerPlugin;
+const BundleAnalyzerPlugin =
+ require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
const webpackConfigProd = require("react-scripts/config/webpack.config")(
"production"
);
@@ -25,7 +25,7 @@ webpackConfigProd.plugins.push(
new ProgressBarPlugin({
format: `${green("analyzing...")} ${green("[:bar]")}${green(
"[:percent]"
- )}${green("[:elapsed seconds]")} - :msg`,
+ )}${green("[:elapsed seconds]")} - :msg`
})
);
diff --git a/apps/web/src/app-effects.js b/apps/web/src/app-effects.js
index 4c5a54df1..14c58fb09 100644
--- a/apps/web/src/app-effects.js
+++ b/apps/web/src/app-effects.js
@@ -18,7 +18,7 @@ import {
showBuyDialog,
showFeatureDialog,
showInvalidSystemTimeDialog,
- showOnboardingDialog,
+ showOnboardingDialog
} from "./common/dialog-controller";
import useSystemTheme from "./hooks/use-system-theme";
import { isTesting } from "./utils/platform";
@@ -101,7 +101,7 @@ export default function AppEffects({ setShow }) {
initUser,
initNotes,
addReminder,
- setIsVaultCreated,
+ setIsVaultCreated
]
);
@@ -124,7 +124,7 @@ export default function AppEffects({ setShow }) {
updateStatus({
key,
status: `${status} attachments (${current}/${total})`,
- progress: 0,
+ progress: 0
});
}
}
@@ -145,7 +145,7 @@ export default function AppEffects({ setShow }) {
updateStatus({
key,
status: text,
- progress: loaded === total ? 100 : percent,
+ progress: loaded === total ? 100 : percent
});
}
}
diff --git a/apps/web/src/app-effects.mobile.js b/apps/web/src/app-effects.mobile.js
index 314ad4812..7f4b0da21 100644
--- a/apps/web/src/app-effects.mobile.js
+++ b/apps/web/src/app-effects.mobile.js
@@ -34,7 +34,7 @@ export default function MobileAppEffects({ sliderId, overlayId, setShow }) {
toggleSideMenu(slide?.index === 0 ? true : false);
console.log("Setting editor", slide?.index === 2 ? true : false);
setIsEditorOpen(slide?.index === 2 ? true : false);
- },
+ }
});
useEffect(() => {
diff --git a/apps/web/src/app.js b/apps/web/src/app.js
index fecedc177..0cae2b2e2 100644
--- a/apps/web/src/app.js
+++ b/apps/web/src/app.js
@@ -106,7 +106,7 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
<Flex
variant="rowFill"
sx={{
- overflow: "hidden",
+ overflow: "hidden"
}}
>
<Allotment
@@ -131,7 +131,7 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
toggleNavigationContainer: (state) => {
setShow(state || !show);
},
- isTablet: isNarrow,
+ isTablet: isNarrow
}}
fallback={<NavigationLoader />}
/>
@@ -156,7 +156,7 @@ function DesktopAppContents({ isAppLoaded, show, setShow }) {
<Flex
sx={{
overflow: "hidden",
- flex: 1,
+ flex: 1
}}
flexDirection="column"
>
@@ -191,7 +191,7 @@ function MobileAppContents({ isAppLoaded }) {
scrollBehavior: "smooth",
WebkitOverflowScrolling: "touch",
scrollSnapStop: "always",
- overscrollBehavior: "contain",
+ overscrollBehavior: "contain"
}}
>
<Flex
@@ -199,14 +199,14 @@ function MobileAppContents({ isAppLoaded }) {
sx={{
scrollSnapAlign: "start",
scrollSnapStop: "always",
- width: [300, 60],
+ width: [300, 60]
}}
>
<SuspenseLoader
condition={isAppLoaded}
component={NavigationMenu}
props={{
- toggleNavigationContainer: () => {},
+ toggleNavigationContainer: () => {}
}}
fallback={<NavigationLoader />}
/>
@@ -218,7 +218,7 @@ function MobileAppContents({ isAppLoaded }) {
sx={{
position: "relative",
scrollSnapAlign: "start",
- scrollSnapStop: "always",
+ scrollSnapStop: "always"
}}
flexShrink={0}
>
@@ -238,7 +238,7 @@ function MobileAppContents({ isAppLoaded }) {
zIndex: 999,
opacity: 0,
visibility: "visible",
- pointerEvents: "none",
+ pointerEvents: "none"
}}
bg="black"
/>
@@ -248,7 +248,7 @@ function MobileAppContents({ isAppLoaded }) {
flexShrink={0}
sx={{
scrollSnapAlign: "start",
- scrollSnapStop: "always",
+ scrollSnapStop: "always"
}}
flexDirection="column"
>
diff --git a/apps/web/src/commands/check-for-update.js b/apps/web/src/commands/check-for-update.js
index 87262b4d1..ec3b46464 100644
--- a/apps/web/src/commands/check-for-update.js
+++ b/apps/web/src/commands/check-for-update.js
@@ -23,7 +23,7 @@ export default async function checkForUpdate() {
}
AppEventManager.publish(EVENTS.updateDownloadCompleted, {
- version: workerVersion.formatted,
+ version: workerVersion.formatted
});
return;
}
diff --git a/apps/web/src/commands/index.js b/apps/web/src/commands/index.js
index 76b5da240..a7158170a 100644
--- a/apps/web/src/commands/index.js
+++ b/apps/web/src/commands/index.js
@@ -6,7 +6,7 @@ export function invokeCommand(type, payload = {}) {
window.api.send("fromRenderer", {
type,
- ...payload,
+ ...payload
});
}
diff --git a/apps/web/src/common/app-events.js b/apps/web/src/common/app-events.js
index 91b914037..8febbb810 100644
--- a/apps/web/src/common/app-events.js
+++ b/apps/web/src/common/app-events.js
@@ -4,5 +4,5 @@ export const AppEventManager = new EventManager();
export const AppEvents = {
UPDATE_ATTACHMENT_PROGRESS: "updateAttachmentProgress",
UPDATE_STATUS: "updateStatus",
- REMOVE_STATUS: "removeStatus",
+ REMOVE_STATUS: "removeStatus"
};
diff --git a/apps/web/src/common/attachments.js b/apps/web/src/common/attachments.js
index 707e28ef5..7922d1efa 100644
--- a/apps/web/src/common/attachments.js
+++ b/apps/web/src/common/attachments.js
@@ -20,7 +20,7 @@ export async function downloadAttachment(hash) {
iv: attachment.iv,
name: attachment.metadata.filename,
type: attachment.metadata.type,
- isUploaded: !!attachment.dateUploaded,
+ isUploaded: !!attachment.dateUploaded
});
}
diff --git a/apps/web/src/common/constants.ts b/apps/web/src/common/constants.ts
index 987d0c8e1..0e4ff9924 100644
--- a/apps/web/src/common/constants.ts
+++ b/apps/web/src/common/constants.ts
@@ -5,7 +5,7 @@ export const COLORS = [
"green",
"blue",
"purple",
- "gray",
+ "gray"
] as const;
export const SUBSCRIPTION_STATUS = {
@@ -14,5 +14,5 @@ export const SUBSCRIPTION_STATUS = {
BETA: 2,
PREMIUM: 5,
PREMIUM_EXPIRED: 6,
- PREMIUM_CANCELED: 7,
+ PREMIUM_CANCELED: 7
} as const;
diff --git a/apps/web/src/common/db.js b/apps/web/src/common/db.js
index c5299b132..99cf5f092 100644
--- a/apps/web/src/common/db.js
+++ b/apps/web/src/common/db.js
@@ -19,7 +19,7 @@ async function initializeDatabase(persistence) {
db.host({
API_HOST: "https://api.notesnook.com",
AUTH_HOST: "https://auth.streetwriters.co",
- SSE_HOST: "https://events.streetwriters.co",
+ SSE_HOST: "https://events.streetwriters.co"
});
// } else {
// db.host({
diff --git a/apps/web/src/common/dialog-controller.tsx b/apps/web/src/common/dialog-controller.tsx
index cfe8a05e5..56f9cb275 100644
--- a/apps/web/src/common/dialog-controller.tsx
+++ b/apps/web/src/common/dialog-controller.tsx
@@ -198,7 +198,7 @@ export function showMultiDeleteConfirmation(length: number) {
</Text>
),
yesText: `Delete selected`,
- noText: "Cancel",
+ noText: "Cancel"
});
}
@@ -216,7 +216,7 @@ export function showMultiPermanentDeleteConfirmation(length: number) {
</Text>
),
yesText: `Permanently delete selected`,
- noText: "Cancel",
+ noText: "Cancel"
});
}
@@ -226,7 +226,7 @@ export function showLogoutConfirmation() {
message:
"Logging out will delete all local data and reset the app. Make sure you have synced your data before logging out.",
yesText: `Yes`,
- noText: "No",
+ noText: "No"
});
}
@@ -236,7 +236,7 @@ export function showClearSessionsConfirmation() {
message:
"All other logged-in devices will be forced to logout stopping sync. Use with care lest you lose important notes.",
yesText: `Yes`,
- noText: "No",
+ noText: "No"
});
}
@@ -246,7 +246,7 @@ export function showAccountLoggedOutNotice(reason?: string) {
message: reason,
noText: "Okay",
yesText: `Relogin`,
- yesAction: () => hardNavigate("/login"),
+ yesAction: () => hardNavigate("/login")
});
}
@@ -274,7 +274,7 @@ export function showAppUpdatedNotice(
</Text>
</Flex>
),
- yesText: `Yay!`,
+ yesText: `Yay!`
});
}
@@ -341,14 +341,14 @@ function getDialogData(type: string) {
return {
title: "Create your vault",
subtitle: "A vault stores your notes in a password-encrypted storage.",
- positiveButtonText: "Create vault",
+ positiveButtonText: "Create vault"
};
case "clear_vault":
return {
title: "Clear your vault",
subtitle:
"Enter vault password to unlock and remove all notes from the vault.",
- positiveButtonText: "Clear vault",
+ positiveButtonText: "Clear vault"
};
case "delete_vault":
return {
@@ -356,46 +356,46 @@ function getDialogData(type: string) {
subtitle: "Enter your account password to delete your vault.",
positiveButtonText: "Delete vault",
checks: [
- { key: "deleteAllLockedNotes", title: "Delete all locked notes?" },
- ],
+ { key: "deleteAllLockedNotes", title: "Delete all locked notes?" }
+ ]
};
case "lock_note":
return {
title: "Lock note",
subtitle: "Please open your vault to encrypt & lock this note.",
- positiveButtonText: "Lock note",
+ positiveButtonText: "Lock note"
};
case "unlock_note":
return {
title: "Unlock note",
subtitle: "Your note will be unencrypted and removed from the vault.",
- positiveButtonText: "Unlock note",
+ positiveButtonText: "Unlock note"
};
case "unlock_and_delete_note":
return {
title: "Delete note",
subtitle: "Please unlock this note to move it to trash.",
- positiveButtonText: "Unlock & delete",
+ positiveButtonText: "Unlock & delete"
};
case "change_password":
return {
title: "Change vault password",
subtitle:
"All locked notes will be re-encrypted with the new password.",
- positiveButtonText: "Change password",
+ positiveButtonText: "Change password"
};
case "ask_vault_password":
return {
title: "Unlock vault",
subtitle: "Please enter your vault password to continue.",
- positiveButtonText: "Unlock",
+ positiveButtonText: "Unlock"
};
case "ask_backup_password":
return {
title: "Encrypted backup",
subtitle:
"Please enter the password to decrypt and restore this backup.",
- positiveButtonText: "Restore",
+ positiveButtonText: "Restore"
};
case "change_account_password":
return {
@@ -417,13 +417,13 @@ function getDialogData(type: string) {
</Box>
</>
),
- positiveButtonText: "Change password",
+ positiveButtonText: "Change password"
};
case "verify_account":
return {
title: "Verify it's you",
subtitle: "Enter your account password to proceed.",
- positiveButtonText: "Verify",
+ positiveButtonText: "Verify"
};
case "delete_account":
return {
@@ -434,7 +434,7 @@ function getDialogData(type: string) {
<b>no way of recovery</b>. Proceed with caution.
</Text>
),
- positiveButtonText: "Delete Account",
+ positiveButtonText: "Delete Account"
};
default:
return {};
@@ -665,7 +665,7 @@ export function showOnboardingDialog(type: string) {
export function showInvalidSystemTimeDialog({
serverTime,
- localTime,
+ localTime
}: {
serverTime: number;
localTime: number;
@@ -687,13 +687,13 @@ export function showInvalidSystemTimeDialog({
</>
),
yesText: "Reload app",
- yesAction: () => window.location.reload(),
+ yesAction: () => window.location.reload()
});
}
export function showUpdateAvailableNotice({
changelog,
- version,
+ version
}: {
changelog: string;
version: string;
@@ -702,7 +702,7 @@ export function showUpdateAvailableNotice({
title: `New version available`,
subtitle: `v${version} is available for download`,
changelog,
- action: { text: `Update now`, onClick: () => downloadUpdate() },
+ action: { text: `Update now`, onClick: () => downloadUpdate() }
});
}
@@ -714,8 +714,8 @@ export async function showUpdateReadyNotice({ version }: { version: string }) {
changelog,
action: {
text: "Install now",
- onClick: () => installUpdate(),
- },
+ onClick: () => installUpdate()
+ }
});
}
@@ -732,7 +732,7 @@ function showUpdateDialog({
title,
subtitle,
changelog,
- action,
+ action
}: UpdateDialogProps) {
return confirm({
title,
@@ -760,6 +760,6 @@ function showUpdateDialog({
),
width: "500px",
yesText: action.text,
- yesAction: action.onClick,
+ yesAction: action.onClick
});
}
diff --git a/apps/web/src/common/export.ts b/apps/web/src/common/export.ts
index 1268a5bb6..ef76cf8d5 100644
--- a/apps/web/src/common/export.ts
+++ b/apps/web/src/common/export.ts
@@ -19,7 +19,7 @@ export async function exportToPDF(
onPrintDialogClose: () => {
resolve(false);
},
- onError: () => resolve(false),
+ onError: () => resolve(false)
});
resolve(true);
});
@@ -46,7 +46,7 @@ export async function exportNotes(
report({
current: ++index,
total: noteIds.length,
- text: `Exporting "${note.title}"...`,
+ text: `Exporting "${note.title}"...`
});
console.log("Exporting", note.title);
const content: string = await note.export(format, null).catch((e) => {
@@ -67,6 +67,6 @@ export async function exportNotes(
saveAs(new Blob([zipped.buffer]), "notes.zip");
}
return true;
- },
+ }
});
}
diff --git a/apps/web/src/common/height-calculator.js b/apps/web/src/common/height-calculator.js
index 0d2a223e2..4bf41bec1 100644
--- a/apps/web/src/common/height-calculator.js
+++ b/apps/web/src/common/height-calculator.js
@@ -4,7 +4,7 @@ const DEFAULT_FONT_SIZE = document.getElementById("p").clientHeight - 1;
const MAX_HEIGHTS = {
note: SINGLE_LINE_HEIGHT * 7 * DEFAULT_FONT_SIZE,
notebook: SINGLE_LINE_HEIGHT * 7 * DEFAULT_FONT_SIZE,
- generic: SINGLE_LINE_HEIGHT * 4 * DEFAULT_FONT_SIZE,
+ generic: SINGLE_LINE_HEIGHT * 4 * DEFAULT_FONT_SIZE
};
function getNoteHeight(item) {
diff --git a/apps/web/src/common/index.js b/apps/web/src/common/index.js
index 84cea7104..f05ecb7b6 100644
--- a/apps/web/src/common/index.js
+++ b/apps/web/src/common/index.js
@@ -2,7 +2,7 @@ import {
showFeatureDialog,
showLoadingDialog,
showPasswordDialog,
- showReminderDialog,
+ showReminderDialog
} from "../common/dialog-controller";
import Config from "../utils/config";
import { hashNavigate, getCurrentHash } from "../navigation";
@@ -20,20 +20,20 @@ export const CREATE_BUTTON_MAP = {
notes: {
title: "Make a note",
onClick: () =>
- hashNavigate("/notes/create", { addNonce: true, replace: true }),
+ hashNavigate("/notes/create", { addNonce: true, replace: true })
},
notebooks: {
title: "Create a notebook",
- onClick: () => hashNavigate("/notebooks/create"),
+ onClick: () => hashNavigate("/notebooks/create")
},
topics: {
title: "Create a topic",
- onClick: () => hashNavigate(`/topics/create`),
+ onClick: () => hashNavigate(`/topics/create`)
},
tags: {
title: "Create a tag",
- onClick: () => hashNavigate(`/tags/create`),
- },
+ onClick: () => hashNavigate(`/tags/create`)
+ }
};
export async function introduceFeatures() {
@@ -56,7 +56,7 @@ export async function createBackup(save = true) {
subtitle: "We are creating a backup of your data. Please wait...",
action: async () => {
return await db.backup.export("web", encryptBackups);
- },
+ }
});
if (!data) {
showToast("error", "Could not create a backup of your data.");
@@ -77,7 +77,7 @@ export async function createBackup(save = true) {
export async function selectBackupFile() {
const file = await showFilePicker({
- acceptedFileTypes: ".nnbackup,application/json",
+ acceptedFileTypes: ".nnbackup,application/json"
});
if (!file) return;
@@ -117,7 +117,7 @@ export async function restoreBackupFile(backup) {
title: "Restoring backup",
subtitle:
"Please do NOT close your browser or shut down your PC until the process completes.",
- action: () => restore(backup),
+ action: () => restore(backup)
});
}
}
diff --git a/apps/web/src/common/key-map.js b/apps/web/src/common/key-map.js
index 5b2f3b9bd..26a78de8f 100644
--- a/apps/web/src/common/key-map.js
+++ b/apps/web/src/common/key-map.js
@@ -43,8 +43,8 @@ const KEYMAP = [
e.preventDefault();
navigate("/search/notes");
- },
- },
+ }
+ }
// {
// keys: ["alt+n"],
// description: "Go to Notes",
diff --git a/apps/web/src/common/list-profiles.js b/apps/web/src/common/list-profiles.js
index 9397b7944..ae493b12a 100644
--- a/apps/web/src/common/list-profiles.js
+++ b/apps/web/src/common/list-profiles.js
@@ -8,7 +8,7 @@ import {
getItemHeight,
getNotebookHeight,
getNoteHeight,
- MAX_HEIGHTS,
+ MAX_HEIGHTS
} from "./height-calculator";
import { db } from "./db";
import { getTotalNotes } from ".";
@@ -89,7 +89,7 @@ const Profiles = {
tags: TagsProfile,
topics: TopicsProfile,
trash: TrashProfile,
- attachments: AttachmentProfile,
+ attachments: AttachmentProfile
};
export default Profiles;
@@ -121,7 +121,7 @@ function getNotebook(notebooks, contextType) {
id: notebook.id,
title: notebook.title,
dateEdited: notebook.dateEdited,
- topic: { id: topicId, title: topic.title },
+ topic: { id: topicId, title: topic.title }
};
}
diff --git a/apps/web/src/common/multi-select.ts b/apps/web/src/common/multi-select.ts
index efb769d91..2e0a7a182 100644
--- a/apps/web/src/common/multi-select.ts
+++ b/apps/web/src/common/multi-select.ts
@@ -31,10 +31,10 @@ async function moveNotesToTrash(notes: any[], confirm = true) {
id: "deleteNotes",
action: async (report) => {
report({
- text: `Deleting ${items.length} notes...`,
+ text: `Deleting ${items.length} notes...`
});
await noteStore.delete(...items);
- },
+ }
});
showToast("success", `${items.length} notes moved to trash`);
@@ -54,10 +54,10 @@ async function moveNotebooksToTrash(notebooks: any[]) {
id: "deleteNotebooks",
action: async (report) => {
report({
- text: `Deleting ${notebooks.length} notebooks...`,
+ text: `Deleting ${notebooks.length} notebooks...`
});
await notebookStore.delete(...notebooks.map((i) => i.id));
- },
+ }
});
if (isMultiselect) {
@@ -73,13 +73,13 @@ async function deleteTopics(notebookId: string, topics: any[]) {
id: "deleteTopics",
action: async (report) => {
report({
- text: `Deleting ${topics.length} topics...`,
+ text: `Deleting ${topics.length} topics...`
});
await db
.notebooks!.notebook(notebookId)
.topics.delete(...topics.map((t) => t.id));
notebookStore.setSelectedNotebook(notebookId);
- },
+ }
});
showToast("success", `${topics.length} topics deleted`);
}
@@ -101,11 +101,11 @@ async function deleteAttachments(attachments: any[]) {
report({
text: `Deleting ${attachments.length} attachments...`,
current: i,
- total: attachments.length,
+ total: attachments.length
});
await attachmentStore.permanentDelete(attachment.metadata.hash);
}
- },
+ }
});
showToast("success", `${attachments.length} attachments deleted`);
}
@@ -114,5 +114,5 @@ export const Multiselect = {
moveNotebooksToTrash,
moveNotesToTrash,
deleteTopics,
- deleteAttachments,
+ deleteAttachments
};
diff --git a/apps/web/src/common/reminders.js b/apps/web/src/common/reminders.js
index 30c93b552..ca9b76307 100644
--- a/apps/web/src/common/reminders.js
+++ b/apps/web/src/common/reminders.js
@@ -6,7 +6,7 @@ import * as Icon from "../components/icons";
import dayjs from "dayjs";
import {
showBackupDialog,
- showRecoveryKeyDialog,
+ showRecoveryKeyDialog
} from "../common/dialog-controller";
import { hardNavigate, hashNavigate } from "../navigation";
import { isDesktop, isTesting } from "../utils/platform";
@@ -60,21 +60,21 @@ export const Reminders = {
action: async () => {
if (await verifyAccount()) await createBackup();
},
- icon: Icon.Backup,
+ icon: Icon.Backup
},
login: {
key: "login",
title: "Login to sync your notes",
subtitle: "You are not logged in",
action: () => hardNavigate("/login"),
- icon: Icon.User,
+ icon: Icon.User
},
email: {
key: "email",
title: "Your email is not confirmed",
subtitle: "Please confirm your email to sync your notes",
action: () => hashNavigate("/email/verify"),
- icon: Icon.Email,
+ icon: Icon.Email
},
recoverykey: {
key: "recoverykey",
@@ -84,8 +84,8 @@ export const Reminders = {
action: async () => {
if (await verifyAccount()) await showRecoveryKeyDialog();
},
- icon: Icon.Warn,
- },
+ icon: Icon.Warn
+ }
};
var openedToast = null;
@@ -115,13 +115,13 @@ export async function resetReminders() {
openedToast?.hide();
openedToast = null;
},
- type: "text",
+ type: "text"
},
{
text: "Download",
onClick: () => createBackup(true),
- type: "primary",
- },
+ type: "primary"
+ }
],
0
);
diff --git a/apps/web/src/common/task-manager.ts b/apps/web/src/common/task-manager.ts
index a00dfa336..b3b405b82 100644
--- a/apps/web/src/common/task-manager.ts
+++ b/apps/web/src/common/task-manager.ts
@@ -49,7 +49,7 @@ export class TaskManager {
key: statusTask.id,
status: progress.text,
progress: percentage,
- icon: null,
+ icon: null
});
});
removeStatus(statusTask.id);
@@ -58,7 +58,7 @@ export class TaskManager {
return await showProgressDialog<T>({
title: task.title,
subtitle: task.subtitle,
- action: task.action,
+ action: task.action
});
}
}
diff --git a/apps/web/src/common/toolbar-config.ts b/apps/web/src/common/toolbar-config.ts
index 16bd10045..45322f131 100644
--- a/apps/web/src/common/toolbar-config.ts
+++ b/apps/web/src/common/toolbar-config.ts
@@ -1,6 +1,6 @@
import {
getDefaultPresets,
- ToolbarGroupDefinition,
+ ToolbarGroupDefinition
} from "@streetwriters/editor";
import { db } from "./db";
@@ -17,9 +17,9 @@ const presets: Record<PresetId, Preset> = {
minimal: {
id: "minimal",
title: "Minimal",
- tools: defaultPresets.minimal,
+ tools: defaultPresets.minimal
},
- custom: { id: "custom", title: "Custom", tools: [], editable: true },
+ custom: { id: "custom", title: "Custom", tools: [], editable: true }
};
export function getCurrentPreset() {
diff --git a/apps/web/src/components/accent-item/index.js b/apps/web/src/components/accent-item/index.js
index a154d78fb..13bafaca8 100644
--- a/apps/web/src/components/accent-item/index.js
+++ b/apps/web/src/components/accent-item/index.js
@@ -27,7 +27,7 @@ function AccentItem(props) {
sx={{
position: "absolute",
zIndex: 1,
- cursor: "pointer",
+ cursor: "pointer"
}}
color="static"
size={20}
diff --git a/apps/web/src/components/accordion/index.js b/apps/web/src/components/accordion/index.js
index 521f58371..8b60c5087 100644
--- a/apps/web/src/components/accordion/index.js
+++ b/apps/web/src/components/accordion/index.js
@@ -26,7 +26,7 @@ export default function Accordion({
cursor: "pointer",
bg: "bgSecondary",
p: 1,
- borderRadius: "default",
+ borderRadius: "default"
}}
onClick={() => {
setIsContentHidden((state) => !state);
diff --git a/apps/web/src/components/announcements/body.js b/apps/web/src/components/announcements/body.js
index 1034ae816..494ff29bd 100644
--- a/apps/web/src/components/announcements/body.js
+++ b/apps/web/src/components/announcements/body.js
@@ -3,12 +3,12 @@ import {
Button,
Flex,
Image as RebassImage,
- Text as RebassText,
+ Text as RebassText
} from "rebass";
import { allowedPlatforms } from "../../hooks/use-announcements";
import {
closeOpenedDialog,
- showBuyDialog,
+ showBuyDialog
} from "../../common/dialog-controller";
import { ANALYTICS_EVENTS, trackEvent } from "../../utils/analytics";
import * as Icon from "../icons";
@@ -26,13 +26,13 @@ const features = [
{ icon: Icon.Backup, title: "Encrypted backups" },
{ icon: Icon.Vault, title: "Secure private vault" },
{ icon: Icon.PDF, title: "Export to PDF" },
- { icon: Icon.Edit, title: "Rich text editor" },
+ { icon: Icon.Edit, title: "Rich text editor" }
];
export default function AnnouncementBody({
removeAnnouncement,
components,
- type,
+ type
}) {
return components
.filter((item) =>
@@ -58,7 +58,7 @@ export default function AnnouncementBody({
<Description
item={{
...item,
- style: { ...item.style, textAlign: "left", marginTop: 1 },
+ style: { ...item.style, textAlign: "left", marginTop: 1 }
}}
fontSize="body"
color="icon"
@@ -125,7 +125,7 @@ function Image({ item }) {
maxHeight="150px"
sx={{
objectFit: "cover",
- ...mapStyle(style),
+ ...mapStyle(style)
}}
/>
);
@@ -220,8 +220,8 @@ function CalltoActions({ item, removeAnnouncement }) {
}
sx={{
":first-of-type": {
- mr: 1,
- },
+ mr: 1
+ }
}}
removeAnnouncement={removeAnnouncement}
/>
@@ -253,8 +253,8 @@ function InlineCalltoActions({ item }) {
color: index === 0 ? "primary" : "fontTertiary",
fontWeight: "bold",
":first-of-type": {
- mr: 1,
- },
+ mr: 1
+ }
}}
/>
))}
@@ -308,7 +308,7 @@ export function Features({ item }) {
columnGap: 1,
rowGap: 1,
mx: HORIZONTAL_MARGIN,
- ...mapStyle(style),
+ ...mapStyle(style)
}}
>
{features.map((feature) => (
@@ -317,7 +317,7 @@ export function Features({ item }) {
p={1}
sx={{
borderRadius: "default",
- border: "1px solid var(--border)",
+ border: "1px solid var(--border)"
}}
>
<feature.icon size={16} sx={{ alignSelf: "start" }} />
@@ -334,6 +334,6 @@ function mapStyle(style) {
return {
mt: margins[style.marginTop],
mb: margins[style.marginBottom],
- textAlign: style.textAlign,
+ textAlign: style.textAlign
};
}
diff --git a/apps/web/src/components/announcements/index.js b/apps/web/src/components/announcements/index.js
index 51c9f10e1..a3a4d3396 100644
--- a/apps/web/src/components/announcements/index.js
+++ b/apps/web/src/components/announcements/index.js
@@ -25,7 +25,7 @@ function Announcements({ announcements, removeAnnouncement }) {
top: 2,
borderRadius: 50,
cursor: "pointer",
- alignSelf: "end",
+ alignSelf: "end"
}}
title="Dismiss announcement"
onClick={() => {
diff --git a/apps/web/src/components/attachment/index.js b/apps/web/src/components/attachment/index.js
index befe73b35..899614781 100644
--- a/apps/web/src/components/attachment/index.js
+++ b/apps/web/src/components/attachment/index.js
@@ -10,14 +10,14 @@ import { Multiselect } from "../../common/multi-select";
import {
closeOpenedDialog,
showAttachmentsDialog,
- showPromptDialog,
+ showPromptDialog
} from "../../common/dialog-controller";
import { hashNavigate } from "../../navigation";
import { showToast } from "../../utils/toast";
const workStatusMap = {
recheck: "Rechecking...",
- delete: "Deleting...",
+ delete: "Deleting..."
};
function Attachment({ item, isCompact, index }) {
const attachment = item;
@@ -34,7 +34,7 @@ function Attachment({ item, isCompact, index }) {
}
menu={{
items: menuItems,
- extraData: { attachment },
+ extraData: { attachment }
}}
onClick={() => {
if (isCompact) showAttachmentsDialog();
@@ -45,7 +45,7 @@ function Attachment({ item, isCompact, index }) {
alignItems="center"
sx={{
fontSize: "subBody",
- color: "fontTertiary",
+ color: "fontTertiary"
}}
>
{status ? (
@@ -106,7 +106,7 @@ function Attachment({ item, isCompact, index }) {
my: 1,
bg: "primary",
height: "2px",
- width: `${status.progress}%`,
+ width: `${status.progress}%`
}}
/>
</Flex>
@@ -115,7 +115,7 @@ function Attachment({ item, isCompact, index }) {
alignItems="center"
sx={{
fontSize: "subBody",
- color: "fontTertiary",
+ color: "fontTertiary"
}}
>
<Text mr={1}>{formatBytes(attachment.length)}</Text>
@@ -150,7 +150,7 @@ const menuItems = [
prev.push({
key: curr,
title: `Note with id ${curr}`,
- onClick: () => showToast("error", "This note does not exist."),
+ onClick: () => showToast("error", "This note does not exist.")
});
else
prev.push({
@@ -159,10 +159,10 @@ const menuItems = [
onClick: () => {
hashNavigate(`/notes/${curr}/edit`);
closeOpenedDialog();
- },
+ }
});
return prev;
- }, []),
+ }, [])
},
{
key: "recheck",
@@ -173,7 +173,7 @@ const menuItems = [
onClick: async ({ items }) => {
await store.recheck(items.map((i) => i.metadata.hash));
},
- multiSelect: true,
+ multiSelect: true
},
{
key: "rename",
@@ -183,11 +183,11 @@ const menuItems = [
const newName = await showPromptDialog({
title: "Rename attachment",
description: attachment.metadata.filename,
- defaultValue: attachment.metadata.filename,
+ defaultValue: attachment.metadata.filename
});
if (!newName) return;
await store.rename(attachment.metadata.hash, newName);
- },
+ }
},
{
key: "download",
@@ -201,7 +201,7 @@ const menuItems = [
if (isDownloading) {
await db.fs.cancel(attachment.metadata.hash, "download");
} else await downloadAttachment(attachment.metadata.hash);
- },
+ }
},
{
key: "reupload",
@@ -217,7 +217,7 @@ const menuItems = [
attachment.metadata.type,
attachment.metadata.hash
);
- },
+ }
},
{
key: "permanent-delete",
@@ -226,6 +226,6 @@ const menuItems = [
title: () => "Delete permanently",
icon: Icon.DeleteForver,
onClick: ({ items }) => Multiselect.deleteAttachments(items),
- multiSelect: true,
- },
+ multiSelect: true
+ }
];
diff --git a/apps/web/src/components/auth-container/index.js b/apps/web/src/components/auth-container/index.js
index 3188291ed..714a5dcf2 100644
--- a/apps/web/src/components/auth-container/index.js
+++ b/apps/web/src/components/auth-container/index.js
@@ -16,29 +16,29 @@ const testimonials = [
image: Grberk,
name: "Glenn Berkshier",
link: "https://twitter.com/grberk/status/1438955961490751489",
- text: "Are you looking for an alternative to @evernote, or just looking for a more secure note taking platform? Take a look at @notesnook and see if it will fit your needs.",
+ text: "Are you looking for an alternative to @evernote, or just looking for a more secure note taking platform? Take a look at @notesnook and see if it will fit your needs."
},
{
username: "HolensteinDan",
image: Holenstein,
name: "Dan Holenstein",
link: "https://twitter.com/HolensteinDan/status/1439728355935342592",
- text: "@notesnook app is what @evernote should have become long ago. And they're still improving.",
+ text: "@notesnook app is what @evernote should have become long ago. And they're still improving."
},
{
username: "jasonbereklewis",
image: Jason,
name: "Jason Berek-Lewis",
link: "https://twitter.com/jasonbereklewis/status/1438635808727044098",
- text: "I work in content writing and communications. My day starts and ends in Notesnook. My Chrome app is always open; it's where I take all my notes. The clean design, focus mode, the tagging and color coding are all features that help keep my work organised every day.",
+ text: "I work in content writing and communications. My day starts and ends in Notesnook. My Chrome app is always open; it's where I take all my notes. The clean design, focus mode, the tagging and color coding are all features that help keep my work organised every day."
},
{
username: "camflint",
image: Cameron,
name: "Cameron Flint",
link: "https://twitter.com/camflint/status/1481061416434286592",
- text: "I'm pretty impressed at the progress @notesnook are making on their app — particularly in respect to how performant the app runs and behaves, despite the overhead of end-to-end encrypting user data.",
- },
+ text: "I'm pretty impressed at the progress @notesnook are making on their app — particularly in respect to how performant the app runs and behaves, despite the overhead of end-to-end encrypting user data."
+ }
];
const titles = [
@@ -46,7 +46,7 @@ const titles = [
"Privacy comes first.",
"Take notes privately.",
"Encrypted, private, secure.",
- "❤️ = 🔒 + 🗒️",
+ "❤️ = 🔒 + 🗒️"
];
function randomTestimonial() {
@@ -71,7 +71,7 @@ function AuthContainer(props) {
position: "relative",
overflow: "hidden",
flexDirection: "column",
- display: ["none", "none", "flex"],
+ display: ["none", "none", "flex"]
}}
>
<Box
@@ -83,7 +83,7 @@ function AuthContainer(props) {
position: "absolute",
top: -100,
left: 0,
- height: "100%",
+ height: "100%"
// opacity: 0.7,
}}
>
@@ -174,7 +174,7 @@ function AuthContainer(props) {
<Flex
flex={1.5}
sx={{
- position: "relative",
+ position: "relative"
}}
flexDirection="column"
>
@@ -190,7 +190,7 @@ function AuthContainer(props) {
right: 0,
bottom: 0,
width: "130%",
- height: "100%",
+ height: "100%"
}}
>
<path
diff --git a/apps/web/src/components/cached-router/index.js b/apps/web/src/components/cached-router/index.js
index f60a14ee5..3a287e557 100644
--- a/apps/web/src/components/cached-router/index.js
+++ b/apps/web/src/components/cached-router/index.js
@@ -12,8 +12,8 @@ function CachedRouter() {
const [RouteResult, location] = useRoutes(routes, {
fallbackRoute: getHomeRoute(),
hooks: {
- beforeNavigate: () => selectionStore.toggleSelectionMode(false),
- },
+ beforeNavigate: () => selectionStore.toggleSelectionMode(false)
+ }
});
useEffect(() => {
diff --git a/apps/web/src/components/dialogs/add-notebook-dialog.js b/apps/web/src/components/dialogs/add-notebook-dialog.js
index 475163784..585f68513 100644
--- a/apps/web/src/components/dialogs/add-notebook-dialog.js
+++ b/apps/web/src/components/dialogs/add-notebook-dialog.js
@@ -14,7 +14,7 @@ class AddNotebookDialog extends React.Component {
state = {
topics: [],
isEditting: false,
- editIndex: -1,
+ editIndex: -1
};
removeTopic(index) {
@@ -25,7 +25,7 @@ class AddNotebookDialog extends React.Component {
}
topics.splice(index, 1);
this.setState({
- topics,
+ topics
});
}
@@ -35,7 +35,7 @@ class AddNotebookDialog extends React.Component {
const topics = this.state.topics.slice();
topics.push({ title: topicTitle });
this.setState({
- topics,
+ topics
});
this.resetTopicInput();
}
@@ -66,7 +66,7 @@ class AddNotebookDialog extends React.Component {
if (!this.props.notebook) return;
const { title, description, id, topics } = qclone(this.props.notebook);
this.setState({
- topics,
+ topics
});
this.title = title;
this.notebookTitle = title;
@@ -80,7 +80,7 @@ class AddNotebookDialog extends React.Component {
this.description = "";
this.id = undefined;
this.setState({
- topics: [],
+ topics: []
});
}
@@ -95,7 +95,7 @@ class AddNotebookDialog extends React.Component {
if (topic.id) return topic;
return topic.title;
}),
- id: this.id,
+ id: this.id
};
this.props.onDone(notebook, this.deletedTopics);
}
@@ -116,7 +116,7 @@ class AddNotebookDialog extends React.Component {
text: props.edit ? "Save" : "Create",
onClick: () => {
this.createNotebook();
- },
+ }
}}
onClose={props.onClose}
negativeButton={{ text: "Cancel", onClick: props.onClose }}
@@ -162,14 +162,14 @@ class AddNotebookDialog extends React.Component {
this.addTopic(this._topicInputRef.value);
}
},
- icon: this.state.isEditting ? Icon.Checkmark : Icon.Plus,
+ icon: this.state.isEditting ? Icon.Checkmark : Icon.Plus
}}
onChange={(e) => {
if (!this.state.isEditting) return;
const topics = this.state.topics.slice();
topics[this.state.editIndex].title = e.target.value;
this.setState({
- topics,
+ topics
});
}}
onKeyUp={(e) => {
@@ -211,7 +211,7 @@ function TopicItem(props) {
onDelete,
isEditing,
hideActions,
- index,
+ index
} = props;
return (
<Flex
@@ -224,7 +224,7 @@ function TopicItem(props) {
borderBottomColor: isEditing ? "primary" : "border",
borderBottomStyle: "solid",
cursor: "pointer",
- ":hover": { borderBottomColor: "primary" },
+ ":hover": { borderBottomColor: "primary" }
}}
onClick={isEditing ? onDoneEditing : onEdit}
>
diff --git a/apps/web/src/components/dialogs/announcement-dialog.js b/apps/web/src/components/dialogs/announcement-dialog.js
index b4568baa5..bd887d87f 100644
--- a/apps/web/src/components/dialogs/announcement-dialog.js
+++ b/apps/web/src/components/dialogs/announcement-dialog.js
@@ -43,12 +43,12 @@ function AnnouncementDialog(props) {
padding: 0,
overflowY: "hidden",
border: 0,
- zIndex: 0,
+ zIndex: 0
},
overlay: {
zIndex: 999,
- background: theme.colors.overlay,
- },
+ background: theme.colors.overlay
+ }
}}
>
<Flex
@@ -62,7 +62,7 @@ function AnnouncementDialog(props) {
position: "relative",
overflow: "hidden",
boxShadow: "4px 5px 18px 2px #00000038",
- borderRadius: "dialog",
+ borderRadius: "dialog"
}}
>
<AnnouncementBody
diff --git a/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx b/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx
index 6840df6c5..f6e1d8116 100644
--- a/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx
+++ b/apps/web/src/components/dialogs/buy-dialog/buy-dialog.tsx
@@ -72,12 +72,12 @@ export function BuyDialog(props: BuyDialogProps) {
padding: 0,
overflowY: "hidden",
border: 0,
- zIndex: 0,
+ zIndex: 0
},
overlay: {
zIndex: 999,
- background: theme.colors.overlay,
- },
+ background: theme.colors.overlay
+ }
}}
>
<Flex
@@ -91,7 +91,7 @@ export function BuyDialog(props: BuyDialogProps) {
position: "relative",
overflow: "hidden",
boxShadow: "4px 5px 18px 2px #00000038",
- borderRadius: "dialog",
+ borderRadius: "dialog"
}}
>
<Flex
@@ -107,8 +107,8 @@ export function BuyDialog(props: BuyDialogProps) {
"@supports ((-webkit-backdrop-filter: none) or (backdrop-filter: none))":
{
bg: "bgTransparent",
- backdropFilter: "blur(8px)",
- },
+ backdropFilter: "blur(8px)"
+ }
}}
width={["100%", "100%", 350]}
p={4}
@@ -172,10 +172,10 @@ function SideBar(props: SideBarProps) {
id: "trialActivation",
action: (report) => {
report({
- text: "Activating trial",
+ text: "Activating trial"
});
return db.user?.activateTrial();
- },
+ }
});
if (result) onClose();
} catch (e) {
@@ -326,7 +326,7 @@ function SelectedPlan(props: SelectedPlanProps) {
const [isInvalidCoupon, setIsInvalidCoupon] = useState(false);
const [isApplyingCoupon, setIsApplyingCoupon] = useCheckoutStore((store) => [
store.isApplyingCoupon,
- store.setIsApplyingCoupon,
+ store.setIsApplyingCoupon
]);
const onApplyCoupon = useCheckoutStore((store) => store.onApplyCoupon);
@@ -418,7 +418,7 @@ function SelectedPlan(props: SelectedPlanProps) {
? Icon.Cross
: Icon.Check,
onClick: () =>
- pricingInfo?.coupon ? removeCoupon() : applyCoupon(),
+ pricingInfo?.coupon ? removeCoupon() : applyCoupon()
}}
/>
<CheckoutPricing pricingInfo={pricingInfo} />
@@ -451,13 +451,13 @@ function CheckoutPricing(props: CheckoutPricingProps) {
{
key: "subtotal",
label: "Subtotal",
- value: formatPrice(currency, price.net.toFixed(2), null),
+ value: formatPrice(currency, price.net.toFixed(2), null)
},
{
key: "tax",
label: "Sales tax",
color: "error",
- value: formatPrice(currency, price.tax.toFixed(2), null),
+ value: formatPrice(currency, price.tax.toFixed(2), null)
},
{
key: "discount",
@@ -468,8 +468,8 @@ function CheckoutPricing(props: CheckoutPricingProps) {
discount.amount.toFixed(2),
null,
discount.amount > 0
- ),
- },
+ )
+ }
];
const isDiscounted = discount.recurring || discount.amount <= 0;
diff --git a/apps/web/src/components/dialogs/buy-dialog/features.tsx b/apps/web/src/components/dialogs/buy-dialog/features.tsx
index 93c32310d..0cf8fd530 100644
--- a/apps/web/src/components/dialogs/buy-dialog/features.tsx
+++ b/apps/web/src/components/dialogs/buy-dialog/features.tsx
@@ -24,32 +24,32 @@ const sections: Section[] = [
features: [
{
title: "Zero ads & zero trackers",
- icon: Icon.Billboard,
+ icon: Icon.Billboard
},
{
title: "On device encryption",
- icon: Icon.Cellphone,
+ icon: Icon.Cellphone
},
{
title: "Secure app lock for all",
- icon: Icon.CellphoneLock,
+ icon: Icon.CellphoneLock
},
{
title: "100% end-to-end encrypted",
- icon: Icon.Lock,
+ icon: Icon.Lock
},
{
title: "Private vault for notes",
icon: Icon.ShieldLock,
- pro: true,
- },
- ],
+ pro: true
+ }
+ ]
},
{
title: "Instant syncing",
detail:
"Seemlessly work from anywhere. Every change is synced instantly everywhere.",
- pro: true,
+ pro: true
},
{
title: "100% cross platform",
@@ -57,30 +57,30 @@ const sections: Section[] = [
columns: 8,
features: [
{
- icon: Icon.iOS,
+ icon: Icon.iOS
},
{
- icon: Icon.Android,
+ icon: Icon.Android
},
{
- icon: Icon.Windows,
+ icon: Icon.Windows
},
{
- icon: Icon.Linux,
+ icon: Icon.Linux
},
{
- icon: Icon.MacOS,
+ icon: Icon.MacOS
},
{
- icon: Icon.Chrome,
+ icon: Icon.Chrome
},
{
- icon: Icon.Firefox,
+ icon: Icon.Firefox
},
{
- icon: Icon.Safari,
- },
- ],
+ icon: Icon.Safari
+ }
+ ]
},
{
title: "Attach files & images",
@@ -90,30 +90,30 @@ const sections: Section[] = [
features: [
{
title: "Bulletproof encryption",
- icon: Icon.Lock,
+ icon: Icon.Lock
},
{
title: "High quality 4K images",
- icon: Icon.ImageMultiple,
+ icon: Icon.ImageMultiple
},
{
title: "Unlimited storage",
- icon: Icon.Harddisk,
+ icon: Icon.Harddisk
},
{
title: "Upto 500 MB per file",
- icon: Icon.FileCabinet,
+ icon: Icon.FileCabinet
},
{
title: "All file types supported",
- icon: Icon.File,
- },
- ],
+ icon: Icon.File
+ }
+ ]
},
{
title: "No limit on notes",
detail:
- "We don't have nonsense like blocks and whatnot. You can create as many notes as you want — no limits.",
+ "We don't have nonsense like blocks and whatnot. You can create as many notes as you want — no limits."
},
{
title: "Safe publishing to the Internet",
@@ -122,17 +122,17 @@ const sections: Section[] = [
features: [
{
title: "Anonymous publishing",
- icon: Icon.Anonymous,
+ icon: Icon.Anonymous
},
{
title: "Password protection",
- icon: Icon.CloudLock,
+ icon: Icon.CloudLock
},
{
title: "Self destructable notes",
- icon: Icon.Timebomb,
- },
- ],
+ icon: Icon.Timebomb
+ }
+ ]
},
{
title: "Organize yourself in the best way",
@@ -142,23 +142,23 @@ const sections: Section[] = [
{
title: "Unlimited notebooks*",
icon: Icon.Notebook2,
- pro: true,
+ pro: true
},
{
title: "Colors & tags*",
icon: Icon.Palette,
- pro: true,
+ pro: true
},
{
title: "Side menu shortcuts",
- icon: Icon.Shortcut,
+ icon: Icon.Shortcut
},
{
title: "Pins & favorites",
- icon: Icon.Pin,
- },
+ icon: Icon.Pin
+ }
],
- info: "* Free users can only create 3 notebooks (no limit on topics) and 5 tags.",
+ info: "* Free users can only create 3 notebooks (no limit on topics) and 5 tags."
},
{
@@ -169,21 +169,21 @@ const sections: Section[] = [
features: [
{
title: "Lists & tables",
- icon: Icon.Table,
+ icon: Icon.Table
},
{
title: "Images & embeds",
- icon: Icon.Embed,
+ icon: Icon.Embed
},
{
title: "Checklists",
- icon: Icon.CheckCircleOutline,
+ icon: Icon.CheckCircleOutline
},
{
title: "Markdown shortcuts",
- icon: Icon.Markdown,
- },
- ],
+ icon: Icon.Markdown
+ }
+ ]
},
{
title: "Export and take your notes anywhere",
@@ -194,27 +194,27 @@ const sections: Section[] = [
{
title: "Export as Markdown",
icon: Icon.Markdown,
- pro: true,
+ pro: true
},
{
title: "Export as PDF",
icon: Icon.PDF,
- pro: true,
+ pro: true
},
{
title: "Export as HTML",
icon: Icon.HTML,
- pro: true,
+ pro: true
},
{
title: "Export as text",
- icon: Icon.Text,
+ icon: Icon.Text
},
{
title: "Bulk exports",
- icon: Icon.Export,
- },
- ],
+ icon: Icon.Export
+ }
+ ]
},
{
title: "Backup & keep your notes safe",
@@ -224,14 +224,14 @@ const sections: Section[] = [
{
title: "Automatic monthly, weekly & daily backups",
icon: Icon.Backup,
- pro: true,
+ pro: true
},
{
title: "Backup encryption",
icon: Icon.EncryptedBackup,
- pro: true,
- },
- ],
+ pro: true
+ }
+ ]
},
{
title: "Personalize & make Notesnook your own",
@@ -241,18 +241,18 @@ const sections: Section[] = [
features: [
{
title: "10+ themes",
- icon: Icon.Accent,
+ icon: Icon.Accent
},
{
title: "Automatic dark mode",
- icon: Icon.Theme,
+ icon: Icon.Theme
},
{
title: "Change default home page",
- icon: Icon.Home,
- },
- ],
- },
+ icon: Icon.Home
+ }
+ ]
+ }
];
export function Features() {
@@ -296,7 +296,7 @@ export function Features() {
gridTemplateColumns: section.columns
? "1fr ".repeat(section.columns)
: "1fr 1fr 1fr",
- gap: 3,
+ gap: 3
}}
mt={4}
>
diff --git a/apps/web/src/components/dialogs/buy-dialog/helpers.ts b/apps/web/src/components/dialogs/buy-dialog/helpers.ts
index 0523f46a7..bd343ae57 100644
--- a/apps/web/src/components/dialogs/buy-dialog/helpers.ts
+++ b/apps/web/src/components/dialogs/buy-dialog/helpers.ts
@@ -1,6 +1,6 @@
import {
getCurrencySymbol as _getSymbol,
- ICurrencySymbols,
+ ICurrencySymbols
} from "@brixtol/currency-symbols";
export function getCurrencySymbol(currency: string) {
diff --git a/apps/web/src/components/dialogs/buy-dialog/paddle.tsx b/apps/web/src/components/dialogs/buy-dialog/paddle.tsx
index 86c100e12..c7f86f9c8 100644
--- a/apps/web/src/components/dialogs/buy-dialog/paddle.tsx
+++ b/apps/web/src/components/dialogs/buy-dialog/paddle.tsx
@@ -9,7 +9,7 @@ import {
PaddleEvents,
Plan,
Price,
- PricingInfo,
+ PricingInfo
} from "./types";
// const isDev = false; // process.env.NODE_ENV === "development";
@@ -20,7 +20,7 @@ const SUBSCRIBED_EVENTS: PaddleEvents[] = [
PaddleEvents["Checkout.Loaded"],
PaddleEvents["Checkout.Coupon.Applied"],
PaddleEvents["Checkout.Coupon.Remove"],
- PaddleEvents["Checkout.Location.Submit"],
+ PaddleEvents["Checkout.Location.Submit"]
];
type PaddleCheckoutProps = {
@@ -117,7 +117,7 @@ export function PaddleCheckout(props: PaddleCheckoutProps) {
onPriceUpdated,
plan,
reloadCheckout,
- updatePrice,
+ updatePrice
]);
return (
@@ -145,7 +145,7 @@ export function PaddleCheckout(props: PaddleCheckoutProps) {
flex: 1,
outline: "none",
border: "none",
- minHeight: 500,
+ minHeight: 500
}}
/>
</Flex>
@@ -185,12 +185,12 @@ function getPricingInfo(plan: Plan, checkoutData: CheckoutData): PricingInfo {
currency: price.currency,
discount: {
amount: discount?.gross_discount || 0,
- recurring: isRecurringDiscount,
+ recurring: isRecurringDiscount
},
period: plan.period,
price: normalizeCheckoutPrice(price),
recurringPrice: normalizeCheckoutPrice(recurringPrice),
- coupon: discount?.code,
+ coupon: discount?.code
};
}
@@ -200,7 +200,7 @@ function normalizeCheckoutPrice(prices: CheckoutPrices): Price {
gross: price.gross,
net: price.net,
tax: price.tax,
- currency: prices.currency,
+ currency: prices.currency
};
}
@@ -215,7 +215,7 @@ async function applyCoupon(
const response = await fetch(url, {
body: JSON.stringify(body),
headers,
- method: "POST",
+ method: "POST"
});
if (!response.ok) return false;
const json = (await response.json()) as CheckoutDataResponse;
@@ -229,7 +229,7 @@ async function removeCoupon(checkoutId: string): Promise<CheckoutData | false> {
const url = ` https://checkout-service.paddle.com/checkout/${checkoutId}/coupon`;
const response = await fetch(url, {
- method: "DELETE",
+ method: "DELETE"
});
if (!response.ok) return false;
const json = (await response.json()) as CheckoutDataResponse;
@@ -247,7 +247,7 @@ async function sendCheckoutEvent(checkoutId: string, eventName: PaddleEvents) {
const response = await fetch(url, {
body: JSON.stringify(body),
headers,
- method: "POST",
+ method: "POST"
});
return response.ok;
}
diff --git a/apps/web/src/components/dialogs/buy-dialog/plans.ts b/apps/web/src/components/dialogs/buy-dialog/plans.ts
index f62cbf222..fb0bca1e7 100644
--- a/apps/web/src/components/dialogs/buy-dialog/plans.ts
+++ b/apps/web/src/components/dialogs/buy-dialog/plans.ts
@@ -14,7 +14,7 @@ export const DEFAULT_PLANS: Plan[] = [
currency: "USD",
discount: 0,
id: "648884",
- price: { gross: 4.49, net: 0, tax: 0 },
+ price: { gross: 4.49, net: 0, tax: 0 }
},
{
period: "yearly",
@@ -22,13 +22,13 @@ export const DEFAULT_PLANS: Plan[] = [
currency: "USD",
discount: 0,
id: "658759",
- price: { gross: 49.99, net: 0, tax: 0 },
- },
+ price: { gross: 49.99, net: 0, tax: 0 }
+ }
];
export const PLAN_METADATA: Record<Period, PlanMetadata> = {
monthly: { title: "Monthly", subtitle: `Pay once a month.` },
- yearly: { title: "Yearly", subtitle: `Pay once a year.` },
+ yearly: { title: "Yearly", subtitle: `Pay once a year.` }
};
var CACHED_PLANS: Plan[];
diff --git a/apps/web/src/components/dialogs/buy-dialog/store.ts b/apps/web/src/components/dialogs/buy-dialog/store.ts
index a566c1437..61c70816d 100644
--- a/apps/web/src/components/dialogs/buy-dialog/store.ts
+++ b/apps/web/src/components/dialogs/buy-dialog/store.ts
@@ -53,5 +53,5 @@ export const useCheckoutStore = create<ICheckoutStore>((set, get) => ({
state.isApplyingCoupon = false;
})
);
- },
+ }
}));
diff --git a/apps/web/src/components/dialogs/buy-dialog/types.ts b/apps/web/src/components/dialogs/buy-dialog/types.ts
index de5bd8872..e8b411ba1 100644
--- a/apps/web/src/components/dialogs/buy-dialog/types.ts
+++ b/apps/web/src/components/dialogs/buy-dialog/types.ts
@@ -50,7 +50,7 @@ export enum PaddleEvents {
/** User has selected "Change Payment Method" when on the payment screen **/
"Checkout.PaymentMethodChange" = "Checkout.PaymentMethodChange",
/** User has selected "Change Payment Method" when on the Wire Transfer screen **/
- "Checkout.WireTransfer.PaymentMethodChange" = "Checkout.WireTransfer.PaymentMethodChange",
+ "Checkout.WireTransfer.PaymentMethodChange" = "Checkout.WireTransfer.PaymentMethodChange"
}
export interface CallbackData {
diff --git a/apps/web/src/components/dialogs/confirm.js b/apps/web/src/components/dialogs/confirm.js
index ed4d4b0a7..392c60c62 100644
--- a/apps/web/src/components/dialogs/confirm.js
+++ b/apps/web/src/components/dialogs/confirm.js
@@ -15,7 +15,7 @@ function Confirm(props) {
props.yesText && {
text: props.yesText,
onClick: props.onYes,
- autoFocus: !!props.yesText,
+ autoFocus: !!props.yesText
}
}
negativeButton={
diff --git a/apps/web/src/components/dialogs/dialog-loader.tsx b/apps/web/src/components/dialogs/dialog-loader.tsx
index 6d699e965..64ee5ab6a 100644
--- a/apps/web/src/components/dialogs/dialog-loader.tsx
+++ b/apps/web/src/components/dialogs/dialog-loader.tsx
@@ -16,7 +16,7 @@ export default function DialogLoader() {
mb: 3,
mt: 1,
justifyContent: "flex-end",
- alignItems: "flex-end",
+ alignItems: "flex-end"
}}
>
<Skeleton height={25} width={70} />
diff --git a/apps/web/src/components/dialogs/dialog.js b/apps/web/src/components/dialogs/dialog.js
index 58fb60538..338e8513b 100644
--- a/apps/web/src/components/dialogs/dialog.js
+++ b/apps/web/src/components/dialogs/dialog.js
@@ -44,12 +44,12 @@ function Dialog(props) {
padding: 0,
overflowY: "hidden",
border: 0,
- zIndex: 0,
+ zIndex: 0
},
overlay: {
zIndex: 999,
- background: theme.colors.overlay,
- },
+ background: theme.colors.overlay
+ }
}}
>
<Flex
@@ -65,7 +65,7 @@ function Dialog(props) {
position: "relative",
overflow: "hidden",
boxShadow: "4px 5px 18px 2px #00000038",
- borderRadius: "dialog",
+ borderRadius: "dialog"
}}
>
{props.showClose && (
@@ -76,7 +76,7 @@ function Dialog(props) {
top: 0,
right: 20,
mt: 26,
- zIndex: 999,
+ zIndex: 999
}}
size={20}
onClick={props.onClose}
diff --git a/apps/web/src/components/dialogs/email-verification-dialog.js b/apps/web/src/components/dialogs/email-verification-dialog.js
index 8ce30cd55..2be431152 100644
--- a/apps/web/src/components/dialogs/email-verification-dialog.js
+++ b/apps/web/src/components/dialogs/email-verification-dialog.js
@@ -59,12 +59,12 @@ function EmailVerificationDialog(props) {
}
},
loading: isSending,
- disabled: isSending || !canSendAgain,
+ disabled: isSending || !canSendAgain
}}
negativeButton={{
text: "Cancel",
onClick: props.onCancel,
- disabled: isSending,
+ disabled: isSending
}}
>
<Flex flexDirection="column">
diff --git a/apps/web/src/components/dialogs/feature-dialog.tsx b/apps/web/src/components/dialogs/feature-dialog.tsx
index ff579abd8..06c04fca4 100644
--- a/apps/web/src/components/dialogs/feature-dialog.tsx
+++ b/apps/web/src/components/dialogs/feature-dialog.tsx
@@ -33,8 +33,8 @@ const features: Record<FeatureKeys, Feature> = {
cta: {
title: "Continue",
icon: Icon.ArrowRight,
- action: () => hardNavigate(getHomeRoute()),
- },
+ action: () => hardNavigate(getHomeRoute())
+ }
},
highlights: {
title: appVersion.isBeta
@@ -55,7 +55,7 @@ const features: Record<FeatureKeys, Feature> = {
the <Code text="Report an issue" /> button to report all bugs.
Thank you!
</>
- ),
+ )
},
{
icon: Icon.Warn,
@@ -67,8 +67,8 @@ const features: Record<FeatureKeys, Feature> = {
use both simultaneously. You can switch once the beta version
enters stable.
</>
- ),
- },
+ )
+ }
]
: [
{
@@ -85,15 +85,15 @@ const features: Record<FeatureKeys, Feature> = {
To add current date <em>and time</em> use{" "}
<Code text="Ctrl+Alt+d" /> or just type <Code text="/now" />.
</>
- ),
- },
+ )
+ }
],
cta: {
title: "Got it",
icon: Icon.Checkmark,
action: () => {
Config.set(`${appVersion.numerical}:highlights`, true);
- },
+ }
},
shouldShow: () => {
if (!features.highlights.subFeatures?.length) return false;
@@ -105,8 +105,8 @@ const features: Record<FeatureKeys, Feature> = {
if (!hasShownAny) Config.set(key, true);
return hasShownAny && !isTesting() && !hasShownBefore;
- },
- },
+ }
+ }
};
type FeatureDialogProps = {
@@ -142,7 +142,7 @@ function FeatureDialog(props: FeatureDialogProps) {
onClick: () => {
if (feature.cta.action) feature.cta.action();
props.onClose(true);
- },
+ }
}}
>
<Flex flexDirection="column" overflowY="auto" mt={2}>
@@ -186,7 +186,7 @@ export function Code(props: CodeProps) {
fontFamily: "monospace",
fontSize: "subBody",
border: "1px solid var(--border)",
- cursor: props.href ? "pointer" : "unset",
+ cursor: props.href ? "pointer" : "unset"
}}
onClick={() => {
if (props.href) window.open(props.href, "_target");
diff --git a/apps/web/src/components/dialogs/import-dialog.js b/apps/web/src/components/dialogs/import-dialog.js
index 02ef02ac9..d018e66e4 100644
--- a/apps/web/src/components/dialogs/import-dialog.js
+++ b/apps/web/src/components/dialogs/import-dialog.js
@@ -13,7 +13,7 @@ function ImportDialog(props) {
const [progress, setProgress] = useState({
total: 0,
current: 0,
- done: false,
+ done: false
});
const [files, setFiles] = useState([]);
const [notes, setNotes] = useState([]);
@@ -28,7 +28,7 @@ function ImportDialog(props) {
}, []);
const { getRootProps, getInputProps, isDragActive } = useDropzone({
onDrop,
- accept: [".zip"],
+ accept: [".zip"]
});
useEffect(() => {
@@ -54,14 +54,14 @@ function ImportDialog(props) {
? undefined
: {
text: "Cancel",
- onClick: props.onClose,
+ onClick: props.onClose
}
}
positiveButton={
progress.done
? {
onClick: props.onClose,
- text: "Close",
+ text: "Close"
}
: {
onClick: async () => {
@@ -86,7 +86,7 @@ function ImportDialog(props) {
? `Import ${selectedNotes.length} notes`
: "Import",
loading: progress.current > 0,
- disabled: notes.length <= 0 || progress.current > 0,
+ disabled: notes.length <= 0 || progress.current > 0
}
}
>
@@ -109,7 +109,7 @@ function ImportDialog(props) {
<Text
variant="body"
sx={{
- color: "error",
+ color: "error"
}}
>
{error.message}
@@ -135,7 +135,7 @@ function ImportDialog(props) {
width: "full",
border: "2px dashed var(--border)",
borderRadius: "default",
- mt: 1,
+ mt: 1
}}
>
<Input {...getInputProps()} />
@@ -154,7 +154,7 @@ function ImportDialog(props) {
sx={{
":hover": { bg: "hover" },
cursor: "pointer",
- borderRadius: "default",
+ borderRadius: "default"
}}
onClick={() => {
setFiles((files) => {
@@ -206,7 +206,7 @@ function ImportDialog(props) {
sx={{
":hover": { bg: "hover" },
cursor: "pointer",
- borderRadius: "default",
+ borderRadius: "default"
}}
onClick={() => {
setNotes((notes) => {
diff --git a/apps/web/src/components/dialogs/index.ts b/apps/web/src/components/dialogs/index.ts
index 78a85ab83..af9e30ad1 100644
--- a/apps/web/src/components/dialogs/index.ts
+++ b/apps/web/src/components/dialogs/index.ts
@@ -54,5 +54,5 @@ export const Dialogs = {
RecoveryCodesDialog,
OnboardingDialog,
AttachmentsDialog,
- MigrationDialog,
+ MigrationDialog
};
diff --git a/apps/web/src/components/dialogs/issue-dialog.tsx b/apps/web/src/components/dialogs/issue-dialog.tsx
index aae174c72..a869fecc8 100644
--- a/apps/web/src/components/dialogs/issue-dialog.tsx
+++ b/apps/web/src/components/dialogs/issue-dialog.tsx
@@ -19,7 +19,7 @@ For example things like:
2. Things you have tried so far
3. etc.
-This is all optional, of course.`,
+This is all optional, of course.`
};
type IssueDialogProps = {
@@ -37,10 +37,10 @@ function IssueDialog(props: IssueDialogProps) {
positiveButton={{
text: "Submit",
props: {
- form: "issueForm",
+ form: "issueForm"
},
loading: isSubmitting,
- disabled: isSubmitting,
+ disabled: isSubmitting
}}
negativeButton={{ text: "Cancel", onClick: props.onClose }}
>
@@ -64,7 +64,7 @@ function IssueDialog(props: IssueDialogProps) {
const url = await db.debug?.report({
title: requestData.title,
body: requestData.body,
- userId: userstore.get().user?.id,
+ userId: userstore.get().user?.id
});
if (!url) throw new Error("Could not submit bug report.");
@@ -96,8 +96,8 @@ function IssueDialog(props: IssueDialogProps) {
sx={{ mt: 1 }}
styles={{
input: {
- minHeight: 150,
- },
+ minHeight: 150
+ }
}}
/>
<Text
@@ -167,7 +167,7 @@ function showIssueReportedDialog({ url }: { url: string }) {
for one-to-one support.
</p>
</>
- ),
+ )
});
}
diff --git a/apps/web/src/components/dialogs/item-dialog.js b/apps/web/src/components/dialogs/item-dialog.js
index d6c7663ac..7d6c7a828 100644
--- a/apps/web/src/components/dialogs/item-dialog.js
+++ b/apps/web/src/components/dialogs/item-dialog.js
@@ -12,9 +12,9 @@ function ItemDialog(props) {
positiveButton={{
props: {
form: "itemForm",
- type: "submit",
+ type: "submit"
},
- text: props.title,
+ text: props.title
}}
onClose={props.onClose}
negativeButton={{ text: "Cancel", onClick: props.onClose }}
diff --git a/apps/web/src/components/dialogs/mfa/multi-factor-dialog.tsx b/apps/web/src/components/dialogs/mfa/multi-factor-dialog.tsx
index 79bb79410..dfcffd79f 100644
--- a/apps/web/src/components/dialogs/mfa/multi-factor-dialog.tsx
+++ b/apps/web/src/components/dialogs/mfa/multi-factor-dialog.tsx
@@ -27,7 +27,7 @@ export default function MultifactorDialog(props: MultifactorDialogProps) {
step.next
? {
text: "Continue",
- props: { form: "2faForm" },
+ props: { form: "2faForm" }
}
: null
}
@@ -35,7 +35,7 @@ export default function MultifactorDialog(props: MultifactorDialogProps) {
step.cancellable
? {
text: "Cancel",
- onClick: onClose,
+ onClick: onClose
}
: null
}
diff --git a/apps/web/src/components/dialogs/mfa/recovery-code-dialog.tsx b/apps/web/src/components/dialogs/mfa/recovery-code-dialog.tsx
index e777476b2..3d794f600 100644
--- a/apps/web/src/components/dialogs/mfa/recovery-code-dialog.tsx
+++ b/apps/web/src/components/dialogs/mfa/recovery-code-dialog.tsx
@@ -23,7 +23,7 @@ export default function RecoveryCodesDialog(props: RecoveryCodesDialogProps) {
width={500}
positiveButton={{
text: "Okay",
- onClick: onClose,
+ onClick: onClose
}}
>
{step.component && (
diff --git a/apps/web/src/components/dialogs/mfa/steps.tsx b/apps/web/src/components/dialogs/mfa/steps.tsx
index 30cce76cd..aabd42870 100644
--- a/apps/web/src/components/dialogs/mfa/steps.tsx
+++ b/apps/web/src/components/dialogs/mfa/steps.tsx
@@ -5,7 +5,7 @@ import React, {
useEffect,
useMemo,
useRef,
- useState,
+ useState
} from "react";
import { Text, Flex, Button, Box } from "rebass";
import { useSessionState } from "../../../hooks/use-session-state";
@@ -18,7 +18,7 @@ import {
Print,
Copy,
Refresh,
- Checkmark,
+ Checkmark
} from "../../icons";
import Field from "../../field";
import { exportToPDF } from "../../../common/export";
@@ -34,7 +34,7 @@ import {
AuthenticatorType,
StepComponent,
SubmitCodeFunction,
- StepComponentProps,
+ StepComponentProps
} from "./types";
import { showMultifactorDialog } from "../../../common/dialog-controller";
const QRCode = React.lazy(
@@ -77,20 +77,20 @@ const Authenticators: Authenticator[] = [
subtitle:
"Use an authenticator app like Aegis or Raivo Authenticator to get the authentication codes.",
icon: MFAAuthenticator,
- recommended: true,
+ recommended: true
},
{
type: "sms",
title: "Set up using SMS",
subtitle: "Notesnook will send you an SMS text with the 2FA code at login.",
- icon: MFASMS,
+ icon: MFASMS
},
{
type: "email",
title: "Set up using Email",
subtitle: "Notesnook will send you the 2FA code on your email at login.",
- icon: MFAEmail,
- },
+ icon: MFAEmail
+ }
];
export const steps = {
@@ -104,7 +104,7 @@ export const steps = {
/>
),
next: "setup",
- cancellable: true,
+ cancellable: true
}),
setup: (authenticator: Authenticator): Step => ({
title: authenticator.title,
@@ -116,7 +116,7 @@ export const steps = {
authenticator={authenticator.type}
/>
),
- cancellable: true,
+ cancellable: true
}),
recoveryCodes: (authenticatorType: AuthenticatorType): Step => ({
title: "Save your recovery codes",
@@ -135,7 +135,7 @@ export const steps = {
authenticatorType={authenticatorType}
/>
),
- next: "finish",
+ next: "finish"
}),
finish: (authenticatorType: AuthenticatorType): Step => ({
component: ({ onNext, onClose, onError }) => (
@@ -145,8 +145,8 @@ export const steps = {
onError={onError}
authenticatorType={authenticatorType}
/>
- ),
- }),
+ )
+ })
} as const;
export const fallbackSteps = {
@@ -163,7 +163,7 @@ export const fallbackSteps = {
/>
),
next: "setup",
- cancellable: true,
+ cancellable: true
}),
setup: (authenticator: Authenticator): FallbackStep => ({
title: authenticator.title,
@@ -176,7 +176,7 @@ export const fallbackSteps = {
authenticator={authenticator.type}
isFallback
/>
- ),
+ )
}),
finish: (
fallbackMethod: AuthenticatorType,
@@ -189,8 +189,8 @@ export const fallbackSteps = {
primaryMethod={primaryMethod}
fallbackMethod={fallbackMethod}
/>
- ),
- }),
+ )
+ })
} as const;
type ChooseAuthenticatorProps = StepComponentProps & {
@@ -228,7 +228,7 @@ function ChooseAuthenticator(props: ChooseAuthenticatorProps) {
alignItems: "start",
textAlign: "left",
bg: "transparent",
- px: 0,
+ px: 0
}}
onClick={() => setSelected(index)}
>
@@ -239,7 +239,7 @@ function ChooseAuthenticator(props: ChooseAuthenticatorProps) {
borderRadius: 100,
width: 35,
height: 35,
- mr: 2,
+ mr: 2
}}
size={16}
color={selected === index ? "primary" : "text"}
@@ -299,7 +299,7 @@ function SetupAuthenticatorApp(props: SetupAuthenticatorProps) {
const { onSubmitCode } = props;
const [authenticatorDetails, setAuthenticatorDetails] = useState({
sharedKey: null,
- authenticatorUri: null,
+ authenticatorUri: null
});
const [copied, setCopied] = useState(false);
@@ -350,7 +350,7 @@ function SetupAuthenticatorApp(props: SetupAuthenticatorProps) {
sx={{
flex: 1,
overflowWrap: "anywhere",
- color: "text",
+ color: "text"
}}
>
{authenticatorDetails.sharedKey ? (
@@ -478,7 +478,7 @@ function SetupSMS(props: SetupAuthenticatorProps) {
autoFocus
required
styles={{
- input: { flex: 1 },
+ input: { flex: 1 }
}}
placeholder={"+1234567890"}
onChange={() => {
@@ -524,7 +524,7 @@ function SetupSMS(props: SetupAuthenticatorProps) {
} finally {
setIsSending(false);
}
- },
+ }
}}
/>
{error ? (
@@ -574,7 +574,7 @@ function BackupRecoveryCodes(props: TwoFactorEnabledProps) {
"Notesnook 2FA Recovery Codes",
recoveryCodesRef.current.outerHTML
);
- },
+ }
},
{
title: "Copy",
@@ -591,7 +591,7 @@ function BackupRecoveryCodes(props: TwoFactorEnabledProps) {
setTimeout(() => {
buttonText.innerHTML = "Copy";
}, 2500);
- },
+ }
},
{
title: "Download",
@@ -601,9 +601,9 @@ function BackupRecoveryCodes(props: TwoFactorEnabledProps) {
new Blob([Buffer.from(codes.join("\n"))]),
`notesnook-recovery-codes.txt`
);
- },
+ }
},
- { title: "Regenerate", icon: Refresh, action: generate },
+ { title: "Regenerate", icon: Refresh, action: generate }
],
[codes, generate]
);
@@ -626,7 +626,7 @@ function BackupRecoveryCodes(props: TwoFactorEnabledProps) {
gridTemplateColumns: "1fr 1fr 1fr 1fr",
bg: "bgSecondary",
p: 2,
- borderRadius: "default",
+ borderRadius: "default"
}}
>
{codes.map((code) => (
@@ -775,8 +775,8 @@ function VerifyAuthenticatorForm(props: VerifyAuthenticatorFormProps) {
width: "100%",
fontSize: 38,
fontFamily: "monospace",
- textAlign: "center",
- },
+ textAlign: "center"
+ }
}}
/>
</Flex>
diff --git a/apps/web/src/components/dialogs/migration-dialog.tsx b/apps/web/src/components/dialogs/migration-dialog.tsx
index 0e784f560..b4709a395 100644
--- a/apps/web/src/components/dialogs/migration-dialog.tsx
+++ b/apps/web/src/components/dialogs/migration-dialog.tsx
@@ -30,10 +30,10 @@ export default function MigrationDialog(props: MigrationDialogProps) {
action: (task) => {
task({ text: `Please wait...` });
return db.migrations?.migrate();
- },
+ }
});
props.onClose(true);
- },
+ }
}}
>
<Text variant={"subtitle"}>Read before continuing:</Text>
diff --git a/apps/web/src/components/dialogs/move-note-dialog.js b/apps/web/src/components/dialogs/move-note-dialog.js
index 03ae36da4..6a4557d94 100644
--- a/apps/web/src/components/dialogs/move-note-dialog.js
+++ b/apps/web/src/components/dialogs/move-note-dialog.js
@@ -52,11 +52,11 @@ function MoveDialog({ onClose, noteIds }) {
`Added ${noteIds.length} notes to ${selected.length} topics`
);
onClose();
- },
+ }
}}
negativeButton={{
text: "Cancel",
- onClick: onClose,
+ onClick: onClose
}}
>
<Flex flexDirection="column" mt={1} sx={{ overflowY: "hidden" }}>
@@ -64,13 +64,13 @@ function MoveDialog({ onClose, noteIds }) {
testId="mnd-new-notebook-title"
placeholders={{
empty: "Add a new notebook",
- filter: "Filter notebooks",
+ filter: "Filter notebooks"
}}
getAll={getAllNotebooks}
filter={(notebooks, query) => db.lookup.notebooks(notebooks, query)}
onCreateNewItem={(title) =>
db.notebooks.add({
- title,
+ title
})
}
refreshItems={refreshNotebooks}
@@ -106,7 +106,7 @@ function MoveDialog({ onClose, noteIds }) {
<FilteredList
placeholders={{
empty: "Add a new topic",
- filter: "Filter topics",
+ filter: "Filter topics"
}}
testId="mnd-new-topic-title"
itemName="topic"
@@ -139,7 +139,7 @@ function MoveDialog({ onClose, noteIds }) {
copy.push({
id: notebook.id,
topic: topic.id,
- type: opType,
+ type: opType
});
else copy.splice(index, 1);
return copy;
@@ -203,7 +203,7 @@ function FilteredList({
onCreateNewItem,
renderItem,
refreshItems,
- itemName,
+ itemName
}) {
const [items, setItems] = useState([]);
const [query, setQuery] = useState();
@@ -264,7 +264,7 @@ function FilteredList({
items.length <= 0
? {
icon: Icon.Plus,
- onClick: async () => await _createNewItem(query),
+ onClick: async () => await _createNewItem(query)
}
: { icon: Icon.Search, onClick: () => _filter(query) }
}
@@ -277,7 +277,7 @@ function FilteredList({
display: "flex",
justifyContent: "space-between",
alignItems: "center",
- py: 2,
+ py: 2
}}
onClick={async () => {
await _createNewItem(query);
diff --git a/apps/web/src/components/dialogs/onboarding-dialog.js b/apps/web/src/components/dialogs/onboarding-dialog.js
index e294e3dca..7e6ae54d4 100644
--- a/apps/web/src/components/dialogs/onboarding-dialog.js
+++ b/apps/web/src/components/dialogs/onboarding-dialog.js
@@ -28,14 +28,14 @@ const newUserSteps = [
subtitle: "Write with freedom. Never compromise on privacy again.",
buttonText: "Get started",
image: <Note width={120} />,
- component: TrackingConsent,
+ component: TrackingConsent
},
{
title: "Choose your style",
subtitle:
"You can change the theme at any time from Settings or the side menu.",
buttonText: "Next",
- component: ThemeSelector,
+ component: ThemeSelector
},
{
image: <E2E width={180} />,
@@ -43,21 +43,21 @@ const newUserSteps = [
subtitle:
"Notesnook encrypts everything offline before syncing to your other devices. This means that no one can read your notes except you. Not even us.",
component: CrossPlatform,
- buttonText: "Next",
+ buttonText: "Next"
},
{
title: "Join the cause",
subtitle:
"Meet other privacy-minded people & talk to us directly about your concerns, issues and suggestions.",
component: JoinCause,
- image: <Friends width={140} />,
+ image: <Friends width={140} />
},
{
image: <Icon.Pro size={60} color="primary" />,
title: "Notesnook Pro",
subtitle: "Experience the next level of private note taking",
- component: TrialOffer,
- },
+ component: TrialOffer
+ }
];
const proUserSteps = [
@@ -65,25 +65,25 @@ const proUserSteps = [
title: "Welcome to Notesnook Pro",
subtitle: "Thank you. You are the proof that privacy always comes first.",
buttonText: "Next",
- image: <Nomad width={120} />,
+ image: <Nomad width={120} />
},
{
title: "Style your 'nook",
subtitle: "Let's make Notesnook your new note taking home",
buttonText: "Next",
- component: AccentSelector,
+ component: AccentSelector
},
{
title: "We are always listening",
subtitle: "If you face any issue, you can reach out to us anytime.",
buttonText: "Next",
- component: Support,
+ component: Support
},
{
title: "Import your notes",
subtitle: "You can import your notes from most other note taking apps.",
- component: Importer,
- },
+ component: Importer
+ }
];
const trialUserSteps = [
@@ -91,14 +91,14 @@ const trialUserSteps = [
title: "Congratulations!",
subtitle: "You 14-day free trial has been activated.",
buttonText: "Continue",
- image: <WorkAnywhere width={160} />,
- },
+ image: <WorkAnywhere width={160} />
+ }
];
const onboarding = {
new: newUserSteps,
pro: proUserSteps,
- trial: trialUserSteps,
+ trial: trialUserSteps
};
export function interruptedOnboarding() {
@@ -132,7 +132,7 @@ function OnboardingDialog({ onClose: _onClose, type }) {
subtitle,
image,
component: Component,
- buttonText,
+ buttonText
} = steps[step];
return (
@@ -197,7 +197,7 @@ const importers = [
{ title: "HTML" },
{ title: "Markdown" },
{ title: "Google Keep" },
- { title: "Standard Notes" },
+ { title: "Standard Notes" }
];
function Importer({ onClose }) {
return (
@@ -212,7 +212,7 @@ function Importer({ onClose }) {
border: "1px solid var(--border)",
alignItems: "center",
justifyContent: "center",
- p: 1,
+ p: 1
}}
>
<Text variant={"body"} textAlign="center" ml={1}>
@@ -250,7 +250,7 @@ function AccentSelector() {
<Box
sx={{
display: "grid",
- gridTemplateColumns: "1fr 1fr 1fr 1fr 1fr 1fr",
+ gridTemplateColumns: "1fr 1fr 1fr 1fr 1fr 1fr"
}}
>
{getAllAccents().map((color) => (
@@ -266,26 +266,26 @@ const supportChannels = [
key: "email",
url: "mailto:[email protected]",
title: "Email us",
- icon: Icon.Email,
+ icon: Icon.Email
},
{
key: "discord",
url: "https://discord.com/invite/zQBK97EE22",
title: "Join the community",
- icon: Icon.Discord,
+ icon: Icon.Discord
},
{
key: "twitter",
url: "https://twitter.com/notesnook",
title: "Follow us @notesnook",
- icon: Icon.Twitter,
+ icon: Icon.Twitter
},
{
key: "github",
url: "https://github.com/streetwriters/notesnook",
title: "Create an issue",
- icon: Icon.Github,
- },
+ icon: Icon.Github
+ }
];
function Support() {
@@ -300,7 +300,7 @@ function Support() {
display: "flex",
flexDirection: "row",
borderRadius: "default",
- alignItems: "center",
+ alignItems: "center"
}}
>
<channel.icon size={16} />
@@ -315,7 +315,7 @@ function Support() {
const themes = [
{ key: "light", name: "Light", image: LightUI },
- { key: "dark", name: "Dark", image: DarkUI },
+ { key: "dark", name: "Dark", image: DarkUI }
];
function ThemeSelector() {
@@ -340,11 +340,11 @@ function ThemeSelector() {
bg: isSelected ? "bgSecondary" : "transparent",
cursor: "pointer",
":last-of-type": {
- borderRight: "0px",
+ borderRight: "0px"
},
":hover": {
- bg: "hover",
- },
+ bg: "hover"
+ }
}}
onClick={() => {
setTheme(theme.key);
@@ -355,7 +355,7 @@ function ThemeSelector() {
sx={{
borderRadius: "default",
border: isSelected ? "2px solid var(--primary)" : "none",
- boxShadow: isSelected ? "0px 0px 10px 1px #00000016" : "none",
+ boxShadow: isSelected ? "0px 0px 10px 1px #00000016" : "none"
}}
/>
<Text variant={"subtitle"} color="icon" mt={2}>
@@ -455,10 +455,10 @@ function TrialOffer({ onClose }) {
id: "trialActivation",
action: (report) => {
report({
- text: "Activating trial",
+ text: "Activating trial"
});
return db.user.activateTrial();
- },
+ }
});
if (result) onClose();
} catch (e) {
diff --git a/apps/web/src/components/dialogs/password-dialog.js b/apps/web/src/components/dialogs/password-dialog.js
index dce3691df..0e09d2c2c 100644
--- a/apps/web/src/components/dialogs/password-dialog.js
+++ b/apps/web/src/components/dialogs/password-dialog.js
@@ -40,11 +40,11 @@ function PasswordDialog(props) {
positiveButton={{
props: {
form: "passwordForm",
- type: "submit",
+ type: "submit"
},
text: props.positiveButtonText,
loading: isLoading,
- disabled: isLoading,
+ disabled: isLoading
}}
negativeButton={{ text: "Cancel", onClick: props.onClose }}
>
diff --git a/apps/web/src/components/dialogs/progress-dialog.js b/apps/web/src/components/dialogs/progress-dialog.js
index a6d088593..b547f7be6 100644
--- a/apps/web/src/components/dialogs/progress-dialog.js
+++ b/apps/web/src/components/dialogs/progress-dialog.js
@@ -6,7 +6,7 @@ function ProgressDialog(props) {
const [{ current, total, text }, setProgress] = useState({
current: 0,
total: 1,
- text: "",
+ text: ""
});
useEffect(() => {
@@ -39,7 +39,7 @@ function ProgressDialog(props) {
my: 1,
bg: "primary",
height: "2px",
- width: `${(current / total) * 100}%`,
+ width: `${(current / total) * 100}%`
}}
/>
</>
diff --git a/apps/web/src/components/dialogs/prompt.tsx b/apps/web/src/components/dialogs/prompt.tsx
index 9b0c0a8fa..c89b313c8 100644
--- a/apps/web/src/components/dialogs/prompt.tsx
+++ b/apps/web/src/components/dialogs/prompt.tsx
@@ -21,7 +21,7 @@ export default function Prompt(props: PromptDialogProps) {
onClose={props.onClose}
positiveButton={{
text: "Done",
- onClick: () => props.onSave(inputRef.current?.value || ""),
+ onClick: () => props.onSave(inputRef.current?.value || "")
}}
negativeButton={{ text: "Cancel", onClick: props.onClose }}
>
diff --git a/apps/web/src/components/dialogs/recovery-key-dialog.js b/apps/web/src/components/dialogs/recovery-key-dialog.js
index bb773b50c..9ef28234d 100644
--- a/apps/web/src/components/dialogs/recovery-key-dialog.js
+++ b/apps/web/src/components/dialogs/recovery-key-dialog.js
@@ -33,7 +33,7 @@ function RecoveryKeyDialog(props) {
onClick: () => {
Config.set("recoveryKeyBackupDate", Date.now());
props.onDone();
- },
+ }
}}
>
<Flex flexDirection="column" flex={1} sx={{ overflow: "hidden" }}>
diff --git a/apps/web/src/components/dialogs/reminder-dialog.js b/apps/web/src/components/dialogs/reminder-dialog.js
index 94e1c45ff..70cbb90de 100644
--- a/apps/web/src/components/dialogs/reminder-dialog.js
+++ b/apps/web/src/components/dialogs/reminder-dialog.js
@@ -11,7 +11,7 @@ const features = [
{ icon: Icon.Backup, title: "Encrypted backups" },
{ icon: Icon.Vault, title: "Secure private vault" },
{ icon: Icon.PDF, title: "Export to PDF" },
- { icon: Icon.Edit, title: "Rich text editor" },
+ { icon: Icon.Edit, title: "Rich text editor" }
];
// TODO create trial expiry coupon codes
const reminders = {
@@ -28,7 +28,7 @@ const reminders = {
*
</>
),
- subtitle: "*Only for yearly plan",
+ subtitle: "*Only for yearly plan"
},
features,
// footer: (
@@ -44,8 +44,8 @@ const reminders = {
setTimeout(async () => {
await showBuyDialog("yearly", "TRIAL2PRO");
}, 0);
- },
- },
+ }
+ }
},
trialexpiring: {
title: "Your free trial is ending soon",
@@ -56,7 +56,7 @@ const reminders = {
Upgrade now to continue using all the pro features without
interruption.
</>
- ),
+ )
},
features,
cta: {
@@ -65,9 +65,9 @@ const reminders = {
setTimeout(async () => {
await showBuyDialog();
}, 0);
- },
- },
- },
+ }
+ }
+ }
};
function ReminderDialog(props) {
@@ -89,7 +89,7 @@ function ReminderDialog(props) {
if (reminder.cta.action) await reminder.cta.action();
props.onClose(true);
- },
+ }
}}
footer={reminder.footer}
>
@@ -118,7 +118,7 @@ function ReminderDialog(props) {
display: "grid",
gridTemplateColumns: "1fr 1fr",
columnGap: 1,
- rowGap: 1,
+ rowGap: 1
}}
>
{reminder.features.map((feature) => (
@@ -126,7 +126,7 @@ function ReminderDialog(props) {
p={1}
sx={{
borderRadius: "default",
- border: "1px solid var(--border)",
+ border: "1px solid var(--border)"
}}
>
<feature.icon size={16} sx={{ alignSelf: "start" }} />
diff --git a/apps/web/src/components/dialogs/toolbar-config-dialog.tsx b/apps/web/src/components/dialogs/toolbar-config-dialog.tsx
index 4f3d18434..296f4edeb 100644
--- a/apps/web/src/components/dialogs/toolbar-config-dialog.tsx
+++ b/apps/web/src/components/dialogs/toolbar-config-dialog.tsx
@@ -8,7 +8,7 @@ import {
Icons,
ToolbarGroupDefinition,
ToolDefinition,
- ToolId,
+ ToolId
} from "@streetwriters/editor";
import {
closestCenter,
@@ -18,14 +18,14 @@ import {
KeyboardSensor,
PointerSensor,
DragOverlay,
- MeasuringStrategy,
+ MeasuringStrategy
} from "@dnd-kit/core";
import {
arrayMove,
SortableContext,
sortableKeyboardCoordinates,
useSortable,
- verticalListSortingStrategy,
+ verticalListSortingStrategy
} from "@dnd-kit/sortable";
import { useEffect, useState } from "react";
import { CSS } from "@dnd-kit/utilities";
@@ -40,7 +40,7 @@ import {
getPreset,
getPresetTools,
Preset,
- PresetId,
+ PresetId
} from "../../common/toolbar-config";
import { showToast } from "../../utils/toast";
export type ToolbarConfigDialogProps = {
@@ -51,7 +51,7 @@ export default function ToolbarConfigDialog(props: ToolbarConfigDialogProps) {
const sensors = useSensors(
useSensor(PointerSensor),
useSensor(KeyboardSensor, {
- coordinateGetter: sortableKeyboardCoordinates,
+ coordinateGetter: sortableKeyboardCoordinates
})
);
const [items, setItems] = useState<TreeNode[]>([]);
@@ -82,12 +82,12 @@ export default function ToolbarConfigDialog(props: ToolbarConfigDialogProps) {
await db.settings?.setToolbarConfig("desktop", {
preset: currentPreset.id,
- config: currentPreset.id === "custom" ? tools : undefined,
+ config: currentPreset.id === "custom" ? tools : undefined
});
setToolbarConfig(tools);
props.onClose(true);
- },
+ }
}}
negativeButton={{ text: "Cancel", onClick: props.onClose }}
>
@@ -123,7 +123,7 @@ export default function ToolbarConfigDialog(props: ToolbarConfigDialogProps) {
display: "flex",
flexShrink: 0,
alignItems: "center",
- p: 1,
+ p: 1
}}
title="Add group"
onClick={() => {
@@ -143,7 +143,7 @@ export default function ToolbarConfigDialog(props: ToolbarConfigDialogProps) {
if (currentPreset.id !== "custom") {
setCurrentPreset((c) => ({
...getPreset("custom"),
- tools: getPresetTools(c),
+ tools: getPresetTools(c)
}));
}
@@ -169,7 +169,7 @@ export default function ToolbarConfigDialog(props: ToolbarConfigDialogProps) {
setActiveItem(undefined);
}}
measuring={{
- droppable: { strategy: MeasuringStrategy.Always },
+ droppable: { strategy: MeasuringStrategy.Always }
}}
>
<SortableContext items={items} strategy={verticalListSortingStrategy}>
@@ -265,7 +265,7 @@ function TreeNodeComponent(props: TreeNodeComponentProps) {
p: 1,
mb: 1,
ml: item.depth * 15,
- alignItems: "center",
+ alignItems: "center"
}}
>
{isDraggable ? (
@@ -292,7 +292,7 @@ function TreeNodeComponent(props: TreeNodeComponentProps) {
borderRadius: "default",
mb: 1,
ml: item.depth * 15,
- ":last-of-type": { mb: 0 },
+ ":last-of-type": { mb: 0 }
}}
>
{item.icon && (
@@ -338,7 +338,7 @@ function SortableWrapper(props: SortableWrapperProps) {
transition,
justifyContent: "space-between",
":hover #remove-item, :hover #add-item": { opacity: 1 },
- ...sx,
+ ...sx
}}
>
<Flex
@@ -447,7 +447,7 @@ function createGroup(config: Partial<Group>): Group {
id: id(),
depth: 0,
title: "Group",
- ...config,
+ ...config
};
}
@@ -459,7 +459,7 @@ function createItem(config: Partial<Item>): Item {
title: "",
icon: "",
toolId: "",
- ...config,
+ ...config
};
}
@@ -467,7 +467,7 @@ function createTrash() {
return createGroup({
id: "trash",
depth: 0,
- title: "Disabled items",
+ title: "Disabled items"
});
}
@@ -645,7 +645,7 @@ function getGroup(items: TreeNode[], groupId: string): ResolvedGroup | null {
items: items.slice(
index,
nextGroupIndex < 0 ? items.length : nextGroupIndex
- ),
+ )
};
}
diff --git a/apps/web/src/components/dialogs/tracking-details-dialog.js b/apps/web/src/components/dialogs/tracking-details-dialog.js
index 7eb744b6f..25fb94acc 100644
--- a/apps/web/src/components/dialogs/tracking-details-dialog.js
+++ b/apps/web/src/components/dialogs/tracking-details-dialog.js
@@ -16,7 +16,7 @@ function TrackingDetailsDialog(props) {
onClose={props.onClose}
positiveButton={{
text: "Okay",
- onClick: props.onClose,
+ onClick: props.onClose
}}
>
<Box overflowY="auto">
diff --git a/apps/web/src/components/diff-viewer/content-toggle.js b/apps/web/src/components/diff-viewer/content-toggle.js
index d68b32099..aaad085e4 100644
--- a/apps/web/src/components/diff-viewer/content-toggle.js
+++ b/apps/web/src/components/diff-viewer/content-toggle.js
@@ -9,7 +9,7 @@ function ContentToggle(props) {
sx,
label,
dateEdited,
- resolveConflict,
+ resolveConflict
} = props;
return (
diff --git a/apps/web/src/components/diff-viewer/index.js b/apps/web/src/components/diff-viewer/index.js
index 642395de6..228b2ed82 100644
--- a/apps/web/src/components/diff-viewer/index.js
+++ b/apps/web/src/components/diff-viewer/index.js
@@ -31,7 +31,7 @@ function DiffViewer(props) {
await db.notes.add({
id: conflictedNote.id,
dateEdited: toKeepDateEdited,
- conflicted: false,
+ conflicted: false
});
await db.content.add({
@@ -40,17 +40,17 @@ function DiffViewer(props) {
type: "tiptap",
dateResolved,
conflicted: false,
- sessionId: Date.now(),
+ sessionId: Date.now()
});
if (toCopy) {
const toCopyContent = {
data: toCopy,
- type: "tiptap",
+ type: "tiptap"
};
await db.notes.add({
content: toCopyContent,
- title: conflictedNote.title + " (COPY)",
+ title: conflictedNote.title + " (COPY)"
});
}
@@ -86,7 +86,7 @@ function DiffViewer(props) {
if (!content.conflicted)
return resolveConflict({
toKeep: content.data,
- toKeepDateEdited: content.dateEdited,
+ toKeepDateEdited: content.dateEdited
});
setConflictedNote(note);
@@ -119,7 +119,7 @@ function DiffViewer(props) {
flexShrink: 0,
whiteSpace: "nowrap",
overflow: "hidden",
- textOverflow: "ellipsis",
+ textOverflow: "ellipsis"
}}
>
{conflictedNote.title}
@@ -136,12 +136,12 @@ function DiffViewer(props) {
await Promise.all([
db.content.downloadMedia(noteId, {
data: htmlDiff.before,
- type: localContent.type,
+ type: localContent.type
}),
db.content.downloadMedia(noteId, {
data: htmlDiff.after,
- type: remoteContent.type,
- }),
+ type: remoteContent.type
+ })
]);
} finally {
setIsDownloadingImages(false);
@@ -184,7 +184,7 @@ function DiffViewer(props) {
toKeep: remoteContent.data,
toCopy: saveCopy ? localContent.data : null,
toKeepDateEdited: localContent.dateEdited,
- dateResolved: remoteContent.dateModified,
+ dateResolved: remoteContent.dateModified
});
}}
sx={{
@@ -193,7 +193,7 @@ function DiffViewer(props) {
borderBottomWidth: 1,
borderColor: "border",
px: 2,
- pb: 1,
+ pb: 1
}}
/>
<ScrollSyncPane>
@@ -206,7 +206,7 @@ function DiffViewer(props) {
borderWidth: 0,
borderRightWidth: [0, 0, 1],
borderBottomWidth: [1, 1, 0],
- borderColor: "border",
+ borderColor: "border"
}}
>
<Editor
@@ -230,7 +230,7 @@ function DiffViewer(props) {
toKeep: localContent.data,
toCopy: saveCopy ? remoteContent.data : null,
toKeepDateEdited: remoteContent.dateEdited,
- dateResolved: remoteContent.dateModified,
+ dateResolved: remoteContent.dateModified
});
}}
label="Incoming note"
@@ -246,7 +246,7 @@ function DiffViewer(props) {
borderColor: "border",
px: 2,
pb: 1,
- pt: [1, 1, 0],
+ pt: [1, 1, 0]
}}
/>
<ScrollSyncPane>
diff --git a/apps/web/src/components/dropdown-button/index.js b/apps/web/src/components/dropdown-button/index.js
index 34023d507..fa35e53e4 100644
--- a/apps/web/src/components/dropdown-button/index.js
+++ b/apps/web/src/components/dropdown-button/index.js
@@ -19,7 +19,7 @@ export default function DropdownButton({ title, options }) {
px={1}
sx={{
borderBottomLeftRadius: 0,
- borderTopLeftRadius: 0,
+ borderTopLeftRadius: 0
}}
onClick={() => openMenu(options.slice(1), { title })}
>
diff --git a/apps/web/src/components/editor/-placeholder.js b/apps/web/src/components/editor/-placeholder.js
index 114ac8d1c..827d0193f 100644
--- a/apps/web/src/components/editor/-placeholder.js
+++ b/apps/web/src/components/editor/-placeholder.js
@@ -24,7 +24,7 @@ function EditorPlaceholder() {
display="flex"
sx={{
alignItems: "center",
- justifyContent: "center",
+ justifyContent: "center"
}}
variant="tool"
onClick={() =>
diff --git a/apps/web/src/components/editor/context.ts b/apps/web/src/components/editor/context.ts
index d84ba94a5..d9a6c09c7 100644
--- a/apps/web/src/components/editor/context.ts
+++ b/apps/web/src/components/editor/context.ts
@@ -55,7 +55,7 @@ export function useHistory() {
canUndo: store.subState.canUndo,
canRedo: store.subState.canRedo,
undo: store.subState.editor?.undo,
- redo: store.subState.editor?.redo,
+ redo: store.subState.editor?.redo
} as const),
shallow
);
@@ -87,7 +87,7 @@ export function useNoteStatistics(): NoteStatistics {
return useEditorContext(
(store) =>
store.subState.statistics || {
- words: { total: 0 },
+ words: { total: 0 }
}
);
}
diff --git a/apps/web/src/components/editor/footer.js b/apps/web/src/components/editor/footer.js
index 3a7dda458..03cf755f9 100644
--- a/apps/web/src/components/editor/footer.js
+++ b/apps/web/src/components/editor/footer.js
@@ -7,7 +7,7 @@ import { useNoteStatistics } from "./context";
const SAVE_STATE_ICON_MAP = {
"-1": NotSaved,
0: Loading,
- 1: Saved,
+ 1: Saved
};
function EditorFooter() {
diff --git a/apps/web/src/components/editor/header.js b/apps/web/src/components/editor/header.js
index bb4099460..87690220d 100644
--- a/apps/web/src/components/editor/header.js
+++ b/apps/web/src/components/editor/header.js
@@ -56,7 +56,7 @@ function Autosuggest({
onRemove,
onSelect,
onAdd,
- defaultItems,
+ defaultItems
}) {
const [filtered, setFiltered] = useState([]);
const inputRef = useRef();
@@ -93,7 +93,7 @@ function Autosuggest({
key: "new",
title: () => `Create "${filterText}" tag`,
icon: Icon.Plus,
- onClick: () => onAction("add", filterText),
+ onClick: () => onAction("add", filterText)
});
} else {
items.push(
@@ -101,7 +101,7 @@ function Autosuggest({
key: tag.id,
title: () => tag.title,
icon: Icon.Tag,
- onClick: () => onAction("select", tag),
+ onClick: () => onAction("select", tag)
}))
);
}
@@ -111,8 +111,8 @@ function Autosuggest({
positionOptions: {
relativeTo: inputRef.current,
absolute: true,
- location: "below",
- },
+ location: "below"
+ }
});
}, [filtered, getInputValue, closeMenu, openMenu, onAction]);
diff --git a/apps/web/src/components/editor/index.tsx b/apps/web/src/components/editor/index.tsx
index 6424b62d1..e3d8af95b 100644
--- a/apps/web/src/components/editor/index.tsx
+++ b/apps/web/src/components/editor/index.tsx
@@ -3,7 +3,7 @@ import {
useCallback,
useState,
useRef,
- PropsWithChildren,
+ PropsWithChildren
} from "react";
import { Box, Button, Flex, Text } from "rebass";
import Properties from "../properties";
@@ -36,7 +36,7 @@ function onEditorChange(noteId: string, sessionId: string, content: string) {
editorstore.get().saveSessionContent(noteId, sessionId, {
type: "tiptap",
- data: content,
+ data: content
});
}
@@ -51,7 +51,7 @@ const debouncedOnTitleChange = debounceWithId(onTitleChange, 100);
export default function EditorManager({
noteId,
- nonce,
+ nonce
}: {
noteId: string | number;
nonce?: string;
@@ -125,7 +125,7 @@ export default function EditorManager({
sx={{
position: "relative",
alignSelf: "stretch",
- overflow: "hidden",
+ overflow: "hidden"
}}
>
{previewSession.current && (
@@ -141,7 +141,7 @@ export default function EditorManager({
options={{
readonly: isReadonly || isPreviewSession,
onRequestFocus: () => toggleProperties(false),
- onLoadMedia: loadMedia,
+ onLoadMedia: loadMedia
}}
/>
{arePropertiesVisible && (
@@ -177,7 +177,7 @@ export function Editor(props: EditorProps) {
const { readonly, headless, onLoadMedia } = options || {
headless: false,
readonly: false,
- focusMode: false,
+ focusMode: false
};
const editor = useEditorInstance();
@@ -199,7 +199,7 @@ export function Editor(props: EditorProps) {
({
groupId,
hash,
- src,
+ src
}: {
groupId?: string;
hash: string;
@@ -255,7 +255,7 @@ function EditorChrome(props: PropsWithChildren<EditorProps>) {
const { readonly, focusMode, headless, onRequestFocus } = options || {
headless: false,
readonly: false,
- focusMode: false,
+ focusMode: false
};
const isMobile: boolean | null = useMobile();
@@ -273,7 +273,7 @@ function EditorChrome(props: PropsWithChildren<EditorProps>) {
variant="columnFill"
className="editor"
sx={{
- alignSelf: ["stretch", focusMode ? "center" : "stretch", "center"],
+ alignSelf: ["stretch", focusMode ? "center" : "stretch", "center"]
}}
maxWidth={
focusMode ? "min(100%, 850px)" : "max(calc(100% - 200px), 850px)"
@@ -292,7 +292,7 @@ function EditorChrome(props: PropsWithChildren<EditorProps>) {
position: "sticky",
top: 0,
mb: 1,
- zIndex: 2,
+ zIndex: 2
}}
/>
)}
@@ -322,7 +322,7 @@ function EditorChrome(props: PropsWithChildren<EditorProps>) {
top: 0,
mb: 1,
zIndex: 2,
- px: [2, 2, 35],
+ px: [2, 2, 35]
}}
/>
)}
@@ -404,7 +404,7 @@ function DropZone(props: DropZoneProps) {
zIndex: 3,
alignItems: "center",
justifyContent: "center",
- display: "none",
+ display: "none"
}}
onDrop={async (e) => {
if (!editor || !e.dataTransfer.files?.length) return;
@@ -423,7 +423,7 @@ function DropZone(props: DropZoneProps) {
borderRadius: "default",
p: 70,
flexDirection: "column",
- pointerEvents: "none",
+ pointerEvents: "none"
}}
>
<Attachment size={72} />
diff --git a/apps/web/src/components/editor/picker.ts b/apps/web/src/components/editor/picker.ts
index 3e991cff0..facf6ffa2 100644
--- a/apps/web/src/components/editor/picker.ts
+++ b/apps/web/src/components/editor/picker.ts
@@ -19,7 +19,7 @@ export async function insertAttachment(type: MimeType = "*/*") {
}
const selectedFile = await showFilePicker({
- acceptedFileTypes: type || "*/*",
+ acceptedFileTypes: type || "*/*"
});
if (!selectedFile) return;
@@ -43,14 +43,14 @@ export async function reuploadAttachment(
expectedFileHash: string
) {
const selectedFile = await showFilePicker({
- acceptedFileTypes: type || "*/*",
+ acceptedFileTypes: type || "*/*"
});
if (!selectedFile) return;
const options: AddAttachmentOptions = {
expectedFileHash,
showProgress: false,
- forceWrite: true,
+ forceWrite: true
};
if (selectedFile.type.startsWith("image/")) {
@@ -104,7 +104,7 @@ async function getEncryptionKey(): Promise<SerializedKey> {
type FilePickerOptions = { acceptedFileTypes: MimeType };
export function showFilePicker({
- acceptedFileTypes,
+ acceptedFileTypes
}: FilePickerOptions): Promise<File | undefined> {
return new Promise((resolve) => {
const input = document.createElement("input");
@@ -180,7 +180,7 @@ async function addAttachment(
hashType,
filename: file.name,
type: file.type,
- key,
+ key
});
}
@@ -189,7 +189,7 @@ async function addAttachment(
filename: file.name,
type: file.type,
size: file.size,
- dataurl,
+ dataurl
};
};
@@ -214,12 +214,12 @@ function withProgress<T>(file: File, action: () => Promise<T>): Promise<T> {
report({
current: loaded,
total: total,
- text: file.name,
+ text: file.name
});
}
);
event.unsubscribe();
return action();
- },
+ }
});
}
diff --git a/apps/web/src/components/editor/tiptap.tsx b/apps/web/src/components/editor/tiptap.tsx
index 1048ccee6..5888ba92f 100644
--- a/apps/web/src/components/editor/tiptap.tsx
+++ b/apps/web/src/components/editor/tiptap.tsx
@@ -11,7 +11,7 @@ import {
PortalProvider,
Editor,
AttachmentType,
- usePermissionHandler,
+ usePermissionHandler
} from "@streetwriters/editor";
import { Box, Flex } from "rebass";
import { PropsWithChildren, useEffect, useRef, useState } from "react";
@@ -55,7 +55,7 @@ function TipTap(props: TipTapProps) {
editorContainer,
readonly,
nonce,
- theme,
+ theme
} = props;
const isUserPremium = useIsUserPremium();
@@ -69,11 +69,11 @@ function TipTap(props: TipTapProps) {
usePermissionHandler({
claims: {
- premium: isUserPremium,
+ premium: isUserPremium
},
onPermissionDenied: (claim) => {
if (claim === "premium") showBuyDialog();
- },
+ }
});
const editor = useTiptap(
@@ -88,7 +88,7 @@ function TipTap(props: TipTapProps) {
}
return true;
}
- },
+ }
},
doubleSpacedLines,
isKeyboardOpen: true,
@@ -107,9 +107,9 @@ function TipTap(props: TipTapProps) {
statistics: {
words: {
total: getTotalWords(editor as Editor),
- selected: 0,
- },
- },
+ selected: 0
+ }
+ }
});
if (onLoad) onLoad();
},
@@ -124,9 +124,9 @@ function TipTap(props: TipTapProps) {
statistics: {
words: {
total: countWords(editor.view.dom.innerText),
- selected: 0,
- },
- },
+ selected: 0
+ }
+ }
});
}, SAVE_INTERVAL) as unknown as number;
},
@@ -136,13 +136,13 @@ function TipTap(props: TipTapProps) {
canRedo: false,
canUndo: false,
searching: false,
- statistics: undefined,
+ statistics: undefined
});
},
onTransaction: ({ editor }) => {
configure({
canRedo: editor.can().redo(),
- canUndo: editor.can().undo(),
+ canUndo: editor.can().undo()
});
},
onSelectionUpdate: ({ editor, transaction }) => {
@@ -155,9 +155,9 @@ function TipTap(props: TipTapProps) {
selected: getSelectedWords(
editor as Editor,
transaction.selection
- ),
- },
- },
+ )
+ }
+ }
}));
},
theme,
@@ -168,7 +168,7 @@ function TipTap(props: TipTapProps) {
onDownloadAttachment: (_editor, attachment) => {
onDownloadAttachment?.(attachment);
return true;
- },
+ }
},
// IMPORTANT: only put stuff here that the editor depends on.
[readonly, nonce]
@@ -239,7 +239,7 @@ function TiptapWrapper(props: Omit<TipTapProps, "editorContainer" | "theme">) {
flex: 1,
cursor: "text",
color: theme.colors.text, // TODO!
- paddingBottom: 150,
+ paddingBottom: 150
}}
/>
</Flex>
@@ -277,8 +277,8 @@ function toIEditor(editor: Editor): IEditor {
editor.current?.commands.setAttachmentProgress({
hash,
type: type as any,
- progress,
- }),
+ progress
+ })
};
}
diff --git a/apps/web/src/components/editor/title-box.tsx b/apps/web/src/components/editor/title-box.tsx
index f1641f00c..5155f96ef 100644
--- a/apps/web/src/components/editor/title-box.tsx
+++ b/apps/web/src/components/editor/title-box.tsx
@@ -29,7 +29,7 @@ function TitleBox(props: TitleBoxProps) {
p: 0,
fontFamily: "heading",
fontSize: ["1.625em", "1.625em", "2.625em"],
- fontWeight: "heading",
+ fontWeight: "heading"
}}
onChange={(e) => {
setCurrentTitle(e.target.value);
diff --git a/apps/web/src/components/editor/toolbar.js b/apps/web/src/components/editor/toolbar.js
index 90fc6957b..9297bbf1f 100644
--- a/apps/web/src/components/editor/toolbar.js
+++ b/apps/web/src/components/editor/toolbar.js
@@ -59,8 +59,8 @@ function Toolbar(props) {
icon: isNotePublished ? Icon.Published : Icon.Publish,
hidden: !sessionId,
enabled: !isLocked,
- onClick: () => showPublishView(store.get().session.id, "top"),
- },
+ onClick: () => showPublishView(store.get().session.id, "top")
+ }
],
[sessionId, isLocked, isNotePublished]
);
@@ -72,7 +72,7 @@ function Toolbar(props) {
icon: Icon.Theme,
hidden: !isFocusMode,
enabled: true,
- onClick: () => toggleNightMode(),
+ onClick: () => toggleNightMode()
},
{
title: isFocusMode ? "Normal mode" : "Focus mode",
@@ -86,7 +86,7 @@ function Toolbar(props) {
setIsFullscreen(false);
}
if (editor) editor.current.focus();
- },
+ }
},
{
title: isFullscreen ? "Exit fullscreen" : "Enter fullscreen",
@@ -101,36 +101,36 @@ function Toolbar(props) {
enterFullscreen(document.documentElement);
}
setIsFullscreen((s) => !s);
- },
+ }
},
{
title: "Search",
icon: Icon.Search,
enabled: true,
hidden: !sessionId,
- onClick: () => toggleSearch(),
+ onClick: () => toggleSearch()
},
{
title: "Undo",
icon: Icon.Undo,
enabled: canUndo,
hidden: !sessionId,
- onClick: () => undo(),
+ onClick: () => undo()
},
{
title: "Redo",
icon: Icon.Redo,
enabled: canRedo,
hidden: !sessionId,
- onClick: () => redo(),
+ onClick: () => redo()
},
{
title: "Properties",
icon: Icon.Properties,
enabled: true,
hidden: !sessionId || isFocusMode,
- onClick: toggleProperties,
- },
+ onClick: toggleProperties
+ }
],
[
editor,
@@ -145,7 +145,7 @@ function Toolbar(props) {
theme,
toggleNightMode,
sessionId,
- toggleSearch,
+ toggleSearch
]
);
@@ -155,7 +155,7 @@ function Toolbar(props) {
<Icon.ArrowLeft
sx={{
display: ["block", "none", "none"],
- flexShrink: 0,
+ flexShrink: 0
}}
size={24}
onClick={() => {
@@ -169,11 +169,11 @@ function Toolbar(props) {
ml={[2, 2, 0]}
initial={{
opacity: isTitleVisible ? 1 : 0,
- zIndex: isTitleVisible ? 1 : -1,
+ zIndex: isTitleVisible ? 1 : -1
}}
animate={{
opacity: isTitleVisible ? 1 : 0,
- zIndex: isTitleVisible ? 1 : -1,
+ zIndex: isTitleVisible ? 1 : -1
}}
transition={{ duration: 0.5 }}
fontWeight="heading"
@@ -191,7 +191,7 @@ function Toolbar(props) {
textOverflow: "ellipsis",
whiteSpace: "nowrap",
overflow: "hidden",
- ":focus": { bg: "bgSecondary" },
+ ":focus": { bg: "bgSecondary" }
}}
/>
</Flex>
@@ -208,10 +208,10 @@ function Toolbar(props) {
sx={{
display: [
tool.hideOnMobile ? "none" : "flex",
- tool.hidden ? "none" : "flex",
+ tool.hidden ? "none" : "flex"
],
color: tool.enabled ? "text" : "disabled",
- cursor: tool.enabled ? "pointer" : "not-allowed",
+ cursor: tool.enabled ? "pointer" : "not-allowed"
}}
onClick={tool.onClick}
flexDirection="row"
@@ -242,10 +242,10 @@ function Toolbar(props) {
borderRadius: 0,
display: [
tool.hideOnMobile ? "none" : "flex",
- tool.hidden ? "none" : "flex",
+ tool.hidden ? "none" : "flex"
],
color: tool.enabled ? "text" : "disabled",
- cursor: tool.enabled ? "pointer" : "not-allowed",
+ cursor: tool.enabled ? "pointer" : "not-allowed"
}}
onClick={tool.onClick}
flexDirection="row"
diff --git a/apps/web/src/components/field/index.js b/apps/web/src/components/field/index.js
index 5bbc44513..988fcab2b 100644
--- a/apps/web/src/components/field/index.js
+++ b/apps/web/src/components/field/index.js
@@ -6,8 +6,8 @@ import * as Icon from "../icons";
const passwordValidationRules = [
{
title: "8 characters",
- validate: (password) => password.length >= 8,
- },
+ validate: (password) => password.length >= 8
+ }
// {
// title: "1 lowercase letter",
// validate: (password) => /[a-z]/.test(password),
@@ -51,7 +51,7 @@ function Field(props) {
inputMode,
pattern,
variant = "input",
- as = "input",
+ as = "input"
} = props;
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
const [rules, setRules] = useState(passwordValidationRules);
@@ -65,7 +65,7 @@ function Field(props) {
fontWeight: "bold",
color: "icon",
flexDirection: "column",
- ...styles.label,
+ ...styles.label
}}
>
{label}{" "}
@@ -76,7 +76,7 @@ function Field(props) {
fontSize: "subBody",
fontWeight: "normal",
color: "fontTertiary",
- ...styles.helpText,
+ ...styles.helpText
}}
>
{helpText}
@@ -104,8 +104,8 @@ function Field(props) {
sx={{
...styles.input,
":disabled": {
- bg: "bgSecondary",
- },
+ bg: "bgSecondary"
+ }
}}
onChange={(e) => {
if (validatePassword) {
@@ -141,7 +141,7 @@ function Field(props) {
cursor: "pointer",
borderTopRightRadius: "default",
borderBottomRightRadius: "default",
- ":hover": { bg: "border" },
+ ":hover": { bg: "border" }
}}
>
{isPasswordVisible ? (
@@ -165,7 +165,7 @@ function Field(props) {
bottom: "2px",
px: 1,
borderRadius: "default",
- ":hover": { bg: "border" },
+ ":hover": { bg: "border" }
}}
disabled={action.disabled}
>
diff --git a/apps/web/src/components/global-menu-wrapper/index.js b/apps/web/src/components/global-menu-wrapper/index.js
index d140f1ad2..dd89fd1ed 100644
--- a/apps/web/src/components/global-menu-wrapper/index.js
+++ b/apps/web/src/components/global-menu-wrapper/index.js
@@ -29,7 +29,7 @@ function GlobalMenuWrapper() {
style={{
...props.style,
zIndex: 1000,
- backgroundColor: isAutocomplete ? "transparent" : "unset",
+ backgroundColor: isAutocomplete ? "transparent" : "unset"
}}
onClick={(e) => {
if (e.target.closest(".menuContainer")) return;
@@ -67,7 +67,7 @@ function GlobalMenuWrapper() {
padding: 0,
zIndex: 0,
outline: 0,
- isolation: "isolate",
+ isolation: "isolate"
}}
>
{children}
@@ -77,8 +77,8 @@ function GlobalMenuWrapper() {
content: {},
overlay: {
zIndex: 999,
- background: "transparent",
- },
+ background: "transparent"
+ }
}}
>
<Menu
diff --git a/apps/web/src/components/group-header/index.js b/apps/web/src/components/group-header/index.js
index 353d10bc9..3c9d67e63 100644
--- a/apps/web/src/components/group-header/index.js
+++ b/apps/web/src/components/group-header/index.js
@@ -14,7 +14,7 @@ const groupByToTitleMap = {
abc: "A - Z",
year: "Year",
week: "Week",
- month: "Month",
+ month: "Month"
};
const menuItems = [
@@ -33,14 +33,14 @@ const menuItems = [
{
key: "asc",
title: ({ groupOptions }) =>
- groupOptions.sortBy === "title" ? "A - Z" : "Oldest - newest",
+ groupOptions.sortBy === "title" ? "A - Z" : "Oldest - newest"
},
{
key: "desc",
title: ({ groupOptions }) =>
- groupOptions.sortBy === "title" ? "Z - A" : "Newest - oldest",
- },
- ]),
+ groupOptions.sortBy === "title" ? "Z - A" : "Newest - oldest"
+ }
+ ])
},
{
key: "sortBy",
@@ -50,22 +50,22 @@ const menuItems = [
{
key: "dateCreated",
title: "Date created",
- hidden: ({ type }) => type === "trash",
+ hidden: ({ type }) => type === "trash"
},
{
key: "dateEdited",
title: "Date edited",
- hidden: ({ type }) => type === "trash" || type === "tags",
+ hidden: ({ type }) => type === "trash" || type === "tags"
},
{
key: "dateDeleted",
title: "Date deleted",
- hidden: ({ type }) => type !== "trash",
+ hidden: ({ type }) => type !== "trash"
},
{
key: "dateModified",
title: "Date modified",
- hidden: ({ type }) => type !== "tags",
+ hidden: ({ type }) => type !== "tags"
},
{
key: "title",
@@ -77,9 +77,9 @@ const menuItems = [
groupOptions.groupBy !== "abc" &&
groupOptions.groupBy !== "none"
);
- },
- },
- ]),
+ }
+ }
+ ])
},
{
key: "groupBy",
@@ -91,9 +91,9 @@ const menuItems = [
{ key: "year", title: "Year" },
{ key: "month", title: "Month" },
{ key: "week", title: "Week" },
- { key: "abc", title: "A - Z" },
- ]),
- },
+ { key: "abc", title: "A - Z" }
+ ])
+ }
];
function changeGroupOptions({ groupOptions, type, refresh, parent }, item) {
@@ -139,7 +139,7 @@ function GroupHeader(props) {
type,
refresh,
onSelectGroup,
- isFocused,
+ isFocused
} = props;
const [groupOptions, setGroupOptions] = useState(
db.settings.getGroupOptions(type)
@@ -167,7 +167,7 @@ function GroupHeader(props) {
notesViewMode,
notebooksViewMode,
setNotesViewMode,
- setNotebooksViewMode,
+ setNotebooksViewMode
]);
const isCompact = useMemo(() => viewMode === "compact", [viewMode]);
@@ -189,12 +189,12 @@ function GroupHeader(props) {
key: groupTitle,
title: () => groupTitle,
onClick: () => onJump(groupTitle),
- checked: group.title === title,
+ checked: group.title === title
};
});
openMenu(items, {
title: "Jump to group",
- target: groupHeaderRef.current,
+ target: groupHeaderRef.current
});
}}
mx={1}
@@ -211,8 +211,8 @@ function GroupHeader(props) {
border: isMenuTarget ? "1px solid var(--primary)" : "none",
":focus": {
border: "1px solid var(--primary)",
- outline: "none",
- },
+ outline: "none"
+ }
}}
tabIndex={0}
>
@@ -241,7 +241,7 @@ function GroupHeader(props) {
title: "Group & sort",
groupOptions,
refresh,
- type,
+ type
});
}}
/>
diff --git a/apps/web/src/components/icon-tag/index.js b/apps/web/src/components/icon-tag/index.js
index 7189c43b7..69eeaf606 100644
--- a/apps/web/src/components/icon-tag/index.js
+++ b/apps/web/src/components/icon-tag/index.js
@@ -19,14 +19,14 @@ function IconTag({ text, title, icon: Icon, onClick, styles, testId }) {
lineHeight: "initial",
":hover": {
bg: "hover",
- filter: "brightness(95%)",
+ filter: "brightness(95%)"
},
maxWidth: "100%",
px: 1,
mr: 1,
cursor: onClick ? "pointer" : "default",
overflow: "hidden",
- ...styles?.container,
+ ...styles?.container
}}
bg="bgSecondary"
justifyContent="center"
@@ -47,7 +47,7 @@ function IconTag({ text, title, icon: Icon, onClick, styles, testId }) {
textOverflow: "ellipsis",
whiteSpace: "nowrap",
overflow: "hidden",
- ...styles?.text,
+ ...styles?.text
}}
>
{text}
diff --git a/apps/web/src/components/icons/index.js b/apps/web/src/components/icons/index.js
index 73444ed61..57e85d99d 100644
--- a/apps/web/src/components/icons/index.js
+++ b/apps/web/src/components/icons/index.js
@@ -156,7 +156,7 @@ import {
mdiArrowCollapseHorizontal,
mdiSpeedometer,
mdiFormatLineSpacing,
- mdiCalendarClockOutline,
+ mdiCalendarClockOutline
} from "@mdi/js";
import { useTheme } from "emotion-theming";
import { AnimatedFlex } from "../animated";
@@ -171,7 +171,7 @@ function Icon({ title, name, size = 24, color = "icon", stroke, rotate }) {
size={size + "px"}
style={{
strokeWidth: stroke || "0px",
- stroke: theme.colors[color] || color,
+ stroke: theme.colors[color] || color
}}
color={theme.colors[color] || color}
spin={rotate}
diff --git a/apps/web/src/components/install-notice/index.js b/apps/web/src/components/install-notice/index.js
index 9aad2ecbc..dc9cff3a3 100644
--- a/apps/web/src/components/install-notice/index.js
+++ b/apps/web/src/components/install-notice/index.js
@@ -11,7 +11,7 @@ const nativeFeatures = [
"Pin notes in notifications drawer",
"Share & append to notes from anywhere",
"Quick note widgets",
- "App lock",
+ "App lock"
];
const platform = getPlatform();
@@ -26,7 +26,7 @@ function getOptions(onClose) {
window.open(item.link, "_blank");
onClose();
Config.set("installNotice", false);
- },
+ }
}));
}
@@ -44,7 +44,7 @@ export default function InstallNotice({ onClose }) {
bg: "background",
borderRadius: "default",
border: "1px solid var(--border)",
- width: ["95%", 400],
+ width: ["95%", 400]
}}
p={2}
>
@@ -59,7 +59,7 @@ export default function InstallNotice({ onClose }) {
gridTemplateColumns: "1fr 1fr",
columnGap: 1,
rowGap: 1,
- mt: 1,
+ mt: 1
}}
>
{nativeFeatures.map((feature) => (
@@ -67,7 +67,7 @@ export default function InstallNotice({ onClose }) {
p={1}
sx={{
borderRadius: "default",
- border: "1px solid var(--border)",
+ border: "1px solid var(--border)"
}}
>
<Text variant="body" ml={1}>
diff --git a/apps/web/src/components/list-container/index.js b/apps/web/src/components/list-container/index.js
index a7a63277f..2b414c0ad 100644
--- a/apps/web/src/components/list-container/index.js
+++ b/apps/web/src/components/list-container/index.js
@@ -4,7 +4,7 @@ import * as Icon from "../icons";
import { Virtuoso } from "react-virtuoso";
import {
useStore as useSelectionStore,
- store as selectionStore,
+ store as selectionStore
} from "../../stores/selection-store";
import GroupHeader from "../group-header";
import ListProfiles from "../../common/list-profiles";
@@ -79,7 +79,7 @@ function ListContainer(props) {
if (isNaN(endIndex)) return;
setSelectedItems([
...selectionStore.get().selectedItems,
- ...items.slice(focusedItemIndex.current + 1, endIndex + 1),
+ ...items.slice(focusedItemIndex.current + 1, endIndex + 1)
]);
listItem.firstElementChild.focus();
}
@@ -134,7 +134,7 @@ function ListContainer(props) {
const listItem = document.querySelector(query);
if (!listItem) return;
listItem.firstElementChild.focus();
- },
+ }
});
selectionStore.toggleSelectionMode(false);
// if (isShiftKey) {
@@ -175,7 +175,7 @@ function ListContainer(props) {
/>
) : (
<ReminderBar />
- ),
+ )
}}
itemContent={(index, item) => {
if (!item) return null;
@@ -202,7 +202,7 @@ function ListContainer(props) {
...props.items.slice(
index,
endIndex || props.items.length
- ),
+ )
]);
}}
groups={groups}
@@ -214,7 +214,7 @@ function ListContainer(props) {
listRef.current.scrollToIndex({
index,
align: "center",
- behavior: "auto",
+ behavior: "auto"
});
setFocusedGroupIndex(index);
}}
@@ -244,7 +244,7 @@ function ListContainer(props) {
mb: 2,
mr: 2,
width: 45,
- height: 45,
+ height: 45
}}
>
<Icon.Plus color="static" />
diff --git a/apps/web/src/components/list-item/index.js b/apps/web/src/components/list-item/index.js
index 09dd7db17..6dcb3b574 100644
--- a/apps/web/src/components/list-item/index.js
+++ b/apps/web/src/components/list-item/index.js
@@ -2,7 +2,7 @@ import { Box, Flex, Text } from "rebass";
import * as Icon from "../icons";
import {
store as selectionStore,
- useStore as useSelectionStore,
+ useStore as useSelectionStore
} from "../../stores/selection-store";
import { useMenuTrigger } from "../../hooks/use-menu";
import Config from "../../utils/config";
@@ -20,16 +20,16 @@ function debugMenuItems(type) {
onClick: async ({ [type]: item }) => {
if (type === "note" && item.contentId) {
item.additionalData = {
- content: db.debug.strip(await db.content.raw(item.contentId)),
+ content: db.debug.strip(await db.content.raw(item.contentId))
};
}
item.additionalData = {
...item.additionalData,
- lastSynced: await db.lastSynced(),
+ lastSynced: await db.lastSynced()
};
await clipboard.writeText(db.debug.strip(item));
- },
- },
+ }
+ }
];
}
@@ -38,10 +38,10 @@ function ListItem(props) {
colors: { text, background, primary } = {
primary: "primary",
text: "text",
- background: "background",
+ background: "background"
},
isFocused,
- isCompact,
+ isCompact
} = props;
const listItemRef = useRef();
@@ -89,7 +89,7 @@ function ListItem(props) {
title,
items: selectedItems,
target: listItemRef.current,
- ...props.menu?.extraData,
+ ...props.menu?.extraData
});
}}
pr={2}
@@ -106,15 +106,15 @@ function ListItem(props) {
outline: isMenuTarget ? `1px solid var(--${primary})` : "none",
// borderBottom: isMenuTarget ? `1px solid var(--${primary})` : "none",
":hover": {
- backgroundColor: isSelected ? "shade" : "hover",
+ backgroundColor: isSelected ? "shade" : "hover"
},
":focus,:focus-visible": {
// outline: "none",
- outline: `1px solid var(--${primary})`,
+ outline: `1px solid var(--${primary})`
// outline: `1px solid var(--${primary})`,
},
overflow: "hidden",
- maxWidth: "100%",
+ maxWidth: "100%"
}}
onKeyPress={(e) => {
if (e.key === "Enter") {
@@ -152,7 +152,7 @@ function ListItem(props) {
sx={{
whiteSpace: "nowrap",
overflow: "hidden",
- textOverflow: "ellipsis",
+ textOverflow: "ellipsis"
}}
>
{props.title}
@@ -170,7 +170,7 @@ function ListItem(props) {
position: "relative",
display: "-webkit-box",
WebkitLineClamp: 4,
- WebkitBoxOrient: "vertical",
+ WebkitBoxOrient: "vertical"
}}
>
{props.body}
diff --git a/apps/web/src/components/loaders/list-loader.tsx b/apps/web/src/components/loaders/list-loader.tsx
index 1d86a9bca..587ac74fc 100644
--- a/apps/web/src/components/loaders/list-loader.tsx
+++ b/apps/web/src/components/loaders/list-loader.tsx
@@ -17,7 +17,7 @@ export const ListLoader = memo(function ListLoader() {
flex: 1,
ml: 1,
flexDirection: "column",
- justifyContent: "center",
+ justifyContent: "center"
}}
>
<Box height={14}>
diff --git a/apps/web/src/components/loaders/navigation-loader.tsx b/apps/web/src/components/loaders/navigation-loader.tsx
index 1ddc14fc4..e2f772ec4 100644
--- a/apps/web/src/components/loaders/navigation-loader.tsx
+++ b/apps/web/src/components/loaders/navigation-loader.tsx
@@ -12,7 +12,7 @@ export const NavigationLoader = memo(function NavigationLoader() {
sx={{
height: "100%",
zIndex: 1,
- position: "relative",
+ position: "relative"
}}
bg={"bgSecondary"}
>
@@ -26,7 +26,7 @@ export const NavigationLoader = memo(function NavigationLoader() {
sx={{
position: "relative",
":first-of-type": { mt: 1 },
- ":last-of-type": { mb: 1 },
+ ":last-of-type": { mb: 1 }
}}
>
<Skeleton
diff --git a/apps/web/src/components/menu/index.js b/apps/web/src/components/menu/index.js
index 146bea9e8..a41964b44 100644
--- a/apps/web/src/components/menu/index.js
+++ b/apps/web/src/components/menu/index.js
@@ -16,7 +16,7 @@ function useMenuFocus(items, onAction, onClose) {
const element = document.getElementById(item.key);
if (!element) return;
element.scrollIntoView({
- behavior: "auto",
+ behavior: "auto"
});
},
[items]
@@ -128,7 +128,7 @@ function Menu({ items, data, title, closeMenu }) {
const { top, left } = getPosition(subMenuRef.current, {
yOffset: document.getElementById(item.key).offsetHeight,
relativeTo: document.getElementById(item.key),
- location: "right",
+ location: "right"
});
subMenuRef.current.style.visibility = "visible";
@@ -177,7 +177,7 @@ function Menu({ items, data, title, closeMenu }) {
ref={subMenuRef}
style={{ visibility: "hidden" }}
sx={{
- position: "absolute",
+ position: "absolute"
}}
>
<Menu
@@ -209,7 +209,7 @@ function MenuContainer({ title, children }) {
borderRadius: "default",
boxShadow: "0px 0px 10px 0px #00000022",
border: "1px solid var(--border)",
- width: 220,
+ width: 220
}}
>
{title && (
@@ -222,7 +222,7 @@ function MenuContainer({ title, children }) {
sx={{
borderBottom: "1px solid",
borderBottomColor: "border",
- wordWrap: "break-word",
+ wordWrap: "break-word"
}}
>
{title}
diff --git a/apps/web/src/components/menu/menu-item.js b/apps/web/src/components/menu/menu-item.js
index 42dc7648f..46de677eb 100644
--- a/apps/web/src/components/menu/menu-item.js
+++ b/apps/web/src/components/menu/menu-item.js
@@ -15,7 +15,7 @@ function MenuItem({ item, isFocused, onMouseEnter, onMouseLeave, onClick }) {
isChecked,
hasSubmenu,
isPremium,
- modifier,
+ modifier
} = item;
const itemRef = useRef();
if (type === "seperator")
@@ -53,7 +53,7 @@ function MenuItem({ item, isFocused, onMouseEnter, onMouseLeave, onClick }) {
disabled={isDisabled}
onClick={onClick}
sx={{
- bg: isFocused ? "hover" : "transparent",
+ bg: isFocused ? "hover" : "transparent"
}}
>
<Flex>
diff --git a/apps/web/src/components/navigation-menu/index.js b/apps/web/src/components/navigation-menu/index.js
index 3bc841415..819133813 100644
--- a/apps/web/src/components/navigation-menu/index.js
+++ b/apps/web/src/components/navigation-menu/index.js
@@ -14,7 +14,7 @@ import {
DarkMode,
LightMode,
Login,
- Circle,
+ Circle
} from "../icons";
import { AnimatedFlex } from "../animated";
import NavigationItem from "./navigation-item";
@@ -44,26 +44,26 @@ const routes = [
{
title: "Notebooks",
path: "/notebooks",
- icon: Notebook,
+ icon: Notebook
},
{
title: "Favorites",
path: "/favorites",
- icon: StarOutline,
+ icon: StarOutline
},
{ title: "Tags", path: "/tags", icon: Tag },
{
title: "Monographs",
path: "/monographs",
- icon: Monographs,
+ icon: Monographs
},
- { title: "Trash", path: "/trash", icon: Trash },
+ { title: "Trash", path: "/trash", icon: Trash }
];
const settings = {
title: "Settings",
path: "/settings",
- icon: Settings,
+ icon: Settings
};
const NAVIGATION_MENU_WIDTH = "10em";
@@ -105,18 +105,18 @@ function NavigationMenu(props) {
flexDirection="column"
justifyContent="space-between"
initial={{
- opacity: 1,
+ opacity: 1
}}
animate={{
opacity: isFocusMode ? 0 : 1,
- visibility: isFocusMode ? "collapse" : "visible",
+ visibility: isFocusMode ? "collapse" : "visible"
}}
transition={{ duration: 0.3, ease: "easeOut" }}
sx={{
zIndex: 1,
height: "auto",
position: "relative",
- flex: 1,
+ flex: 1
}}
bg={"bgSecondary"}
px={0}
@@ -160,10 +160,10 @@ function NavigationMenu(props) {
title: () => "Rename color",
onClick: async ({ color }) => {
await showRenameColorDialog(color.id);
- },
- },
+ }
+ }
],
- extraData: { color },
+ extraData: { color }
}}
/>
))}
@@ -187,10 +187,10 @@ function NavigationMenu(props) {
onClick: async ({ pin }) => {
await db.settings.unpin(pin.id);
refreshNavItems();
- },
- },
+ }
+ }
],
- extraData: { pin },
+ extraData: { pin }
}}
icon={
pin.type === "notebook"
@@ -243,8 +243,8 @@ function NavigationMenu(props) {
borderRadius: "default",
":hover:not(disabled)": {
bg: "bgSecondaryHover",
- filter: "brightness(100%)",
- },
+ filter: "brightness(100%)"
+ }
}}
onClick={(e) => {
setFollowSystemTheme(false);
diff --git a/apps/web/src/components/navigation-menu/navigation-item.js b/apps/web/src/components/navigation-menu/navigation-item.js
index c2567774a..1c9f7dd70 100644
--- a/apps/web/src/components/navigation-menu/navigation-item.js
+++ b/apps/web/src/components/navigation-menu/navigation-item.js
@@ -13,7 +13,7 @@ function NavigationItem(props) {
isShortcut,
isNew,
children,
- isTablet,
+ isTablet
} = props;
const toggleSideMenu = useAppStore((store) => store.toggleSideMenu);
const { openMenu } = useMenuTrigger();
@@ -32,8 +32,8 @@ function NavigationItem(props) {
":last-of-type": { mb: 1 },
":hover:not(:disabled)": {
bg: "bgSecondaryHover",
- filter: "brightness(100%)",
- },
+ filter: "brightness(100%)"
+ }
}}
>
<Button
@@ -41,7 +41,7 @@ function NavigationItem(props) {
bg={"transparent"}
sx={{
px: 2,
- flex: 1,
+ flex: 1
}}
label={title}
title={title}
@@ -86,7 +86,7 @@ function NavigationItem(props) {
whiteSpace: "nowrap",
overflow: "hidden",
textOverflow: "ellipsis",
- fontWeight: props.selected ? "bold" : "normal",
+ fontWeight: props.selected ? "bold" : "normal"
}}
ml={1}
>
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index 9921464eb..609398b24 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -6,7 +6,7 @@ import ListItem from "../list-item";
import {
confirm,
showError,
- showMoveNoteDialog,
+ showMoveNoteDialog
} from "../../common/dialog-controller";
import { store, useStore } from "../../stores/note-store";
import { store as userstore } from "../../stores/user-store";
@@ -61,11 +61,11 @@ function Note(props) {
colors={{
primary,
text: note.color ? primary : "text",
- background: isOpened ? "bgSecondary" : "background",
+ background: isOpened ? "bgSecondary" : "background"
}}
menu={{
items: context?.type === "topic" ? topicNoteMenuItems : menuItems,
- extraData: { note, context },
+ extraData: { note, context }
}}
onClick={() => {
if (note.conflicted) {
@@ -83,8 +83,8 @@ function Note(props) {
container: {
alignSelf: "flex-start",
justifySelf: "flex-start",
- mb: 1,
- },
+ mb: 1
+ }
}}
onClick={() => {
navigate(`/notebooks/${notebook.id}/${notebook.topic.id}`);
@@ -99,7 +99,7 @@ function Note(props) {
alignItems="center"
sx={{
fontSize: "subBody",
- color: isOpened ? "bgSecondaryText" : "fontTertiary",
+ color: isOpened ? "bgSecondaryText" : "fontTertiary"
}}
>
{isCompact ? (
@@ -184,7 +184,7 @@ function Note(props) {
sx={{
maxWidth: `calc(100% / ${tags.length})`,
overflow: "hidden",
- textOverflow: "ellipsis",
+ textOverflow: "ellipsis"
}}
>
#{tag.alias}
@@ -233,26 +233,26 @@ const formats = [
title: "PDF",
icon: Icon.PDF,
subtitle:
- "Can be opened in any PDF reader like Adobe Acrobat or Foxit Reader.",
+ "Can be opened in any PDF reader like Adobe Acrobat or Foxit Reader."
},
{
type: "md",
title: "Markdown",
icon: Icon.Markdown,
- subtitle: "Can be opened in any plain-text or markdown editor.",
+ subtitle: "Can be opened in any plain-text or markdown editor."
},
{
type: "html",
title: "HTML",
icon: Icon.HTML,
- subtitle: "Can be opened in any web browser like Google Chrome.",
+ subtitle: "Can be opened in any web browser like Google Chrome."
},
{
type: "txt",
title: "Text",
icon: Icon.Text,
- subtitle: "Can be opened in any plain-text editor.",
- },
+ subtitle: "Can be opened in any plain-text editor."
+ }
];
const notFullySyncedText =
@@ -264,13 +264,13 @@ const menuItems = [
icon: Icon.Pin,
onClick: async ({ note }) => {
await pin(note);
- },
+ }
},
{
key: "favorite",
title: ({ note }) => (note.favorite ? "Unfavorite" : "Favorite"),
icon: Icon.StarOutline,
- onClick: ({ note }) => store.favorite(note.id),
+ onClick: ({ note }) => store.favorite(note.id)
},
{
key: "addtonotebook",
@@ -279,13 +279,13 @@ const menuItems = [
onClick: async ({ items }) => {
await showMoveNoteDialog(items.map((i) => i.id));
},
- multiSelect: true,
+ multiSelect: true
},
{
key: "colors",
title: "Assign color",
icon: Icon.Colors,
- items: colorsToMenuItems(),
+ items: colorsToMenuItems()
},
{
key: "publish",
@@ -301,7 +301,7 @@ const menuItems = [
const isPublished = db.monographs.isPublished(note.id);
if (isPublished) await db.monographs.unpublish(note.id);
else await showPublishView(note.id, "bottom");
- },
+ }
},
{
key: "export",
@@ -325,10 +325,10 @@ const menuItems = [
format.type,
items.map((i) => i.id)
);
- },
+ }
})),
multiSelect: true,
- isPro: true,
+ isPro: true
},
{
key: "duplicate",
@@ -345,12 +345,12 @@ const menuItems = [
title: "Open duplicated note?",
message: "Do you want to open the duplicated note?",
noText: "No",
- yesText: "Yes",
+ yesText: "Yes"
})
) {
hashNavigate(`/notes/${id}/edit`, { replace: true });
}
- },
+ }
},
{
key: "lock",
@@ -368,7 +368,7 @@ const menuItems = [
showToast("success", "Note unlocked successfully!");
}
},
- isPro: true,
+ isPro: true
},
{
key: "sync-disable",
@@ -385,11 +385,11 @@ const menuItems = [
message:
"Turning sync off for this item will automatically delete it from all other devices. Are you sure you want to continue?",
yesText: "Yes",
- noText: "No",
+ noText: "No"
}))
)
await store.get().localOnly(note.id);
- },
+ }
},
{
key: "movetotrash",
@@ -412,8 +412,8 @@ const menuItems = [
onClick: async ({ items }) => {
await Multiselect.moveNotesToTrash(items, items.length > 1);
},
- multiSelect: true,
- },
+ multiSelect: true
+ }
];
const topicNoteMenuItems = [
@@ -442,8 +442,8 @@ const topicNoteMenuItems = [
showToast("error", `Failed to remove note from topic: ${e.message}.`);
}
},
- multiSelect: true,
- },
+ multiSelect: true
+ }
];
function colorsToMenuItems() {
@@ -460,7 +460,7 @@ function colorsToMenuItems() {
onClick: ({ note }) => {
const { id } = note;
store.setColor(id, lowercase);
- },
+ }
};
});
}
diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.js
index b997a76c3..6a31e383a 100644
--- a/apps/web/src/components/notebook/index.js
+++ b/apps/web/src/components/notebook/index.js
@@ -66,7 +66,7 @@ function Notebook(props) {
•
</Text>
{new Date(date).toLocaleDateString("en", {
- dateStyle: "medium",
+ dateStyle: "medium"
})}
<Text as="span" mx={1}>
•
@@ -107,20 +107,20 @@ const menuItems = [
key: "edit",
title: "Edit",
icon: Icon.NotebookEdit,
- onClick: ({ notebook }) => hashNavigate(`/notebooks/${notebook.id}/edit`),
+ onClick: ({ notebook }) => hashNavigate(`/notebooks/${notebook.id}/edit`)
},
{
key: "pin",
icon: Icon.Pin,
title: ({ notebook }) => (notebook.pinned ? "Unpin" : "Pin"),
- onClick: ({ notebook }) => pin(notebook),
+ onClick: ({ notebook }) => pin(notebook)
},
{
key: "shortcut",
icon: Icon.Shortcut,
title: ({ notebook }) =>
db.settings.isPinned(notebook.id) ? "Remove shortcut" : "Create shortcut",
- onClick: ({ notebook }) => appStore.pinItemToMenu(notebook),
+ onClick: ({ notebook }) => appStore.pinItemToMenu(notebook)
},
{
key: "movetotrash",
@@ -131,6 +131,6 @@ const menuItems = [
onClick: async ({ items }) => {
await Multiselect.moveNotebooksToTrash(items);
},
- multiSelect: true,
- },
+ multiSelect: true
+ }
];
diff --git a/apps/web/src/components/placeholders/loader.js b/apps/web/src/components/placeholders/loader.js
index 44c237125..e6710aa6c 100644
--- a/apps/web/src/components/placeholders/loader.js
+++ b/apps/web/src/components/placeholders/loader.js
@@ -17,7 +17,7 @@ const Placeholders = {
tag: Tag,
trash: Trash,
favorites: Fav,
- attachments: Attachment,
+ attachments: Attachment
};
export default function PlaceholderLoader({ name, onLoad, ...restProps }) {
diff --git a/apps/web/src/components/placeholders/notebooks-placeholder.js b/apps/web/src/components/placeholders/notebooks-placeholder.js
index 10c362b38..63e623195 100644
--- a/apps/web/src/components/placeholders/notebooks-placeholder.js
+++ b/apps/web/src/components/placeholders/notebooks-placeholder.js
@@ -12,7 +12,7 @@ function NotebooksPlaceholder() {
callToAction={{
text: "Make your first notebook",
icon: Plus,
- onClick: () => hashNavigate("/notebooks/create"),
+ onClick: () => hashNavigate("/notebooks/create")
}}
/>
);
diff --git a/apps/web/src/components/placeholders/notesplacholder.js b/apps/web/src/components/placeholders/notesplacholder.js
index b79903672..e04e5f870 100644
--- a/apps/web/src/components/placeholders/notesplacholder.js
+++ b/apps/web/src/components/placeholders/notesplacholder.js
@@ -12,7 +12,7 @@ function NotesPlaceholder() {
text: "Make your first note",
icon: Icon.Plus,
onClick: () =>
- hashNavigate("/notes/create", { replace: true, addNonce: true }),
+ hashNavigate("/notes/create", { replace: true, addNonce: true })
}}
/>
);
diff --git a/apps/web/src/components/placeholders/topics-placeholder.js b/apps/web/src/components/placeholders/topics-placeholder.js
index 8e5e11de3..03eb1f954 100644
--- a/apps/web/src/components/placeholders/topics-placeholder.js
+++ b/apps/web/src/components/placeholders/topics-placeholder.js
@@ -10,7 +10,7 @@ function TopicsPlaceholder() {
callToAction={{
text: "Add a topic",
icon: Plus,
- onClick: () => hashNavigate("/topics/create"),
+ onClick: () => hashNavigate("/topics/create")
}}
/>
);
diff --git a/apps/web/src/components/properties/index.js b/apps/web/src/components/properties/index.js
index 37723b5f6..7a13914c4 100644
--- a/apps/web/src/components/properties/index.js
+++ b/apps/web/src/components/properties/index.js
@@ -24,24 +24,24 @@ const tools = [
{
key: "favorite",
icon: Icon.StarOutline,
- label: "Favorite",
+ label: "Favorite"
},
{ key: "locked", icon: Icon.Unlock, label: "Lock" },
{ key: "readonly", icon: Icon.Readonly, label: "Readonly" },
- { key: "localOnly", icon: Icon.SyncOff, label: "Disable sync" },
+ { key: "localOnly", icon: Icon.SyncOff, label: "Disable sync" }
];
const metadataItems = [
{
key: "dateCreated",
label: "Created at",
- value: (date) => formatDate(date || Date.now()),
+ value: (date) => formatDate(date || Date.now())
},
{
key: "dateEdited",
label: "Last edited at",
- value: (date) => (date ? formatDate(date) : "never"),
- },
+ value: (date) => (date ? formatDate(date) : "never")
+ }
];
function Properties(props) {
@@ -94,13 +94,13 @@ function Properties(props) {
<>
<AnimatedFlex
animate={{
- x: 0,
+ x: 0
}}
transition={{
duration: 0.3,
bounceDamping: 1,
bounceStiffness: 1,
- ease: "easeOut",
+ ease: "easeOut"
}}
initial={{ x: 800 }}
sx={{
@@ -113,7 +113,7 @@ function Properties(props) {
borderLeft: "1px solid",
borderLeftColor: "border",
overflowY: "hidden",
- overflowX: "hidden",
+ overflowX: "hidden"
}}
flexDirection="column"
bg="background"
@@ -152,7 +152,7 @@ function Properties(props) {
py={2}
px={2}
sx={{
- borderBottom: "1px solid var(--border)",
+ borderBottom: "1px solid var(--border)"
}}
>
<Text variant="body" color="fontTertiary">
@@ -173,7 +173,7 @@ function Properties(props) {
py={2}
px={2}
sx={{
- cursor: "pointer",
+ cursor: "pointer"
}}
justifyContent="center"
>
@@ -185,7 +185,7 @@ function Properties(props) {
onClick={() => noteStore.get().setColor(sessionId, label)}
sx={{
cursor: "pointer",
- position: "relative",
+ position: "relative"
}}
data-test-id={`properties-${label}`}
>
@@ -225,8 +225,8 @@ function Properties(props) {
":last-of-type": { borderBottom: "none" },
cursor: "pointer",
":hover": {
- bg: "hover",
- },
+ bg: "hover"
+ }
}}
flexDirection="column"
onClick={() => {
@@ -240,7 +240,7 @@ function Properties(props) {
<Flex
sx={{
- flexWrap: "wrap",
+ flexWrap: "wrap"
}}
mt={1}
>
@@ -287,16 +287,16 @@ function Properties(props) {
>
{versionHistory.map((session, index) => {
const fromDate = formatDate(session.dateCreated, {
- dateStyle: "short",
+ dateStyle: "short"
});
const toDate = formatDate(session.dateModified, {
- dateStyle: "short",
+ dateStyle: "short"
});
const fromTime = formatDate(session.dateCreated, {
- timeStyle: "short",
+ timeStyle: "short"
});
const toTime = formatDate(session.dateModified, {
- timeStyle: "short",
+ timeStyle: "short"
});
const label = `${fromDate}, ${fromTime} — ${
fromDate !== toDate ? `${toDate}, ` : ""
@@ -314,8 +314,8 @@ function Properties(props) {
cursor: "pointer",
bg: isSelected ? "bgSecondary" : "transparent",
":hover": {
- bg: "hover",
- },
+ bg: "hover"
+ }
}}
justifyContent={"space-between"}
alignItems={"center"}
@@ -332,7 +332,7 @@ function Properties(props) {
onOpenPreviewSession({
content: decryptedContent,
dateCreated: session.dateCreated,
- dateEdited: session.dateModified,
+ dateEdited: session.dateModified
});
return true;
} catch (e) {
@@ -343,7 +343,7 @@ function Properties(props) {
onOpenPreviewSession({
content,
dateCreated: session.dateCreated,
- dateEdited: session.dateModified,
+ dateEdited: session.dateModified
});
}
}}
@@ -373,7 +373,7 @@ function Card({ title, subtitle, button, children }) {
<Flex
flexDirection="column"
sx={{
- borderRadius: "default",
+ borderRadius: "default"
}}
>
<Flex mx={2} mt={2} alignItems="center">
diff --git a/apps/web/src/components/properties/toggle.js b/apps/web/src/components/properties/toggle.js
index aecb1a3eb..f323a987a 100644
--- a/apps/web/src/components/properties/toggle.js
+++ b/apps/web/src/components/properties/toggle.js
@@ -13,7 +13,7 @@ function Toggle(props) {
px={2}
sx={{
borderBottom: "1px solid var(--border)",
- cursor: "pointer",
+ cursor: "pointer"
}}
onClick={() => onToggle(!isOn)}
data-test-id={props.testId}
diff --git a/apps/web/src/components/publish-view/index.js b/apps/web/src/components/publish-view/index.js
index 0909df120..e81739da0 100644
--- a/apps/web/src/components/publish-view/index.js
+++ b/apps/web/src/components/publish-view/index.js
@@ -65,7 +65,7 @@ function PublishView(props) {
borderColor: "border",
borderRadius: "default",
boxShadow: "0px 0px 15px 0px #00000011",
- ...position,
+ ...position
}}
bg="background"
// p={2}
@@ -107,7 +107,7 @@ function PublishView(props) {
p: 1,
borderRadius: "default",
alignItems: "center",
- justifyContent: "center",
+ justifyContent: "center"
}}
>
<Text
@@ -120,7 +120,7 @@ function PublishView(props) {
whiteSpace: "nowrap",
textDecoration: "none",
overflow: "hidden",
- mr: 2,
+ mr: 2
}}
>
{`https://monograph.notesnook.com/${publishId}`}
@@ -185,7 +185,7 @@ function PublishView(props) {
fontWeight="bold"
bg={"transparent"}
sx={{
- ":hover": { bg: "bgSecondary" },
+ ":hover": { bg: "bgSecondary" }
}}
onClick={async () => {
try {
@@ -195,7 +195,7 @@ function PublishView(props) {
const publishId = await publishNote(noteId, {
selfDestruct,
- password,
+ password
});
setPublishId(publishId);
showToast("success", "Note published.");
@@ -224,7 +224,7 @@ function PublishView(props) {
fontWeight="bold"
bg={"transparent"}
sx={{
- ":hover": { bg: "bgSecondary" },
+ ":hover": { bg: "bgSecondary" }
}}
onClick={async () => {
try {
@@ -255,7 +255,7 @@ function PublishView(props) {
fontWeight="bold"
bg={"transparent"}
sx={{
- ":hover": { bg: "bgSecondary" },
+ ":hover": { bg: "bgSecondary" }
}}
onClick={() => {
onClose(false);
@@ -287,7 +287,7 @@ export function showPublishView(noteId, location = "top") {
top: location === "top" ? [0, 50, 60] : undefined,
right: location === "top" ? [0, 20, 10] : undefined,
bottom: location === "bottom" ? 0 : undefined,
- left: location === "bottom" ? 0 : undefined,
+ left: location === "bottom" ? 0 : undefined
}}
onClose={perform}
/>
diff --git a/apps/web/src/components/reminder-bar/index.js b/apps/web/src/components/reminder-bar/index.js
index 735b8996c..daa55f15f 100644
--- a/apps/web/src/components/reminder-bar/index.js
+++ b/apps/web/src/components/reminder-bar/index.js
@@ -24,7 +24,7 @@ function ReminderBar() {
sx={{
cursor: "pointer",
borderRadius: "default",
- ":hover": { bg: "hover" },
+ ":hover": { bg: "hover" }
}}
p={1}
onClick={reminder?.action}
@@ -62,7 +62,7 @@ function ReminderBar() {
p: 1,
mr: 1,
bg: "transparent",
- ":hover": { backgroundColor: "shade" },
+ ":hover": { backgroundColor: "shade" }
}}
variant="tool"
>
diff --git a/apps/web/src/components/route-container/index.js b/apps/web/src/components/route-container/index.js
index 591c50cf3..8a998067a 100644
--- a/apps/web/src/components/route-container/index.js
+++ b/apps/web/src/components/route-container/index.js
@@ -16,7 +16,7 @@ function RouteContainer(props) {
onChange,
subtitle,
buttons,
- component,
+ component
} = props;
return (
<>
@@ -63,7 +63,7 @@ function Header(props) {
ml: 0,
mr: 4,
mt: 1,
- display: ["block", "none", "none"],
+ display: ["block", "none", "none"]
}}
size={30}
/>
@@ -96,7 +96,7 @@ function Header(props) {
ml: 2,
borderRadius: 100,
size: 28,
- ":hover": { boxShadow: "0px 0px 5px 0px var(--dimPrimary)" },
+ ":hover": { boxShadow: "0px 0px 5px 0px var(--dimPrimary)" }
}}
title={createButtonData.title}
onClick={createButtonData.onClick}
@@ -137,7 +137,7 @@ function RouteTitle({ title, subtitle, isEditable, onChange }) {
border: "none",
bg: isEditing ? "bgSecondary" : "transparent",
- ":focus-visible": { outline: "none" },
+ ":focus-visible": { outline: "none" }
}}
onDoubleClick={(e) => {
setIsEditing(isEditable && true);
diff --git a/apps/web/src/components/scroll-container/index.js b/apps/web/src/components/scroll-container/index.js
index 04ed8c3c6..d559b9d2a 100644
--- a/apps/web/src/components/scroll-container/index.js
+++ b/apps/web/src/components/scroll-container/index.js
@@ -33,7 +33,7 @@ const ScrollContainer = ({ children, style, forwardedRef, ...props }) => {
{...props}
style={{
...style,
- backgroundColor: "var(--bgSecondaryText)",
+ backgroundColor: "var(--bgSecondaryText)"
}}
/>
)}
@@ -62,7 +62,7 @@ export function FlexScrollContainer({
display: "flex",
flexDirection: "column",
flex: "1 1 auto",
- ...style,
+ ...style
}}
renderView={({ style, ...props }) => (
<Box
@@ -72,12 +72,12 @@ export function FlexScrollContainer({
overflow: "auto",
position: "relative",
flex: "1 1 auto",
- ...viewStyle,
+ ...viewStyle
}}
sx={{
scrollbarWidth: "none",
"::-webkit-scrollbar": { width: 0, height: 0 },
- msOverflowStyle: "none",
+ msOverflowStyle: "none"
}}
/>
)}
@@ -86,7 +86,7 @@ export function FlexScrollContainer({
{...props}
style={{
...style,
- backgroundColor: "var(--bgSecondaryText)",
+ backgroundColor: "var(--bgSecondaryText)"
}}
/>
)}
diff --git a/apps/web/src/components/search/index.js b/apps/web/src/components/search/index.js
index 811d368e5..39d5fa533 100644
--- a/apps/web/src/components/search/index.js
+++ b/apps/web/src/components/search/index.js
@@ -22,7 +22,7 @@ function SearchBox(props) {
if (searchField && searchField.value && searchField.value.length) {
props.onSearch(searchField.value);
}
- },
+ }
}}
/>
);
diff --git a/apps/web/src/components/status-bar/index.js b/apps/web/src/components/status-bar/index.js
index f7cfa8e1a..bfdb320d9 100644
--- a/apps/web/src/components/status-bar/index.js
+++ b/apps/web/src/components/status-bar/index.js
@@ -8,7 +8,7 @@ import {
SyncError,
Checkmark,
Alert,
- Issue,
+ Issue
} from "../icons";
import { useStore as useUserStore } from "../../stores/user-store";
import { useStore as useAppStore } from "../../stores/app-store";
@@ -19,7 +19,7 @@ import installUpdate from "../../commands/install-update";
import checkForUpdate from "../../commands/check-for-update";
import {
showIssueDialog,
- showUpdateAvailableNotice,
+ showUpdateAvailableNotice
} from "../../common/dialog-controller";
import useStatus from "../../hooks/use-status";
import { getIconFromAlias } from "../icons/resolver";
@@ -215,7 +215,7 @@ const syncStatusFilters = [
) : (
"click to sync"
),
- tooltip: "All changes are synced.",
+ tooltip: "All changes are synced."
},
{
key: "syncing",
@@ -223,14 +223,14 @@ const syncStatusFilters = [
icon: Sync,
loading: true,
text: ({ syncStatus }) => <>{syncStatus.type || "sync"}ing</>,
- tooltip: "Syncing your notes...",
+ tooltip: "Syncing your notes..."
},
{
key: "completed",
check: (syncStatus) => syncStatus === "completed",
icon: Checkmark,
iconColor: "success",
- text: "",
+ text: ""
},
{
key: "conflicts",
@@ -238,7 +238,7 @@ const syncStatusFilters = [
icon: Alert,
iconColor: "error",
text: "Merge conflicts",
- tooltip: "Please resolve all merge conflicts and run the sync again.",
+ tooltip: "Please resolve all merge conflicts and run the sync again."
},
{
key: "emailNotConfirmed",
@@ -246,7 +246,7 @@ const syncStatusFilters = [
icon: Alert,
iconColor: "warn",
text: "Sync disabled",
- tooltip: "Please confirm your email to start syncing.",
+ tooltip: "Please confirm your email to start syncing."
},
{
key: "failed",
@@ -254,6 +254,6 @@ const syncStatusFilters = [
icon: SyncError,
color: "error",
text: "Sync failed",
- tooltip: "Sync failed to completed. Please try again.",
- },
+ tooltip: "Sync failed to completed. Please try again."
+ }
];
diff --git a/apps/web/src/components/tag/index.js b/apps/web/src/components/tag/index.js
index 5ec83fd71..bb52de61b 100644
--- a/apps/web/src/components/tag/index.js
+++ b/apps/web/src/components/tag/index.js
@@ -16,14 +16,14 @@ const menuItems = [
icon: Icon.Edit,
onClick: ({ tag }) => {
hashNavigate(`/tags/${tag.id}/edit`);
- },
+ }
},
{
key: "shortcut",
title: ({ tag }) =>
db.settings.isPinned(tag.id) ? "Remove shortcut" : "Create shortcut",
icon: Icon.Shortcut,
- onClick: ({ tag }) => appStore.pinItemToMenu(tag),
+ onClick: ({ tag }) => appStore.pinItemToMenu(tag)
},
{
key: "delete",
@@ -40,8 +40,8 @@ const menuItems = [
showToast("success", `${items.length} tags deleted`);
tagStore.refresh();
},
- multiSelect: true,
- },
+ multiSelect: true
+ }
];
function Tag({ item, index }) {
diff --git a/apps/web/src/components/time-ago/index.js b/apps/web/src/components/time-ago/index.js
index cad968c34..bbb1ed564 100644
--- a/apps/web/src/components/time-ago/index.js
+++ b/apps/web/src/components/time-ago/index.js
@@ -17,7 +17,7 @@ const shortLocale = [
["1mo", "in 1mo"],
["%smo", "in %smo"],
["1yr", "in 1yr"],
- ["%syr", "in %syr"],
+ ["%syr", "in %syr"]
];
const enShortLocale = [
@@ -34,7 +34,7 @@ const enShortLocale = [
["1mo ago", "in 1mo"],
["%smo ago", "in %smo"],
["1yr ago", "in 1yr"],
- ["%syr ago", "in %syr"],
+ ["%syr ago", "in %syr"]
];
register("short", (_n, index) => shortLocale[index]);
register("en_short", (_n, index) => enShortLocale[index]);
diff --git a/apps/web/src/components/toggle/index.js b/apps/web/src/components/toggle/index.js
index e99604ee5..537538516 100644
--- a/apps/web/src/components/toggle/index.js
+++ b/apps/web/src/components/toggle/index.js
@@ -25,7 +25,7 @@ function Toggle(props) {
cursor: "pointer",
borderBottom: "1px solid",
borderBottomColor: "border",
- ":hover": { borderBottomColor: "primary" },
+ ":hover": { borderBottomColor: "primary" }
}}
>
<Tip text={title} tip={isToggled ? onTip : offTip} sx={{ mr: 2 }} />
diff --git a/apps/web/src/components/topic/index.js b/apps/web/src/components/topic/index.js
index 9af6537c0..7354f29e2 100644
--- a/apps/web/src/components/topic/index.js
+++ b/apps/web/src/components/topic/index.js
@@ -35,7 +35,7 @@ function Topic({ item, index, onClick }) {
index={index}
menu={{
items: menuItems,
- extraData: { topic, notebookId: topic.notebookId },
+ extraData: { topic, notebookId: topic.notebookId }
}}
/>
);
@@ -54,14 +54,14 @@ const menuItems = [
title: "Edit",
icon: Icon.Edit,
onClick: ({ topic }) =>
- hashNavigate(`/notebooks/${topic.notebookId}/topics/${topic.id}/edit`),
+ hashNavigate(`/notebooks/${topic.notebookId}/topics/${topic.id}/edit`)
},
{
key: "shortcut",
title: ({ topic }) =>
db.settings.isPinned(topic.id) ? "Remove shortcut" : "Create shortcut",
icon: Icon.Shortcut,
- onClick: ({ topic }) => appStore.pinItemToMenu(topic),
+ onClick: ({ topic }) => appStore.pinItemToMenu(topic)
},
{
key: "delete",
@@ -72,6 +72,6 @@ const menuItems = [
onClick: async ({ items, notebookId }) => {
await Multiselect.deleteTopics(notebookId, items);
},
- multiSelect: true,
- },
+ multiSelect: true
+ }
];
diff --git a/apps/web/src/components/trash-item/index.js b/apps/web/src/components/trash-item/index.js
index 4f4e9c5be..1ba2989cc 100644
--- a/apps/web/src/components/trash-item/index.js
+++ b/apps/web/src/components/trash-item/index.js
@@ -41,7 +41,7 @@ const menuItems = [
store.restore(items.map((i) => i.id));
showToast("success", `${items.length} items restored`);
},
- multiSelect: true,
+ multiSelect: true
},
{
key: "delete",
@@ -59,6 +59,6 @@ const menuItems = [
() => store.refresh()
);
},
- multiSelect: true,
- },
+ multiSelect: true
+ }
];
diff --git a/apps/web/src/components/unlock/index.js b/apps/web/src/components/unlock/index.js
index ff5a87d0b..f56e2cb3b 100644
--- a/apps/web/src/components/unlock/index.js
+++ b/apps/web/src/components/unlock/index.js
@@ -3,7 +3,7 @@ import React, {
useState,
useCallback,
useEffect,
- useMemo,
+ useMemo
} from "react";
import { Flex, Text, Button } from "rebass";
import * as Icon from "../icons";
diff --git a/apps/web/src/hooks/use-auto-updater.js b/apps/web/src/hooks/use-auto-updater.js
index 8e4d5e9b7..599d7a853 100644
--- a/apps/web/src/hooks/use-auto-updater.js
+++ b/apps/web/src/hooks/use-auto-updater.js
@@ -3,7 +3,7 @@ import { AppEventManager } from "../common/app-events";
import { EVENTS } from "@notesnook/desktop/events";
import {
showUpdateAvailableNotice,
- showUpdateReadyNotice,
+ showUpdateReadyNotice
} from "../common/dialog-controller";
import checkForUpdate from "../commands/check-for-update";
import { isDesktop } from "../utils/platform";
@@ -29,11 +29,11 @@ export default function useAutoUpdater() {
changeStatus({
type: "available",
version: info.version,
- changelog: info.releaseNotes,
+ changelog: info.releaseNotes
});
showUpdateAvailableNotice({
changelog: info.releaseNotes,
- version: info.version,
+ version: info.version
});
}
diff --git a/apps/web/src/hooks/use-database.js b/apps/web/src/hooks/use-database.js
index 457f08723..bcb5f5723 100644
--- a/apps/web/src/hooks/use-database.js
+++ b/apps/web/src/hooks/use-database.js
@@ -8,7 +8,7 @@ if (process.env.NODE_ENV === "production") {
}
const memory = {
- isAppLoaded: false,
+ isAppLoaded: false
};
export default function useDatabase(persistence) {
const [isAppLoaded, setIsAppLoaded] = useState(memory.isAppLoaded);
diff --git a/apps/web/src/hooks/use-hash-location.ts b/apps/web/src/hooks/use-hash-location.ts
index f5e320cdf..9e0c1ee80 100644
--- a/apps/web/src/hooks/use-hash-location.ts
+++ b/apps/web/src/hooks/use-hash-location.ts
@@ -21,7 +21,7 @@ type HashLocation = { location: string; update: boolean };
export default function useHashLocation() {
const [loc, setLoc] = useState<HashLocation>({
location: currentLocation(),
- update: true,
+ update: true
});
const [queryParams, setQueryParams] = useState(currentQuery());
@@ -32,7 +32,7 @@ export default function useHashLocation() {
console.log(currentLocation());
setLoc({
location: currentLocation(),
- update,
+ update
});
setQueryParams(currentQuery());
};
diff --git a/apps/web/src/hooks/use-is-user-premium.js b/apps/web/src/hooks/use-is-user-premium.js
index a23c52af4..1e518f408 100644
--- a/apps/web/src/hooks/use-is-user-premium.js
+++ b/apps/web/src/hooks/use-is-user-premium.js
@@ -1,7 +1,7 @@
import { SUBSCRIPTION_STATUS } from "../common/constants";
import {
useStore as useUserStore,
- store as userstore,
+ store as userstore
} from "../stores/user-store";
export function useIsUserPremium() {
diff --git a/apps/web/src/hooks/use-menu.js b/apps/web/src/hooks/use-menu.js
index 9338e9998..ea5e34310 100644
--- a/apps/web/src/hooks/use-menu.js
+++ b/apps/web/src/hooks/use-menu.js
@@ -23,8 +23,8 @@ const useMenuStore = create((set) => ({
isOpen: false,
items: [],
data: undefined,
- title: undefined,
- })),
+ title: undefined
+ }))
}));
export function useMenuTrigger() {
@@ -39,7 +39,7 @@ export function useMenuTrigger() {
openMenu: open,
closeMenu: close,
isOpen,
- target,
+ target
};
}
@@ -60,7 +60,7 @@ export function getPosition(element, positionOptions) {
relativeTo = "mouse",
absolute = false,
location = undefined,
- yOffset = 0,
+ yOffset = 0
} = positionOptions || {};
const { x, y, width, height, actualX, actualY } =
@@ -130,7 +130,7 @@ function getMousePosition(e) {
x: posx,
y: posy,
actualY: posy,
- actualX: posx,
+ actualX: posx
};
}
@@ -146,7 +146,7 @@ function getElementPosition(element, absolute) {
width: rect.width,
height: rect.height,
actualY: rect.y,
- actualX: rect.x,
+ actualX: rect.x
};
if (absolute) {
position.x = position.actualX;
@@ -168,7 +168,7 @@ function mapMenuItems(items, data) {
isNew,
type,
iconColor,
- modifier,
+ modifier
} = item;
const isHidden = hidden && hidden(data, item);
@@ -210,7 +210,7 @@ function mapMenuItems(items, data) {
color,
iconColor,
- modifier: modifier?.join("+"),
+ modifier: modifier?.join("+")
};
if (hasSubmenu)
diff --git a/apps/web/src/hooks/use-session-state.ts b/apps/web/src/hooks/use-session-state.ts
index 506baecfb..ee1a9ec1e 100644
--- a/apps/web/src/hooks/use-session-state.ts
+++ b/apps/web/src/hooks/use-session-state.ts
@@ -12,6 +12,6 @@ export function useSessionState<T>(key: string, def: T) {
return [
value as T,
- setValue as React.Dispatch<React.SetStateAction<T>>,
+ setValue as React.Dispatch<React.SetStateAction<T>>
] as const;
}
diff --git a/apps/web/src/hooks/use-slider.js b/apps/web/src/hooks/use-slider.js
index 3ff045fbf..8c186a2f8 100644
--- a/apps/web/src/hooks/use-slider.js
+++ b/apps/web/src/hooks/use-slider.js
@@ -16,7 +16,7 @@ export default function useSlider(sliderId, { onSliding, onChange }) {
index: slides.length,
node,
offset: last,
- width: node.scrollWidth,
+ width: node.scrollWidth
});
last += node.scrollWidth;
}
diff --git a/apps/web/src/hooks/use-status.ts b/apps/web/src/hooks/use-status.ts
index 00af90693..eb0a2c637 100644
--- a/apps/web/src/hooks/use-status.ts
+++ b/apps/web/src/hooks/use-status.ts
@@ -32,7 +32,7 @@ const useStatusStore = create<IStatusStore>((set, get) => ({
if (!key || !statuses[key]) return;
delete statuses[key];
})
- ),
+ )
}));
export default function useStatus() {
diff --git a/apps/web/src/index.tsx b/apps/web/src/index.tsx
index cebcd9f0e..ec5913edb 100644
--- a/apps/web/src/index.tsx
+++ b/apps/web/src/index.tsx
@@ -36,43 +36,43 @@ type Routes =
const routes: Record<Routes, Route> = {
"/account/recovery": {
component: () => import("./views/recovery"),
- props: { route: "methods" },
+ props: { route: "methods" }
},
"/account/verified": {
component: () => import("./views/email-confirmed"),
- props: {},
+ props: {}
},
"/signup": {
component: () => import("./views/auth"),
- props: { route: "signup" },
+ props: { route: "signup" }
},
"/sessionexpired": {
component: () => import("./views/auth"),
- props: { route: "sessionExpiry" },
+ props: { route: "sessionExpiry" }
},
"/login": {
component: () => import("./views/auth"),
- props: { route: "login" },
+ props: { route: "login" }
},
"/recover": {
component: () => import("./views/auth"),
- props: { route: "recover" },
+ props: { route: "recover" }
},
"/mfa/code": {
component: () => import("./views/auth"),
- props: { route: "login" },
+ props: { route: "login" }
},
"/mfa/select": {
component: () => import("./views/auth"),
- props: { route: "login" },
+ props: { route: "login" }
},
- default: { component: () => import("./app"), props: {} },
+ default: { component: () => import("./app"), props: {} }
};
const sessionExpiryExceptions: Routes[] = [
"/recover",
"/account/recovery",
- "/sessionexpired",
+ "/sessionexpired"
];
const serviceWorkerWhitelist: Routes[] = ["default"];
@@ -131,7 +131,7 @@ if (process.env.NODE_ENV === "development") {
async function renderApp() {
const {
path,
- route: { component, props },
+ route: { component, props }
} = getRoute();
if (serviceWorkerWhitelist.includes(path)) await initializeServiceWorker();
@@ -162,9 +162,9 @@ async function initializeServiceWorker() {
registration.waiting
);
AppEventManager.publish(EVENTS.updateDownloadCompleted, {
- version: formatted,
+ version: formatted
});
- },
+ }
});
// window.addEventListener("beforeinstallprompt", () => showInstallNotice());
} else serviceWorker.unregister();
diff --git a/apps/web/src/interfaces/fs.js b/apps/web/src/interfaces/fs.js
index cdf0a24ad..e5779f56d 100644
--- a/apps/web/src/interfaces/fs.js
+++ b/apps/web/src/interfaces/fs.js
@@ -50,7 +50,7 @@ async function writeEncryptedFile(file, key, hash) {
const isFinal = offset === file.size;
return {
final: isFinal,
- data: chunk,
+ data: chunk
};
},
write: async (chunk) => {
@@ -60,7 +60,7 @@ async function writeEncryptedFile(file, key, hash) {
{ type: "encrypt", hash }
);
await fileHandle.write(chunk.data);
- },
+ }
},
file.name
);
@@ -72,7 +72,7 @@ async function writeEncryptedFile(file, key, hash) {
iv: iv,
length: file.size,
salt: key.salt,
- alg: "xcha-stream",
+ alg: "xcha-stream"
};
}
@@ -90,14 +90,14 @@ async function writeEncrypted(filename, { data, type, key }) {
if (!filename) filename = hash;
const file = new File([data.buffer], filename, {
- type: "application/octet-stream",
+ type: "application/octet-stream"
});
const result = await writeEncryptedFile(file, key, hash);
return {
...result,
hash,
- hashType,
+ hashType
};
}
@@ -109,7 +109,7 @@ async function writeEncrypted(filename, { data, type, key }) {
async function hashBuffer(data) {
return {
hash: await xxhash64(data),
- type: "xxh64",
+ type: "xxh64"
};
}
@@ -154,7 +154,7 @@ async function readEncrypted(filename, key, cipherData) {
write: async (chunk) => {
plainText.set(chunk.data, offset);
offset += chunk.data.length;
- },
+ }
},
filename
);
@@ -176,7 +176,7 @@ async function uploadFile(filename, requestOptions) {
uploadedChunks = [],
uploadedBytes = 0,
uploaded = false,
- uploadId = "",
+ uploadId = ""
} = fileHandle.file.additionalData || {};
try {
@@ -192,7 +192,7 @@ async function uploadFile(filename, requestOptions) {
`${hosts.API_HOST}/s3/multipart?name=${filename}&parts=${TOTAL_PARTS}&uploadId=${uploadId}`,
{
headers,
- cancelToken: cancellationToken,
+ cancelToken: cancellationToken
}
)
.catch((e) => {
@@ -208,11 +208,11 @@ async function uploadFile(filename, requestOptions) {
reportProgress(
{
total: fileHandle.file.size + ABYTES,
- loaded: uploadedBytes + ev.loaded,
+ loaded: uploadedBytes + ev.loaded
},
{
type: "upload",
- hash: filename,
+ hash: filename
}
);
}
@@ -231,7 +231,7 @@ async function uploadFile(filename, requestOptions) {
headers: { "Content-Type": "" },
cancelToken: cancellationToken,
data,
- onUploadProgress,
+ onUploadProgress
})
.catch((e) => {
throw new S3Error(`Failed to upload part at offset ${i}`, e);
@@ -243,7 +243,7 @@ async function uploadFile(filename, requestOptions) {
uploadedBytes += blob.size;
uploadedChunks.push({
PartNumber: i + 1,
- ETag: JSON.parse(response.headers.etag),
+ ETag: JSON.parse(response.headers.etag)
});
await fileHandle.addAdditionalData("uploadedChunks", uploadedChunks);
await fileHandle.addAdditionalData("uploadedBytes", uploadedBytes);
@@ -255,11 +255,11 @@ async function uploadFile(filename, requestOptions) {
{
Key: filename,
UploadId: uploadId,
- PartETags: uploadedChunks,
+ PartETags: uploadedChunks
},
{
headers,
- cancelToken: cancellationToken,
+ cancelToken: cancellationToken
}
)
.catch((e) => {
@@ -294,7 +294,7 @@ function reportProgress(ev, { type, hash }) {
type,
hash,
total: ev?.total || 1,
- loaded: ev?.loaded || 1,
+ loaded: ev?.loaded || 1
});
}
@@ -310,7 +310,7 @@ async function downloadFile(filename, requestOptions) {
const signedUrlResponse = await axios.get(url, {
headers,
- responseType: "text",
+ responseType: "text"
});
const signedUrl = signedUrlResponse.data;
@@ -318,7 +318,7 @@ async function downloadFile(filename, requestOptions) {
responseType: "arraybuffer",
cancelToken: cancellationToken,
onDownloadProgress: (ev) =>
- reportProgress(ev, { type: "download", hash: filename }),
+ reportProgress(ev, { type: "download", hash: filename })
});
const contentType = response.headers["content-type"];
@@ -384,7 +384,7 @@ async function saveFile(filename, fileMetadata) {
},
write: async (chunk) => {
blobParts.push(chunk.data);
- },
+ }
},
filename
);
@@ -400,7 +400,7 @@ async function deleteFile(filename, requestOptions) {
try {
const { url, headers } = requestOptions;
const response = await axios.delete(url, {
- headers: headers,
+ headers: headers
});
const result = isSuccessStatusCode(response.status);
@@ -418,7 +418,7 @@ async function getUploadedFileSize(filename) {
const token = await db.user.tokenManager.getAccessToken();
const attachmentInfo = await axios.head(url, {
- headers: { Authorization: `Bearer ${token}` },
+ headers: { Authorization: `Bearer ${token}` }
});
const contentLength = parseInt(attachmentInfo.headers["content-length"]);
@@ -445,7 +445,7 @@ const FS = {
hashStream,
writeEncryptedFile,
clearFileStorage,
- getUploadedFileSize,
+ getUploadedFileSize
};
export default FS;
@@ -461,7 +461,7 @@ function cancellable(operation) {
execute: () => operation(filename, requestOptions),
cancel: (message) => {
source.cancel(message);
- },
+ }
};
};
}
diff --git a/apps/web/src/interfaces/storage.ts b/apps/web/src/interfaces/storage.ts
index a650436c1..84dad5962 100644
--- a/apps/web/src/interfaces/storage.ts
+++ b/apps/web/src/interfaces/storage.ts
@@ -21,7 +21,7 @@ export class NNStorage {
: [localforage.INDEXEDDB, localforage.WEBSQL, localforage.LOCALSTORAGE];
this.database = localforage.createInstance({
name,
- driver: drivers,
+ driver: drivers
});
}
@@ -139,7 +139,7 @@ async function derivePBKDF2Key(password: string): Promise<CryptoKey> {
name: "PBKDF2",
salt,
iterations: 100000,
- hash: "SHA-256",
+ hash: "SHA-256"
},
key,
{ name: "AES-GCM", length: 256 },
@@ -157,7 +157,7 @@ async function aesEncrypt(
const cipher = await window.crypto.subtle.encrypt(
{
name: "AES-GCM",
- iv: iv,
+ iv: iv
},
cryptoKey,
enc.encode(data)
@@ -165,7 +165,7 @@ async function aesEncrypt(
return {
iv,
- cipher,
+ cipher
};
}
@@ -178,7 +178,7 @@ async function aesDecrypt(
const plainText = await window.crypto.subtle.decrypt(
{
name: "AES-GCM",
- iv: iv,
+ iv: iv
},
cryptoKey,
cipher
diff --git a/apps/web/src/navigation/hash-routes.js b/apps/web/src/navigation/hash-routes.js
index f49f30f29..b688346a0 100644
--- a/apps/web/src/navigation/hash-routes.js
+++ b/apps/web/src/navigation/hash-routes.js
@@ -5,11 +5,11 @@ import {
showEditTagDialog,
showEmailVerificationDialog,
showFeatureDialog,
- showOnboardingDialog,
+ showOnboardingDialog
} from "../common/dialog-controller";
import {
showAddNotebookDialog,
- showEditNotebookDialog,
+ showEditNotebookDialog
} from "../common/dialog-controller";
import { closeOpenedDialog } from "../common/dialog-controller";
import RouteContainer from "../components/route-container";
@@ -20,7 +20,7 @@ import { store as editorStore } from "../stores/editor-store";
import { isMobile } from "../utils/dimensions";
import {
showEditTopicDialog,
- showCreateTopicDialog,
+ showCreateTopicDialog
} from "../common/dialog-controller";
import { hashNavigate } from ".";
import EditorPlaceholder from "../components/editor/-placeholder";
@@ -75,10 +75,10 @@ const hashroutes = {
action: () =>
hashNavigate("/notes/create", {
addNonce: true,
- replace: true,
- }),
+ replace: true
+ })
}
- : undefined,
+ : undefined
}}
component={<Unlock noteId={noteId} />}
/>
@@ -110,7 +110,7 @@ const hashroutes = {
},
"/confirmed": () => {
showFeatureDialog("confirmed");
- },
+ }
};
export default hashroutes;
diff --git a/apps/web/src/navigation/index.js b/apps/web/src/navigation/index.js
index 5f188893e..ec46678c0 100644
--- a/apps/web/src/navigation/index.js
+++ b/apps/web/src/navigation/index.js
@@ -74,7 +74,7 @@ const HOMEPAGE_ROUTE = {
0: "/notes",
1: "/notebooks",
2: "/favorites",
- 3: "/tags",
+ 3: "/tags"
};
export function getHomeRoute() {
return HOMEPAGE_ROUTE[Config.get("homepage", 0)];
diff --git a/apps/web/src/navigation/routes.js b/apps/web/src/navigation/routes.js
index dfb791c1b..12e1a1c9a 100644
--- a/apps/web/src/navigation/routes.js
+++ b/apps/web/src/navigation/routes.js
@@ -21,9 +21,9 @@ const routes = {
component: <Home />,
buttons: {
search: {
- title: "Search notes",
- },
- },
+ title: "Search notes"
+ }
+ }
}),
"/notebooks": () => ({
key: "notebooks",
@@ -32,9 +32,9 @@ const routes = {
component: <Notebooks />,
buttons: {
search: {
- title: "Search notebooks",
- },
- },
+ title: "Search notebooks"
+ }
+ }
}),
"/notebooks/:notebookId": ({ notebookId }) => {
const notebook = db.notebooks.notebook(notebookId);
@@ -47,12 +47,12 @@ const routes = {
buttons: {
back: {
title: "Go back to notebooks",
- action: () => navigate("/notebooks"),
+ action: () => navigate("/notebooks")
},
search: {
- title: `Search ${notebook.title} topics`,
- },
- },
+ title: `Search ${notebook.title} topics`
+ }
+ }
};
},
"/notebooks/:notebookId/:topicId": ({ notebookId, topicId }) => {
@@ -61,7 +61,7 @@ const routes = {
if (!topic) return false;
notestore.setContext({
type: "topic",
- value: { id: notebookId, topic: topicId },
+ value: { id: notebookId, topic: topicId }
});
return {
key: "notes",
@@ -77,12 +77,12 @@ const routes = {
buttons: {
back: {
title: `Go back to ${notebook.title}`,
- action: () => navigate(`/notebooks/${notebookId}`),
+ action: () => navigate(`/notebooks/${notebookId}`)
},
search: {
- title: `Search ${notebook.title} ${topic.title} notes`,
- },
- },
+ title: `Search ${notebook.title} ${topic.title} notes`
+ }
+ }
};
},
"/favorites": () => {
@@ -94,9 +94,9 @@ const routes = {
component: <Notes />,
buttons: {
search: {
- title: "Search favorite notes",
- },
- },
+ title: "Search favorite notes"
+ }
+ }
};
},
"/trash": () => ({
@@ -106,9 +106,9 @@ const routes = {
component: <Trash />,
buttons: {
search: {
- title: "Search trash",
- },
- },
+ title: "Search trash"
+ }
+ }
}),
"/tags": () => ({
key: "tags",
@@ -117,9 +117,9 @@ const routes = {
component: <Tags />,
buttons: {
search: {
- title: "Search tags",
- },
- },
+ title: "Search tags"
+ }
+ }
}),
"/tags/:tagId": ({ tagId }) => {
const tag = db.tags.tag(tagId);
@@ -135,12 +135,12 @@ const routes = {
buttons: {
back: {
title: "Go back to tags",
- action: () => navigate("/tags"),
+ action: () => navigate("/tags")
},
search: {
- title: `Search #${title} notes`,
- },
- },
+ title: `Search #${title} notes`
+ }
+ }
};
},
"/colors/:colorId": ({ colorId }) => {
@@ -156,15 +156,15 @@ const routes = {
component: <Notes />,
buttons: {
search: {
- title: `Search ${title} colored notes`,
- },
- },
+ title: `Search ${title} colored notes`
+ }
+ }
};
},
"/settings": () => ({
key: "settings",
title: "Settings",
- component: <Settings />,
+ component: <Settings />
}),
"/monographs": () => {
notestore.setContext({ type: "monographs" });
@@ -175,9 +175,9 @@ const routes = {
component: <Notes />,
buttons: {
search: {
- title: "Search monograph notes",
- },
- },
+ title: "Search monograph notes"
+ }
+ }
};
},
"/search/:type": ({ type }) => ({
@@ -187,10 +187,10 @@ const routes = {
buttons: {
back: {
title: `Go back to ${type}`,
- action: () => window.history.back(),
- },
- },
- }),
+ action: () => window.history.back()
+ }
+ }
+ })
};
export default routes;
diff --git a/apps/web/src/service-worker-registration.js b/apps/web/src/service-worker-registration.js
index aaadbbc72..15700f734 100644
--- a/apps/web/src/service-worker-registration.js
+++ b/apps/web/src/service-worker-registration.js
@@ -101,7 +101,7 @@ function registerValidSW(swUrl, config) {
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, {
- headers: { "Service-Worker": "script" },
+ headers: { "Service-Worker": "script" }
})
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
diff --git a/apps/web/src/service-worker.js b/apps/web/src/service-worker.js
index cd7841608..f77f99d06 100644
--- a/apps/web/src/service-worker.js
+++ b/apps/web/src/service-worker.js
@@ -66,8 +66,8 @@ registerRoute(
plugins: [
// Ensure that once this runtime cache reaches a maximum size the
// least-recently used images are removed.
- new ExpirationPlugin({ maxEntries: 50 }),
- ],
+ new ExpirationPlugin({ maxEntries: 50 })
+ ]
})
);
@@ -87,7 +87,7 @@ self.addEventListener("message", (event) => {
event.source.postMessage({
type: data.type,
version: VERSION,
- hash: HASH,
+ hash: HASH
});
break;
default:
diff --git a/apps/web/src/stores/app-store.js b/apps/web/src/stores/app-store.js
index 401b696b2..179b5eca2 100644
--- a/apps/web/src/stores/app-store.js
+++ b/apps/web/src/stores/app-store.js
@@ -24,7 +24,7 @@ class AppStore extends BaseStore {
syncStatus = {
key: "synced",
progress: null,
- type: null,
+ type: null
};
colors = [];
globalMenu = { items: [], data: {} };
@@ -44,7 +44,7 @@ class AppStore extends BaseStore {
state.syncStatus = {
key: "syncing",
progress: ((current / total) * 100).toFixed(),
- type,
+ type
};
});
@@ -125,7 +125,7 @@ class AppStore extends BaseStore {
const { priority, type } = reminder;
state.reminders.push({
type,
- priority: priority === "high" ? 1 : priority === "medium" ? 2 : 1,
+ priority: priority === "high" ? 1 : priority === "medium" ? 2 : 1
});
}
});
@@ -147,7 +147,7 @@ class AppStore extends BaseStore {
} else {
await db.settings.pin(item.type, {
id: item.id,
- notebookId: item.notebookId,
+ notebookId: item.notebookId
});
this.refreshNavItems();
showToast("success", `Shortcut created!`);
diff --git a/apps/web/src/stores/attachment-store.js b/apps/web/src/stores/attachment-store.js
index 0998a84fd..82051082e 100644
--- a/apps/web/src/stores/attachment-store.js
+++ b/apps/web/src/stores/attachment-store.js
@@ -24,7 +24,7 @@ class AttachmentStore extends BaseStore {
if (!status) return this.refresh();
state.attachments[index] = {
...state.attachments[index],
- status,
+ status
};
});
}
@@ -65,7 +65,7 @@ class AttachmentStore extends BaseStore {
rename = async (hash, newName) => {
await db.attachments.add({
hash,
- filename: newName,
+ filename: newName
});
this.get().refresh();
};
diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.js
index 9fd1668df..8d8c0df65 100644
--- a/apps/web/src/stores/editor-store.js
+++ b/apps/web/src/stores/editor-store.js
@@ -14,7 +14,7 @@ const SESSION_STATES = {
new: "new",
locked: "locked",
unlocked: "unlocked",
- opening: "opening",
+ opening: "opening"
};
export const getDefaultSession = (sessionId = Date.now()) => {
@@ -36,7 +36,7 @@ export const getDefaultSession = (sessionId = Date.now()) => {
context: undefined,
color: undefined,
dateEdited: 0,
- attachmentsLength: 0,
+ attachmentsLength: 0
};
};
@@ -73,7 +73,7 @@ class EditorStore extends BaseStore {
...note,
sessionType: "locked",
id: undefined, // NOTE: we give a session id only after the note is opened.
- state: SESSION_STATES.unlocked,
+ state: SESSION_STATES.unlocked
};
});
appStore.setIsEditorOpen(true);
@@ -113,7 +113,7 @@ class EditorStore extends BaseStore {
...defaultSession,
...note,
state: SESSION_STATES.new,
- attachmentsLength: db.attachments.ofNote(note.id, "all")?.length || 0,
+ attachmentsLength: db.attachments.ofNote(note.id, "all")?.length || 0
};
});
appStore.setIsEditorOpen(true);
@@ -196,7 +196,7 @@ class EditorStore extends BaseStore {
...getDefaultSession(),
context,
nonce,
- state: SESSION_STATES.new,
+ state: SESSION_STATES.new
};
});
noteStore.setSelectedNote(0);
@@ -210,7 +210,7 @@ class EditorStore extends BaseStore {
this.set((state) => {
state.session = {
...getDefaultSession(),
- state: SESSION_STATES.new,
+ state: SESSION_STATES.new
};
});
noteStore.setSelectedNote(0);
diff --git a/apps/web/src/stores/user-store.js b/apps/web/src/stores/user-store.js
index 51933ea13..80b367d2c 100644
--- a/apps/web/src/stores/user-store.js
+++ b/apps/web/src/stores/user-store.js
@@ -5,7 +5,7 @@ import config from "../utils/config";
import { EV, EVENTS } from "@streetwriters/notesnook-core/common";
import {
showAccountLoggedOutNotice,
- showOnboardingDialog,
+ showOnboardingDialog
} from "../common/dialog-controller";
import Config from "../utils/config";
import { onPageVisibilityChanged } from "../utils/page-visibility";
diff --git a/apps/web/src/utils/analytics.ts b/apps/web/src/utils/analytics.ts
index 917da0ef6..28d0ff50f 100644
--- a/apps/web/src/utils/analytics.ts
+++ b/apps/web/src/utils/analytics.ts
@@ -44,45 +44,45 @@ type TrackerEvent = {
export const ANALYTICS_EVENTS = {
version: {
name: "version",
- description: "Sent on startup",
+ description: "Sent on startup"
},
checkoutStarted: {
name: "checkout:started",
- description: "Sent when you start Paddle checkout.",
+ description: "Sent when you start Paddle checkout."
},
offerClaimed: {
name: "offer:claimed",
description:
- "Sent when you start Paddle checkout with a coupon code applied.",
+ "Sent when you start Paddle checkout with a coupon code applied."
},
announcementDismissed: {
name: "announcement:dismissed",
- description: "Sent when you dismiss an announcement.",
+ description: "Sent when you dismiss an announcement."
},
purchaseInitiated: {
name: "purchase:initiated",
description:
- "Sent whenever the Premium dialog is shown to you. This can be voluntary or via accessing a premium feature.",
+ "Sent whenever the Premium dialog is shown to you. This can be voluntary or via accessing a premium feature."
},
socialLink: {
name: "link:social",
description:
- "Sent whenever you open Notesnook social media link from the email verified screen.",
+ "Sent whenever you open Notesnook social media link from the email verified screen."
},
announcementCta: {
name: "announcement:cta",
- description: "Sent whenever you an announcement CTA is invoked.",
+ description: "Sent whenever you an announcement CTA is invoked."
},
accountCreated: {
name: "/account/created",
description: "Sent when you create an account.",
- type: "view",
+ type: "view"
},
signupSkipped: {
name: "/signup/skipped",
description: `Sent when you press "Jump to app" button on signup screen.`,
- type: "view",
- },
+ type: "view"
+ }
} as const;
export function trackEvent(event: TrackerEvent, eventMessage?: string) {
diff --git a/apps/web/src/utils/importer.js b/apps/web/src/utils/importer.js
index bb3c11a06..209f78abb 100644
--- a/apps/web/src/utils/importer.js
+++ b/apps/web/src/utils/importer.js
@@ -63,7 +63,7 @@ function binaryToJson(binary, def) {
async function importAttachments(attachments) {
for (let attachment of attachments) {
const file = new File([attachment.data.buffer], attachment.filename, {
- type: attachment.mime,
+ type: attachment.mime
});
if (db.attachments.exists(attachment.hash)) continue;
@@ -75,7 +75,7 @@ async function importAttachments(attachments) {
hash: attachment.hash,
hashType: attachment.hashType,
filename: attachment.filename,
- type: attachment.mime,
+ type: attachment.mime
});
}
}
@@ -85,7 +85,7 @@ async function importNotebook(notebook) {
if (!nb) {
const nbId = await db.notebooks.add({
title: notebook.notebook,
- topics: [notebook.topic],
+ topics: [notebook.topic]
});
nb = db.notebooks.notebook(nbId).data;
}
diff --git a/apps/web/src/utils/logger.ts b/apps/web/src/utils/logger.ts
index cf611d571..d901938a1 100644
--- a/apps/web/src/utils/logger.ts
+++ b/apps/web/src/utils/logger.ts
@@ -1,7 +1,7 @@
import {
initalize,
logger as _logger,
- logManager,
+ logManager
} from "@streetwriters/notesnook-core/logger";
import FileSaver from "file-saver";
import { DatabasePersistence, NNStorage } from "../interfaces/storage";
@@ -18,7 +18,7 @@ async function downloadLogs() {
const allLogs = await logManager.get();
const files = allLogs.map((log) => ({
filename: log.key,
- content: (log.logs as any[]).map((line) => JSON.stringify(line)).join("\n"),
+ content: (log.logs as any[]).map((line) => JSON.stringify(line)).join("\n")
}));
const archive = await zip(files, "log");
FileSaver.saveAs(new Blob([archive.buffer]), "notesnook-logs.zip");
diff --git a/apps/web/src/utils/platform.js b/apps/web/src/utils/platform.js
index cd2878e87..2ceea0cf6 100644
--- a/apps/web/src/utils/platform.js
+++ b/apps/web/src/utils/platform.js
@@ -28,71 +28,71 @@ export function getDownloadLink(platform) {
return [
{
type: "Install from App Store",
- link: "https://apps.apple.com/pk/app/notesnook-take-private-notes/id1544027013",
- },
+ link: "https://apps.apple.com/pk/app/notesnook-take-private-notes/id1544027013"
+ }
];
case "Android":
return [
{
type: "Install from Google Play Store",
- link: "https://play.google.com/store/apps/details?id=com.streetwriters.notesnook",
+ link: "https://play.google.com/store/apps/details?id=com.streetwriters.notesnook"
},
{
type: "Download .apk (arm64-v8a)",
- link: `${baseurl}/notesnook-arm64-v8a.apk`,
+ link: `${baseurl}/notesnook-arm64-v8a.apk`
},
{
type: "Download .apk (armeabi-v7a)",
- link: `${baseurl}/notesnook-armeabi-v7a.apk`,
+ link: `${baseurl}/notesnook-armeabi-v7a.apk`
},
{
type: "Download .apk (x86)",
- link: `${baseurl}/notesnook-x86.apk`,
+ link: `${baseurl}/notesnook-x86.apk`
},
{
type: "Download .apk (x86_64)",
- link: `${baseurl}/notesnook-x86_64.apk`,
- },
+ link: `${baseurl}/notesnook-x86_64.apk`
+ }
];
case "macOS":
return [
{
type: "Download .dmg (x64)",
- link: `${baseurl}/notesnook_x64.dmg`,
+ link: `${baseurl}/notesnook_x64.dmg`
},
{
type: "Download .dmg (arm64)",
- link: `${baseurl}/notesnook_arm64.dmg`,
- },
+ link: `${baseurl}/notesnook_arm64.dmg`
+ }
];
case "Windows":
return [
{
type: "Download .exe (x64)",
- link: `${baseurl}/notesnook_x64.exe`,
- },
+ link: `${baseurl}/notesnook_x64.exe`
+ }
];
case "Linux":
return [
{
type: "Download .AppImage",
- link: `${baseurl}/notesnook_x86_64.AppImage`,
+ link: `${baseurl}/notesnook_x86_64.AppImage`
},
{
type: "Download .deb",
- link: `${baseurl}/notesnook_amd64.deb`,
+ link: `${baseurl}/notesnook_amd64.deb`
},
{
type: "Download .rpm",
- link: `${baseurl}/notesnook_x86_64.rpm`,
- },
+ link: `${baseurl}/notesnook_x86_64.rpm`
+ }
];
default:
return [
{
type: "Download",
- link: "https://github.com/streetwriters/notesnook/releases/",
- },
+ link: "https://github.com/streetwriters/notesnook/releases/"
+ }
];
}
}
diff --git a/apps/web/src/utils/toast.tsx b/apps/web/src/utils/toast.tsx
index 8cd846f5a..f6263e8c7 100644
--- a/apps/web/src/utils/toast.tsx
+++ b/apps/web/src/utils/toast.tsx
@@ -31,8 +31,8 @@ function showToast(
position: "bottom-right",
style: {
maxWidth: "auto",
- backgroundColor: "var(--background)",
- },
+ backgroundColor: "var(--background)"
+ }
});
return { hide: () => toast.dismiss(id) };
}
@@ -73,7 +73,7 @@ function ToastContainer(props: ToastContainerProps) {
sx={{
py: "7px",
":hover": { bg: "bgSecondary" },
- m: 0,
+ m: 0
}}
key={action.text}
onClick={action.onClick}
diff --git a/apps/web/src/utils/version.ts b/apps/web/src/utils/version.ts
index 4d09922a0..e2cf31ff3 100644
--- a/apps/web/src/utils/version.ts
+++ b/apps/web/src/utils/version.ts
@@ -9,7 +9,7 @@ export const appVersion = {
),
clean: formatVersion(process.env.REACT_APP_VERSION),
numerical: parseInt(process.env.REACT_APP_VERSION || "0"),
- isBeta: process.env.REACT_APP_BETA === "true",
+ isBeta: process.env.REACT_APP_BETA === "true"
};
function format(
@@ -45,7 +45,7 @@ export function getServiceWorkerVersion(
formatted: formatVersion(version),
numerical: parseInt(version),
clean: formatVersion(version),
- isBeta: appVersion.isBeta,
+ isBeta: appVersion.isBeta
});
});
serviceWorker.postMessage({ type: "GET_VERSION" });
diff --git a/apps/web/src/views/auth.tsx b/apps/web/src/views/auth.tsx
index 2bf0272b3..3261d6453 100644
--- a/apps/web/src/views/auth.tsx
+++ b/apps/web/src/views/auth.tsx
@@ -9,7 +9,7 @@ import {
MFAEmail,
MFARecoveryCode,
ArrowRight,
- Logout,
+ Logout
} from "../components/icons";
import Field from "../components/field";
import { getQueryParams, hardNavigate, makeURL } from "../navigation";
@@ -121,7 +121,7 @@ const routePaths: Record<AuthRoutes, string> = {
sessionExpiry: "/sessionexpired",
signup: "/signup",
"mfa:code": "/mfa/code",
- "mfa:select": "/mfa/select",
+ "mfa:select": "/mfa/select"
};
function Auth(props: AuthProps) {
@@ -141,7 +141,7 @@ function Auth(props: AuthProps) {
sx={{
zIndex: 1,
flex: 1,
- overflowY: "auto",
+ overflowY: "auto"
}}
>
{route === "login" || route === "signup" || route === "recover" ? (
@@ -151,7 +151,7 @@ function Auth(props: AuthProps) {
mt: 2,
mr: 2,
alignSelf: "end",
- alignItems: "center",
+ alignItems: "center"
}}
variant={"secondary"}
onClick={() => {
@@ -171,7 +171,7 @@ function Auth(props: AuthProps) {
mt: 2,
mr: 2,
alignSelf: "end",
- alignItems: "center",
+ alignItems: "center"
}}
onClick={async () => {
await db.user?.logout();
@@ -216,7 +216,7 @@ function Login(props: BaseAuthComponentProps<"login">) {
}
loading={{
title: "Logging you in",
- subtitle: "Please wait while you are authenticated.",
+ subtitle: "Please wait while you are authenticated."
}}
onSubmit={(form) => login(form, navigate)}
>
@@ -275,7 +275,7 @@ function Signup(props: BaseAuthComponentProps<"signup">) {
}
loading={{
title: "Creating your account",
- subtitle: "Please wait while we finalize your account.",
+ subtitle: "Please wait while we finalize your account."
}}
onSubmit={async (form) => {
if (form.password !== form["confirm-password"]) {
@@ -379,7 +379,7 @@ function SessionExpiry(props: BaseAuthComponentProps<"sessionExpiry">) {
}
loading={{
title: "Logging you in",
- subtitle: "Please wait while you are authenticated.",
+ subtitle: "Please wait while you are authenticated."
}}
onSubmit={async (form) => {
if (!user) return;
@@ -438,7 +438,7 @@ function AccountRecovery(props: BaseAuthComponentProps<"recover">) {
}
loading={{
title: "Sending recovery email",
- subtitle: "Please wait while we send you recovery instructions.",
+ subtitle: "Please wait while we send you recovery instructions."
}}
onSubmit={async (form) => {
if (!form.email) {
@@ -500,14 +500,14 @@ function getTexts(formData: MFAFormData) {
"Please confirm your identity by entering the authentication code from your authenticator app.",
instructions: `Open the two-factor authentication (TOTP) app to view your authentication code.`,
selector: `Don't have access to your authenticator app?`,
- label: "Enter 6-digit code",
+ label: "Enter 6-digit code"
},
email: {
subtitle:
"Please confirm your identity by entering the authentication code sent to your email address.",
instructions: `It may take a minute to receive your code.`,
selector: `Don't have access to your email address?`,
- label: "Enter 6-digit code",
+ label: "Enter 6-digit code"
},
sms: {
subtitle: `Please confirm your identity by entering the authentication code sent to ${
@@ -515,14 +515,14 @@ function getTexts(formData: MFAFormData) {
}.`,
instructions: `It may take a minute to receive your code.`,
selector: `Don't have access to your phone number?`,
- label: "Enter 6-digit code",
+ label: "Enter 6-digit code"
},
recoveryCode: {
subtitle: `Please confirm your identity by entering a recovery code.`,
instructions: "",
selector: `Don't have your recovery codes?`,
- label: "Enter recovery code",
- },
+ label: "Enter recovery code"
+ }
};
}
@@ -580,14 +580,14 @@ function MFACode(props: BaseAuthComponentProps<"mfa:code">) {
subtitle={texts.subtitle}
loading={{
title: "Logging you in",
- subtitle: "Please wait while you are authenticated.",
+ subtitle: "Please wait while you are authenticated."
}}
onSubmit={async (form) => {
const loginForm: MFALoginFormData = {
email: formData.email,
password: formData.password,
code: form.code,
- method: formData.selectedMethod,
+ method: formData.selectedMethod
};
await login(loginForm, navigate);
}}
@@ -618,7 +618,7 @@ function MFACode(props: BaseAuthComponentProps<"mfa:code">) {
),
onClick: async () => {
await sendCode(selectedMethod, token);
- },
+ }
}
: undefined
}
@@ -651,7 +651,7 @@ const MFAMethods: MFAMethod[] = [
{ type: "app", title: "Use an authenticator app", icon: MFAAuthenticator },
{ type: "sms", title: "Send code to your phone number", icon: MFASMS },
{ type: "email", title: "Send code to your email address", icon: MFAEmail },
- { type: "recoveryCode", title: "Use a recovery code", icon: MFARecoveryCode },
+ { type: "recoveryCode", title: "Use a recovery code", icon: MFARecoveryCode }
];
function MFASelector(props: BaseAuthComponentProps<"mfa:select">) {
const { navigate, formData } = props;
@@ -678,7 +678,7 @@ function MFASelector(props: BaseAuthComponentProps<"mfa:select">) {
subtitle={`Where should we send you the authentication code?`}
loading={{
title: "Logging you in",
- subtitle: "Please wait while you are authenticated.",
+ subtitle: "Please wait while you are authenticated."
}}
onSubmit={async (form) => {
const selectedType = MFAMethods[selected];
@@ -700,7 +700,7 @@ function MFASelector(props: BaseAuthComponentProps<"mfa:select">) {
alignSelf: "stretch",
alignItems: "center",
textAlign: "left",
- px: 2,
+ px: 2
}}
onClick={() => setSelected(index)}
>
@@ -710,7 +710,7 @@ function MFASelector(props: BaseAuthComponentProps<"mfa:select">) {
borderRadius: 100,
width: 35,
height: 35,
- mr: 2,
+ mr: 2
}}
size={16}
color={selected === index ? "primary" : "text"}
@@ -826,7 +826,7 @@ function SubtitleWithAction(props: SubtitleWithActionProps) {
sx={{
textDecoration: "underline",
":hover": { color: "dimPrimary" },
- cursor: "pointer",
+ cursor: "pointer"
}}
as="b"
color="text"
@@ -881,8 +881,8 @@ export function AuthField(props: AuthFieldProps) {
p: "12px",
borderRadius: "default",
bg: "background",
- boxShadow: "0px 0px 5px 0px #00000019",
- },
+ boxShadow: "0px 0px 5px 0px #00000019"
+ }
}}
/>
);
@@ -938,7 +938,7 @@ async function login(
selectedMethod: primaryMethod,
primaryMethod,
phoneNumber,
- secondaryMethod,
+ secondaryMethod
});
} else throw e;
}
diff --git a/apps/web/src/views/email-confirmed.js b/apps/web/src/views/email-confirmed.js
index 93fc21b99..a94303327 100644
--- a/apps/web/src/views/email-confirmed.js
+++ b/apps/web/src/views/email-confirmed.js
@@ -81,20 +81,20 @@ const social = [
title: "Discord",
hoverColor: "#7289da",
icon: Icon.Discord,
- link: "https://discord.com/invite/zQBK97EE22",
+ link: "https://discord.com/invite/zQBK97EE22"
},
{
title: "Twitter",
hoverColor: "#1da1f2",
icon: Icon.Twitter,
- link: "https://twitter.com/notesnook",
+ link: "https://twitter.com/notesnook"
},
{
title: "Reddit",
hoverColor: "#ff4500",
icon: Icon.Reddit,
- link: "https://reddit.com/r/Notesnook",
- },
+ link: "https://reddit.com/r/Notesnook"
+ }
];
function BlogPromoBanner(props) {
return (
diff --git a/apps/web/src/views/home.js b/apps/web/src/views/home.js
index ba716717c..95567a1e8 100644
--- a/apps/web/src/views/home.js
+++ b/apps/web/src/views/home.js
@@ -49,7 +49,7 @@ function Home() {
button={{
content: "Make a new note",
onClick: () =>
- hashNavigate("/notes/create", { replace: true, addNonce: true }),
+ hashNavigate("/notes/create", { replace: true, addNonce: true })
}}
/>
);
diff --git a/apps/web/src/views/notebooks.js b/apps/web/src/views/notebooks.js
index 791f9d4ef..14deccc03 100644
--- a/apps/web/src/views/notebooks.js
+++ b/apps/web/src/views/notebooks.js
@@ -20,7 +20,7 @@ function Notebooks() {
placeholder={NotebooksPlaceholder}
button={{
content: "Create a notebook",
- onClick: () => hashNavigate("/notebooks/create"),
+ onClick: () => hashNavigate("/notebooks/create")
}}
/>
</>
diff --git a/apps/web/src/views/notes.js b/apps/web/src/views/notes.js
index ccf682ec4..ccaccc486 100644
--- a/apps/web/src/views/notes.js
+++ b/apps/web/src/views/notes.js
@@ -53,7 +53,7 @@ function Notes() {
button={{
content: "Make a new note",
onClick: () =>
- hashNavigate("/notes/create", { addNonce: true, replace: true }),
+ hashNavigate("/notes/create", { addNonce: true, replace: true })
}}
/>
);
diff --git a/apps/web/src/views/recovery.tsx b/apps/web/src/views/recovery.tsx
index 712316c75..b7d1e4f92 100644
--- a/apps/web/src/views/recovery.tsx
+++ b/apps/web/src/views/recovery.tsx
@@ -94,12 +94,12 @@ const routePaths: Record<RecoveryRoutes, string> = {
"method:reset": "/account/recovery/method/reset",
backup: "/account/recovery/backup",
new: "/account/recovery/new",
- final: "/account/recovery/final",
+ final: "/account/recovery/final"
};
function useAuthenticateUser({
code,
- userId,
+ userId
}: {
code: string;
userId: string;
@@ -156,7 +156,7 @@ function Recovery(props: RecoveryProps) {
sx={{
zIndex: 1,
flex: 1,
- overflowY: "auto",
+ overflowY: "auto"
}}
>
{isAuthenticating ? (
@@ -171,7 +171,7 @@ function Recovery(props: RecoveryProps) {
sx={{
display: "flex",
alignSelf: "end",
- alignItems: "center",
+ alignItems: "center"
}}
variant={"body"}
>
@@ -183,7 +183,7 @@ function Recovery(props: RecoveryProps) {
mt: 0,
ml: 2,
alignSelf: "start",
- alignItems: "center",
+ alignItems: "center"
}}
variant={"secondary"}
onClick={() => openURL("/login")}
@@ -222,14 +222,14 @@ const recoveryMethods: RecoveryMethod[] = [
testId: "step-recovery-key",
title: "Use recovery key",
description:
- "Your data recovery key is basically a hashed version of your password (plus some random salt). It can be used to decrypt your data for re-encryption.",
+ "Your data recovery key is basically a hashed version of your password (plus some random salt). It can be used to decrypt your data for re-encryption."
},
{
type: "backup",
testId: "step-backup",
title: "Use a backup file",
description:
- "If you don't have a recovery key, you can recover your data by restoring a Notesnook data backup file (.nnbackup).",
+ "If you don't have a recovery key, you can recover your data by restoring a Notesnook data backup file (.nnbackup)."
},
{
type: "reset",
@@ -237,8 +237,8 @@ const recoveryMethods: RecoveryMethod[] = [
title: "Clear data & reset account",
description:
"EXTREMELY DANGEROUS! This action is irreversible. All your data including notes, notebooks, attachments & settings will be deleted. This is a full account reset. Proceed with caution.",
- isDangerous: true,
- },
+ isDangerous: true
+ }
];
function RecoveryMethods(props: BaseRecoveryComponentProps<"methods">) {
const { navigate } = props;
@@ -258,7 +258,7 @@ function RecoveryMethods(props: BaseRecoveryComponentProps<"methods">) {
onSubmit={async () => {
const selectedMethod = recoveryMethods[selected].type;
navigate(`method:${selectedMethod}`, {
- userResetRequired: selectedMethod === "reset",
+ userResetRequired: selectedMethod === "reset"
});
}}
>
@@ -276,7 +276,7 @@ function RecoveryMethods(props: BaseRecoveryComponentProps<"methods">) {
alignSelf: "stretch",
// alignItems: "center",
textAlign: "left",
- px: 2,
+ px: 2
}}
onClick={() => setSelected(index)}
>
@@ -306,7 +306,7 @@ function RecoveryKeyMethod(props: BaseRecoveryComponentProps<"method:key">) {
subtitle={"Use a data recovery key to reset your account password."}
loading={{
title: "Downloading your data",
- subtitle: "Please wait while your data is downloaded & decrypted.",
+ subtitle: "Please wait while your data is downloaded & decrypted."
}}
onSubmit={async (form) => {
const user = await db.user?.getUser();
@@ -380,7 +380,7 @@ function BackupFileMethod(props: BaseRecoveryComponentProps<"method:backup">) {
component: <Text variant={"body"}>Browse</Text>,
onClick: async () => {
setBackupFile(await selectBackupFile());
- },
+ }
}}
/>
<SubmitButton text="Start account recovery" />
@@ -412,7 +412,7 @@ function BackupData(props: BaseRecoveryComponentProps<"backup">) {
loading={{
title: "Creating backup...",
subtitle:
- "Please wait while we create a backup file for you to download.",
+ "Please wait while we create a backup file for you to download."
}}
onSubmit={async () => {
await createBackup();
@@ -437,7 +437,7 @@ function NewPassword(props: BaseRecoveryComponentProps<"new">) {
}
loading={{
title: "Resetting account password",
- subtitle: "Please wait while we reset your account password.",
+ subtitle: "Please wait while we reset your account password."
}}
onSubmit={async (form) => {
if (form.password !== form.confirmPassword)
diff --git a/apps/web/src/views/search.js b/apps/web/src/views/search.js
index 7aa8cc567..b8b905117 100644
--- a/apps/web/src/views/search.js
+++ b/apps/web/src/views/search.js
@@ -36,7 +36,7 @@ async function typeToItems(type, context) {
function Search({ type }) {
const [searchState, setSearchState] = useState({
isSearching: false,
- totalItems: 0,
+ totalItems: 0
});
const [results, setResults] = useState([]);
const context = useNoteStore((store) => store.context);
diff --git a/apps/web/src/views/settings.js b/apps/web/src/views/settings.js
index ea07bb4fe..667f54de8 100644
--- a/apps/web/src/views/settings.js
+++ b/apps/web/src/views/settings.js
@@ -21,7 +21,7 @@ import {
showMultifactorDialog,
showAttachmentsDialog,
show2FARecoveryCodesDialog,
- showToolbarConfigDialog,
+ showToolbarConfigDialog
} from "../common/dialog-controller";
import { SUBSCRIPTION_STATUS } from "../common/constants";
import { createBackup, importBackup, verifyAccount } from "../common";
@@ -64,40 +64,40 @@ const otherItems = [
{
title: "Terms of service",
description: "Read our terms of service.",
- link: "https://notesnook.com/tos",
+ link: "https://notesnook.com/tos"
},
{
title: "Privacy policy",
description:
"We do not share, sell, read, or use your data. Read our privacy policy.",
- link: "https://notesnook.com/privacy",
+ link: "https://notesnook.com/privacy"
},
{
title: "Report an issue",
description: "Facing an issue? Click here to create a bug report.",
- onClick: () => showIssueDialog(),
+ onClick: () => showIssueDialog()
},
{
title: "Join our Discord community",
description:
"We are not ghosts. Come chat with us and share your experience.",
- link: "https://discord.com/invite/zQBK97EE22",
+ link: "https://discord.com/invite/zQBK97EE22"
},
{
title: "Download for iOS & Android",
description: "Notesnook is available on Android & iOS",
- link: "https://notesnook.com/",
+ link: "https://notesnook.com/"
},
{
title: "Documentation",
description: "Learn about every feature in Notesnook and how it works",
- link: "https://docs.notesnook.com/",
+ link: "https://docs.notesnook.com/"
},
{
title: "Roadmap",
description: "See what the future of Notesnook is going to be like!",
- link: "https://notesnook.com/roadmap",
- },
+ link: "https://notesnook.com/roadmap"
+ }
];
function Settings(props) {
@@ -109,7 +109,7 @@ function Settings(props) {
importer: false,
privacy: false,
developer: false,
- other: true,
+ other: true
});
const isVaultCreated = useAppStore((store) => store.isVaultCreated);
const setIsVaultCreated = useAppStore((store) => store.setIsVaultCreated);
@@ -175,7 +175,7 @@ function Settings(props) {
mr={2}
size={35}
sx={{
- borderRadius: 80,
+ borderRadius: 80
}}
>
<Icon.User size={20} color="primary" />
@@ -247,7 +247,7 @@ function Settings(props) {
if (await showLogoutConfirmation()) {
await showLoadingDialog({
title: "You are being logged out",
- action: () => db.user.logout(true),
+ action: () => db.user.logout(true)
});
showToast("success", "You have been logged out.");
}
@@ -370,7 +370,7 @@ function Settings(props) {
flexWrap="wrap"
justifyContent="left"
sx={{
- borderRadius: "default",
+ borderRadius: "default"
}}
>
{getAllAccents().map((color) => (
@@ -526,7 +526,7 @@ function Settings(props) {
const location = await window.native.selectDirectory({
title: "Select where Notesnook should save backups",
defaultPath:
- backupStorageLocation || PATHS.backupsDirectory,
+ backupStorageLocation || PATHS.backupsDirectory
});
if (!location) return;
setBackupStorageLocation(location);
@@ -792,7 +792,7 @@ function OptionsItem(props) {
selectedOption,
onSelectionChanged,
onlyIf,
- premium,
+ premium
} = props;
if (onlyIf === false) return null;
@@ -805,7 +805,7 @@ function OptionsItem(props) {
cursor: "pointer",
borderBottom: "1px solid",
borderBottomColor: "border",
- ":hover": { borderBottomColor: "primary" },
+ ":hover": { borderBottomColor: "primary" }
}}
>
<Tip text={title} tip={tip} />
@@ -833,7 +833,7 @@ function OptionsItem(props) {
}
}}
sx={{
- ":hover": { color: selectedOption === index ? "static" : "text" },
+ ":hover": { color: selectedOption === index ? "static" : "text" }
}}
>
{option}
@@ -853,7 +853,7 @@ function AccountStatus(props) {
isBasic,
isProCancelled,
isProExpired,
- remainingDays,
+ remainingDays
} = useMemo(() => {
const type = user?.subscription?.type;
const expiry = user?.subscription?.expiry;
@@ -865,7 +865,7 @@ function AccountStatus(props) {
isBeta: type === SUBSCRIPTION_STATUS.BETA,
isPro: type === SUBSCRIPTION_STATUS.PREMIUM,
isProCancelled: type === SUBSCRIPTION_STATUS.PREMIUM_CANCELED,
- isProExpired: type === SUBSCRIPTION_STATUS.PREMIUM_EXPIRED,
+ isProExpired: type === SUBSCRIPTION_STATUS.PREMIUM_EXPIRED
};
}, [user]);
diff --git a/apps/web/src/views/topics.js b/apps/web/src/views/topics.js
index d124a7ebc..127bf7ce5 100644
--- a/apps/web/src/views/topics.js
+++ b/apps/web/src/views/topics.js
@@ -34,7 +34,7 @@ function Topics() {
}
button={{
content: "Add a new topic",
- onClick: () => hashNavigate(`/topics/create`),
+ onClick: () => hashNavigate(`/topics/create`)
}}
/>
</>
diff --git a/apps/web/src/views/trash.js b/apps/web/src/views/trash.js
index b796fc888..1ae025e67 100644
--- a/apps/web/src/views/trash.js
+++ b/apps/web/src/views/trash.js
@@ -46,7 +46,7 @@ function Trash() {
not be able to recover any of these items.
</Text>
</>
- ),
+ )
}).then(async (res) => {
if (res) {
try {
@@ -60,7 +60,7 @@ function Trash() {
}
}
});
- },
+ }
}}
/>
);
diff --git a/package.json b/package.json
index 3bf530529..115a03be6 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,8 @@
"scripts": {
"bootstrap": "lerna bootstrap",
"build": "nx run-many --target=build --all",
- "start:web": "nx start @notesnook/web"
+ "start:web": "nx start @notesnook/web",
+ "prettier": "npx prettier . --write"
},
"devDependencies": {
"lerna": "^5.4.0",
diff --git a/packages/crypto-worker/index.ts b/packages/crypto-worker/index.ts
index 704a70da6..b06bf54ac 100644
--- a/packages/crypto-worker/index.ts
+++ b/packages/crypto-worker/index.ts
@@ -4,7 +4,7 @@ import {
OutputFormat,
Cipher,
EncryptionKey,
- Chunk,
+ Chunk
} from "@notesnook/crypto/dist/src/types";
import { NNCryptoWorkerModule } from "./src/worker";
import { INNCrypto, IStreamable } from "@notesnook/crypto/dist/src/interfaces";
@@ -146,7 +146,7 @@ export class NNCryptoWorker implements INNCrypto {
done();
}
}
- },
+ }
};
}
}
diff --git a/packages/crypto-worker/src/worker.ts b/packages/crypto-worker/src/worker.ts
index a4cda5872..b468395ad 100644
--- a/packages/crypto-worker/src/worker.ts
+++ b/packages/crypto-worker/src/worker.ts
@@ -2,7 +2,7 @@ import {
Cipher,
OutputFormat,
Plaintext,
- SerializedKey,
+ SerializedKey
} from "@notesnook/crypto/dist/src/types";
import { expose } from "comlink";
import WorkerStream from "./workerstream";
@@ -55,7 +55,7 @@ const module = {
) {
const crypto = await loadNNCrypto();
return crypto.createDecryptionStream(iv, key, new WorkerStream(id));
- },
+ }
};
export type NNCryptoWorkerModule = typeof module;
diff --git a/packages/crypto/index.ts b/packages/crypto/index.ts
index 1c45873a5..e361d218b 100644
--- a/packages/crypto/index.ts
+++ b/packages/crypto/index.ts
@@ -10,7 +10,7 @@ import {
OutputFormat,
Plaintext,
SerializedKey,
- Chunk,
+ Chunk
} from "./src/types";
export class NNCrypto implements INNCrypto {
@@ -70,7 +70,7 @@ export class NNCrypto implements INNCrypto {
const encryptedChunk: Chunk = {
data: encryptionStream.write(data, final),
- final,
+ final
};
await stream.write(encryptedChunk);
@@ -95,7 +95,7 @@ export class NNCrypto implements INNCrypto {
const decryptedChunk: Chunk = {
data: decryptionStream.read(data),
- final,
+ final
};
await stream.write(decryptedChunk);
diff --git a/packages/crypto/src/decryption.ts b/packages/crypto/src/decryption.ts
index 0c9ba3bfb..c57dce454 100644
--- a/packages/crypto/src/decryption.ts
+++ b/packages/crypto/src/decryption.ts
@@ -7,7 +7,7 @@ import {
base64_variants,
StateAddress,
to_string,
- from_hex,
+ from_hex
} from "libsodium-wrappers";
import KeyUtils from "./keyutils";
import {
@@ -15,7 +15,7 @@ import {
EncryptionKey,
OutputFormat,
Plaintext,
- SerializedKey,
+ SerializedKey
} from "./types";
export default class Decryption {
@@ -65,7 +65,7 @@ export default class Decryption {
? to_base64(plaintext, base64_variants.ORIGINAL)
: outputFormat === "text"
? to_string(plaintext)
- : plaintext,
+ : plaintext
};
}
diff --git a/packages/crypto/src/encryption.ts b/packages/crypto/src/encryption.ts
index 8b8274fd8..b59749ac1 100644
--- a/packages/crypto/src/encryption.ts
+++ b/packages/crypto/src/encryption.ts
@@ -9,7 +9,7 @@ import {
to_base64,
from_base64,
base64_variants,
- StateAddress,
+ StateAddress
} from "libsodium-wrappers";
import KeyUtils from "./keyutils";
import {
@@ -17,7 +17,7 @@ import {
EncryptionKey,
OutputFormat,
Plaintext,
- SerializedKey,
+ SerializedKey
} from "./types";
const encoder = new TextEncoder();
@@ -66,7 +66,7 @@ export default class Encryption {
cipher: output,
iv,
salt: encryptionKey.salt,
- length: data.length,
+ length: data.length
};
}
diff --git a/packages/crypto/src/interfaces.ts b/packages/crypto/src/interfaces.ts
index fbcb3e30c..9c817f64b 100644
--- a/packages/crypto/src/interfaces.ts
+++ b/packages/crypto/src/interfaces.ts
@@ -4,7 +4,7 @@ import {
OutputFormat,
Plaintext,
SerializedKey,
- Chunk,
+ Chunk
} from "./types";
export interface IStreamable {
diff --git a/packages/crypto/src/keyutils.ts b/packages/crypto/src/keyutils.ts
index ba24cf319..8795fac4c 100644
--- a/packages/crypto/src/keyutils.ts
+++ b/packages/crypto/src/keyutils.ts
@@ -5,7 +5,7 @@ import {
crypto_pwhash,
crypto_pwhash_SALTBYTES,
crypto_pwhash_ALG_ARGON2I13,
- crypto_aead_xchacha20poly1305_ietf_KEYBYTES,
+ crypto_aead_xchacha20poly1305_ietf_KEYBYTES
} from "libsodium-wrappers";
import { EncryptionKey, SerializedKey } from "./types";
@@ -31,7 +31,7 @@ export default class KeyUtils {
return {
key,
- salt: typeof salt === "string" ? salt : to_base64(saltBytes),
+ salt: typeof salt === "string" ? salt : to_base64(saltBytes)
};
}
diff --git a/packages/crypto/src/password.ts b/packages/crypto/src/password.ts
index c2af55082..5a283cd4b 100644
--- a/packages/crypto/src/password.ts
+++ b/packages/crypto/src/password.ts
@@ -2,7 +2,7 @@ import {
crypto_generichash,
crypto_pwhash,
crypto_pwhash_ALG_ARGON2ID13,
- crypto_pwhash_SALTBYTES,
+ crypto_pwhash_SALTBYTES
} from "libsodium-wrappers";
export default class Password {
diff --git a/packages/editor/README.md b/packages/editor/README.md
index 1df28b590..2f878fb60 100644
--- a/packages/editor/README.md
+++ b/packages/editor/README.md
@@ -1 +1 @@
-# notesnook-editor
\ No newline at end of file
+# notesnook-editor
diff --git a/packages/editor/scripts/langen.js b/packages/editor/scripts/langen.js
index d4545a872..bd5b5b909 100644
--- a/packages/editor/scripts/langen.js
+++ b/packages/editor/scripts/langen.js
@@ -21,7 +21,7 @@ async function main() {
? Array.isArray(language.alias)
? language.alias
: [language.alias]
- : undefined,
+ : undefined
});
}
console.log(JSON.stringify(output));
diff --git a/packages/editor/src/components/action-sheet/index.tsx b/packages/editor/src/components/action-sheet/index.tsx
index 06c93b8cc..dea147f67 100644
--- a/packages/editor/src/components/action-sheet/index.tsx
+++ b/packages/editor/src/components/action-sheet/index.tsx
@@ -3,7 +3,7 @@ import React, {
useCallback,
useRef,
useState,
- useEffect,
+ useEffect
} from "react";
import { MenuItem } from "../menu/types";
import { Box, Button, Flex, Text } from "rebass";
@@ -18,7 +18,7 @@ import {
useMotionValue,
animate,
useTransform,
- useAnimation,
+ useAnimation
} from "framer-motion";
import { useTheme } from "../../toolbar/stores/toolbar-store";
@@ -32,7 +32,7 @@ const TRANSITION = {
stiffness: 300,
damping: 30,
mass: 0.2,
- duration: 300,
+ duration: 300
};
function useHistory<T>(initial: T) {
@@ -81,7 +81,7 @@ export function ActionSheetPresenter(
blocking = true,
focusOnRender = true,
draggable = true,
- children,
+ children
} = props;
const theme = useTheme();
const contentRef = useRef<HTMLDivElement>();
@@ -101,7 +101,7 @@ export function ActionSheetPresenter(
}, TRANSITION.duration - 50);
animation.start({
transition: TRANSITION,
- y: height + 100,
+ y: height + 100
});
}, [animation, onClose, contentRef.current]);
@@ -152,7 +152,7 @@ export function ActionSheetPresenter(
...props.style,
position: blocking ? "fixed" : "sticky",
zIndex: 1000,
- backgroundColor: !blocking ? "transparent" : "unset",
+ backgroundColor: !blocking ? "transparent" : "unset"
}}
tabIndex={-1}
>
@@ -164,7 +164,7 @@ export function ActionSheetPresenter(
width: "100%",
opacity,
position: "absolute",
- backgroundColor: "var(--overlay)",
+ backgroundColor: "var(--overlay)"
}}
tabIndex={-1}
/>
@@ -190,7 +190,7 @@ export function ActionSheetPresenter(
padding: 0,
zIndex: 0,
outline: 0,
- isolation: "isolate",
+ isolation: "isolate"
}}
>
{children}
@@ -207,7 +207,7 @@ export function ActionSheetPresenter(
borderTopRightRadius: 15,
boxShadow: theme?.shadows.menu || "none",
flex: 1,
- flexDirection: "column",
+ flexDirection: "column"
}}
>
{draggable && (
@@ -241,7 +241,7 @@ export function ActionSheetPresenter(
bg: "transparent",
alignItems: "center",
justifyContent: "center",
- p: 2,
+ p: 2
}}
>
<Box
@@ -250,7 +250,7 @@ export function ActionSheetPresenter(
backgroundColor: "hover",
width: 60,
height: 8,
- borderRadius: 100,
+ borderRadius: 100
}}
/>
</AnimatedFlex>
@@ -274,7 +274,7 @@ function ContentContainer(props: PropsWithChildren<ContentContainerProps>) {
const { current, goBack, canGoBack, navigate } =
useHistory<ActionSheetHistoryItem>({
title,
- items,
+ items
});
return (
diff --git a/packages/editor/src/components/button.tsx b/packages/editor/src/components/button.tsx
index a0877dfef..05f0f502e 100644
--- a/packages/editor/src/components/button.tsx
+++ b/packages/editor/src/components/button.tsx
@@ -14,12 +14,12 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
buttonRef.current.addEventListener("mousedown", onMouseDown, {
passive: false,
- capture: true,
+ capture: true
});
return () => {
buttonRef.current?.removeEventListener("mousedown", onMouseDown, {
- capture: true,
+ capture: true
});
};
}, []);
@@ -34,7 +34,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
sx={{
...sx,
":hover": { bg: [bg, hoverBg] },
- ":active": { bg: hoverBg },
+ ":active": { bg: hoverBg }
}}
ref={(ref) => {
buttonRef.current = ref;
diff --git a/packages/editor/src/components/inline-input/index.tsx b/packages/editor/src/components/inline-input/index.tsx
index 4026b621f..da4f7f112 100644
--- a/packages/editor/src/components/inline-input/index.tsx
+++ b/packages/editor/src/components/inline-input/index.tsx
@@ -19,8 +19,8 @@ export function InlineInput(props: LabelInputProps) {
borderRadius: "default",
":focus-within": {
outlineColor: "primary",
- outlineWidth: "1.8px",
- },
+ outlineWidth: "1.8px"
+ }
}}
>
<Input variant={"clean"} sx={{ ...sx, p: 0 }} {...inputProps} />
@@ -30,7 +30,7 @@ export function InlineInput(props: LabelInputProps) {
flexShrink: 0,
color: "fontTertiary",
borderLeft: "1px solid var(--border)",
- pl: 1,
+ pl: 1
}}
>
{label}
diff --git a/packages/editor/src/components/menu/index.tsx b/packages/editor/src/components/menu/index.tsx
index 8aa97cb80..6d28e7ea1 100644
--- a/packages/editor/src/components/menu/index.tsx
+++ b/packages/editor/src/components/menu/index.tsx
@@ -2,14 +2,14 @@ import React, {
useCallback,
useRef,
useEffect,
- PropsWithChildren,
+ PropsWithChildren
} from "react";
import { Box, Flex, FlexProps, Text } from "rebass";
import { getPosition } from "../../utils/position";
import {
MenuButton as MenuButtonType,
MenuItem,
- MenuItem as MenuItemType,
+ MenuItem as MenuItemType
} from "./types";
import { useFocus } from "./use-focus";
import { MenuSeparator } from "./menu-separator";
@@ -63,7 +63,7 @@ export function Menu(props: MenuProps) {
const { top, left } = getPosition(subMenuRef.current, {
// yOffset: menuItemElement.offsetHeight,
target: menuItemElement,
- location: "right",
+ location: "right"
});
subMenuRef.current.style.visibility = "visible";
@@ -124,7 +124,7 @@ export function Menu(props: MenuProps) {
ref={subMenuRef}
style={{ visibility: "hidden" }}
sx={{
- position: "absolute",
+ position: "absolute"
}}
>
<Menu items={focusedItem.menu.items} onClose={onClose} />
@@ -158,7 +158,7 @@ function MenuContainer(props: PropsWithChildren<MenuContainerProps>) {
boxShadow: "menu",
border: "1px solid var(--border)",
minWidth: 220,
- ...sx,
+ ...sx
}}
{...flexProps}
>
@@ -172,7 +172,7 @@ function MenuContainer(props: PropsWithChildren<MenuContainerProps>) {
px: 3,
borderBottom: "1px solid",
borderBottomColor: "border",
- wordWrap: "break-word",
+ wordWrap: "break-word"
}}
>
{title}
diff --git a/packages/editor/src/components/menu/menu-button.tsx b/packages/editor/src/components/menu/menu-button.tsx
index 5dd00d0e7..35bc02b19 100644
--- a/packages/editor/src/components/menu/menu-button.tsx
+++ b/packages/editor/src/components/menu/menu-button.tsx
@@ -25,7 +25,7 @@ export function MenuButton(props: MenuButtonProps) {
isChecked,
menu,
modifier,
- styles,
+ styles
} = item;
const itemRef = useRef<HTMLButtonElement>(null);
const toolbarLocation = useToolbarLocation();
@@ -55,8 +55,8 @@ export function MenuButton(props: MenuButtonProps) {
alignItems: "center",
justifyContent: "space-between",
":hover": {
- bg: isBottom ? "transparent" : "hover",
- },
+ bg: isBottom ? "transparent" : "hover"
+ }
}}
>
<Flex sx={{ fontSize: "inherit", fontFamily: "inherit" }}>
@@ -86,7 +86,7 @@ export function MenuButton(props: MenuButtonProps) {
sx={{
fontFamily: "body",
fontSize: "menu",
- color: "fontTertiary",
+ color: "fontTertiary"
}}
>
{modifier}
diff --git a/packages/editor/src/components/menu/menu-separator.tsx b/packages/editor/src/components/menu/menu-separator.tsx
index e76810813..cfc4629ed 100644
--- a/packages/editor/src/components/menu/menu-separator.tsx
+++ b/packages/editor/src/components/menu/menu-separator.tsx
@@ -9,7 +9,7 @@ export function MenuSeparator() {
height: "0.5px",
bg: "border",
my: 2,
- alignSelf: "center",
+ alignSelf: "center"
}}
/>
);
diff --git a/packages/editor/src/components/menu/use-focus.ts b/packages/editor/src/components/menu/use-focus.ts
index 5fdf8f93d..9cba826f4 100644
--- a/packages/editor/src/components/menu/use-focus.ts
+++ b/packages/editor/src/components/menu/use-focus.ts
@@ -16,7 +16,7 @@ export function useFocus(
const element = document.getElementById(item.key);
if (!element) return;
element.scrollIntoView({
- behavior: "auto",
+ behavior: "auto"
});
},
[items]
diff --git a/packages/editor/src/components/popup-presenter/index.tsx b/packages/editor/src/components/popup-presenter/index.tsx
index 6acd37ebb..4e17a32ac 100644
--- a/packages/editor/src/components/popup-presenter/index.tsx
+++ b/packages/editor/src/components/popup-presenter/index.tsx
@@ -3,7 +3,7 @@ import {
useRef,
useEffect,
PropsWithChildren,
- ReactNode,
+ ReactNode
} from "react";
import { Box } from "rebass";
import { getPosition, PositionOptions } from "../../utils/position";
@@ -14,13 +14,13 @@ import { getPopupContainer, getToolbarElement } from "../../toolbar/utils/dom";
import { Theme } from "@streetwriters/theme";
import {
useIsMobile,
- useToolbarStore,
+ useToolbarStore
} from "../../toolbar/stores/toolbar-store";
import React from "react";
import {
EditorContext,
PopupRenderer,
- usePopupRenderer,
+ usePopupRenderer
} from "./popuprenderer";
import { ResponsivePresenter, ResponsivePresenterProps } from "../responsive";
import { ThemeProvider } from "../theme-provider";
@@ -41,7 +41,7 @@ function _PopupPresenter(props: PropsWithChildren<PopupPresenterProps>) {
onClose,
blocking = true,
focusOnRender = true,
- children,
+ children
} = props;
const isMobile = useIsMobile();
@@ -163,7 +163,7 @@ function _PopupPresenter(props: PropsWithChildren<PopupPresenterProps>) {
...props.style,
position: !blocking ? "initial" : "fixed",
zIndex: 1000,
- backgroundColor: !blocking ? "transparent" : "unset",
+ backgroundColor: !blocking ? "transparent" : "unset"
}}
// onClick={(e) => {
// if (!(e.target instanceof HTMLElement)) return;
@@ -200,7 +200,7 @@ function _PopupPresenter(props: PropsWithChildren<PopupPresenterProps>) {
padding: 0,
zIndex: 999,
outline: 0,
- isolation: "isolate",
+ isolation: "isolate"
}}
>
{children}
@@ -210,8 +210,8 @@ function _PopupPresenter(props: PropsWithChildren<PopupPresenterProps>) {
content: {},
overlay: {
zIndex: 999,
- background: "transparent",
- },
+ background: "transparent"
+ }
}}
>
{children}
@@ -281,7 +281,7 @@ export function PopupWrapper(props: PopupWrapperProps) {
sx={{
boxShadow: "menu",
borderRadius: "default",
- overflow: "hidden",
+ overflow: "hidden"
// width,
}}
>
@@ -361,7 +361,7 @@ export function showPopup(options: ShowPopupOptions) {
isTargetAbsolute: true,
location: "below",
align: "end",
- yOffset: 10,
+ yOffset: 10
}}
blocking
focusOnRender
diff --git a/packages/editor/src/components/popup-presenter/popuprenderer.tsx b/packages/editor/src/components/popup-presenter/popuprenderer.tsx
index daa64ef3b..d49c549bf 100644
--- a/packages/editor/src/components/popup-presenter/popuprenderer.tsx
+++ b/packages/editor/src/components/popup-presenter/popuprenderer.tsx
@@ -20,14 +20,14 @@ export class PopupRenderer extends React.Component<
> {
popupContainer: HTMLDivElement | null = null;
state: PopupRendererState = {
- popups: [] as PopupRendererState["popups"],
+ popups: [] as PopupRendererState["popups"]
};
openPopup = (id: string, popup: PopupComponent) => {
if (!popup) return;
this.setState((prev) => {
return {
- popups: [...prev.popups, { id, popup }],
+ popups: [...prev.popups, { id, popup }]
};
});
};
@@ -39,7 +39,7 @@ export class PopupRenderer extends React.Component<
const clone = prev.popups.slice();
clone.splice(index, 1);
return {
- popups: clone,
+ popups: clone
};
});
};
diff --git a/packages/editor/src/components/resizer/index.tsx b/packages/editor/src/components/resizer/index.tsx
index eb7b80f5e..7005e69f4 100644
--- a/packages/editor/src/components/resizer/index.tsx
+++ b/packages/editor/src/components/resizer/index.tsx
@@ -28,11 +28,11 @@ export function Resizer(props: PropsWithChildren<ResizerProps>) {
bottomLeft: false,
bottomRight: selected,
topLeft: false,
- topRight: false,
+ topRight: false
}}
size={{
height: height || "auto",
- width: width || "auto",
+ width: width || "auto"
}}
maxWidth="100%"
minWidth={135}
@@ -45,13 +45,13 @@ export function Resizer(props: PropsWithChildren<ResizerProps>) {
marginLeft: -20,
marginTop: -20,
borderTopLeftRadius: "default",
- borderBottomRightRadius: "default",
+ borderBottomRightRadius: "default"
}}
path={Icons.resize}
size={25}
color={handleColor || "icon"}
/>
- ),
+ )
}}
onResizeStop={(e, direction, ref, d) => {
try {
diff --git a/packages/editor/src/components/responsive/index.tsx b/packages/editor/src/components/responsive/index.tsx
index 50caef28d..b8dcd5e85 100644
--- a/packages/editor/src/components/responsive/index.tsx
+++ b/packages/editor/src/components/responsive/index.tsx
@@ -1,11 +1,11 @@
import React, { PropsWithChildren } from "react";
import {
useIsMobile,
- useToolbarStore,
+ useToolbarStore
} from "../../toolbar/stores/toolbar-store";
import {
ActionSheetPresenter,
- ActionSheetPresenterProps,
+ ActionSheetPresenterProps
} from "../action-sheet";
import { MenuPresenter, MenuPresenterProps } from "../menu";
diff --git a/packages/editor/src/components/tabs/index.tsx b/packages/editor/src/components/tabs/index.tsx
index d1794d142..f54d0d67c 100644
--- a/packages/editor/src/components/tabs/index.tsx
+++ b/packages/editor/src/components/tabs/index.tsx
@@ -28,7 +28,7 @@ export function Tabs(props: PropsWithChildren<TabsProps>) {
<Flex sx={{ flexDirection: "column" }}>
<Flex
sx={{
- mb: 1,
+ mb: 1
}}
>
{tabs?.map((tab, index) => (
@@ -49,8 +49,8 @@ export function Tabs(props: PropsWithChildren<TabsProps>) {
borderBottomColor:
activeTab === index ? "primary" : "transparent",
":hover": {
- bg: "hover",
- },
+ bg: "hover"
+ }
}}
onClick={() => {
setActiveTab(index);
diff --git a/packages/editor/src/extensions/attachment/attachment.ts b/packages/editor/src/extensions/attachment/attachment.ts
index 554386118..7fd280e0b 100644
--- a/packages/editor/src/extensions/attachment/attachment.ts
+++ b/packages/editor/src/extensions/attachment/attachment.ts
@@ -48,7 +48,7 @@ export const AttachmentNode = Node.create<AttachmentOptions>({
return {
HTMLAttributes: {},
onDownloadAttachment: () => false,
- onOpenAttachmentPicker: () => false,
+ onOpenAttachmentPicker: () => false
};
},
@@ -62,27 +62,27 @@ export const AttachmentNode = Node.create<AttachmentOptions>({
return {
progress: {
default: 0,
- rendered: false,
+ rendered: false
},
hash: getDataAttribute("hash"),
filename: getDataAttribute("filename"),
type: getDataAttribute("mime"),
- size: getDataAttribute("size"),
+ size: getDataAttribute("size")
};
},
parseHTML() {
return [
{
- tag: "span[data-hash]",
- },
+ tag: "span[data-hash]"
+ }
];
},
renderHTML({ HTMLAttributes }) {
return [
"span",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)
];
},
@@ -90,7 +90,7 @@ export const AttachmentNode = Node.create<AttachmentOptions>({
return createSelectionBasedNodeView(AttachmentComponent, {
shouldUpdate: ({ attrs: prev }, { attrs: next }) => {
return prev.progress !== next.progress;
- },
+ }
});
},
@@ -101,7 +101,7 @@ export const AttachmentNode = Node.create<AttachmentOptions>({
({ commands }) => {
return commands.insertContent({
type: this.name,
- attrs: attachment,
+ attrs: attachment
});
},
removeAttachment:
@@ -132,16 +132,16 @@ export const AttachmentNode = Node.create<AttachmentOptions>({
for (const attachment of attachments) {
tr.setNodeMarkup(attachment.pos, attachment.node.type, {
...attachment.node.attrs,
- progress: progress === 100 ? null : progress,
+ progress: progress === 100 ? null : progress
});
}
tr.setMeta("preventUpdate", true);
tr.setMeta("addToHistory", false);
if (dispatch) dispatch(tr);
return true;
- },
+ }
};
- },
+ }
// addInputRules() {
// return [
@@ -171,8 +171,8 @@ export function getDataAttribute(
}
return {
- [`data-${name}`]: attributes[name],
+ [`data-${name}`]: attributes[name]
};
- },
+ }
};
}
diff --git a/packages/editor/src/extensions/attachment/component.tsx b/packages/editor/src/extensions/attachment/component.tsx
index 0dc8a0454..28e929c42 100644
--- a/packages/editor/src/extensions/attachment/component.tsx
+++ b/packages/editor/src/extensions/attachment/component.tsx
@@ -39,8 +39,8 @@ export function AttachmentComponent(
maxWidth: 250,
borderColor: selected ? "primary" : "border",
":hover": {
- bg: "hover",
- },
+ bg: "hover"
+ }
}}
title={filename}
>
@@ -52,7 +52,7 @@ export function AttachmentComponent(
fontSize: "body",
whiteSpace: "nowrap",
textOverflow: "ellipsis",
- overflow: "hidden",
+ overflow: "hidden"
}}
>
{filename}
@@ -63,7 +63,7 @@ export function AttachmentComponent(
ml: 1,
fontSize: "0.65rem",
color: "fontTertiary",
- flexShrink: 0,
+ flexShrink: 0
}}
>
{progress ? `${progress}%` : formatBytes(size)}
@@ -78,7 +78,7 @@ export function AttachmentComponent(
borderRadius: "default",
bg: "background",
position: "absolute",
- top: -35,
+ top: -35
}}
/>
)}
diff --git a/packages/editor/src/extensions/bullet-list/bullet-list.ts b/packages/editor/src/extensions/bullet-list/bullet-list.ts
index d611f8402..88eb62f56 100644
--- a/packages/editor/src/extensions/bullet-list/bullet-list.ts
+++ b/packages/editor/src/extensions/bullet-list/bullet-list.ts
@@ -12,10 +12,10 @@ export const BulletList = TiptapBulletList.extend({
}
return {
- style: `list-style-type: ${attributes.listType}`,
+ style: `list-style-type: ${attributes.listType}`
};
- },
- },
+ }
+ }
};
- },
+ }
});
diff --git a/packages/editor/src/extensions/clipboard-text-serializer/index.ts b/packages/editor/src/extensions/clipboard-text-serializer/index.ts
index 4e066d37e..25ad6efc0 100644
--- a/packages/editor/src/extensions/clipboard-text-serializer/index.ts
+++ b/packages/editor/src/extensions/clipboard-text-serializer/index.ts
@@ -12,14 +12,14 @@ export const ClipboardTextSerializer = Extension.create({
props: {
clipboardTextSerializer: (content) => {
const {
- editor: { schema },
+ editor: { schema }
} = this;
return getTextBetween(content, schema);
- },
- },
- }),
+ }
+ }
+ })
];
- },
+ }
});
function getTextBetween(slice: Slice, schema: Schema): string {
@@ -45,7 +45,7 @@ function getTextBetween(slice: Slice, schema: Schema): string {
pos,
parent,
index,
- range,
+ range
});
}
} else if (node.isText) {
diff --git a/packages/editor/src/extensions/code-block/code-block.ts b/packages/editor/src/extensions/code-block/code-block.ts
index bd1d39d3f..38c0cfef4 100644
--- a/packages/editor/src/extensions/code-block/code-block.ts
+++ b/packages/editor/src/extensions/code-block/code-block.ts
@@ -5,7 +5,7 @@ import {
PluginKey,
TextSelection,
Transaction,
- Selection,
+ Selection
} from "prosemirror-state";
import { ResolvedPos, Node as ProsemirrorNode } from "prosemirror-model";
import { CodeblockComponent } from "./component";
@@ -88,7 +88,7 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
exitOnTripleEnter: true,
exitOnArrowDown: true,
exitOnArrowUp: true,
- HTMLAttributes: {},
+ HTMLAttributes: {}
};
},
@@ -106,11 +106,11 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
return {
caretPosition: {
default: undefined,
- rendered: false,
+ rendered: false
},
lines: {
default: [],
- rendered: false,
+ rendered: false
},
indentType: {
default: "space",
@@ -123,9 +123,9 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
return {};
}
return {
- "data-indent-type": attributes.indentType,
+ "data-indent-type": attributes.indentType
};
- },
+ }
},
indentLength: {
default: 2,
@@ -138,9 +138,9 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
return {};
}
return {
- "data-indent-length": attributes.indentLength,
+ "data-indent-length": attributes.indentLength
};
- },
+ }
},
language: {
default: null,
@@ -148,7 +148,7 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
const { languageClassPrefix } = this.options;
const classNames = [
...(element.classList || []),
- ...(element?.firstElementChild?.classList || []),
+ ...(element?.firstElementChild?.classList || [])
];
const languages = classNames
.filter((className) => className.startsWith(languageClassPrefix))
@@ -167,10 +167,10 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
}
return {
- class: `language-${attributes.language}`,
+ class: `language-${attributes.language}`
};
- },
- },
+ }
+ }
};
},
@@ -178,14 +178,14 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
return [
{
tag: "pre",
- preserveWhitespace: "full",
+ preserveWhitespace: "full"
// contentElement: (node) => {
// if (node instanceof HTMLElement) {
// node.innerText = node.innerText.replaceAll("\n\u200b\n", "\n\n");
// }
// return node;
// },
- },
+ }
];
},
@@ -193,7 +193,7 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
return [
"pre",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
- ["code", {}, 0],
+ ["code", {}, 0]
];
},
@@ -231,7 +231,7 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
const indentLength = whitespaceLength;
const indentToken = indent({
type: options.type,
- amount: indentLength,
+ amount: indentLength
});
tr.insertText(
@@ -243,10 +243,10 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
commands.updateAttributes(this.type, {
indentType: options.type,
- indentLength: options.amount,
+ indentLength: options.amount
});
return true;
- },
+ }
};
},
@@ -266,7 +266,7 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
if (!codeblock) return false;
return editor.commands.setTextSelection({
from: codeblock.pos + 1,
- to: codeblock.pos + codeblock.node.nodeSize - 1,
+ to: codeblock.pos + codeblock.node.nodeSize - 1
});
},
// remove code block when at start of document or code block is empty
@@ -438,7 +438,7 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
})
)
.run();
- },
+ }
};
},
@@ -448,16 +448,16 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
find: backtickInputRegex,
type: this.type,
getAttributes: (match) => ({
- language: match[1],
- }),
+ language: match[1]
+ })
}),
textblockTypeInputRule({
find: tildeInputRegex,
type: this.type,
getAttributes: (match) => ({
- language: match[1],
- }),
- }),
+ language: match[1]
+ })
+ })
];
},
@@ -495,7 +495,7 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
this.type.create({
language,
indentType: indent.type,
- indentLength: indent.amount,
+ indentLength: indent.amount
})
);
}
@@ -520,10 +520,10 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
view.dispatch(tr);
return true;
- },
- },
+ }
+ }
}),
- HighlighterPlugin({ name: this.name, defaultLanguage: "txt" }),
+ HighlighterPlugin({ name: this.name, defaultLanguage: "txt" })
];
},
@@ -543,9 +543,9 @@ export const CodeBlock = Node.create<CodeBlockOptions>({
prev.language !== next.language ||
prev.indentType !== next.indentType
);
- },
+ }
});
- },
+ }
});
export type CaretPosition = {
@@ -571,7 +571,7 @@ export function toCaretPosition(
column: lineLength - (line.to - $head.pos),
selected: $to.pos - $from.pos,
total: lines.length,
- from: line.from,
+ from: line.from
};
}
}
@@ -609,7 +609,7 @@ function indentOnEnter(editor: Editor, $from: ResolvedPos, options: Indent) {
return editor
.chain()
.insertContent(`${newline}${indentation}`, {
- parseOptions: { preserveWhitespace: "full" },
+ parseOptions: { preserveWhitespace: "full" }
})
.focus()
.run();
@@ -625,7 +625,7 @@ function getNewline($from: ResolvedPos, options: Indent) {
return {
newline: NEWLINE,
- indentation: indent({ amount: indentLength, type: options.type }),
+ indentation: indent({ amount: indentLength, type: options.type })
};
}
@@ -659,7 +659,7 @@ export function toCodeLines(code: string, pos: number): CodeLine[] {
lineStart,
length ? lineStart + length : lineStart + lineLength
);
- },
+ }
});
from = to + 1;
@@ -685,7 +685,7 @@ function parseIndentation(node: ProsemirrorNode): Indent | undefined {
const { indentType, indentLength } = node.attrs;
return {
type: indentType,
- amount: parseInt(indentLength),
+ amount: parseInt(indentLength)
};
}
@@ -740,7 +740,7 @@ function fixIndentation(
const { amount, type = "space" } = indent || detectIndent(code);
const fixed = redent(code, amount, {
includeEmptyLines: false,
- indent: type === "space" ? " " : "\t",
+ indent: type === "space" ? " " : "\t"
});
return { code: stripIndent(fixed), amount, type };
}
diff --git a/packages/editor/src/extensions/code-block/component.tsx b/packages/editor/src/extensions/code-block/component.tsx
index cc59582f6..be81fc385 100644
--- a/packages/editor/src/extensions/code-block/component.tsx
+++ b/packages/editor/src/extensions/code-block/component.tsx
@@ -39,7 +39,7 @@ export function CodeblockComponent(
const preventUpdate = language === languageDefinition.filename;
updateAttributes(
{
- language: languageDefinition.filename,
+ language: languageDefinition.filename
},
{ preventUpdate, addToHistory: false }
);
@@ -52,7 +52,7 @@ export function CodeblockComponent(
sx={{
flexDirection: "column",
borderRadius: "default",
- overflow: "hidden",
+ overflow: "hidden"
}}
>
<Text
@@ -66,7 +66,7 @@ export function CodeblockComponent(
fontFamily: "monospace",
fontSize: "code",
whiteSpace: "pre !important",
- tabSize: 1,
+ tabSize: 1
},
position: "relative",
lineHeight: "20px",
@@ -76,7 +76,7 @@ export function CodeblockComponent(
display: "flex",
px: 2,
pt: 2,
- pb: 1,
+ pb: 1
}}
spellCheck={false}
/>
@@ -87,7 +87,7 @@ export function CodeblockComponent(
bg: "codeBg",
alignItems: "center",
justifyContent: "flex-end",
- borderTop: "1px solid var(--codeBorder)",
+ borderTop: "1px solid var(--codeBorder)"
}}
>
{caretPosition ? (
@@ -104,7 +104,7 @@ export function CodeblockComponent(
p: 1,
mr: 1,
opacity: "1 !important",
- ":hover": { bg: "codeSelection" },
+ ":hover": { bg: "codeSelection" }
}}
title="Toggle indentation mode"
disabled={!editor.isEditable}
@@ -112,7 +112,7 @@ export function CodeblockComponent(
if (!editor.isEditable) return;
editor.commands.changeCodeBlockIndentation({
type: indentType === "space" ? "tab" : "space",
- amount: indentLength,
+ amount: indentLength
});
}}
>
@@ -127,7 +127,7 @@ export function CodeblockComponent(
p: 1,
mr: 1,
bg: isOpen ? "codeSelection" : "transparent",
- ":hover": { bg: "codeSelection" },
+ ":hover": { bg: "codeSelection" }
}}
disabled={!editor.isEditable}
onClick={() => {
@@ -167,7 +167,7 @@ export function CodeblockComponent(
align: "end",
isTargetAbsolute: true,
location: "top",
- yOffset: 5,
+ yOffset: 5
}}
title="Change code block language"
>
@@ -204,7 +204,7 @@ function LanguageSelector(props: LanguageSelectorProps) {
height: 200,
width: ["auto", 300],
overflowY: "auto",
- bg: "background",
+ bg: "background"
}}
>
<Input
@@ -220,7 +220,7 @@ function LanguageSelector(props: LanguageSelectorProps) {
bg: "background",
mx: 2,
p: "7px",
- zIndex: 999,
+ zIndex: 999
}}
onChange={(e) => {
if (!e.target.value) return setLanguages(Languages);
@@ -241,7 +241,7 @@ function LanguageSelector(props: LanguageSelectorProps) {
sx={{
flexDirection: "column",
pt: 1,
- mt: 1,
+ mt: 1
}}
>
{languages.map((lang) => (
@@ -253,7 +253,7 @@ function LanguageSelector(props: LanguageSelectorProps) {
py: 1,
display: "flex",
justifyContent: "space-between",
- alignItems: "center",
+ alignItems: "center"
}}
onClick={() => onLanguageSelected(lang.filename)}
>
diff --git a/packages/editor/src/extensions/code-block/highlighter.ts b/packages/editor/src/extensions/code-block/highlighter.ts
index 95fad3abb..4e2b55a37 100644
--- a/packages/editor/src/extensions/code-block/highlighter.ts
+++ b/packages/editor/src/extensions/code-block/highlighter.ts
@@ -3,7 +3,7 @@ import { Decoration, DecorationSet } from "prosemirror-view";
import {
findChildren,
findParentNodeClosestToPos,
- NodeWithPos,
+ NodeWithPos
} from "@tiptap/core";
import { Root, refractor } from "refractor/lib/core";
import { RootContent } from "hast";
@@ -44,7 +44,7 @@ function getHighlightNodes(result: Root) {
function getDecorations({
block,
- defaultLanguage,
+ defaultLanguage
}: {
block: NodeWithPos;
defaultLanguage: string | null | undefined;
@@ -65,7 +65,7 @@ function getDecorations({
const to = from + node.text.length;
if (node.classes.length) {
const decoration = Decoration.inline(from, to, {
- class: node.classes.join(" "),
+ class: node.classes.join(" ")
});
decorations.push(decoration);
}
@@ -77,7 +77,7 @@ function getDecorations({
export function HighlighterPlugin({
name,
- defaultLanguage,
+ defaultLanguage
}: {
name: string;
defaultLanguage: string | null | undefined;
@@ -123,7 +123,7 @@ export function HighlighterPlugin({
const newDecorations = getDecorations({
block,
- defaultLanguage,
+ defaultLanguage
});
if (!newDecorations)
return decorationSet.map(transaction.mapping, transaction.doc);
@@ -134,13 +134,13 @@ export function HighlighterPlugin({
}
return decorationSet.map(transaction.mapping, transaction.doc);
- },
+ }
},
props: {
decorations(state) {
return key.getState(state);
- },
+ }
},
appendTransaction: (transactions, oldState, newState) => {
@@ -183,6 +183,6 @@ export function HighlighterPlugin({
return tr;
}
- },
+ }
});
}
diff --git a/packages/editor/src/extensions/code-block/languages.json b/packages/editor/src/extensions/code-block/languages.json
index 08b61e12b..99d4e3289 100644
--- a/packages/editor/src/extensions/code-block/languages.json
+++ b/packages/editor/src/extensions/code-block/languages.json
@@ -1 +1,357 @@
-[{"filename":"markup","title":"Markup","alias":["html","xml","svg","mathml","ssml","atom","rss"]},{"filename":"css","title":"CSS"},{"filename":"clike","title":"C-like"},{"filename":"javascript","title":"JavaScript","alias":["js"]},{"filename":"abap","title":"ABAP"},{"filename":"abnf","title":"ABNF"},{"filename":"actionscript","title":"ActionScript"},{"filename":"ada","title":"Ada"},{"filename":"agda","title":"Agda"},{"filename":"al","title":"AL"},{"filename":"antlr4","title":"ANTLR4","alias":["g4"]},{"filename":"apacheconf","title":"Apache Configuration"},{"filename":"apex","title":"Apex"},{"filename":"apl","title":"APL"},{"filename":"applescript","title":"AppleScript"},{"filename":"aql","title":"AQL"},{"filename":"arduino","title":"Arduino","alias":["ino"]},{"filename":"arff","title":"ARFF"},{"filename":"armasm","title":"ARM Assembly","alias":["arm-asm"]},{"filename":"arturo","title":"Arturo","alias":["art"]},{"filename":"asciidoc","title":"AsciiDoc","alias":["adoc"]},{"filename":"aspnet","title":"ASP.NET (C#)"},{"filename":"asm6502","title":"6502 Assembly"},{"filename":"asmatmel","title":"Atmel AVR Assembly"},{"filename":"autohotkey","title":"AutoHotkey"},{"filename":"autoit","title":"AutoIt"},{"filename":"avisynth","title":"AviSynth","alias":["avs"]},{"filename":"avro-idl","title":"Avro IDL","alias":["avdl"]},{"filename":"awk","title":"AWK","alias":["gawk"]},{"filename":"bash","title":"Bash","alias":["shell"]},{"filename":"basic","title":"BASIC"},{"filename":"batch","title":"Batch"},{"filename":"bbcode","title":"BBcode","alias":["shortcode"]},{"filename":"bicep","title":"Bicep"},{"filename":"birb","title":"Birb"},{"filename":"bison","title":"Bison"},{"filename":"bnf","title":"BNF","alias":["rbnf"]},{"filename":"brainfuck","title":"Brainfuck"},{"filename":"brightscript","title":"BrightScript"},{"filename":"bro","title":"Bro"},{"filename":"bsl","title":"BSL (1C:Enterprise)","alias":["oscript"]},{"filename":"c","title":"C"},{"filename":"csharp","title":"C#","alias":["cs","dotnet"]},{"filename":"cpp","title":"C++"},{"filename":"cfscript","title":"CFScript","alias":["cfc"]},{"filename":"chaiscript","title":"ChaiScript"},{"filename":"cil","title":"CIL"},{"filename":"clojure","title":"Clojure"},{"filename":"cmake","title":"CMake"},{"filename":"cobol","title":"COBOL"},{"filename":"coffeescript","title":"CoffeeScript","alias":["coffee"]},{"filename":"concurnas","title":"Concurnas","alias":["conc"]},{"filename":"csp","title":"Content-Security-Policy"},{"filename":"cooklang","title":"Cooklang"},{"filename":"coq","title":"Coq"},{"filename":"crystal","title":"Crystal"},{"filename":"css-extras","title":"CSS Extras"},{"filename":"csv","title":"CSV"},{"filename":"cue","title":"CUE"},{"filename":"cypher","title":"Cypher"},{"filename":"d","title":"D"},{"filename":"dart","title":"Dart"},{"filename":"dataweave","title":"DataWeave"},{"filename":"dax","title":"DAX"},{"filename":"dhall","title":"Dhall"},{"filename":"diff","title":"Diff"},{"filename":"django","title":"Django/Jinja2","alias":["jinja2"]},{"filename":"dns-zone-file","title":"DNS zone file","alias":["dns-zone"]},{"filename":"docker","title":"Docker","alias":["dockerfile"]},{"filename":"dot","title":"DOT (Graphviz)","alias":["gv"]},{"filename":"ebnf","title":"EBNF"},{"filename":"editorconfig","title":"EditorConfig"},{"filename":"eiffel","title":"Eiffel"},{"filename":"ejs","title":"EJS","alias":["eta"]},{"filename":"elixir","title":"Elixir"},{"filename":"elm","title":"Elm"},{"filename":"etlua","title":"Embedded Lua templating"},{"filename":"erb","title":"ERB"},{"filename":"erlang","title":"Erlang"},{"filename":"excel-formula","title":"Excel Formula","alias":["xlsx","xls"]},{"filename":"fsharp","title":"F#"},{"filename":"factor","title":"Factor"},{"filename":"false","title":"False"},{"filename":"firestore-security-rules","title":"Firestore security rules"},{"filename":"flow","title":"Flow"},{"filename":"fortran","title":"Fortran"},{"filename":"ftl","title":"FreeMarker Template Language"},{"filename":"gml","title":"GameMaker Language","alias":["gamemakerlanguage"]},{"filename":"gap","title":"GAP (CAS)"},{"filename":"gcode","title":"G-code"},{"filename":"gdscript","title":"GDScript"},{"filename":"gedcom","title":"GEDCOM"},{"filename":"gettext","title":"gettext","alias":["po"]},{"filename":"gherkin","title":"Gherkin"},{"filename":"git","title":"Git"},{"filename":"glsl","title":"GLSL"},{"filename":"gn","title":"GN","alias":["gni"]},{"filename":"linker-script","title":"GNU Linker Script","alias":["ld"]},{"filename":"go","title":"Go"},{"filename":"go-module","title":"Go module","alias":["go-mod"]},{"filename":"gradle","title":"Gradle"},{"filename":"graphql","title":"GraphQL"},{"filename":"groovy","title":"Groovy"},{"filename":"haml","title":"Haml"},{"filename":"handlebars","title":"Handlebars","alias":["hbs","mustache"]},{"filename":"haskell","title":"Haskell","alias":["hs"]},{"filename":"haxe","title":"Haxe"},{"filename":"hcl","title":"HCL"},{"filename":"hlsl","title":"HLSL"},{"filename":"hoon","title":"Hoon"},{"filename":"http","title":"HTTP"},{"filename":"hpkp","title":"HTTP Public-Key-Pins"},{"filename":"hsts","title":"HTTP Strict-Transport-Security"},{"filename":"ichigojam","title":"IchigoJam"},{"filename":"icon","title":"Icon"},{"filename":"icu-message-format","title":"ICU Message Format"},{"filename":"idris","title":"Idris","alias":["idr"]},{"filename":"ignore","title":".ignore","alias":["gitignore","hgignore","npmignore"]},{"filename":"inform7","title":"Inform 7"},{"filename":"ini","title":"Ini"},{"filename":"io","title":"Io"},{"filename":"j","title":"J"},{"filename":"java","title":"Java"},{"filename":"javadoc","title":"JavaDoc"},{"filename":"javadoclike","title":"JavaDoc-like"},{"filename":"javastacktrace","title":"Java stack trace"},{"filename":"jexl","title":"Jexl"},{"filename":"jolie","title":"Jolie"},{"filename":"jq","title":"JQ"},{"filename":"jsdoc","title":"JSDoc"},{"filename":"js-extras","title":"JS Extras"},{"filename":"json","title":"JSON","alias":["webmanifest"]},{"filename":"json5","title":"JSON5"},{"filename":"jsonp","title":"JSONP"},{"filename":"jsstacktrace","title":"JS stack trace"},{"filename":"js-templates","title":"JS Templates"},{"filename":"julia","title":"Julia"},{"filename":"keepalived","title":"Keepalived Configure"},{"filename":"keyman","title":"Keyman"},{"filename":"kotlin","title":"Kotlin","alias":["kt","kts"]},{"filename":"kumir","title":"KuMir (КуМир)","alias":["kum"]},{"filename":"kusto","title":"Kusto"},{"filename":"latex","title":"LaTeX","alias":["tex","context"]},{"filename":"latte","title":"Latte"},{"filename":"less","title":"Less"},{"filename":"lilypond","title":"LilyPond","alias":["ly"]},{"filename":"liquid","title":"Liquid"},{"filename":"lisp","title":"Lisp","alias":["emacs","elisp","emacs-lisp"]},{"filename":"livescript","title":"LiveScript"},{"filename":"llvm","title":"LLVM IR"},{"filename":"log","title":"Log file"},{"filename":"lolcode","title":"LOLCODE"},{"filename":"lua","title":"Lua"},{"filename":"magma","title":"Magma (CAS)"},{"filename":"makefile","title":"Makefile"},{"filename":"markdown","title":"Markdown","alias":["md"]},{"filename":"markup-templating","title":"Markup templating"},{"filename":"mata","title":"Mata"},{"filename":"matlab","title":"MATLAB"},{"filename":"maxscript","title":"MAXScript"},{"filename":"mel","title":"MEL"},{"filename":"mermaid","title":"Mermaid"},{"filename":"mizar","title":"Mizar"},{"filename":"mongodb","title":"MongoDB"},{"filename":"monkey","title":"Monkey"},{"filename":"moonscript","title":"MoonScript","alias":["moon"]},{"filename":"n1ql","title":"N1QL"},{"filename":"n4js","title":"N4JS","alias":["n4jsd"]},{"filename":"nand2tetris-hdl","title":"Nand To Tetris HDL"},{"filename":"naniscript","title":"Naninovel Script","alias":["nani"]},{"filename":"nasm","title":"NASM"},{"filename":"neon","title":"NEON"},{"filename":"nevod","title":"Nevod"},{"filename":"nginx","title":"nginx"},{"filename":"nim","title":"Nim"},{"filename":"nix","title":"Nix"},{"filename":"nsis","title":"NSIS"},{"filename":"objectivec","title":"Objective-C","alias":["objc"]},{"filename":"ocaml","title":"OCaml"},{"filename":"odin","title":"Odin"},{"filename":"opencl","title":"OpenCL"},{"filename":"openqasm","title":"OpenQasm","alias":["qasm"]},{"filename":"oz","title":"Oz"},{"filename":"parigp","title":"PARI/GP"},{"filename":"parser","title":"Parser"},{"filename":"pascal","title":"Pascal","alias":["objectpascal"]},{"filename":"pascaligo","title":"Pascaligo"},{"filename":"psl","title":"PATROL Scripting Language"},{"filename":"pcaxis","title":"PC-Axis","alias":["px"]},{"filename":"peoplecode","title":"PeopleCode","alias":["pcode"]},{"filename":"perl","title":"Perl"},{"filename":"php","title":"PHP"},{"filename":"phpdoc","title":"PHPDoc"},{"filename":"php-extras","title":"PHP Extras"},{"filename":"plant-uml","title":"PlantUML","alias":["plantuml"]},{"filename":"plsql","title":"PL/SQL"},{"filename":"powerquery","title":"PowerQuery","alias":["pq","mscript"]},{"filename":"powershell","title":"PowerShell"},{"filename":"processing","title":"Processing"},{"filename":"prolog","title":"Prolog"},{"filename":"promql","title":"PromQL"},{"filename":"properties","title":".properties"},{"filename":"protobuf","title":"Protocol Buffers"},{"filename":"pug","title":"Pug"},{"filename":"puppet","title":"Puppet"},{"filename":"pure","title":"Pure"},{"filename":"purebasic","title":"PureBasic","alias":["pbfasm"]},{"filename":"purescript","title":"PureScript","alias":["purs"]},{"filename":"python","title":"Python","alias":["py"]},{"filename":"qsharp","title":"Q#","alias":["qs"]},{"filename":"q","title":"Q (kdb+ database)"},{"filename":"qml","title":"QML"},{"filename":"qore","title":"Qore"},{"filename":"r","title":"R"},{"filename":"racket","title":"Racket","alias":["rkt"]},{"filename":"cshtml","title":"Razor C#","alias":["razor"]},{"filename":"jsx","title":"React JSX"},{"filename":"tsx","title":"React TSX"},{"filename":"reason","title":"Reason"},{"filename":"regex","title":"Regex"},{"filename":"rego","title":"Rego"},{"filename":"renpy","title":"Ren'py","alias":["rpy"]},{"filename":"rescript","title":"ReScript","alias":["res"]},{"filename":"rest","title":"reST (reStructuredText)"},{"filename":"rip","title":"Rip"},{"filename":"roboconf","title":"Roboconf"},{"filename":"robotframework","title":"Robot Framework","alias":["robot"]},{"filename":"ruby","title":"Ruby","alias":["rb"]},{"filename":"rust","title":"Rust"},{"filename":"sas","title":"SAS"},{"filename":"sass","title":"Sass (Sass)"},{"filename":"scss","title":"Sass (Scss)"},{"filename":"scala","title":"Scala"},{"filename":"scheme","title":"Scheme"},{"filename":"shell-session","title":"Shell session","alias":["sh-session","shellsession"]},{"filename":"smali","title":"Smali"},{"filename":"smalltalk","title":"Smalltalk"},{"filename":"smarty","title":"Smarty"},{"filename":"sml","title":"SML","alias":["smlnj"]},{"filename":"solidity","title":"Solidity (Ethereum)","alias":["sol"]},{"filename":"solution-file","title":"Solution file","alias":["sln"]},{"filename":"soy","title":"Soy (Closure Template)"},{"filename":"sparql","title":"SPARQL","alias":["rq"]},{"filename":"splunk-spl","title":"Splunk SPL"},{"filename":"sqf","title":"SQF: Status Quo Function (Arma 3)"},{"filename":"sql","title":"SQL"},{"filename":"squirrel","title":"Squirrel"},{"filename":"stan","title":"Stan"},{"filename":"stata","title":"Stata Ado"},{"filename":"iecst","title":"Structured Text (IEC 61131-3)"},{"filename":"stylus","title":"Stylus"},{"filename":"supercollider","title":"SuperCollider","alias":["sclang"]},{"filename":"swift","title":"Swift"},{"filename":"systemd","title":"Systemd configuration file"},{"filename":"t4-templating","title":"T4 templating"},{"filename":"t4-cs","title":"T4 Text Templates (C#)","alias":["t4"]},{"filename":"t4-vb","title":"T4 Text Templates (VB)"},{"filename":"tap","title":"TAP"},{"filename":"tcl","title":"Tcl"},{"filename":"tt2","title":"Template Toolkit 2"},{"filename":"textile","title":"Textile"},{"filename":"toml","title":"TOML"},{"filename":"tremor","title":"Tremor","alias":["trickle","troy"]},{"filename":"turtle","title":"Turtle","alias":["trig"]},{"filename":"twig","title":"Twig"},{"filename":"typescript","title":"TypeScript","alias":["ts"]},{"filename":"typoscript","title":"TypoScript","alias":["tsconfig"]},{"filename":"unrealscript","title":"UnrealScript","alias":["uscript","uc"]},{"filename":"uorazor","title":"UO Razor Script"},{"filename":"uri","title":"URI","alias":["url"]},{"filename":"v","title":"V"},{"filename":"vala","title":"Vala"},{"filename":"vbnet","title":"VB.Net"},{"filename":"velocity","title":"Velocity"},{"filename":"verilog","title":"Verilog"},{"filename":"vhdl","title":"VHDL"},{"filename":"vim","title":"vim"},{"filename":"visual-basic","title":"Visual Basic","alias":["vb","vba"]},{"filename":"warpscript","title":"WarpScript"},{"filename":"wasm","title":"WebAssembly"},{"filename":"web-idl","title":"Web IDL","alias":["webidl"]},{"filename":"wgsl","title":"WGSL"},{"filename":"wiki","title":"Wiki markup"},{"filename":"wolfram","title":"Wolfram language","alias":["mathematica","nb","wl"]},{"filename":"wren","title":"Wren"},{"filename":"xeora","title":"Xeora","alias":["xeoracube"]},{"filename":"xml-doc","title":"XML doc (.net)"},{"filename":"xojo","title":"Xojo (REALbasic)"},{"filename":"xquery","title":"XQuery"},{"filename":"yaml","title":"YAML","alias":["yml"]},{"filename":"yang","title":"YANG"},{"filename":"zig","title":"Zig"}]
+[
+ {
+ "filename": "markup",
+ "title": "Markup",
+ "alias": ["html", "xml", "svg", "mathml", "ssml", "atom", "rss"]
+ },
+ { "filename": "css", "title": "CSS" },
+ { "filename": "clike", "title": "C-like" },
+ { "filename": "javascript", "title": "JavaScript", "alias": ["js"] },
+ { "filename": "abap", "title": "ABAP" },
+ { "filename": "abnf", "title": "ABNF" },
+ { "filename": "actionscript", "title": "ActionScript" },
+ { "filename": "ada", "title": "Ada" },
+ { "filename": "agda", "title": "Agda" },
+ { "filename": "al", "title": "AL" },
+ { "filename": "antlr4", "title": "ANTLR4", "alias": ["g4"] },
+ { "filename": "apacheconf", "title": "Apache Configuration" },
+ { "filename": "apex", "title": "Apex" },
+ { "filename": "apl", "title": "APL" },
+ { "filename": "applescript", "title": "AppleScript" },
+ { "filename": "aql", "title": "AQL" },
+ { "filename": "arduino", "title": "Arduino", "alias": ["ino"] },
+ { "filename": "arff", "title": "ARFF" },
+ { "filename": "armasm", "title": "ARM Assembly", "alias": ["arm-asm"] },
+ { "filename": "arturo", "title": "Arturo", "alias": ["art"] },
+ { "filename": "asciidoc", "title": "AsciiDoc", "alias": ["adoc"] },
+ { "filename": "aspnet", "title": "ASP.NET (C#)" },
+ { "filename": "asm6502", "title": "6502 Assembly" },
+ { "filename": "asmatmel", "title": "Atmel AVR Assembly" },
+ { "filename": "autohotkey", "title": "AutoHotkey" },
+ { "filename": "autoit", "title": "AutoIt" },
+ { "filename": "avisynth", "title": "AviSynth", "alias": ["avs"] },
+ { "filename": "avro-idl", "title": "Avro IDL", "alias": ["avdl"] },
+ { "filename": "awk", "title": "AWK", "alias": ["gawk"] },
+ { "filename": "bash", "title": "Bash", "alias": ["shell"] },
+ { "filename": "basic", "title": "BASIC" },
+ { "filename": "batch", "title": "Batch" },
+ { "filename": "bbcode", "title": "BBcode", "alias": ["shortcode"] },
+ { "filename": "bicep", "title": "Bicep" },
+ { "filename": "birb", "title": "Birb" },
+ { "filename": "bison", "title": "Bison" },
+ { "filename": "bnf", "title": "BNF", "alias": ["rbnf"] },
+ { "filename": "brainfuck", "title": "Brainfuck" },
+ { "filename": "brightscript", "title": "BrightScript" },
+ { "filename": "bro", "title": "Bro" },
+ { "filename": "bsl", "title": "BSL (1C:Enterprise)", "alias": ["oscript"] },
+ { "filename": "c", "title": "C" },
+ { "filename": "csharp", "title": "C#", "alias": ["cs", "dotnet"] },
+ { "filename": "cpp", "title": "C++" },
+ { "filename": "cfscript", "title": "CFScript", "alias": ["cfc"] },
+ { "filename": "chaiscript", "title": "ChaiScript" },
+ { "filename": "cil", "title": "CIL" },
+ { "filename": "clojure", "title": "Clojure" },
+ { "filename": "cmake", "title": "CMake" },
+ { "filename": "cobol", "title": "COBOL" },
+ { "filename": "coffeescript", "title": "CoffeeScript", "alias": ["coffee"] },
+ { "filename": "concurnas", "title": "Concurnas", "alias": ["conc"] },
+ { "filename": "csp", "title": "Content-Security-Policy" },
+ { "filename": "cooklang", "title": "Cooklang" },
+ { "filename": "coq", "title": "Coq" },
+ { "filename": "crystal", "title": "Crystal" },
+ { "filename": "css-extras", "title": "CSS Extras" },
+ { "filename": "csv", "title": "CSV" },
+ { "filename": "cue", "title": "CUE" },
+ { "filename": "cypher", "title": "Cypher" },
+ { "filename": "d", "title": "D" },
+ { "filename": "dart", "title": "Dart" },
+ { "filename": "dataweave", "title": "DataWeave" },
+ { "filename": "dax", "title": "DAX" },
+ { "filename": "dhall", "title": "Dhall" },
+ { "filename": "diff", "title": "Diff" },
+ { "filename": "django", "title": "Django/Jinja2", "alias": ["jinja2"] },
+ {
+ "filename": "dns-zone-file",
+ "title": "DNS zone file",
+ "alias": ["dns-zone"]
+ },
+ { "filename": "docker", "title": "Docker", "alias": ["dockerfile"] },
+ { "filename": "dot", "title": "DOT (Graphviz)", "alias": ["gv"] },
+ { "filename": "ebnf", "title": "EBNF" },
+ { "filename": "editorconfig", "title": "EditorConfig" },
+ { "filename": "eiffel", "title": "Eiffel" },
+ { "filename": "ejs", "title": "EJS", "alias": ["eta"] },
+ { "filename": "elixir", "title": "Elixir" },
+ { "filename": "elm", "title": "Elm" },
+ { "filename": "etlua", "title": "Embedded Lua templating" },
+ { "filename": "erb", "title": "ERB" },
+ { "filename": "erlang", "title": "Erlang" },
+ {
+ "filename": "excel-formula",
+ "title": "Excel Formula",
+ "alias": ["xlsx", "xls"]
+ },
+ { "filename": "fsharp", "title": "F#" },
+ { "filename": "factor", "title": "Factor" },
+ { "filename": "false", "title": "False" },
+ {
+ "filename": "firestore-security-rules",
+ "title": "Firestore security rules"
+ },
+ { "filename": "flow", "title": "Flow" },
+ { "filename": "fortran", "title": "Fortran" },
+ { "filename": "ftl", "title": "FreeMarker Template Language" },
+ {
+ "filename": "gml",
+ "title": "GameMaker Language",
+ "alias": ["gamemakerlanguage"]
+ },
+ { "filename": "gap", "title": "GAP (CAS)" },
+ { "filename": "gcode", "title": "G-code" },
+ { "filename": "gdscript", "title": "GDScript" },
+ { "filename": "gedcom", "title": "GEDCOM" },
+ { "filename": "gettext", "title": "gettext", "alias": ["po"] },
+ { "filename": "gherkin", "title": "Gherkin" },
+ { "filename": "git", "title": "Git" },
+ { "filename": "glsl", "title": "GLSL" },
+ { "filename": "gn", "title": "GN", "alias": ["gni"] },
+ {
+ "filename": "linker-script",
+ "title": "GNU Linker Script",
+ "alias": ["ld"]
+ },
+ { "filename": "go", "title": "Go" },
+ { "filename": "go-module", "title": "Go module", "alias": ["go-mod"] },
+ { "filename": "gradle", "title": "Gradle" },
+ { "filename": "graphql", "title": "GraphQL" },
+ { "filename": "groovy", "title": "Groovy" },
+ { "filename": "haml", "title": "Haml" },
+ {
+ "filename": "handlebars",
+ "title": "Handlebars",
+ "alias": ["hbs", "mustache"]
+ },
+ { "filename": "haskell", "title": "Haskell", "alias": ["hs"] },
+ { "filename": "haxe", "title": "Haxe" },
+ { "filename": "hcl", "title": "HCL" },
+ { "filename": "hlsl", "title": "HLSL" },
+ { "filename": "hoon", "title": "Hoon" },
+ { "filename": "http", "title": "HTTP" },
+ { "filename": "hpkp", "title": "HTTP Public-Key-Pins" },
+ { "filename": "hsts", "title": "HTTP Strict-Transport-Security" },
+ { "filename": "ichigojam", "title": "IchigoJam" },
+ { "filename": "icon", "title": "Icon" },
+ { "filename": "icu-message-format", "title": "ICU Message Format" },
+ { "filename": "idris", "title": "Idris", "alias": ["idr"] },
+ {
+ "filename": "ignore",
+ "title": ".ignore",
+ "alias": ["gitignore", "hgignore", "npmignore"]
+ },
+ { "filename": "inform7", "title": "Inform 7" },
+ { "filename": "ini", "title": "Ini" },
+ { "filename": "io", "title": "Io" },
+ { "filename": "j", "title": "J" },
+ { "filename": "java", "title": "Java" },
+ { "filename": "javadoc", "title": "JavaDoc" },
+ { "filename": "javadoclike", "title": "JavaDoc-like" },
+ { "filename": "javastacktrace", "title": "Java stack trace" },
+ { "filename": "jexl", "title": "Jexl" },
+ { "filename": "jolie", "title": "Jolie" },
+ { "filename": "jq", "title": "JQ" },
+ { "filename": "jsdoc", "title": "JSDoc" },
+ { "filename": "js-extras", "title": "JS Extras" },
+ { "filename": "json", "title": "JSON", "alias": ["webmanifest"] },
+ { "filename": "json5", "title": "JSON5" },
+ { "filename": "jsonp", "title": "JSONP" },
+ { "filename": "jsstacktrace", "title": "JS stack trace" },
+ { "filename": "js-templates", "title": "JS Templates" },
+ { "filename": "julia", "title": "Julia" },
+ { "filename": "keepalived", "title": "Keepalived Configure" },
+ { "filename": "keyman", "title": "Keyman" },
+ { "filename": "kotlin", "title": "Kotlin", "alias": ["kt", "kts"] },
+ { "filename": "kumir", "title": "KuMir (КуМир)", "alias": ["kum"] },
+ { "filename": "kusto", "title": "Kusto" },
+ { "filename": "latex", "title": "LaTeX", "alias": ["tex", "context"] },
+ { "filename": "latte", "title": "Latte" },
+ { "filename": "less", "title": "Less" },
+ { "filename": "lilypond", "title": "LilyPond", "alias": ["ly"] },
+ { "filename": "liquid", "title": "Liquid" },
+ {
+ "filename": "lisp",
+ "title": "Lisp",
+ "alias": ["emacs", "elisp", "emacs-lisp"]
+ },
+ { "filename": "livescript", "title": "LiveScript" },
+ { "filename": "llvm", "title": "LLVM IR" },
+ { "filename": "log", "title": "Log file" },
+ { "filename": "lolcode", "title": "LOLCODE" },
+ { "filename": "lua", "title": "Lua" },
+ { "filename": "magma", "title": "Magma (CAS)" },
+ { "filename": "makefile", "title": "Makefile" },
+ { "filename": "markdown", "title": "Markdown", "alias": ["md"] },
+ { "filename": "markup-templating", "title": "Markup templating" },
+ { "filename": "mata", "title": "Mata" },
+ { "filename": "matlab", "title": "MATLAB" },
+ { "filename": "maxscript", "title": "MAXScript" },
+ { "filename": "mel", "title": "MEL" },
+ { "filename": "mermaid", "title": "Mermaid" },
+ { "filename": "mizar", "title": "Mizar" },
+ { "filename": "mongodb", "title": "MongoDB" },
+ { "filename": "monkey", "title": "Monkey" },
+ { "filename": "moonscript", "title": "MoonScript", "alias": ["moon"] },
+ { "filename": "n1ql", "title": "N1QL" },
+ { "filename": "n4js", "title": "N4JS", "alias": ["n4jsd"] },
+ { "filename": "nand2tetris-hdl", "title": "Nand To Tetris HDL" },
+ { "filename": "naniscript", "title": "Naninovel Script", "alias": ["nani"] },
+ { "filename": "nasm", "title": "NASM" },
+ { "filename": "neon", "title": "NEON" },
+ { "filename": "nevod", "title": "Nevod" },
+ { "filename": "nginx", "title": "nginx" },
+ { "filename": "nim", "title": "Nim" },
+ { "filename": "nix", "title": "Nix" },
+ { "filename": "nsis", "title": "NSIS" },
+ { "filename": "objectivec", "title": "Objective-C", "alias": ["objc"] },
+ { "filename": "ocaml", "title": "OCaml" },
+ { "filename": "odin", "title": "Odin" },
+ { "filename": "opencl", "title": "OpenCL" },
+ { "filename": "openqasm", "title": "OpenQasm", "alias": ["qasm"] },
+ { "filename": "oz", "title": "Oz" },
+ { "filename": "parigp", "title": "PARI/GP" },
+ { "filename": "parser", "title": "Parser" },
+ { "filename": "pascal", "title": "Pascal", "alias": ["objectpascal"] },
+ { "filename": "pascaligo", "title": "Pascaligo" },
+ { "filename": "psl", "title": "PATROL Scripting Language" },
+ { "filename": "pcaxis", "title": "PC-Axis", "alias": ["px"] },
+ { "filename": "peoplecode", "title": "PeopleCode", "alias": ["pcode"] },
+ { "filename": "perl", "title": "Perl" },
+ { "filename": "php", "title": "PHP" },
+ { "filename": "phpdoc", "title": "PHPDoc" },
+ { "filename": "php-extras", "title": "PHP Extras" },
+ { "filename": "plant-uml", "title": "PlantUML", "alias": ["plantuml"] },
+ { "filename": "plsql", "title": "PL/SQL" },
+ {
+ "filename": "powerquery",
+ "title": "PowerQuery",
+ "alias": ["pq", "mscript"]
+ },
+ { "filename": "powershell", "title": "PowerShell" },
+ { "filename": "processing", "title": "Processing" },
+ { "filename": "prolog", "title": "Prolog" },
+ { "filename": "promql", "title": "PromQL" },
+ { "filename": "properties", "title": ".properties" },
+ { "filename": "protobuf", "title": "Protocol Buffers" },
+ { "filename": "pug", "title": "Pug" },
+ { "filename": "puppet", "title": "Puppet" },
+ { "filename": "pure", "title": "Pure" },
+ { "filename": "purebasic", "title": "PureBasic", "alias": ["pbfasm"] },
+ { "filename": "purescript", "title": "PureScript", "alias": ["purs"] },
+ { "filename": "python", "title": "Python", "alias": ["py"] },
+ { "filename": "qsharp", "title": "Q#", "alias": ["qs"] },
+ { "filename": "q", "title": "Q (kdb+ database)" },
+ { "filename": "qml", "title": "QML" },
+ { "filename": "qore", "title": "Qore" },
+ { "filename": "r", "title": "R" },
+ { "filename": "racket", "title": "Racket", "alias": ["rkt"] },
+ { "filename": "cshtml", "title": "Razor C#", "alias": ["razor"] },
+ { "filename": "jsx", "title": "React JSX" },
+ { "filename": "tsx", "title": "React TSX" },
+ { "filename": "reason", "title": "Reason" },
+ { "filename": "regex", "title": "Regex" },
+ { "filename": "rego", "title": "Rego" },
+ { "filename": "renpy", "title": "Ren'py", "alias": ["rpy"] },
+ { "filename": "rescript", "title": "ReScript", "alias": ["res"] },
+ { "filename": "rest", "title": "reST (reStructuredText)" },
+ { "filename": "rip", "title": "Rip" },
+ { "filename": "roboconf", "title": "Roboconf" },
+ {
+ "filename": "robotframework",
+ "title": "Robot Framework",
+ "alias": ["robot"]
+ },
+ { "filename": "ruby", "title": "Ruby", "alias": ["rb"] },
+ { "filename": "rust", "title": "Rust" },
+ { "filename": "sas", "title": "SAS" },
+ { "filename": "sass", "title": "Sass (Sass)" },
+ { "filename": "scss", "title": "Sass (Scss)" },
+ { "filename": "scala", "title": "Scala" },
+ { "filename": "scheme", "title": "Scheme" },
+ {
+ "filename": "shell-session",
+ "title": "Shell session",
+ "alias": ["sh-session", "shellsession"]
+ },
+ { "filename": "smali", "title": "Smali" },
+ { "filename": "smalltalk", "title": "Smalltalk" },
+ { "filename": "smarty", "title": "Smarty" },
+ { "filename": "sml", "title": "SML", "alias": ["smlnj"] },
+ { "filename": "solidity", "title": "Solidity (Ethereum)", "alias": ["sol"] },
+ { "filename": "solution-file", "title": "Solution file", "alias": ["sln"] },
+ { "filename": "soy", "title": "Soy (Closure Template)" },
+ { "filename": "sparql", "title": "SPARQL", "alias": ["rq"] },
+ { "filename": "splunk-spl", "title": "Splunk SPL" },
+ { "filename": "sqf", "title": "SQF: Status Quo Function (Arma 3)" },
+ { "filename": "sql", "title": "SQL" },
+ { "filename": "squirrel", "title": "Squirrel" },
+ { "filename": "stan", "title": "Stan" },
+ { "filename": "stata", "title": "Stata Ado" },
+ { "filename": "iecst", "title": "Structured Text (IEC 61131-3)" },
+ { "filename": "stylus", "title": "Stylus" },
+ {
+ "filename": "supercollider",
+ "title": "SuperCollider",
+ "alias": ["sclang"]
+ },
+ { "filename": "swift", "title": "Swift" },
+ { "filename": "systemd", "title": "Systemd configuration file" },
+ { "filename": "t4-templating", "title": "T4 templating" },
+ { "filename": "t4-cs", "title": "T4 Text Templates (C#)", "alias": ["t4"] },
+ { "filename": "t4-vb", "title": "T4 Text Templates (VB)" },
+ { "filename": "tap", "title": "TAP" },
+ { "filename": "tcl", "title": "Tcl" },
+ { "filename": "tt2", "title": "Template Toolkit 2" },
+ { "filename": "textile", "title": "Textile" },
+ { "filename": "toml", "title": "TOML" },
+ { "filename": "tremor", "title": "Tremor", "alias": ["trickle", "troy"] },
+ { "filename": "turtle", "title": "Turtle", "alias": ["trig"] },
+ { "filename": "twig", "title": "Twig" },
+ { "filename": "typescript", "title": "TypeScript", "alias": ["ts"] },
+ { "filename": "typoscript", "title": "TypoScript", "alias": ["tsconfig"] },
+ {
+ "filename": "unrealscript",
+ "title": "UnrealScript",
+ "alias": ["uscript", "uc"]
+ },
+ { "filename": "uorazor", "title": "UO Razor Script" },
+ { "filename": "uri", "title": "URI", "alias": ["url"] },
+ { "filename": "v", "title": "V" },
+ { "filename": "vala", "title": "Vala" },
+ { "filename": "vbnet", "title": "VB.Net" },
+ { "filename": "velocity", "title": "Velocity" },
+ { "filename": "verilog", "title": "Verilog" },
+ { "filename": "vhdl", "title": "VHDL" },
+ { "filename": "vim", "title": "vim" },
+ {
+ "filename": "visual-basic",
+ "title": "Visual Basic",
+ "alias": ["vb", "vba"]
+ },
+ { "filename": "warpscript", "title": "WarpScript" },
+ { "filename": "wasm", "title": "WebAssembly" },
+ { "filename": "web-idl", "title": "Web IDL", "alias": ["webidl"] },
+ { "filename": "wgsl", "title": "WGSL" },
+ { "filename": "wiki", "title": "Wiki markup" },
+ {
+ "filename": "wolfram",
+ "title": "Wolfram language",
+ "alias": ["mathematica", "nb", "wl"]
+ },
+ { "filename": "wren", "title": "Wren" },
+ { "filename": "xeora", "title": "Xeora", "alias": ["xeoracube"] },
+ { "filename": "xml-doc", "title": "XML doc (.net)" },
+ { "filename": "xojo", "title": "Xojo (REALbasic)" },
+ { "filename": "xquery", "title": "XQuery" },
+ { "filename": "yaml", "title": "YAML", "alias": ["yml"] },
+ { "filename": "yang", "title": "YANG" },
+ { "filename": "zig", "title": "Zig" }
+]
diff --git a/packages/editor/src/extensions/code-mark/code-mark.ts b/packages/editor/src/extensions/code-mark/code-mark.ts
index d2e63535b..cf091d0f5 100644
--- a/packages/editor/src/extensions/code-mark/code-mark.ts
+++ b/packages/editor/src/extensions/code-mark/code-mark.ts
@@ -5,5 +5,5 @@ export const Codemark = Extension.create({
name: "codemarkPlugin",
addProseMirrorPlugins() {
return codemark({ markType: this.editor.schema.marks.code });
- },
+ }
});
diff --git a/packages/editor/src/extensions/date-time/date-time.ts b/packages/editor/src/extensions/date-time/date-time.ts
index 3145c0bb6..4da292247 100644
--- a/packages/editor/src/extensions/date-time/date-time.ts
+++ b/packages/editor/src/extensions/date-time/date-time.ts
@@ -2,7 +2,7 @@ import {
Extension,
InputRule,
InputRuleFinder,
- ExtendedRegExpMatchArray,
+ ExtendedRegExpMatchArray
} from "@tiptap/core";
declare module "@tiptap/core" {
@@ -31,7 +31,7 @@ export const DateTime = Extension.create({
return {
"Alt-t": ({ editor }) => editor.commands.insertTime(),
"Alt-d": ({ editor }) => editor.commands.insertDate(),
- "Mod-Alt-d": ({ editor }) => editor.commands.insertDateTime(),
+ "Mod-Alt-d": ({ editor }) => editor.commands.insertDateTime()
};
},
@@ -48,7 +48,7 @@ export const DateTime = Extension.create({
insertDateTime:
() =>
({ commands }) =>
- commands.insertContent(currentDateTime()),
+ commands.insertContent(currentDateTime())
};
},
@@ -58,22 +58,22 @@ export const DateTime = Extension.create({
shortcut: "/time",
replace: () => {
return currentTime();
- },
+ }
}),
shortcutInputRule({
shortcut: "/date",
replace: () => {
return currentDate();
- },
+ }
}),
shortcutInputRule({
shortcut: "/now",
replace: () => {
return currentDateTime();
- },
- }),
+ }
+ })
];
- },
+ }
});
function currentTime() {
@@ -81,7 +81,7 @@ function currentTime() {
second: undefined,
minute: "2-digit",
hour12: true,
- hour: "2-digit",
+ hour: "2-digit"
});
}
@@ -114,7 +114,7 @@ function shortcutInputRule(config: {
after: ({ match, state, range }) => {
const newlineRequested = match[2] === "\n";
if (newlineRequested) state.tr.split(state.tr.mapping.map(range.to));
- },
+ }
});
}
@@ -134,6 +134,6 @@ function textInputRule(config: {
state.tr.insertText(insert, start, end);
if (config.after) config.after(props);
- },
+ }
});
}
diff --git a/packages/editor/src/extensions/drop-cursor/drop-cursor.pm.ts b/packages/editor/src/extensions/drop-cursor/drop-cursor.pm.ts
index 10c014caf..4b90b1c27 100644
--- a/packages/editor/src/extensions/drop-cursor/drop-cursor.pm.ts
+++ b/packages/editor/src/extensions/drop-cursor/drop-cursor.pm.ts
@@ -28,7 +28,7 @@ export function dropCursor(options: DropcursorOptions = {}) {
return new Plugin({
view(editorView) {
return new DropCursorView(editorView, options);
- },
+ }
});
}
@@ -109,7 +109,7 @@ class DropCursorView {
left: nodeRect.left,
right: nodeRect.right,
top: top - this.width / 2,
- bottom: top + this.width / 2,
+ bottom: top + this.width / 2
};
}
}
@@ -119,7 +119,7 @@ class DropCursorView {
left: coords.left - this.width / 2,
right: coords.left + this.width / 2,
top: coords.top,
- bottom: coords.bottom,
+ bottom: coords.bottom
};
}
@@ -162,7 +162,7 @@ class DropCursorView {
if (!this.editorView.editable) return;
let pos = this.editorView.posAtCoords({
left: event.clientX,
- top: event.clientY,
+ top: event.clientY
});
let node =
diff --git a/packages/editor/src/extensions/drop-cursor/drop-cursor.ts b/packages/editor/src/extensions/drop-cursor/drop-cursor.ts
index 797700be9..9280c4ca1 100644
--- a/packages/editor/src/extensions/drop-cursor/drop-cursor.ts
+++ b/packages/editor/src/extensions/drop-cursor/drop-cursor.ts
@@ -14,11 +14,11 @@ export const Dropcursor = Extension.create<DropcursorOptions>({
return {
color: "currentColor",
width: 1,
- class: null,
+ class: null
};
},
addProseMirrorPlugins() {
return [dropCursor(this.options)];
- },
+ }
});
diff --git a/packages/editor/src/extensions/embed/component.tsx b/packages/editor/src/extensions/embed/component.tsx
index 8426325cc..a969f91ea 100644
--- a/packages/editor/src/extensions/embed/component.tsx
+++ b/packages/editor/src/extensions/embed/component.tsx
@@ -26,7 +26,7 @@ export function EmbedComponent(
flexDirection: "column",
justifyContent:
align === "center" ? "center" : align === "left" ? "start" : "end",
- position: "relative",
+ position: "relative"
}}
>
<Resizer
@@ -39,7 +39,7 @@ export function EmbedComponent(
updateAttributes(
{
width,
- height,
+ height
},
{ addToHistory: true, preventUpdate: false }
);
@@ -59,8 +59,8 @@ export function EmbedComponent(
borderColor: selected ? "border" : "bgSecondary",
cursor: "pointer",
":hover": {
- borderColor: "border",
- },
+ borderColor: "border"
+ }
}}
>
<Icon path={Icons.dragHandle} size={"big"} />
@@ -72,7 +72,7 @@ export function EmbedComponent(
position: "absolute",
top: -10,
mb: 2,
- alignItems: "end",
+ alignItems: "end"
}}
>
<ToolbarGroup
@@ -81,12 +81,12 @@ export function EmbedComponent(
"embedAlignLeft",
"embedAlignCenter",
"embedAlignRight",
- "embedProperties",
+ "embedProperties"
]}
sx={{
boxShadow: "menu",
borderRadius: "default",
- bg: "background",
+ bg: "background"
}}
/>
</Flex>
@@ -105,7 +105,7 @@ export function EmbedComponent(
border: selected
? "2px solid var(--primary)"
: "2px solid transparent",
- borderRadius: "default",
+ borderRadius: "default"
}}
onLoad={() => setIsLoading(false)}
{...props}
@@ -118,7 +118,7 @@ export function EmbedComponent(
width: "100%",
height: "calc(100% - 20px)",
alignItems: "center",
- justifyContent: "center",
+ justifyContent: "center"
}}
>
<Icon path={Icons.loading} rotate size={32} color="disabled" />
diff --git a/packages/editor/src/extensions/embed/embed.ts b/packages/editor/src/extensions/embed/embed.ts
index 9bf0eb0c3..dc257170e 100644
--- a/packages/editor/src/extensions/embed/embed.ts
+++ b/packages/editor/src/extensions/embed/embed.ts
@@ -2,7 +2,7 @@ import { Node, mergeAttributes } from "@tiptap/core";
import {
createNodeView,
createSelectionBasedNodeView,
- NodeViewSelectionNotifierPlugin,
+ NodeViewSelectionNotifierPlugin
} from "../react";
import { EmbedComponent } from "./component";
@@ -47,7 +47,7 @@ export const EmbedNode = Node.create<EmbedOptions>({
addOptions() {
return {
- HTMLAttributes: {},
+ HTMLAttributes: {}
};
},
@@ -58,26 +58,26 @@ export const EmbedNode = Node.create<EmbedOptions>({
addAttributes() {
return {
src: {
- default: null,
+ default: null
},
width: { default: null },
height: { default: null },
- align: { default: "left" },
+ align: { default: "left" }
};
},
parseHTML() {
return [
{
- tag: "iframe[src]",
- },
+ tag: "iframe[src]"
+ }
];
},
renderHTML({ HTMLAttributes }) {
return [
"iframe",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)
];
},
@@ -92,7 +92,7 @@ export const EmbedNode = Node.create<EmbedOptions>({
({ commands }) => {
return commands.insertContent({
type: this.name,
- attrs: options,
+ attrs: options
});
},
setEmbedAlignment:
@@ -109,7 +109,7 @@ export const EmbedNode = Node.create<EmbedOptions>({
(src) =>
({ commands }) => {
return commands.updateAttributes(this.name, { src });
- },
+ }
};
- },
+ }
});
diff --git a/packages/editor/src/extensions/font-size/font-size.ts b/packages/editor/src/extensions/font-size/font-size.ts
index edd9f4fb1..9a979f049 100644
--- a/packages/editor/src/extensions/font-size/font-size.ts
+++ b/packages/editor/src/extensions/font-size/font-size.ts
@@ -26,7 +26,7 @@ export const FontSize = Extension.create<FontSizeOptions>({
defaultOptions: {
types: ["textStyle"],
- defaultFontSize: 16,
+ defaultFontSize: 16
},
addGlobalAttributes() {
@@ -43,12 +43,12 @@ export const FontSize = Extension.create<FontSizeOptions>({
}
return {
- style: `font-size: ${attributes.fontSize}`,
+ style: `font-size: ${attributes.fontSize}`
};
- },
- },
- },
- },
+ }
+ }
+ }
+ }
];
},
@@ -66,7 +66,7 @@ export const FontSize = Extension.create<FontSizeOptions>({
.setMark("textStyle", { fontSize: null })
.removeEmptyTextStyle()
.run();
- },
+ }
};
- },
+ }
});
diff --git a/packages/editor/src/extensions/highlight/highlight.ts b/packages/editor/src/extensions/highlight/highlight.ts
index 71fcf1da0..75b298b36 100644
--- a/packages/editor/src/extensions/highlight/highlight.ts
+++ b/packages/editor/src/extensions/highlight/highlight.ts
@@ -31,7 +31,7 @@ export const Highlight = Extension.create<HighlightOptions>({
addOptions() {
return {
types: ["textStyle"],
- HTMLAttributes: {},
+ HTMLAttributes: {}
};
},
@@ -50,12 +50,12 @@ export const Highlight = Extension.create<HighlightOptions>({
}
return {
- style: `background-color: ${attributes.backgroundColor}`,
+ style: `background-color: ${attributes.backgroundColor}`
};
- },
- },
- },
- },
+ }
+ }
+ }
+ }
];
},
@@ -78,9 +78,9 @@ export const Highlight = Extension.create<HighlightOptions>({
.setMark("textStyle", { backgroundColor: null })
.removeEmptyTextStyle()
.run();
- },
+ }
};
- },
+ }
// addKeyboardShortcuts() {
// return {
diff --git a/packages/editor/src/extensions/image/component.tsx b/packages/editor/src/extensions/image/component.tsx
index 207ea1cf2..dd07e24cf 100644
--- a/packages/editor/src/extensions/image/component.tsx
+++ b/packages/editor/src/extensions/image/component.tsx
@@ -14,7 +14,7 @@ import {
downloadImage,
isDataUrl,
toBlobURL,
- toDataURL,
+ toDataURL
} from "../../utils/downloader";
export function ImageComponent(
@@ -68,8 +68,8 @@ export function ImageComponent(
? "start"
: "end",
":hover .drag-handle, :active .drag-handle": {
- opacity: 1,
- },
+ opacity: 1
+ }
}}
>
{!source || error ? (
@@ -86,7 +86,7 @@ export function ImageComponent(
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
- py: 50,
+ py: 50
}}
>
<Icon
@@ -109,7 +109,7 @@ export function ImageComponent(
textDecoration: "none",
textAlign: "center",
mx: 2,
- mt: 2,
+ mt: 2
}}
>
{error
@@ -149,7 +149,7 @@ export function ImageComponent(
position: "absolute",
top: -40,
mb: 2,
- alignItems: "end",
+ alignItems: "end"
}}
>
<ToolbarGroup
@@ -159,19 +159,19 @@ export function ImageComponent(
? [
"imageAlignLeft",
"imageAlignRight",
- "imageProperties",
+ "imageProperties"
]
: [
"imageAlignLeft",
"imageAlignCenter",
"imageAlignRight",
- "imageProperties",
+ "imageProperties"
]
}
sx={{
boxShadow: "menu",
borderRadius: "default",
- bg: "background",
+ bg: "background"
}}
/>
</Flex>
@@ -189,7 +189,7 @@ export function ImageComponent(
position: "absolute",
top: 2,
left: 2,
- zIndex: 999,
+ zIndex: 999
}}
/>
)}
@@ -206,7 +206,7 @@ export function ImageComponent(
border: selected
? "2px solid var(--primary)"
: "2px solid transparent",
- borderRadius: "default",
+ borderRadius: "default"
}}
{...props}
/>
diff --git a/packages/editor/src/extensions/image/image.ts b/packages/editor/src/extensions/image/image.ts
index c37846176..e6897d140 100644
--- a/packages/editor/src/extensions/image/image.ts
+++ b/packages/editor/src/extensions/image/image.ts
@@ -2,13 +2,13 @@ import {
Node,
nodeInputRule,
mergeAttributes,
- findChildren,
+ findChildren
} from "@tiptap/core";
import { Attachment, getDataAttribute } from "../attachment";
import {
createNodeView,
createSelectionBasedNodeView,
- NodeViewSelectionNotifierPlugin,
+ NodeViewSelectionNotifierPlugin
} from "../react";
import { ImageComponent } from "./component";
@@ -61,7 +61,7 @@ export const ImageNode = Node.create<ImageOptions>({
return {
inline: true,
allowBase64: true,
- HTMLAttributes: {},
+ HTMLAttributes: {}
};
},
@@ -78,13 +78,13 @@ export const ImageNode = Node.create<ImageOptions>({
addAttributes() {
return {
src: {
- default: null,
+ default: null
},
alt: {
- default: null,
+ default: null
},
title: {
- default: null,
+ default: null
},
width: { default: null },
height: { default: null },
@@ -96,22 +96,22 @@ export const ImageNode = Node.create<ImageOptions>({
hash: getDataAttribute("hash"),
filename: getDataAttribute("filename"),
type: getDataAttribute("mime"),
- size: getDataAttribute("size"),
+ size: getDataAttribute("size")
};
},
parseHTML() {
return [
{
- tag: this.options.allowBase64 ? "img" : 'img:not([src^="data:"])',
- },
+ tag: this.options.allowBase64 ? "img" : 'img:not([src^="data:"])'
+ }
];
},
renderHTML({ HTMLAttributes }) {
return [
"img",
- mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
+ mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)
];
},
@@ -126,7 +126,7 @@ export const ImageNode = Node.create<ImageOptions>({
({ commands }) => {
return commands.insertContent({
type: this.name,
- attrs: options,
+ attrs: options
});
},
setImageAlignment:
@@ -166,14 +166,14 @@ export const ImageNode = Node.create<ImageOptions>({
for (const image of images) {
tr.setNodeMarkup(image.pos, image.node.type, {
...image.node.attrs,
- ...options,
+ ...options
});
}
tr.setMeta("preventUpdate", options.preventUpdate || false);
tr.setMeta("addToHistory", false);
if (dispatch) dispatch(tr);
return true;
- },
+ }
};
},
@@ -186,8 +186,8 @@ export const ImageNode = Node.create<ImageOptions>({
const [, , alt, src, title] = match;
return { src, alt, title };
- },
- }),
+ }
+ })
];
- },
+ }
});
diff --git a/packages/editor/src/extensions/keep-in-view/keep-in-view.ts b/packages/editor/src/extensions/keep-in-view/keep-in-view.ts
index 233bdfeae..57755590e 100644
--- a/packages/editor/src/extensions/keep-in-view/keep-in-view.ts
+++ b/packages/editor/src/extensions/keep-in-view/keep-in-view.ts
@@ -24,9 +24,9 @@ export const KeepInView = Extension.create({
keepLastLineInView(editor);
});
return false;
- },
+ }
};
- },
+ }
});
export function keepLastLineInView(editor: Editor) {
diff --git a/packages/editor/src/extensions/list-item/list-item.ts b/packages/editor/src/extensions/list-item/list-item.ts
index c4e9e0b63..f691a3085 100644
--- a/packages/editor/src/extensions/list-item/list-item.ts
+++ b/packages/editor/src/extensions/list-item/list-item.ts
@@ -16,7 +16,7 @@ export const ListItem = TiptapListItem.extend({
return this.parent?.()?.Tab(props) || false;
},
Backspace: ({ editor }) =>
- onBackspacePressed(editor, this.name, this.type),
+ onBackspacePressed(editor, this.name, this.type)
};
- },
+ }
});
diff --git a/packages/editor/src/extensions/math/math-block.ts b/packages/editor/src/extensions/math/math-block.ts
index 44f18cdd3..7a10b28c3 100644
--- a/packages/editor/src/extensions/math/math-block.ts
+++ b/packages/editor/src/extensions/math/math-block.ts
@@ -3,7 +3,7 @@ import { inputRules } from "prosemirror-inputrules";
import {
insertMathNode,
makeBlockMathInputRule,
- REGEX_BLOCK_MATH_DOLLARS,
+ REGEX_BLOCK_MATH_DOLLARS
} from "./plugin";
declare module "@tiptap/core" {
@@ -24,8 +24,8 @@ export const MathBlock = Node.create({
parseHTML() {
return [
{
- tag: `div[class*='math-block']`, // important!
- },
+ tag: `div[class*='math-block']` // important!
+ }
];
},
@@ -33,7 +33,7 @@ export const MathBlock = Node.create({
return [
"div",
mergeAttributes({ class: "math-block math-node" }, HTMLAttributes),
- 0,
+ 0
];
},
@@ -43,15 +43,15 @@ export const MathBlock = Node.create({
() =>
({ state, dispatch, view }) => {
return insertMathNode(this.type)(state, dispatch, view);
- },
+ }
};
},
addProseMirrorPlugins() {
const inputRulePlugin = inputRules({
- rules: [makeBlockMathInputRule(REGEX_BLOCK_MATH_DOLLARS, this.type)],
+ rules: [makeBlockMathInputRule(REGEX_BLOCK_MATH_DOLLARS, this.type)]
});
return [inputRulePlugin];
- },
+ }
});
diff --git a/packages/editor/src/extensions/math/math-inline.ts b/packages/editor/src/extensions/math/math-inline.ts
index 03695ed2d..ae669b172 100644
--- a/packages/editor/src/extensions/math/math-inline.ts
+++ b/packages/editor/src/extensions/math/math-inline.ts
@@ -4,7 +4,7 @@ import {
makeInlineMathInputRule,
REGEX_INLINE_MATH_DOLLARS,
mathPlugin,
- insertMathNode,
+ insertMathNode
} from "./plugin";
declare module "@tiptap/core" {
@@ -26,8 +26,8 @@ export const MathInline = Node.create({
parseHTML() {
return [
{
- tag: "span[class*='math-inline']", // important!,
- },
+ tag: "span[class*='math-inline']" // important!,
+ }
];
},
@@ -35,7 +35,7 @@ export const MathInline = Node.create({
return [
"span",
mergeAttributes({ class: "math-inline math-node" }, HTMLAttributes),
- 0,
+ 0
];
},
@@ -49,15 +49,15 @@ export const MathInline = Node.create({
.insertContent({ type: this.name, attrs: {} })
.setNodeSelection($from.pos)
.run();
- },
+ }
};
},
addProseMirrorPlugins() {
const inputRulePlugin = inputRules({
- rules: [makeInlineMathInputRule(REGEX_INLINE_MATH_DOLLARS, this.type)],
+ rules: [makeInlineMathInputRule(REGEX_INLINE_MATH_DOLLARS, this.type)]
});
return [mathPlugin, inputRulePlugin];
- },
+ }
});
diff --git a/packages/editor/src/extensions/math/plugin/commands/insert-math-node.ts b/packages/editor/src/extensions/math/plugin/commands/insert-math-node.ts
index 139e00797..b860da99f 100644
--- a/packages/editor/src/extensions/math/plugin/commands/insert-math-node.ts
+++ b/packages/editor/src/extensions/math/plugin/commands/insert-math-node.ts
@@ -4,7 +4,7 @@ import {
EditorState,
NodeSelection,
Transaction,
- TextSelection,
+ TextSelection
} from "prosemirror-state";
////////////////////////////////////////////////////////////////////////////////
diff --git a/packages/editor/src/extensions/math/plugin/global.d.ts b/packages/editor/src/extensions/math/plugin/global.d.ts
index 11c872594..b4c1ac993 100644
--- a/packages/editor/src/extensions/math/plugin/global.d.ts
+++ b/packages/editor/src/extensions/math/plugin/global.d.ts
@@ -1,24 +1,28 @@
// (https://stackoverflow.com/a/53098695/1444650)
-// import needed to make this a module
+// import needed to make this a module
import { Fragment, Node as ProseNode } from "prosemirror-model";
import { EditorState, Transaction } from "prosemirror-state";
import { EditorView } from "prosemirror-view";
declare module "prosemirror-model" {
- interface Fragment {
- // as of (3/31/20) official @types/prosemirror-model
- // was missing Fragment.content, so we define it here
- content: Node[];
- }
+ interface Fragment {
+ // as of (3/31/20) official @types/prosemirror-model
+ // was missing Fragment.content, so we define it here
+ content: Node[];
+ }
- interface NodeType {
- hasRequiredAttrs(): boolean;
- createAndFill(attrs?:Object, content?: Fragment|ProseNode|ProseNode[], marks?:Mark[]): ProseNode;
- }
+ interface NodeType {
+ hasRequiredAttrs(): boolean;
+ createAndFill(
+ attrs?: Object,
+ content?: Fragment | ProseNode | ProseNode[],
+ marks?: Mark[]
+ ): ProseNode;
+ }
- interface ResolvedPos {
- // missing declaration as of (7/25/20)
- /** Get the position at the given index in the parent node at the given depth (which defaults to this.depth). */
- posAtIndex(index:number, depth?:number):number;
- }
-}
\ No newline at end of file
+ interface ResolvedPos {
+ // missing declaration as of (7/25/20)
+ /** Get the position at the given index in the parent node at the given depth (which defaults to this.depth). */
+ posAtIndex(index: number, depth?: number): number;
+ }
+}
diff --git a/packages/editor/src/extensions/math/plugin/index.ts b/packages/editor/src/extensions/math/plugin/index.ts
index 89bfb9054..fc255c799 100644
--- a/packages/editor/src/extensions/math/plugin/index.ts
+++ b/packages/editor/src/extensions/math/plugin/index.ts
@@ -8,7 +8,7 @@ export { MathView, type ICursorPosObserver } from "./math-node-view";
export {
mathPlugin,
createMathView,
- type IMathPluginState,
+ type IMathPluginState
} from "./math-plugin";
export { mathSchemaSpec, createMathSchema } from "./math-schema";
@@ -19,7 +19,7 @@ export {
makeInlineMathInputRule,
REGEX_BLOCK_MATH_DOLLARS,
REGEX_INLINE_MATH_DOLLARS,
- REGEX_INLINE_MATH_DOLLARS_ESCAPED,
+ REGEX_INLINE_MATH_DOLLARS_ESCAPED
} from "./plugins/math-input-rules";
// optional / experimental plugins
diff --git a/packages/editor/src/extensions/math/plugin/math-node-view.ts b/packages/editor/src/extensions/math/plugin/math-node-view.ts
index 81a3b8c78..7ad42b828 100644
--- a/packages/editor/src/extensions/math/plugin/math-node-view.ts
+++ b/packages/editor/src/extensions/math/plugin/math-node-view.ts
@@ -9,20 +9,20 @@ import {
EditorState,
Transaction,
TextSelection,
- PluginKey,
+ PluginKey
} from "prosemirror-state";
import {
NodeView,
EditorView,
Decoration,
- DecorationSource,
+ DecorationSource
} from "prosemirror-view";
import { StepMap } from "prosemirror-transform";
import { keymap } from "prosemirror-keymap";
import {
newlineInCode,
chainCommands,
- deleteSelection,
+ deleteSelection
} from "prosemirror-commands";
import { collapseMathNode } from "./commands/collapse-math-node";
@@ -347,11 +347,11 @@ export class MathView implements NodeView, ICursorPosObserver {
ArrowLeft: collapseMathNode(this._outerView, -1, true),
ArrowRight: collapseMathNode(this._outerView, +1, true),
ArrowUp: collapseMathNode(this._outerView, -1, true),
- ArrowDown: collapseMathNode(this._outerView, +1, true),
- }),
- ],
+ ArrowDown: collapseMathNode(this._outerView, +1, true)
+ })
+ ]
}),
- dispatchTransaction: this.dispatchInner.bind(this),
+ dispatchTransaction: this.dispatchInner.bind(this)
});
// focus element
diff --git a/packages/editor/src/extensions/math/plugin/math-plugin.ts b/packages/editor/src/extensions/math/plugin/math-plugin.ts
index c2a9c8d7e..ed2ec38c8 100644
--- a/packages/editor/src/extensions/math/plugin/math-plugin.ts
+++ b/packages/editor/src/extensions/math/plugin/math-plugin.ts
@@ -8,7 +8,7 @@ import { Schema, Node as ProseNode } from "prosemirror-model";
import {
Plugin as ProsePlugin,
PluginKey,
- PluginSpec,
+ PluginSpec
} from "prosemirror-state";
import { MathView } from "./math-node-view";
import { EditorView } from "prosemirror-view";
@@ -60,7 +60,7 @@ export function createMathView(inline: boolean) {
{
className: inline ? "math-inline" : "math-block",
renderer: inline ? KatexRenderer.inline : KatexRenderer.block,
- tagName: inline ? "span" : "div",
+ tagName: inline ? "span" : "div"
},
MATH_PLUGIN_KEY,
() => {
@@ -80,7 +80,7 @@ let mathPluginSpec: PluginSpec<IMathPluginState> = {
return {
macros: {},
activeNodeViews: [],
- prevCursorPos: 0,
+ prevCursorPos: 0
};
},
apply(tr, value, oldState, newState) {
@@ -93,9 +93,9 @@ let mathPluginSpec: PluginSpec<IMathPluginState> = {
activeNodeViews: value.activeNodeViews,
macros: value.macros,
// update with the second-most recent cursor pos
- prevCursorPos: oldPos !== newPos ? oldPos : value.prevCursorPos,
+ prevCursorPos: oldPos !== newPos ? oldPos : value.prevCursorPos
};
- },
+ }
/** @todo (8/21/20) implement serialization for math plugin */
// toJSON(value) { },
// fromJSON(config, value, state){ return {}; }
@@ -103,9 +103,9 @@ let mathPluginSpec: PluginSpec<IMathPluginState> = {
props: {
nodeViews: {
mathInline: createMathView(true),
- mathBlock: createMathView(false),
- },
- },
+ mathBlock: createMathView(false)
+ }
+ }
};
export const mathPlugin = new ProsePlugin(mathPluginSpec);
diff --git a/packages/editor/src/extensions/math/plugin/math-schema.ts b/packages/editor/src/extensions/math/plugin/math-schema.ts
index 6c70bdba3..0fefc0e53 100644
--- a/packages/editor/src/extensions/math/plugin/math-schema.ts
+++ b/packages/editor/src/extensions/math/plugin/math-schema.ts
@@ -11,11 +11,11 @@ import {
NodeSpec,
Schema,
SchemaSpec,
- NodeType,
+ NodeType
} from "prosemirror-model";
import {
defaultBlockMathParseRules,
- defaultInlineMathParseRules,
+ defaultInlineMathParseRules
} from "./plugins/math-paste-rules";
import { SchemaSpecMarkT, SchemaSpecNodeT } from "./utils/types";
@@ -59,7 +59,7 @@ export const mathSchemaSpec = createSchemaSpec({
nodes: {
// :: NodeSpec top-level document node
doc: {
- content: "block+",
+ content: "block+"
},
paragraph: {
content: "inline*",
@@ -67,7 +67,7 @@ export const mathSchemaSpec = createSchemaSpec({
parseDOM: [{ tag: "p" }],
toDOM() {
return ["p", 0];
- },
+ }
},
math_inline: {
group: "inline math",
@@ -75,7 +75,7 @@ export const mathSchemaSpec = createSchemaSpec({
inline: true,
atom: true,
toDOM: () => ["math-inline", { class: "math-node" }, 0],
- parseDOM: [{ tag: "math-inline" }, ...defaultInlineMathParseRules],
+ parseDOM: [{ tag: "math-inline" }, ...defaultInlineMathParseRules]
},
math_display: {
group: "block math",
@@ -83,20 +83,20 @@ export const mathSchemaSpec = createSchemaSpec({
atom: true,
code: true,
toDOM: () => ["math-display", { class: "math-node" }, 0],
- parseDOM: [{ tag: "math-display" }, ...defaultBlockMathParseRules],
+ parseDOM: [{ tag: "math-display" }, ...defaultBlockMathParseRules]
},
text: {
- group: "inline",
- },
+ group: "inline"
+ }
},
marks: {
math_select: {
toDOM() {
return ["math-select", 0];
},
- parseDOM: [{ tag: "math-select" }],
- },
- },
+ parseDOM: [{ tag: "math-select" }]
+ }
+ }
});
/**
diff --git a/packages/editor/src/extensions/math/plugin/plugins/math-paste-rules.ts b/packages/editor/src/extensions/math/plugin/plugins/math-paste-rules.ts
index 89cdecc32..158f7b50c 100644
--- a/packages/editor/src/extensions/math/plugin/plugins/math-paste-rules.ts
+++ b/packages/editor/src/extensions/math/plugin/plugins/math-paste-rules.ts
@@ -14,7 +14,7 @@ import {
Fragment,
ParseRule,
Schema,
- NodeType,
+ NodeType
} from "prosemirror-model";
////////////////////////////////////////////////////////////
@@ -87,7 +87,7 @@ function matchWikipedia(root: Element): false | string {
let match: false | string = getFirstMatch(root, [
texFromMediaWikiFallbackImage,
texFromMathML_01,
- texFromMathML_02,
+ texFromMathML_02
]);
// TODO: if no tex string was found, but we have MathML, try to parse it
return match;
@@ -147,7 +147,7 @@ export const wikipediaBlockMathParseRule: ParseRule = {
// return a fragment representing the math node's children
let texString: string = match || "\\text{\\color{red}(paste error)}";
return makeTextFragment(texString, schema);
- },
+ }
};
/**
@@ -185,7 +185,7 @@ export const wikipediaInlineMathParseRule: ParseRule = {
// return a fragment representing the math node's children
let texString: string = match || "\\text{\\color{red}(paste error)}";
return makeTextFragment(texString, schema);
- },
+ }
};
// -- MathJax ------------------------------------------- //
@@ -193,9 +193,9 @@ export const wikipediaInlineMathParseRule: ParseRule = {
////////////////////////////////////////////////////////////
export const defaultInlineMathParseRules: ParseRule[] = [
- wikipediaInlineMathParseRule,
+ wikipediaInlineMathParseRule
];
export const defaultBlockMathParseRules: ParseRule[] = [
- wikipediaBlockMathParseRule,
+ wikipediaBlockMathParseRule
];
diff --git a/packages/editor/src/extensions/math/plugin/plugins/math-select.ts b/packages/editor/src/extensions/math/plugin/plugins/math-select.ts
index bd2ab58a7..19d8c8dad 100644
--- a/packages/editor/src/extensions/math/plugin/plugins/math-select.ts
+++ b/packages/editor/src/extensions/math/plugin/plugins/math-select.ts
@@ -9,7 +9,7 @@ import {
Transaction,
Selection as ProseSelection,
Plugin as ProsePlugin,
- EditorStateConfig,
+ EditorStateConfig
} from "prosemirror-state";
import { DecorationSet, Decoration } from "prosemirror-view";
import { Fragment, Node as ProseNode } from "prosemirror-model";
@@ -36,7 +36,7 @@ const checkSelection = (arg: { selection: ProseSelection; doc: ProseNode }) => {
if (node.type.name.startsWith("math_")) {
result.push({
start: Math.max(from + pos - 1, 0),
- end: from + pos + node.nodeSize - 1,
+ end: from + pos + node.nodeSize - 1
});
return false;
}
@@ -78,11 +78,11 @@ export const mathSelectPlugin: ProsePlugin = new ProsePlugin({
}
let sel = checkSelection(tr);
return sel;
- },
+ }
},
props: {
decorations: (state: EditorState) => {
return mathSelectPlugin.getState(state);
- },
- },
+ }
+ }
});
diff --git a/packages/editor/src/extensions/math/plugin/renderers/katex.ts b/packages/editor/src/extensions/math/plugin/renderers/katex.ts
index 095c59ef8..8e3f60aeb 100644
--- a/packages/editor/src/extensions/math/plugin/renderers/katex.ts
+++ b/packages/editor/src/extensions/math/plugin/renderers/katex.ts
@@ -15,7 +15,7 @@ export const KatexRenderer: MathRenderer = {
katex.render(text, element, {
displayMode: false,
globalGroup: true,
- throwOnError: false,
+ throwOnError: false
});
});
},
@@ -24,8 +24,8 @@ export const KatexRenderer: MathRenderer = {
katex.render(text, element, {
displayMode: true,
globalGroup: true,
- throwOnError: false,
+ throwOnError: false
});
});
- },
+ }
};
diff --git a/packages/editor/src/extensions/math/plugin/utils/text-serializer.ts b/packages/editor/src/extensions/math/plugin/utils/text-serializer.ts
index b56fed4e4..1fd6f122b 100644
--- a/packages/editor/src/extensions/math/plugin/utils/text-serializer.ts
+++ b/packages/editor/src/extensions/math/plugin/utils/text-serializer.ts
@@ -4,7 +4,7 @@ import {
Slice,
NodeType,
MarkType,
- Fragment,
+ Fragment
} from "prosemirror-model";
////////////////////////////////////////////////////////////////////////////////
@@ -92,6 +92,6 @@ class ProseMirrorTextSerializer {
export const mathSerializer = new ProseMirrorTextSerializer({
nodes: {
math_inline: (node) => `$${node.textContent}$`,
- math_display: (node) => `\n\n$$\n${node.textContent}\n$$`,
- },
+ math_display: (node) => `\n\n$$\n${node.textContent}\n$$`
+ }
});
diff --git a/packages/editor/src/extensions/math/plugin/utils/types.ts b/packages/editor/src/extensions/math/plugin/utils/types.ts
index 299f378eb..f1ab69a1d 100644
--- a/packages/editor/src/extensions/math/plugin/utils/types.ts
+++ b/packages/editor/src/extensions/math/plugin/utils/types.ts
@@ -3,8 +3,12 @@ import { Schema, SchemaSpec } from "prosemirror-model";
////////////////////////////////////////////////////////////////////////////////
// infer generic `Nodes` and `Marks` type parameters for a SchemaSpec
-export type SchemaSpecNodeT<Spec> = Spec extends SchemaSpec<infer N, infer _> ? N : never;
-export type SchemaSpecMarkT<Spec> = Spec extends SchemaSpec<infer _, infer M> ? M : never;
+export type SchemaSpecNodeT<Spec> = Spec extends SchemaSpec<infer N, infer _>
+ ? N
+ : never;
+export type SchemaSpecMarkT<Spec> = Spec extends SchemaSpec<infer _, infer M>
+ ? M
+ : never;
export type SchemaNodeT<S> = S extends Schema<infer N, infer _> ? N : never;
-export type SchemaMarkT<S> = S extends Schema<infer _, infer M> ? M : never;
\ No newline at end of file
+export type SchemaMarkT<S> = S extends Schema<infer _, infer M> ? M : never;
diff --git a/packages/editor/src/extensions/ordered-list/ordered-list.ts b/packages/editor/src/extensions/ordered-list/ordered-list.ts
index e14847d3e..aa089b55c 100644
--- a/packages/editor/src/extensions/ordered-list/ordered-list.ts
+++ b/packages/editor/src/extensions/ordered-list/ordered-list.ts
@@ -12,10 +12,10 @@ export const OrderedList = TiptapOrderedList.extend({
}
return {
- style: `list-style-type: ${attributes.listType}`,
+ style: `list-style-type: ${attributes.listType}`
};
- },
- },
+ }
+ }
};
- },
+ }
});
diff --git a/packages/editor/src/extensions/outline-list-item/component.tsx b/packages/editor/src/extensions/outline-list-item/component.tsx
index db847375d..263519a13 100644
--- a/packages/editor/src/extensions/outline-list-item/component.tsx
+++ b/packages/editor/src/extensions/outline-list-item/component.tsx
@@ -22,7 +22,7 @@ export function OutlineListItemComponent(props: ReactNodeViewProps) {
sx={{
flexDirection: "column",
alignItems: "center",
- mt: isMobile ? "0px" : "3px",
+ mt: isMobile ? "0px" : "3px"
}}
>
{isNested ? (
@@ -37,14 +37,14 @@ export function OutlineListItemComponent(props: ReactNodeViewProps) {
cursor: "pointer",
transition: `all .2s ease-in-out`,
":hover": {
- transform: ["unset", "scale(1.3)"],
+ transform: ["unset", "scale(1.3)"]
},
":active": {
- transform: ["scale(1.3)", "unset"],
+ transform: ["scale(1.3)", "unset"]
},
".icon:hover path": {
- fill: "var(--checked) !important",
- },
+ fill: "var(--checked) !important"
+ }
}}
size={isMobile ? 24 : 18}
onMouseDown={(e) => e.preventDefault()}
@@ -77,8 +77,8 @@ export function OutlineListItemComponent(props: ReactNodeViewProps) {
transition: `all .2s ease-in-out`,
":hover": {
backgroundColor: "fontTertiary",
- width: 4,
- },
+ width: 4
+ }
}}
contentEditable={false}
/>
@@ -89,7 +89,7 @@ export function OutlineListItemComponent(props: ReactNodeViewProps) {
sx={{
pl: 1,
listStyleType: "none",
- flex: 1,
+ flex: 1
}}
/>
</Flex>
diff --git a/packages/editor/src/extensions/outline-list-item/outline-list-item.ts b/packages/editor/src/extensions/outline-list-item/outline-list-item.ts
index 3e0b8e195..ad3eb79a3 100644
--- a/packages/editor/src/extensions/outline-list-item/outline-list-item.ts
+++ b/packages/editor/src/extensions/outline-list-item/outline-list-item.ts
@@ -24,7 +24,7 @@ export const OutlineListItem = Node.create<ListItemOptions>({
addOptions() {
return {
- HTMLAttributes: {},
+ HTMLAttributes: {}
};
},
@@ -35,8 +35,8 @@ export const OutlineListItem = Node.create<ListItemOptions>({
parseHTML() {
return [
{
- tag: `li[data-type="${this.name}"]`,
- },
+ tag: `li[data-type="${this.name}"]`
+ }
];
},
@@ -44,9 +44,9 @@ export const OutlineListItem = Node.create<ListItemOptions>({
return [
"li",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
- "data-type": this.name,
+ "data-type": this.name
}),
- 0,
+ 0
];
},
@@ -77,7 +77,7 @@ export const OutlineListItem = Node.create<ListItemOptions>({
Tab: () => this.editor.commands.sinkListItem(this.name),
"Shift-Tab": () => this.editor.commands.liftListItem(this.name),
Backspace: ({ editor }) =>
- onBackspacePressed(editor, this.name, this.type),
+ onBackspacePressed(editor, this.name, this.type)
};
},
@@ -87,19 +87,19 @@ export const OutlineListItem = Node.create<ListItemOptions>({
(pos, state) =>
({ tr }) => {
tr.setNodeMarkup(pos, undefined, {
- collapsed: state,
+ collapsed: state
});
return true;
- },
+ }
};
},
addNodeView() {
return createNodeView(OutlineListItemComponent, {
contentDOMFactory: true,
- wrapperFactory: () => document.createElement("li"),
+ wrapperFactory: () => document.createElement("li")
});
- },
+ }
});
function findSublist(editor: Editor, type: NodeType) {
diff --git a/packages/editor/src/extensions/outline-list/outline-list.ts b/packages/editor/src/extensions/outline-list/outline-list.ts
index 69416de92..5cdf2718c 100644
--- a/packages/editor/src/extensions/outline-list/outline-list.ts
+++ b/packages/editor/src/extensions/outline-list/outline-list.ts
@@ -28,7 +28,7 @@ export const OutlineList = Node.create<OutlineListOptions>({
addOptions() {
return {
- HTMLAttributes: {},
+ HTMLAttributes: {}
};
},
@@ -39,9 +39,9 @@ export const OutlineList = Node.create<OutlineListOptions>({
keepOnSplit: false,
parseHTML: (element) => element.dataset.collapsed === "true",
renderHTML: (attributes) => ({
- "data-collapsed": attributes.collapsed === true,
- }),
- },
+ "data-collapsed": attributes.collapsed === true
+ })
+ }
};
},
@@ -53,8 +53,8 @@ export const OutlineList = Node.create<OutlineListOptions>({
return [
{
tag: `ul[data-type="${this.name}"]`,
- priority: 52,
- },
+ priority: 52
+ }
];
},
@@ -62,9 +62,9 @@ export const OutlineList = Node.create<OutlineListOptions>({
return [
"ul",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
- "data-type": this.name,
+ "data-type": this.name
}),
- 0,
+ 0
];
},
@@ -74,13 +74,13 @@ export const OutlineList = Node.create<OutlineListOptions>({
() =>
({ commands }) => {
return commands.toggleList(this.name, outlineListItemName);
- },
+ }
};
},
addKeyboardShortcuts() {
return {
- "Mod-Shift-O": () => this.editor.commands.toggleOutlineList(),
+ "Mod-Shift-O": () => this.editor.commands.toggleOutlineList()
};
},
@@ -88,8 +88,8 @@ export const OutlineList = Node.create<OutlineListOptions>({
return [
wrappingInputRule({
find: inputRegex,
- type: this.type,
- }),
+ type: this.type
+ })
];
},
@@ -100,7 +100,7 @@ export const OutlineList = Node.create<OutlineListOptions>({
content.classList.add(`${this.name.toLowerCase()}-content-wrapper`);
content.style.whiteSpace = "inherit";
return { dom: content };
- },
+ }
});
- },
+ }
});
diff --git a/packages/editor/src/extensions/paragraph/paragraph.ts b/packages/editor/src/extensions/paragraph/paragraph.ts
index 26d965933..b3dc4a11e 100644
--- a/packages/editor/src/extensions/paragraph/paragraph.ts
+++ b/packages/editor/src/extensions/paragraph/paragraph.ts
@@ -26,7 +26,7 @@ export const Paragraph = Node.create<ParagraphOptions>({
addOptions() {
return {
HTMLAttributes: {},
- doubleSpaced: true,
+ doubleSpaced: true
};
},
@@ -44,10 +44,10 @@ export const Paragraph = Node.create<ParagraphOptions>({
if (!attributes.spacing) return;
return {
- "data-spacing": attributes.spacing,
+ "data-spacing": attributes.spacing
};
- },
- },
+ }
+ }
};
},
@@ -59,7 +59,7 @@ export const Paragraph = Node.create<ParagraphOptions>({
return [
"p",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),
- 0,
+ 0
];
},
@@ -69,7 +69,7 @@ export const Paragraph = Node.create<ParagraphOptions>({
() =>
({ commands }) => {
return commands.setNode(this.name);
- },
+ }
};
},
@@ -99,9 +99,9 @@ export const Paragraph = Node.create<ParagraphOptions>({
createParagraph(editor, this.type, false, true),
"Shift-Enter": ({ editor }) =>
createParagraph(editor, this.type, false, true),
- "Mod-Alt-0": () => this.editor.commands.setParagraph(),
+ "Mod-Alt-0": () => this.editor.commands.setParagraph()
};
- },
+ }
});
function getSpacing(doubleSpaced: boolean): "single" | "double" {
@@ -128,7 +128,7 @@ function createParagraph(
})
.splitBlock({ keepMarks: true })
.updateAttributes(type, {
- spacing: getSpacing(doubleSpaced),
+ spacing: getSpacing(doubleSpaced)
})
.run();
}
diff --git a/packages/editor/src/extensions/react/plugin.ts b/packages/editor/src/extensions/react/plugin.ts
index 4ca65a14a..badf58361 100644
--- a/packages/editor/src/extensions/react/plugin.ts
+++ b/packages/editor/src/extensions/react/plugin.ts
@@ -33,7 +33,7 @@ export const NodeViewSelectionNotifierPlugin = new Plugin({
},
apply(_tr, pluginState: ReactNodeViewState) {
return pluginState;
- },
+ }
},
key: stateKey,
view: (view: EditorView) => {
@@ -43,14 +43,14 @@ export const NodeViewSelectionNotifierPlugin = new Plugin({
update: (view: EditorView) => {
const { from, to } = view.state.selection;
pluginState.notifyNewSelection(from, to);
- },
+ }
};
- },
+ }
});
export const NodeViewSelectionNotifier = Extension.create({
name: "node-view-selection-notifier",
addProseMirrorPlugins() {
return [NodeViewSelectionNotifierPlugin];
- },
+ }
});
diff --git a/packages/editor/src/extensions/react/react-node-view.tsx b/packages/editor/src/extensions/react/react-node-view.tsx
index 29df77eb7..d00826067 100644
--- a/packages/editor/src/extensions/react/react-node-view.tsx
+++ b/packages/editor/src/extensions/react/react-node-view.tsx
@@ -9,7 +9,7 @@ import {
ReactNodeViewOptions,
GetPosNode,
ForwardRef,
- ContentDOM,
+ ContentDOM
} from "./types";
import { NodeViewRendererProps } from "@tiptap/core";
import { Theme } from "@streetwriters/theme";
@@ -54,7 +54,7 @@ export class ReactNodeView<P extends ReactNodeViewProps> implements NodeView {
const { dom: contentDOMWrapper, contentDOM } = this.getContentDOM() || {
dom: undefined,
- contentDOM: undefined,
+ contentDOM: undefined
};
if (this.domRef && contentDOMWrapper) {
@@ -160,7 +160,7 @@ export class ReactNodeView<P extends ReactNodeViewProps> implements NodeView {
this.editor.commands.command(({ tr }) => {
tr.setNodeMarkup(pos, undefined, {
...this.node.attrs,
- ...attributes,
+ ...attributes
});
tr.setMeta("addToHistory", addToHistory);
tr.setMeta("preventUpdate", preventUpdate);
@@ -381,7 +381,7 @@ export class ReactNodeView<P extends ReactNodeViewProps> implements NodeView {
) {
const changedNodes = [
...Array.from(mutation.addedNodes),
- ...Array.from(mutation.removedNodes),
+ ...Array.from(mutation.removedNodes)
] as HTMLElement[];
// we’ll check if every changed node is contentEditable
@@ -446,7 +446,7 @@ export function createNodeView<TProps extends ReactNodeViewProps>(
return new ReactNodeView<TProps>(node, editor as Editor, _getPos, {
...options,
- component,
+ component
}).init();
};
}
diff --git a/packages/editor/src/extensions/react/react-portal-provider.tsx b/packages/editor/src/extensions/react/react-portal-provider.tsx
index 1e3fb863f..e17e92c83 100644
--- a/packages/editor/src/extensions/react/react-portal-provider.tsx
+++ b/packages/editor/src/extensions/react/react-portal-provider.tsx
@@ -2,7 +2,7 @@ import React, { PropsWithChildren, useContext } from "react";
import {
createPortal,
unstable_renderSubtreeIntoContainer,
- unmountComponentAtNode,
+ unmountComponentAtNode
} from "react-dom";
import { EventDispatcher } from "./event-dispatcher";
@@ -35,7 +35,7 @@ export class PortalProviderAPI extends EventDispatcher {
container: HTMLElement
) {
this.portals.set(container, {
- children,
+ children
});
let wrappedChildren = children() as JSX.Element;
diff --git a/packages/editor/src/extensions/react/selection-based-react-node-view.tsx b/packages/editor/src/extensions/react/selection-based-react-node-view.tsx
index 52d0750c5..f66f9fef6 100644
--- a/packages/editor/src/extensions/react/selection-based-react-node-view.tsx
+++ b/packages/editor/src/extensions/react/selection-based-react-node-view.tsx
@@ -5,7 +5,7 @@ import { Selection, NodeSelection } from "prosemirror-state";
import { PortalProviderAPI } from "./react-portal-provider";
import {
stateKey as SelectionChangePluginKey,
- ReactNodeViewState,
+ ReactNodeViewState
} from "./plugin";
import { EventDispatcher } from "./event-dispatcher";
import {
@@ -13,7 +13,7 @@ import {
ReactNodeViewOptions,
GetPosNode,
SelectionBasedReactNodeViewProps,
- ForwardRef,
+ ForwardRef
} from "./types";
import { ReactNodeView } from "./react-node-view";
import { NodeViewRendererProps } from "@tiptap/core";
@@ -119,7 +119,7 @@ export class SelectionBasedNodeView<
private getPositionsWithDefault(pos?: number, posEnd?: number) {
return {
pos: typeof pos !== "number" ? this.pos : pos,
- posEnd: typeof posEnd !== "number" ? this.posEnd : posEnd,
+ posEnd: typeof posEnd !== "number" ? this.posEnd : posEnd
};
}
@@ -156,7 +156,7 @@ export class SelectionBasedNodeView<
private isSelectedNode = (selection: Selection): boolean => {
if (selection instanceof NodeSelection) {
const {
- selection: { from, to },
+ selection: { from, to }
} = this.editor.view.state;
return (
selection.node === this.node ||
@@ -171,7 +171,7 @@ export class SelectionBasedNodeView<
insideSelection = () => {
const {
- selection: { from, to },
+ selection: { from, to }
} = this.editor.view.state;
return (
@@ -193,7 +193,7 @@ export class SelectionBasedNodeView<
if (super.viewShouldUpdate(nextNode)) return true;
const {
- state: { selection },
+ state: { selection }
} = this.editor.view;
// update selection
@@ -260,7 +260,7 @@ export function createSelectionBasedNodeView<
const _getPos = () => (typeof getPos === "boolean" ? -1 : getPos());
return new SelectionBasedNodeView(node, editor as Editor, _getPos, {
...options,
- component,
+ component
}).init();
};
}
diff --git a/packages/editor/src/extensions/search-replace/search-replace.ts b/packages/editor/src/extensions/search-replace/search-replace.ts
index 5cdea5875..5880a54e8 100644
--- a/packages/editor/src/extensions/search-replace/search-replace.ts
+++ b/packages/editor/src/extensions/search-replace/search-replace.ts
@@ -5,7 +5,7 @@ import {
Plugin,
PluginKey,
TextSelection,
- Transaction,
+ Transaction
} from "prosemirror-state";
declare module "@tiptap/core" {
@@ -79,7 +79,7 @@ function searchDocument(
return {
decorationSet: DecorationSet.empty,
results: [],
- startIndex: selectedIndex || 0,
+ startIndex: selectedIndex || 0
};
const doc = tr.doc;
@@ -94,12 +94,12 @@ function searchDocument(
if (textNodesWithPosition[index]) {
textNodesWithPosition[index] = {
text: textNodesWithPosition[index].text + node.text,
- pos: textNodesWithPosition[index].pos,
+ pos: textNodesWithPosition[index].pos
};
} else {
textNodesWithPosition[index] = {
text: node.text || "",
- pos,
+ pos
};
}
} else {
@@ -117,7 +117,7 @@ function searchDocument(
if (m.index !== undefined) {
results.push({
from: pos + m.index,
- to: pos + m.index + m[0].length,
+ to: pos + m.index + m[0].length
});
}
}
@@ -147,7 +147,7 @@ function searchDocument(
return {
startIndex: selectedIndex || 0,
decorationSet: DecorationSet.create(doc, decorations),
- results,
+ results
};
}
@@ -170,7 +170,7 @@ const replaceAll = (
const { from, to } = results[i + 1];
results[i + 1] = {
from: map.map(from),
- to: map.map(to),
+ to: map.map(to)
};
}
}
@@ -182,7 +182,7 @@ export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({
addOptions() {
return {
- searchResultClass: "search-result",
+ searchResultClass: "search-result"
};
},
@@ -274,7 +274,7 @@ export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({
const { from, to } = results[index + 1];
const nextResult = (results[index + 1] = {
from: tr.mapping.map(from),
- to: tr.mapping.map(to),
+ to: tr.mapping.map(to)
});
commands.focus();
@@ -298,14 +298,14 @@ export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({
dispatch(replaceAll(term, results, tr));
return true;
- },
+ }
};
},
addKeyboardShortcuts() {
return {
"Mod-f": ({ editor }) => editor.commands.startSearch(),
- Escape: ({ editor }) => editor.commands.endSearch(),
+ Escape: ({ editor }) => editor.commands.endSearch()
};
},
@@ -328,7 +328,7 @@ export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({
matchCase,
matchWholeWord,
selectedIndex,
- isSearching,
+ isSearching
} = this.storage;
if (docChanged || forceUpdate) {
const { searchResultClass } = this.options;
@@ -350,16 +350,16 @@ export const SearchReplace = Extension.create<SearchOptions, SearchStorage>({
}
return isSearching ? value : DecorationSet.empty;
- },
+ }
},
props: {
decorations(state) {
return key.getState(state);
- },
- },
- }),
+ }
+ }
+ })
];
- },
+ }
});
function scrollIntoView(editor: Editor, from: number) {
diff --git a/packages/editor/src/extensions/selection-persist/selection-persist.ts b/packages/editor/src/extensions/selection-persist/selection-persist.ts
index 8b6412abe..b69380740 100644
--- a/packages/editor/src/extensions/selection-persist/selection-persist.ts
+++ b/packages/editor/src/extensions/selection-persist/selection-persist.ts
@@ -17,7 +17,7 @@ export const SelectionPersist = Extension.create({
props: {
decorations(state) {
return key.getState(state);
- },
+ }
},
state: {
init() {
@@ -48,16 +48,16 @@ export const SelectionPersist = Extension.create({
if (isBlurred) {
return DecorationSet.create(tr.doc, [
Decoration.inline(from, to, {
- style: `background-color: var(--dimPrimary)`,
- }),
+ style: `background-color: var(--dimPrimary)`
+ })
]);
} else if (isFocused) {
return DecorationSet.empty;
}
return DecorationSet.empty;
- },
- },
- }),
+ }
+ }
+ })
];
- },
+ }
});
diff --git a/packages/editor/src/extensions/table-cell/table-cell.ts b/packages/editor/src/extensions/table-cell/table-cell.ts
index 7f1386667..8f21c182f 100644
--- a/packages/editor/src/extensions/table-cell/table-cell.ts
+++ b/packages/editor/src/extensions/table-cell/table-cell.ts
@@ -9,9 +9,9 @@ export const TableCell = TiptapTableCell.extend({
color: addStyleAttribute("color", "color"),
borderWidth: addStyleAttribute("borderWidth", "border-width", "px"),
borderStyle: addStyleAttribute("borderStyle", "border-style"),
- borderColor: addStyleAttribute("borderColor", "border-color"),
+ borderColor: addStyleAttribute("borderColor", "border-color")
};
- },
+ }
});
function addStyleAttribute(
@@ -31,8 +31,8 @@ function addStyleAttribute(
}
return {
- style: `${cssName}: ${attributes[name as string]}${unit || ""}`,
+ style: `${cssName}: ${attributes[name as string]}${unit || ""}`
};
- },
+ }
};
}
diff --git a/packages/editor/src/extensions/table/component.tsx b/packages/editor/src/extensions/table/component.tsx
index 25a34b2aa..12bde1d89 100644
--- a/packages/editor/src/extensions/table/component.tsx
+++ b/packages/editor/src/extensions/table/component.tsx
@@ -1,7 +1,7 @@
import { Flex } from "rebass";
import {
SelectionBasedNodeView,
- SelectionBasedReactNodeViewProps,
+ SelectionBasedReactNodeViewProps
} from "../react";
import { Node as ProsemirrorNode } from "prosemirror-model";
import { Editor } from "../../types";
@@ -12,7 +12,7 @@ import {
InsertColumnRight,
InsertRowBelow,
RowProperties,
- TableProperties,
+ TableProperties
} from "../../toolbar/tools/table";
import { getToolDefinition } from "../../toolbar/tool-definitions";
import { getPosition } from "../../utils/position";
@@ -79,7 +79,7 @@ export function TableNodeView(editor: Editor) {
const dom = document.createElement("div");
dom.style.position = "relative";
return dom;
- },
+ }
}
);
super.init();
@@ -110,7 +110,7 @@ function TableRowToolbar(props: TableToolbarProps) {
target: currentRow,
align: "start",
xOffset: -5,
- yOffset: -3,
+ yOffset: -3
});
rowToolsRef.current.style.top = `${pos.top}px`;
rowToolsRef.current.style.left = `${pos.left}px`;
@@ -129,8 +129,8 @@ function TableRowToolbar(props: TableToolbarProps) {
borderRadius: "default",
opacity: 0.3,
":hover": {
- opacity: 1,
- },
+ opacity: 1
+ }
}}
>
<RowProperties
@@ -158,7 +158,7 @@ function TableColumnToolbar(props: TableToolbarProps) {
const currentCell = findSelectedDOMNode(editor, [
"tableCell",
- "tableHeader",
+ "tableHeader"
]);
if (!currentCell) return;
@@ -168,7 +168,7 @@ function TableColumnToolbar(props: TableToolbarProps) {
align: "center",
target: currentCell as HTMLElement,
yAnchor: table,
- yOffset: 2,
+ yOffset: 2
});
columnToolsRef.current.style.left = `${pos.left}px`;
@@ -188,8 +188,8 @@ function TableColumnToolbar(props: TableToolbarProps) {
borderRadius: "default",
opacity: 0.3,
":hover": {
- opacity: 1,
- },
+ opacity: 1
+ }
}}
>
<TableProperties
diff --git a/packages/editor/src/extensions/table/table.ts b/packages/editor/src/extensions/table/table.ts
index 77c3eddcf..c97e019b9 100644
--- a/packages/editor/src/extensions/table/table.ts
+++ b/packages/editor/src/extensions/table/table.ts
@@ -16,13 +16,13 @@ export const Table = TiptapTable.extend<TableOptions>({
View: TableNodeView(this.editor as Editor),
// TODO: PR for @types/prosemirror-tables
// @ts-ignore (incorrect type)
- lastColumnResizable: this.options.lastColumnResizable,
- }),
+ lastColumnResizable: this.options.lastColumnResizable
+ })
]
: []),
tableEditing({
- allowTableNodeSelection: this.options.allowTableNodeSelection,
- }),
+ allowTableNodeSelection: this.options.allowTableNodeSelection
+ })
];
- },
+ }
});
diff --git a/packages/editor/src/extensions/task-item/component.tsx b/packages/editor/src/extensions/task-item/component.tsx
index 1e37e9ae3..e059267eb 100644
--- a/packages/editor/src/extensions/task-item/component.tsx
+++ b/packages/editor/src/extensions/task-item/component.tsx
@@ -9,7 +9,7 @@ import { useCallback, useEffect } from "react";
import { TaskItemNode, TaskItemAttributes } from "./task-item";
import {
useIsKeyboardOpen,
- useIsMobile,
+ useIsMobile
} from "../../toolbar/stores/toolbar-store";
import { isiOS } from "../../utils/platform";
@@ -61,8 +61,8 @@ export function TaskItemComponent(
bg: "background",
borderRadius: "default",
":hover > .dragHandle": {
- opacity: editor.isEditable ? 1 : 0,
- },
+ opacity: editor.isEditable ? 1 : 0
+ }
}}
>
{editor.isEditable && (
@@ -81,8 +81,8 @@ export function TaskItemComponent(
bg: "transparent",
cursor: "grab",
".icon:hover path": {
- fill: "var(--checked) !important",
- },
+ fill: "var(--checked) !important"
+ }
}}
size={isMobile ? 24 : 20}
/>
@@ -101,11 +101,11 @@ export function TaskItemComponent(
p: "1px",
cursor: editor.isEditable ? "pointer" : "unset",
":hover": {
- borderColor: "checked",
+ borderColor: "checked"
},
":hover .icon path": {
- fill: "var(--checked) !important",
- },
+ fill: "var(--checked) !important"
+ }
}}
onMouseDown={(e) => {
if (useIsKeyboardOpen.current) {
@@ -129,9 +129,9 @@ export function TaskItemComponent(
sx={{
"> .taskitem-content-wrapper > p": {
textDecorationLine: checked ? "line-through" : "none",
- opacity: checked ? 0.8 : 1,
+ opacity: checked ? 0.8 : 1
},
- flex: 1,
+ flex: 1
}}
/>
</Flex>
@@ -154,7 +154,7 @@ function toggleChildren(
// need to add 1 to get inside the node
const actualPos = pos + parentPos + 1;
tr.setNodeMarkup(actualPos, undefined, {
- checked: toggleState,
+ checked: toggleState
});
}
return tr;
diff --git a/packages/editor/src/extensions/task-item/task-item.ts b/packages/editor/src/extensions/task-item/task-item.ts
index 48a2cbcda..ae780080b 100644
--- a/packages/editor/src/extensions/task-item/task-item.ts
+++ b/packages/editor/src/extensions/task-item/task-item.ts
@@ -18,9 +18,9 @@ export const TaskItemNode = TaskItem.extend({
keepOnSplit: false,
parseHTML: (element) => element.classList.contains("checked"),
renderHTML: (attributes) => ({
- class: attributes.checked ? "checked" : "",
- }),
- },
+ class: attributes.checked ? "checked" : ""
+ })
+ }
};
},
@@ -28,9 +28,9 @@ export const TaskItemNode = TaskItem.extend({
return [
"li",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
- class: "checklist--item",
+ class: "checklist--item"
}),
- 0,
+ 0
];
},
@@ -47,8 +47,8 @@ export const TaskItemNode = TaskItem.extend({
}
return false;
},
- priority: 51,
- },
+ priority: 51
+ }
];
},
@@ -56,7 +56,7 @@ export const TaskItemNode = TaskItem.extend({
return {
...this.parent?.(),
Backspace: ({ editor }) =>
- onBackspacePressed(editor, this.name, this.type),
+ onBackspacePressed(editor, this.name, this.type)
};
},
@@ -68,7 +68,7 @@ export const TaskItemNode = TaskItem.extend({
return (
prev.checked !== next.checked || prev.collapsed !== next.collapsed
);
- },
+ }
});
- },
+ }
});
diff --git a/packages/editor/src/extensions/task-list/component.tsx b/packages/editor/src/extensions/task-list/component.tsx
index 8eaa53232..5885754eb 100644
--- a/packages/editor/src/extensions/task-list/component.tsx
+++ b/packages/editor/src/extensions/task-list/component.tsx
@@ -4,7 +4,7 @@ import { Node } from "prosemirror-model";
import {
findParentNodeClosestToPos,
findChildren,
- getNodeType,
+ getNodeType
} from "@tiptap/core";
import { Icon } from "../../toolbar/components/icon";
import { Icons } from "../../toolbar/icons";
@@ -66,7 +66,7 @@ export function TaskListComponent(
<Flex
sx={{
flexDirection: "column",
- ":hover > div > .toggleSublist": { opacity: 1 },
+ ":hover > div > .toggleSublist": { opacity: 1 }
}}
>
{isNested ? (
@@ -74,7 +74,7 @@ export function TaskListComponent(
sx={{
position: "absolute",
top: 0,
- right: 0,
+ right: 0
}}
contentEditable={false}
>
@@ -94,8 +94,8 @@ export function TaskListComponent(
mr: 2,
cursor: "pointer",
".icon:hover path": {
- fill: "var(--checked) !important",
- },
+ fill: "var(--checked) !important"
+ }
}}
size={isMobile ? 24 : 20}
onClick={() => {
@@ -116,7 +116,7 @@ export function TaskListComponent(
mb: 2,
alignItems: "center",
justifyContent: "end",
- overflow: "hidden",
+ overflow: "hidden"
}}
contentEditable={false}
>
@@ -129,7 +129,7 @@ export function TaskListComponent(
zIndex: 0,
left: 0,
- transition: "width 250ms ease-out",
+ transition: "width 250ms ease-out"
}}
/>
<Input
@@ -141,7 +141,7 @@ export function TaskListComponent(
px: 2,
zIndex: 1,
color: "fontTertiary",
- fontSize: "body",
+ fontSize: "body"
}}
placeholder="Untitled"
onChange={(e) => {
@@ -169,13 +169,13 @@ export function TaskListComponent(
paddingInlineStart: 0,
marginBlockStart: isNested ? 10 : 0,
marginBlockEnd: 0,
- marginLeft: isNested ? (editor.isEditable ? -35 : -10) : 0,
+ marginLeft: isNested ? (editor.isEditable ? -35 : -10) : 0
},
li: {
listStyleType: "none",
position: "relative",
- marginBottom: isNested ? [1, "3px"] : [2, "7px"],
- },
+ marginBottom: isNested ? [1, "3px"] : [2, "7px"]
+ }
}}
/>
</>
diff --git a/packages/editor/src/extensions/task-list/task-list.ts b/packages/editor/src/extensions/task-list/task-list.ts
index 62dacfbab..34a744110 100644
--- a/packages/editor/src/extensions/task-list/task-list.ts
+++ b/packages/editor/src/extensions/task-list/task-list.ts
@@ -16,8 +16,8 @@ export const TaskListNode = TaskList.extend({
keepOnSplit: false,
parseHTML: (element) => element.dataset.collapsed === "true",
renderHTML: (attributes) => ({
- "data-collapsed": attributes.collapsed === true,
- }),
+ "data-collapsed": attributes.collapsed === true
+ })
},
title: {
default: null,
@@ -29,10 +29,10 @@ export const TaskListNode = TaskList.extend({
}
return {
- "data-title": attributes.title,
+ "data-title": attributes.title
};
- },
- },
+ }
+ }
};
},
@@ -46,8 +46,8 @@ export const TaskListNode = TaskList.extend({
}
return false;
},
- priority: 51,
- },
+ priority: 51
+ }
];
},
@@ -55,9 +55,9 @@ export const TaskListNode = TaskList.extend({
return [
"ul",
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
- class: "checklist",
+ class: "checklist"
}),
- 0,
+ 0
];
},
@@ -70,7 +70,7 @@ export const TaskListNode = TaskList.extend({
commands.toggleList(this.name, this.options.itemTypeName);
const position = {
from: tr.mapping.map($from.pos),
- to: tr.mapping.map($to.pos),
+ to: tr.mapping.map($to.pos)
};
// There is a minor bug in Prosemirror or Tiptap where creating
// nested node view causes the editor selection to act weird.
@@ -80,7 +80,7 @@ export const TaskListNode = TaskList.extend({
// directly or else it won't run.
setTimeout(() => editor.commands.setTextSelection(position), 0);
return true;
- },
+ }
};
},
@@ -91,7 +91,7 @@ export const TaskListNode = TaskList.extend({
content.classList.add(`${this.name.toLowerCase()}-content-wrapper`);
content.style.whiteSpace = "inherit";
return { dom: content };
- },
+ }
});
- },
+ }
});
diff --git a/packages/editor/src/extensions/text-direction/text-direction.ts b/packages/editor/src/extensions/text-direction/text-direction.ts
index a40ffddf7..a43b75784 100644
--- a/packages/editor/src/extensions/text-direction/text-direction.ts
+++ b/packages/editor/src/extensions/text-direction/text-direction.ts
@@ -23,7 +23,7 @@ export const TextDirection = Extension.create<TextDirectionOptions>({
defaultOptions: {
types: ["paragraph", "heading"],
- defaultDirection: "ltr",
+ defaultDirection: "ltr"
},
addGlobalAttributes() {
@@ -40,12 +40,12 @@ export const TextDirection = Extension.create<TextDirectionOptions>({
}
return {
- dir: attributes.textDirection,
+ dir: attributes.textDirection
};
- },
- },
- },
- },
+ }
+ }
+ }
+ }
];
},
@@ -57,7 +57,7 @@ export const TextDirection = Extension.create<TextDirectionOptions>({
return this.options.types.every((type) =>
commands.updateAttributes(type, { textDirection: direction })
);
- },
+ }
};
- },
+ }
});
diff --git a/packages/editor/src/hooks/use-editor.ts b/packages/editor/src/hooks/use-editor.ts
index 79afc62dc..2bc5a974e 100644
--- a/packages/editor/src/hooks/use-editor.ts
+++ b/packages/editor/src/hooks/use-editor.ts
@@ -46,7 +46,7 @@ export const useEditor = (
if (!editor.current) {
Object.defineProperty(editor, "current", {
- get: () => editorRef.current,
+ get: () => editorRef.current
});
}
// if (!editor.executor) {
diff --git a/packages/editor/src/hooks/use-permission-handler.ts b/packages/editor/src/hooks/use-permission-handler.ts
index d2d48fcb4..a35735993 100644
--- a/packages/editor/src/hooks/use-permission-handler.ts
+++ b/packages/editor/src/hooks/use-permission-handler.ts
@@ -9,7 +9,7 @@ export type PermissionHandlerOptions = {
};
const ClaimsMap: Record<Claims, (keyof UnionCommands)[]> = {
- premium: ["insertImage"],
+ premium: ["insertImage"]
};
export function usePermissionHandler(options: PermissionHandlerOptions) {
@@ -18,7 +18,7 @@ export function usePermissionHandler(options: PermissionHandlerOptions) {
useEffect(() => {
function onPermissionRequested(ev: Event) {
const {
- detail: { id },
+ detail: { id }
} = ev as PermissionRequestEvent;
for (const key in ClaimsMap) {
diff --git a/packages/editor/src/index.ts b/packages/editor/src/index.ts
index 8aefab14c..2bb1ce4c5 100644
--- a/packages/editor/src/index.ts
+++ b/packages/editor/src/index.ts
@@ -34,7 +34,7 @@ import { Codemark } from "./extensions/code-mark";
import { MathInline, MathBlock } from "./extensions/math";
import {
NodeViewSelectionNotifier,
- usePortalProvider,
+ usePortalProvider
} from "./extensions/react";
import { OutlineList } from "./extensions/outline-list";
import { OutlineListItem } from "./extensions/outline-list-item";
@@ -45,7 +45,7 @@ import { useToolbarStore } from "./toolbar/stores/toolbar-store";
import { useEditor } from "./hooks/use-editor";
import {
EditorOptions,
- extensions as TiptapCoreExtensions,
+ extensions as TiptapCoreExtensions
} from "@tiptap/core";
import { usePermissionHandler } from "./hooks/use-permission-handler";
import { Highlight } from "./extensions/highlight";
@@ -107,7 +107,7 @@ const useTiptap = (
SearchReplace,
TextStyle,
Paragraph.configure({
- doubleSpaced: doubleSpacedLines,
+ doubleSpaced: doubleSpacedLines
}),
StarterKit.configure({
code: false,
@@ -120,11 +120,11 @@ const useTiptap = (
hardBreak: false,
history: {
depth: 200,
- newGroupDelay: 1000,
- },
+ newGroupDelay: 1000
+ }
}),
Dropcursor.configure({
- class: "drop-cursor",
+ class: "drop-cursor"
}),
CharacterCount,
Underline,
@@ -139,14 +139,14 @@ const useTiptap = (
TaskListNode,
Link.configure({
openOnClick: !isMobile,
- autolink: false,
+ autolink: false
}).extend({
- inclusive: true,
+ inclusive: true
}),
Table.configure({
resizable: true,
allowTableNodeSelection: true,
- cellMinWidth: 50,
+ cellMinWidth: 50
}),
TableRow,
TableCell,
@@ -157,17 +157,17 @@ const useTiptap = (
TextAlign.configure({
types: ["heading", "paragraph"],
alignments: ["left", "right", "center", "justify"],
- defaultAlignment: "left",
+ defaultAlignment: "left"
}),
Placeholder.configure({
- placeholder: "Start writing your note...",
+ placeholder: "Start writing your note..."
}),
ImageNode.configure({ allowBase64: true }),
EmbedNode,
AttachmentNode.configure({
onDownloadAttachment,
- onOpenAttachmentPicker,
+ onOpenAttachmentPicker
}),
OutlineListItem,
OutlineList,
@@ -178,26 +178,26 @@ const useTiptap = (
MathBlock,
KeepInView,
SelectionPersist,
- DateTime,
+ DateTime
],
onBeforeCreate: ({ editor }) => {
editor.storage.portalProviderAPI = PortalProviderAPI;
if (onBeforeCreate) onBeforeCreate({ editor });
},
- injectCSS: false,
+ injectCSS: false
}),
[
onDownloadAttachment,
onOpenAttachmentPicker,
PortalProviderAPI,
- onBeforeCreate,
+ onBeforeCreate
]
);
const editor = useEditor(
{
...defaultOptions,
- ...restOptions,
+ ...restOptions
},
deps
);
diff --git a/packages/editor/src/toolbar/components/counter.tsx b/packages/editor/src/toolbar/components/counter.tsx
index 25f2bee39..b6e60189a 100644
--- a/packages/editor/src/toolbar/components/counter.tsx
+++ b/packages/editor/src/toolbar/components/counter.tsx
@@ -19,8 +19,8 @@ function _Counter(props: CounterProps) {
alignItems: "center",
mr: 1,
":last-of-type": {
- mr: 0,
- },
+ mr: 0
+ }
}}
>
<ToolButton
@@ -39,7 +39,7 @@ function _Counter(props: CounterProps) {
fontSize: "subBody",
mx: 1,
textAlign: "center",
- ":hover": { bg: "transparent" },
+ ":hover": { bg: "transparent" }
}}
onClick={onReset}
title={`Reset ${title}`}
diff --git a/packages/editor/src/toolbar/components/dropdown.tsx b/packages/editor/src/toolbar/components/dropdown.tsx
index 40b083052..2396b5792 100644
--- a/packages/editor/src/toolbar/components/dropdown.tsx
+++ b/packages/editor/src/toolbar/components/dropdown.tsx
@@ -7,7 +7,7 @@ import { MenuItem } from "../../components/menu/types";
import {
useIsMobile,
useToolbarLocation,
- useToolbarStore,
+ useToolbarStore
} from "../stores/toolbar-store";
import { MenuPresenter } from "../../components/menu";
import { getToolbarElement } from "../utils/dom";
@@ -34,7 +34,7 @@ export function Dropdown(props: DropdownProps) {
group,
id,
isOpen,
- onClosed: () => setIsOpen(false),
+ onClosed: () => setIsOpen(false)
});
return (
@@ -53,8 +53,8 @@ export function Dropdown(props: DropdownProps) {
alignItems: "center",
":hover": { bg: "hover" },
":last-of-type": {
- mr: 0,
- },
+ mr: 0
+ }
}}
onClick={() => setIsOpen((s) => !s)}
onMouseDown={(e) => e.preventDefault()}
@@ -84,7 +84,7 @@ export function Dropdown(props: DropdownProps) {
isTargetAbsolute: true,
location: isBottom ? "top" : "below",
align: "center",
- yOffset: 5,
+ yOffset: 5
}}
blocking={!isMobile}
focusOnRender={!isMobile}
@@ -96,7 +96,7 @@ export function Dropdown(props: DropdownProps) {
marginRight: isBottom ? "10px" : 0,
display: "flex",
alignItems: isBottom ? "center" : "unset",
- mr: isBottom ? 0 : 2,
+ mr: isBottom ? 0 : 2
}}
/>
</>
diff --git a/packages/editor/src/toolbar/components/icon.tsx b/packages/editor/src/toolbar/components/icon.tsx
index de2d644f0..afc3e7450 100644
--- a/packages/editor/src/toolbar/components/icon.tsx
+++ b/packages/editor/src/toolbar/components/icon.tsx
@@ -18,7 +18,7 @@ function MDIIconWrapper({
size = 24,
color = "icon",
stroke,
- rotate,
+ rotate
}: IconProps) {
const theme: Theme = useTheme();
@@ -38,7 +38,7 @@ function MDIIconWrapper({
}
style={{
strokeWidth: stroke || "0px",
- stroke: themedColor,
+ stroke: themedColor
}}
color={themedColor}
spin={rotate}
@@ -57,7 +57,7 @@ export function Icon(props: NNIconProps) {
flexShrink: 0,
justifyContent: "center",
alignItems: "center",
- ...sx,
+ ...sx
}}
{...restProps}
>
diff --git a/packages/editor/src/toolbar/components/more-tools.tsx b/packages/editor/src/toolbar/components/more-tools.tsx
index 6ac3602ae..e1d0e6519 100644
--- a/packages/editor/src/toolbar/components/more-tools.tsx
+++ b/packages/editor/src/toolbar/components/more-tools.tsx
@@ -37,7 +37,7 @@ export function MoreTools(props: MoreToolsProps) {
target: isBottom ? getToolbarElement() : buttonRef.current || "mouse",
align: "center",
location: isBottom ? "top" : "below",
- yOffset: 10,
+ yOffset: 10
}}
autoCloseOnUnmount={autoCloseOnUnmount}
focusOnRender={false}
@@ -56,7 +56,7 @@ export function MoreTools(props: MoreToolsProps) {
bg: "background",
borderRadius: "default",
overflowX: "auto",
- maxWidth: "95vw",
+ maxWidth: "95vw"
}}
/>
)}
diff --git a/packages/editor/src/toolbar/components/popup.tsx b/packages/editor/src/toolbar/components/popup.tsx
index 6fdca644c..1dd05d44d 100644
--- a/packages/editor/src/toolbar/components/popup.tsx
+++ b/packages/editor/src/toolbar/components/popup.tsx
@@ -31,7 +31,7 @@ export function Popup(props: PropsWithChildren<PopupProps>) {
borderRadius: "default",
// border: "1px solid var(--border)",
boxShadow: "menu",
- minWidth: 200,
+ minWidth: 200
}}
>
{title && (
@@ -40,7 +40,7 @@ export function Popup(props: PropsWithChildren<PopupProps>) {
sx={{
justifyContent: "space-between",
alignItems: "center",
- p: 2,
+ p: 2
}}
>
<Text variant={"title"}>{title}</Text>
@@ -90,7 +90,7 @@ export function Popup(props: PropsWithChildren<PopupProps>) {
mb: 1,
mt: 2,
mx: 1,
- py: 2,
+ py: 2
}}
onClick={action.disabled ? undefined : action?.onClick}
disabled={action.disabled}
diff --git a/packages/editor/src/toolbar/components/split-button.tsx b/packages/editor/src/toolbar/components/split-button.tsx
index 19de10207..142fbc666 100644
--- a/packages/editor/src/toolbar/components/split-button.tsx
+++ b/packages/editor/src/toolbar/components/split-button.tsx
@@ -6,7 +6,7 @@ import { ToolButton, ToolButtonProps } from "./tool-button";
import { useToolbarLocation } from "../stores/toolbar-store";
import {
PopupWrapper,
- PopupWrapperProps,
+ PopupWrapperProps
} from "../../components/popup-presenter";
import { PositionOptions } from "../../utils/position";
import { Button } from "../../components/button";
@@ -24,7 +24,7 @@ function _SplitButton(props: PropsWithChildren<SplitButtonProps>) {
<Flex
ref={ref}
sx={{
- borderRadius: "default",
+ borderRadius: "default"
}}
>
<ToolButton
@@ -41,8 +41,8 @@ function _SplitButton(props: PropsWithChildren<SplitButtonProps>) {
bg: "bgSecondary",
":hover": { bg: "hover" },
":last-of-type": {
- mr: 0,
- },
+ mr: 0
+ }
}}
onClick={onOpen}
>
diff --git a/packages/editor/src/toolbar/components/tool-button.tsx b/packages/editor/src/toolbar/components/tool-button.tsx
index 9a87706c6..c4d80bd41 100644
--- a/packages/editor/src/toolbar/components/tool-button.tsx
+++ b/packages/editor/src/toolbar/components/tool-button.tsx
@@ -43,9 +43,9 @@ export const ToolButton = React.memo(
mr: variant === "small" ? 0 : 1,
":hover": { bg: "hover" },
":last-of-type": {
- mr: 0,
+ mr: 0
},
- ...sx,
+ ...sx
}}
onMouseDown={(e) => e.preventDefault()}
{...buttonProps}
diff --git a/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx b/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx
index ed8faf416..70ce4a440 100644
--- a/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx
+++ b/packages/editor/src/toolbar/floating-menus/hover-popup/index.tsx
@@ -63,7 +63,7 @@ export function HoverPopupHandler(props: FloatingMenuProps) {
selectedNode={{
node,
from: pos,
- to: pos + node.nodeSize,
+ to: pos + node.nodeSize
}}
/>
),
@@ -73,8 +73,8 @@ export function HoverPopupHandler(props: FloatingMenuProps) {
target: element,
align: "center",
location: "top",
- isTargetAbsolute: true,
- },
+ isTargetAbsolute: true
+ }
});
activePopup.current = { element, hide: hidePopup };
},
diff --git a/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx b/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx
index 284d4a0ae..412054cd0 100644
--- a/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx
+++ b/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx
@@ -22,7 +22,7 @@ function LinkHoverPopup(props: HoverPopupProps) {
bg: "background",
boxShadow: "menu",
borderRadius: "default",
- p: 1,
+ p: 1
}}
/>
);
@@ -30,5 +30,5 @@ function LinkHoverPopup(props: HoverPopupProps) {
export const LinkHoverPopupHandler = {
isActive: (e: HTMLElement) => !!e.closest("a"),
- popup: LinkHoverPopup,
+ popup: LinkHoverPopup
};
diff --git a/packages/editor/src/toolbar/floating-menus/search-replace.tsx b/packages/editor/src/toolbar/floating-menus/search-replace.tsx
index 38fa9907a..89399b4fa 100644
--- a/packages/editor/src/toolbar/floating-menus/search-replace.tsx
+++ b/packages/editor/src/toolbar/floating-menus/search-replace.tsx
@@ -4,7 +4,7 @@ import { SearchReplacePopup } from "../popups/search-replace";
import {
DesktopOnly,
MobileOnly,
- ResponsivePresenter,
+ ResponsivePresenter
} from "../../components/responsive";
import { getToolbarElement } from "../utils/dom";
@@ -23,7 +23,7 @@ export function SearchReplaceFloatingMenu(props: FloatingMenuProps) {
isTargetAbsolute: true,
location: "below",
align: "end",
- yOffset: 5,
+ yOffset: 5
}}
blocking={false}
focusOnRender={false}
diff --git a/packages/editor/src/toolbar/icons.ts b/packages/editor/src/toolbar/icons.ts
index 86ac0d05c..b27e56f6b 100644
--- a/packages/editor/src/toolbar/icons.ts
+++ b/packages/editor/src/toolbar/icons.ts
@@ -87,7 +87,7 @@ import {
mdiResizeBottomRight,
mdiImageOutline,
mdiProgressDownload,
- mdiProgressAlert,
+ mdiProgressAlert
} from "@mdi/js";
export const Icons = {
@@ -198,7 +198,7 @@ export const Icons = {
circle: mdiCircle,
arrowLeft: mdiArrowLeft,
resize: mdiResizeBottomRight,
- none: "",
+ none: ""
};
export type IconNames = keyof typeof Icons;
diff --git a/packages/editor/src/toolbar/popups/color-picker.tsx b/packages/editor/src/toolbar/popups/color-picker.tsx
index cac811a30..a623c09db 100644
--- a/packages/editor/src/toolbar/popups/color-picker.tsx
+++ b/packages/editor/src/toolbar/popups/color-picker.tsx
@@ -21,7 +21,7 @@ export const DEFAULT_COLORS = [
"#cddc39",
"#ffeb3b",
"#ffc107",
- "#f44336",
+ "#f44336"
];
type ColorPickerProps = {
@@ -42,7 +42,7 @@ export function ColorPicker(props: ColorPickerProps) {
onChange,
title,
onClose,
- expanded,
+ expanded
} = props;
const ref = useRef<HTMLDivElement>();
const [isPickerOpen, setIsPickerOpen] = useState(expanded || false);
@@ -72,12 +72,12 @@ export function ColorPicker(props: ColorPickerProps) {
flexDirection: "column",
".react-colorful": {
width: "auto",
- height: 150,
+ height: 150
},
".react-colorful__saturation": {
- borderRadius: ["default", 0],
+ borderRadius: ["default", 0]
},
- width: ["calc(100vw - 20px)", 250],
+ width: ["calc(100vw - 20px)", 250]
// width: ["auto", 250],
}}
>
@@ -89,7 +89,7 @@ export function ColorPicker(props: ColorPickerProps) {
p: 2,
pb: isPickerOpen ? 2 : 0,
//pb: 0,
- alignItems: "center",
+ alignItems: "center"
}}
onClick={onClose}
>
@@ -121,7 +121,7 @@ export function ColorPicker(props: ColorPickerProps) {
fontSize: ["title", "title", "body"],
color: "fontTertiary",
textAlign: "center",
- letterSpacing: 1.5,
+ letterSpacing: 1.5
}}
value={currentColor.toUpperCase()}
maxLength={7}
@@ -143,7 +143,7 @@ export function ColorPicker(props: ColorPickerProps) {
flex: 1,
p: 1,
overflowX: ["auto", "hidden"],
- flexWrap: ["nowrap", "wrap"],
+ flexWrap: ["nowrap", "wrap"]
}}
>
<Button
@@ -155,7 +155,7 @@ export function ColorPicker(props: ColorPickerProps) {
borderRadius: 50,
boxShadow: "menu",
p: 0,
- ml: [2, 2, 1],
+ ml: [2, 2, 1]
}}
onClick={onClear}
>
@@ -173,8 +173,8 @@ export function ColorPicker(props: ColorPickerProps) {
p: 0,
ml: [2, 2, 1],
":hover": {
- bg: currentColor,
- },
+ bg: currentColor
+ }
}}
onClick={() => setIsPickerOpen((s) => !s)}
>
@@ -196,8 +196,8 @@ export function ColorPicker(props: ColorPickerProps) {
mb: [0, 1, 1],
borderRadius: 50,
":hover": {
- bg: color,
- },
+ bg: color
+ }
}}
onClick={() => {
setCurrentColor(color);
diff --git a/packages/editor/src/toolbar/popups/embed-popup.tsx b/packages/editor/src/toolbar/popups/embed-popup.tsx
index e31b92e10..67a620b55 100644
--- a/packages/editor/src/toolbar/popups/embed-popup.tsx
+++ b/packages/editor/src/toolbar/popups/embed-popup.tsx
@@ -6,7 +6,7 @@ import {
Embed,
EmbedAlignmentOptions,
EmbedAttributes,
- EmbedSizeOptions,
+ EmbedSizeOptions
} from "../../extensions/embed";
import { IconNames } from "../icons";
import { ToolButton } from "../components/tool-button";
@@ -36,16 +36,16 @@ export function EmbedPopup(props: EmbedPopupProps) {
const size: EmbedSizeOptions = newWidth
? {
width: newWidth,
- height: newWidth * (height / width),
+ height: newWidth * (height / width)
}
: newHeight
? {
width: newHeight * (width / height),
- height: newHeight,
+ height: newHeight
}
: {
width: 0,
- height: 0,
+ height: 0
};
setWidth(size.width);
setHeight(size.height);
@@ -91,9 +91,9 @@ export function EmbedPopup(props: EmbedPopupProps) {
onClose({
height: _height,
width: _width,
- src: _src,
+ src: _src
});
- },
+ }
}}
>
<Flex sx={{ flexDirection: "column", width: ["auto", 300] }}>
@@ -104,7 +104,7 @@ export function EmbedPopup(props: EmbedPopupProps) {
bg: "errorBg",
color: "error",
p: 1,
- borderRadius: "default",
+ borderRadius: "default"
}}
>
Error: {error}
@@ -134,7 +134,7 @@ export function EmbedPopup(props: EmbedPopupProps) {
value={width}
sx={{
mr: 1,
- fontSize: "body",
+ fontSize: "body"
}}
onChange={(e) => onSizeChange(e.target.valueAsNumber)}
/>
diff --git a/packages/editor/src/toolbar/popups/image-properties.tsx b/packages/editor/src/toolbar/popups/image-properties.tsx
index 0d3337742..4c7356755 100644
--- a/packages/editor/src/toolbar/popups/image-properties.tsx
+++ b/packages/editor/src/toolbar/popups/image-properties.tsx
@@ -4,7 +4,7 @@ import { Popup } from "../components/popup";
import { Checkbox, Label } from "@rebass/forms";
import {
ImageAlignmentOptions,
- ImageSizeOptions,
+ ImageSizeOptions
} from "../../extensions/image";
import { Editor } from "../../types";
import { InlineInput } from "../../components/inline-input";
@@ -20,16 +20,16 @@ export function ImageProperties(props: ImagePropertiesProps) {
const size: ImageSizeOptions = newWidth
? {
width: newWidth,
- height: newWidth * (height / width),
+ height: newWidth * (height / width)
}
: newHeight
? {
width: newHeight * (width / height),
- height: newHeight,
+ height: newHeight
}
: {
width: 0,
- height: 0,
+ height: 0
};
editor.current?.chain().setImageSize(size).run();
@@ -63,7 +63,7 @@ export function ImageProperties(props: ImagePropertiesProps) {
type="number"
value={width}
containerProps={{
- sx: { mr: 1 },
+ sx: { mr: 1 }
}}
onChange={(e) => onSizeChange(e.target.valueAsNumber)}
/>
diff --git a/packages/editor/src/toolbar/popups/image-upload.tsx b/packages/editor/src/toolbar/popups/image-upload.tsx
index 138d774a0..169a9c6d7 100644
--- a/packages/editor/src/toolbar/popups/image-upload.tsx
+++ b/packages/editor/src/toolbar/popups/image-upload.tsx
@@ -35,7 +35,7 @@ export function ImageUploadPopup(props: ImageUploadPopupProps) {
} finally {
setIsDownloading(false);
}
- },
+ }
}}
>
<Flex sx={{ px: 1, flexDirection: "column", width: ["auto", 350] }}>
@@ -57,7 +57,7 @@ export function ImageUploadPopup(props: ImageUploadPopupProps) {
bg: "errorBg",
mt: 1,
p: 1,
- borderRadius: "default",
+ borderRadius: "default"
}}
>
Failed to download image: {error.toLowerCase()}.
@@ -70,7 +70,7 @@ export function ImageUploadPopup(props: ImageUploadPopupProps) {
color: "primary",
mt: 1,
p: 1,
- borderRadius: "default",
+ borderRadius: "default"
}}
>
To protect your privacy, we will download the image &amp; add it to
diff --git a/packages/editor/src/toolbar/popups/link-popup.tsx b/packages/editor/src/toolbar/popups/link-popup.tsx
index 68498dd0f..bab3d87d0 100644
--- a/packages/editor/src/toolbar/popups/link-popup.tsx
+++ b/packages/editor/src/toolbar/popups/link-popup.tsx
@@ -24,7 +24,7 @@ export function LinkPopup(props: LinkPopupProps) {
onClick: () => {
if (!link.current) return;
onDone(link.current);
- },
+ }
}}
>
<Flex sx={{ p: 1, flexDirection: "column", width: ["auto", 250] }}>
diff --git a/packages/editor/src/toolbar/popups/search-replace.tsx b/packages/editor/src/toolbar/popups/search-replace.tsx
index ae93f8b23..815d44fb8 100644
--- a/packages/editor/src/toolbar/popups/search-replace.tsx
+++ b/packages/editor/src/toolbar/popups/search-replace.tsx
@@ -24,7 +24,7 @@ export function SearchReplacePopup(props: SearchReplacePopupProps) {
editor.commands.search(term, {
matchCase,
enableRegex,
- matchWholeWord,
+ matchWholeWord
});
},
[matchCase, enableRegex, matchWholeWord]
@@ -55,7 +55,7 @@ export function SearchReplacePopup(props: SearchReplacePopupProps) {
bg: "background",
flexDirection: "column",
boxShadow: ["none", "menu"],
- borderRadius: [0, "default"],
+ borderRadius: [0, "default"]
}}
>
<Flex>
@@ -73,11 +73,11 @@ export function SearchReplacePopup(props: SearchReplacePopupProps) {
py: 0,
":focus-within": {
outlineColor: "primary",
- outlineWidth: "1.8px",
+ outlineWidth: "1.8px"
},
":hover": {
- outlineColor: "primary",
- },
+ outlineColor: "primary"
+ }
}}
>
<Input
@@ -100,12 +100,12 @@ export function SearchReplacePopup(props: SearchReplacePopupProps) {
sx={{
flexShrink: 0,
mr: 0,
- alignItems: "center",
+ alignItems: "center"
}}
>
<ToolButton
sx={{
- mr: 0,
+ mr: 0
}}
toggled={isExpanded}
title="Expand"
@@ -118,7 +118,7 @@ export function SearchReplacePopup(props: SearchReplacePopupProps) {
<>
<ToolButton
sx={{
- mr: 0,
+ mr: 0
}}
toggled={matchCase}
title="Match case"
@@ -129,7 +129,7 @@ export function SearchReplacePopup(props: SearchReplacePopupProps) {
/>
<ToolButton
sx={{
- mr: 0,
+ mr: 0
}}
toggled={matchWholeWord}
title="Match whole word"
@@ -140,7 +140,7 @@ export function SearchReplacePopup(props: SearchReplacePopupProps) {
/>
<ToolButton
sx={{
- mr: 0,
+ mr: 0
}}
toggled={enableRegex}
title="Enable regex"
@@ -157,7 +157,7 @@ export function SearchReplacePopup(props: SearchReplacePopupProps) {
flexShrink: 0,
borderLeft: "1px solid var(--border)",
color: "fontTertiary",
- px: 1,
+ px: 1
}}
>
{results ? `${selectedIndex + 1}/${results.length}` : ""}
diff --git a/packages/editor/src/toolbar/stores/toolbar-store.ts b/packages/editor/src/toolbar/stores/toolbar-store.ts
index 6af8ca900..758b29c67 100644
--- a/packages/editor/src/toolbar/stores/toolbar-store.ts
+++ b/packages/editor/src/toolbar/stores/toolbar-store.ts
@@ -46,7 +46,7 @@ export const useToolbarStore = create<ToolbarState>((set, get) => ({
set((state) => {
state.openedPopups = {
...state.openedPopups,
- [id]: false,
+ [id]: false
};
}),
isPopupOpen: (id) => !!get().openedPopups[id],
@@ -54,7 +54,7 @@ export const useToolbarStore = create<ToolbarState>((set, get) => ({
set((state) => {
state.openedPopups = {
...state.openedPopups,
- [ref.id]: ref,
+ [ref.id]: ref
};
}),
closePopupGroup: (group, excluded) =>
@@ -65,7 +65,7 @@ export const useToolbarStore = create<ToolbarState>((set, get) => ({
state.openedPopups[key] = false;
}
}
- }),
+ })
}));
export function useToolbarLocation() {
@@ -82,7 +82,7 @@ export const useTheme = Object.defineProperty(
},
"current",
{
- get: () => useToolbarStore.getState().theme,
+ get: () => useToolbarStore.getState().theme
}
) as (() => Theme | undefined) & { current: Theme | undefined };
@@ -92,6 +92,6 @@ export const useIsKeyboardOpen = Object.defineProperty(
},
"current",
{
- get: () => useToolbarStore.getState().isKeyboardOpen,
+ get: () => useToolbarStore.getState().isKeyboardOpen
}
) as (() => boolean) & { current: boolean };
diff --git a/packages/editor/src/toolbar/tool-definitions.ts b/packages/editor/src/toolbar/tool-definitions.ts
index 51314fed9..c897a9707 100644
--- a/packages/editor/src/toolbar/tool-definitions.ts
+++ b/packages/editor/src/toolbar/tool-definitions.ts
@@ -4,292 +4,292 @@ import { ToolId } from "./tools";
const tools: Record<ToolId, ToolDefinition> = {
bold: {
icon: "bold",
- title: "Bold",
+ title: "Bold"
},
italic: {
icon: "italic",
- title: "Italic",
+ title: "Italic"
},
underline: {
icon: "underline",
- title: "Underline",
+ title: "Underline"
},
strikethrough: {
icon: "strikethrough",
- title: "Strikethrough",
+ title: "Strikethrough"
},
addLink: {
icon: "link",
- title: "Link",
+ title: "Link"
},
editLink: {
icon: "linkEdit",
title: "Edit link",
- conditional: true,
+ conditional: true
},
removeLink: {
icon: "linkRemove",
title: "Remove link",
- conditional: true,
+ conditional: true
},
openLink: {
icon: "openLink",
title: "Open link",
- conditional: true,
+ conditional: true
},
linkSettings: {
icon: "linkSettings",
title: "Link settings",
- conditional: true,
+ conditional: true
},
code: {
icon: "code",
- title: "Code",
+ title: "Code"
},
codeRemove: {
icon: "codeRemove",
title: "Code",
- conditional: true,
+ conditional: true
},
clearformatting: {
icon: "formatClear",
- title: "Clear all formatting",
+ title: "Clear all formatting"
},
subscript: {
icon: "subscript",
- title: "Subscript",
+ title: "Subscript"
},
superscript: {
icon: "superscript",
- title: "Superscript",
+ title: "Superscript"
},
insertBlock: {
icon: "plus",
title: "Insert",
- conditional: true,
+ conditional: true
},
bulletList: {
icon: "bulletList",
- title: "Bullet list",
+ title: "Bullet list"
},
numberedList: {
icon: "numberedList",
- title: "Numbered list",
+ title: "Numbered list"
},
fontFamily: {
icon: "fontFamily",
- title: "Font family",
+ title: "Font family"
},
fontSize: {
icon: "fontSize",
- title: "Font size",
+ title: "Font size"
},
headings: {
icon: "heading",
- title: "Headings",
+ title: "Headings"
},
alignment: {
icon: "alignCenter",
- title: "Alignment",
+ title: "Alignment"
},
textDirection: {
icon: "ltr",
- title: "Text direction",
+ title: "Text direction"
},
highlight: {
icon: "highlight",
- title: "Highlight",
+ title: "Highlight"
},
textColor: {
icon: "textColor",
- title: "Text color",
+ title: "Text color"
},
math: {
icon: "math",
- title: "Math (inline)",
+ title: "Math (inline)"
},
tableSettings: {
icon: "tableSettings",
title: "Table settings",
- conditional: true,
+ conditional: true
},
columnProperties: {
icon: "columnProperties",
title: "Column properties",
- conditional: true,
+ conditional: true
},
rowProperties: {
icon: "rowProperties",
title: "Row properties",
- conditional: true,
+ conditional: true
},
cellProperties: {
icon: "cellProperties",
title: "Cell properties",
- conditional: true,
+ conditional: true
},
insertColumnLeft: {
icon: "insertColumnLeft",
title: "Insert column left",
- conditional: true,
+ conditional: true
},
insertColumnRight: {
icon: "insertColumnRight",
title: "Insert column right",
- conditional: true,
+ conditional: true
},
moveColumnLeft: {
icon: "moveColumnLeft",
title: "Move column left",
- conditional: true,
+ conditional: true
},
moveColumnRight: {
icon: "moveColumnRight",
title: "Move column right",
- conditional: true,
+ conditional: true
},
deleteColumn: {
icon: "deleteColumn",
title: "Delete column",
- conditional: true,
+ conditional: true
},
splitCells: {
icon: "splitCells",
title: "Split cells",
- conditional: true,
+ conditional: true
},
mergeCells: {
icon: "mergeCells",
title: "Merge cells",
- conditional: true,
+ conditional: true
},
insertRowAbove: {
icon: "insertRowAbove",
title: "Insert row above",
- conditional: true,
+ conditional: true
},
insertRowBelow: {
icon: "insertRowBelow",
title: "Insert row below",
- conditional: true,
+ conditional: true
},
moveRowUp: {
icon: "moveRowUp",
title: "Move row up",
- conditional: true,
+ conditional: true
},
moveRowDown: {
icon: "moveRowDown",
title: "Move row down",
- conditional: true,
+ conditional: true
},
deleteRow: {
icon: "deleteRow",
title: "Delete row",
- conditional: true,
+ conditional: true
},
deleteTable: {
icon: "deleteTable",
title: "Delete table",
- conditional: true,
+ conditional: true
},
cellBackgroundColor: {
icon: "backgroundColor",
title: "Cell background color",
- conditional: true,
+ conditional: true
},
cellBorderColor: {
icon: "cellBorderColor",
title: "Cell border color",
- conditional: true,
+ conditional: true
},
cellTextColor: {
icon: "textColor",
title: "Cell text color",
- conditional: true,
+ conditional: true
},
cellBorderWidth: {
icon: "none",
title: "Cell border width",
- conditional: true,
+ conditional: true
},
imageSettings: {
icon: "imageSettings",
title: "Image settings",
- conditional: true,
+ conditional: true
},
imageAlignCenter: {
icon: "alignCenter",
title: "Align center",
- conditional: true,
+ conditional: true
},
imageAlignLeft: {
icon: "alignLeft",
title: "Align left",
- conditional: true,
+ conditional: true
},
imageAlignRight: {
icon: "alignRight",
title: "Align right",
- conditional: true,
+ conditional: true
},
imageProperties: {
icon: "more",
title: "Image properties",
- conditional: true,
+ conditional: true
},
attachmentSettings: {
icon: "attachmentSettings",
title: "Attachment settings",
- conditional: true,
+ conditional: true
},
downloadAttachment: {
icon: "download",
title: "Download attachment",
- conditional: true,
+ conditional: true
},
removeAttachment: {
icon: "delete",
title: "Remove attachment",
- conditional: true,
+ conditional: true
},
embedSettings: {
icon: "embedSettings",
title: "Embed settings",
- conditional: true,
+ conditional: true
},
embedAlignCenter: {
icon: "alignCenter",
title: "Align center",
- conditional: true,
+ conditional: true
},
embedAlignLeft: {
icon: "alignLeft",
title: "Align left",
- conditional: true,
+ conditional: true
},
embedAlignRight: {
icon: "alignRight",
title: "Align right",
- conditional: true,
+ conditional: true
},
embedProperties: {
icon: "more",
title: "Embed properties",
- conditional: true,
+ conditional: true
},
outdent: {
icon: "outdent",
title: "Lift list item",
- conditional: true,
+ conditional: true
},
indent: {
icon: "indent",
title: "Sink list item",
- conditional: true,
- },
+ conditional: true
+ }
};
export function getToolDefinition(id: ToolId) {
@@ -314,8 +314,8 @@ export const STATIC_TOOLBAR_GROUPS: ToolbarDefinition = [
"linkSettings",
"codeRemove",
"outdent",
- "indent",
- ],
+ "indent"
+ ]
];
const defaultPresets: Record<"default" | "minimal", ToolbarDefinition> = {
@@ -331,19 +331,19 @@ const defaultPresets: Record<"default" | "minimal", ToolbarDefinition> = {
"superscript",
"highlight",
"textColor",
- "math",
- ],
+ "math"
+ ]
],
["fontSize"],
["headings", "fontFamily"],
["numberedList", "bulletList"],
["addLink"],
["alignment", "textDirection"],
- ["clearformatting"],
+ ["clearformatting"]
],
minimal: [
["bold", "italic", "underline", "strikethrough", "code"],
["headings", "addLink"],
- ["clearformatting"],
- ],
+ ["clearformatting"]
+ ]
};
diff --git a/packages/editor/src/toolbar/toolbar.tsx b/packages/editor/src/toolbar/toolbar.tsx
index e49cdd28c..c4406dd5d 100644
--- a/packages/editor/src/toolbar/toolbar.tsx
+++ b/packages/editor/src/toolbar/toolbar.tsx
@@ -8,13 +8,13 @@ import { useEffect, useMemo } from "react";
import {
ToolbarLocation,
useIsMobile,
- useToolbarStore,
+ useToolbarStore
} from "./stores/toolbar-store";
import { ToolbarDefinition } from "./types";
import { ToolbarGroup } from "./components/toolbar-group";
import {
EditorContext,
- PopupRenderer,
+ PopupRenderer
} from "../components/popup-presenter/popuprenderer";
type ToolbarProps = FlexProps & {
@@ -59,7 +59,7 @@ export function Toolbar(props: ToolbarProps) {
sx={{
...sx,
flexWrap: isMobile ? "nowrap" : "wrap",
- overflowX: isMobile ? "auto" : "hidden",
+ overflowX: isMobile ? "auto" : "hidden"
}}
{...flexProps}
>
@@ -74,7 +74,7 @@ export function Toolbar(props: ToolbarProps) {
pr: 2,
mr: 2,
borderRight: "1px solid var(--border)",
- ":last-of-type": { mr: 0, pr: 0, borderRight: "none" },
+ ":last-of-type": { mr: 0, pr: 0, borderRight: "none" }
}}
/>
);
diff --git a/packages/editor/src/toolbar/tools/alignment.tsx b/packages/editor/src/toolbar/tools/alignment.tsx
index 4a8c9bd8d..143ae4103 100644
--- a/packages/editor/src/toolbar/tools/alignment.tsx
+++ b/packages/editor/src/toolbar/tools/alignment.tsx
@@ -30,7 +30,7 @@ export function Alignment(props: ToolProps) {
const { editor } = props;
const { textAlign } = {
...editor.getAttributes("paragraph"),
- ...editor.getAttributes("heading"),
+ ...editor.getAttributes("heading")
} as { textAlign: Alignment };
const newAlignment: Alignment =
diff --git a/packages/editor/src/toolbar/tools/block.tsx b/packages/editor/src/toolbar/tools/block.tsx
index adb143f1f..4cbb2a23a 100644
--- a/packages/editor/src/toolbar/tools/block.tsx
+++ b/packages/editor/src/toolbar/tools/block.tsx
@@ -30,7 +30,7 @@ export function InsertBlock(props: ToolProps) {
image(editor, isMobile),
attachment(editor),
isMobile ? embedMobile(editor) : embedDesktop(editor),
- table(editor),
+ table(editor)
];
}, [isMobile]);
@@ -47,8 +47,8 @@ export function InsertBlock(props: ToolProps) {
alignItems: "center",
":hover": { bg: "hover" },
":last-of-type": {
- mr: 0,
- },
+ mr: 0
+ }
}}
onMouseDown={(e) => e.preventDefault()}
onClick={() => setIsOpen((s) => !s)}
@@ -67,7 +67,7 @@ export function InsertBlock(props: ToolProps) {
target: buttonRef.current || undefined,
isTargetAbsolute: true,
location: toolbarLocation === "bottom" ? "top" : "below",
- yOffset: 5,
+ yOffset: 5
}}
/>
</>
@@ -80,7 +80,7 @@ const horizontalRule = (editor: Editor): MenuItem => ({
title: "Horizontal rule",
icon: "horizontalRule",
isChecked: editor?.isActive("horizontalRule"),
- onClick: () => editor.current?.chain().focus().setHorizontalRule().run(),
+ onClick: () => editor.current?.chain().focus().setHorizontalRule().run()
});
const codeblock = (editor: Editor): MenuItem => ({
@@ -89,7 +89,7 @@ const codeblock = (editor: Editor): MenuItem => ({
title: "Code block",
icon: "codeblock",
isChecked: editor?.isActive("codeBlock"),
- onClick: () => editor.current?.chain().focus().toggleCodeBlock().run(),
+ onClick: () => editor.current?.chain().focus().toggleCodeBlock().run()
});
const blockquote = (editor: Editor): MenuItem => ({
@@ -98,7 +98,7 @@ const blockquote = (editor: Editor): MenuItem => ({
title: "Quote",
icon: "blockquote",
isChecked: editor?.isActive("blockQuote"),
- onClick: () => editor.current?.chain().focus().toggleBlockquote().run(),
+ onClick: () => editor.current?.chain().focus().toggleBlockquote().run()
});
const mathblock = (editor: Editor): MenuItem => ({
@@ -107,7 +107,7 @@ const mathblock = (editor: Editor): MenuItem => ({
title: "Math & formulas",
icon: "mathBlock",
isChecked: editor?.isActive("mathBlock"),
- onClick: () => editor.current?.chain().focus().insertMathBlock().run(),
+ onClick: () => editor.current?.chain().focus().insertMathBlock().run()
});
const image = (editor: Editor, isMobile: boolean): MenuItem => ({
@@ -124,7 +124,7 @@ const image = (editor: Editor, isMobile: boolean): MenuItem => ({
title: "Upload from disk",
icon: "upload",
onClick: () =>
- editor.current?.chain().focus().openAttachmentPicker("image").run(),
+ editor.current?.chain().focus().openAttachmentPicker("image").run()
},
{
key: "camera",
@@ -133,11 +133,11 @@ const image = (editor: Editor, isMobile: boolean): MenuItem => ({
icon: "camera",
isHidden: !isMobile,
onClick: () =>
- editor.current?.chain().focus().openAttachmentPicker("camera").run(),
+ editor.current?.chain().focus().openAttachmentPicker("camera").run()
},
- isMobile ? uploadImageFromURLMobile(editor) : uploadImageFromURL(editor),
- ],
- },
+ isMobile ? uploadImageFromURLMobile(editor) : uploadImageFromURL(editor)
+ ]
+ }
});
const table = (editor: Editor): MenuItem => ({
@@ -159,16 +159,16 @@ const table = (editor: Editor): MenuItem => ({
.focus()
.insertTable({
rows: size.rows,
- cols: size.columns,
+ cols: size.columns
})
.run();
props.onClick?.();
}}
/>
- ),
- },
- ],
- },
+ )
+ }
+ ]
+ }
});
const embedMobile = (editor: Editor): MenuItem => ({
@@ -193,10 +193,10 @@ const embedMobile = (editor: Editor): MenuItem => ({
}}
/>
);
- },
- },
- ],
- },
+ }
+ }
+ ]
+ }
});
const embedDesktop = (editor: Editor): MenuItem => ({
@@ -216,9 +216,9 @@ const embedDesktop = (editor: Editor): MenuItem => ({
hide();
}}
/>
- ),
+ )
});
- },
+ }
});
const attachment = (editor: Editor): MenuItem => ({
@@ -228,7 +228,7 @@ const attachment = (editor: Editor): MenuItem => ({
icon: "attachment",
isChecked: editor?.isActive("attachment"),
onClick: () =>
- editor.current?.chain().focus().openAttachmentPicker("file").run(),
+ editor.current?.chain().focus().openAttachmentPicker("file").run()
});
const tasklist = (editor: Editor): MenuItem => ({
@@ -237,7 +237,7 @@ const tasklist = (editor: Editor): MenuItem => ({
title: "Task list",
icon: "checkbox",
isChecked: editor?.isActive("taskList"),
- onClick: () => editor.current?.chain().focus().toggleTaskList().run(),
+ onClick: () => editor.current?.chain().focus().toggleTaskList().run()
});
const outlinelist = (editor: Editor): MenuItem => ({
@@ -246,7 +246,7 @@ const outlinelist = (editor: Editor): MenuItem => ({
title: "Outline list",
icon: "outlineList",
isChecked: editor?.isActive("outlineList"),
- onClick: () => editor.current?.chain().focus().toggleOutlineList().run(),
+ onClick: () => editor.current?.chain().focus().toggleOutlineList().run()
});
const uploadImageFromURLMobile = (editor: Editor): MenuItem => ({
@@ -275,10 +275,10 @@ const uploadImageFromURLMobile = (editor: Editor): MenuItem => ({
onClick?.();
}}
/>
- ),
- },
- ],
- },
+ )
+ }
+ ]
+ }
});
const uploadImageFromURL = (editor: Editor): MenuItem => ({
@@ -301,7 +301,7 @@ const uploadImageFromURL = (editor: Editor): MenuItem => ({
}}
onClose={hide}
/>
- ),
+ )
});
- },
+ }
});
diff --git a/packages/editor/src/toolbar/tools/colors.tsx b/packages/editor/src/toolbar/tools/colors.tsx
index 5fabc3713..1a14c6cf5 100644
--- a/packages/editor/src/toolbar/tools/colors.tsx
+++ b/packages/editor/src/toolbar/tools/colors.tsx
@@ -37,8 +37,8 @@ export function ColorTool(props: ColorToolProps) {
mr: 0,
bg: activeColor || "transparent",
":hover": {
- bg: activeColor ? tColor.darken(5).toRgbString() : "transparent",
- },
+ bg: activeColor ? tColor.darken(5).toRgbString() : "transparent"
+ }
}}
onOpen={() => setIsOpen((s) => !s)}
toggled={isOpen}
@@ -53,7 +53,7 @@ export function ColorTool(props: ColorToolProps) {
target: getToolbarElement(),
align: isBottom ? "center" : "end",
location: isBottom ? "top" : "below",
- yOffset: 10,
+ yOffset: 10
}}
focusOnRender={false}
blocking={false}
diff --git a/packages/editor/src/toolbar/tools/embed.tsx b/packages/editor/src/toolbar/tools/embed.tsx
index f72f99788..0c0023ee9 100644
--- a/packages/editor/src/toolbar/tools/embed.tsx
+++ b/packages/editor/src/toolbar/tools/embed.tsx
@@ -106,7 +106,7 @@ export function EmbedProperties(props: ToolProps) {
align: "start",
location: "below",
yOffset: 10,
- isTargetAbsolute: true,
+ isTargetAbsolute: true
}}
>
<EmbedPopup
diff --git a/packages/editor/src/toolbar/tools/font.tsx b/packages/editor/src/toolbar/tools/font.tsx
index 5e0951890..5d05df127 100644
--- a/packages/editor/src/toolbar/tools/font.tsx
+++ b/packages/editor/src/toolbar/tools/font.tsx
@@ -46,7 +46,7 @@ export function FontSize(props: ToolProps) {
const fontFamilies = {
"Sans-serif": "Open Sans",
Serif: "serif",
- Monospace: "monospace",
+ Monospace: "monospace"
};
export function FontFamily(props: ToolProps) {
const { editor } = props;
@@ -85,8 +85,8 @@ function toMenuItems(editor: Editor, currentFontFamily: string): MenuItem[] {
isChecked: key === currentFontFamily,
onClick: () => editor.current?.chain().focus().setFontFamily(value).run(),
styles: {
- fontFamily: value,
- },
+ fontFamily: value
+ }
});
}
return menuItems;
diff --git a/packages/editor/src/toolbar/tools/headings.tsx b/packages/editor/src/toolbar/tools/headings.tsx
index 02d7a45f9..b49f6535f 100644
--- a/packages/editor/src/toolbar/tools/headings.tsx
+++ b/packages/editor/src/toolbar/tools/headings.tsx
@@ -49,14 +49,14 @@ function toMenuItems(
.focus()
.updateAttributes("textStyle", { fontSize: null, fontStyle: null })
.setHeading({ level: level as any })
- .run(),
+ .run()
}));
const paragraph: MenuItem = {
key: "paragraph",
type: "button",
title: "Paragraph",
isChecked: !currentHeadingLevel,
- onClick: () => editor.current?.chain().focus().setParagraph().run(),
+ onClick: () => editor.current?.chain().focus().setParagraph().run()
};
return [paragraph, ...menuItems];
}
diff --git a/packages/editor/src/toolbar/tools/image.tsx b/packages/editor/src/toolbar/tools/image.tsx
index 0f80f6e95..6263e850e 100644
--- a/packages/editor/src/toolbar/tools/image.tsx
+++ b/packages/editor/src/toolbar/tools/image.tsx
@@ -8,7 +8,7 @@ import { useToolbarLocation } from "../stores/toolbar-store";
import { ImageProperties as ImagePropertiesPopup } from "../popups/image-properties";
import {
ImageAlignmentOptions,
- ImageSizeOptions,
+ ImageSizeOptions
} from "../../extensions/image";
import { findSelectedNode } from "../utils/prosemirror";
@@ -30,7 +30,7 @@ export function ImageSettings(props: ToolProps) {
"imageAlignLeft",
"imageAlignCenter",
"imageAlignRight",
- "imageProperties",
+ "imageProperties"
]
}
/>
@@ -119,7 +119,7 @@ export function ImageProperties(props: ToolProps) {
align: "start",
location: "below",
yOffset: 10,
- isTargetAbsolute: true,
+ isTargetAbsolute: true
}}
>
<ImagePropertiesPopup
diff --git a/packages/editor/src/toolbar/tools/index.ts b/packages/editor/src/toolbar/tools/index.ts
index 94fe156c6..13deafdc9 100644
--- a/packages/editor/src/toolbar/tools/index.ts
+++ b/packages/editor/src/toolbar/tools/index.ts
@@ -10,7 +10,7 @@ import {
Superscript,
ClearFormatting,
CodeRemove,
- Math,
+ Math
} from "./inline";
import { InsertBlock } from "./block";
import { FontSize, FontFamily } from "./font";
@@ -40,26 +40,26 @@ import {
CellBackgroundColor,
CellBorderColor,
CellTextColor,
- CellBorderWidth,
+ CellBorderWidth
} from "./table";
import {
ImageSettings,
ImageAlignCenter,
ImageAlignLeft,
ImageAlignRight,
- ImageProperties,
+ ImageProperties
} from "./image";
import {
AttachmentSettings,
DownloadAttachment,
- RemoveAttachment,
+ RemoveAttachment
} from "./attachment";
import {
EmbedAlignCenter,
EmbedAlignLeft,
EmbedAlignRight,
EmbedProperties,
- EmbedSettings,
+ EmbedSettings
} from "./embed";
import { AddLink, EditLink, RemoveLink, LinkSettings, OpenLink } from "./link";
@@ -130,7 +130,7 @@ const tools = {
deleteTable: DeleteTable,
outdent: Outdent,
- indent: Indent,
+ indent: Indent
};
export function findTool(id: ToolId): React.FunctionComponent<ToolProps> {
diff --git a/packages/editor/src/toolbar/tools/link.tsx b/packages/editor/src/toolbar/tools/link.tsx
index f9d57339f..97d9ad444 100644
--- a/packages/editor/src/toolbar/tools/link.tsx
+++ b/packages/editor/src/toolbar/tools/link.tsx
@@ -139,7 +139,7 @@ export function EditLink(props: ToolProps) {
return {
text: selectedText,
href: mark.attrs.href,
- isImage: node.type.name === ImageNode.name,
+ isImage: node.type.name === ImageNode.name
};
}}
/>
@@ -156,7 +156,7 @@ export function RemoveLink(props: ToolProps) {
if (selectedNode)
editor.current?.commands.setTextSelection({
from: selectedNode.from,
- to: selectedNode.to,
+ to: selectedNode.to
});
editor.current?.chain().focus().unsetLink().run();
}}
@@ -226,7 +226,7 @@ function LinkTool(props: LinkToolProps) {
isTargetAbsolute: true,
location: "below",
align: "center",
- yOffset: 5,
+ yOffset: 5
}}
title={isEditing ? "Edit link" : "Insert link"}
isOpen={isOpen}
diff --git a/packages/editor/src/toolbar/tools/lists.tsx b/packages/editor/src/toolbar/tools/lists.tsx
index 5ef6daaca..41a3ada30 100644
--- a/packages/editor/src/toolbar/tools/lists.tsx
+++ b/packages/editor/src/toolbar/tools/lists.tsx
@@ -53,7 +53,7 @@ function _ListTool<TListStyleTypes extends string>(
target: isBottom ? getToolbarElement() : buttonRef.current || "mouse",
align: "center",
location: isBottom ? "top" : "below",
- yOffset: 10,
+ yOffset: 10
}}
onClosed={() => setIsOpen(false)}
renderPopup={() => (
@@ -62,7 +62,7 @@ function _ListTool<TListStyleTypes extends string>(
bg: "background",
display: "grid",
gridTemplateColumns: "1fr 1fr 1fr",
- p: 1,
+ p: 1
}}
>
{subTypes.map((item) => (
@@ -127,14 +127,14 @@ export function NumberedList(props: ToolProps) {
{
type: "upper-roman",
title: "Upper Roman",
- items: ["I", "II", "III"],
+ items: ["I", "II", "III"]
},
{
type: "lower-roman",
title: "Lower Roman",
- items: ["i", "ii", "iii"],
+ items: ["i", "ii", "iii"]
},
- { type: "lower-greek", title: "Lower Greek", items: ["α", "β", "γ"] },
+ { type: "lower-greek", title: "Lower Greek", items: ["α", "β", "γ"] }
]}
/>
);
@@ -157,7 +157,7 @@ export function BulletList(props: ToolProps) {
subTypes={[
{ type: "disc", title: "Decimal", items: ["1", "2", "3"] },
{ type: "circle", title: "Upper alpha", items: ["A", "B", "C"] },
- { type: "square", title: "Lower alpha", items: ["a", "b", "c"] },
+ { type: "square", title: "Lower alpha", items: ["a", "b", "c"] }
]}
/>
);
@@ -209,7 +209,7 @@ function ListThumbnail(props: ListThumbnailProps) {
flexDirection: "column",
flex: 1,
p: 0,
- listStyleType,
+ listStyleType
}}
onMouseDown={(e) => e.preventDefault()}
>
@@ -221,12 +221,12 @@ function ListThumbnail(props: ListThumbnailProps) {
display: "list-item",
color: "text",
fontSize: 8,
- mb: "1px",
+ mb: "1px"
}}
>
<Flex
sx={{
- alignItems: "center",
+ alignItems: "center"
}}
>
<Box
@@ -235,7 +235,7 @@ function ListThumbnail(props: ListThumbnailProps) {
flexShrink: 0,
height: 4,
bg: "#cbcbcb",
- borderRadius: "small",
+ borderRadius: "small"
}}
/>
</Flex>
diff --git a/packages/editor/src/toolbar/tools/table.tsx b/packages/editor/src/toolbar/tools/table.tsx
index 0aeacd8dd..d09aadb02 100644
--- a/packages/editor/src/toolbar/tools/table.tsx
+++ b/packages/editor/src/toolbar/tools/table.tsx
@@ -9,7 +9,7 @@ import {
moveColumnLeft as moveColumnLeftAction,
moveColumnRight as moveColumnRightAction,
moveRowDown as moveRowDownAction,
- moveRowUp as moveRowUpAction,
+ moveRowUp as moveRowUpAction
} from "../../extensions/table/actions";
import { MoreTools } from "../components/more-tools";
import { menuButtonToTool } from "./utils";
@@ -39,7 +39,7 @@ export function TableSettings(props: ToolProps) {
"rowProperties",
"deleteRow",
"deleteColumn",
- "deleteTable",
+ "deleteTable"
]}
/>
);
@@ -55,7 +55,7 @@ export function RowProperties(props: ToolProps) {
insertRowBelow(editor),
moveRowUp(editor),
moveRowDown(editor),
- deleteRow(editor),
+ deleteRow(editor)
],
[]
);
@@ -78,7 +78,7 @@ export function RowProperties(props: ToolProps) {
target: buttonRef.current,
isTargetAbsolute: true,
location: "below",
- yOffset: 5,
+ yOffset: 5
}}
items={items}
/>
@@ -97,7 +97,7 @@ export function ColumnProperties(props: ToolProps) {
insertColumnRight(editor),
moveColumnLeft(editor),
moveColumnRight(editor),
- deleteColumn(editor),
+ deleteColumn(editor)
],
[]
);
@@ -120,7 +120,7 @@ export function ColumnProperties(props: ToolProps) {
target: buttonRef.current,
isTargetAbsolute: true,
location: "below",
- yOffset: 5,
+ yOffset: 5
}}
items={items}
/>
@@ -145,7 +145,7 @@ export function TableProperties(props: ToolProps) {
splitCells(editor),
cellProperties(editor),
{ type: "separator", key: "tableSeperator" },
- deleteTable(editor),
+ deleteTable(editor)
],
[]
);
@@ -168,7 +168,7 @@ export function TableProperties(props: ToolProps) {
target: buttonRef.current,
isTargetAbsolute: true,
location: "below",
- yOffset: 5,
+ yOffset: 5
}}
items={items}
/>
@@ -188,7 +188,7 @@ export function CellProperties(props: ToolProps) {
"cellBackgroundColor",
"cellTextColor",
"cellBorderColor",
- "cellBorderWidth",
+ "cellBorderWidth"
]}
/>
</>
@@ -292,7 +292,7 @@ const insertColumnLeft = (editor: Editor): MenuButton => ({
...getToolDefinition("insertColumnLeft"),
key: "addColumnLeft",
type: "button",
- onClick: () => editor.current?.chain().focus().addColumnBefore().run(),
+ onClick: () => editor.current?.chain().focus().addColumnBefore().run()
});
const insertColumnRight = (editor: Editor): MenuButton => ({
@@ -301,83 +301,83 @@ const insertColumnRight = (editor: Editor): MenuButton => ({
type: "button",
title: "Add column right",
onClick: () => editor.current?.chain().focus().addColumnAfter().run(),
- icon: "insertColumnRight",
+ icon: "insertColumnRight"
});
const moveColumnLeft = (editor: Editor): MenuButton => ({
...getToolDefinition("moveColumnLeft"),
key: "moveColumnLeft",
type: "button",
- onClick: () => moveColumnLeftAction(editor),
+ onClick: () => moveColumnLeftAction(editor)
});
const moveColumnRight = (editor: Editor): MenuButton => ({
...getToolDefinition("moveColumnRight"),
key: "moveColumnRight",
type: "button",
- onClick: () => moveColumnRightAction(editor),
+ onClick: () => moveColumnRightAction(editor)
});
const deleteColumn = (editor: Editor): MenuButton => ({
...getToolDefinition("deleteColumn"),
key: "deleteColumn",
type: "button",
- onClick: () => editor.current?.chain().focus().deleteColumn().run(),
+ onClick: () => editor.current?.chain().focus().deleteColumn().run()
});
const splitCells = (editor: Editor): MenuButton => ({
...getToolDefinition("splitCells"),
key: "splitCells",
type: "button",
- onClick: () => editor.current?.chain().focus().splitCell().run(),
+ onClick: () => editor.current?.chain().focus().splitCell().run()
});
const mergeCells = (editor: Editor): MenuButton => ({
...getToolDefinition("mergeCells"),
key: "mergeCells",
type: "button",
- onClick: () => editor.current?.chain().focus().mergeCells().run(),
+ onClick: () => editor.current?.chain().focus().mergeCells().run()
});
const insertRowAbove = (editor: Editor): MenuButton => ({
...getToolDefinition("insertRowAbove"),
key: "insertRowAbove",
type: "button",
- onClick: () => editor.current?.chain().focus().addRowBefore().run(),
+ onClick: () => editor.current?.chain().focus().addRowBefore().run()
});
const insertRowBelow = (editor: Editor): MenuButton => ({
...getToolDefinition("insertRowBelow"),
key: "insertRowBelow",
type: "button",
- onClick: () => editor.current?.chain().focus().addRowAfter().run(),
+ onClick: () => editor.current?.chain().focus().addRowAfter().run()
});
const moveRowUp = (editor: Editor): MenuButton => ({
...getToolDefinition("moveRowUp"),
key: "moveRowUp",
type: "button",
- onClick: () => moveRowUpAction(editor),
+ onClick: () => moveRowUpAction(editor)
});
const moveRowDown = (editor: Editor): MenuButton => ({
...getToolDefinition("moveRowDown"),
key: "moveRowDown",
type: "button",
- onClick: () => moveRowDownAction(editor),
+ onClick: () => moveRowDownAction(editor)
});
const deleteRow = (editor: Editor): MenuButton => ({
...getToolDefinition("deleteRow"),
key: "deleteRow",
type: "button",
- onClick: () => editor.current?.chain().focus().deleteRow().run(),
+ onClick: () => editor.current?.chain().focus().deleteRow().run()
});
const deleteTable = (editor: Editor): MenuButton => ({
...getToolDefinition("deleteTable"),
key: "deleteTable",
type: "button",
- onClick: () => editor.current?.chain().focus().deleteTable().run(),
+ onClick: () => editor.current?.chain().focus().deleteTable().run()
});
const cellProperties = (editor: Editor): MenuButton => ({
@@ -386,9 +386,9 @@ const cellProperties = (editor: Editor): MenuButton => ({
type: "button",
onClick: () => {
showPopup({
- popup: (hide) => <CellPropertiesPopup onClose={hide} editor={editor} />,
+ popup: (hide) => <CellPropertiesPopup onClose={hide} editor={editor} />
});
- },
+ }
});
export const InsertColumnLeft = menuButtonToTool(insertColumnLeft);
diff --git a/packages/editor/src/toolbar/tools/text-direction.tsx b/packages/editor/src/toolbar/tools/text-direction.tsx
index 77b13bde1..eb3d60f78 100644
--- a/packages/editor/src/toolbar/tools/text-direction.tsx
+++ b/packages/editor/src/toolbar/tools/text-direction.tsx
@@ -30,7 +30,7 @@ export function TextDirection(props: ToolProps) {
const { editor } = props;
const { textDirection } = {
...editor.getAttributes("paragraph"),
- ...editor.getAttributes("heading"),
+ ...editor.getAttributes("heading")
} as { textDirection: TextDirection };
const newTextDirection: TextDirection =
diff --git a/packages/editor/src/toolbar/utils/prosemirror.ts b/packages/editor/src/toolbar/utils/prosemirror.ts
index 0c754a02c..3d8f350aa 100644
--- a/packages/editor/src/toolbar/utils/prosemirror.ts
+++ b/packages/editor/src/toolbar/utils/prosemirror.ts
@@ -56,7 +56,7 @@ export function selectionToOffset(state: EditorState): NodeWithOffset {
return {
node: state.doc.nodeAt(from) || undefined,
from,
- to: from + $from.node().nodeSize,
+ to: from + $from.node().nodeSize
};
}
diff --git a/packages/editor/src/types.ts b/packages/editor/src/types.ts
index f7e308ed1..cd0d64006 100644
--- a/packages/editor/src/types.ts
+++ b/packages/editor/src/types.ts
@@ -20,7 +20,7 @@ export class Editor extends TiptapEditor {
requestPermission(id: keyof UnionCommands): TiptapEditor | undefined {
const event = new CustomEvent("permissionrequest", {
detail: { id },
- cancelable: true,
+ cancelable: true
});
if (!window.dispatchEvent(event)) return undefined;
diff --git a/packages/editor/src/utils/downloader.ts b/packages/editor/src/utils/downloader.ts
index 186f53231..d529df74e 100644
--- a/packages/editor/src/utils/downloader.ts
+++ b/packages/editor/src/utils/downloader.ts
@@ -19,7 +19,7 @@ export async function downloadImage(url: string) {
blob,
url: URL.createObjectURL(blob),
type: contentType,
- size,
+ size
};
}
diff --git a/packages/editor/src/utils/platform.ts b/packages/editor/src/utils/platform.ts
index dfcfa7c25..c52f50c0d 100644
--- a/packages/editor/src/utils/platform.ts
+++ b/packages/editor/src/utils/platform.ts
@@ -6,7 +6,7 @@ export function isiOS(): boolean {
"iPod Simulator",
"iPad",
"iPhone",
- "iPod",
+ "iPod"
].includes(navigator.platform) ||
// iPad on iOS 13 detection
(navigator.userAgent.includes("Mac") && "ontouchend" in document)
diff --git a/packages/editor/src/utils/position.ts b/packages/editor/src/utils/position.ts
index b4bde2367..40013a15c 100644
--- a/packages/editor/src/utils/position.ts
+++ b/packages/editor/src/utils/position.ts
@@ -38,7 +38,7 @@ export function getPosition(
xOffset = 0,
align = "start",
parent = document.body,
- yAnchor,
+ yAnchor
} = options || {};
const { x, y, width, height, actualX, actualY } =
@@ -128,7 +128,7 @@ function getMousePosition(e: MouseEvent) {
x: posx,
y: posy,
actualY: posy,
- actualX: posx,
+ actualX: posx
};
}
@@ -143,7 +143,7 @@ export function getElementPosition(
width: rect.width,
height: rect.height,
actualY: rect.y,
- actualX: rect.x,
+ actualX: rect.x
};
if (absolute) {
position.x = position.actualX;
diff --git a/packages/logger/src/index.ts b/packages/logger/src/index.ts
index 752dac65b..1b94b469d 100644
--- a/packages/logger/src/index.ts
+++ b/packages/logger/src/index.ts
@@ -22,7 +22,7 @@ export class Logger implements ILogger {
constructor(
private readonly config: LoggerConfig = {
reporter: consoleReporter,
- lastTime: Date.now(),
+ lastTime: Date.now()
}
) {}
@@ -74,7 +74,7 @@ function logLevelFactory(level: LogLevel, config: LoggerConfig) {
timestamp: now,
extras,
scope: config.scope,
- elapsed: now - config.lastTime,
+ elapsed: now - config.lastTime
});
config.lastTime = now;
};
@@ -97,7 +97,7 @@ function errorLogLevelFactory(level: LogLevel, config: LoggerConfig) {
timestamp: now,
extras,
scope: config.scope,
- elapsed: now - config.lastTime,
+ elapsed: now - config.lastTime
});
config.lastTime = now;
};
@@ -109,6 +109,6 @@ export function combineReporters(reporters: ILogReporter[]): ILogReporter {
for (const reporter of reporters) {
reporter.write(log);
}
- },
+ }
};
}
diff --git a/packages/logger/src/reporters/console.ts b/packages/logger/src/reporters/console.ts
index 6cc18a1ea..dc846d43b 100644
--- a/packages/logger/src/reporters/console.ts
+++ b/packages/logger/src/reporters/console.ts
@@ -23,7 +23,7 @@ export const consoleReporter: ILogReporter = {
console.log(format(log));
break;
}
- },
+ }
};
type Token = {
@@ -36,7 +36,7 @@ export function format(log: LogMessage) {
{ value: time, separator: " | " },
{ value: LogLevel[log.level].toUpperCase(), separator: " | " },
{ value: log.scope ? `[${log.scope}]` : "", separator: ": " },
- { value: log.message },
+ { value: log.message }
];
if (log.extras) tokens.push({ value: JSON.stringify(log.extras) });
diff --git a/packages/logger/src/types.ts b/packages/logger/src/types.ts
index 753172a82..5c25c7037 100644
--- a/packages/logger/src/types.ts
+++ b/packages/logger/src/types.ts
@@ -8,7 +8,7 @@ export enum LogLevel {
Warn,
Info,
Debug,
- Log,
+ Log
}
export type LogMessage = {
diff --git a/packages/streamable-fs/index.ts b/packages/streamable-fs/index.ts
index c995e650a..aa70563be 100644
--- a/packages/streamable-fs/index.ts
+++ b/packages/streamable-fs/index.ts
@@ -13,7 +13,7 @@ export class StreamableFS implements IStreamableFS {
this.storage = localforage.createInstance({
storeName: "streamable-fs",
name: db,
- driver: [localforage.INDEXEDDB],
+ driver: [localforage.INDEXEDDB]
});
}
@@ -28,7 +28,7 @@ export class StreamableFS implements IStreamableFS {
filename,
size,
type,
- chunks: 0,
+ chunks: 0
});
return new FileHandle(this.storage, file);
}
diff --git a/packages/streamable-fs/src/filestreamsource.ts b/packages/streamable-fs/src/filestreamsource.ts
index 269b9a3ea..305490dd6 100644
--- a/packages/streamable-fs/src/filestreamsource.ts
+++ b/packages/streamable-fs/src/filestreamsource.ts
@@ -20,7 +20,7 @@ export default class FileStreamSource implements UnderlyingSource<Chunk> {
if (data)
controller.enqueue({
data,
- final: isFinalChunk,
+ final: isFinalChunk
});
if (isFinalChunk || !data) controller.close();