Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display: grid for toolbar, editor and preview - using inline styles #7788

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions core/modules/editor/engines/framed.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function FramedEngine(options) {
this.widget.domNodes.push(this.dummyTextArea);
// Create the iframe
this.iframeNode = this.widget.document.createElement("iframe");
$tw.utils.setStyle(this.iframeNode,[
{"grid-area": "editor"}
]);
this.parentNode.insertBefore(this.iframeNode,this.nextSibling);
this.iframeDoc = this.iframeNode.contentWindow.document;
// (Firefox requires us to put some empty content in the iframe)
Expand Down
3 changes: 3 additions & 0 deletions core/modules/editor/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
if(this.editShowToolbar) {
this.toolbarNode = this.document.createElement("div");
this.toolbarNode.className = "tc-editor-toolbar";
$tw.utils.setStyle(this.toolbarNode,[
{"grid-area": "toolbar"}
]);
parent.insertBefore(this.toolbarNode,nextSibling);
this.renderChildren(this.toolbarNode,null);
this.domNodes.push(this.toolbarNode);
Expand Down
6 changes: 6 additions & 0 deletions core/modules/widgets/edit-bitmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ EditBitmapWidget.prototype.render = function(parent,nextSibling) {
this.execute();
// Create the wrapper for the toolbar and render its content
this.toolbarNode = this.document.createElement("div");
$tw.utils.setStyle(this.toolbarNode,[
{"grid-area": "toolbar"}
]);
this.toolbarNode.className = "tc-editor-toolbar";
parent.insertBefore(this.toolbarNode,nextSibling);
this.domNodes.push(this.toolbarNode);
Expand All @@ -75,6 +78,9 @@ EditBitmapWidget.prototype.render = function(parent,nextSibling) {
// Set the width and height variables
this.setVariable("tv-bitmap-editor-width",this.canvasDomNode.width + "px");
this.setVariable("tv-bitmap-editor-height",this.canvasDomNode.height + "px");
$tw.utils.setStyle(this.canvasDomNode,[
{"grid-area": "editor"}
]);
// Render toolbar child widgets
this.renderChildren(this.toolbarNode,null);
// // Insert the elements into the DOM
Expand Down
20 changes: 19 additions & 1 deletion core/ui/EditTemplate/body/default.tid
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,31 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
<$action-popup $state=<<importState>> $coords="(0,0,0,0)" $floating="yes"/>
\end

\procedure display-preview-grid-styles()
display: grid;
grid-template-areas:
"toolbar toolbar"
"editor preview";
grid-template-columns: 1fr 1fr;
grid-template-rows: auto 1fr;
\end

\procedure display-no-preview-grid-styles()
display: grid;
grid-template-areas:
"toolbar"
"editor";
grid-template-columns: 1fr;
grid-template-rows: auto 1fr;
\end

\whitespace trim
<$let
importTitle=<<qualify $:/ImportImage>>
importState=<<qualify $:/state/ImportImage>> >
<$dropzone importTitle=<<importTitle>> autoOpenOnImport="no" contentTypesFilter={{$:/config/Editor/ImportContentTypesFilter}} class="tc-dropzone-editor" enable={{{ [{$:/config/DragAndDrop/Enable}match[no]] :else[subfilter{$:/config/Editor/EnableImportFilter}then[yes]else[no]] }}} filesOnly="yes" actions=<<importFileActions>> >
<div>
<div class={{{ [function[edit-preview-state]match[yes]then[tc-tiddler-preview]] +[join[ ]] }}}>
<div class={{{ [function[edit-preview-state]match[yes]then[tc-tiddler-preview]] +[join[ ]] }}} style={{{ [function[edit-preview-state]match[yes]then<display-preview-grid-styles>else<display-no-preview-grid-styles>] }}}>

<$transclude tiddler="$:/core/ui/EditTemplate/body/editor" mode="inline"/>

Expand Down
10 changes: 3 additions & 7 deletions themes/tiddlywiki/vanilla/base.tid
Original file line number Diff line number Diff line change
Expand Up @@ -1577,8 +1577,8 @@ html body.tc-body.tc-single-tiddler-window {
}

.tc-tiddler-preview-preview {
float: right;
width: 49%;
overflow-wrap: anywhere;
word-break: normal;
border: 1px solid <<colour tiddler-editor-border>>;
margin: 4px 0 3px 3px;
padding: 3px 3px 3px 3px;
Expand All @@ -1593,12 +1593,8 @@ html body.tc-body.tc-single-tiddler-window {

""">>

.tc-tiddler-frame .tc-tiddler-preview .tc-edit-texteditor {
width: 49%;
}

.tc-tiddler-frame .tc-tiddler-preview canvas.tc-edit-bitmapeditor {
max-width: 49%;
max-width: 100%;
}

.tc-edit-fields {
Expand Down
Loading