1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 10:07:19 +00:00

Take editor configuration from configuration tiddlers

This should enable @buggyj to add an html editor by including a
configuration tiddler in the plugin.
This commit is contained in:
Jermolene 2014-01-24 20:22:23 +00:00
parent 9522050aa7
commit 70a7321edd
7 changed files with 21 additions and 12 deletions

View File

@ -0,0 +1,3 @@
title: $:/config/EditorTypeMappings/image/gif
bitmap

View File

@ -0,0 +1,3 @@
title: $:/config/EditorTypeMappings/image/jpeg
bitmap

View File

@ -0,0 +1,3 @@
title: $:/config/EditorTypeMappings/image/jpg
bitmap

View File

@ -0,0 +1,3 @@
title: $:/config/EditorTypeMappings/image/png
bitmap

View File

@ -0,0 +1,3 @@
title: $:/config/EditorTypeMappings/image/x-icon
bitmap

View File

@ -0,0 +1,3 @@
title: $:/config/EditorTypeMappings/text/vnd.tiddlywiki
text

View File

@ -33,17 +33,8 @@ EditWidget.prototype.render = function(parent,nextSibling) {
this.renderChildren(parent,nextSibling);
};
// Mappings from content type to editor type
// TODO: This information should be configurable/extensible
var editorTypeMappings = {
"text/vnd.tiddlywiki": "text",
"image/svg+xml": "text",
"image/jpg": "bitmap",
"image/jpeg": "bitmap",
"image/gif": "bitmap",
"image/png": "bitmap",
"image/x-icon": "bitmap"
};
// Mappings from content type to editor type are stored in tiddlers with this prefix
var EDITOR_MAPPING_PREFIX = "$:/config/EditorTypeMappings/";
/*
Compute the internal state of the widget
@ -65,7 +56,7 @@ EditWidget.prototype.execute = function() {
}
type = type || "text/vnd.tiddlywiki";
// Choose the appropriate edit widget
var editorType = editorTypeMappings[type] || "text";
var editorType = this.wiki.getTiddlerText(EDITOR_MAPPING_PREFIX + type) || "text";
// Make the child widgets
this.makeChildWidgets([{
type: "edit-" + editorType,