mirror of
https://github.com/documize/community.git
synced 2025-07-24 23:59:47 +02:00
improved markdown editing experience
This commit is contained in:
parent
bbf115b9b1
commit
0b51608383
7 changed files with 619 additions and 647 deletions
|
@ -31,8 +31,6 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
let self = this;
|
let self = this;
|
||||||
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js";
|
|
||||||
|
|
||||||
let rawBody = this.get('meta.rawBody');
|
let rawBody = this.get('meta.rawBody');
|
||||||
let cleanBody = rawBody.replace("</pre>", "");
|
let cleanBody = rawBody.replace("</pre>", "");
|
||||||
|
|
||||||
|
@ -135,8 +133,9 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
onAction(title) {
|
onAction(title) {
|
||||||
let page = this.get('page');
|
let page = this.get('page');
|
||||||
let meta = this.get('meta');
|
let meta = this.get('meta');
|
||||||
page.set('title', title);
|
|
||||||
meta.set('rawBody', this.getPRE());
|
meta.set('rawBody', this.getPRE());
|
||||||
|
page.set('title', title);
|
||||||
|
page.set('body', meta.get('rawBody'));
|
||||||
|
|
||||||
this.attrs.onAction(page, meta);
|
this.attrs.onAction(page, meta);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,12 +17,11 @@ export default Ember.Component.extend({
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js";
|
|
||||||
|
|
||||||
let page = this.get('page');
|
let page = this.get('page');
|
||||||
let rawBody = page.get('body');
|
let rawBody = page.get('body');
|
||||||
let cleanBody = rawBody.replace("</pre>", "").replace('<pre class="code-mirror cm-s-solarized cm-s-dark" data-lang="', "");
|
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() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
if (this.get('isDestroyed') || this.get('isDestroying')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,36 +34,7 @@ export default Ember.Component.extend(TooltipMixin, {
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
// let self = this;
|
|
||||||
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js";
|
|
||||||
|
|
||||||
this.set('pageBody', this.get('meta.rawBody').trim());
|
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() {
|
didInsertElement() {
|
||||||
|
|
|
@ -20,6 +20,7 @@ export function initialize( /*application*/ ) {
|
||||||
});
|
});
|
||||||
|
|
||||||
Dropzone.autoDiscover = false;
|
Dropzone.autoDiscover = false;
|
||||||
|
CodeMirror.modeURL = "/codemirror/mode/%N/%N.js";
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -62,7 +62,8 @@ export default Ember.Controller.extend(NotifierMixin, {
|
||||||
meta: meta.toJSON({ includeId: true })
|
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'));
|
this.set('pageId', page.get('id'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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";
|
var revision = skipRevision ? "?r=true" : "?r=false";
|
||||||
let url = `documents/${documentId}/pages/${pageId}${revision}`;
|
let url = `documents/${documentId}/pages/${pageId}${revision}`;
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue