mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Add banner for binary tiddlers in edit mode
Makes it easier to add tags to a binary tiddler (eg a PDF).
This commit is contained in:
parent
bced7124e4
commit
a4294b55f0
@ -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
|
||||
|
64
core/modules/widgets/edit-binary.js
Normal file
64
core/modules/widgets/edit-binary.js
Normal file
@ -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;
|
||||
|
||||
})();
|
@ -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,
|
||||
|
8
core/ui/BinaryWarning.tid
Normal file
8
core/ui/BinaryWarning.tid
Normal file
@ -0,0 +1,8 @@
|
||||
title: $:/core/ui/BinaryWarning
|
||||
|
||||
\define lingo-base() $:/language/BinaryWarning/
|
||||
<div class="tw-binary-warning">
|
||||
|
||||
<<lingo Prompt>>
|
||||
|
||||
</div>
|
@ -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: <<colour alert-background>>;
|
||||
border: 1px solid <<colour alert-border>>;
|
||||
}
|
||||
|
||||
.tw-tiddler-frame input.tw-edit-texteditor {
|
||||
background-color: <<colour tiddler-editor-background>>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user