Add previewMode settings to code2
This commit is contained in:
parent
0d008aaa2e
commit
b8971cdc23
@ -222,21 +222,19 @@ define([
|
|||||||
];
|
];
|
||||||
|
|
||||||
var onModeChanged = function (mode) {
|
var onModeChanged = function (mode) {
|
||||||
// TODO
|
var $codeMirror = $('.CodeMirror');
|
||||||
return;
|
|
||||||
var $codeMirror = $iframe.find('.CodeMirror');
|
|
||||||
window.clearTimeout(APP.previewTo);
|
window.clearTimeout(APP.previewTo);
|
||||||
$codeMirror.addClass('transition');
|
$codeMirror.addClass('transition');
|
||||||
APP.previewTo = window.setTimeout(function () {
|
APP.previewTo = window.setTimeout(function () {
|
||||||
$codeMirror.removeClass('transition');
|
$codeMirror.removeClass('transition');
|
||||||
}, 500);
|
}, 500);
|
||||||
if (mediaTagModes.indexOf(mode) !== -1) {
|
/*if (mediaTagModes.indexOf(mode) !== -1) {
|
||||||
APP.$mediaTagButton.show();
|
APP.$mediaTagButton.show();
|
||||||
} else { APP.$mediaTagButton.hide(); }
|
} else { APP.$mediaTagButton.hide(); }*/// TODO
|
||||||
|
|
||||||
if (mode === "markdown") {
|
if (mode === "markdown") {
|
||||||
APP.$previewButton.show();
|
APP.$previewButton.show();
|
||||||
Cryptpad.getPadAttribute('previewMode', function (e, data) {
|
common.getPadAttribute('previewMode', function (e, data) {
|
||||||
if (e) { return void console.error(e); }
|
if (e) { return void console.error(e); }
|
||||||
if (data !== false) {
|
if (data !== false) {
|
||||||
$previewContainer.show();
|
$previewContainer.show();
|
||||||
@ -323,6 +321,45 @@ define([
|
|||||||
var $forgetPad = common.createButton('forget', true, {}, forgetCb);
|
var $forgetPad = common.createButton('forget', true, {}, forgetCb);
|
||||||
$rightside.append($forgetPad);
|
$rightside.append($forgetPad);
|
||||||
|
|
||||||
|
var $previewButton = APP.$previewButton = common.createButton(null, true);
|
||||||
|
$previewButton.removeClass('fa-question').addClass('fa-eye');
|
||||||
|
$previewButton.attr('title', Messages.previewButtonTitle);
|
||||||
|
$previewButton.click(function () {
|
||||||
|
var $codeMirror = $('.CodeMirror');
|
||||||
|
window.clearTimeout(APP.previewTo);
|
||||||
|
$codeMirror.addClass('transition');
|
||||||
|
APP.previewTo = window.setTimeout(function () {
|
||||||
|
$codeMirror.removeClass('transition');
|
||||||
|
}, 500);
|
||||||
|
if (CodeMirror.highlightMode !== 'markdown') {
|
||||||
|
$previewContainer.show();
|
||||||
|
}
|
||||||
|
$previewContainer.toggle();
|
||||||
|
if ($previewContainer.is(':visible')) {
|
||||||
|
forceDrawPreview();
|
||||||
|
$codeMirror.removeClass('fullPage');
|
||||||
|
$previewButton.addClass('active');
|
||||||
|
common.setPadAttribute('previewMode', true, function (e) {
|
||||||
|
if (e) { return console.log(e); }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$codeMirror.addClass('fullPage');
|
||||||
|
$previewButton.removeClass('active');
|
||||||
|
common.setPadAttribute('previewMode', false, function (e) {
|
||||||
|
if (e) { return console.log(e); }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
$rightside.append($previewButton);
|
||||||
|
|
||||||
|
if (!readOnly) {
|
||||||
|
CodeMirror.configureTheme(function () {
|
||||||
|
CodeMirror.configureLanguage(null, onModeChanged);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
CodeMirror.configureTheme();
|
||||||
|
}
|
||||||
// TODO
|
// TODO
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -345,45 +382,6 @@ define([
|
|||||||
Cryptpad.createFileDialog(fileDialogCfg);
|
Cryptpad.createFileDialog(fileDialogCfg);
|
||||||
}).appendTo($rightside);
|
}).appendTo($rightside);
|
||||||
|
|
||||||
var $previewButton = APP.$previewButton = Cryptpad.createButton(null, true);
|
|
||||||
$previewButton.removeClass('fa-question').addClass('fa-eye');
|
|
||||||
$previewButton.attr('title', Messages.previewButtonTitle);
|
|
||||||
$previewButton.click(function () {
|
|
||||||
var $codeMirror = $iframe.find('.CodeMirror');
|
|
||||||
window.clearTimeout(APP.previewTo);
|
|
||||||
$codeMirror.addClass('transition');
|
|
||||||
APP.previewTo = window.setTimeout(function () {
|
|
||||||
$codeMirror.removeClass('transition');
|
|
||||||
}, 500);
|
|
||||||
if (CodeMirror.highlightMode !== 'markdown') {
|
|
||||||
$previewContainer.show();
|
|
||||||
}
|
|
||||||
$previewContainer.toggle();
|
|
||||||
if ($previewContainer.is(':visible')) {
|
|
||||||
forceDrawPreview();
|
|
||||||
$codeMirror.removeClass('fullPage');
|
|
||||||
Cryptpad.setPadAttribute('previewMode', true, function (e) {
|
|
||||||
if (e) { return console.log(e); }
|
|
||||||
});
|
|
||||||
$previewButton.addClass('active');
|
|
||||||
} else {
|
|
||||||
$codeMirror.addClass('fullPage');
|
|
||||||
$previewButton.removeClass('active');
|
|
||||||
Cryptpad.setPadAttribute('previewMode', false, function (e) {
|
|
||||||
if (e) { return console.log(e); }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
$rightside.append($previewButton);
|
|
||||||
|
|
||||||
if (!readOnly) {
|
|
||||||
CodeMirror.configureTheme(function () {
|
|
||||||
CodeMirror.configureLanguage(null, onModeChanged);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
CodeMirror.configureTheme();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config.onReady = function (info) {
|
config.onReady = function (info) {
|
||||||
@ -439,14 +437,13 @@ define([
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* TODO RPC
|
common.getPadAttribute('previewMode', function (e, data) {
|
||||||
Cryptpad.getPadAttribute('previewMode', function (e, data) {
|
|
||||||
if (e) { return void console.error(e); }
|
if (e) { return void console.error(e); }
|
||||||
if (data === false && APP.$previewButton) {
|
if (data === false && APP.$previewButton) {
|
||||||
APP.$previewButton.click();
|
APP.$previewButton.click();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// add the splitter
|
// add the splitter
|
||||||
|
|||||||
@ -200,6 +200,21 @@ define([
|
|||||||
network.sendto(hkn, JSON.stringify(['GET_FULL_HISTORY', secret.channel, secret.keys.validateKey]));
|
network.sendto(hkn, JSON.stringify(['GET_FULL_HISTORY', secret.channel, secret.keys.validateKey]));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
sframeChan.on('Q_GET_PAD_ATTRIBUTE', function (data, cb) {
|
||||||
|
Cryptpad.getPadAttribute(data.key, function (e, data) {
|
||||||
|
cb({
|
||||||
|
error: e,
|
||||||
|
data: data
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
sframeChan.on('Q_SET_PAD_ATTRIBUTE', function (data, cb) {
|
||||||
|
Cryptpad.setPadAttribute(data.key, data.value, function (e) {
|
||||||
|
cb({error:e});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
CpNfOuter.start({
|
CpNfOuter.start({
|
||||||
sframeChan: sframeChan,
|
sframeChan: sframeChan,
|
||||||
channel: secret.channel,
|
channel: secret.channel,
|
||||||
|
|||||||
@ -107,6 +107,22 @@ define([
|
|||||||
ctx.sframeChan.query('Q_GET_FULL_HISTORY', null, cb);
|
ctx.sframeChan.query('Q_GET_FULL_HISTORY', null, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
funcs.getPadAttribute = function (key, cb) {
|
||||||
|
ctx.sframeChan.query('Q_GET_PAD_ATTRIBUTE', {
|
||||||
|
key: key
|
||||||
|
}, function (err, res) {
|
||||||
|
cb (err || res.error, res.data);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
funcs.setPadAttribute = function (key, value, cb) {
|
||||||
|
ctx.sframeChan.query('Q_SET_PAD_ATTRIBUTE', {
|
||||||
|
key: key,
|
||||||
|
value: value
|
||||||
|
}, function (err, data) {
|
||||||
|
cb();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Friends
|
// Friends
|
||||||
var pendingFriends = [];
|
var pendingFriends = [];
|
||||||
funcs.getPendingFriends = function () {
|
funcs.getPendingFriends = function () {
|
||||||
|
|||||||
@ -84,4 +84,8 @@ define({
|
|||||||
|
|
||||||
// Send the new settings to the inner iframe when they are changed in the proxy
|
// Send the new settings to the inner iframe when they are changed in the proxy
|
||||||
'EV_SETTINGS_UPDATE': true,
|
'EV_SETTINGS_UPDATE': true,
|
||||||
|
|
||||||
|
// Get and set pad attributes stored in the drive from the inner iframe
|
||||||
|
'Q_GET_PAD_ATTRIBUTE': true,
|
||||||
|
'Q_SET_PAD_ATTRIBUTE': true,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -146,6 +146,7 @@ define([
|
|||||||
if (!attr || !attr.trim()) { return void cb("E_INVAL_ATTR"); }
|
if (!attr || !attr.trim()) { return void cb("E_INVAL_ATTR"); }
|
||||||
var data = getFileData(id);
|
var data = getFileData(id);
|
||||||
data[attr] = value;
|
data[attr] = value;
|
||||||
|
cb(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
// PATHS
|
// PATHS
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user