Skip to content

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

feat: doubleSpacedLines

ammarahm-edddabf99811da
diff --git a/packages/editor-mobile/package-lock.json b/packages/editor-mobile/package-lock.json
index f6d5707fc..3c29471e5 100644
--- a/packages/editor-mobile/package-lock.json
+++ b/packages/editor-mobile/package-lock.json
@@ -9,7 +9,7 @@
"version": "1.0.0",
"hasInstallScript": true,
"dependencies": {
- "@streetwriters/editor": "^1.1.4",
+ "@streetwriters/editor": "^1.2.3",
"@streetwriters/theme": "^1.0.1",
"framer-motion": "^4.1.17",
"mdi-react": "^8.4.0",
@@ -2971,9 +2971,10 @@
"integrity": "sha512-CUqgq2PTmdmWhNPzth9JN1cFoaFsIWhgiuDVD23hjD+9HJVD+xs3GlbZF+YWYMKVhRa3hib4A7Ev8rOjz2QBwQ=="
},
"node_modules/@streetwriters/editor": {
- "version": "1.1.4",
- "resolved": "https://npm.pkg.github.com/download/@streetwriters/editor/1.1.4/433e9624150d9758fefc5d7f7bd10aab062b7de199f02e655852dd7b2b4ebb66",
- "integrity": "sha512-Va8mFBex7WYfI0pHprxw0n/xX9WJR+jWTfFGGycw8q+WfzvUIdZ/Qj02AvhZ5nu6sgimbVsbHbbHelq5z/BxYQ==",
+ "version": "1.2.3",
+ "resolved": "https://npm.pkg.github.com/download/@streetwriters/editor/1.2.3/3dd3215d873bc14358e2999baeab3687987a96f85200fb21d7a28ee6729375ac",
+ "integrity": "sha512-AuifKA+yMk8BRsSykul0bph0V64yWSXzO5O3bIpn+9e47ho4Vj7S/8pBYlr6qfNNO7yxJlxwLNcqj4sYJa4xjw==",
+ "hasInstallScript": true,
"license": "GPL-3.0",
"dependencies": {
"@_ueberdosis/prosemirror-tables": "^1.1.3",
@@ -3019,7 +3020,9 @@
"zustand": "^3.7.2"
},
"peerDependencies": {
- "framer-motion": "^4.1.17"
+ "framer-motion": "^4.1.17",
+ "react": "^17.0.2",
+ "react-dom": "^17.0.2"
}
},
"node_modules/@streetwriters/editor/node_modules/indent-string": {
@@ -25749,9 +25752,9 @@
"integrity": "sha512-CUqgq2PTmdmWhNPzth9JN1cFoaFsIWhgiuDVD23hjD+9HJVD+xs3GlbZF+YWYMKVhRa3hib4A7Ev8rOjz2QBwQ=="
},
"@streetwriters/editor": {
- "version": "1.1.4",
- "resolved": "https://npm.pkg.github.com/download/@streetwriters/editor/1.1.4/433e9624150d9758fefc5d7f7bd10aab062b7de199f02e655852dd7b2b4ebb66",
- "integrity": "sha512-Va8mFBex7WYfI0pHprxw0n/xX9WJR+jWTfFGGycw8q+WfzvUIdZ/Qj02AvhZ5nu6sgimbVsbHbbHelq5z/BxYQ==",
+ "version": "1.2.3",
+ "resolved": "https://npm.pkg.github.com/download/@streetwriters/editor/1.2.3/3dd3215d873bc14358e2999baeab3687987a96f85200fb21d7a28ee6729375ac",
+ "integrity": "sha512-AuifKA+yMk8BRsSykul0bph0V64yWSXzO5O3bIpn+9e47ho4Vj7S/8pBYlr6qfNNO7yxJlxwLNcqj4sYJa4xjw==",
"requires": {
"@_ueberdosis/prosemirror-tables": "^1.1.3",
"@mdi/js": "^6.9.96",
diff --git a/packages/editor-mobile/package.json b/packages/editor-mobile/package.json
index ccf8b4e1b..5f94166b7 100644
--- a/packages/editor-mobile/package.json
+++ b/packages/editor-mobile/package.json
@@ -3,7 +3,7 @@
"version": "1.0.0",
"private": true,
"dependencies": {
- "@streetwriters/editor": "^1.1.4",
+ "@streetwriters/editor": "^1.2.3",
"@streetwriters/theme": "^1.0.1",
"framer-motion": "^4.1.17",
"mdi-react": "^8.4.0",
diff --git a/packages/editor-mobile/patches/@tiptap+core+2.0.0-beta.181.patch b/packages/editor-mobile/patches/@tiptap+core+2.0.0-beta.181.patch
new file mode 100644
index 000000000..3d926c03f
--- /dev/null
+++ b/packages/editor-mobile/patches/@tiptap+core+2.0.0-beta.181.patch
@@ -0,0 +1,28 @@
+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,
\ No newline at end of file
diff --git a/packages/editor-mobile/scripts/build.sh b/packages/editor-mobile/scripts/build.sh
new file mode 100755
index 000000000..e69de29bb
diff --git a/packages/editor-mobile/src/components/editor.tsx b/packages/editor-mobile/src/components/editor.tsx
index a309e5edb..f7185be2e 100644
--- a/packages/editor-mobile/src/components/editor.tsx
+++ b/packages/editor-mobile/src/components/editor.tsx
@@ -69,12 +69,14 @@ const Tiptap = ({
content: global.editorController?.content?.current,
isMobile: true,
isKeyboardOpen: settings.keyboardShown,
+ doubleSpacedLines: settings.doubleSpacedLines,
},
[layout, settings.readonly, tick]
);
const update = useCallback(() => {
setTick((tick) => tick + 1);
+
globalThis.editorController.setTitlePlaceholder("Note title");
}, []);
@@ -129,7 +131,10 @@ const Tiptap = ({
</>
)}
- <ContentDiv ref={contentRef} />
+ <ContentDiv
+ padding={settings.doubleSpacedLines ? 0 : 6}
+ ref={contentRef}
+ />
<div
onDoubleClick={() => {
@@ -137,13 +142,19 @@ const Tiptap = ({
if (!lastPosition) return;
globalThis.editor
?.chain()
- .focus()
.insertContentAt(lastPosition - 1, "<p></p>", {
updateSelection: true,
})
.run();
+ setTimeout(() => {
+ globalThis.editor?.commands.focus();
+ }, 1);
+ }}
+ style={{
+ flexShrink: 0,
+ height: 150,
+ width: "100%",
}}
- style={{ flexShrink: 0, height: 150, width: "100%" }}
/>
</div>
@@ -162,14 +173,14 @@ const Tiptap = ({
};
const ContentDiv = memo(
- forwardRef<HTMLDivElement>((props, ref) => {
+ forwardRef<HTMLDivElement, { padding: number }>((props, ref) => {
const theme = useEditorThemeStore((state) => state.colors);
return (
<div
ref={ref}
style={{
padding: 12,
- paddingTop: 0,
+ paddingTop: props.padding,
flex: 1,
color: theme.pri,
marginTop: -12,
diff --git a/packages/editor-mobile/src/components/title.tsx b/packages/editor-mobile/src/components/title.tsx
index a278b0224..61bb134d5 100644
--- a/packages/editor-mobile/src/components/title.tsx
+++ b/packages/editor-mobile/src/components/title.tsx
@@ -44,6 +44,7 @@ function Title({
backgroundColor: "transparent",
color: "var(--nn_heading)",
}}
+ maxLength={150}
onChange={(event) => {
if (!emitUpdate.current) return;
controller.current?.titleChange(event.target.value);
diff --git a/packages/editor-mobile/src/hooks/useSettings.ts b/packages/editor-mobile/src/hooks/useSettings.ts
index 025356cd8..6e7c89f4d 100644
--- a/packages/editor-mobile/src/hooks/useSettings.ts
+++ b/packages/editor-mobile/src/hooks/useSettings.ts
@@ -10,6 +10,7 @@ const initialState = {
noToolbar: global.noToolbar,
noHeader: global.noHeader,
readonly: global.readonly,
+ doubleSpacedLines: true,
};
global.settingsController = {
diff --git a/packages/editor-mobile/src/utils/index.ts b/packages/editor-mobile/src/utils/index.ts
index 17b9205fb..5959106fa 100644
--- a/packages/editor-mobile/src/utils/index.ts
+++ b/packages/editor-mobile/src/utils/index.ts
@@ -19,6 +19,7 @@ export type Settings = {
noToolbar?: boolean;
noHeader?: boolean;
keyboardShown?: boolean;
+ doubleSpacedLines?: boolean;
};
declare global {