diff --git a/src/components/Explorer.vue b/src/components/Explorer.vue index d8cde861..c2e3bd47 100644 --- a/src/components/Explorer.vue +++ b/src/components/Explorer.vue @@ -48,7 +48,7 @@ export default { newItem(isFolder) { let parentId = this.$store.getters['explorer/selectedNodeFolder'].item.id; if (parentId === 'trash') { - parentId = undefined; + parentId = null; } this.$store.dispatch('explorer/openNode', parentId); this.$store.commit('explorer/setNewItem', { @@ -92,6 +92,7 @@ export default { id: selectedNode.item.id, parentId: 'trash', }); + this.$store.commit('file/setCurrentId', this.$store.getters['data/lastOpenedIds'][1]); } } }); diff --git a/src/components/ExplorerNode.vue b/src/components/ExplorerNode.vue index 4d07331e..6f0abc45 100644 --- a/src/components/ExplorerNode.vue +++ b/src/components/ExplorerNode.vue @@ -58,7 +58,7 @@ export default { return this.$store.state.explorer.newChildNode.item.name; }, set(value) { - this.$store.commit('explorer/setNewItemName', value && value.slice(0, 250)); + this.$store.commit('explorer/setNewItemName', value); }, }, editingNodeName: { @@ -91,28 +91,18 @@ export default { submitNewChild(cancel) { const newChildNode = this.$store.state.explorer.newChildNode; if (!cancel && !newChildNode.isNil && newChildNode.item.name) { - const id = utils.uid(); if (newChildNode.isFolder) { + const id = utils.uid(); this.$store.commit('folder/setItem', { ...newChildNode.item, id, + name: utils.sanitizeName(newChildNode.item.name), }); + this.select(id); } else { - // Add empty line at the end if needed - const ensureFinalNewLine = text => `${text}\n`.replace(/\n\n$/, '\n'); - const text = ensureFinalNewLine(this.$store.getters['data/computedSettings'].newFileContent); - const properties = ensureFinalNewLine(this.$store.getters['data/computedSettings'].newFileProperties); - this.$store.commit('content/setItem', { - id: `${id}/content`, - text, - properties, - }); - this.$store.commit('file/setItem', { - ...newChildNode.item, - id, - }); + this.$store.dispatch('createFile', newChildNode.item) + .then(file => this.select(file.id)); } - this.select(id); } this.$store.commit('explorer/setNewItem', null); }, @@ -123,7 +113,7 @@ export default { if (!cancel && id && value) { this.$store.commit(editingNode.isFolder ? 'folder/patchItem' : 'file/patchItem', { id, - name: value.slice(0, 250), + name: utils.sanitizeName(value), }); } this.$store.commit('explorer/setEditingId', null); diff --git a/src/components/NavigationBar.vue b/src/components/NavigationBar.vue index 65a0e7db..3b0f3c66 100644 --- a/src/components/NavigationBar.vue +++ b/src/components/NavigationBar.vue @@ -80,6 +80,7 @@ import editorSvc from '../services/editorSvc'; import syncSvc from '../services/syncSvc'; import publishSvc from '../services/publishSvc'; import animationSvc from '../services/animationSvc'; +import utils from '../services/utils'; export default { data: () => ({ @@ -171,7 +172,7 @@ export default { } else { const title = this.title.trim(); if (title) { - this.$store.dispatch('file/patchCurrent', { name: title.slice(0, 250) }); + this.$store.dispatch('file/patchCurrent', { name: utils.sanitizeName(title) }); } else { this.title = this.$store.getters['file/current'].name; } @@ -342,9 +343,7 @@ export default { } .navigation-bar__title--input, -.navigation-bar__inner--edit-buttons, -.navigation-bar__inner--button, -.navigation-bar__spinner { +.navigation-bar__inner--edit-buttons { display: none; .navigation-bar--editor & { @@ -355,6 +354,7 @@ export default { .navigation-bar__button { display: none; + .navigation-bar__inner--button &, .navigation-bar--editor & { display: inline-block; } @@ -374,13 +374,13 @@ $b: $d/10; $t: 3000ms; .navigation-bar__spinner { - width: 22px; + width: 24px; margin: 7px 0 0 8px; color: #b2b2b2; .icon { - width: 22px; - height: 22px; + width: 24px; + height: 24px; color: transparentize($error-color, 0.5); } } diff --git a/src/components/SplashScreen.vue b/src/components/SplashScreen.vue index ea3c5408..b1ecd09e 100644 --- a/src/components/SplashScreen.vue +++ b/src/components/SplashScreen.vue @@ -1,6 +1,6 @@ diff --git a/src/components/common/app.scss b/src/components/common/app.scss index d4067513..26124c17 100644 --- a/src/components/common/app.scss +++ b/src/components/common/app.scss @@ -81,7 +81,8 @@ textarea { &:active, &:focus, - &:hover { + &:hover, + .hidden-file:focus + & { color: #333; background-color: rgba(0, 0, 0, 0.067); outline: 0; @@ -193,3 +194,41 @@ textarea { background: no-repeat center url('../assets/logo.svg'); background-size: contain; } + +@media print { + body { + background-color: transparent !important; + color: #000 !important; // Black prints faster + overflow: visible !important; + position: absolute !important; + + div { + display: none !important; + } + + a { + text-decoration: underline; + } + } + + body > .app, + body > .app > .layout, + body > .app > .layout > .layout__panel, + body > .app > .layout > .layout__panel > .layout__panel, + body > .app > .layout > .layout__panel > .layout__panel > .layout__panel, + body > .app > .layout > .layout__panel > .layout__panel > .layout__panel > .layout__panel--preview, + body > .app > .layout > .layout__panel > .layout__panel > .layout__panel > .layout__panel--preview div { + background-color: transparent !important; + display: block !important; + height: auto !important; + overflow: visible !important; + position: static !important; + width: auto !important; + font-size: 16px; + } + + .preview__inner-2 { + padding: 0 50px !important; + } + // scss-lint:enable ImportantRule +} diff --git a/src/components/menus/MainMenu.vue b/src/components/menus/MainMenu.vue index a83ecd18..f4d1ba1d 100644 --- a/src/components/menus/MainMenu.vue +++ b/src/components/menus/MainMenu.vue @@ -37,10 +37,19 @@ Markdown cheat sheet
- - - Import from disk + + + Print + + Export to disk @@ -58,6 +67,7 @@ import MenuEntry from './MenuEntry'; import UserImage from '../UserImage'; import googleHelper from '../../services/providers/helpers/googleHelper'; import syncSvc from '../../services/syncSvc'; +import providerUtils from '../../services/providers/providerUtils'; export default { components: { @@ -80,13 +90,32 @@ export default { () => {}, // Cancel ); }, - importFile() { - return this.$store.dispatch('modal/notImplemented'); + onImportFile(evt) { + const file = evt.target.files[0]; + if (file) { + const reader = new FileReader(); + reader.onload = (e) => { + const content = e.target.result; + if (content.match(/\uFFFD/)) { + this.$store.dispatch('notification/error', 'File is not readable.'); + } else { + this.$store.dispatch('createFile', { + ...providerUtils.parseContent(content), + name: file.name, + }) + .then(item => this.$store.commit('file/setCurrentId', item.id)); + } + }; + reader.readAsText(file); + } }, fileProperties() { return this.$store.dispatch('modal/open', 'fileProperties') .catch(() => {}); // Cancel }, + print() { + print(); + }, }, }; diff --git a/src/components/menus/MenuEntry.vue b/src/components/menus/MenuEntry.vue index 53b9d6a0..2000385c 100644 --- a/src/components/menus/MenuEntry.vue +++ b/src/components/menus/MenuEntry.vue @@ -37,4 +37,9 @@ border-radius: $border-radius-base; overflow: hidden; } + +.hidden-file { + position: fixed; + top: -999px; +} diff --git a/src/components/menus/MoreMenu.vue b/src/components/menus/MoreMenu.vue index 6c7451c9..23f12340 100644 --- a/src/components/menus/MoreMenu.vue +++ b/src/components/menus/MoreMenu.vue @@ -16,6 +16,20 @@ Sign out and clean local data.
+ + + + + Export backup + +
About StackEdit @@ -34,12 +48,29 @@