diff --git a/app/app/components/document/document-view.js b/app/app/components/document/document-view.js index 27e3592f..7ac563ed 100644 --- a/app/app/components/document/document-view.js +++ b/app/app/components/document/document-view.js @@ -50,8 +50,9 @@ export default Ember.Component.extend(NotifierMixin, TooltipMixin, { if (_.isUndefined(exists)) { link.orphan = true; } else { - self.attrs.gotoPage(link.targetId); - return false; + if (link.linkType === "section") { + self.attrs.gotoPage(link.targetId); + } } } diff --git a/app/app/components/section/markdown/type-editor.js b/app/app/components/section/markdown/type-editor.js index 927bdc47..35f07d85 100644 --- a/app/app/components/section/markdown/type-editor.js +++ b/app/app/components/section/markdown/type-editor.js @@ -18,24 +18,22 @@ const { export default Ember.Component.extend({ link: service(), - + editMode: true, isDirty: false, pageBody: "", + pagePreview: "", + height: $(document).height() - 450, didReceiveAttrs() { this.set("pageBody", this.get("meta.rawBody")); }, didInsertElement() { - let height = $(document).height() - $(".document-editor > .toolbar").height() - 130; - $("#section-markdown-editor, #section-markdown-preview").css("height", height); + $("#section-markdown-editor").css("height", this.get('height')); + $("#section-markdown-preview").css("height", this.get('height')); - this.renderPreview(); - let self = this; - - $("#section-markdown-editor").off("keyup").on("keyup", function () { - self.renderPreview(); - self.set('isDirty', true); + $("#section-markdown-editor").off("keyup").on("keyup", () => { + this.set('isDirty', true); }); }, @@ -43,15 +41,26 @@ export default Ember.Component.extend({ $("#section-markdown-editor").off("keyup"); }, - renderPreview() { - let md = window.markdownit({ - linkify: true - }); - let result = md.render(this.get("pageBody")); - $("#section-markdown-preview").html(result); - }, - actions: { + toggleMode() { + this.set('editMode', !this.get('editMode')); + + Ember.run.schedule('afterRender', () => { + if (this.get('editMode')) { + $("#section-markdown-editor").off("keyup").on("keyup", () => { + this.set('isDirty', true); + }); + $("#section-markdown-editor").css("height", this.get('height')); + } else { + let md = window.markdownit({ linkify: true }); + let result = md.render(this.get("pageBody")); + + this.set('pagePreview', result); + $("#section-markdown-preview").css("height", this.get('height')); + } + }); + }, + onInsertLink(link) { let linkMarkdown = this.get('link').buildLink(link); diff --git a/app/app/services/link.js b/app/app/services/link.js index 12caf78b..c2815875 100644 --- a/app/app/services/link.js +++ b/app/app/services/link.js @@ -33,7 +33,6 @@ export default Ember.Service.extend({ return this.get('ajax').request(`links/${folderId}/${documentId}/${pageId}`, { method: 'GET' }).then((response) => { - console.log(response); return response; }); }, diff --git a/app/app/templates/components/section/markdown/type-editor.hbs b/app/app/templates/components/section/markdown/type-editor.hbs index 78ade45c..74ce93e2 100644 --- a/app/app/templates/components/section/markdown/type-editor.hbs +++ b/app/app/templates/components/section/markdown/type-editor.hbs @@ -1,16 +1,26 @@ {{#section/base-editor document=document folder=folder page=page isDirty=(action 'isDirty') onCancel=(action 'onCancel') onAction=(action 'onAction')}}