@@ -36,6 +36,17 @@ const historyCSSClassTemplate = `
36
36
}
37
37
` ;
38
38
39
+ const toolbarCSSClassTemplate = `
40
+ .sm-editor-scroller {
41
+ height: calc(100% - 46px);
42
+ overflow: auto;
43
+ }
44
+
45
+ .sm-toolbar-wrapper.active {
46
+ border-bottom: 1px solid #F7F7F7;
47
+ }
48
+ ` ;
49
+
39
50
export default class ShimoDocumentCabinet extends CabinetBase {
40
51
public editor : ShimoSDK . Document . Editor ;
41
52
private sdkCommon : any ;
@@ -82,8 +93,16 @@ export default class ShimoDocumentCabinet extends CabinetBase {
82
93
}
83
94
84
95
const toolbarContainer = this . getDom ( "toolbar-wrapper" ) ;
96
+ const editorScroller = this . getDom ( "sm-editor-scroller" ) ;
97
+ toolbarContainer . className += "sm-toolbar-wrapper" ;
98
+ editorScroller . className += "sm-editor-scroller" ;
85
99
86
- editor . render ( this . getDom ( "sm-editor" ) , {
100
+ const style = document . createElement ( "style" ) ;
101
+ style . type = "text/css" ;
102
+ style . innerHTML = historyCSSClassTemplate + toolbarCSSClassTemplate ;
103
+ document . getElementsByTagName ( "head" ) [ 0 ] . appendChild ( style ) ;
104
+
105
+ editor . render ( this . getDom ( "sm-editor" , editorScroller ) , {
87
106
readOnly : ! this . editorOptions . editable ,
88
107
id : this . user . id ,
89
108
localeConfig,
@@ -92,6 +111,17 @@ export default class ShimoDocumentCabinet extends CabinetBase {
92
111
} ,
93
112
} ) ;
94
113
editor . setContent ( this . file . content ) ;
114
+
115
+ editorScroller . addEventListener ( "scroll" , ( ) => {
116
+ setTimeout ( ( ) => {
117
+ if ( editorScroller . scrollTop === 0 ) {
118
+ toolbarContainer . classList . remove ( "active" ) ;
119
+ } else {
120
+ toolbarContainer . classList . add ( "active" ) ;
121
+ }
122
+ } , 0 ) ;
123
+ } ) ;
124
+
95
125
for ( const plugin of this . plugins ) {
96
126
this [ `init${ plugin } ` ] ( editor ) ;
97
127
}
@@ -137,11 +167,6 @@ export default class ShimoDocumentCabinet extends CabinetBase {
137
167
} ;
138
168
139
169
if ( ! document . querySelector ( "history-sidebar" ) ) {
140
- const style = document . createElement ( "style" ) ;
141
- style . type = "text/css" ;
142
- style . innerHTML = historyCSSClassTemplate ;
143
- document . getElementsByTagName ( "head" ) [ 0 ] . appendChild ( style ) ;
144
-
145
170
this . rootDom . insertAdjacentHTML ( "afterend" , historyContainerTemplate ) ;
146
171
}
147
172
0 commit comments