mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
editor: fixes & refactoring for monorepo merge
This commit is contained in:
@@ -12,4 +12,7 @@ apps/mobile/__tests__/
|
|||||||
apps/web/public/an.js
|
apps/web/public/an.js
|
||||||
|
|
||||||
# editor
|
# editor
|
||||||
packages/editor/styles/
|
packages/editor/styles/
|
||||||
|
|
||||||
|
# editor mobile
|
||||||
|
packages/editor-mobile/build.bundle
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@flyerhq/react-native-link-preview": "^1.6.0",
|
"@flyerhq/react-native-link-preview": "^1.6.0",
|
||||||
"@mdi/js": "^6.7.96",
|
"@mdi/js": "^6.7.96",
|
||||||
"@streetwriters/editor": "*",
|
"@notesnook/editor": "*",
|
||||||
"@notesnook/core": "*",
|
"@notesnook/core": "*",
|
||||||
"absolutify": "^0.1.0",
|
"absolutify": "^0.1.0",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import type {
|
import type {
|
||||||
Attachment,
|
Attachment,
|
||||||
AttachmentProgress
|
AttachmentProgress
|
||||||
} from "@streetwriters/editor/dist/extensions/attachment/index";
|
} from "@notesnook/editor/dist/extensions/attachment/index";
|
||||||
import type { ImageAttributes } from "@streetwriters/editor/dist/extensions/image/index";
|
import type { ImageAttributes } from "@notesnook/editor/dist/extensions/image/index";
|
||||||
import { createRef, RefObject } from "react";
|
import { createRef, RefObject } from "react";
|
||||||
import { Platform } from "react-native";
|
import { Platform } from "react-native";
|
||||||
import { EdgeInsets } from "react-native-safe-area-context";
|
import { EdgeInsets } from "react-native-safe-area-context";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useEditor } from "./use-editor";
|
import { useEditor } from "./use-editor";
|
||||||
import type { ToolbarGroupDefinition } from "@streetwriters/editor/dist/toolbar/types";
|
import type { ToolbarGroupDefinition } from "@notesnook/editor/dist/toolbar/types";
|
||||||
import { ThemeStore } from "../../../stores/use-theme-store";
|
import { ThemeStore } from "../../../stores/use-theme-store";
|
||||||
export type useEditorType = ReturnType<typeof useEditor>;
|
export type useEditorType = ReturnType<typeof useEditor>;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable no-case-declarations */
|
/* eslint-disable no-case-declarations */
|
||||||
/* eslint-disable @typescript-eslint/no-var-requires */
|
/* eslint-disable @typescript-eslint/no-var-requires */
|
||||||
import { getDefaultPresets } from "@streetwriters/editor/dist/toolbar/tool-definitions";
|
import { getDefaultPresets } from "@notesnook/editor/dist/toolbar/tool-definitions";
|
||||||
import { useCallback, useEffect, useRef } from "react";
|
import { useCallback, useEffect, useRef } from "react";
|
||||||
import {
|
import {
|
||||||
BackHandler,
|
BackHandler,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import type { ToolbarGroupDefinition } from "@streetwriters/editor/dist/toolbar/types";
|
import type { ToolbarGroupDefinition } from "@notesnook/editor/dist/toolbar/types";
|
||||||
import create, { State } from "zustand";
|
import create, { State } from "zustand";
|
||||||
import { persist } from "zustand/middleware";
|
import { persist } from "zustand/middleware";
|
||||||
import { useNoteStore } from "../../../stores/use-notes-store";
|
import { useNoteStore } from "../../../stores/use-notes-store";
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ToolId } from "@streetwriters/editor/dist/toolbar";
|
import { ToolId } from "@notesnook/editor/dist/toolbar";
|
||||||
import React, { RefObject } from "react";
|
import React, { RefObject } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
import ActionSheet from "react-native-actions-sheet";
|
import ActionSheet from "react-native-actions-sheet";
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Icons } from "@streetwriters/editor/dist/toolbar/icons";
|
import { Icons } from "@notesnook/editor/dist/toolbar/icons";
|
||||||
import {
|
import {
|
||||||
getDefaultPresets,
|
getDefaultPresets,
|
||||||
getAllTools
|
getAllTools
|
||||||
} from "@streetwriters/editor/dist/toolbar/tool-definitions";
|
} from "@notesnook/editor/dist/toolbar/tool-definitions";
|
||||||
import { ToolId } from "@streetwriters/editor/dist/toolbar/tools";
|
import { ToolId } from "@notesnook/editor/dist/toolbar/tools";
|
||||||
import { ToolbarGroupDefinition } from "@streetwriters/editor/dist/toolbar/index";
|
import { ToolbarGroupDefinition } from "@notesnook/editor/dist/toolbar/index";
|
||||||
import { useThemeStore } from "../../../stores/use-theme-store";
|
import { useThemeStore } from "../../../stores/use-theme-store";
|
||||||
|
|
||||||
export const tools = getAllTools();
|
export const tools = getAllTools();
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ module.exports = (env) => {
|
|||||||
//'react-native': reactNativePath,
|
//'react-native': reactNativePath,
|
||||||
"react": path.join(__dirname, "../node_modules/react"),
|
"react": path.join(__dirname, "../node_modules/react"),
|
||||||
"react-dom": path.join(__dirname, "../node_modules/react-dom"),
|
"react-dom": path.join(__dirname, "../node_modules/react-dom"),
|
||||||
"@streetwriters/editor": path.join(__dirname, "../../../packages/editor"),
|
"@notesnook/editor": path.join(__dirname, "../../../packages/editor"),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
14
apps/mobile/package-lock.json
generated
14
apps/mobile/package-lock.json
generated
@@ -12,7 +12,7 @@
|
|||||||
"app/"
|
"app/"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@streetwriters/editor": "*"
|
"@notesnook/editor": "*"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"patch-package": "^6.4.7",
|
"patch-package": "^6.4.7",
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@flyerhq/react-native-link-preview": "^1.6.0",
|
"@flyerhq/react-native-link-preview": "^1.6.0",
|
||||||
"@mdi/js": "^6.7.96",
|
"@mdi/js": "^6.7.96",
|
||||||
"@streetwriters/editor": "*",
|
"@notesnook/editor": "*",
|
||||||
"@streetwriters/notesnook-core": "^7.3.5",
|
"@streetwriters/notesnook-core": "^7.3.5",
|
||||||
"absolutify": "^0.1.0",
|
"absolutify": "^0.1.0",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
@@ -5823,9 +5823,9 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@social-embed/lib/-/lib-0.0.1-next.12.tgz",
|
"resolved": "https://registry.npmjs.org/@social-embed/lib/-/lib-0.0.1-next.12.tgz",
|
||||||
"integrity": "sha512-CUqgq2PTmdmWhNPzth9JN1cFoaFsIWhgiuDVD23hjD+9HJVD+xs3GlbZF+YWYMKVhRa3hib4A7Ev8rOjz2QBwQ=="
|
"integrity": "sha512-CUqgq2PTmdmWhNPzth9JN1cFoaFsIWhgiuDVD23hjD+9HJVD+xs3GlbZF+YWYMKVhRa3hib4A7Ev8rOjz2QBwQ=="
|
||||||
},
|
},
|
||||||
"node_modules/@streetwriters/editor": {
|
"node_modules/@notesnook/editor": {
|
||||||
"version": "1.3.1",
|
"version": "1.3.1",
|
||||||
"resolved": "https://npm.pkg.github.com/download/@streetwriters/editor/1.3.1/68b8d739d0b11e392b689b5bf7375318172de61a",
|
"resolved": "https://npm.pkg.github.com/download/@notesnook/editor/1.3.1/68b8d739d0b11e392b689b5bf7375318172de61a",
|
||||||
"integrity": "sha512-Pub5JXPabY4YdraMLi43HW+Y94ZiZRZA+PXJUmpSPa+KBr/36hTZG55EJUEqlY+bGDdec0ctSWFJ5Hu1cNPBqg==",
|
"integrity": "sha512-Pub5JXPabY4YdraMLi43HW+Y94ZiZRZA+PXJUmpSPa+KBr/36hTZG55EJUEqlY+bGDdec0ctSWFJ5Hu1cNPBqg==",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "GPL-3.0",
|
"license": "GPL-3.0",
|
||||||
@@ -26147,7 +26147,7 @@
|
|||||||
"requires": {
|
"requires": {
|
||||||
"@flyerhq/react-native-link-preview": "^1.6.0",
|
"@flyerhq/react-native-link-preview": "^1.6.0",
|
||||||
"@mdi/js": "^6.7.96",
|
"@mdi/js": "^6.7.96",
|
||||||
"@streetwriters/editor": "*",
|
"@notesnook/editor": "*",
|
||||||
"@streetwriters/notesnook-core": "^7.3.5",
|
"@streetwriters/notesnook-core": "^7.3.5",
|
||||||
"absolutify": "^0.1.0",
|
"absolutify": "^0.1.0",
|
||||||
"buffer": "^6.0.3",
|
"buffer": "^6.0.3",
|
||||||
@@ -27440,9 +27440,9 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@social-embed/lib/-/lib-0.0.1-next.12.tgz",
|
"resolved": "https://registry.npmjs.org/@social-embed/lib/-/lib-0.0.1-next.12.tgz",
|
||||||
"integrity": "sha512-CUqgq2PTmdmWhNPzth9JN1cFoaFsIWhgiuDVD23hjD+9HJVD+xs3GlbZF+YWYMKVhRa3hib4A7Ev8rOjz2QBwQ=="
|
"integrity": "sha512-CUqgq2PTmdmWhNPzth9JN1cFoaFsIWhgiuDVD23hjD+9HJVD+xs3GlbZF+YWYMKVhRa3hib4A7Ev8rOjz2QBwQ=="
|
||||||
},
|
},
|
||||||
"@streetwriters/editor": {
|
"@notesnook/editor": {
|
||||||
"version": "1.3.1",
|
"version": "1.3.1",
|
||||||
"resolved": "https://npm.pkg.github.com/download/@streetwriters/editor/1.3.1/68b8d739d0b11e392b689b5bf7375318172de61a",
|
"resolved": "https://npm.pkg.github.com/download/@notesnook/editor/1.3.1/68b8d739d0b11e392b689b5bf7375318172de61a",
|
||||||
"integrity": "sha512-Pub5JXPabY4YdraMLi43HW+Y94ZiZRZA+PXJUmpSPa+KBr/36hTZG55EJUEqlY+bGDdec0ctSWFJ5Hu1cNPBqg==",
|
"integrity": "sha512-Pub5JXPabY4YdraMLi43HW+Y94ZiZRZA+PXJUmpSPa+KBr/36hTZG55EJUEqlY+bGDdec0ctSWFJ5Hu1cNPBqg==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@_ueberdosis/prosemirror-tables": "^1.1.3",
|
"@_ueberdosis/prosemirror-tables": "^1.1.3",
|
||||||
|
|||||||
@@ -21,6 +21,6 @@
|
|||||||
"typescript": "^4.8.2"
|
"typescript": "^4.8.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@streetwriters/editor": "*"
|
"@notesnook/editor": "*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,9 +104,6 @@
|
|||||||
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
||||||
"postinstall": "patch-package"
|
"postinstall": "patch-package"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
|
||||||
"extends": "react-app"
|
|
||||||
},
|
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
"production": [
|
"production": [
|
||||||
">0.2%",
|
">0.2%",
|
||||||
|
|||||||
1
packages/editor-mobile/.env
Normal file
1
packages/editor-mobile/.env
Normal file
@@ -0,0 +1 @@
|
|||||||
|
SKIP_PREFLIGHT_CHECK=true
|
||||||
1
packages/editor-mobile/.gitignore
vendored
1
packages/editor-mobile/.gitignore
vendored
@@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
# production
|
# production
|
||||||
/build
|
/build
|
||||||
|
/build.bundle
|
||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
# Getting Started with Create React App
|
|
||||||
|
|
||||||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
||||||
|
|
||||||
## Available Scripts
|
|
||||||
|
|
||||||
In the project directory, you can run:
|
|
||||||
|
|
||||||
### `npm start`
|
|
||||||
|
|
||||||
Runs the app in the development mode.\
|
|
||||||
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
|
|
||||||
|
|
||||||
The page will reload if you make edits.\
|
|
||||||
You will also see any lint errors in the console.
|
|
||||||
|
|
||||||
### `npm test`
|
|
||||||
|
|
||||||
Launches the test runner in the interactive watch mode.\
|
|
||||||
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
||||||
|
|
||||||
### `npm run build`
|
|
||||||
|
|
||||||
Builds the app for production to the `build` folder.\
|
|
||||||
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
||||||
|
|
||||||
The build is minified and the filenames include the hashes.\
|
|
||||||
Your app is ready to be deployed!
|
|
||||||
|
|
||||||
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
||||||
|
|
||||||
### `npm run eject`
|
|
||||||
|
|
||||||
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
|
|
||||||
|
|
||||||
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
||||||
|
|
||||||
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
|
|
||||||
|
|
||||||
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
|
|
||||||
|
|
||||||
## Learn More
|
|
||||||
|
|
||||||
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
||||||
|
|
||||||
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
||||||
|
|
||||||
### Code Splitting
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
|
||||||
|
|
||||||
### Analyzing the Bundle Size
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
|
||||||
|
|
||||||
### Making a Progressive Web App
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
|
||||||
|
|
||||||
### Advanced Configuration
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
|
||||||
|
|
||||||
### Deployment
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
|
||||||
|
|
||||||
### `npm run build` fails to minify
|
|
||||||
|
|
||||||
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|
|
||||||
|
|||||||
11481
packages/editor-mobile/package-lock.json
generated
11481
packages/editor-mobile/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,28 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "tiptap",
|
"name": "@notesnook/editor-mobile",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@streetwriters/editor": "^1.3.1",
|
"@notesnook/editor": "*",
|
||||||
"@streetwriters/theme": "^1.0.1",
|
"@notesnook/theme": "*",
|
||||||
"framer-motion": "^4.1.17",
|
"framer-motion": "^4.1.17",
|
||||||
"mdi-react": "^8.4.0",
|
"mdi-react": "^8.4.0",
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.2",
|
||||||
"zustand": "^3.6.8"
|
"zustand": "^3.6.8"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
|
||||||
"@types/react": "^17.0.39",
|
|
||||||
"@types/react-dom": "^17.0.11"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@testing-library/jest-dom": "^5.16.0",
|
"@testing-library/jest-dom": "^5.16.0",
|
||||||
"@testing-library/react": "^11.2.7",
|
"@testing-library/react": "^11.2.7",
|
||||||
"@testing-library/user-event": "^12.8.3",
|
"@testing-library/user-event": "^12.8.3",
|
||||||
"@types/jest": "^27.0.3",
|
"@types/jest": "^27.0.3",
|
||||||
"@types/node": "^16.11.11",
|
"@types/node": "^16.11.11",
|
||||||
"@types/react": "^17.0.39",
|
"@types/react": "^17.0.2",
|
||||||
"@types/react-dom": "^17.0.11",
|
"@types/react-dom": "^17.0.2",
|
||||||
"patch-package": "^6.4.7",
|
"patch-package": "^6.4.7",
|
||||||
"react-error-overlay": "6.0.9",
|
"react-error-overlay": "6.0.9",
|
||||||
"react-scripts": "^4.0.3",
|
"react-scripts": "^4.0.3",
|
||||||
@@ -31,16 +27,9 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "BROWSER=none react-scripts start",
|
"start": "BROWSER=none react-scripts start",
|
||||||
"build": "GENERATE_SOURCEMAP=false react-scripts build && rm -rf ../clean/notesnook-mobile/web.bundle/ && mkdir ../clean/notesnook-mobile/web.bundle && cp -R ./build/* ../clean/notesnook-mobile/web.bundle/",
|
"build": "GENERATE_SOURCEMAP=false react-scripts build && mv build build.bundle",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject"
|
||||||
"postinstall": "patch-package"
|
|
||||||
},
|
|
||||||
"eslintConfig": {
|
|
||||||
"extends": [
|
|
||||||
"react-app",
|
|
||||||
"react-app/jest"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"homepage": ".",
|
"homepage": ".",
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
@@ -54,5 +43,14 @@
|
|||||||
"last 1 firefox version",
|
"last 1 firefox version",
|
||||||
"last 1 safari version"
|
"last 1 safari version"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"nx": {
|
||||||
|
"targets": {
|
||||||
|
"build": {
|
||||||
|
"outputs": [
|
||||||
|
"{projectRoot}/build.bundle"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
diff --git a/node_modules/@tiptap/core/dist/tiptap-core.esm.js b/node_modules/@tiptap/core/dist/tiptap-core.esm.js
|
|
||||||
index 3739b80..173171c 100644
|
|
||||||
--- a/node_modules/@tiptap/core/dist/tiptap-core.esm.js
|
|
||||||
+++ b/node_modules/@tiptap/core/dist/tiptap-core.esm.js
|
|
||||||
@@ -2768,8 +2768,7 @@ const Keymap = Extension.create({
|
|
||||||
new Plugin({
|
|
||||||
key: new PluginKey('clearDocument'),
|
|
||||||
appendTransaction: (transactions, oldState, newState) => {
|
|
||||||
- const docChanges = transactions.some(transaction => transaction.docChanged)
|
|
||||||
- && !oldState.doc.eq(newState.doc);
|
|
||||||
+ const docChanges = transactions.some(transaction => transaction.docChanged);
|
|
||||||
if (!docChanges) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
@@ -2777,10 +2776,11 @@ const Keymap = Extension.create({
|
|
||||||
const allFrom = Selection.atStart(oldState.doc).from;
|
|
||||||
const allEnd = Selection.atEnd(oldState.doc).to;
|
|
||||||
const allWasSelected = from === allFrom && to === allEnd;
|
|
||||||
- const isEmpty = newState.doc.textBetween(0, newState.doc.content.size, ' ', ' ').length === 0;
|
|
||||||
- if (empty || !allWasSelected || !isEmpty) {
|
|
||||||
+ if (empty || !allWasSelected) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
+ const isEmpty = newState.doc.textBetween(0, newState.doc.content.size, ' ', ' ').length === 0;
|
|
||||||
+ if (!isEmpty) return;
|
|
||||||
const tr = newState.tr;
|
|
||||||
const state = createChainableState({
|
|
||||||
state: newState,
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
diff --git a/node_modules/react-scripts/config/webpack.config.js b/node_modules/react-scripts/config/webpack.config.js
|
|
||||||
index 26c2a65..c534178 100644
|
|
||||||
--- a/node_modules/react-scripts/config/webpack.config.js
|
|
||||||
+++ b/node_modules/react-scripts/config/webpack.config.js
|
|
||||||
@@ -343,6 +343,8 @@ module.exports = function (webpackEnv) {
|
|
||||||
'react-dom$': 'react-dom/profiling',
|
|
||||||
'scheduler/tracing': 'scheduler/tracing-profiling',
|
|
||||||
}),
|
|
||||||
+ react: path.resolve(__dirname, '../../react'),
|
|
||||||
+ 'react-dom': path.resolve(__dirname, '../../react-dom'),
|
|
||||||
...(modules.webpackAliases || {}),
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { render, screen } from '@testing-library/react';
|
import { render, screen } from "@testing-library/react";
|
||||||
import App from './App';
|
import App from "./App";
|
||||||
|
|
||||||
test('renders learn react link', () => {
|
test("renders learn react link", () => {
|
||||||
render(<App />);
|
render(<App />);
|
||||||
const linkElement = screen.getByText(/learn react/i);
|
const linkElement = screen.getByText(/learn react/i);
|
||||||
expect(linkElement).toBeInTheDocument();
|
expect(linkElement).toBeInTheDocument();
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Editor } from "@streetwriters/editor";
|
import { Editor } from "@notesnook/editor";
|
||||||
|
|
||||||
type ButtonType = {
|
type ButtonType = {
|
||||||
editor: Editor | null;
|
editor: Editor | null;
|
||||||
@@ -13,7 +13,7 @@ export default function Button({
|
|||||||
title,
|
title,
|
||||||
onPress,
|
onPress,
|
||||||
marginRight = 10,
|
marginRight = 10,
|
||||||
activeKey,
|
activeKey
|
||||||
}: ButtonType) {
|
}: ButtonType) {
|
||||||
const active = editor?.isActive(activeKey);
|
const active = editor?.isActive(activeKey);
|
||||||
|
|
||||||
@@ -29,7 +29,7 @@ export default function Button({
|
|||||||
userSelect: "none",
|
userSelect: "none",
|
||||||
color: active ? "var(--nn_accent)" : "var(--nn_pri)",
|
color: active ? "var(--nn_accent)" : "var(--nn_pri)",
|
||||||
marginRight: marginRight,
|
marginRight: marginRight,
|
||||||
fontSize: 18,
|
fontSize: 18
|
||||||
}}
|
}}
|
||||||
onMouseUp={(e) => {
|
onMouseUp={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -3,16 +3,16 @@ import {
|
|||||||
PortalProvider,
|
PortalProvider,
|
||||||
Toolbar,
|
Toolbar,
|
||||||
usePermissionHandler,
|
usePermissionHandler,
|
||||||
useTiptap,
|
useTiptap
|
||||||
} from "@streetwriters/editor";
|
} from "@notesnook/editor";
|
||||||
import { Theme, useTheme } from "@streetwriters/theme";
|
import { Theme, useTheme } from "@notesnook/theme";
|
||||||
import {
|
import {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
memo,
|
memo,
|
||||||
useCallback,
|
useCallback,
|
||||||
useLayoutEffect,
|
useLayoutEffect,
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useEditorController } from "../hooks/useEditorController";
|
import { useEditorController } from "../hooks/useEditorController";
|
||||||
import { useSettings } from "../hooks/useSettings";
|
import { useSettings } from "../hooks/useSettings";
|
||||||
@@ -26,7 +26,7 @@ import Title from "./title";
|
|||||||
const Tiptap = ({
|
const Tiptap = ({
|
||||||
editorTheme,
|
editorTheme,
|
||||||
toolbarTheme,
|
toolbarTheme,
|
||||||
settings,
|
settings
|
||||||
}: {
|
}: {
|
||||||
editorTheme: Theme;
|
editorTheme: Theme;
|
||||||
toolbarTheme: Theme;
|
toolbarTheme: Theme;
|
||||||
@@ -38,11 +38,11 @@ const Tiptap = ({
|
|||||||
const [layout, setLayout] = useState(false);
|
const [layout, setLayout] = useState(false);
|
||||||
usePermissionHandler({
|
usePermissionHandler({
|
||||||
claims: {
|
claims: {
|
||||||
premium: settings.premium,
|
premium: settings.premium
|
||||||
},
|
},
|
||||||
onPermissionDenied: () => {
|
onPermissionDenied: () => {
|
||||||
post(EventTypes.pro);
|
post(EventTypes.pro);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
const _editor = useTiptap(
|
const _editor = useTiptap(
|
||||||
{
|
{
|
||||||
@@ -64,12 +64,12 @@ const Tiptap = ({
|
|||||||
element: !layout ? undefined : contentRef.current || undefined,
|
element: !layout ? undefined : contentRef.current || undefined,
|
||||||
editable: !settings.readonly,
|
editable: !settings.readonly,
|
||||||
editorProps: {
|
editorProps: {
|
||||||
editable: () => !settings.readonly,
|
editable: () => !settings.readonly
|
||||||
},
|
},
|
||||||
content: global.editorController?.content?.current,
|
content: global.editorController?.content?.current,
|
||||||
isMobile: true,
|
isMobile: true,
|
||||||
isKeyboardOpen: settings.keyboardShown,
|
isKeyboardOpen: settings.keyboardShown,
|
||||||
doubleSpacedLines: settings.doubleSpacedLines,
|
doubleSpacedLines: settings.doubleSpacedLines
|
||||||
},
|
},
|
||||||
[layout, settings.readonly, tick]
|
[layout, settings.readonly, tick]
|
||||||
);
|
);
|
||||||
@@ -97,7 +97,7 @@ const Tiptap = ({
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
maxWidth: "100vw",
|
maxWidth: "100vw",
|
||||||
marginBottom: "5px",
|
marginBottom: "5px"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Header
|
<Header
|
||||||
@@ -115,7 +115,7 @@ const Tiptap = ({
|
|||||||
height: "100%",
|
height: "100%",
|
||||||
flexGrow: 1,
|
flexGrow: 1,
|
||||||
flexShrink: 1,
|
flexShrink: 1,
|
||||||
display: "flex",
|
display: "flex"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{settings.noHeader ? null : (
|
{settings.noHeader ? null : (
|
||||||
@@ -143,7 +143,7 @@ const Tiptap = ({
|
|||||||
globalThis.editor
|
globalThis.editor
|
||||||
?.chain()
|
?.chain()
|
||||||
.insertContentAt(lastPosition - 1, "<p></p>", {
|
.insertContentAt(lastPosition - 1, "<p></p>", {
|
||||||
updateSelection: true,
|
updateSelection: true
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -153,7 +153,7 @@ const Tiptap = ({
|
|||||||
style={{
|
style={{
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
height: 150,
|
height: 150,
|
||||||
width: "100%",
|
width: "100%"
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -184,7 +184,7 @@ const ContentDiv = memo(
|
|||||||
flex: 1,
|
flex: 1,
|
||||||
color: theme.pri,
|
color: theme.pri,
|
||||||
marginTop: -12,
|
marginTop: -12,
|
||||||
caretColor: theme.accent,
|
caretColor: theme.accent
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
@@ -194,36 +194,35 @@ const ContentDiv = memo(
|
|||||||
|
|
||||||
const modifyToolbarTheme = (toolbarTheme: Theme) => {
|
const modifyToolbarTheme = (toolbarTheme: Theme) => {
|
||||||
toolbarTheme.space = [0, 10, 12, 18];
|
toolbarTheme.space = [0, 10, 12, 18];
|
||||||
//@ts-ignore
|
|
||||||
toolbarTheme.space.small = "10px";
|
toolbarTheme.space.small = "10px";
|
||||||
|
|
||||||
toolbarTheme.buttons.menuitem = {
|
toolbarTheme.buttons.menuitem = {
|
||||||
...toolbarTheme.buttons.menuitem,
|
...toolbarTheme.buttons.menuitem,
|
||||||
height: "50px",
|
height: "50px",
|
||||||
paddingX: "20px",
|
paddingX: "20px",
|
||||||
borderBottomWidth: 0,
|
borderBottomWidth: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
toolbarTheme.iconSizes = {
|
toolbarTheme.iconSizes = {
|
||||||
big: 20,
|
big: 20,
|
||||||
medium: 18,
|
medium: 18,
|
||||||
small: 18,
|
small: 18
|
||||||
};
|
};
|
||||||
toolbarTheme.fontSizes = {
|
toolbarTheme.fontSizes = {
|
||||||
...toolbarTheme.fontSizes,
|
...toolbarTheme.fontSizes,
|
||||||
subBody: "0.8rem",
|
subBody: "0.8rem",
|
||||||
body: "0.9rem",
|
body: "0.9rem"
|
||||||
};
|
};
|
||||||
|
|
||||||
toolbarTheme.radii = {
|
toolbarTheme.radii = {
|
||||||
...toolbarTheme.radii,
|
...toolbarTheme.radii,
|
||||||
small: 5,
|
small: 5
|
||||||
};
|
};
|
||||||
|
|
||||||
toolbarTheme.buttons.menuitem = {
|
toolbarTheme.buttons.menuitem = {
|
||||||
...toolbarTheme.buttons.menuitem,
|
...toolbarTheme.buttons.menuitem,
|
||||||
px: 5,
|
px: 5,
|
||||||
height: "45px",
|
height: "45px"
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -234,14 +233,14 @@ const TiptapProvider = () => {
|
|||||||
//todo
|
//todo
|
||||||
accent: theme?.accent,
|
accent: theme?.accent,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
theme: theme?.night ? "dark" : "light",
|
theme: theme?.night ? "dark" : "light"
|
||||||
});
|
});
|
||||||
modifyToolbarTheme(toolbarTheme);
|
modifyToolbarTheme(toolbarTheme);
|
||||||
const editorTheme = useTheme({
|
const editorTheme = useTheme({
|
||||||
//todo
|
//todo
|
||||||
accent: theme?.accent,
|
accent: theme?.accent,
|
||||||
scale: 1,
|
scale: 1,
|
||||||
theme: theme?.night ? "dark" : "light",
|
theme: theme?.night ? "dark" : "light"
|
||||||
});
|
});
|
||||||
editorTheme.colors.background = theme?.bg || "#f0f0f0";
|
editorTheme.colors.background = theme?.bg || "#f0f0f0";
|
||||||
editorTheme.space = [0, 10, 12, 20];
|
editorTheme.space = [0, 10, 12, 20];
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import React, { RefObject, useEffect, useRef, useState } from "react";
|
|||||||
function StatusBar({ container }: { container: RefObject<HTMLDivElement> }) {
|
function StatusBar({ container }: { container: RefObject<HTMLDivElement> }) {
|
||||||
const [status, setStatus] = useState({
|
const [status, setStatus] = useState({
|
||||||
date: "",
|
date: "",
|
||||||
saved: "",
|
saved: ""
|
||||||
});
|
});
|
||||||
const [sticky, setSticky] = useState(false);
|
const [sticky, setSticky] = useState(false);
|
||||||
const stickyRef = useRef(false);
|
const stickyRef = useRef(false);
|
||||||
@@ -13,13 +13,11 @@ function StatusBar({ container }: { container: RefObject<HTMLDivElement> }) {
|
|||||||
const currentWords = useRef(words);
|
const currentWords = useRef(words);
|
||||||
const interval = useRef(0);
|
const interval = useRef(0);
|
||||||
const statusBar = useRef({
|
const statusBar = useRef({
|
||||||
set: setStatus,
|
set: setStatus
|
||||||
});
|
});
|
||||||
//@ts-ignore
|
|
||||||
globalThis.statusBar = statusBar;
|
globalThis.statusBar = statusBar;
|
||||||
|
|
||||||
const onScroll = React.useCallback((event) => {
|
const onScroll = React.useCallback((event) => {
|
||||||
//@ts-ignore
|
|
||||||
const currentOffset = event.target.scrollTop;
|
const currentOffset = event.target.scrollTop;
|
||||||
if (currentOffset < 200) {
|
if (currentOffset < 200) {
|
||||||
if (stickyRef.current) {
|
if (stickyRef.current) {
|
||||||
@@ -48,12 +46,11 @@ function StatusBar({ container }: { container: RefObject<HTMLDivElement> }) {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
clearInterval(interval.current);
|
clearInterval(interval.current);
|
||||||
//@ts-ignore
|
|
||||||
interval.current = setInterval(() => {
|
interval.current = setInterval(() => {
|
||||||
const words = editor?.storage?.characterCount?.words() + " words";
|
const words = editor?.storage?.characterCount?.words() + " words";
|
||||||
if (currentWords.current === words) return;
|
if (currentWords.current === words) return;
|
||||||
setWords(words);
|
setWords(words);
|
||||||
}, 3000);
|
}, 3000) as unknown as number;
|
||||||
return () => {
|
return () => {
|
||||||
clearInterval(interval.current);
|
clearInterval(interval.current);
|
||||||
};
|
};
|
||||||
@@ -73,7 +70,7 @@ function StatusBar({ container }: { container: RefObject<HTMLDivElement> }) {
|
|||||||
fontSize: "12px",
|
fontSize: "12px",
|
||||||
color: "var(--nn_icon)",
|
color: "var(--nn_icon)",
|
||||||
marginRight: 8,
|
marginRight: 8,
|
||||||
paddingBottom: 0,
|
paddingBottom: 0
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -89,7 +86,7 @@ function StatusBar({ container }: { container: RefObject<HTMLDivElement> }) {
|
|||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
justifyContent: sticky ? "center" : "flex-start",
|
justifyContent: sticky ? "center" : "flex-start",
|
||||||
paddingTop: 2,
|
paddingTop: 2,
|
||||||
paddingBottom: 2,
|
paddingBottom: 2
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<p style={paragraphStyle}>{words}</p>
|
<p style={paragraphStyle}>{words}</p>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import styles from "./styles.module.css";
|
|||||||
export default function Tags() {
|
export default function Tags() {
|
||||||
const [tags, setTags] = useState<{ title: string; alias: string }[]>([]);
|
const [tags, setTags] = useState<{ title: string; alias: string }[]>([]);
|
||||||
const editorTags = useRef({
|
const editorTags = useRef({
|
||||||
setTags: setTags,
|
setTags: setTags
|
||||||
});
|
});
|
||||||
|
|
||||||
global.editorTags = editorTags;
|
global.editorTags = editorTags;
|
||||||
@@ -24,7 +24,7 @@ export default function Tags() {
|
|||||||
padding: "0px 12px",
|
padding: "0px 12px",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
marginTop: 10,
|
marginTop: 10
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<button
|
<button
|
||||||
@@ -47,7 +47,7 @@ export default function Tags() {
|
|||||||
fontFamily: "Open Sans",
|
fontFamily: "Open Sans",
|
||||||
display: "flex",
|
display: "flex",
|
||||||
alignItems: "center",
|
alignItems: "center",
|
||||||
height: "30px",
|
height: "30px"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{tags.length === 0 ? (
|
{tags.length === 0 ? (
|
||||||
@@ -56,7 +56,7 @@ export default function Tags() {
|
|||||||
marginRight: 4,
|
marginRight: 4,
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: "var(--nn_icon)",
|
color: "var(--nn_icon)",
|
||||||
userSelect: "none",
|
userSelect: "none"
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Add a tag
|
Add a tag
|
||||||
@@ -78,6 +78,7 @@ export default function Tags() {
|
|||||||
|
|
||||||
{tags.map((tag) => (
|
{tags.map((tag) => (
|
||||||
<button
|
<button
|
||||||
|
key={tag.title}
|
||||||
className={styles.btn}
|
className={styles.btn}
|
||||||
style={{
|
style={{
|
||||||
borderWidth: 0,
|
borderWidth: 0,
|
||||||
@@ -88,7 +89,7 @@ export default function Tags() {
|
|||||||
height: "30px",
|
height: "30px",
|
||||||
fontFamily: "Open Sans",
|
fontFamily: "Open Sans",
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
color: "var(--nn_icon)",
|
color: "var(--nn_icon)"
|
||||||
}}
|
}}
|
||||||
onMouseUp={(e) => {
|
onMouseUp={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Editor } from "@streetwriters/editor";
|
import { Editor } from "@notesnook/editor";
|
||||||
import {
|
import {
|
||||||
MutableRefObject,
|
MutableRefObject,
|
||||||
useCallback,
|
useCallback,
|
||||||
useEffect,
|
useEffect,
|
||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState
|
||||||
} from "react";
|
} from "react";
|
||||||
import { useEditorThemeStore } from "../state/theme";
|
import { useEditorThemeStore } from "../state/theme";
|
||||||
import { EventTypes, isReactNative, post } from "../utils";
|
import { EventTypes, isReactNative, post } from "../utils";
|
||||||
@@ -20,7 +20,7 @@ export type Selection = {
|
|||||||
[name: string]: {
|
[name: string]: {
|
||||||
text?: string;
|
text?: string;
|
||||||
length?: number;
|
length?: number;
|
||||||
attributes?: Record<string, any>;
|
attributes?: Record<string, unknown>;
|
||||||
type?: "mark" | "node";
|
type?: "mark" | "node";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -51,10 +51,10 @@ export function useEditorController(update: () => void): EditorController {
|
|||||||
const htmlContentRef = useRef<string | null>(null);
|
const htmlContentRef = useRef<string | null>(null);
|
||||||
const timers = useRef<Timers>({
|
const timers = useRef<Timers>({
|
||||||
selectionChange: null,
|
selectionChange: null,
|
||||||
change: null,
|
change: null
|
||||||
});
|
});
|
||||||
|
|
||||||
const selectionChange = useCallback((editor: Editor) => {}, []);
|
const selectionChange = useCallback((_editor: Editor) => {}, []);
|
||||||
|
|
||||||
const titleChange = useCallback((title: string) => {
|
const titleChange = useCallback((title: string) => {
|
||||||
post(EventTypes.title, title);
|
post(EventTypes.title, title);
|
||||||
@@ -72,10 +72,7 @@ export function useEditorController(update: () => void): EditorController {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const scroll = useCallback(
|
const scroll = useCallback(
|
||||||
(event: React.UIEvent<HTMLDivElement, UIEvent>) => {
|
(_event: React.UIEvent<HTMLDivElement, UIEvent>) => {},
|
||||||
//@ts-ignore
|
|
||||||
//post(EventTypes.scroll, event.target.scrollTop);
|
|
||||||
},
|
|
||||||
[]
|
[]
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -84,13 +81,12 @@ export function useEditorController(update: () => void): EditorController {
|
|||||||
}, [update]);
|
}, [update]);
|
||||||
|
|
||||||
const onMessage = useCallback(
|
const onMessage = useCallback(
|
||||||
(data: Event) => {
|
(event: Event & { data?: string }) => {
|
||||||
//@ts-ignore
|
if (event?.data?.[0] !== "{") return;
|
||||||
if (data?.data[0] !== "{") return;
|
|
||||||
//@ts-ignore
|
const message = JSON.parse(event.data);
|
||||||
let message = JSON.parse(data.data);
|
const type = message.type;
|
||||||
let type = message.type;
|
const value = message.value;
|
||||||
let value = message.value;
|
|
||||||
global.sessionId = message.sessionId;
|
global.sessionId = message.sessionId;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "native:html":
|
case "native:html":
|
||||||
@@ -118,10 +114,9 @@ export function useEditorController(update: () => void): EditorController {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isReactNative()) return; // Subscribe only in react native webview.
|
if (!isReactNative()) return; // Subscribe only in react native webview.
|
||||||
let isSafari = navigator.vendor.match(/apple/i);
|
const isSafari = navigator.vendor.match(/apple/i);
|
||||||
let root = document;
|
let root: Document | Window = document;
|
||||||
if (isSafari) {
|
if (isSafari) {
|
||||||
//@ts-ignore
|
|
||||||
root = window;
|
root = window;
|
||||||
}
|
}
|
||||||
console.log("recreating messaging");
|
console.log("recreating messaging");
|
||||||
@@ -152,6 +147,6 @@ export function useEditorController(update: () => void): EditorController {
|
|||||||
openFilePicker,
|
openFilePicker,
|
||||||
downloadAttachment,
|
downloadAttachment,
|
||||||
content: htmlContentRef,
|
content: htmlContentRef,
|
||||||
onUpdate: onUpdate,
|
onUpdate: onUpdate
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { getDefaultPresets } from "@streetwriters/editor";
|
import { getDefaultPresets } from "@notesnook/editor";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
const settingsJson = localStorage.getItem("editorSettings");
|
const settingsJson = localStorage.getItem("editorSettings");
|
||||||
@@ -10,7 +10,7 @@ const initialState = {
|
|||||||
noToolbar: globalThis.noToolbar,
|
noToolbar: globalThis.noToolbar,
|
||||||
noHeader: globalThis.noHeader,
|
noHeader: globalThis.noHeader,
|
||||||
readonly: globalThis.readonly,
|
readonly: globalThis.readonly,
|
||||||
doubleSpacedLines: true,
|
doubleSpacedLines: true
|
||||||
};
|
};
|
||||||
|
|
||||||
global.settingsController = {
|
global.settingsController = {
|
||||||
@@ -19,7 +19,7 @@ global.settingsController = {
|
|||||||
...settings,
|
...settings,
|
||||||
noToolbar: globalThis.noToolbar || settings.noToolbar,
|
noToolbar: globalThis.noToolbar || settings.noToolbar,
|
||||||
noHeader: globalThis.noHeader || settings.noHeader,
|
noHeader: globalThis.noHeader || settings.noHeader,
|
||||||
readonly: globalThis.readonly || settings.readonly,
|
readonly: globalThis.readonly || settings.readonly
|
||||||
};
|
};
|
||||||
if (
|
if (
|
||||||
JSON.stringify(nextSettings) ===
|
JSON.stringify(nextSettings) ===
|
||||||
@@ -36,7 +36,7 @@ global.settingsController = {
|
|||||||
}
|
}
|
||||||
settingsController.previous = { ...nextSettings };
|
settingsController.previous = { ...nextSettings };
|
||||||
},
|
},
|
||||||
previous: settingsJson ? JSON.parse(settingsJson) : { ...initialState },
|
previous: settingsJson ? JSON.parse(settingsJson) : { ...initialState }
|
||||||
};
|
};
|
||||||
global.settingsController.previous.noHeader = globalThis.noHeader;
|
global.settingsController.previous.noHeader = globalThis.noHeader;
|
||||||
global.settingsController.previous.noToolbar = globalThis.noToolbar;
|
global.settingsController.previous.noToolbar = globalThis.noToolbar;
|
||||||
@@ -44,7 +44,7 @@ global.settingsController.previous.readonly = globalThis.readonly;
|
|||||||
|
|
||||||
export const useSettings = () => {
|
export const useSettings = () => {
|
||||||
const [settings, setSettings] = useState({
|
const [settings, setSettings] = useState({
|
||||||
...global.settingsController.previous,
|
...global.settingsController.previous
|
||||||
});
|
});
|
||||||
global.settingsController.set = setSettings;
|
global.settingsController.set = setSettings;
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,11 @@ import React from "react";
|
|||||||
import ReactDOM from "react-dom";
|
import ReactDOM from "react-dom";
|
||||||
import "./index.css";
|
import "./index.css";
|
||||||
import App from "./App";
|
import App from "./App";
|
||||||
import reportWebVitals from "./reportWebVitals";
|
import "@notesnook/editor/styles/katex.min.css";
|
||||||
import "@streetwriters/editor/styles/katex.min.css";
|
import "@notesnook/editor/styles/prism-theme.css";
|
||||||
import "@streetwriters/editor/styles/prism-theme.css";
|
import "@notesnook/editor/styles/fonts.mobile.css";
|
||||||
import "@streetwriters/editor/styles/fonts.mobile.css";
|
import "@notesnook/editor/styles/katex-fonts.mobile.css";
|
||||||
import "@streetwriters/editor/styles/katexfonts.mobile.css";
|
import "@notesnook/editor/styles/styles.css";
|
||||||
import "@streetwriters/editor/styles/styles.css";
|
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
@@ -15,8 +14,3 @@ ReactDOM.render(
|
|||||||
</React.StrictMode>,
|
</React.StrictMode>,
|
||||||
document.getElementById("root")
|
document.getElementById("root")
|
||||||
);
|
);
|
||||||
|
|
||||||
// If you want to start measuring performance in your app, pass a function
|
|
||||||
// to log results (for example: reportWebVitals(console.log))
|
|
||||||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
||||||
reportWebVitals();
|
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
const reportWebVitals = onPerfEntry => {
|
|
||||||
if (onPerfEntry && onPerfEntry instanceof Function) {
|
|
||||||
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
|
|
||||||
getCLS(onPerfEntry);
|
|
||||||
getFID(onPerfEntry);
|
|
||||||
getFCP(onPerfEntry);
|
|
||||||
getLCP(onPerfEntry);
|
|
||||||
getTTFB(onPerfEntry);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
export default reportWebVitals;
|
|
||||||
@@ -2,4 +2,4 @@
|
|||||||
// allows you to do things like:
|
// allows you to do things like:
|
||||||
// expect(element).toHaveTextContent(/react/i)
|
// expect(element).toHaveTextContent(/react/i)
|
||||||
// learn more: https://github.com/testing-library/jest-dom
|
// learn more: https://github.com/testing-library/jest-dom
|
||||||
import '@testing-library/jest-dom';
|
import "@testing-library/jest-dom";
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ const DefaultColors = {
|
|||||||
input: "transparent",
|
input: "transparent",
|
||||||
heading: "#212121",
|
heading: "#212121",
|
||||||
border: "#E8E8E8",
|
border: "#E8E8E8",
|
||||||
placeholder: "#a9a9a9",
|
placeholder: "#a9a9a9"
|
||||||
};
|
};
|
||||||
|
|
||||||
injectCss(transform(DefaultColors));
|
injectCss(transform(DefaultColors));
|
||||||
@@ -72,10 +72,10 @@ interface ThemeState extends State {
|
|||||||
setColors: (colors: Colors) => void;
|
setColors: (colors: Colors) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useEditorThemeStore = create<ThemeState>((set, get) => ({
|
export const useEditorThemeStore = create<ThemeState>((set) => ({
|
||||||
colors: DefaultColors,
|
colors: DefaultColors,
|
||||||
setColors: (colors) => {
|
setColors: (colors) => {
|
||||||
injectCss(transform(colors));
|
injectCss(transform(colors));
|
||||||
set({ colors: colors });
|
set({ colors: colors });
|
||||||
},
|
}
|
||||||
}));
|
}));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { ToolbarGroupDefinition } from "@streetwriters/editor";
|
import { ToolbarGroupDefinition } from "@notesnook/editor";
|
||||||
import { Editor } from "@streetwriters/editor";
|
import { Editor } from "@notesnook/editor";
|
||||||
import { Dispatch, MutableRefObject, RefObject, SetStateAction } from "react";
|
import { Dispatch, MutableRefObject, RefObject, SetStateAction } from "react";
|
||||||
import { useEditorController } from "../hooks/useEditorController";
|
import { useEditorController } from "../hooks/useEditorController";
|
||||||
|
|
||||||
@@ -22,7 +22,16 @@ export type Settings = {
|
|||||||
doubleSpacedLines?: boolean;
|
doubleSpacedLines?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* eslint-disable no-var */
|
||||||
declare global {
|
declare global {
|
||||||
|
var statusBar: React.MutableRefObject<{
|
||||||
|
set: React.Dispatch<
|
||||||
|
React.SetStateAction<{
|
||||||
|
date: string;
|
||||||
|
saved: string;
|
||||||
|
}>
|
||||||
|
>;
|
||||||
|
}>;
|
||||||
var readonly: boolean;
|
var readonly: boolean;
|
||||||
var noToolbar: boolean;
|
var noToolbar: boolean;
|
||||||
var noHeader: boolean;
|
var noHeader: boolean;
|
||||||
@@ -76,14 +85,17 @@ declare global {
|
|||||||
>;
|
>;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
function logger(type: "info" | "warn" | "error", ...logs: any[]): void;
|
function logger(type: "info" | "warn" | "error", ...logs: never[]): void;
|
||||||
/**
|
/**
|
||||||
* Function to post message to react native
|
* Function to post message to react native
|
||||||
* @param type
|
* @param type
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function post(type: string, value?: unknown): void;
|
function post<T extends keyof typeof EventTypes>(
|
||||||
|
type: typeof EventTypes[T],
|
||||||
|
value?: unknown
|
||||||
|
): void;
|
||||||
interface Window {
|
interface Window {
|
||||||
/**
|
/**
|
||||||
* React Native WebView
|
* React Native WebView
|
||||||
@@ -93,11 +105,7 @@ declare global {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* eslint-enable no-var */
|
||||||
export const timerFn = (callback: () => void, duration: number) => {
|
|
||||||
// timer = setTimeout(callback, duration);
|
|
||||||
// return timer;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const EventTypes = {
|
export const EventTypes = {
|
||||||
selection: "editor-event:selection",
|
selection: "editor-event:selection",
|
||||||
@@ -114,15 +122,15 @@ export const EventTypes = {
|
|||||||
pro: "editor-event:pro",
|
pro: "editor-event:pro",
|
||||||
monograph: "editor-event:monograph",
|
monograph: "editor-event:monograph",
|
||||||
properties: "editor-event:properties",
|
properties: "editor-event:properties",
|
||||||
fullscreen: "editor-event:fullscreen",
|
fullscreen: "editor-event:fullscreen"
|
||||||
};
|
} as const;
|
||||||
|
|
||||||
export function isReactNative(): boolean {
|
export function isReactNative(): boolean {
|
||||||
return !!window.ReactNativeWebView;
|
return !!window.ReactNativeWebView;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logger(type: "info" | "warn" | "error", ...logs: any[]) {
|
export function logger(type: "info" | "warn" | "error", ...logs: never[]) {
|
||||||
let logString = logs
|
const logString = logs
|
||||||
.map((log) => {
|
.map((log) => {
|
||||||
return typeof log !== "string" ? JSON.stringify(log) : log;
|
return typeof log !== "string" ? JSON.stringify(log) : log;
|
||||||
})
|
})
|
||||||
@@ -131,19 +139,22 @@ export function logger(type: "info" | "warn" | "error", ...logs: any[]) {
|
|||||||
post(EventTypes.logger, `[${type}]: ` + logString);
|
post(EventTypes.logger, `[${type}]: ` + logString);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function post(type: string, value?: unknown) {
|
export function post<T extends keyof typeof EventTypes>(
|
||||||
|
type: typeof EventTypes[T],
|
||||||
|
value?: unknown
|
||||||
|
) {
|
||||||
if (isReactNative()) {
|
if (isReactNative()) {
|
||||||
window.ReactNativeWebView.postMessage(
|
window.ReactNativeWebView.postMessage(
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
//@ts-ignore
|
type,
|
||||||
type: EventTypes[type] || type,
|
|
||||||
value: value,
|
value: value,
|
||||||
sessionId: global.sessionId,
|
sessionId: globalThis.sessionId
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log(type, value);
|
console.log(type, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
globalThis.logger = logger;
|
globalThis.logger = logger;
|
||||||
globalThis.post = post;
|
globalThis.post = post;
|
||||||
|
|||||||
@@ -1,26 +1,19 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://json.schemastore.org/tsconfig",
|
"$schema": "https://json.schemastore.org/tsconfig",
|
||||||
"display": "tiptap editor",
|
"extends": "../../tsconfig",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"lib": ["dom", "dom.iterable", "esnext"],
|
"lib": [
|
||||||
"module": "esnext",
|
"dom",
|
||||||
"target": "es5",
|
"dom.iterable",
|
||||||
"allowJs": true,
|
"esnext"
|
||||||
"allowSyntheticDefaultImports": true,
|
],
|
||||||
"esModuleInterop": true,
|
|
||||||
"forceConsistentCasingInFileNames": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
"jsx": "react-jsx",
|
"jsx": "react-jsx",
|
||||||
"moduleResolution": "node",
|
|
||||||
"noEmit": true,
|
"noEmit": true,
|
||||||
"noFallthroughCasesInSwitch": true,
|
|
||||||
"resolveJsonModule": true,
|
|
||||||
"skipLibCheck": true,
|
|
||||||
"strict": true,
|
|
||||||
"outDir": "../notesnook-mobile/web.bundle",
|
|
||||||
"downlevelIteration": true,
|
"downlevelIteration": true,
|
||||||
"maxNodeModuleJsDepth": 5
|
"maxNodeModuleJsDepth": 5,
|
||||||
|
"allowJs": true
|
||||||
},
|
},
|
||||||
"include": ["src/"],
|
"include": [
|
||||||
"exclude": ["src/notesnook-editor/"]
|
"src/"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { ThemeConfig } from "./types";
|
|||||||
|
|
||||||
export type Theme = {
|
export type Theme = {
|
||||||
breakpoints: string[];
|
breakpoints: string[];
|
||||||
space: number[] & { small?: number };
|
space: number[] & { small?: number | string };
|
||||||
sizes: { full: "100%"; half: "50%" };
|
sizes: { full: "100%"; half: "50%" };
|
||||||
radii: {
|
radii: {
|
||||||
none: number;
|
none: number;
|
||||||
@@ -41,13 +41,13 @@ class ThemeFactory {
|
|||||||
shadows:
|
shadows:
|
||||||
config.theme === "dark"
|
config.theme === "dark"
|
||||||
? {
|
? {
|
||||||
menu: "0px 0px 10px 0px #00000078",
|
menu: "0px 0px 10px 0px #00000078"
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
menu: "0px 0px 10px 0px #00000022",
|
menu: "0px 0px 10px 0px #00000022"
|
||||||
},
|
},
|
||||||
...getFontConfig(config.scale),
|
...getFontConfig(config.scale),
|
||||||
...variants,
|
...variants
|
||||||
};
|
};
|
||||||
theme.space.small = 3;
|
theme.space.small = 3;
|
||||||
return theme;
|
return theme;
|
||||||
|
|||||||
Reference in New Issue
Block a user