Skip to content

Commit

Permalink
Item14288: working on dialogs
Browse files Browse the repository at this point in the history
- insert link will also insert attachments now
- the separate insert attachment is gone
- instead there is a new insert image now (not yet functional)
  • Loading branch information
MichaelDaum committed Apr 5, 2017
1 parent d7114cb commit 602136c
Show file tree
Hide file tree
Showing 30 changed files with 103,697 additions and 396 deletions.
230 changes: 111 additions & 119 deletions NatEditPlugin/locale/NatEditPlugin/Foswiki.pot

Large diffs are not rendered by default.

3,810 changes: 3,810 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/bg.po

Large diffs are not rendered by default.

5,417 changes: 5,417 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/cs.po

Large diffs are not rendered by default.

4,842 changes: 4,842 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/da.po

Large diffs are not rendered by default.

332 changes: 162 additions & 170 deletions NatEditPlugin/locale/NatEditPlugin/de.po

Large diffs are not rendered by default.

4,472 changes: 4,472 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/el.po

Large diffs are not rendered by default.

6,006 changes: 6,006 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/es.po

Large diffs are not rendered by default.

4,531 changes: 4,531 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/fi.po

Large diffs are not rendered by default.

5,448 changes: 5,448 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/fr.po

Large diffs are not rendered by default.

5,331 changes: 5,331 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/it.po

Large diffs are not rendered by default.

5,347 changes: 5,347 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/ja.po

Large diffs are not rendered by default.

2,559 changes: 2,559 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/ko.po

Large diffs are not rendered by default.

4,747 changes: 4,747 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/nl.po

Large diffs are not rendered by default.

4,743 changes: 4,743 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/no.po

Large diffs are not rendered by default.

5,913 changes: 5,913 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/pl.po

Large diffs are not rendered by default.

4,879 changes: 4,879 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/pt-br.po

Large diffs are not rendered by default.

4,551 changes: 4,551 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/pt.po

Large diffs are not rendered by default.

4,865 changes: 4,865 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/ru.po

Large diffs are not rendered by default.

4,653 changes: 4,653 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/sv.po

Large diffs are not rendered by default.

4,567 changes: 4,567 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/tlh.po

Large diffs are not rendered by default.

1,970 changes: 1,970 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/tr.po

Large diffs are not rendered by default.

5,375 changes: 5,375 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/uk.po

Large diffs are not rendered by default.

4,280 changes: 4,280 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/zh-cn.po

Large diffs are not rendered by default.

4,835 changes: 4,835 additions & 0 deletions NatEditPlugin/locale/NatEditPlugin/zh-tw.po

Large diffs are not rendered by default.

Expand Up @@ -249,6 +249,108 @@ BaseEngine.prototype.insertTable = function(opts) {
self.insert(table);
};

/***************************************************************************
* insert a link
* opts is a hash of params that can have either of two forms:
*
* insert a link to a topic:
* {
* web: "TheWeb",
* topic: "TheTopic",
* text: "the link text" (optional)
* }
*
* insert an external link:
* {
* url: "http://...",
* text: "the link text" (optional)
* }
*
* insert an attachment link:
* {
* web: "TheWeb",
* topic: "TheTopic",
* file: "TheAttachment.jpg",
* text: "the link text" (optional)
* }
*/
BaseEngine.prototype.insertLink = function(opts) {
var self = this, markup;

console.log("insertLink opts=",opts);

if (typeof(opts.url) !== 'undefined') {
// external link
if (typeof(opts.url) === 'undefined' || opts.url === '') {
return; // nop
}

if (typeof(opts.text) !== 'undefined' && opts.text !== '') {
markup = "[["+opts.url+"]["+opts.text+"]]";
} else {
markup = "[["+opts.url+"]]";
}
} else if (typeof(opts.file) !== 'undefined') {
// attachment link

if (typeof(opts.web) === 'undefined' || opts.web === '' ||
typeof(opts.topic) === 'undefined' || opts.topic === '') {
return; // nop
}

if (opts.file.match(/\.(bmp|png|jpe?g|gif|svg)$/i) && foswiki.getPreference("NatEditPlugin").ImagePluginEnabled) {
markup = '%IMAGE{"'+opts.file+'"';
if (opts.web !== self.shell.opts.web || opts.topic !== self.shell.opts.topic) {
markup += ' topic="';
if (opts.web !== self.shell.opts.web) {
markup += opts.web+'.';
}
markup += opts.topic+'"';
}
if (typeof(opts.text) !== 'undefined' && opts.text !== '') {
markup += ' caption="'+opts.text+'"';
}
markup += ' size="320"}%';
} else {
// linking to an ordinary attachment

if (opts.web === self.shell.opts.web && opts.topic === self.shell.opts.topic) {
markup = "[[%ATTACHURLPATH%/"+opts.file+"]";
} else {
markup = "[[%PUBURLPATH%/"+opts.web+"/"+opts.topic+"/"+opts.file+"]";
}

if (typeof(opts.text) !== 'undefined' && opts.text !== '') {
markup += "["+opts.text+"]";
} else {
markup += "["+opts.file+"]";
}
markup += "]";
}

} else {
// wiki link

if (typeof(opts.topic) === 'undefined' || opts.topic === '') {
return; // nop
}

if (opts.web === self.shell.opts.web) {
markup = "[["+opts.topic+"]";
} else {
markup = "[["+opts.web+"."+opts.topic+"]";
}

if (typeof(opts.text) !== 'undefined' && opts.text !== '') {
markup += "["+opts.text+"]";
}
markup += "]";
}

self.remove();
self.insert(markup);
};

