1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-24 16:06:58 +00:00

fix editor-preview button not focusing editor, two-cell-slider experiments

This commit is contained in:
BurningTreeC 2024-11-15 11:00:53 +01:00
parent 2e68b6f1a1
commit 40489a2fba
6 changed files with 34 additions and 24 deletions

View File

@ -106,6 +106,10 @@ function FramedEngine(options) {
this.iframeDoc.body.appendChild(this.domNode); this.iframeDoc.body.appendChild(this.domNode);
} }
FramedEngine.prototype.assignDomNodeClasses = function() {
this.iframeNode.className = this.widget.getAttribute("class","");
};
/* /*
Copy styles from the dummy text area to the textarea in the iframe Copy styles from the dummy text area to the textarea in the iframe
*/ */

View File

@ -220,7 +220,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
EditTextWidget.prototype.refresh = function(changedTiddlers) { EditTextWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(); var changedAttributes = this.computeAttributes();
// Completely rerender if any of our attributes have changed // Completely rerender if any of our attributes have changed
if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || changedAttributes["class"] || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE] || changedTiddlers["$:/palette"] || changedAttributes.disabled || changedAttributes.fileDrop) { if(changedAttributes.tiddler || changedAttributes.field || changedAttributes.index || changedAttributes["default"] || (changedAttributes["class"] && !this.engine.assignDomNodeClasses) || changedAttributes.placeholder || changedAttributes.size || changedAttributes.autoHeight || changedAttributes.minHeight || changedAttributes.focusPopup || changedAttributes.rows || changedAttributes.tabindex || changedAttributes.cancelPopups || changedAttributes.inputActions || changedAttributes.refreshTitle || changedAttributes.autocomplete || changedTiddlers[HEIGHT_MODE_TITLE] || changedTiddlers[ENABLE_TOOLBAR_TITLE] || changedTiddlers["$:/palette"] || changedAttributes.disabled || changedAttributes.fileDrop) {
this.refreshSelf(); this.refreshSelf();
return true; return true;
} else if (changedTiddlers[this.editRefreshTitle]) { } else if (changedTiddlers[this.editRefreshTitle]) {
@ -229,6 +229,9 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) {
var editInfo = this.getEditInfo(); var editInfo = this.getEditInfo();
this.updateEditor(editInfo.value,editInfo.type); this.updateEditor(editInfo.value,editInfo.type);
} }
if(changedAttributes["class"] && this.engine.assignDomNodeClasses) {
this.engine.assignDomNodeClasses();
}
this.engine.fixHeight(); this.engine.fixHeight();
if(this.editShowToolbar) { if(this.editShowToolbar) {
return this.refreshChildren(changedTiddlers); return this.refreshChildren(changedTiddlers);

View File

@ -1,5 +1,7 @@
title: $:/core/ui/EditTemplate/body/default title: $:/core/ui/EditTemplate/body/default
\import $:/core/procedures/sliders
\function get.edit-preview-state() \function get.edit-preview-state()
[{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualified-preview-state>] +[get[text]] :else[[no]] [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[<qualified-preview-state>] +[get[text]] :else[[no]]
\end \end
@ -60,7 +62,6 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$
$variable="editor-preview-slider" $variable="editor-preview-slider"
class="tc-edit-texteditor-slider" class="tc-edit-texteditor-slider"
template="tp-tiddler-editor-preview" template="tp-tiddler-editor-preview"
sliderCondition=<<get.slider.condition>>
mode="inline" mode="inline"
padding="0px" padding="0px"
sliderWidth=<<get.theme.metric previewsliderwidth>> sliderWidth=<<get.theme.metric previewsliderwidth>>

View File

@ -10,6 +10,7 @@ code-body: yes
\function resizer.class() tc-main-slider \function resizer.class() tc-main-slider
\function set.throttling() yes \function set.throttling() yes
\function drag.direction.reverse() [<get.theme.option sidebarposition>match[left]then[yes]] :else[[no]] \function drag.direction.reverse() [<get.theme.option sidebarposition>match[left]then[yes]] :else[[no]]
\function get.slider.condition() [{$:/state/sidebar}!match[no]then[yes]]
\whitespace trim \whitespace trim
<%if [<get.theme.explicit.option sidebarresizer>match[show]] %> <%if [<get.theme.explicit.option sidebarresizer>match[show]] %>

View File

@ -371,7 +371,7 @@ title: $:/core/procedures/sidebar-resizer
\function get.template-right.style.flex-basis() [<sliderCondition>match[no]then[0%]] :else[[calc(]addsuffix<get.template-right.width>addsuffix[ - ]addsuffix<resizerWidthDivided>addsuffix[px)]] \function get.template-right.style.flex-basis() [<sliderCondition>match[no]then[0%]] :else[[calc(]addsuffix<get.template-right.width>addsuffix[ - ]addsuffix<resizerWidthDivided>addsuffix[px)]]
\procedure sidebar-resizer(templateLeft:"",templateRight:"",mode:"block",sliderCondition:"yes",eventCatcherClass:"",zIndexLeft:"") \procedure sidebar-resizer(templateLeft:"",templateRight:"",mode:"block",eventCatcherClass:"",zIndexLeft:"")
<$set name="resizerWidthDivided" value={{{ [<get.resizer.style.width>divide[2]] }}}> <$set name="resizerWidthDivided" value={{{ [<get.resizer.style.width>divide[2]] }}}>
@ -419,6 +419,7 @@ title: $:/core/procedures/sidebar-resizer
style.top="0" style.top="0"
style.left="0" style.left="0"
style.flex-basis=<<get.template-left.style.flex-basis>> style.flex-basis=<<get.template-left.style.flex-basis>>
style.width=<<get.template-left.style.flex-basis>>
style.z-index=<<zIndexLeft>> style.z-index=<<zIndexLeft>>
> >
@ -436,7 +437,7 @@ title: $:/core/procedures/sidebar-resizer
<% endif %> <% endif %>
<%if [<sliderCondition>match[yes]] %> <%if [<get.slider.condition>match[yes]] %>
<div <div
class=<<get.resizer.class>> class=<<get.resizer.class>>
@ -456,6 +457,7 @@ title: $:/core/procedures/sidebar-resizer
style.top="0" style.top="0"
style.left=<<get.template-right.style.left>> style.left=<<get.template-right.style.left>>
style.flex-basis=<<get.template-right.style.flex-basis>> style.flex-basis=<<get.template-right.style.flex-basis>>
style.width=<<get.template-right.style.flex-basis>>
> >
<%if [<templateRight>is[variable]] %> <%if [<templateRight>is[variable]] %>
@ -519,7 +521,7 @@ title: $:/core/procedures/sidebar-resizer
</$eventcatcher> </$eventcatcher>
<%if [<sliderCondition>match[yes]] %> <%if [<get.slider.condition>match[yes]] %>
<div <div
class=<<get.resizer.class>> class=<<get.resizer.class>>

View File

@ -1,11 +1,10 @@
title: $:/core/procedures/sliders title: $:/core/procedures/sliders
tags: $:/tags/Global
code-body: yes code-body: yes
\procedure editor-preview-slider(class:"",width:"100%", \procedure editor-preview-slider(class:"",width:"100%",
minHeight:"10px",template:"", minHeight:"10px",template:"",
mode:"block",sliderWidth:"12px", mode:"block",sliderWidth:"12px",
padding:"12px",sliderCondition:"yes", padding:"12px",
leftMinWidth:"0%",rightMinWidth:"0%") leftMinWidth:"0%",rightMinWidth:"0%")
\import $:/core/procedures/sidebar-resizer \import $:/core/procedures/sidebar-resizer
@ -35,7 +34,6 @@ leftMinWidth:"0%",rightMinWidth:"0%")
<$transclude <$transclude
$variable="editor-resizer" $variable="editor-resizer"
template=<<template>> template=<<template>>
sliderCondition=<<sliderCondition>>
eventCatcherClass="tc-editor-preview-eventcatcher" eventCatcherClass="tc-editor-preview-eventcatcher"
mode=<<mode>> mode=<<mode>>
/> />
@ -43,20 +41,22 @@ leftMinWidth:"0%",rightMinWidth:"0%")
</$let> </$let>
\end \end
\procedure two-cell-slider(width:"100%",minHeight:"10px", \procedure two-cell-slider(
templateLeft:"",templateRight:"", templateLeft:"",templateRight:"",
width:"100%",minHeight:"22px",
mode:"block",sliderWidth:"12px", mode:"block",sliderWidth:"12px",
padding:"12px",sliderCondition:"yes", padding:"12px",leftMinWidth:"100px",
leftMinWidth:"100px",rightMinWidth:"100px") rightMinWidth:"100px",id:"1")
\import $:/core/procedures/sidebar-resizer \import $:/core/procedures/sidebar-resizer
\function get.resizer.style.position() absolute \function get.resizer.style.position() absolute
\function get.template-right.width() [<sidebarWidthTiddler>get[text]] :else[[50%]] \function get.template-right.width() [<sidebarWidthTiddler>get[text]] :else[[50%]]
\function get.resizer.style.left() [[calc(100% - ]addsuffix<get.template-right.width>addsuffix[)]] \function get.resizer.style.left() [[clamp(]addsuffix<leftMinWidth>addsuffix[,]addsuffix[calc(100% - ]addsuffix<get.template-right.width>addsuffix[),calc(100% - ]addsuffix<rightMinWidth>addsuffix[))]]
\function get.resizer.style.width() [<sliderWidth>] \function get.resizer.style.width() [<sliderWidth>]
\function set.throttling() no \function set.throttling() no
\function get.left.minwidth() [<leftMinWidth>] \function get.modulo.minwidth(width) [<id>remainder[3]match[1]then<width>multiply[2]else<width>multiply[1]] :map[get.value.metric<width>addprefix<currentTiddler>]
\function get.right.minwidth() [<rightMinWidth>] \function get.left.minwidth() [get.modulo.minwidth<leftMinWidth>]
\function get.right.minwidth() [get.modulo.minwidth<rightMinWidth>]
\function drag.direction.reverse() no \function drag.direction.reverse() no
\whitespace trim \whitespace trim
@ -75,21 +75,20 @@ leftMinWidth:"100px",rightMinWidth:"100px")
tv-set-storywidth-storyright="no" tv-set-storywidth-storyright="no"
tv-set-sidebarwidth="yes" tv-set-sidebarwidth="yes"
tv-set-centralised="no" tv-set-centralised="no"
storyLeftTiddler={{{ [<storyLeftTiddler>!is[blank]] :else[<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storyleft-]] }}} storyLeftTiddler={{{ [<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storyleft-]addsuffix<id>] }}}
storyRightTiddler={{{ [<storyRightTiddler>!is[blank]] :else[<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storyright-]] }}} storyRightTiddler={{{ [<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storyright-]addsuffix<id>] }}}
sidebarWidthTiddler={{{ [<sidebarWidthTiddler>!is[blank]] :else[<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/rightwidth-]] }}} sidebarWidthTiddler={{{ [<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/rightwidth-]addsuffix<id>] }}}
tiddlerWidthTiddler={{{ [<tiddlerWidthTiddler>!is[blank]] :else[<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/tiddlerwidth-]] }}} tiddlerWidthTiddler={{{ [<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/tiddlerwidth-]addsuffix<id>] }}}
storyWidthTiddler={{{ [<storyWidthTiddler>!is[blank]] :else[<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storywidth-]] }}} storyWidthTiddler={{{ [<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storywidth-]addsuffix<id>] }}}
storyMinWidthTiddler={{{ [<storyMinWidthTiddler>!is[blank]] :else[<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storywidth-]] }}} storyMinWidthTiddler={{{ [<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storywidth-]addsuffix<id>] }}}
sidebarMinWidthTiddler={{{ [<sidebarMinWidthTiddler>!is[blank]] :else[<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storyminwidth-]] }}} sidebarMinWidthTiddler={{{ [<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storyminwidth-]addsuffix<id>] }}}
storyPaddingLeftTiddler={{{ [<storyPaddingLeftTiddler>!is[blank]] :else[<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storypaddingleft-]] }}} storyPaddingLeftTiddler={{{ [<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storypaddingleft-]addsuffix<id>] }}}
storyPaddingRightTiddler={{{ [<storyPaddingRightTiddler>!is[blank]] :else[<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storypaddingright-]] }}}> storyPaddingRightTiddler={{{ [<qualify>addsuffix<currentTiddler>sha256[]addprefix[$:/state/resizer/storypaddingright-]addsuffix<id>] }}}>
<$transclude <$transclude
$variable="sidebar-resizer" $variable="sidebar-resizer"
templateLeft=<<templateLeft>> templateLeft=<<templateLeft>>
templateRight=<<templateRight>> templateRight=<<templateRight>>
sliderCondition=<<sliderCondition>>
mode=<<mode>> mode=<<mode>>
/> />