@operato/font 1.0.0-beta.7 → 1.0.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 +367 -0
- package/custom-elements.json +855 -0
- package/dist/src/font-creation-card.d.ts +18 -0
- package/dist/src/font-creation-card.js +258 -0
- package/dist/src/font-creation-card.js.map +1 -0
- package/dist/src/font-graphql-client.d.ts +20 -0
- package/dist/src/font-graphql-client.js +109 -0
- package/dist/src/font-graphql-client.js.map +1 -0
- package/dist/src/font-selector.d.ts +36 -0
- package/dist/src/font-selector.js +285 -0
- package/dist/src/font-selector.js.map +1 -0
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ox-file-selector.d.ts +12 -0
- package/dist/src/ox-file-selector.js +129 -0
- package/dist/src/ox-file-selector.js.map +1 -0
- package/dist/src/ox-font-selector.d.ts +15 -0
- package/dist/src/ox-font-selector.js +88 -0
- package/dist/src/ox-font-selector.js.map +1 -0
- package/dist/src/ox-property-editor-font-selector.d.ts +8 -0
- package/dist/src/ox-property-editor-font-selector.js +13 -0
- package/dist/src/ox-property-editor-font-selector.js.map +1 -0
- package/dist/src/redux-font-actions.d.ts +7 -0
- package/dist/src/redux-font-actions.js +19 -0
- package/dist/src/redux-font-actions.js.map +1 -0
- package/dist/src/redux-font-reducers.d.ts +12 -0
- package/dist/src/redux-font-reducers.js +70 -0
- package/dist/src/redux-font-reducers.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +65 -20
- package/src/font-creation-card.ts +260 -0
- package/src/{graphql-client.js → font-graphql-client.ts} +35 -26
- package/src/font-selector.ts +284 -0
- package/src/index.ts +6 -0
- package/src/ox-file-selector.ts +114 -0
- package/src/ox-font-selector.ts +94 -0
- package/src/ox-property-editor-font-selector.ts +17 -0
- package/src/redux-font-actions.ts +21 -0
- package/src/redux-font-reducers.ts +88 -0
- package/src/font-creation-card.js +0 -311
- package/src/font-selector.js +0 -465
- package/src/index.js +0 -3
- package/src/ox-font-selector.js +0 -102
- package/src/ox-property-editor-font-selector.js +0 -25
- package/things-factory.config.js +0 -5
package/src/font-selector.js
DELETED
|
@@ -1,465 +0,0 @@
|
|
|
1
|
-
import "./font-creation-card";
|
|
2
|
-
|
|
3
|
-
import { HeadroomStyles, ScrollbarStyles } from "@operato/styles";
|
|
4
|
-
import { LitElement, css, html } from "lit";
|
|
5
|
-
import {
|
|
6
|
-
createFont,
|
|
7
|
-
deleteFont,
|
|
8
|
-
fetchFontList,
|
|
9
|
-
updateFont,
|
|
10
|
-
} from "./graphql-client";
|
|
11
|
-
import { i18next, localize } from "@operato/i18n";
|
|
12
|
-
|
|
13
|
-
import Headroom from "@operato/headroom";
|
|
14
|
-
import { client } from "@operato/graphql";
|
|
15
|
-
import { connect } from "pwa-helpers/connect-mixin.js";
|
|
16
|
-
import gql from "graphql-tag";
|
|
17
|
-
import { pulltorefresh } from "@operato/pull-to-refresh";
|
|
18
|
-
import { store } from "@operato/shell";
|
|
19
|
-
import uuid from "uuid/v4";
|
|
20
|
-
|
|
21
|
-
export class FontSelector extends localize(i18next)(
|
|
22
|
-
connect(store)(LitElement)
|
|
23
|
-
) {
|
|
24
|
-
static get styles() {
|
|
25
|
-
return [
|
|
26
|
-
ScrollbarStyles,
|
|
27
|
-
HeadroomStyles,
|
|
28
|
-
css`
|
|
29
|
-
:host {
|
|
30
|
-
display: flex;
|
|
31
|
-
flex-direction: column;
|
|
32
|
-
overflow: hidden;
|
|
33
|
-
background-color: var(--popup-content-background-color);
|
|
34
|
-
|
|
35
|
-
position: relative;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
:host(.candrop) {
|
|
39
|
-
background: orange;
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
#main {
|
|
44
|
-
overflow: auto;
|
|
45
|
-
padding: var(--popup-content-padding);
|
|
46
|
-
display: grid;
|
|
47
|
-
grid-template-columns: var(--card-list-template);
|
|
48
|
-
grid-auto-rows: var(--card-list-rows-height);
|
|
49
|
-
grid-gap: 20px;
|
|
50
|
-
box-sizing: border-box;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
#main .card {
|
|
54
|
-
display: flex;
|
|
55
|
-
flex-direction: column;
|
|
56
|
-
align-items: center;
|
|
57
|
-
overflow: hidden;
|
|
58
|
-
border-radius: var(--card-list-border-radius);
|
|
59
|
-
border: var(--font-selector-border);
|
|
60
|
-
background-color: var(--card-list-background-color);
|
|
61
|
-
|
|
62
|
-
position: relative;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.card .button-container {
|
|
66
|
-
position: absolute;
|
|
67
|
-
right: 0;
|
|
68
|
-
height: 100%;
|
|
69
|
-
display: flex;
|
|
70
|
-
direction: rtl;
|
|
71
|
-
flex-direction: column;
|
|
72
|
-
flex-wrap: wrap;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.card .button-container > mwc-icon {
|
|
76
|
-
background-color: var(--font-selector-icon-background-color);
|
|
77
|
-
text-align: center;
|
|
78
|
-
width: var(--font-selector-icon-size);
|
|
79
|
-
height: var(--font-selector-icon-size);
|
|
80
|
-
font: var(--font-selector-icon-font);
|
|
81
|
-
color: var(--font-selector-icon-color);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.card .button-container > mwc-icon:last-child {
|
|
85
|
-
border-bottom-left-radius: 12px;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
.card .button-container > mwc-icon:hover,
|
|
89
|
-
.card .button-container > mwc-icon:active {
|
|
90
|
-
background-color: var(--primary-color);
|
|
91
|
-
color: #fff;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
#main .card.create {
|
|
95
|
-
overflow: visible;
|
|
96
|
-
background-color: initial;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
#main .card:hover {
|
|
100
|
-
cursor: pointer;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
[face] {
|
|
104
|
-
flex: 1;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
[name] {
|
|
108
|
-
background-color: var(--board-renderer-name-background-color);
|
|
109
|
-
opacity: 0.8;
|
|
110
|
-
margin-top: -35px;
|
|
111
|
-
width: 100%;
|
|
112
|
-
color: #fff;
|
|
113
|
-
font-weight: bolder;
|
|
114
|
-
font-size: 13px;
|
|
115
|
-
text-indent: 7px;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
[provider] {
|
|
119
|
-
background-color: rgba(0, 0, 0, 0.7);
|
|
120
|
-
width: 100%;
|
|
121
|
-
min-height: 15px;
|
|
122
|
-
font-size: 0.6rem;
|
|
123
|
-
color: #fff;
|
|
124
|
-
text-indent: 7px;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
#filter {
|
|
128
|
-
padding: var(--popup-content-padding);
|
|
129
|
-
background-color: var(--font-tools-background-color);
|
|
130
|
-
box-shadow: var(--box-shadow);
|
|
131
|
-
|
|
132
|
-
position: absolute;
|
|
133
|
-
width: 100%;
|
|
134
|
-
box-sizing: border-box;
|
|
135
|
-
z-index: 1;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
#filter * {
|
|
139
|
-
font-size: 15px;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
select {
|
|
143
|
-
text-transform: capitalize;
|
|
144
|
-
float: right;
|
|
145
|
-
}
|
|
146
|
-
`,
|
|
147
|
-
];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
static get properties() {
|
|
151
|
-
return {
|
|
152
|
-
fonts: Array,
|
|
153
|
-
_page: Number,
|
|
154
|
-
_total: Number,
|
|
155
|
-
creatable: Boolean,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
render() {
|
|
160
|
-
var fonts = this.fonts || [];
|
|
161
|
-
|
|
162
|
-
return html`
|
|
163
|
-
<div id="filter">
|
|
164
|
-
<select
|
|
165
|
-
@change=${(e) => {
|
|
166
|
-
this.provider = e.currentTarget.value;
|
|
167
|
-
this.requestUpdate();
|
|
168
|
-
}}
|
|
169
|
-
>
|
|
170
|
-
<option value="">
|
|
171
|
-
--${i18next.t("text.please choose a provider")}--
|
|
172
|
-
</option>
|
|
173
|
-
${["google", "custom"].map(
|
|
174
|
-
(provider) => html` <option value=${provider}>${provider}</option> `
|
|
175
|
-
)}
|
|
176
|
-
</select>
|
|
177
|
-
</div>
|
|
178
|
-
|
|
179
|
-
<div id="main">
|
|
180
|
-
${this.creatable
|
|
181
|
-
? html`
|
|
182
|
-
<font-creation-card
|
|
183
|
-
class="card create"
|
|
184
|
-
@create-font=${(e) => this.onCreateFont(e)}
|
|
185
|
-
@file-drop=${(e) => this.onAttachmentDropped(e)}
|
|
186
|
-
></font-creation-card>
|
|
187
|
-
`
|
|
188
|
-
: html``}
|
|
189
|
-
${fonts.map(
|
|
190
|
-
(font) => html`
|
|
191
|
-
<div class="card" @click=${(e) => this.onClickSelect(font)}>
|
|
192
|
-
<div face>
|
|
193
|
-
<font .face=${font.name}>ABCDEFGHIJKLMN</font>
|
|
194
|
-
<font .face=${font.name}>abcdefghijklmn</font>
|
|
195
|
-
</div>
|
|
196
|
-
<div name>${font.name}</div>
|
|
197
|
-
<div provider>${font.provider}</div>
|
|
198
|
-
<div class="button-container">
|
|
199
|
-
<mwc-icon
|
|
200
|
-
@click=${(e) => {
|
|
201
|
-
e.stopPropagation();
|
|
202
|
-
this.toggleActive(font);
|
|
203
|
-
}}
|
|
204
|
-
>${font.active
|
|
205
|
-
? "check_box"
|
|
206
|
-
: "check_box_outline_blank"}</mwc-icon
|
|
207
|
-
>
|
|
208
|
-
<mwc-icon
|
|
209
|
-
@click=${(e) => {
|
|
210
|
-
e.stopPropagation();
|
|
211
|
-
this.deleteFont(font);
|
|
212
|
-
}}
|
|
213
|
-
>delete</mwc-icon
|
|
214
|
-
>
|
|
215
|
-
</div>
|
|
216
|
-
</div>
|
|
217
|
-
`
|
|
218
|
-
)}
|
|
219
|
-
</div>
|
|
220
|
-
`;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
async firstUpdated() {
|
|
224
|
-
var list = this.shadowRoot.querySelector("#main");
|
|
225
|
-
|
|
226
|
-
pulltorefresh({
|
|
227
|
-
container: this.shadowRoot,
|
|
228
|
-
scrollable: list,
|
|
229
|
-
refresh: () => {
|
|
230
|
-
return this.refresh();
|
|
231
|
-
},
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
/* for headroom */
|
|
235
|
-
var main = this.renderRoot.querySelector("#main");
|
|
236
|
-
main.addEventListener("scroll", (e) => {
|
|
237
|
-
this.showGotoTop = e.target.scrollTop !== 0;
|
|
238
|
-
});
|
|
239
|
-
|
|
240
|
-
var filter = this.renderRoot.querySelector("#filter");
|
|
241
|
-
|
|
242
|
-
await this.requestUpdate();
|
|
243
|
-
|
|
244
|
-
var originPaddingTop = parseFloat(
|
|
245
|
-
getComputedStyle(main, null).getPropertyValue("padding-top")
|
|
246
|
-
);
|
|
247
|
-
main.style.paddingTop = filter.clientHeight + originPaddingTop + "px";
|
|
248
|
-
var headroom = new Headroom(filter, {
|
|
249
|
-
scroller: main,
|
|
250
|
-
});
|
|
251
|
-
headroom.init();
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
get creationCard() {
|
|
255
|
-
return this.shadowRoot.querySelector("font-creation-card");
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
updated(changes) {
|
|
259
|
-
if (changes.has("fonts")) {
|
|
260
|
-
var creationCard = this.creationCard;
|
|
261
|
-
if (creationCard) {
|
|
262
|
-
creationCard.reset();
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
stateChanged(state) {
|
|
268
|
-
this.fonts = state.font;
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
refresh() {
|
|
272
|
-
return store.dispatch(fetchFontList());
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
toggleActive(font) {
|
|
276
|
-
store.dispatch(updateFont({ id: font.id, active: !font.active }));
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
onCreateFont(e) {
|
|
280
|
-
var font = e.detail;
|
|
281
|
-
this.createFont(font);
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
async createFont(font) {
|
|
285
|
-
if (font._files?.length > 0) {
|
|
286
|
-
let attachment = await this.attachFile(font._files[0], [
|
|
287
|
-
"fullpath",
|
|
288
|
-
"refBy",
|
|
289
|
-
]);
|
|
290
|
-
|
|
291
|
-
//font.id = attachment?.refBy
|
|
292
|
-
font.uri = attachment?.fullpath;
|
|
293
|
-
delete font._files;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
store.dispatch(createFont(font));
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
async onAttachmentDropped(e) {
|
|
300
|
-
var isNonFontIncluded = false;
|
|
301
|
-
var files = e.detail.filter((file) => {
|
|
302
|
-
var isFontFormat = !![
|
|
303
|
-
".woff",
|
|
304
|
-
".woff2",
|
|
305
|
-
".eot",
|
|
306
|
-
".svg",
|
|
307
|
-
".svgz",
|
|
308
|
-
".ttf",
|
|
309
|
-
".otf",
|
|
310
|
-
].find((ext) => file.name.endsWith(ext));
|
|
311
|
-
if (!isFontFormat) {
|
|
312
|
-
isNonFontIncluded = true;
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
|
-
var alreadyExist = !!this.fonts.find(
|
|
316
|
-
(font) =>
|
|
317
|
-
font.name == file.name.replace(/\.[^/.]+$/, "").replace(".", "_")
|
|
318
|
-
);
|
|
319
|
-
if (alreadyExist) return false;
|
|
320
|
-
return true;
|
|
321
|
-
});
|
|
322
|
-
// TODO alert if non-font file is included. ex) Non-font file is excluded in upload list.
|
|
323
|
-
|
|
324
|
-
if (files.length > 0) {
|
|
325
|
-
var attached = await this.attachFiles(files, [
|
|
326
|
-
"name",
|
|
327
|
-
"fullpath",
|
|
328
|
-
"refBy",
|
|
329
|
-
]);
|
|
330
|
-
attached.forEach((attachment) => {
|
|
331
|
-
this.createFont({
|
|
332
|
-
id: attachment.refBy,
|
|
333
|
-
name: attachment.name.replace(/\.[^/.]+$/, "").replace(".", "_"), // cannot apply font correctly if '.' exists in name
|
|
334
|
-
provider: "custom",
|
|
335
|
-
active: true,
|
|
336
|
-
uri: attachment.fullpath,
|
|
337
|
-
});
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* attach a file
|
|
344
|
-
*
|
|
345
|
-
* @param { File } file file
|
|
346
|
-
* @param { Array<String> } fields fields to select from return
|
|
347
|
-
*/
|
|
348
|
-
async attachFile(file, fields = []) {
|
|
349
|
-
var attaching = await client.mutate({
|
|
350
|
-
mutation: gql`
|
|
351
|
-
mutation ($attachment: NewAttachment!) {
|
|
352
|
-
createAttachment(attachment: $attachment) {
|
|
353
|
-
id
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
`,
|
|
357
|
-
variables: {
|
|
358
|
-
attachment: { refBy: uuid(), category: "font", file },
|
|
359
|
-
},
|
|
360
|
-
context: {
|
|
361
|
-
hasUpload: true,
|
|
362
|
-
},
|
|
363
|
-
});
|
|
364
|
-
// TODO mutation 이후 query 호출 안 해도 되도록 수정
|
|
365
|
-
// fullpath 값은 getter라서 그런지 뮤테이션에서 못 받아오는 듯
|
|
366
|
-
var attached = await client.query({
|
|
367
|
-
query: gql`
|
|
368
|
-
query($id: String!) {
|
|
369
|
-
attachment(id: $id) {
|
|
370
|
-
id
|
|
371
|
-
${fields.join("\n")}
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
`,
|
|
375
|
-
variables: {
|
|
376
|
-
id: attaching.data.createAttachment?.id,
|
|
377
|
-
},
|
|
378
|
-
});
|
|
379
|
-
return attached.data.attachment;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/**
|
|
383
|
-
* attach multiple files
|
|
384
|
-
*
|
|
385
|
-
* @param { Array<File> } files files
|
|
386
|
-
* @param { Array<String> } fields fields to select from return
|
|
387
|
-
*/
|
|
388
|
-
async attachFiles(files, fields = []) {
|
|
389
|
-
var attaching = await client.mutate({
|
|
390
|
-
mutation: gql`
|
|
391
|
-
mutation ($attachments: [NewAttachment!]!) {
|
|
392
|
-
createAttachments(attachments: $attachments) {
|
|
393
|
-
id
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
`,
|
|
397
|
-
variables: {
|
|
398
|
-
attachments: files.map((file) => ({
|
|
399
|
-
refBy: uuid(),
|
|
400
|
-
category: "",
|
|
401
|
-
file,
|
|
402
|
-
})),
|
|
403
|
-
},
|
|
404
|
-
context: {
|
|
405
|
-
hasUpload: true,
|
|
406
|
-
},
|
|
407
|
-
});
|
|
408
|
-
// TODO mutation 이후 query 호출 안 해도 되도록 수정
|
|
409
|
-
// fullpath 값은 getter라서 그런지 뮤테이션에서 못 받아오는 듯
|
|
410
|
-
var attached = await client.query({
|
|
411
|
-
query: gql`
|
|
412
|
-
query($filters: [Filter]) {
|
|
413
|
-
attachments(filters: $filters) {
|
|
414
|
-
items {
|
|
415
|
-
id
|
|
416
|
-
${fields.join("\n")}
|
|
417
|
-
}
|
|
418
|
-
total
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
`,
|
|
422
|
-
variables: {
|
|
423
|
-
filters: {
|
|
424
|
-
name: "id",
|
|
425
|
-
operator: "in",
|
|
426
|
-
value: attaching.data.createAttachments.map(
|
|
427
|
-
(attachment) => attachment.id
|
|
428
|
-
),
|
|
429
|
-
},
|
|
430
|
-
},
|
|
431
|
-
});
|
|
432
|
-
return attached.data.attachments.items;
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
async deleteFont(font) {
|
|
436
|
-
try {
|
|
437
|
-
client.mutate({
|
|
438
|
-
mutation: gql`
|
|
439
|
-
mutation ($refBys: [String!]!) {
|
|
440
|
-
deleteAttachmentsByRef(refBys: $refBys)
|
|
441
|
-
}
|
|
442
|
-
`,
|
|
443
|
-
variables: {
|
|
444
|
-
refBys: [font.id],
|
|
445
|
-
},
|
|
446
|
-
});
|
|
447
|
-
} catch (e) {}
|
|
448
|
-
|
|
449
|
-
store.dispatch(deleteFont(font));
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
onClickSelect(font) {
|
|
453
|
-
this.dispatchEvent(
|
|
454
|
-
new CustomEvent("font-selected", {
|
|
455
|
-
composed: true,
|
|
456
|
-
bubbles: true,
|
|
457
|
-
detail: {
|
|
458
|
-
font,
|
|
459
|
-
},
|
|
460
|
-
})
|
|
461
|
-
);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
customElements.define("font-selector", FontSelector);
|
package/src/index.js
DELETED
package/src/ox-font-selector.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import "@material/mwc-icon";
|
|
6
|
-
import "./font-selector";
|
|
7
|
-
|
|
8
|
-
import { LitElement, css, html } from "lit";
|
|
9
|
-
|
|
10
|
-
import { i18next } from "@operato/i18n";
|
|
11
|
-
import { openPopup } from "@operato/layout";
|
|
12
|
-
|
|
13
|
-
export default class OxFontSelector extends LitElement {
|
|
14
|
-
static get properties() {
|
|
15
|
-
return {
|
|
16
|
-
value: String,
|
|
17
|
-
properties: Object,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
static get styles() {
|
|
22
|
-
return [
|
|
23
|
-
css`
|
|
24
|
-
:host {
|
|
25
|
-
position: relative;
|
|
26
|
-
display: inline-block;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
input[type="text"] {
|
|
30
|
-
box-sizing: border-box;
|
|
31
|
-
width: 100%;
|
|
32
|
-
height: 100%;
|
|
33
|
-
border: 1px solid rgba(0, 0, 0, 0.2);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
mwc-icon {
|
|
37
|
-
position: absolute;
|
|
38
|
-
top: 0;
|
|
39
|
-
right: 0;
|
|
40
|
-
}
|
|
41
|
-
`,
|
|
42
|
-
];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
render() {
|
|
46
|
-
return html`
|
|
47
|
-
<input
|
|
48
|
-
id="text"
|
|
49
|
-
type="text"
|
|
50
|
-
.value=${this.value || ""}
|
|
51
|
-
@change=${(e) => this._onInputChanged(e)}
|
|
52
|
-
.placeholder=${this.getAttribute("placeholder") || ""}
|
|
53
|
-
/>
|
|
54
|
-
|
|
55
|
-
<mwc-icon @click=${(e) => this.openSelector(e)}>font_download</mwc-icon>
|
|
56
|
-
`;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
_onInputChanged(e) {
|
|
60
|
-
this.value = e.target.value;
|
|
61
|
-
this.dispatchEvent(
|
|
62
|
-
new CustomEvent("change", { bubbles: true, composed: true })
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
openSelector() {
|
|
67
|
-
if (this.popup) {
|
|
68
|
-
delete this.popup;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
* 기존 설정된 보드가 선택된 상태가 되게 하기 위해서는 selector에 value를 전달해줄 필요가 있음.
|
|
73
|
-
* 주의. value는 object일 수도 있고, string일 수도 있다.
|
|
74
|
-
* string인 경우에는 해당 보드의 id로 해석한다.
|
|
75
|
-
*/
|
|
76
|
-
var value = this.value || {};
|
|
77
|
-
|
|
78
|
-
var template = html`
|
|
79
|
-
<font-selector
|
|
80
|
-
.creatable=${true}
|
|
81
|
-
@font-selected=${async (e) => {
|
|
82
|
-
var font = e.detail.font;
|
|
83
|
-
this.value = font.name;
|
|
84
|
-
|
|
85
|
-
this.dispatchEvent(
|
|
86
|
-
new CustomEvent("change", { bubbles: true, composed: true })
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
this.popup && this.popup.close();
|
|
90
|
-
}}
|
|
91
|
-
></font-selector>
|
|
92
|
-
`;
|
|
93
|
-
|
|
94
|
-
this.popup = openPopup(template, {
|
|
95
|
-
backdrop: true,
|
|
96
|
-
size: "large",
|
|
97
|
-
title: i18next.t("title.select font"),
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
customElements.define("ox-font-selector", OxFontSelector);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright © HatioLab Inc. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import "./ox-font-selector";
|
|
6
|
-
|
|
7
|
-
import { OxPropertyEditor } from "@operato/property-editor";
|
|
8
|
-
import { html } from "lit";
|
|
9
|
-
|
|
10
|
-
export class OxPropertyEditorFontSelector extends OxPropertyEditor {
|
|
11
|
-
editorTemplate() {
|
|
12
|
-
return html`
|
|
13
|
-
<ox-font-selector
|
|
14
|
-
id="editor"
|
|
15
|
-
.value=${this.value}
|
|
16
|
-
.properties=${this.property}
|
|
17
|
-
></ox-font-selector>
|
|
18
|
-
`;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
customElements.define(
|
|
23
|
-
"ox-property-editor-font-selector",
|
|
24
|
-
OxPropertyEditorFontSelector
|
|
25
|
-
);
|