File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
1
import React , { useState , useEffect } from 'react' ;
2
+ import debounce from 'lodash/debounce' ;
2
3
import Editor from './Editor' ;
3
4
import ElementInfo from './ElementInfo' ;
4
5
import Header from './Header' ;
@@ -30,6 +31,7 @@ function App() {
30
31
31
32
parsed . targets ?. forEach ( ( el ) => el . classList . add ( 'highlight' ) ) ;
32
33
state . save ( { html, js } ) ;
34
+ state . updateTitle ( parsed . expression ?. expression ) ;
33
35
34
36
return ( ) => {
35
37
parsed . targets ?. forEach ( ( el ) => el . classList . remove ( 'highlight' ) ) ;
Original file line number Diff line number Diff line change @@ -21,17 +21,28 @@ function load() {
21
21
. slice ( 1 )
22
22
. split ( '&' ) ;
23
23
24
- console . log ( 'load' , { htmlCompressed, jsCompressed } ) ;
25
-
26
24
return {
27
25
html : htmlCompressed && decompressFromEncodedURIComponent ( htmlCompressed ) ,
28
26
js : jsCompressed && decompressFromEncodedURIComponent ( jsCompressed ) ,
29
27
} ;
30
28
}
31
29
30
+ function updateTitle ( text ) {
31
+ const title = document . title . split ( ':' ) [ 0 ] ;
32
+
33
+ if ( ! text || text . length === 0 ) {
34
+ document . title = title ;
35
+ return ;
36
+ }
37
+
38
+ const suffix = text . replace ( / \s + / g, ' ' ) . substring ( 0 , 1000 ) . trim ( ) ;
39
+ document . title = title + ': ' + suffix ;
40
+ }
41
+
32
42
const state = {
33
43
save,
34
44
load,
45
+ updateTitle,
35
46
} ;
36
47
37
48
export default state ;
You can’t perform that action at this time.
0 commit comments