1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-08 00:10:27 +00:00

different classes for text-editor and bitmap-editor

This commit is contained in:
BurningTreeC 2024-11-17 08:19:02 +01:00
parent fc8396273e
commit 04b9e5ba4c
5 changed files with 24 additions and 5 deletions

View File

@ -54,10 +54,14 @@ EditBitmapWidget.prototype.render = function(parent,nextSibling) {
this.toolbarNode.className = "tc-editor-toolbar";
parent.insertBefore(this.toolbarNode,nextSibling);
this.domNodes.push(this.toolbarNode);
var classes = this.getAttribute("class","").split(" ");
if(classes.indexOf("tc-edit-bitmapeditor") === -1) {
classes.push("tc-edit-bitmapeditor");
}
// Create the on-screen canvas
this.canvasDomNode = $tw.utils.domMaker("canvas",{
document: this.document,
"class":"tc-edit-bitmapeditor",
"class": classes.join(" "),
eventListeners: [{
name: "touchstart", handlerObject: this, handlerMethod: "handleTouchStartEvent"
},{
@ -90,6 +94,14 @@ EditBitmapWidget.prototype.render = function(parent,nextSibling) {
]);
};
EditBitmapWidget.prototype.assignDomNodeClasses = function() {
var classes = this.getAttribute("class","").split(" ");
if(classes.indexOf("tc-edit-bitmapeditor") === -1) {
classes.push("tc-edit-bitmapeditor");
}
this.canvasDomNode.className = classes.join(" ");
};
/*
Handle an edit bitmap operation message from the toolbar
*/
@ -115,6 +127,10 @@ EditBitmapWidget.prototype.execute = function() {
Just refresh the toolbar
*/
EditBitmapWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes["class"]) {
this.assignDomNodeClasses();
}
return this.refreshChildren(changedTiddlers);
};

View File

@ -5,7 +5,7 @@ title: $:/core/ui/EditTemplate/body/editor
<$edit
field="text"
class=<<get.tc-edit-texteditor.class>>
class=<<get.tc-editor.class>>
placeholder={{$:/language/EditTemplate/Body/Placeholder}}
tabindex={{$:/config/EditTabIndex}}
focus={{{ [{$:/config/AutoFocus}match[text]then[true]] ~[[false]] }}}

View File

@ -6,7 +6,7 @@ title: $:/core/ui/EditTemplate/body/default
[{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualified-preview-state>] +[get[text]] :else[[no]]
\end
\function get.tc-edit-texteditor.class() tc-edit-texteditor tc-edit-texteditor-body [<get.edit-preview-state>match[yes]then<identifier>addprefix[tc-edit-texteditor-identified-]] +[join[ ]]
\function get.tc-editor.class() [{!!type}is[blank]then[tc-edit-texteditor tc-edit-texteditor-body]] [{!!type}is[blank]then<get.edit-preview-state>match[yes]then<identifier>addprefix[tc-edit-texteditor-identified-]] [{!!type}addprefix[$:/config/EditorTypeMappings/]get[text]!match[bitmap]then[tc-edit-texteditor tc-edit-texteditor-body]] [{!!type}addprefix[$:/config/EditorTypeMappings/]get[text]!match[bitmap]then<get.edit-preview-state>match[yes]then<identifier>addprefix[tc-edit-texteditor-identified-]] [{!!type}addprefix[$:/config/EditorTypeMappings/]get[text]match[bitmap]then[tc-edit-bitmapeditor tc-edit-bitmapeditor-body]] [{!!type}addprefix[$:/config/EditorTypeMappings/]get[text]match[bitmap]then<get.edit-preview-state>match[yes]then<identifier>addprefix[tc-edit-bitmapeditor-identified-]] +[join[ ]]
\function get.tc-tiddler-preview-preview.class() tc-tiddler-preview-preview [<identifier>addprefix[tc-tiddler-preview-preview-identified-]] +[join[ ]]

View File

@ -1775,6 +1775,7 @@ html body.tc-body.tc-single-tiddler-window {
.tc-tiddler-frame .tc-tiddler-editor.tc-tiddler-preview-hidden canvas.tc-edit-bitmapeditor {
grid-area: editor;
max-width: 100%;
z-index: 1;
}
.tc-edit-fields {

View File

@ -183,14 +183,16 @@ code-body: yes
.tc-tiddler-frame iframe[class*="tc-edit-texteditor-identified-"].tc-edit-texteditor,
.tc-tiddler-frame textarea[class*="tc-edit-texteditor-identified-"].tc-edit-texteditor,
.tc-tiddler-frame div[class*="tc-edit-texteditor-identified-"].tc-edit-texteditor {
.tc-tiddler-frame div[class*="tc-edit-texteditor-identified-"].tc-edit-texteditor,
.tc-tiddler-frame canvas[class*="tc-edit-bitmapeditor-identified-"].tc-edit-bitmapeditor {
width: calc(100% - <<get.theme.metric previewsliderwidth>>);
min-width: 0px;
}
.tc-tiddler-frame iframe[class*="tc-edit-texteditor-identified-"].tc-edit-texteditor + .tc-tiddler-preview-preview,
.tc-tiddler-frame textarea[class*="tc-edit-texteditor-identified-"].tc-edit-texteditor + .tc-tiddler-preview-preview,
.tc-tiddler-frame div[class*="tc-edit-texteditor-identified-"].tc-edit-texteditor + .tc-tiddler-preview-preview {
.tc-tiddler-frame div[class*="tc-edit-texteditor-identified-"].tc-edit-texteditor + .tc-tiddler-preview-preview,
.tc-tiddler-frame canvas[class*="tc-edit-bitmapeditor-identified-"].tc-edit-bitmapeditor + .tc-tiddler-preview-preview {
min-width: 0px;
}