Skip to content

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

feat: sticky toolbar

thecodrr55fbd1972330
diff --git a/apps/web/package.json b/apps/web/package.json
index 997c7852b..0155d7b88 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -12,7 +12,7 @@
"@mdi/js": "^5.9.55",
"@mdi/react": "^1.4.0",
"@rebass/forms": "^4.0.6",
- "@tinymce/tinymce-react": "^3.10.2",
+ "@tinymce/tinymce-react": "^3.12.6",
"clipboard": "^2.0.6",
"cogo-toast": "^4.2.3",
"compressorjs": "^1.0.7",
@@ -44,7 +44,7 @@
"react-window": "^1.8.6",
"rebass": "^4.0.7",
"timeago-react": "^3.0.2",
- "tinymce": "^5.7.0",
+ "tinymce": "5.8.1",
"uzip": "^0.20201231.0",
"wouter": "^2.7.3",
"zustand": "^3.3.1"
diff --git a/apps/web/src/components/editor/editor.css b/apps/web/src/components/editor/editor.css
index 08135558f..731afb4ca 100644
--- a/apps/web/src/components/editor/editor.css
+++ b/apps/web/src/components/editor/editor.css
@@ -69,3 +69,7 @@ tox-tbtn tox-tbtn--select {
background: none !important;
border-bottom: 1px solid var(--border) !important;
}
+
+.mce-content-body:focus-visible {
+ outline: none;
+}
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.js
index 3525ad179..939513f0a 100644
--- a/apps/web/src/components/editor/index.js
+++ b/apps/web/src/components/editor/index.js
@@ -124,27 +124,39 @@ function Editor({ noteId, nonce }) {
mt={[0, 0, 25]}
>
<Header />
+ <Flex
+ id="editorToolbar"
+ sx={{
+ bg: "background",
+ position: "sticky",
+ top: 0,
+ zIndex: 999,
+ boxShadow: "0px 0px 15px 0px #0000002e",
+ }}
+ />
<Suspense fallback={<EditorLoading />}>
{contentType === "tiny" ? (
- <ReactMCE
- editorRef={editorRef}
- onFocus={() => toggleProperties(false)}
- onSave={saveSession}
- onChange={(content) => {
- if (!content.length) content = "<p><br></pr>";
- setSession((state) => {
- state.session.content = {
- type: "tiny",
- data: content,
- };
- });
- }}
- changeInterval={500}
- onWordCountChanged={updateWordCount}
- onInit={async () => {
- await startSession(noteId);
- }}
- />
+ <>
+ <ReactMCE
+ editorRef={editorRef}
+ onFocus={() => toggleProperties(false)}
+ onSave={saveSession}
+ onChange={(content) => {
+ if (!content.length) content = "<p><br></pr>";
+ setSession((state) => {
+ state.session.content = {
+ type: "tiny",
+ data: content,
+ };
+ });
+ }}
+ changeInterval={500}
+ onWordCountChanged={updateWordCount}
+ onInit={async () => {
+ await startSession(noteId);
+ }}
+ />
+ </>
) : null}
</Suspense>
</Animated.Flex>
diff --git a/apps/web/src/components/editor/tinymce.js b/apps/web/src/components/editor/tinymce.js
index 931e3ddae..59764c8c4 100644
--- a/apps/web/src/components/editor/tinymce.js
+++ b/apps/web/src/components/editor/tinymce.js
@@ -120,20 +120,20 @@ function TinyMCE(props) {
const [oldSkin, newSkin] = useSkin();
const tinymceRef = editorRef;
useEffect(() => {
- if (tinymceRef.current.editor.initialized) {
- tinymceRef.current.editor.dom.styleSheetLoader.unload(
- `${oldSkin}/content.min.css`
- );
- tinymceRef.current.editor.ui.styleSheetLoader.unload(
- `${oldSkin}/skin.min.css`
- );
- tinymceRef.current.editor.dom.styleSheetLoader.load(
- `${newSkin}/content.min.css`
- );
- tinymceRef.current.editor.ui.styleSheetLoader.load(
- `${newSkin}/skin.min.css`
- );
- }
+ // if (tinymceRef.current.editor.initialized) {
+ tinymceRef.current.editor.dom.styleSheetLoader.unload(
+ `${oldSkin}/content.min.css`
+ );
+ tinymceRef.current.editor.ui.styleSheetLoader.unload(
+ `${oldSkin}/skin.min.css`
+ );
+ tinymceRef.current.editor.dom.styleSheetLoader.load(
+ `${newSkin}/content.min.css`
+ );
+ tinymceRef.current.editor.ui.styleSheetLoader.load(
+ `${newSkin}/skin.min.css`
+ );
+ // }
}, [tinymceRef, newSkin, oldSkin]);
return (
@@ -153,16 +153,8 @@ function TinyMCE(props) {
contextmenu: false,
quickbars_insert_toolbar: false,
skin_url: newSkin,
- content_css: newSkin,
+ // content_css: "",
content_style: `
- span.diff-del {
- background-color: #FDB0C0;
- }
-
- span.diff-ins {
- background-color: #CAFFFB;
- }
-
pre.codeblock {
overflow-x: auto;
}
@@ -213,9 +205,13 @@ function TinyMCE(props) {
});
});
},
+ toolbar_persist: true,
browser_spellcheck: true,
autoresize_bottom_margin: 100,
+ fixed_toolbar_container_target:
+ document.getElementById("editorToolbar"),
}}
+ inline
onBeforeExecCommand={async (command) => {
if (
premiumCommands.some(
diff --git a/apps/web/yarn.lock b/apps/web/yarn.lock
index b537a93a8..548437074 100644
--- a/apps/web/yarn.lock
+++ b/apps/web/yarn.lock
@@ -1971,13 +1971,13 @@
dependencies:
defer-to-connect "^1.0.1"
-"@tinymce/tinymce-react@^3.10.2":
- version "3.10.2"
- resolved "https://registry.npmjs.org/@tinymce/tinymce-react/-/tinymce-react-3.10.2.tgz"
- integrity sha512-PcCGYuepfTidkNwSaTyEg5nVRrqQa9KJDBiCrfb7xRCkoNXeYKY4lFhnT84AcBe9BEcJ4HnCXoqCTnjOaF/R2w==
+"@tinymce/tinymce-react@^3.12.6":
+ version "3.12.6"
+ resolved "https://registry.yarnpkg.com/@tinymce/tinymce-react/-/tinymce-react-3.12.6.tgz#8a4e2a5c5026b7a0c9c4c839af4d691804aa0604"
+ integrity sha512-a7/Ns7uVsSr2N0fCxn+OhDx8f9JqfywTlHbXsgcwlWB6vIBMIjjRBJ6PGo/5H0y2vfzO6fBzd4gc6h05Cm5R7A==
dependencies:
prop-types "^15.6.2"
- tinymce "^5.7.0"
+ tinymce "^5.5.1"
"@types/anymatch@*":
version "1.3.1"
@@ -12843,10 +12843,10 @@ tiny-emitter@^2.0.0:
resolved "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz"
integrity sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==
-tinymce@^5.7.0:
- version "5.7.0"
- resolved "https://registry.npmjs.org/tinymce/-/tinymce-5.7.0.tgz"
- integrity sha512-WikgMpJbqYPaucV3lfstCj+Y4NquZlK61gyuJ2eqDUBlSU+4fFh6rpwnelVTxuvtEyJsAVOl8HZmbzBfDJiLsQ==
[email protected], tinymce@^5.5.1:
+ version "5.8.1"
+ resolved "https://registry.yarnpkg.com/tinymce/-/tinymce-5.8.1.tgz#f6ace70e47cf6b5b0a63f52cf38e4ae04a35ba58"
+ integrity sha512-1zGXdZplWQafstlC7sri0ttCgMagsiXDc9N3I8JNrPOsWAeTfq4AAJWZoxsQBYn8gYcuPu/WzMKG5SoJjxI1VA==
version "1.0.4"