1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
// widget for handling studip-style quoting with author name
(function studipQuotePlugin(CKEDITOR) {
CKEDITOR.plugins.add('studip-quote', {
icons: 'blockquote,splitquote,removequote',
hidpi: true,
init: initPlugin
});
function initPlugin(editor) {
editor.addCommand('insertStudipQuote', {
exec: insertStudipQuote
});
editor.addCommand('splitQuote', {
exec: splitStudipQuote
});
editor.addCommand('removeQuote', {
exec: removeStudipQuote
});
editor.ui.addButton('blockquote', {
label: 'Zitat einfügen'.toLocaleString(),
command: 'insertStudipQuote',
toolbar: 'quote'
});
editor.ui.addButton('SplitQuote', {
label: 'Zitat teilen'.toLocaleString(),
command: 'splitQuote',
toolbar: 'quote'
});
editor.ui.addButton('RemoveQuote', {
label: 'Zitat löschen'.toLocaleString(),
command: 'removeQuote',
toolbar: 'quote'
});
editor.setKeystroke(CKEDITOR.CTRL + CKEDITOR.SHIFT + 13, 'splitQuote'); // CTRL+SHIFT+Return
}
function insertStudipQuote(editor) {
// If quoting is changed update these functions:
// - StudipFormat::markupQuote
// lib/classes/StudipFormat.php
// - quotes_encode lib/visual.inc.php
// - STUDIP.Forum.citeEntry > quote
// public/plugins_packages/core/Forum/javascript/forum.js
// - studipQuotePlugin > insertStudipQuote
// public/assets/javascripts/ckeditor/plugins/studip-quote/plugin.js
var writtenBy = '%s hat geschrieben:'.toLocaleString();
// TODO generate HTML tags with JS/jQuery functions
editor.insertHtml(
'<blockquote><div class="author">'
+ writtenBy.replace('%s', '"Name"')
+ '</div><p> </p></blockquote><p> </p>'
);
}
function splitStudipQuote(editor) {
// is the cursor position within a blockquote?
var blockquote = editor.elementPath().contains('blockquote', true, false);
if (blockquote !== null) {
var pElement = CKEDITOR.dom.element.createFromHtml('<p></p>');
editor.insertElement(pElement);
pElement.breakParent(blockquote);
var range = editor.createRange();
range.moveToElementEditablePosition(pElement);
editor.getSelection().selectRanges([range]);
}
}
function removeStudipQuote(editor) {
// is the cursor position within a blockquote?
var blockquote = editor.elementPath().contains('blockquote', true, false);
if (blockquote !== null) {
blockquote.remove(true);
}
}
})(CKEDITOR);
|