File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -167,10 +167,34 @@ function handleEditSession() {
167167 $toggleEditorButton . on ( 'click' , toggleEditor ) ;
168168}
169169
170+ /**
171+ * when the editor switch button moves out of the view-port, the menubar gets a class
172+ * @see https://codepen.io/hey-nick/pen/mLpmMV
173+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API
174+ */
175+
176+ function menubar ( ) {
177+ const editorswitch = document . querySelector ( 'button[name=prosemirror]' ) ;
178+ const menubar = document . querySelector ( '#prosemirror__editor div.menubar' ) ;
179+ const observer = new IntersectionObserver (
180+ ( [ e ] ) => {
181+ return menubar . classList . toggle ( 'prosemirror-menubar-fixed' , e . intersectionRatio !== 1 ) ;
182+ } ,
183+ {
184+ root : null ,
185+ threshold : [ 0 , 1 ]
186+ }
187+ ) ;
188+ observer . observe ( editorswitch ) ;
189+ }
190+
191+
170192jQuery ( function ( ) {
171193 initializeProsemirror ( ) ;
172194 window . proseMirrorIsActive = false ;
173195
196+ jQuery ( menubar ) ;
197+
174198 if ( jQuery ( '#dw__editform' ) . find ( '[name=prosemirror_json]' ) . length ) {
175199 handleEditSession ( ) ;
176200 }
Original file line number Diff line number Diff line change 8585 display : block ;
8686
8787 .menubar {
88- position : sticky ;
89- top : 0 ; // Users/Theme developers can override this to stick it below a sticky header
9088 margin-bottom : 0.5rem ;
9189 border : @border-style ;
9290 border-radius : @border-radius ;
91+
92+ & .prosemirror-menubar-fixed {
93+ position : fixed ;
94+ top : 0 ;
95+ border : 3px solid @ini_border ;
96+ padding : 1em ;
97+ }
9398 }
9499}
95100
You can’t perform that action at this time.
0 commit comments