Hi Steve,

long time no peep from me.

Here's a quick shot for your converter (also see attachment):

/*\
title: $:/plugins/tobibeer/convertable.js
type: application/javascript
module-type: widget

A widget to convert a pasted excel or google spreadsheet to a tiddlywiki 
table.

\*/
(function(){

/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";

var Widget = require("$:/core/modules/widgets/widget.js").widget;

var ConvertableWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
};

ConvertableWidget.prototype = new Widget();

ConvertableWidget.prototype.render = function(parent,nextSibling) {
this.parentDomNode = parent;
this.computeAttributes();
var textNode = this.document.createElement("textarea"),
buttonNode = this.document.createElement("button");
textNode.style.width = "100%";
buttonNode.style.clear = "left";
buttonNode.innerHTML="Convert to Wikitext";
buttonNode.addEventListener("click",function (event) {
textNode.value = textNode.value.replace(/^|$|\t/gm, '|');
});
textNode.value = this.getAttribute("text") || "";
this.domNodes.push(textNode);
parent.insertBefore(textNode,nextSibling);
this.domNodes.push(buttonNode);
parent.insertBefore(buttonNode,nextSibling);
};

ConvertableWidget.prototype.refresh = function(changedTiddlers) {
return false;
};

exports.convertable = ConvertableWidget;

})();

Will publish later.

Best wishes,

Tobias.

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/1beb453a-ea8a-4d4d-a766-1e5b8df87ec7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Attachment: tobibeer-convertable.js.tid
Description: Binary data

Reply via email to