/*****************************************************************************
* parse the current selection into a two-dimensional array
* to be used initializing a table. rows are separated by \n, columns by whitespace
Expand Down
Expand Up @@ -334,7 +334,6 @@ CodemirrorEngine.prototype.insertLineTag = function(markup) {
doc.setSelection(start, end);

self.cm.focus();

};

/*************************************************************************
Expand Down
Expand Up @@ -75,6 +75,7 @@ TinyMCEEngine.prototype.init = function() {
alert("Error calling tml2html"); // SMELL: better error handling
});

/*
self.on("BeforeSetContent", function(ev) {
if (foswiki.getPreference("NatEditPlugin").ImagePluginEnabled) {
var paramsRegex = /(?:(\w+?)=)?"(.*?)"/g;
Expand Down Expand Up @@ -103,6 +104,7 @@ TinyMCEEngine.prototype.init = function() {
}
});
self.on("GetContent", function() { console.log("got GetContent event"); });
*/
};

tinymce.init(self.opts.tinymce);
Expand Down Expand Up @@ -428,6 +430,96 @@ TinyMCEEngine.prototype.insertTable = function(opts) {
self.insert(table);
};

/***************************************************************************
* insert a link
* opts is a hash of params that can have either of two forms:
*
* insert a link to a topic:
* {
* web: "TheWeb",
* topic: "TheTopic",
* text: "the link text" (optional)
* }
*
* insert an external link:
* {
* url: "http://...",
* text: "the link text" (optional)
* }
*
* insert an attachment link:
* {
* web: "TheWeb",
* topic: "TheTopic",
* file: "TheAttachment.jpg",
* text: "the link text" (optional)
* }
*/
TinyMCEEngine.prototype.insertLink = function(opts) {
var self = this, markup, link;

//console.log("called insertLink",opts);

if (typeof(opts.url) !== 'undefined') {
if (opts.url === '') {
return; // nop
}

if (typeof(opts.text) !== 'undefined' && opts.text !== '') {
markup = "<a href='"+opts.url+"'>"+opts.text+"</a>";
} else {
markup = "<a href='"+opts.url+"'>"+opts.url+"</a>";
}
} else if (typeof(opts.file) !== 'undefined') {
// attachment link

if (typeof(opts.web) === 'undefined' || opts.web === '' ||
typeof(opts.topic) === 'undefined' || opts.topic === '') {
return; // nop
}

link = '%PUBURLPATH%/'+opts.web+'/'+opts.topic+'/'+opts.file;

if (opts.file.match(/\.(bmp|png|jpe?g|gif|svg)$/i) && !opts.text) {
markup = "<img src='"+link+"' alt='"+opts.file+"' height='320' />";
} else {
// linking to an ordinary attachment

markup = "<a href='"+link+"'>";

if (typeof(opts.text) !== 'undefined' && opts.text !== '') {
markup += opts.text;
} else {
markup += opts.file;
}
markup += "</a>";
}

} else {
// wiki link

if (typeof(opts.topic) === 'undefined' || opts.topic === '') {
return; // nop
}

link = opts.web+'.'+opts.topic; // converted by WysiwygPlugin

markup = "<a href='"+link+"'>";

if (typeof(opts.text) !== 'undefined' && opts.text !== '') {
markup += opts.text;
} else {
markup += opts.topic;
}
markup += "</a>";
}

//console.log("markup=",markup);

self.remove();
self.insert(markup);
};

/*************************************************************************
* set the value of the editor
*/
Expand Down Expand Up @@ -484,7 +576,7 @@ TinyMCEEngine.defaults = {
menubar: false,
toolbar: false,
statusbar: false,
plugins: 'contextmenu table searchreplace paste lists link anchor hr legacyoutput image textpattern', // save autosave fullscreen anchor charmap code textcolor colorpicker
plugins: 'table searchreplace paste lists link anchor hr legacyoutput image textpattern', // save autosave fullscreen anchor charmap code textcolor colorpicker
table_toolbar : "tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol",
table_appearance_options: false,
table_advtab: false,
Expand All @@ -493,6 +585,11 @@ TinyMCEEngine.defaults = {
object_resizing: "img",
paste_data_images: true,
content_css: [],
style_formats_autohide: true,
removeformat: [{
selector: 'div,p,pre',
remove: 'all'
}],
formats: {
h1Markup: { block: "h1", toolbar: ".ui-natedit-h1" },
h2Markup: { block: "h2", toolbar: ".ui-natedit-h2" },
Expand Down

0 comments on commit 602136c

Please sign in to comment.