From fb95df2e14e139dc270c710d4f5c97190b1ce0b3 Mon Sep 17 00:00:00 2001 From: Benoit Schweblin Date: Mon, 2 Oct 2017 20:09:39 +0100 Subject: [PATCH] Fixed form entries. Fixed error logs when canceling a modal. --- src/components/Modal.vue | 62 ++++++++++++++++++++++++++ src/components/menus/ExportMenu.vue | 6 ++- src/components/menus/MainMenu.vue | 8 +++- src/components/menus/MoreMenu.vue | 15 +++++-- src/components/menus/PublishMenu.vue | 42 ++++++++++++------ src/components/menus/SyncMenu.vue | 21 ++++++--- src/components/modals/FormEntry.vue | 66 ---------------------------- src/libs/mdGrammar.js | 12 ++--- 8 files changed, 132 insertions(+), 100 deletions(-) diff --git a/src/components/Modal.vue b/src/components/Modal.vue index 6a2f847c..3f94ec00 100644 --- a/src/components/Modal.vue +++ b/src/components/Modal.vue @@ -224,4 +224,66 @@ export default { margin-left: 5px; } } + +.form-entry { + margin: 1em 0; +} + +.form-entry__label { + display: block; + font-size: 0.9rem; + color: #a0a0a0; + + .form-entry--focused & { + color: darken($link-color, 10%); + } +} + +.form-entry__field { + border: 1px solid #d8d8d8; + border-radius: $border-radius-base; + position: relative; + overflow: hidden; + + .form-entry--focused & { + border-color: $link-color; + } +} + +.form-entry__actions { + text-align: right; + margin: 0.25em; +} + +.form-entry__button { + width: 38px; + height: 38px; + padding: 6px; + display: inline-block; + background-color: transparent; + opacity: 0.75; + + &:active, + &:focus, + &:hover { + opacity: 1; + background-color: rgba(0, 0, 0, 0.1); + } +} + +.form-entry__radio, +.form-entry__checkbox { + margin: 0.25em 1em; + + input { + margin-right: 0.25em; + } +} + +.form-entry__info { + font-size: 0.75em; + opacity: 0.5; + line-height: 1.4; + margin: 0.25em 0; +} diff --git a/src/components/menus/ExportMenu.vue b/src/components/menus/ExportMenu.vue index f8678944..ecdf9cb6 100644 --- a/src/components/menus/ExportMenu.vue +++ b/src/components/menus/ExportMenu.vue @@ -29,10 +29,12 @@ export default { methods: { exportMarkdown() { const currentFile = this.$store.getters['file/current']; - return exportSvc.exportToDisk(currentFile.id, 'md'); + return exportSvc.exportToDisk(currentFile.id, 'md') + .catch(() => {}); // Cancel }, exportHtml() { - return this.$store.dispatch('modal/open', 'htmlExport'); + return this.$store.dispatch('modal/open', 'htmlExport') + .catch(() => {}); // Cancel }, exportPdf() { return this.$store.dispatch('modal/notImplemented'); diff --git a/src/components/menus/MainMenu.vue b/src/components/menus/MainMenu.vue index 822c3373..a83ecd18 100644 --- a/src/components/menus/MainMenu.vue +++ b/src/components/menus/MainMenu.vue @@ -75,13 +75,17 @@ export default { }), signin() { return googleHelper.signin() - .then(() => syncSvc.requestSync()); + .then( + () => syncSvc.requestSync(), + () => {}, // Cancel + ); }, importFile() { return this.$store.dispatch('modal/notImplemented'); }, fileProperties() { - return this.$store.dispatch('modal/open', 'fileProperties'); + return this.$store.dispatch('modal/open', 'fileProperties') + .catch(() => {}); // Cancel }, }, }; diff --git a/src/components/menus/MoreMenu.vue b/src/components/menus/MoreMenu.vue index 477744ec..6c7451c9 100644 --- a/src/components/menus/MoreMenu.vue +++ b/src/components/menus/MoreMenu.vue @@ -42,15 +42,24 @@ export default { methods: { settings() { return this.$store.dispatch('modal/open', 'settings') - .then(settings => this.$store.dispatch('data/setSettings', settings)); + .then( + settings => this.$store.dispatch('data/setSettings', settings), + () => {}, // Cancel + ); }, templates() { return this.$store.dispatch('modal/open', 'templates') - .then(({ templates }) => this.$store.dispatch('data/setTemplates', templates)); + .then( + ({ templates }) => this.$store.dispatch('data/setTemplates', templates), + () => {}, // Cancel + ); }, reset() { return this.$store.dispatch('modal/reset') - .then(() => localDbSvc.removeDb()); + .then( + () => localDbSvc.removeDb(), + () => {}, // Cancel + ); }, about() { return this.$store.dispatch('modal/open', 'about'); diff --git a/src/components/menus/PublishMenu.vue b/src/components/menus/PublishMenu.vue index 3e28200e..f65b7d74 100644 --- a/src/components/menus/PublishMenu.vue +++ b/src/components/menus/PublishMenu.vue @@ -161,55 +161,69 @@ export default { return this.$store.dispatch('modal/open', 'publishManagement'); }, addGoogleDriveAccount() { - return googleHelper.addDriveAccount(); + return googleHelper.addDriveAccount() + .catch(() => {}); // Cancel }, addDropboxAccount() { return this.$store.dispatch('modal/open', { type: 'dropboxAccount', onResolve: () => dropboxHelper.addAccount(!store.getters['data/localSettings'].dropboxRestrictedAccess), - }); + }) + .catch(() => {}); // Cancel }, addGithubAccount() { return this.$store.dispatch('modal/open', { type: 'githubAccount', onResolve: () => githubHelper.addAccount(store.getters['data/localSettings'].githubRepoFullAccess), - }); + }) + .catch(() => {}); // Cancel }, addWordpressAccount() { - return wordpressHelper.addAccount(); + return wordpressHelper.addAccount() + .catch(() => {}); // Cancel }, addBloggerAccount() { - return googleHelper.addBloggerAccount(); + return googleHelper.addBloggerAccount() + .catch(() => {}); // Cancel }, addZendeskAccount() { return this.$store.dispatch('modal/open', { type: 'zendeskAccount', onResolve: ({ subdomain, clientId }) => zendeskHelper.addAccount(subdomain, clientId), - }); + }) + .catch(() => {}); // Cancel }, publishGoogleDrive(token) { - return openPublishModal(token, 'googleDrivePublish'); + return openPublishModal(token, 'googleDrivePublish') + .catch(() => {}); // Cancel }, publishDropbox(token) { - return openPublishModal(token, 'dropboxPublish'); + return openPublishModal(token, 'dropboxPublish') + .catch(() => {}); // Cancel }, publishGithub(token) { - return openPublishModal(token, 'githubPublish'); + return openPublishModal(token, 'githubPublish') + .catch(() => {}); // Cancel }, publishGist(token) { - return openPublishModal(token, 'gistPublish'); + return openPublishModal(token, 'gistPublish') + .catch(() => {}); // Cancel }, publishWordpress(token) { - return openPublishModal(token, 'wordpressPublish'); + return openPublishModal(token, 'wordpressPublish') + .catch(() => {}); // Cancel }, publishBlogger(token) { - return openPublishModal(token, 'bloggerPublish'); + return openPublishModal(token, 'bloggerPublish') + .catch(() => {}); // Cancel }, publishBloggerPage(token) { - return openPublishModal(token, 'bloggerPagePublish'); + return openPublishModal(token, 'bloggerPagePublish') + .catch(() => {}); // Cancel }, publishZendesk(token) { - return openPublishModal(token, 'zendeskPublish'); + return openPublishModal(token, 'zendeskPublish') + .catch(() => {}); // Cancel }, }, }; diff --git a/src/components/menus/SyncMenu.vue b/src/components/menus/SyncMenu.vue index b526d89f..91c3aa00 100644 --- a/src/components/menus/SyncMenu.vue +++ b/src/components/menus/SyncMenu.vue @@ -138,19 +138,22 @@ export default { return this.$store.dispatch('modal/open', 'syncManagement'); }, addGoogleDriveAccount() { - return googleHelper.addDriveAccount(); + return googleHelper.addDriveAccount() + .catch(() => {}); // Cancel }, addDropboxAccount() { return this.$store.dispatch('modal/open', { type: 'dropboxAccount', onResolve: () => dropboxHelper.addAccount(!store.getters['data/localSettings'].dropboxRestrictedAccess), - }); + }) + .catch(() => {}); // Cancel }, addGithubAccount() { return this.$store.dispatch('modal/open', { type: 'githubAccount', onResolve: () => githubHelper.addAccount(store.getters['data/localSettings'].githubRepoFullAccess), - }); + }) + .catch(() => {}); // Cancel }, openGoogleDrive(token) { return googleHelper.openPicker(token, 'doc') @@ -163,16 +166,20 @@ export default { () => dropboxProvider.openFiles(token, paths))); }, saveGoogleDrive(token) { - return openSyncModal(token, 'googleDriveSync'); + return openSyncModal(token, 'googleDriveSync') + .catch(() => {}); // Cancel }, saveDropbox(token) { - return openSyncModal(token, 'dropboxSync'); + return openSyncModal(token, 'dropboxSync') + .catch(() => {}); // Cancel }, saveGithub(token) { - return openSyncModal(token, 'githubSync'); + return openSyncModal(token, 'githubSync') + .catch(() => {}); // Cancel }, saveGist(token) { - return openSyncModal(token, 'gistSync'); + return openSyncModal(token, 'gistSync') + .catch(() => {}); // Cancel }, }, }; diff --git a/src/components/modals/FormEntry.vue b/src/components/modals/FormEntry.vue index 9a83c27f..9d18a722 100644 --- a/src/components/modals/FormEntry.vue +++ b/src/components/modals/FormEntry.vue @@ -21,69 +21,3 @@ export default { }, }; - - diff --git a/src/libs/mdGrammar.js b/src/libs/mdGrammar.js index faa634b8..5a049781 100644 --- a/src/libs/mdGrammar.js +++ b/src/libs/mdGrammar.js @@ -231,12 +231,6 @@ module.exports = function (options) { } var rest = {} - rest.code = { - pattern: /(`+)[\s\S]*?\1/g, - inside: { - 'cl cl-code': /`/ - } - } if (options.maths) { rest['math block'] = { pattern: /\\\\\[[\s\S]*?\\\\\]/g, @@ -278,6 +272,12 @@ module.exports = function (options) { } } } + rest.code = { + pattern: /(`+)[\s\S]*?\1/g, + inside: { + 'cl cl-code': /`/ + } + } if (options.footnotes) { rest.inlinefn = { pattern: /\^\[.+?\]/g,