Closed kay54068 closed 5 years ago
Sample code is:
--- a/assets/javascripts/redmine_wysiwyg_editor.js
+++ b/assets/javascripts/redmine_wysiwyg_editor.js
@@ -218,7 +218,8 @@ RedmineWysiwygEditor.prototype._initTinymce = function(setting) {
'code { padding: .1em .2em; background-color: rgba(0,0,0,0.04); border-radius: 3px; }' +
'pre code { padding: 0; background: none; }' +
'blockquote { color: #6c757d; margin: .5em 0; padding: 0 1em; border-left: 2px solid rgba(0,0,0,0.15); }' +
- 'a.issue, a.version, a.attachment, a.changeset, a.source, a.project, a.user { padding: .1em .2em; background-color: rgba(0,0,0,0.6); border-radius: 3px; color: white; text-decoration: none; font-size: 80%; }' +
+ 'a.issue, a.document, a.version, a.attachment, a.changeset, a.source, a.project, a.user { padding: .1em .2em; background-color: rgba(0,0,0,0.6); border-radius: 3px; color: white; text-decoration: none; font-size: 80%; }' +
+ 'a.document::before { content: "document:"; }' +
'a.version::before { content: "version:"; }' +
'a.attachment::before { content: "attachment:"; }' +
'a.project::before { content: "project:"; }' +
@@ -506,7 +507,6 @@ RedmineWysiwygEditor.prototype._setVisualContent = function() {
escapeText(textarea[0].value.replace(/\$/g, '$$$$'))
.replace(/\{\{/g, '{$${')
.replace(/\[\[/g, '[$$[')
- .replace(/document:/g, 'document$$:')
.replace(/forum:/g, 'forum$$:')
.replace(/message:/g, 'message$$:')
.replace(/news:/g, 'news$$:')
@@ -616,6 +616,17 @@ RedmineWysiwygEditor._resorceLinkRule = [
replacement: function(content, node) {
return gluableContent(content, node, ' ');
}
+ }, {
+ key: 'document',
+ filter: function(node) {
+ return (node.nodeName === 'A') && node.classList.contains('document');
+ },
+ replacement: function(content, node) {
+ var m = node.getAttribute('href').match(/\/(\d+)$/);
+
+ // FIXME: Does not work with 'sandbox:document#1'
+ return gluableContent('document#' + m[1], node, ' ');
+ }
}, {
key: 'version',
filter: function(node) {
Note this is not a perfect solution.
Textile format have Documents link macro ,how can I implement it?
Documents command: