git.shiar.nl
/
minimedit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
page: stable include path (site then minimedit root)
[minimedit.git]
/
edit.js
diff --git
a/edit.js
b/edit.js
index fcc8d5f3cb7c9ce3193079f92d597bbc9659f642..5384f2c9eea1039ad6109f95236b85fa78dd45a0 100644
(file)
--- a/
edit.js
+++ b/
edit.js
@@
-4,13
+4,17
@@
CKEDITOR.plugins.add('inlinesave', {
exec: function (editor) {
var pagename = window.location.pathname.replace(/\/$/, '/index');
var body = editor.getData();
exec: function (editor) {
var pagename = window.location.pathname.replace(/\/$/, '/index');
var body = editor.getData();
+ // empty line is equivalent to a paragraph break
body = body.replace(/<br \/>\s*<br \/>/g, '<p>');
body = body.replace(/<br \/>\s*<br \/>/g, '<p>');
+ // wrap long line after each sentence
body = body.replace(/^(\t*).{73,}/mg, function (line, indent) {
body = body.replace(/^(\t*).{73,}/mg, function (line, indent) {
- // wrap long line after each sentence
var dots = '(?:.{24,72}|.{73,}?)'; // chars before punctuation
var dots = '(?:.{24,72}|.{73,}?)'; // chars before punctuation
- var wrap = new RegExp('('+dots+'[.
;
:!?]) (?=[A-Z(<])', 'g'); // separate lines
+ var wrap = new RegExp('('+dots+'[.:!?]) (?=[A-Z(<])', 'g'); // separate lines
return line.replace(wrap, '$1\n'+indent+'\t');
});
return line.replace(wrap, '$1\n'+indent+'\t');
});
+ // treat standalone placeholders as block elements
+ body = body.replace(/<p>(\[\[.*\]\])<\/p>/g, '$1');
+
var data = 'body='+encodeURIComponent(body);
ajaxpost = new XMLHttpRequest();
ajaxpost.open('POST', '/edit'+pagename, true);
var data = 'body='+encodeURIComponent(body);
ajaxpost = new XMLHttpRequest();
ajaxpost.open('POST', '/edit'+pagename, true);
@@
-35,13
+39,20
@@
CKEDITOR.plugins.add('inlinesave', {
});
CKEDITOR.on('dialogDefinition', function (event) {
});
CKEDITOR.on('dialogDefinition', function (event) {
- if (event.data.name === 'table') {
+ switch (event.data.name) {
+ case 'table':
// override initial attribute values
var infoTab = event.data.definition.getContents('info');
infoTab.get('txtWidth').default = '';
infoTab.get('txtBorder').default = '0';
infoTab.get('txtCellSpace').default = '';
infoTab.get('txtCellPad').default = '';
// override initial attribute values
var infoTab = event.data.definition.getContents('info');
infoTab.get('txtWidth').default = '';
infoTab.get('txtBorder').default = '0';
infoTab.get('txtCellSpace').default = '';
infoTab.get('txtCellPad').default = '';
+ break;
+ case 'link':
+ // remove unneeded widgets from the Link Info tab
+ var infotab = event.data.definition.getContents('info');
+ infotab.remove('linkType');
+ break;
}
});
}
});
@@
-65,7
+76,7
@@
CKEDITOR.on('instanceCreated', function (event) {
editor.on('configLoaded', function () {
var config = editor.config;
config.language = 'nl';
editor.on('configLoaded', function () {
var config = editor.config;
config.language = 'nl';
- config.extraPlugins = '
sourcedialog,
inlinesave,placeholder,image2,uploadimage';
+ config.extraPlugins = 'inlinesave,placeholder,image2,uploadimage';
config.format_tags = 'h2;h3;h4;p';
config.allowedContent = true;
config.entities = false; // keep unicode
config.format_tags = 'h2;h3;h4;p';
config.allowedContent = true;
config.entities = false; // keep unicode
@@
-73,14
+84,21
@@
CKEDITOR.on('instanceCreated', function (event) {
config.uploadUrl = '/edit?output=ckjson';
config.image2_alignClasses = ['left', 'center', 'right'];
config.image2_disableResizer = true;
config.uploadUrl = '/edit?output=ckjson';
config.image2_alignClasses = ['left', 'center', 'right'];
config.image2_disableResizer = true;
+ config.stylesSet = [
+ { name: 'Kolom', element: 'div', attributes: { 'class': 'col' } },
+ { name: 'Rechts', element: 'div', attributes: { 'class': 'right' } },
+ ];
config.pasteFilter = pastefilter;
config.contentsCss = document.styleSheets[0].href;
config.toolbar = [
['Inlinesave', '-', 'Undo', 'Redo'],
config.pasteFilter = pastefilter;
config.contentsCss = document.styleSheets[0].href;
config.toolbar = [
['Inlinesave', '-', 'Undo', 'Redo'],
- ['Format'
, 'BulletedList', 'NumberedList', 'Blockquote'
],
+ ['Format'],
['Bold', 'Italic', 'Link'],
['Bold', 'Italic', 'Link'],
- ['HorizontalRule', 'Table', 'Image'],
- ['CreatePlaceholder', 'Sourcedialog'],
+ ['BulletedList', 'NumberedList', 'Blockquote'],
+ ['Table', 'CreateDiv'],
+ ['Image', 'HorizontalRule', 'CreatePlaceholder'],
+// ['Sourcedialog'],
+ ['closebtn'],
];
config.toolbarCanCollapse = true;
config.floatSpacePreferRight = true;
];
config.toolbarCanCollapse = true;
config.floatSpacePreferRight = true;
@@
-104,14
+122,15
@@
CKEDITOR.on('instanceCreated', function (event) {
var pagebody = document.getElementsByClassName('static')[0];
if (pagebody) {
var editlink = document.querySelector('a[href="#edit"]');
var pagebody = document.getElementsByClassName('static')[0];
if (pagebody) {
var editlink = document.querySelector('a[href="#edit"]');
+ if (editlink)
editlink.onclick = function (e) {
editlink.style.fontWeight = 'bold';
editlink.href = '';
editlink.onclick = undefined;
pagebody.setAttribute('contenteditable', true);
pagebody.innerHTML = pagebody.innerHTML
editlink.onclick = function (e) {
editlink.style.fontWeight = 'bold';
editlink.href = '';
editlink.onclick = undefined;
pagebody.setAttribute('contenteditable', true);
pagebody.innerHTML = pagebody.innerHTML
- .replace(/<!--BLOCK:(
[^-]*
)-->[^]*?<!--\/-->/g, '$1');
- CKEDITOR.inline(pagebody);
+ .replace(/<!--BLOCK:(
.*?
)-->[^]*?<!--\/-->/g, '$1');
+ CKEDITOR.inline(pagebody
, { customConfig: '' }
);
document.body.className = 'edit';
return false;
};
document.body.className = 'edit';
return false;
};