|
From: <var...@us...> - 2020-12-10 16:34:10
|
Revision: 10177
http://sourceforge.net/p/phpwiki/code/10177
Author: vargenau
Date: 2020-12-10 16:34:03 +0000 (Thu, 10 Dec 2020)
Log Message:
-----------
Add new button in Edit Toolbar: convert Tab Separated Values to Wikicreole table
Modified Paths:
--------------
trunk/lib/editpage.php
trunk/pgsrc/Help%2FWikicreoleTablePlugin
trunk/pgsrc/ReleaseNotes
trunk/themes/default/toolbar.js
Added Paths:
-----------
trunk/themes/default/images/ed_tab_to_table.png
Modified: trunk/lib/editpage.php
===================================================================
--- trunk/lib/editpage.php 2020-12-04 17:21:15 UTC (rev 10176)
+++ trunk/lib/editpage.php 2020-12-10 16:34:03 UTC (rev 10177)
@@ -766,6 +766,11 @@
'alt' => _('Sample table'),
'title' => _('Sample table'),
'onclick' => 'insertTags("\n{| class=\"bordered\"\n|+ This is the table caption\n|-\n! Header A !! Header B !! Header C\n|-\n| Cell A1 || Cell B1 || Cell C1\n|-\n| Cell A2 || Cell B2 || Cell C2\n|-\n| Cell A3 || Cell B3 || Cell C3\n|}\n","",""); return true;')));
+ $toolbar->pushContent(HTML::img(array('src' => $WikiTheme->getImageURL("ed_tab_to_table.png"),
+ 'class' => 'toolbar',
+ 'alt' => _('Convert tab to table'),
+ 'title' => _('Convert tab to table'),
+ 'onclick' => "convert_tab_to_table();")));
$toolbar->pushContent(HTML::img(array('src' => $WikiTheme->getImageURL("ed_enumlist.png"),
'class' => 'toolbar',
'alt' => _('Enumeration'),
Modified: trunk/pgsrc/Help%2FWikicreoleTablePlugin
===================================================================
--- trunk/pgsrc/Help%2FWikicreoleTablePlugin 2020-12-04 17:21:15 UTC (rev 10176)
+++ trunk/pgsrc/Help%2FWikicreoleTablePlugin 2020-12-10 16:34:03 UTC (rev 10177)
@@ -1,4 +1,4 @@
-Date: Thu, 13 Oct 2016 15:09:28 +0000
+Date: Thu, 10 Dec 2020 15:18:32 +0000
Mime-Version: 1.0 (Produced by PhpWiki 1.6.0)
Content-Type: application/x-phpwiki;
pagename=Help%2FWikicreoleTablePlugin;
@@ -32,6 +32,21 @@
|Cell 1.1 |Two lines\\in Cell 1.2 |
|Cell 2.1 |Cell 2.2 |
+== Toolbar ==
+
+In the Edit Toolbar, the {{/themes/default/images/ed_tab_to_table.png}}
+icon allows to create a Wikicreole table from Tab Separated Values.
+
+You have to select the lines containing the Tab Separated Values and
+click on the icon. The resulting table will contain only normal cells,
+you can add headers if needed.
+
+This feature is expecially useful when you copy spreadsheet cells from
+Libreoffice Calc or Excel. If Excel cells contain multiple lines, the
+results will be wrong, you will need to manually convert these multiline
+cells. In Libreoffice Calc, there is no such issue, but the newlines
+will be lost.
+
== Author ==
* Marc-Etienne Vargenau, Alcatel-Lucent
Modified: trunk/pgsrc/ReleaseNotes
===================================================================
--- trunk/pgsrc/ReleaseNotes 2020-12-04 17:21:15 UTC (rev 10176)
+++ trunk/pgsrc/ReleaseNotes 2020-12-10 16:34:03 UTC (rev 10177)
@@ -1,4 +1,4 @@
-Date: Thu, 18 Apr 2019 21:22:30 +0000
+Date: Thu, 10 Dec 2020 15:11:30 +0000
Mime-Version: 1.0 (Produced by PhpWiki 1.6.0)
Content-Type: application/x-phpwiki;
pagename=ReleaseNotes;
@@ -8,7 +8,7 @@
<<CreateToc with_toclink||=1 headers||=1,2,3 width=300px position=right>>
-== 1.6.0 2019-0X-XX Marc-Etienne Vargenau ==
+== 1.6.0 2020-12-XX Marc-Etienne Vargenau ==
Major release:
* PHP 7 compatible
@@ -30,6 +30,7 @@
* Updated pgsrc pages in all languages
* Security fixes
* Adding SPDX-License-Identifier in PHP source files
+* Add new button in Edit Toolbar: convert Tab Separated Values to Wikicreole table
=== Bugs ===
* Make function IsSafeURL more strict
Added: trunk/themes/default/images/ed_tab_to_table.png
===================================================================
(Binary files differ)
Index: trunk/themes/default/images/ed_tab_to_table.png
===================================================================
--- trunk/themes/default/images/ed_tab_to_table.png 2020-12-04 17:21:15 UTC (rev 10176)
+++ trunk/themes/default/images/ed_tab_to_table.png 2020-12-10 16:34:03 UTC (rev 10177)
Property changes on: trunk/themes/default/images/ed_tab_to_table.png
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Modified: trunk/themes/default/toolbar.js
===================================================================
--- trunk/themes/default/toolbar.js 2020-12-04 17:21:15 UTC (rev 10176)
+++ trunk/themes/default/toolbar.js 2020-12-10 16:34:03 UTC (rev 10177)
@@ -137,6 +137,30 @@
if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();
}
+function convert_tab_to_table() {
+
+ // obtain the object reference for the <textarea>
+ var txtarea = document.getElementById('edit-content');
+ // obtain the index of the first selected character
+ var start = txtarea.selectionStart;
+ // obtain the index of the last selected character
+ var finish = txtarea.selectionEnd;
+ //obtain all Text
+ var allText = txtarea.value;
+ // obtain the selected text
+ var theSelection = allText.substring(start, finish);
+
+ // replace tabs by pipe surrounded by spaces
+ theSelection = theSelection.replace(/\t/g, ' | ');
+ // add pipe followed by space at beginning of lines
+ theSelection = theSelection.replace(/^/g, '| ');
+ theSelection = theSelection.replace(/\n/g, '\n| ');
+
+ // append the text
+ var newText=allText.substring(0, start)+theSelection+allText.substring(finish, allText.length);
+ txtarea.value=newText;
+}
+
// JS_SEARCHREPLACE from walterzorn.de
var f, sr_undo, replacewin, undo_buffer=new Array(), undo_buffer_index=0;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|