Skip to content

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

add premium dialog for editor

ammarahm-ed12028f3266fb
diff --git a/apps/mobile/android/app/src/main/assets/texteditor.html b/apps/mobile/android/app/src/main/assets/texteditor.html
index a7ea344b6..a121c6e98 100644
--- a/apps/mobile/android/app/src/main/assets/texteditor.html
+++ b/apps/mobile/android/app/src/main/assets/texteditor.html
@@ -392,6 +392,46 @@
}
}
+
+
+ function moduleHandlerWrapper(type, premium) {
+ return async function (value) {
+ if (!premium) {
+ await window.ReactNativeWebView.postMessage(JSON.stringify({
+ type: "premium"
+ }));
+ return;
+ }
+ handlers[type].call(this, value);
+ };
+ }
+
+ const SnowTheme = Quill.import("themes/snow");
+ const Toolbar = Quill.import("modules/toolbar");
+
+ const handlers = {
+ ...Toolbar.DEFAULTS.handlers,
+ ...SnowTheme.DEFAULTS.modules.toolbar.handlers,
+ color: function (color) {
+ this.quill.format("color", color, "user");
+ },
+ background: function (color) {
+ this.quill.format("background", color, "user");
+ },
+ align: function (position) {
+ this.quill.format("align", position, "user");
+ },
+ "code-block": function (value) {
+ this.quill.format("code-block", value, "user");
+ },
+ size: function (value) {
+ this.quill.format("size", value, "user");
+ },
+ script: function (value) {
+ this.quill.format("script", value, "user");
+ },
+ };
+
function loadAction(premium, noMenu) {
setFonts();
Quill.register("modules/imageCompressor", imageCompressor);
@@ -400,7 +440,39 @@
editor = new Quill('#editor', {
modules: {
- toolbar: premium ? proToolbar : simpleToolbar,
+ toolbar: {
+ container: [
+ ["bold", "italic", "underline", "strike", "blockquote"],
+ [{ header: "2" }, { header: "3" }, { header: [false, 4, 5, 6] }],
+ [
+ { align: "" },
+ { align: "center" },
+ { align: "right" },
+ { align: "justify" },
+ ],
+ [{ list: "ordered" }, { list: "bullet" }, { list: "check" }],
+ [{ indent: "-1" }, { indent: "+1" }],
+ [{ size: ["small", false, "large", "huge"] }],
+ ["code-block", { script: "sub" }, { script: "super" }],
+ [{ color: [] }, { background: [] }],
+ ["link", "image", "video"],
+ [{ direction: "rtl" }, "clean"],
+ ],
+ handlers: {
+ list: moduleHandlerWrapper("list", premium),
+ indent: moduleHandlerWrapper("indent", premium),
+ direction: moduleHandlerWrapper("direction", premium),
+ image: moduleHandlerWrapper("image", premium),
+ video: moduleHandlerWrapper("video", premium),
+ formula: moduleHandlerWrapper("formula", premium),
+ color: moduleHandlerWrapper("formula", premium),
+ background: moduleHandlerWrapper("background", premium),
+ align: moduleHandlerWrapper("align", premium),
+ "code-block": moduleHandlerWrapper("code-block", premium),
+ size: moduleHandlerWrapper("size", premium),
+ script: moduleHandlerWrapper("script", premium),
+ },
+ },
imageCompressor: {
quality: 1,
maxWidth: 1024,
@@ -414,8 +486,8 @@
imageResize: {
displaySize: false,
},
- markdownShortcuts: premium? true : false,
- magicUrl:true
+ markdownShortcuts: premium,
+ magicUrl: true
},
placeholder: 'Start writing your note',
theme: 'snow',
@@ -430,11 +502,7 @@
setTheme();
attachEditorListeners();
fixDropdownMenuLocations();
-
-
-
}
- loadAction(true);
</script>
diff --git a/apps/mobile/html/Web.bundle/site/index.html b/apps/mobile/html/Web.bundle/site/index.html
index 0d570d6f0..60c449b62 100644
--- a/apps/mobile/html/Web.bundle/site/index.html
+++ b/apps/mobile/html/Web.bundle/site/index.html
@@ -390,6 +390,45 @@
}
+ function moduleHandlerWrapper(type, premium) {
+ return async function (value) {
+ if (!premium) {
+ await window.ReactNativeWebView.postMessage(JSON.stringify({
+ type: "premium"
+ }));
+ return;
+ }
+ handlers[type].call(this, value);
+ };
+ }
+
+ const SnowTheme = Quill.import("themes/snow");
+ const Toolbar = Quill.import("modules/toolbar");
+
+ const handlers = {
+ ...Toolbar.DEFAULTS.handlers,
+ ...SnowTheme.DEFAULTS.modules.toolbar.handlers,
+ color: function (color) {
+ this.quill.format("color", color, "user");
+ },
+ background: function (color) {
+ this.quill.format("background", color, "user");
+ },
+ align: function (position) {
+ this.quill.format("align", position, "user");
+ },
+ "code-block": function (value) {
+ this.quill.format("code-block", value, "user");
+ },
+ size: function (value) {
+ this.quill.format("size", value, "user");
+ },
+ script: function (value) {
+ this.quill.format("script", value, "user");
+ },
+ };
+
+
function loadAction(premium, noMenu) {
let titleIn = document.getElementById('titlebar');
titleIn.style['padding-left'] = 0;
@@ -404,7 +443,39 @@
editor = new Quill('#editor', {
modules: {
- toolbar: mainToolbar,
+ toolbar: {
+ container: [
+ ["bold", "italic", "underline", "strike", "blockquote"],
+ [{ header: "2" }, { header: "3" }, { header: [false, 4, 5, 6] }],
+ [
+ { align: "" },
+ { align: "center" },
+ { align: "right" },
+ { align: "justify" },
+ ],
+ [{ list: "ordered" }, { list: "bullet" }, { list: "check" }],
+ [{ indent: "-1" }, { indent: "+1" }],
+ [{ size: ["small", false, "large", "huge"] }],
+ ["code-block", { script: "sub" }, { script: "super" }],
+ [{ color: [] }, { background: [] }],
+ ["link", "image", "video"],
+ [{ direction: "rtl" }, "clean"],
+ ],
+ handlers: {
+ list: moduleHandlerWrapper("list", premium),
+ indent: moduleHandlerWrapper("indent", premium),
+ direction: moduleHandlerWrapper("direction", premium),
+ image: moduleHandlerWrapper("image", premium),
+ video: moduleHandlerWrapper("video", premium),
+ formula: moduleHandlerWrapper("formula", premium),
+ color: moduleHandlerWrapper("formula", premium),
+ background: moduleHandlerWrapper("background", premium),
+ align: moduleHandlerWrapper("align", premium),
+ "code-block": moduleHandlerWrapper("code-block", premium),
+ size: moduleHandlerWrapper("size", premium),
+ script: moduleHandlerWrapper("script", premium),
+ },
+ },
imageCompressor: {
quality: 0.9,
maxWidth: 1024,
@@ -418,7 +489,7 @@
imageResize: {
displaySize: false,
},
- markdownShortcuts: premium? true : false,
+ markdownShortcuts: premium,
magicUrl: true
},
placeholder: 'Start writing your note',
diff --git a/apps/mobile/src/components/ActionSheetComponent/GetPremium.js b/apps/mobile/src/components/ActionSheetComponent/GetPremium.js
index 1c00db8c7..85fae9124 100644
--- a/apps/mobile/src/components/ActionSheetComponent/GetPremium.js
+++ b/apps/mobile/src/components/ActionSheetComponent/GetPremium.js
@@ -25,7 +25,6 @@ export const GetPremium = ({close, context = 'global', offset = 0}) => {
title: '',
desc: '',
});
-
const open = (event) => {
if (event.context === context) {
setMsg({