5
5
* SPDX-License-Identifier: MIT
6
6
********************************************************************************/
7
7
import observer from '@cocreate/observer' ;
8
- import crud from '@cocreate/crud-client' ;
8
+ // import crud from '@cocreate/crud-client';
9
9
import localStorage from '@cocreate/local-storage' ;
10
10
11
11
const themes = [ "light" , "dark" ] ;
@@ -42,6 +42,12 @@ function init(linkTag) {
42
42
43
43
if ( parse == 'true' ) {
44
44
parseLinkCSS ( ) ;
45
+ linkTag . getValue = ( ) => {
46
+ const onlyUnique = ( value , index , self ) => {
47
+ return self . indexOf ( value ) === index ;
48
+ } ;
49
+ return parsedCSS . concat ( linkCSS ) . filter ( onlyUnique )
50
+ }
45
51
let elements = document . querySelectorAll ( "[class]" ) ;
46
52
initElements ( elements ) ;
47
53
observerInit ( ) ;
@@ -260,7 +266,8 @@ function addNewRules() {
260
266
parsedCSS . splice ( low , 0 , rule ) ;
261
267
}
262
268
if ( tempStyleList . length > 0 )
263
- save ( ) ;
269
+ if ( linkTag . save )
270
+ linkTag . save ( ) ;
264
271
tempStyleList = [ ] ;
265
272
}
266
273
@@ -269,13 +276,14 @@ function save() {
269
276
if ( linkTag && linkTag . hasAttribute ( 'object' ) && linkTag . getAttribute ( 'save' ) != 'false' ) {
270
277
clearTimeout ( delayTimer ) ;
271
278
delayTimer = setTimeout ( function ( ) {
272
- const onlyUnique = ( value , index , self ) => {
273
- return self . indexOf ( value ) === index ;
274
- } ;
275
-
276
- let css = parsedCSS . concat ( linkCSS ) . filter ( onlyUnique ) ;
277
- crud . save ( linkTag , css . join ( '\r\n' ) ) ;
278
- } , 3000 ) ;
279
+ linkTag . save ( ) ;
280
+ // const onlyUnique = (value, index, self) => {
281
+ // return self.indexOf(value) === index;
282
+ // };
283
+
284
+ // let css = parsedCSS.concat(linkCSS).filter(onlyUnique);
285
+ // crud.save(linkTag, css.join('\r\n'));
286
+ } , 5000 ) ;
279
287
}
280
288
}
281
289
0 commit comments