diff --git a/core/language/en-GB/Misc.multids b/core/language/en-GB/Misc.multids index 0890424a5..a58bf5bd5 100644 --- a/core/language/en-GB/Misc.multids +++ b/core/language/en-GB/Misc.multids @@ -1,5 +1,6 @@ title: $:/language/ +BinaryWarning/Prompt: This tiddler contains binary data ClassicWarning/Hint: This tiddler is written in TiddlyWiki Classic wiki text format, which is not fully compatible with TiddlyWiki version 5. See http://tiddlywiki.com/static/Upgrading.html for more details. ClassicWarning/Upgrade/Caption: upgrade CloseAll/Button: close all diff --git a/core/modules/widgets/edit-binary.js b/core/modules/widgets/edit-binary.js new file mode 100644 index 000000000..cf2e2ad2c --- /dev/null +++ b/core/modules/widgets/edit-binary.js @@ -0,0 +1,64 @@ +/*\ +title: $:/core/modules/widgets/edit-binary.js +type: application/javascript +module-type: widget + +Edit-binary widget; placeholder for editing binary tiddlers + +\*/ +(function(){ + +/*jslint node: true, browser: true */ +/*global $tw: false */ +"use strict"; + +var BINARY_WARNING_MESSAGE = "$:/core/ui/BinaryWarning"; + +var Widget = require("$:/core/modules/widgets/widget.js").widget; + +var EditBinaryWidget = function(parseTreeNode,options) { + this.initialise(parseTreeNode,options); +}; + +/* +Inherit from the base widget class +*/ +EditBinaryWidget.prototype = new Widget(); + +/* +Render this widget into the DOM +*/ +EditBinaryWidget.prototype.render = function(parent,nextSibling) { + var self = this; + // Save the parent dom node + this.parentDomNode = parent; + // Compute our attributes + this.computeAttributes(); + // Execute our logic + this.execute(); + this.renderChildren(parent,nextSibling); +}; + +/* +Compute the internal state of the widget +*/ +EditBinaryWidget.prototype.execute = function() { + // Construct the child widgets + this.makeChildWidgets([{ + type: "transclude", + attributes: { + tiddler: {type: "string", value: BINARY_WARNING_MESSAGE} + } + }]); +}; + +/* +Refresh by refreshing our child widget +*/ +EditBinaryWidget.prototype.refresh = function(changedTiddlers) { + return this.refreshChildren(changedTiddlers); +}; + +exports["edit-binary"] = EditBinaryWidget; + +})(); diff --git a/core/modules/widgets/edit.js b/core/modules/widgets/edit.js index c5a7a4969..0782d5118 100644 --- a/core/modules/widgets/edit.js +++ b/core/modules/widgets/edit.js @@ -56,7 +56,15 @@ EditWidget.prototype.execute = function() { } type = type || "text/vnd.tiddlywiki"; // Choose the appropriate edit widget - var editorType = this.wiki.getTiddlerText(EDITOR_MAPPING_PREFIX + type) || "text"; + var editorType = this.wiki.getTiddlerText(EDITOR_MAPPING_PREFIX + type); + if(!editorType) { + var typeInfo = $tw.config.contentTypeInfo[type]; + if(typeInfo && typeInfo.encoding === "base64") { + editorType = "binary"; + } else { + editorType = "text"; + } + } // Make the child widgets this.makeChildWidgets([{ type: "edit-" + editorType, diff --git a/core/ui/BinaryWarning.tid b/core/ui/BinaryWarning.tid new file mode 100644 index 000000000..a2811ceda --- /dev/null +++ b/core/ui/BinaryWarning.tid @@ -0,0 +1,8 @@ +title: $:/core/ui/BinaryWarning + +\define lingo-base() $:/language/BinaryWarning/ +
+ +<> + +
diff --git a/themes/tiddlywiki/vanilla/base.tid b/themes/tiddlywiki/vanilla/base.tid index 8c7389881..bd13ea888 100644 --- a/themes/tiddlywiki/vanilla/base.tid +++ b/themes/tiddlywiki/vanilla/base.tid @@ -625,6 +625,15 @@ a.tw-tiddlylink-external:hover { margin: 4px 0 4px 0; } +.tw-tiddler-frame .tw-binary-warning { + width: 100%; + height: 5em; + text-align: center; + padding: 3em 3em 6em 3em; + background: <>; + border: 1px solid <>; +} + .tw-tiddler-frame input.tw-edit-texteditor { background-color: <>; }