1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-23 15:19:42 +02:00

improved markdown editing experience

This commit is contained in:
Harvey Kandola 2017-03-14 06:15:35 +00:00
parent bbf115b9b1
commit 0b51608383
7 changed files with 619 additions and 647 deletions

View file

@ -31,8 +31,6 @@ export default Ember.Component.extend(TooltipMixin, {
this._super(...arguments);
let self = this;
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js";
let rawBody = this.get('meta.rawBody');
let cleanBody = rawBody.replace("</pre>", "");
@ -135,8 +133,9 @@ export default Ember.Component.extend(TooltipMixin, {
onAction(title) {
let page = this.get('page');
let meta = this.get('meta');
page.set('title', title);
meta.set('rawBody', this.getPRE());
page.set('title', title);
page.set('body', meta.get('rawBody'));
this.attrs.onAction(page, meta);
}

View file

@ -17,12 +17,11 @@ export default Ember.Component.extend({
didReceiveAttrs() {
this._super(...arguments);
if (this.get('isDestroyed') || this.get('isDestroying')) {
return;
}
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js";
let page = this.get('page');
let rawBody = page.get('body');
let cleanBody = rawBody.replace("</pre>", "").replace('<pre class="code-mirror cm-s-solarized cm-s-dark" data-lang="', "");
@ -44,6 +43,7 @@ export default Ember.Component.extend({
didInsertElement() {
this._super(...arguments);
if (this.get('isDestroyed') || this.get('isDestroying')) {
return;
}

View file

@ -34,36 +34,7 @@ export default Ember.Component.extend(TooltipMixin, {
init() {
this._super(...arguments);
// let self = this;
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js";
this.set('pageBody', this.get('meta.rawBody').trim());
// let opts = [];
// let syntax = {
// mode: "markdown",
// name: "Markdown"
// };
// _.each(_.sortBy(CodeMirror.modeInfo, 'name'), function(item) {
// let i = {
// mode: item.mode,
// name: item.name
// };
// opts.pushObject(i);
// if (item.mode === syntax) {
// self.set('codeSyntax', i);
// }
// });
// this.set('syntaxOptions', opts);
// // default check
// if (is.null(this.get("codeSyntax"))) {
// this.set("codeSyntax", opts.findBy("mode", "markdown"));
// }
},
didInsertElement() {

View file

@ -20,6 +20,7 @@ export function initialize( /*application*/ ) {
});
Dropzone.autoDiscover = false;
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js";
}
export default {

View file

@ -62,7 +62,8 @@ export default Ember.Controller.extend(NotifierMixin, {
meta: meta.toJSON({ includeId: true })
};
this.get('documentService').updatePage(documentId, page.get('id'), model).then(() => {
this.get('documentService').updatePage(documentId, page.get('id'), model).then((up) => {
page = up;
this.set('pageId', page.get('id'));
});

View file

@ -124,7 +124,7 @@ export default Ember.Service.extend({
});
},
updatePage: function (documentId, pageId, payload, skipRevision) {
updatePage(documentId, pageId, payload, skipRevision) {
var revision = skipRevision ? "?r=true" : "?r=false";
let url = `documents/${documentId}/pages/${pageId}${revision}`;

File diff suppressed because one or more lines are too long