@cocreate/file 1.17.5 → 1.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/docs/index.html +328 -334
- package/package.json +1 -1
- package/prettier.config.js +16 -0
- package/src/client.js +61 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
# [1.19.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.18.0...v1.19.0) (2024-11-04)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* observer taget has been renamed to selector ([edccd76](https://github.com/CoCreate-app/CoCreate-file/commit/edccd7664b459fce740f7935514805aa3611047d))
|
|
7
|
+
* pretier.config.js and file formating ([a9af856](https://github.com/CoCreate-app/CoCreate-file/commit/a9af8567970d98ff6fcdba0b44d6a3f548423b42))
|
|
8
|
+
* return if typeof file not object ([d0463e4](https://github.com/CoCreate-app/CoCreate-file/commit/d0463e417a1b8abd91a2c5c6b2187a62dfb83a17))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* add prettier.config.js and format files ([1929bea](https://github.com/CoCreate-app/CoCreate-file/commit/1929beaf8e0279bc41a205bad83b88510cefa288))
|
|
14
|
+
* add prettier.config.js and format files ([499e705](https://github.com/CoCreate-app/CoCreate-file/commit/499e705ba9bae33afe94d8b109f00e395480b1fc))
|
|
15
|
+
|
|
16
|
+
# [1.18.0](https://github.com/CoCreate-app/CoCreate-file/compare/v1.17.5...v1.18.0) (2024-08-24)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* handle file.id when setFile() rendering. ([f9a561b](https://github.com/CoCreate-app/CoCreate-file/commit/f9a561b325ae0b8fe964b11d192c09ba2d144e4f))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
* import file from url ([c073276](https://github.com/CoCreate-app/CoCreate-file/commit/c073276894009a04fdf59e3bebabbd34bea3f55b))
|
|
27
|
+
|
|
1
28
|
## [1.17.5](https://github.com/CoCreate-app/CoCreate-file/compare/v1.17.4...v1.17.5) (2024-06-19)
|
|
2
29
|
|
|
3
30
|
|
package/docs/index.html
CHANGED
|
@@ -1,351 +1,345 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
7
|
+
<title>CoCreate-file Documentation | CoCreateJS</title>
|
|
8
|
+
<link
|
|
9
|
+
rel="icon"
|
|
10
|
+
type="image/png"
|
|
11
|
+
sizes="32x32"
|
|
12
|
+
href="https://cocreate.app/images/favicon.ico"
|
|
13
|
+
/>
|
|
14
|
+
<meta
|
|
15
|
+
name="description"
|
|
16
|
+
content="A convenient chain handler allows user to chain multiple components together. When one file is complete next one will start untill all file completed."
|
|
17
|
+
/>
|
|
18
|
+
<meta
|
|
19
|
+
name="keywords"
|
|
20
|
+
content="helper classes, utility classes, css framework, css library, inline style classes"
|
|
21
|
+
/>
|
|
22
|
+
<meta name="robots" content="index,follow" />
|
|
23
|
+
<meta
|
|
24
|
+
property="og:image"
|
|
25
|
+
content="https://cdn.cocreate.app/docs/file.png"
|
|
26
|
+
/>
|
|
23
27
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
<link
|
|
29
|
+
rel="stylesheet"
|
|
30
|
+
href="../index.css"
|
|
31
|
+
array="files"
|
|
32
|
+
object="60888216117c640e7596303f"
|
|
33
|
+
key="src"
|
|
34
|
+
type="text/css"
|
|
35
|
+
save="true"
|
|
36
|
+
/>
|
|
37
|
+
<link rel="manifest" href="/manifest.webmanifest" />
|
|
38
|
+
</head>
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
share-network="share"
|
|
102
|
-
title="Share on share"
|
|
103
|
-
><i src="/assets/svg/share-alt.svg"></i
|
|
104
|
-
></a>
|
|
105
|
-
</div>
|
|
106
|
-
<a
|
|
107
|
-
class="margin-right:15px"
|
|
108
|
-
share-network="share"
|
|
109
|
-
title="Share on share"
|
|
110
|
-
><i src="/assets/svg/share-alt.svg"></i
|
|
111
|
-
></a>
|
|
112
|
-
</div>
|
|
113
|
-
<a
|
|
114
|
-
href="https://github.com/CoCreate-app/CoCreate-file"
|
|
115
|
-
target="_blank"
|
|
116
|
-
class=""
|
|
117
|
-
><i src="/assets/svg/github.svg"></i
|
|
118
|
-
></a>
|
|
40
|
+
<body>
|
|
41
|
+
<!-- Navbar -->
|
|
42
|
+
<nav
|
|
43
|
+
class="width:100% display:flex align-items:center background:transparent padding-top:10px padding-bottom:10px"
|
|
44
|
+
content_id="content"
|
|
45
|
+
scroll="sticky-nav,"
|
|
46
|
+
scroll-up="5"
|
|
47
|
+
scroll-down="5"
|
|
48
|
+
path="../"
|
|
49
|
+
src="../components/navbar.html"
|
|
50
|
+
></nav>
|
|
51
|
+
<sidenav
|
|
52
|
+
id="menuL"
|
|
53
|
+
class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
|
|
54
|
+
resizable
|
|
55
|
+
resize-selector="[content_id='content']"
|
|
56
|
+
resize-property="margin-left"
|
|
57
|
+
resize-value="width"
|
|
58
|
+
>
|
|
59
|
+
<menu array="files" object="603717b07de7fb350ae9fec8" key="src"></menu>
|
|
60
|
+
<div resize="right"></div>
|
|
61
|
+
</sidenav>
|
|
62
|
+
<main
|
|
63
|
+
class="padding-top:15px padding:15px@lg@xl"
|
|
64
|
+
content_id="content"
|
|
65
|
+
id="cocreate-file"
|
|
66
|
+
>
|
|
67
|
+
<div
|
|
68
|
+
class="display:flex flex-wrap:wrap justify-content:space-between position:relative margin:10px"
|
|
69
|
+
>
|
|
70
|
+
<div class="display:flex align-items:center">
|
|
71
|
+
<h2>CoCreate-file</h2>
|
|
72
|
+
</div>
|
|
73
|
+
<div
|
|
74
|
+
class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white"
|
|
75
|
+
>
|
|
76
|
+
<div
|
|
77
|
+
class="display:flex align-items:center transition:0.3s padding-left:10px"
|
|
78
|
+
share-network="true"
|
|
79
|
+
share-text="A convenient chain handler allows user to chain multiple components together. When one file is complete next one will start untill all file completed."
|
|
80
|
+
share-title="CoCreate file"
|
|
81
|
+
share-height="600"
|
|
82
|
+
share-width="700"
|
|
83
|
+
share-media="https://cdn.cocreate.app/docs/file.png"
|
|
84
|
+
hover="display:block!important"
|
|
85
|
+
hover-selector=".social-networks"
|
|
86
|
+
>
|
|
87
|
+
<div class="display:none social-networks">
|
|
88
|
+
<a
|
|
89
|
+
class="margin-right:15px"
|
|
90
|
+
share-network="twitter"
|
|
91
|
+
title="Share on twitter"
|
|
92
|
+
><i src="/assets/svg/twitter.svg"></i
|
|
93
|
+
></a>
|
|
94
|
+
<a
|
|
95
|
+
class="margin-right:15px"
|
|
96
|
+
share-network="facebook"
|
|
97
|
+
title="Share on Facebook"
|
|
98
|
+
><i src="/assets/svg/facebook.svg"></i
|
|
99
|
+
></a>
|
|
100
|
+
<a
|
|
101
|
+
class="margin-right:15px"
|
|
102
|
+
share-network="instagram"
|
|
103
|
+
title="Share on instagram"
|
|
104
|
+
><i src="/assets/svg/instagram.svg"></i
|
|
105
|
+
></a>
|
|
119
106
|
</div>
|
|
107
|
+
<a
|
|
108
|
+
class="margin-right:15px"
|
|
109
|
+
share-network="share"
|
|
110
|
+
title="Share on share"
|
|
111
|
+
><i src="/assets/svg/share-alt.svg"></i
|
|
112
|
+
></a>
|
|
113
|
+
</div>
|
|
114
|
+
<a
|
|
115
|
+
class="margin-right:15px"
|
|
116
|
+
share-network="share"
|
|
117
|
+
title="Share on share"
|
|
118
|
+
><i src="/assets/svg/share-alt.svg"></i
|
|
119
|
+
></a>
|
|
120
|
+
</div>
|
|
121
|
+
<a
|
|
122
|
+
href="https://github.com/CoCreate-app/CoCreate-file"
|
|
123
|
+
target="_blank"
|
|
124
|
+
class=""
|
|
125
|
+
><i src="/assets/svg/github.svg"></i
|
|
126
|
+
></a>
|
|
127
|
+
</div>
|
|
120
128
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
129
|
+
<h1
|
|
130
|
+
class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100"
|
|
131
|
+
>
|
|
132
|
+
A convenient chain handler allows user to chain multiple CoCreate
|
|
133
|
+
components together. When one file is complete next one will start. The
|
|
134
|
+
sequence goes untill all file completed. Grounded on Vanilla javascript,
|
|
135
|
+
easily configured using HTML5 attributes and/or JavaScript API.
|
|
136
|
+
</h1>
|
|
137
|
+
<div id="file-section" class="display:flex flex-wrap:wrap">
|
|
138
|
+
<div
|
|
139
|
+
class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px"
|
|
140
|
+
>
|
|
141
|
+
<div
|
|
142
|
+
id="file-install"
|
|
143
|
+
class="border-bottom:1px_solid_lightgrey"
|
|
144
|
+
scroll
|
|
145
|
+
scroll-intersect="color:dodgerblue"
|
|
146
|
+
scroll-selector="#file-install-section"
|
|
147
|
+
>
|
|
148
|
+
<span
|
|
149
|
+
class="display:flex align-items:center width:fit-content"
|
|
150
|
+
hover="display:block!important"
|
|
151
|
+
hover-selector="[href='#file-install']"
|
|
152
|
+
>
|
|
153
|
+
<h2 class="padding:5px_0px">Install</h2>
|
|
154
|
+
<a class="margin-left:10px display:none" href="#file-install"
|
|
155
|
+
><i src="/assets/svg/link.svg"></i
|
|
156
|
+
></a>
|
|
157
|
+
</span>
|
|
158
|
+
</div>
|
|
150
159
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
160
|
+
<pre><code class="language-bash">npm i @cocreate/file</code></pre>
|
|
161
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
162
|
+
Or you can use cdn link:
|
|
163
|
+
</p>
|
|
164
|
+
<pre><code class="language-html"><script>https://cdn.cocreate.app/file/latest/CoCreate-file.min.js</script></code></pre>
|
|
156
165
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
This is file usage
|
|
178
|
-
</p>
|
|
166
|
+
<div
|
|
167
|
+
id="file-usage"
|
|
168
|
+
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
169
|
+
scroll
|
|
170
|
+
scroll-intersect="color:dodgerblue"
|
|
171
|
+
scroll-selector="#file-usage-section"
|
|
172
|
+
>
|
|
173
|
+
<span
|
|
174
|
+
class="display:flex align-items:center width:fit-content"
|
|
175
|
+
hover="display:block!important"
|
|
176
|
+
hover-selector="[href='#file-usage']"
|
|
177
|
+
>
|
|
178
|
+
<h2 class="padding:5px_0px">Usage</h2>
|
|
179
|
+
<a class="margin-left:10px display:none" href="#file-usage"
|
|
180
|
+
><i src="/assets/svg/link.svg"></i
|
|
181
|
+
></a>
|
|
182
|
+
</span>
|
|
183
|
+
</div>
|
|
184
|
+
<div class="">
|
|
185
|
+
<p class="padding:10px_0px line-height:1.5">This is file usage</p>
|
|
179
186
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
<p class="padding:10px_0px line-height:1.5">
|
|
187
|
-
This is file usage
|
|
188
|
-
</p>
|
|
189
|
-
</div>
|
|
187
|
+
<div class="flex-grow:1 min-width:300px width:100%">
|
|
188
|
+
<pre><code class="language-html"><div></div></code></pre>
|
|
189
|
+
</div>
|
|
190
|
+
<p class="padding:10px_0px line-height:1.5">This is file usage</p>
|
|
191
|
+
<p class="padding:10px_0px line-height:1.5">This is file usage</p>
|
|
192
|
+
</div>
|
|
190
193
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
194
|
+
<div
|
|
195
|
+
id="file-attributes"
|
|
196
|
+
class="margin-top:80px border-bottom:1px_solid_lightgrey"
|
|
197
|
+
scroll
|
|
198
|
+
scroll-intersect="color:dodgerblue"
|
|
199
|
+
scroll-selector="#file-attributes-section"
|
|
200
|
+
>
|
|
201
|
+
<span
|
|
202
|
+
class="display:flex align-items:center width:fit-content"
|
|
203
|
+
hover="display:block!important"
|
|
204
|
+
hover-selector="[href='#file-attributes']"
|
|
205
|
+
>
|
|
206
|
+
<h2 class="padding:5px_0px">Attributes</h2>
|
|
207
|
+
<a class="margin-left:10px display:none" href="#file-attributes"
|
|
208
|
+
><i src="/assets/svg/link.svg"></i
|
|
209
|
+
></a>
|
|
210
|
+
</span>
|
|
211
|
+
</div>
|
|
209
212
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
>string</span
|
|
230
|
-
>
|
|
231
|
-
<span class="cocreate-badge warning"
|
|
232
|
-
>optional</span
|
|
233
|
-
>
|
|
234
|
-
</h4>
|
|
235
|
-
<p>file-attribute</p>
|
|
236
|
-
</li>
|
|
237
|
-
</ul>
|
|
238
|
-
</div>
|
|
213
|
+
<ul class="list-style-type:none">
|
|
214
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
215
|
+
<h4>
|
|
216
|
+
<span>file</span>
|
|
217
|
+
<span class="cocreate-badge success">string</span>
|
|
218
|
+
<span class="cocreate-badge warning">optional</span>
|
|
219
|
+
</h4>
|
|
220
|
+
<p>file-attribute</p>
|
|
221
|
+
</li>
|
|
222
|
+
<li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
|
|
223
|
+
<h4>
|
|
224
|
+
<span>file</span>
|
|
225
|
+
<span class="cocreate-badge success">string</span>
|
|
226
|
+
<span class="cocreate-badge warning">optional</span>
|
|
227
|
+
</h4>
|
|
228
|
+
<p>file-attribute</p>
|
|
229
|
+
</li>
|
|
230
|
+
</ul>
|
|
231
|
+
</div>
|
|
239
232
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
233
|
+
<div
|
|
234
|
+
class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey"
|
|
235
|
+
>
|
|
236
|
+
<!-- SandBox -->
|
|
237
|
+
<div
|
|
238
|
+
id="file-demo"
|
|
239
|
+
class="border-bottom:1px_solid_lightgrey"
|
|
240
|
+
scroll
|
|
241
|
+
scroll-intersect="color:dodgerblue"
|
|
242
|
+
scroll-selector="#file-demo-section"
|
|
243
|
+
>
|
|
244
|
+
<span
|
|
245
|
+
class="display:flex align-items:center width:fit-content"
|
|
246
|
+
hover="display:block!important"
|
|
247
|
+
hover-selector="[href='#file-demo']"
|
|
248
|
+
>
|
|
249
|
+
<h2 class="padding:5px_0px">Demo</h2>
|
|
250
|
+
<a class="margin-left:10px display:none" href="#file-demo"
|
|
251
|
+
><i src="/assets/svg/link.svg"></i
|
|
252
|
+
></a>
|
|
253
|
+
</span>
|
|
254
|
+
</div>
|
|
261
255
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
256
|
+
<div class="position:sticky top:0 padding:15px_0px height:100vh">
|
|
257
|
+
<!-- SandBox -->
|
|
258
|
+
<div
|
|
259
|
+
class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
|
|
260
|
+
id="playground"
|
|
261
|
+
>
|
|
262
|
+
<div
|
|
263
|
+
id="demo-code"
|
|
264
|
+
resizable
|
|
265
|
+
class="position:relative height:50%"
|
|
266
|
+
>
|
|
267
|
+
<textarea
|
|
268
|
+
type="code"
|
|
269
|
+
lang="html"
|
|
270
|
+
array="demos"
|
|
271
|
+
object=""
|
|
272
|
+
key="demo"
|
|
273
|
+
save="false"
|
|
274
|
+
id="demo"
|
|
275
|
+
class="height:100% width:100% outline:none border:none resize:none padding:5px"
|
|
276
|
+
></textarea>
|
|
277
|
+
<div resize="bottom" class="background:lightgrey"></div>
|
|
278
|
+
</div>
|
|
285
279
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
280
|
+
<div
|
|
281
|
+
id="demo-preview"
|
|
282
|
+
class="position:relative overflow:auto background-color:white"
|
|
283
|
+
>
|
|
284
|
+
<div class="demopreview padding:20px"></div>
|
|
285
|
+
</div>
|
|
291
286
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
fullscreen-selector="#playground"></a>
|
|
336
|
-
</div>
|
|
337
|
-
</div>
|
|
338
|
-
<!-- End SandBox -->
|
|
339
|
-
</div>
|
|
340
|
-
</div>
|
|
287
|
+
<div
|
|
288
|
+
class="font-size:20px position:absolute top:10px right:10px opacity:0.6"
|
|
289
|
+
>
|
|
290
|
+
<a
|
|
291
|
+
class="margin-right:10px"
|
|
292
|
+
id="eye"
|
|
293
|
+
show="#eye-slash"
|
|
294
|
+
hide="#eye, #demo-preview"
|
|
295
|
+
toggle="code-height"
|
|
296
|
+
toggle-selector="#demo-code"
|
|
297
|
+
><i class="height:18px" src="/assets/svg/eye.svg"></i
|
|
298
|
+
></a>
|
|
299
|
+
<a
|
|
300
|
+
class="margin-right:10px"
|
|
301
|
+
hidden
|
|
302
|
+
id="eye-slash"
|
|
303
|
+
show="#eye, #demo-preview"
|
|
304
|
+
hide="#eye-slash"
|
|
305
|
+
toggle="code-height"
|
|
306
|
+
toggle-selector="#demo-code"
|
|
307
|
+
><i src="/assets/svg/eye-slash.svg"></i
|
|
308
|
+
></a>
|
|
309
|
+
<a
|
|
310
|
+
class="margin-right:10px"
|
|
311
|
+
id="code"
|
|
312
|
+
show="#code-slash"
|
|
313
|
+
hide="#code, #demo-code"
|
|
314
|
+
><i src="/assets/svg/code.svg"></i
|
|
315
|
+
></a>
|
|
316
|
+
<a
|
|
317
|
+
class="margin-right:10px"
|
|
318
|
+
hidden
|
|
319
|
+
id="code-slash"
|
|
320
|
+
show="#code, #demo-code"
|
|
321
|
+
hide="#code-slash"
|
|
322
|
+
><i class="height:18px" src="/assets/svg/code.svg"></i
|
|
323
|
+
></a>
|
|
324
|
+
<a
|
|
325
|
+
class="margin-right:5px"
|
|
326
|
+
fullscreen
|
|
327
|
+
fullscreen-selector="#playground"
|
|
328
|
+
></a>
|
|
329
|
+
</div>
|
|
341
330
|
</div>
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
331
|
+
<!-- End SandBox -->
|
|
332
|
+
</div>
|
|
333
|
+
</div>
|
|
334
|
+
</div>
|
|
335
|
+
<button
|
|
336
|
+
href="https://github.com/CoCreate-app/CoCreate-file/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
|
|
337
|
+
target="_blank"
|
|
338
|
+
class="display:flex justify-content:center align-items:center position:fixed bottom:15px right:15px height:50px width:50px border-radius:50% box-shadow:0px_2px_10px_0px_rgba(0,_0,_0,_0.4)"
|
|
339
|
+
>
|
|
340
|
+
<i src="../assets/svg/pencil-alt.svg"></i>
|
|
341
|
+
</button>
|
|
342
|
+
</main>
|
|
343
|
+
<script src="https://CoCreate.app/dist/CoCreate.js"></script>
|
|
344
|
+
</body>
|
|
351
345
|
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/file",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"description": "A versatile, configurable headless file uploader supporting local and server operations. Accessible via a JavaScript API and HTML5 attributes, it provides seamless file reading, writing, and uploading with fallbacks to the standard HTML5 file input API. Ideal for developers needing robust file management in headless environments.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"file-uploader",
|
package/src/client.js
CHANGED
|
@@ -338,7 +338,8 @@ function readFile(file, readAs) {
|
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
function setFiles(element, files) {
|
|
341
|
-
if (!files)
|
|
341
|
+
if (!files || typeof files !== 'object')
|
|
342
|
+
return
|
|
342
343
|
if (!Array.isArray(files))
|
|
343
344
|
files = [files]
|
|
344
345
|
else if (!files.length)
|
|
@@ -346,6 +347,8 @@ function setFiles(element, files) {
|
|
|
346
347
|
|
|
347
348
|
let selected = inputs.get(element) || new Map()
|
|
348
349
|
for (let i = 0; i < files.length; i++) {
|
|
350
|
+
if (!files[i].id)
|
|
351
|
+
files[i].id = files[i].pathname
|
|
349
352
|
files[i].input = element
|
|
350
353
|
selected.set(files[i].id, files[i])
|
|
351
354
|
Files.set(files[i].id, files[i])
|
|
@@ -801,6 +804,58 @@ async function exportFile(data) {
|
|
|
801
804
|
link.remove();
|
|
802
805
|
}
|
|
803
806
|
|
|
807
|
+
// TODO: handled by import? if value is a valid url get file by url?
|
|
808
|
+
async function importURL(action) {
|
|
809
|
+
try {
|
|
810
|
+
let element = action.element
|
|
811
|
+
let url = element.getAttribute('url')
|
|
812
|
+
if (!url) {
|
|
813
|
+
element = action.form.querySelector('[import-url]')
|
|
814
|
+
if (!element)
|
|
815
|
+
return
|
|
816
|
+
url = element.getValue()
|
|
817
|
+
if (!url)
|
|
818
|
+
return
|
|
819
|
+
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
const urlObject = new URL(url);
|
|
823
|
+
const filename = urlObject.pathname.split('/').pop();
|
|
824
|
+
|
|
825
|
+
const file = {
|
|
826
|
+
src: url,
|
|
827
|
+
name: filename,
|
|
828
|
+
directory: '/',
|
|
829
|
+
path: '/',
|
|
830
|
+
pathname: '/' + filename
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
await getCustomData(file)
|
|
834
|
+
|
|
835
|
+
let data = await Crud.socket.send({
|
|
836
|
+
method: 'importUrl',
|
|
837
|
+
file,
|
|
838
|
+
broadcast: false,
|
|
839
|
+
broadcastClient: false
|
|
840
|
+
})
|
|
841
|
+
|
|
842
|
+
let queriedElements = queryElements({ element, prefix: 'import-url' })
|
|
843
|
+
if (queriedElements) {
|
|
844
|
+
for (let queriedElement of queriedElements)
|
|
845
|
+
queriedElement.setValue(data.file)
|
|
846
|
+
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
document.dispatchEvent(new CustomEvent(action.name, {
|
|
850
|
+
detail: {}
|
|
851
|
+
}));
|
|
852
|
+
|
|
853
|
+
} catch (error) {
|
|
854
|
+
console.error('Error importing file from URL:', error);
|
|
855
|
+
throw error;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
|
|
804
859
|
async function fileRenderAction(action) {
|
|
805
860
|
const element = action.element
|
|
806
861
|
|
|
@@ -898,7 +953,7 @@ async function Delete(file) {
|
|
|
898
953
|
Observer.init({
|
|
899
954
|
name: 'CoCreateFileAddedNodes',
|
|
900
955
|
observe: ['addedNodes'],
|
|
901
|
-
|
|
956
|
+
selector: '[type="file"]',
|
|
902
957
|
callback: mutation => init(mutation.target)
|
|
903
958
|
|
|
904
959
|
});
|
|
@@ -907,13 +962,13 @@ Observer.init({
|
|
|
907
962
|
name: 'CoCreateFileAttributes',
|
|
908
963
|
observe: ['attributes'],
|
|
909
964
|
attributeName: ['type'],
|
|
910
|
-
|
|
965
|
+
selector: '[type="file"]',
|
|
911
966
|
callback: mutation => init(mutation.target)
|
|
912
967
|
});
|
|
913
968
|
|
|
914
969
|
Actions.init([
|
|
915
970
|
{
|
|
916
|
-
name: ["upload", "download", "saveLocally", "asveAs", "import", "export"],
|
|
971
|
+
name: ["upload", "download", "saveLocally", "asveAs", "import", "export", "importUrl"],
|
|
917
972
|
callback: (action) => {
|
|
918
973
|
if (action.name === 'upload')
|
|
919
974
|
upload(action.element)
|
|
@@ -923,6 +978,8 @@ Actions.init([
|
|
|
923
978
|
Export(action.element)
|
|
924
979
|
} else if (action.name === 'import') {
|
|
925
980
|
Import(action.element)
|
|
981
|
+
} else if (action.name === 'importUrl') {
|
|
982
|
+
importURL(action)
|
|
926
983
|
} else {
|
|
927
984
|
// Something...
|
|
928
985
|
}
|