From 40489a2fbae95e34fc7e154d6e9435a0d284ffed Mon Sep 17 00:00:00 2001 From: BurningTreeC Date: Fri, 15 Nov 2024 11:00:53 +0100 Subject: [PATCH] fix editor-preview button not focusing editor, two-cell-slider experiments --- core/modules/editor/engines/framed.js | 4 +++ core/modules/editor/factory.js | 5 +++- core/ui/EditTemplate/body/default.tid | 3 +- core/ui/PageTemplate/sidebar-resizer.tid | 1 + core/wiki/macros/sidebar-resizer.tid | 8 +++-- core/wiki/macros/sliders.tid | 37 ++++++++++++------------ 6 files changed, 34 insertions(+), 24 deletions(-) diff --git a/core/modules/editor/engines/framed.js b/core/modules/editor/engines/framed.js index 34d11dec7..a2e784df7 100644 --- a/core/modules/editor/engines/framed.js +++ b/core/modules/editor/engines/framed.js @@ -106,6 +106,10 @@ function FramedEngine(options) { 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 */ diff --git a/core/modules/editor/factory.js b/core/modules/editor/factory.js index 6157ec67f..251196fc9 100644 --- a/core/modules/editor/factory.js +++ b/core/modules/editor/factory.js @@ -220,7 +220,7 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { EditTextWidget.prototype.refresh = function(changedTiddlers) { var changedAttributes = this.computeAttributes(); // 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(); return true; } else if (changedTiddlers[this.editRefreshTitle]) { @@ -229,6 +229,9 @@ function editTextWidgetFactory(toolbarEngine,nonToolbarEngine) { var editInfo = this.getEditInfo(); this.updateEditor(editInfo.value,editInfo.type); } + if(changedAttributes["class"] && this.engine.assignDomNodeClasses) { + this.engine.assignDomNodeClasses(); + } this.engine.fixHeight(); if(this.editShowToolbar) { return this.refreshChildren(changedTiddlers); diff --git a/core/ui/EditTemplate/body/default.tid b/core/ui/EditTemplate/body/default.tid index 504d6f2a0..c0f61047e 100644 --- a/core/ui/EditTemplate/body/default.tid +++ b/core/ui/EditTemplate/body/default.tid @@ -1,5 +1,7 @@ title: $:/core/ui/EditTemplate/body/default +\import $:/core/procedures/sliders + \function get.edit-preview-state() [{$:/config/ShowEditPreview/PerTiddler}!match[yes]then[$:/state/showeditpreview]] :else[] +[get[text]] :else[[no]] \end @@ -60,7 +62,6 @@ $:/config/EditorToolbarButtons/Visibility/$(currentTiddler)$ $variable="editor-preview-slider" class="tc-edit-texteditor-slider" template="tp-tiddler-editor-preview" - sliderCondition=<> mode="inline" padding="0px" sliderWidth=<> diff --git a/core/ui/PageTemplate/sidebar-resizer.tid b/core/ui/PageTemplate/sidebar-resizer.tid index 458af4170..18973a9af 100644 --- a/core/ui/PageTemplate/sidebar-resizer.tid +++ b/core/ui/PageTemplate/sidebar-resizer.tid @@ -10,6 +10,7 @@ code-body: yes \function resizer.class() tc-main-slider \function set.throttling() yes \function drag.direction.reverse() [match[left]then[yes]] :else[[no]] +\function get.slider.condition() [{$:/state/sidebar}!match[no]then[yes]] \whitespace trim <%if [match[show]] %> diff --git a/core/wiki/macros/sidebar-resizer.tid b/core/wiki/macros/sidebar-resizer.tid index e40e1931e..4965e18bb 100644 --- a/core/wiki/macros/sidebar-resizer.tid +++ b/core/wiki/macros/sidebar-resizer.tid @@ -371,7 +371,7 @@ title: $:/core/procedures/sidebar-resizer \function get.template-right.style.flex-basis() [match[no]then[0%]] :else[[calc(]addsuffixaddsuffix[ - ]addsuffixaddsuffix[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={{{ [divide[2]] }}}> @@ -419,6 +419,7 @@ title: $:/core/procedures/sidebar-resizer style.top="0" style.left="0" style.flex-basis=<> + style.width=<> style.z-index=<> > @@ -436,7 +437,7 @@ title: $:/core/procedures/sidebar-resizer <% endif %> - <%if [match[yes]] %> + <%if [match[yes]] %>
> @@ -456,6 +457,7 @@ title: $:/core/procedures/sidebar-resizer style.top="0" style.left=<> style.flex-basis=<> + style.width=<> > <%if [is[variable]] %> @@ -519,7 +521,7 @@ title: $:/core/procedures/sidebar-resizer - <%if [match[yes]] %> + <%if [match[yes]] %>
> diff --git a/core/wiki/macros/sliders.tid b/core/wiki/macros/sliders.tid index dbfb0f947..a54564a4d 100644 --- a/core/wiki/macros/sliders.tid +++ b/core/wiki/macros/sliders.tid @@ -1,11 +1,10 @@ title: $:/core/procedures/sliders -tags: $:/tags/Global code-body: yes \procedure editor-preview-slider(class:"",width:"100%", minHeight:"10px",template:"", mode:"block",sliderWidth:"12px", -padding:"12px",sliderCondition:"yes", +padding:"12px", leftMinWidth:"0%",rightMinWidth:"0%") \import $:/core/procedures/sidebar-resizer @@ -35,7 +34,6 @@ leftMinWidth:"0%",rightMinWidth:"0%") <$transclude $variable="editor-resizer" template=<