Skip to content

Commit

Permalink
0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
martec committed Jul 7, 2017
1 parent debb149 commit 50d7fe9
Show file tree
Hide file tree
Showing 16 changed files with 60 additions and 14 deletions.
4 changes: 2 additions & 2 deletions rin/editor/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"type": "phpbb-extension",
"description": "Rin Editor for phpBB",
"homepage": "https://github.com/martec/Rin-Editor_for_phpBB",
"version": "0.1.4",
"time": "2017-07-06",
"version": "0.1.5",
"time": "2017-07-07",
"license": "GPL-2.0",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% if S_PLUPLOAD %}{% include 'rineditor_plupload.html' %}{% endif %}
2 changes: 1 addition & 1 deletion rin/editor/styles/all/template/js/ckeditor.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions rin/editor/styles/all/template/js/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions rin/editor/styles/all/template/rineditor_plupload.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<script type="text/javascript">
phpbb.plupload.updateBbcode = function(action, index) {
var text = CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].getData(),
removal = (action === 'removal');

// Return if the bbcode isn't used at all.
if (text.indexOf('[attachment=') === -1) {
return;
}

function runUpdate(i) {
var regex = new RegExp('\\[attachment=' + i + '\\](.*?)\\[\\/attachment\\]', 'g');
text = text.replace(regex, function updateBbcode(_, fileName) {
// Remove the bbcode if the file was removed.
if (removal && index === i) {
return '';
}
var newIndex = i + ((removal) ? -1 : 1);
return '[attachment=' + newIndex + ']' + fileName + '[/attachment]';
});
}

// Loop forwards when removing and backwards when adding ensures we don't
// corrupt the bbcode index.
var i;
if (removal) {
for (i = index; i < phpbb.plupload.ids.length; i++) {
runUpdate(i);
}
} else {
for (i = phpbb.plupload.ids.length - 1; i >= index; i--) {
runUpdate(i);
}
}

CKEDITOR.instances[Object.keys(CKEDITOR.instances)[0]].setData(text);
};
</script>

0 comments on commit 50d7fe9

Please sign in to comment.