@ddict/popup 0.3.19
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/README.md +1 -0
- package/dist/popup.css +1 -0
- package/dist/popup.es.js +887 -0
- package/dist/popup.umd.js +2 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Ddict Popup
|
package/dist/popup.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.section{margin-bottom:.5rem}.textarea-footer{margin-bottom:0}.title{text-transform:capitalize}.clickable-badge{margin-right:.2rem}.textarea-src-target{padding-top:1.1rem!important}.textarea-src-target-header{left:1.1rem}#clear{margin-right:1rem}.pointer{cursor:pointer}.truncate{max-width:85%}#swap{border:none}#input:focus{outline:none;box-shadow:none}
|
package/dist/popup.es.js
ADDED
|
@@ -0,0 +1,887 @@
|
|
|
1
|
+
import { resolveComponent, openBlock, createElementBlock, createElementVNode, withDirectives, Fragment, renderList, toDisplayString, vModelSelect, createBlock, createCommentVNode, createVNode, normalizeStyle, vModelText, vModelCheckbox, createTextVNode, Transition, withCtx } from "vue";
|
|
2
|
+
var style = "";
|
|
3
|
+
var _export_sfc = (sfc, props) => {
|
|
4
|
+
const target = sfc.__vccOpts || sfc;
|
|
5
|
+
for (const [key, val] of props) {
|
|
6
|
+
target[key] = val;
|
|
7
|
+
}
|
|
8
|
+
return target;
|
|
9
|
+
};
|
|
10
|
+
const _sfc_main$8 = {
|
|
11
|
+
props: {
|
|
12
|
+
select: {
|
|
13
|
+
type: Object,
|
|
14
|
+
default: null
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
data() {
|
|
18
|
+
return {
|
|
19
|
+
src: "",
|
|
20
|
+
target: "",
|
|
21
|
+
warning: false
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
watch: {
|
|
25
|
+
select() {
|
|
26
|
+
this.src = this.select.src;
|
|
27
|
+
this.target = this.select.target;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
methods: {
|
|
31
|
+
warn() {
|
|
32
|
+
this.warning = true;
|
|
33
|
+
setTimeout(() => {
|
|
34
|
+
this.warning = false;
|
|
35
|
+
}, 2e3);
|
|
36
|
+
},
|
|
37
|
+
swap() {
|
|
38
|
+
if (!this.select.srcs.hasOwnProperty(this.target) || !this.select.targets.hasOwnProperty(this.src)) {
|
|
39
|
+
this.warn();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const tmp = this.target;
|
|
43
|
+
this.target = this.src;
|
|
44
|
+
this.src = tmp;
|
|
45
|
+
this.srctarget();
|
|
46
|
+
},
|
|
47
|
+
srctarget() {
|
|
48
|
+
const select = JSON.parse(JSON.stringify(this.select));
|
|
49
|
+
select.src = this.src;
|
|
50
|
+
select.target = this.target;
|
|
51
|
+
this.$emit("srctarget", select);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const _hoisted_1$8 = {
|
|
56
|
+
key: 0,
|
|
57
|
+
class: "row justify-content-center mb-2"
|
|
58
|
+
};
|
|
59
|
+
const _hoisted_2$7 = { class: "col-5" };
|
|
60
|
+
const _hoisted_3$7 = ["value"];
|
|
61
|
+
const _hoisted_4$7 = { class: "col-auto text-center" };
|
|
62
|
+
const _hoisted_5$7 = {
|
|
63
|
+
id: "swap",
|
|
64
|
+
class: "form-control bg-light pointer"
|
|
65
|
+
};
|
|
66
|
+
const _hoisted_6$6 = { class: "col-5" };
|
|
67
|
+
const _hoisted_7$1 = ["value"];
|
|
68
|
+
function _sfc_render$8(_ctx, _cache, $props, $setup, $data, $options) {
|
|
69
|
+
const _component_b_icon = resolveComponent("b-icon");
|
|
70
|
+
return $props.select ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
|
|
71
|
+
createElementVNode("div", _hoisted_2$7, [
|
|
72
|
+
withDirectives(createElementVNode("select", {
|
|
73
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => $data.src = $event),
|
|
74
|
+
class: "form-select",
|
|
75
|
+
onChange: _cache[1] || (_cache[1] = (...args) => $options.srctarget && $options.srctarget(...args))
|
|
76
|
+
}, [
|
|
77
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($props.select.srcs, (value, key) => {
|
|
78
|
+
return openBlock(), createElementBlock("option", {
|
|
79
|
+
value: key,
|
|
80
|
+
key
|
|
81
|
+
}, toDisplayString(value), 9, _hoisted_3$7);
|
|
82
|
+
}), 128))
|
|
83
|
+
], 544), [
|
|
84
|
+
[vModelSelect, $data.src]
|
|
85
|
+
])
|
|
86
|
+
]),
|
|
87
|
+
createElementVNode("div", _hoisted_4$7, [
|
|
88
|
+
createElementVNode("span", _hoisted_5$7, [
|
|
89
|
+
$data.src != "auto" ? (openBlock(), createBlock(_component_b_icon, {
|
|
90
|
+
key: 0,
|
|
91
|
+
icon: "arrow-left-right",
|
|
92
|
+
onClick: $options.swap
|
|
93
|
+
}, null, 8, ["onClick"])) : createCommentVNode("", true),
|
|
94
|
+
$data.src == "auto" ? (openBlock(), createBlock(_component_b_icon, {
|
|
95
|
+
key: 1,
|
|
96
|
+
icon: "arrow-right"
|
|
97
|
+
})) : createCommentVNode("", true)
|
|
98
|
+
])
|
|
99
|
+
]),
|
|
100
|
+
createElementVNode("div", _hoisted_6$6, [
|
|
101
|
+
withDirectives(createElementVNode("select", {
|
|
102
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => $data.target = $event),
|
|
103
|
+
class: "form-select",
|
|
104
|
+
onChange: _cache[3] || (_cache[3] = (...args) => $options.srctarget && $options.srctarget(...args))
|
|
105
|
+
}, [
|
|
106
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($props.select.targets, (value, key) => {
|
|
107
|
+
return openBlock(), createElementBlock("option", {
|
|
108
|
+
value: key,
|
|
109
|
+
key
|
|
110
|
+
}, toDisplayString(value), 9, _hoisted_7$1);
|
|
111
|
+
}), 128))
|
|
112
|
+
], 544), [
|
|
113
|
+
[vModelSelect, $data.target]
|
|
114
|
+
])
|
|
115
|
+
])
|
|
116
|
+
])) : createCommentVNode("", true);
|
|
117
|
+
}
|
|
118
|
+
var selects = /* @__PURE__ */ _export_sfc(_sfc_main$8, [["render", _sfc_render$8]]);
|
|
119
|
+
var config = {
|
|
120
|
+
INPUT_MAX_LENGTH: 5e3,
|
|
121
|
+
INPUT_DELAY: 1e3
|
|
122
|
+
};
|
|
123
|
+
var textarea = {
|
|
124
|
+
init,
|
|
125
|
+
autoResize
|
|
126
|
+
};
|
|
127
|
+
const MIN_HEIGHT = 100;
|
|
128
|
+
const MAX_HEIGHT = 600;
|
|
129
|
+
const PADDING = 10;
|
|
130
|
+
function init(el, max_length) {
|
|
131
|
+
if (max_length) {
|
|
132
|
+
el.maxlength = max_length;
|
|
133
|
+
}
|
|
134
|
+
el.spellcheck = false;
|
|
135
|
+
setHeigtht(el, MIN_HEIGHT);
|
|
136
|
+
}
|
|
137
|
+
function autoResize(el) {
|
|
138
|
+
if (el.value == "") {
|
|
139
|
+
setHeigtht(el, MIN_HEIGHT);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (el.scrollHeight < MIN_HEIGHT) {
|
|
143
|
+
setHeigtht(el, MIN_HEIGHT);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (el.scrollHeight > MAX_HEIGHT) {
|
|
147
|
+
setHeigtht(el, MAX_HEIGHT);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const el_height = el.style.height.replace("px", "");
|
|
151
|
+
if (el_height > el.scrollHeight) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
setHeigtht(el, el.scrollHeight + PADDING);
|
|
155
|
+
}
|
|
156
|
+
function setHeigtht(el, height) {
|
|
157
|
+
el.style.height = `${height}px`;
|
|
158
|
+
}
|
|
159
|
+
var helper = {
|
|
160
|
+
isRTL
|
|
161
|
+
};
|
|
162
|
+
function isRTL(locale) {
|
|
163
|
+
return ["ar", "fa", "iw", "yi", "ur", "pa"].indexOf(locale) > -1;
|
|
164
|
+
}
|
|
165
|
+
const LABEL_AUTO_TRANSLATE = "auto_translate";
|
|
166
|
+
const _sfc_main$7 = {
|
|
167
|
+
props: {
|
|
168
|
+
data: {
|
|
169
|
+
type: Object,
|
|
170
|
+
default: null
|
|
171
|
+
},
|
|
172
|
+
tts: {
|
|
173
|
+
type: Object,
|
|
174
|
+
default: null
|
|
175
|
+
},
|
|
176
|
+
replace: {
|
|
177
|
+
type: String,
|
|
178
|
+
default: ""
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
data() {
|
|
182
|
+
return {
|
|
183
|
+
input: "",
|
|
184
|
+
INPUT_MAX_LENGTH: config.INPUT_MAX_LENGTH,
|
|
185
|
+
input_timeout: null,
|
|
186
|
+
player: new Audio(),
|
|
187
|
+
playing: false,
|
|
188
|
+
ttsIndex: 0,
|
|
189
|
+
auto_translate: true,
|
|
190
|
+
firstTime: true
|
|
191
|
+
};
|
|
192
|
+
},
|
|
193
|
+
computed: {
|
|
194
|
+
rtl() {
|
|
195
|
+
if (!this.data)
|
|
196
|
+
return false;
|
|
197
|
+
return helper.isRTL(this.data.src);
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
watch: {
|
|
201
|
+
replace(new_input) {
|
|
202
|
+
this.input = new_input;
|
|
203
|
+
if (this.firstTime || !this.auto_translate) {
|
|
204
|
+
setTimeout(() => {
|
|
205
|
+
this.$refs.input.select();
|
|
206
|
+
}, 100);
|
|
207
|
+
}
|
|
208
|
+
this.firstTime = false;
|
|
209
|
+
},
|
|
210
|
+
tts() {
|
|
211
|
+
this.ttsIndex = 0;
|
|
212
|
+
},
|
|
213
|
+
auto_translate(val) {
|
|
214
|
+
if (val)
|
|
215
|
+
this.translate();
|
|
216
|
+
localStorage.setItem(LABEL_AUTO_TRANSLATE, val);
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
mounted() {
|
|
220
|
+
textarea.init(this.$refs.input, config.INPUT_MAX_LENGTH);
|
|
221
|
+
this.player.addEventListener("ended", () => {
|
|
222
|
+
this.ttsIndex++;
|
|
223
|
+
if (this.ttsIndex >= this.tts.src.length) {
|
|
224
|
+
this.stop();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
this.play();
|
|
228
|
+
});
|
|
229
|
+
this.$refs.input.addEventListener("input", () => {
|
|
230
|
+
textarea.autoResize(this.$refs.input);
|
|
231
|
+
if (!this.auto_translate)
|
|
232
|
+
return;
|
|
233
|
+
clearTimeout(this.input_timeout);
|
|
234
|
+
this.input_timeout = setTimeout(this.translate, config.INPUT_DELAY);
|
|
235
|
+
});
|
|
236
|
+
this.$refs.input.addEventListener("keyup", (e) => {
|
|
237
|
+
if (this.auto_translate)
|
|
238
|
+
return;
|
|
239
|
+
if (e && e.keyCode === 13)
|
|
240
|
+
this.translate();
|
|
241
|
+
});
|
|
242
|
+
},
|
|
243
|
+
created() {
|
|
244
|
+
const auto_translate = localStorage.getItem(LABEL_AUTO_TRANSLATE);
|
|
245
|
+
if (auto_translate === "false")
|
|
246
|
+
this.auto_translate = false;
|
|
247
|
+
},
|
|
248
|
+
methods: {
|
|
249
|
+
play() {
|
|
250
|
+
if (!this.tts.src) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
this.player.src = this.tts.src[this.ttsIndex];
|
|
254
|
+
this.playing = true;
|
|
255
|
+
this.player.play().catch(() => {
|
|
256
|
+
this.playing = false;
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
stop() {
|
|
260
|
+
this.playing = false;
|
|
261
|
+
this.ttsIndex = 0;
|
|
262
|
+
this.player.pause();
|
|
263
|
+
},
|
|
264
|
+
clear() {
|
|
265
|
+
this.$emit("clear");
|
|
266
|
+
this.input = "";
|
|
267
|
+
textarea.init(this.$refs.input, config.INPUT_MAX_LENGTH);
|
|
268
|
+
this.$refs.input.focus();
|
|
269
|
+
},
|
|
270
|
+
translate() {
|
|
271
|
+
if (!this.input) {
|
|
272
|
+
this.clear();
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
this.$emit("translate", this.input);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
const _hoisted_1$7 = { class: "col-sm-6 section position-relative" };
|
|
280
|
+
const _hoisted_2$6 = {
|
|
281
|
+
key: 0,
|
|
282
|
+
class: "textarea-src-target-header text-truncate position-absolute top-0 start-20 truncate"
|
|
283
|
+
};
|
|
284
|
+
const _hoisted_3$6 = {
|
|
285
|
+
key: 2,
|
|
286
|
+
class: "text-muted small"
|
|
287
|
+
};
|
|
288
|
+
const _hoisted_4$6 = { key: 0 };
|
|
289
|
+
const _hoisted_5$6 = { class: "small form-check form-switch text-muted textarea-footer" };
|
|
290
|
+
const _hoisted_6$5 = /* @__PURE__ */ createElementVNode("label", {
|
|
291
|
+
for: "auto_translate",
|
|
292
|
+
class: "form-check-label small"
|
|
293
|
+
}, "Auto translate", -1);
|
|
294
|
+
const _hoisted_7 = {
|
|
295
|
+
key: 0,
|
|
296
|
+
class: "float-end"
|
|
297
|
+
};
|
|
298
|
+
function _sfc_render$7(_ctx, _cache, $props, $setup, $data, $options) {
|
|
299
|
+
const _component_b_icon = resolveComponent("b-icon");
|
|
300
|
+
return openBlock(), createElementBlock("div", _hoisted_1$7, [
|
|
301
|
+
$props.data ? (openBlock(), createElementBlock("small", _hoisted_2$6, [
|
|
302
|
+
!$data.playing ? (openBlock(), createElementBlock("span", {
|
|
303
|
+
key: 0,
|
|
304
|
+
class: "pointer",
|
|
305
|
+
onClick: _cache[0] || (_cache[0] = (...args) => $options.play && $options.play(...args))
|
|
306
|
+
}, [
|
|
307
|
+
createVNode(_component_b_icon, { icon: "volume-up" })
|
|
308
|
+
])) : createCommentVNode("", true),
|
|
309
|
+
$data.playing ? (openBlock(), createElementBlock("span", {
|
|
310
|
+
key: 1,
|
|
311
|
+
class: "pointer",
|
|
312
|
+
onClick: _cache[1] || (_cache[1] = (...args) => $options.stop && $options.stop(...args))
|
|
313
|
+
}, [
|
|
314
|
+
createVNode(_component_b_icon, { icon: "volume-off" })
|
|
315
|
+
])) : createCommentVNode("", true),
|
|
316
|
+
$props.data.ddictSrc ? (openBlock(), createElementBlock("span", _hoisted_3$6, toDisplayString($props.data.ddictSrc), 1)) : createCommentVNode("", true),
|
|
317
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($props.data.sentences, (sentence, index) => {
|
|
318
|
+
return openBlock(), createElementBlock("span", {
|
|
319
|
+
key: `${sentence.src_translit}-${index}`,
|
|
320
|
+
class: "text-muted small"
|
|
321
|
+
}, [
|
|
322
|
+
sentence.src_translit ? (openBlock(), createElementBlock("span", _hoisted_4$6, " \u2015 " + toDisplayString(sentence.src_translit), 1)) : createCommentVNode("", true)
|
|
323
|
+
]);
|
|
324
|
+
}), 128))
|
|
325
|
+
])) : createCommentVNode("", true),
|
|
326
|
+
$data.input != "" ? (openBlock(), createElementBlock("span", {
|
|
327
|
+
key: 1,
|
|
328
|
+
id: "clear",
|
|
329
|
+
class: "small pointer position-absolute top-0 end-0",
|
|
330
|
+
onClick: _cache[2] || (_cache[2] = (...args) => $options.clear && $options.clear(...args))
|
|
331
|
+
}, [
|
|
332
|
+
createVNode(_component_b_icon, { icon: "x-circle" })
|
|
333
|
+
])) : createCommentVNode("", true),
|
|
334
|
+
withDirectives(createElementVNode("textarea", {
|
|
335
|
+
id: "input",
|
|
336
|
+
ref: "input",
|
|
337
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => $data.input = $event),
|
|
338
|
+
class: "form-control textarea-src-target",
|
|
339
|
+
style: normalizeStyle({ "text-align": $options.rtl ? "right" : "left" }),
|
|
340
|
+
autofocus: ""
|
|
341
|
+
}, "\n ", 4), [
|
|
342
|
+
[
|
|
343
|
+
vModelText,
|
|
344
|
+
$data.input,
|
|
345
|
+
void 0,
|
|
346
|
+
{ trim: true }
|
|
347
|
+
]
|
|
348
|
+
]),
|
|
349
|
+
createElementVNode("p", _hoisted_5$6, [
|
|
350
|
+
withDirectives(createElementVNode("input", {
|
|
351
|
+
id: "auto_translate",
|
|
352
|
+
class: "form-check-input",
|
|
353
|
+
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => $data.auto_translate = $event),
|
|
354
|
+
type: "checkbox"
|
|
355
|
+
}, null, 512), [
|
|
356
|
+
[vModelCheckbox, $data.auto_translate]
|
|
357
|
+
]),
|
|
358
|
+
_hoisted_6$5,
|
|
359
|
+
$data.input != "" ? (openBlock(), createElementBlock("small", _hoisted_7, toDisplayString($data.input.length) + " / " + toDisplayString($data.INPUT_MAX_LENGTH), 1)) : createCommentVNode("", true)
|
|
360
|
+
])
|
|
361
|
+
]);
|
|
362
|
+
}
|
|
363
|
+
var input = /* @__PURE__ */ _export_sfc(_sfc_main$7, [["render", _sfc_render$7]]);
|
|
364
|
+
const _sfc_main$6 = {
|
|
365
|
+
props: {
|
|
366
|
+
data: {
|
|
367
|
+
type: Object,
|
|
368
|
+
default: null
|
|
369
|
+
},
|
|
370
|
+
tts: {
|
|
371
|
+
type: Object,
|
|
372
|
+
default: null
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
data() {
|
|
376
|
+
return {
|
|
377
|
+
player: new Audio(),
|
|
378
|
+
playing: false,
|
|
379
|
+
ttsIndex: 0
|
|
380
|
+
};
|
|
381
|
+
},
|
|
382
|
+
computed: {
|
|
383
|
+
rtl() {
|
|
384
|
+
if (!this.data)
|
|
385
|
+
return false;
|
|
386
|
+
return helper.isRTL(this.data.target);
|
|
387
|
+
}
|
|
388
|
+
},
|
|
389
|
+
watch: {
|
|
390
|
+
data(data) {
|
|
391
|
+
if (!data) {
|
|
392
|
+
this.$refs.input.value = "";
|
|
393
|
+
textarea.init(this.$refs.input);
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
this.$refs.input.value = data.sentences.map((sentence) => sentence.trans).join("");
|
|
397
|
+
textarea.autoResize(this.$refs.input);
|
|
398
|
+
},
|
|
399
|
+
tts() {
|
|
400
|
+
this.ttsIndex = 0;
|
|
401
|
+
}
|
|
402
|
+
},
|
|
403
|
+
mounted() {
|
|
404
|
+
textarea.init(this.$refs.input);
|
|
405
|
+
textarea.autoResize(this.$refs.input);
|
|
406
|
+
this.player.addEventListener("ended", () => {
|
|
407
|
+
this.ttsIndex++;
|
|
408
|
+
if (this.ttsIndex >= this.tts.target.length) {
|
|
409
|
+
this.stop();
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
this.play();
|
|
413
|
+
});
|
|
414
|
+
},
|
|
415
|
+
methods: {
|
|
416
|
+
play() {
|
|
417
|
+
if (!this.tts.target) {
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
this.player.src = this.tts.target[this.ttsIndex];
|
|
421
|
+
this.playing = true;
|
|
422
|
+
this.player.play().catch(() => {
|
|
423
|
+
this.playing = false;
|
|
424
|
+
});
|
|
425
|
+
},
|
|
426
|
+
stop() {
|
|
427
|
+
this.playing = false;
|
|
428
|
+
this.ttsIndex = 0;
|
|
429
|
+
this.player.pause();
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
};
|
|
433
|
+
const _hoisted_1$6 = { class: "col-sm-6 section position-relative" };
|
|
434
|
+
const _hoisted_2$5 = {
|
|
435
|
+
key: 0,
|
|
436
|
+
class: "textarea-src-target-header text-truncate position-absolute top-0 start-20 truncate"
|
|
437
|
+
};
|
|
438
|
+
const _hoisted_3$5 = {
|
|
439
|
+
key: 2,
|
|
440
|
+
class: "text-muted small"
|
|
441
|
+
};
|
|
442
|
+
const _hoisted_4$5 = {
|
|
443
|
+
key: 1,
|
|
444
|
+
class: "small text-end text-muted textarea-footer"
|
|
445
|
+
};
|
|
446
|
+
const _hoisted_5$5 = /* @__PURE__ */ createElementVNode("small", null, "Powered by Google Translate", -1);
|
|
447
|
+
const _hoisted_6$4 = [
|
|
448
|
+
_hoisted_5$5
|
|
449
|
+
];
|
|
450
|
+
function _sfc_render$6(_ctx, _cache, $props, $setup, $data, $options) {
|
|
451
|
+
const _component_b_icon = resolveComponent("b-icon");
|
|
452
|
+
return openBlock(), createElementBlock("div", _hoisted_1$6, [
|
|
453
|
+
$props.data ? (openBlock(), createElementBlock("small", _hoisted_2$5, [
|
|
454
|
+
!$data.playing ? (openBlock(), createElementBlock("span", {
|
|
455
|
+
key: 0,
|
|
456
|
+
class: "pointer",
|
|
457
|
+
onClick: _cache[0] || (_cache[0] = (...args) => $options.play && $options.play(...args))
|
|
458
|
+
}, [
|
|
459
|
+
createVNode(_component_b_icon, { icon: "volume-up" })
|
|
460
|
+
])) : createCommentVNode("", true),
|
|
461
|
+
$data.playing ? (openBlock(), createElementBlock("span", {
|
|
462
|
+
key: 1,
|
|
463
|
+
class: "pointer",
|
|
464
|
+
onClick: _cache[1] || (_cache[1] = (...args) => $options.stop && $options.stop(...args))
|
|
465
|
+
}, [
|
|
466
|
+
createVNode(_component_b_icon, { icon: "volume-off" })
|
|
467
|
+
])) : createCommentVNode("", true),
|
|
468
|
+
$props.data.ddictTarget ? (openBlock(), createElementBlock("span", _hoisted_3$5, toDisplayString($props.data.ddictTarget), 1)) : createCommentVNode("", true)
|
|
469
|
+
])) : createCommentVNode("", true),
|
|
470
|
+
createElementVNode("textarea", {
|
|
471
|
+
ref: "input",
|
|
472
|
+
class: "form-control textarea-src-target",
|
|
473
|
+
style: normalizeStyle({ "text-align": $options.rtl ? "right" : "left" }),
|
|
474
|
+
readonly: "",
|
|
475
|
+
spellcheck: "false"
|
|
476
|
+
}, null, 4),
|
|
477
|
+
$props.data ? (openBlock(), createElementBlock("p", _hoisted_4$5, _hoisted_6$4)) : createCommentVNode("", true)
|
|
478
|
+
]);
|
|
479
|
+
}
|
|
480
|
+
var result = /* @__PURE__ */ _export_sfc(_sfc_main$6, [["render", _sfc_render$6]]);
|
|
481
|
+
const _sfc_main$5 = {
|
|
482
|
+
props: {
|
|
483
|
+
data: {
|
|
484
|
+
type: Object,
|
|
485
|
+
default: null
|
|
486
|
+
}
|
|
487
|
+
},
|
|
488
|
+
data() {
|
|
489
|
+
return {
|
|
490
|
+
name: "Definitions"
|
|
491
|
+
};
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
const _hoisted_1$5 = {
|
|
495
|
+
key: 0,
|
|
496
|
+
class: "card border-success text-success section"
|
|
497
|
+
};
|
|
498
|
+
const _hoisted_2$4 = { class: "card-header" };
|
|
499
|
+
const _hoisted_3$4 = { class: "list-group list-group-flush" };
|
|
500
|
+
const _hoisted_4$4 = { class: "card-title text-muted title" };
|
|
501
|
+
const _hoisted_5$4 = /* @__PURE__ */ createElementVNode("br", null, null, -1);
|
|
502
|
+
const _hoisted_6$3 = { class: "text-muted" };
|
|
503
|
+
function _sfc_render$5(_ctx, _cache, $props, $setup, $data, $options) {
|
|
504
|
+
return $props.data && $props.data.definitions ? (openBlock(), createElementBlock("div", _hoisted_1$5, [
|
|
505
|
+
createElementVNode("div", _hoisted_2$4, toDisplayString($data.name), 1),
|
|
506
|
+
createElementVNode("ul", _hoisted_3$4, [
|
|
507
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($props.data.definitions, (dict, index) => {
|
|
508
|
+
return openBlock(), createElementBlock("li", {
|
|
509
|
+
key: `${dict.pos}-${index}`,
|
|
510
|
+
class: "list-group-item"
|
|
511
|
+
}, [
|
|
512
|
+
createElementVNode("h5", _hoisted_4$4, toDisplayString(dict.pos), 1),
|
|
513
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(dict.entry, (entry, index2) => {
|
|
514
|
+
return openBlock(), createElementBlock("div", {
|
|
515
|
+
key: `${entry.definition_id}-${index2}`
|
|
516
|
+
}, [
|
|
517
|
+
createElementVNode("span", null, toDisplayString(entry.gloss), 1),
|
|
518
|
+
_hoisted_5$4,
|
|
519
|
+
createElementVNode("small", _hoisted_6$3, toDisplayString(entry.example), 1)
|
|
520
|
+
]);
|
|
521
|
+
}), 128))
|
|
522
|
+
]);
|
|
523
|
+
}), 128))
|
|
524
|
+
])
|
|
525
|
+
])) : createCommentVNode("", true);
|
|
526
|
+
}
|
|
527
|
+
var dictSrc = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["render", _sfc_render$5]]);
|
|
528
|
+
const _sfc_main$4 = {
|
|
529
|
+
props: {
|
|
530
|
+
data: {
|
|
531
|
+
type: Object,
|
|
532
|
+
default: null
|
|
533
|
+
}
|
|
534
|
+
},
|
|
535
|
+
data() {
|
|
536
|
+
return {
|
|
537
|
+
name: "Translations"
|
|
538
|
+
};
|
|
539
|
+
},
|
|
540
|
+
methods: {
|
|
541
|
+
translate(word) {
|
|
542
|
+
this.$emit("translate", word);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
};
|
|
546
|
+
const _hoisted_1$4 = {
|
|
547
|
+
key: 0,
|
|
548
|
+
class: "card border-primary text-primary section"
|
|
549
|
+
};
|
|
550
|
+
const _hoisted_2$3 = { class: "card-header" };
|
|
551
|
+
const _hoisted_3$3 = { class: "list-group list-group-flush" };
|
|
552
|
+
const _hoisted_4$3 = { class: "card-title text-muted title" };
|
|
553
|
+
const _hoisted_5$3 = ["onClick"];
|
|
554
|
+
const _hoisted_6$2 = { class: "text-muted" };
|
|
555
|
+
function _sfc_render$4(_ctx, _cache, $props, $setup, $data, $options) {
|
|
556
|
+
return $props.data && $props.data.dict ? (openBlock(), createElementBlock("div", _hoisted_1$4, [
|
|
557
|
+
createElementVNode("div", _hoisted_2$3, toDisplayString($data.name), 1),
|
|
558
|
+
createElementVNode("ul", _hoisted_3$3, [
|
|
559
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($props.data.dict, (dict, index) => {
|
|
560
|
+
return openBlock(), createElementBlock("li", {
|
|
561
|
+
key: `${dict.pos}-${index}`,
|
|
562
|
+
class: "list-group-item"
|
|
563
|
+
}, [
|
|
564
|
+
createElementVNode("h5", _hoisted_4$3, toDisplayString(dict.pos), 1),
|
|
565
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(dict.entry, (entry, index2) => {
|
|
566
|
+
return openBlock(), createElementBlock("div", {
|
|
567
|
+
key: `${entry.word}-${index2}`
|
|
568
|
+
}, [
|
|
569
|
+
createElementVNode("span", {
|
|
570
|
+
class: "badge bg-primary",
|
|
571
|
+
onClick: ($event) => $options.translate(entry.word)
|
|
572
|
+
}, toDisplayString(entry.word), 9, _hoisted_5$3),
|
|
573
|
+
createElementVNode("small", _hoisted_6$2, " \u2015 " + toDisplayString(entry.reverse_translation.join(", ")), 1)
|
|
574
|
+
]);
|
|
575
|
+
}), 128))
|
|
576
|
+
]);
|
|
577
|
+
}), 128))
|
|
578
|
+
])
|
|
579
|
+
])) : createCommentVNode("", true);
|
|
580
|
+
}
|
|
581
|
+
var dictTarget = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["render", _sfc_render$4]]);
|
|
582
|
+
const _sfc_main$3 = {
|
|
583
|
+
props: {
|
|
584
|
+
data: {
|
|
585
|
+
type: Object,
|
|
586
|
+
default: null
|
|
587
|
+
}
|
|
588
|
+
},
|
|
589
|
+
data() {
|
|
590
|
+
return {
|
|
591
|
+
name: "Examples",
|
|
592
|
+
more: false
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
const _hoisted_1$3 = {
|
|
597
|
+
key: 0,
|
|
598
|
+
class: "card border-dark text-dark section"
|
|
599
|
+
};
|
|
600
|
+
const _hoisted_2$2 = { class: "card-header" };
|
|
601
|
+
const _hoisted_3$2 = { class: "list-group list-group-flush" };
|
|
602
|
+
const _hoisted_4$2 = ["innerHTML"];
|
|
603
|
+
const _hoisted_5$2 = {
|
|
604
|
+
key: 0,
|
|
605
|
+
class: "list-group list-group-flush"
|
|
606
|
+
};
|
|
607
|
+
const _hoisted_6$1 = ["innerHTML"];
|
|
608
|
+
function _sfc_render$3(_ctx, _cache, $props, $setup, $data, $options) {
|
|
609
|
+
const _component_b_icon = resolveComponent("b-icon");
|
|
610
|
+
return $props.data && $props.data.examples ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
|
|
611
|
+
createElementVNode("div", _hoisted_2$2, [
|
|
612
|
+
createTextVNode(toDisplayString($data.name) + " ", 1),
|
|
613
|
+
$props.data.examples.example.length > 1 && !$data.more ? (openBlock(), createElementBlock("span", {
|
|
614
|
+
key: 0,
|
|
615
|
+
style: { "float": "right" },
|
|
616
|
+
onClick: _cache[0] || (_cache[0] = ($event) => $data.more = true)
|
|
617
|
+
}, [
|
|
618
|
+
createVNode(_component_b_icon, { icon: "arrows-expand" })
|
|
619
|
+
])) : createCommentVNode("", true),
|
|
620
|
+
$props.data.examples.example.length > 1 && $data.more ? (openBlock(), createElementBlock("span", {
|
|
621
|
+
key: 1,
|
|
622
|
+
style: { "float": "right" },
|
|
623
|
+
onClick: _cache[1] || (_cache[1] = ($event) => $data.more = false)
|
|
624
|
+
}, [
|
|
625
|
+
createVNode(_component_b_icon, { icon: "arrows-collapse" })
|
|
626
|
+
])) : createCommentVNode("", true)
|
|
627
|
+
]),
|
|
628
|
+
createElementVNode("ul", _hoisted_3$2, [
|
|
629
|
+
createElementVNode("li", {
|
|
630
|
+
class: "list-group-item",
|
|
631
|
+
innerHTML: $props.data.examples.example[0].text
|
|
632
|
+
}, null, 8, _hoisted_4$2)
|
|
633
|
+
]),
|
|
634
|
+
createVNode(Transition, { name: "fade" }, {
|
|
635
|
+
default: withCtx(() => [
|
|
636
|
+
$data.more ? (openBlock(), createElementBlock("ul", _hoisted_5$2, [
|
|
637
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($props.data.examples.example.slice(1), (example2, index) => {
|
|
638
|
+
return openBlock(), createElementBlock("li", {
|
|
639
|
+
key: `${example2.definition_id}-${index}`,
|
|
640
|
+
class: "list-group-item",
|
|
641
|
+
innerHTML: example2.text
|
|
642
|
+
}, null, 8, _hoisted_6$1);
|
|
643
|
+
}), 128))
|
|
644
|
+
])) : createCommentVNode("", true)
|
|
645
|
+
]),
|
|
646
|
+
_: 1
|
|
647
|
+
})
|
|
648
|
+
])) : createCommentVNode("", true);
|
|
649
|
+
}
|
|
650
|
+
var example = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["render", _sfc_render$3]]);
|
|
651
|
+
const _sfc_main$2 = {
|
|
652
|
+
props: {
|
|
653
|
+
data: {
|
|
654
|
+
type: Object,
|
|
655
|
+
default: null
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
data() {
|
|
659
|
+
return {
|
|
660
|
+
name: "Synonyms"
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
const _hoisted_1$2 = {
|
|
665
|
+
key: 0,
|
|
666
|
+
class: "card border-info text-info section"
|
|
667
|
+
};
|
|
668
|
+
const _hoisted_2$1 = { class: "card-header" };
|
|
669
|
+
const _hoisted_3$1 = { class: "list-group list-group-flush" };
|
|
670
|
+
const _hoisted_4$1 = { class: "card-title text-muted title" };
|
|
671
|
+
const _hoisted_5$1 = ["onClick"];
|
|
672
|
+
const _hoisted_6 = /* @__PURE__ */ createElementVNode("span", null, null, -1);
|
|
673
|
+
function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
|
|
674
|
+
return $props.data && $props.data.synsets ? (openBlock(), createElementBlock("div", _hoisted_1$2, [
|
|
675
|
+
createElementVNode("div", _hoisted_2$1, toDisplayString($data.name), 1),
|
|
676
|
+
createElementVNode("ul", _hoisted_3$1, [
|
|
677
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($props.data.synsets, (dict, index) => {
|
|
678
|
+
return openBlock(), createElementBlock("li", {
|
|
679
|
+
key: `${dict.pos}-${index}`,
|
|
680
|
+
class: "list-group-item"
|
|
681
|
+
}, [
|
|
682
|
+
createElementVNode("h5", _hoisted_4$1, toDisplayString(dict.pos), 1),
|
|
683
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(dict.entry, (entry, index2) => {
|
|
684
|
+
return openBlock(), createElementBlock("div", {
|
|
685
|
+
key: `${entry.definition_id}-${index2}`
|
|
686
|
+
}, [
|
|
687
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(entry.synonym, (synonym, index3) => {
|
|
688
|
+
return openBlock(), createElementBlock("span", {
|
|
689
|
+
key: `${synonym}-${index3}`
|
|
690
|
+
}, [
|
|
691
|
+
createElementVNode("span", {
|
|
692
|
+
class: "badge bg-info clickable-badge",
|
|
693
|
+
onClick: ($event) => _ctx.$emit("translate", synonym)
|
|
694
|
+
}, toDisplayString(synonym), 9, _hoisted_5$1),
|
|
695
|
+
_hoisted_6
|
|
696
|
+
]);
|
|
697
|
+
}), 128))
|
|
698
|
+
]);
|
|
699
|
+
}), 128))
|
|
700
|
+
]);
|
|
701
|
+
}), 128))
|
|
702
|
+
])
|
|
703
|
+
])) : createCommentVNode("", true);
|
|
704
|
+
}
|
|
705
|
+
var syno = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$2]]);
|
|
706
|
+
const _sfc_main$1 = {
|
|
707
|
+
props: {
|
|
708
|
+
data: {
|
|
709
|
+
type: Object,
|
|
710
|
+
default: null
|
|
711
|
+
}
|
|
712
|
+
},
|
|
713
|
+
data() {
|
|
714
|
+
return {
|
|
715
|
+
name: "See also"
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
};
|
|
719
|
+
const _hoisted_1$1 = {
|
|
720
|
+
key: 0,
|
|
721
|
+
class: "card border-secondary text-secondary section"
|
|
722
|
+
};
|
|
723
|
+
const _hoisted_2 = { class: "card-header" };
|
|
724
|
+
const _hoisted_3 = { class: "card-body" };
|
|
725
|
+
const _hoisted_4 = ["onClick"];
|
|
726
|
+
const _hoisted_5 = /* @__PURE__ */ createElementVNode("span", null, null, -1);
|
|
727
|
+
function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) {
|
|
728
|
+
return $props.data && $props.data.related_words && $props.data.related_words.word ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
729
|
+
createElementVNode("div", _hoisted_2, toDisplayString($data.name), 1),
|
|
730
|
+
createElementVNode("div", _hoisted_3, [
|
|
731
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList($props.data.related_words.word, (word, index) => {
|
|
732
|
+
return openBlock(), createElementBlock("span", {
|
|
733
|
+
key: `${word}-${index}`
|
|
734
|
+
}, [
|
|
735
|
+
createElementVNode("span", {
|
|
736
|
+
class: "badge bg-secondary clickable-badge",
|
|
737
|
+
onClick: ($event) => _ctx.$emit("translate", word)
|
|
738
|
+
}, toDisplayString(word), 9, _hoisted_4),
|
|
739
|
+
_hoisted_5
|
|
740
|
+
]);
|
|
741
|
+
}), 128))
|
|
742
|
+
])
|
|
743
|
+
])) : createCommentVNode("", true);
|
|
744
|
+
}
|
|
745
|
+
var more = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["render", _sfc_render$1]]);
|
|
746
|
+
const _sfc_main = {
|
|
747
|
+
name: "Popup",
|
|
748
|
+
components: {
|
|
749
|
+
appSelects: selects,
|
|
750
|
+
appInput: input,
|
|
751
|
+
appResult: result,
|
|
752
|
+
appDictSrc: dictSrc,
|
|
753
|
+
appDictTarget: dictTarget,
|
|
754
|
+
appExample: example,
|
|
755
|
+
appSyno: syno,
|
|
756
|
+
appMore: more
|
|
757
|
+
},
|
|
758
|
+
props: {
|
|
759
|
+
export_data: {
|
|
760
|
+
type: Object,
|
|
761
|
+
default: null
|
|
762
|
+
},
|
|
763
|
+
export_select: {
|
|
764
|
+
type: Object,
|
|
765
|
+
default: null
|
|
766
|
+
},
|
|
767
|
+
export_tts: {
|
|
768
|
+
type: Object,
|
|
769
|
+
default: null
|
|
770
|
+
}
|
|
771
|
+
},
|
|
772
|
+
data() {
|
|
773
|
+
return {
|
|
774
|
+
data: null,
|
|
775
|
+
select: null,
|
|
776
|
+
tts: null,
|
|
777
|
+
replace: ""
|
|
778
|
+
};
|
|
779
|
+
},
|
|
780
|
+
computed: {
|
|
781
|
+
rtl() {
|
|
782
|
+
if (!this.data)
|
|
783
|
+
return false;
|
|
784
|
+
return helper.isRTL(this.data.target);
|
|
785
|
+
}
|
|
786
|
+
},
|
|
787
|
+
watch: {
|
|
788
|
+
export_data(data) {
|
|
789
|
+
this.data = data;
|
|
790
|
+
if (data.text && this.replace != data.text)
|
|
791
|
+
this.replace = data.text;
|
|
792
|
+
},
|
|
793
|
+
export_select(select) {
|
|
794
|
+
this.select = select;
|
|
795
|
+
},
|
|
796
|
+
export_tts(tts) {
|
|
797
|
+
this.tts = tts;
|
|
798
|
+
}
|
|
799
|
+
},
|
|
800
|
+
methods: {
|
|
801
|
+
clear() {
|
|
802
|
+
this.data = null;
|
|
803
|
+
this.$emit("clear");
|
|
804
|
+
},
|
|
805
|
+
translateReplace(input2) {
|
|
806
|
+
return this.translate(input2, true);
|
|
807
|
+
},
|
|
808
|
+
translateSwap(input2) {
|
|
809
|
+
return this.translate(input2, true, true);
|
|
810
|
+
},
|
|
811
|
+
translate(input2, is_replace, is_swap) {
|
|
812
|
+
if (is_swap) {
|
|
813
|
+
if (!this.data.src || this.data.src === "auto" || !this.data.target) {
|
|
814
|
+
return;
|
|
815
|
+
}
|
|
816
|
+
const select = JSON.parse(JSON.stringify(this.select));
|
|
817
|
+
select.src = this.data.target;
|
|
818
|
+
select.target = this.data.src;
|
|
819
|
+
this.$emit("srctarget", select);
|
|
820
|
+
}
|
|
821
|
+
window.scrollTo(0, 0);
|
|
822
|
+
this.clear();
|
|
823
|
+
if (is_replace) {
|
|
824
|
+
this.replace = input2;
|
|
825
|
+
}
|
|
826
|
+
this.$emit("translate", input2);
|
|
827
|
+
},
|
|
828
|
+
srctarget(select) {
|
|
829
|
+
this.$emit("srctarget", select);
|
|
830
|
+
if (this.data) {
|
|
831
|
+
const input2 = this.data.sentences.map((sentence) => sentence.orig).join("");
|
|
832
|
+
this.$emit("translate", input2);
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
}
|
|
836
|
+
};
|
|
837
|
+
const _hoisted_1 = { class: "row section" };
|
|
838
|
+
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
839
|
+
const _component_app_selects = resolveComponent("app-selects");
|
|
840
|
+
const _component_app_input = resolveComponent("app-input");
|
|
841
|
+
const _component_app_result = resolveComponent("app-result");
|
|
842
|
+
const _component_app_dict_target = resolveComponent("app-dict-target");
|
|
843
|
+
const _component_app_dict_src = resolveComponent("app-dict-src");
|
|
844
|
+
const _component_app_syno = resolveComponent("app-syno");
|
|
845
|
+
const _component_app_more = resolveComponent("app-more");
|
|
846
|
+
const _component_app_example = resolveComponent("app-example");
|
|
847
|
+
return openBlock(), createElementBlock("div", null, [
|
|
848
|
+
createVNode(_component_app_selects, {
|
|
849
|
+
select: $data.select,
|
|
850
|
+
onSrctarget: $options.srctarget
|
|
851
|
+
}, null, 8, ["select", "onSrctarget"]),
|
|
852
|
+
createElementVNode("div", _hoisted_1, [
|
|
853
|
+
createVNode(_component_app_input, {
|
|
854
|
+
data: $data.data,
|
|
855
|
+
tts: $data.tts,
|
|
856
|
+
replace: $data.replace,
|
|
857
|
+
onTranslate: $options.translate,
|
|
858
|
+
onClear: $options.clear
|
|
859
|
+
}, null, 8, ["data", "tts", "replace", "onTranslate", "onClear"]),
|
|
860
|
+
createVNode(_component_app_result, {
|
|
861
|
+
data: $data.data,
|
|
862
|
+
tts: $data.tts
|
|
863
|
+
}, null, 8, ["data", "tts"])
|
|
864
|
+
]),
|
|
865
|
+
createElementVNode("div", {
|
|
866
|
+
class: "card-columns",
|
|
867
|
+
style: normalizeStyle({ "text-align": $options.rtl ? "right" : "left" })
|
|
868
|
+
}, [
|
|
869
|
+
createVNode(_component_app_dict_target, {
|
|
870
|
+
data: $data.data,
|
|
871
|
+
onTranslate: $options.translateSwap
|
|
872
|
+
}, null, 8, ["data", "onTranslate"]),
|
|
873
|
+
createVNode(_component_app_dict_src, { data: $data.data }, null, 8, ["data"]),
|
|
874
|
+
createVNode(_component_app_syno, {
|
|
875
|
+
data: $data.data,
|
|
876
|
+
onTranslate: $options.translateReplace
|
|
877
|
+
}, null, 8, ["data", "onTranslate"]),
|
|
878
|
+
createVNode(_component_app_more, {
|
|
879
|
+
data: $data.data,
|
|
880
|
+
onTranslate: $options.translateReplace
|
|
881
|
+
}, null, 8, ["data", "onTranslate"]),
|
|
882
|
+
createVNode(_component_app_example, { data: $data.data }, null, 8, ["data"])
|
|
883
|
+
], 4)
|
|
884
|
+
]);
|
|
885
|
+
}
|
|
886
|
+
var Popup = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
887
|
+
export { Popup as default };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(function(p,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(p=typeof globalThis!="undefined"?globalThis:p||self,t(p.Popup={},p.Vue))})(this,function(p,t){"use strict";var Qt="",d=(e,s)=>{const a=e.__vccOpts||e;for(const[i,n]of s)a[i]=n;return a};const x={props:{select:{type:Object,default:null}},data(){return{src:"",target:"",warning:!1}},watch:{select(){this.src=this.select.src,this.target=this.select.target}},methods:{warn(){this.warning=!0,setTimeout(()=>{this.warning=!1},2e3)},swap(){if(!this.select.srcs.hasOwnProperty(this.target)||!this.select.targets.hasOwnProperty(this.src)){this.warn();return}const e=this.target;this.target=this.src,this.src=e,this.srctarget()},srctarget(){const e=JSON.parse(JSON.stringify(this.select));e.src=this.src,e.target=this.target,this.$emit("srctarget",e)}}},V={key:0,class:"row justify-content-center mb-2"},C={class:"col-5"},T=["value"],$={class:"col-auto text-center"},b={id:"swap",class:"form-control bg-light pointer"},S={class:"col-5"},w=["value"];function L(e,s,a,i,n,l){const o=t.resolveComponent("b-icon");return a.select?(t.openBlock(),t.createElementBlock("div",V,[t.createElementVNode("div",C,[t.withDirectives(t.createElementVNode("select",{"onUpdate:modelValue":s[0]||(s[0]=r=>n.src=r),class:"form-select",onChange:s[1]||(s[1]=(...r)=>l.srctarget&&l.srctarget(...r))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.select.srcs,(r,c)=>(t.openBlock(),t.createElementBlock("option",{value:c,key:c},t.toDisplayString(r),9,T))),128))],544),[[t.vModelSelect,n.src]])]),t.createElementVNode("div",$,[t.createElementVNode("span",b,[n.src!="auto"?(t.openBlock(),t.createBlock(o,{key:0,icon:"arrow-left-right",onClick:l.swap},null,8,["onClick"])):t.createCommentVNode("",!0),n.src=="auto"?(t.openBlock(),t.createBlock(o,{key:1,icon:"arrow-right"})):t.createCommentVNode("",!0)])]),t.createElementVNode("div",S,[t.withDirectives(t.createElementVNode("select",{"onUpdate:modelValue":s[2]||(s[2]=r=>n.target=r),class:"form-select",onChange:s[3]||(s[3]=(...r)=>l.srctarget&&l.srctarget(...r))},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.select.targets,(r,c)=>(t.openBlock(),t.createElementBlock("option",{value:c,key:c},t.toDisplayString(r),9,w))),128))],544),[[t.vModelSelect,n.target]])])])):t.createCommentVNode("",!0)}var D=d(x,[["render",L]]),k={INPUT_MAX_LENGTH:5e3,INPUT_DELAY:1e3},m={init:O,autoResize:j};const g=100,E=600,I=10;function O(e,s){s&&(e.maxlength=s),e.spellcheck=!1,f(e,g)}function j(e){if(e.value==""){f(e,g);return}if(e.scrollHeight<g){f(e,g);return}if(e.scrollHeight>E){f(e,E);return}e.style.height.replace("px","")>e.scrollHeight||f(e,e.scrollHeight+I)}function f(e,s){e.style.height=`${s}px`}var y={isRTL:H};function H(e){return["ar","fa","iw","yi","ur","pa"].indexOf(e)>-1}const B="auto_translate",M={props:{data:{type:Object,default:null},tts:{type:Object,default:null},replace:{type:String,default:""}},data(){return{input:"",INPUT_MAX_LENGTH:k.INPUT_MAX_LENGTH,input_timeout:null,player:new Audio,playing:!1,ttsIndex:0,auto_translate:!0,firstTime:!0}},computed:{rtl(){return this.data?y.isRTL(this.data.src):!1}},watch:{replace(e){this.input=e,(this.firstTime||!this.auto_translate)&&setTimeout(()=>{this.$refs.input.select()},100),this.firstTime=!1},tts(){this.ttsIndex=0},auto_translate(e){e&&this.translate(),localStorage.setItem(B,e)}},mounted(){m.init(this.$refs.input,k.INPUT_MAX_LENGTH),this.player.addEventListener("ended",()=>{if(this.ttsIndex++,this.ttsIndex>=this.tts.src.length){this.stop();return}this.play()}),this.$refs.input.addEventListener("input",()=>{m.autoResize(this.$refs.input),!!this.auto_translate&&(clearTimeout(this.input_timeout),this.input_timeout=setTimeout(this.translate,k.INPUT_DELAY))}),this.$refs.input.addEventListener("keyup",e=>{this.auto_translate||e&&e.keyCode===13&&this.translate()})},created(){localStorage.getItem(B)==="false"&&(this.auto_translate=!1)},methods:{play(){!this.tts.src||(this.player.src=this.tts.src[this.ttsIndex],this.playing=!0,this.player.play().catch(()=>{this.playing=!1}))},stop(){this.playing=!1,this.ttsIndex=0,this.player.pause()},clear(){this.$emit("clear"),this.input="",m.init(this.$refs.input,k.INPUT_MAX_LENGTH),this.$refs.input.focus()},translate(){if(!this.input){this.clear();return}this.$emit("translate",this.input)}}},A={class:"col-sm-6 section position-relative"},P={key:0,class:"textarea-src-target-header text-truncate position-absolute top-0 start-20 truncate"},R={key:2,class:"text-muted small"},U={key:0},F={class:"small form-check form-switch text-muted textarea-footer"},G=t.createElementVNode("label",{for:"auto_translate",class:"form-check-label small"},"Auto translate",-1),z={key:0,class:"float-end"};function X(e,s,a,i,n,l){const o=t.resolveComponent("b-icon");return t.openBlock(),t.createElementBlock("div",A,[a.data?(t.openBlock(),t.createElementBlock("small",P,[n.playing?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"pointer",onClick:s[0]||(s[0]=(...r)=>l.play&&l.play(...r))},[t.createVNode(o,{icon:"volume-up"})])),n.playing?(t.openBlock(),t.createElementBlock("span",{key:1,class:"pointer",onClick:s[1]||(s[1]=(...r)=>l.stop&&l.stop(...r))},[t.createVNode(o,{icon:"volume-off"})])):t.createCommentVNode("",!0),a.data.ddictSrc?(t.openBlock(),t.createElementBlock("span",R,t.toDisplayString(a.data.ddictSrc),1)):t.createCommentVNode("",!0),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.data.sentences,(r,c)=>(t.openBlock(),t.createElementBlock("span",{key:`${r.src_translit}-${c}`,class:"text-muted small"},[r.src_translit?(t.openBlock(),t.createElementBlock("span",U," \u2015 "+t.toDisplayString(r.src_translit),1)):t.createCommentVNode("",!0)]))),128))])):t.createCommentVNode("",!0),n.input!=""?(t.openBlock(),t.createElementBlock("span",{key:1,id:"clear",class:"small pointer position-absolute top-0 end-0",onClick:s[2]||(s[2]=(...r)=>l.clear&&l.clear(...r))},[t.createVNode(o,{icon:"x-circle"})])):t.createCommentVNode("",!0),t.withDirectives(t.createElementVNode("textarea",{id:"input",ref:"input","onUpdate:modelValue":s[3]||(s[3]=r=>n.input=r),class:"form-control textarea-src-target",style:t.normalizeStyle({"text-align":l.rtl?"right":"left"}),autofocus:""},`
|
|
2
|
+
`,4),[[t.vModelText,n.input,void 0,{trim:!0}]]),t.createElementVNode("p",F,[t.withDirectives(t.createElementVNode("input",{id:"auto_translate",class:"form-check-input","onUpdate:modelValue":s[4]||(s[4]=r=>n.auto_translate=r),type:"checkbox"},null,512),[[t.vModelCheckbox,n.auto_translate]]),G,n.input!=""?(t.openBlock(),t.createElementBlock("small",z,t.toDisplayString(n.input.length)+" / "+t.toDisplayString(n.INPUT_MAX_LENGTH),1)):t.createCommentVNode("",!0)])])}var J=d(M,[["render",X]]);const Y={props:{data:{type:Object,default:null},tts:{type:Object,default:null}},data(){return{player:new Audio,playing:!1,ttsIndex:0}},computed:{rtl(){return this.data?y.isRTL(this.data.target):!1}},watch:{data(e){if(!e){this.$refs.input.value="",m.init(this.$refs.input);return}this.$refs.input.value=e.sentences.map(s=>s.trans).join(""),m.autoResize(this.$refs.input)},tts(){this.ttsIndex=0}},mounted(){m.init(this.$refs.input),m.autoResize(this.$refs.input),this.player.addEventListener("ended",()=>{if(this.ttsIndex++,this.ttsIndex>=this.tts.target.length){this.stop();return}this.play()})},methods:{play(){!this.tts.target||(this.player.src=this.tts.target[this.ttsIndex],this.playing=!0,this.player.play().catch(()=>{this.playing=!1}))},stop(){this.playing=!1,this.ttsIndex=0,this.player.pause()}}},q={class:"col-sm-6 section position-relative"},K={key:0,class:"textarea-src-target-header text-truncate position-absolute top-0 start-20 truncate"},Q={key:2,class:"text-muted small"},W={key:1,class:"small text-end text-muted textarea-footer"},Z=[t.createElementVNode("small",null,"Powered by Google Translate",-1)];function v(e,s,a,i,n,l){const o=t.resolveComponent("b-icon");return t.openBlock(),t.createElementBlock("div",q,[a.data?(t.openBlock(),t.createElementBlock("small",K,[n.playing?t.createCommentVNode("",!0):(t.openBlock(),t.createElementBlock("span",{key:0,class:"pointer",onClick:s[0]||(s[0]=(...r)=>l.play&&l.play(...r))},[t.createVNode(o,{icon:"volume-up"})])),n.playing?(t.openBlock(),t.createElementBlock("span",{key:1,class:"pointer",onClick:s[1]||(s[1]=(...r)=>l.stop&&l.stop(...r))},[t.createVNode(o,{icon:"volume-off"})])):t.createCommentVNode("",!0),a.data.ddictTarget?(t.openBlock(),t.createElementBlock("span",Q,t.toDisplayString(a.data.ddictTarget),1)):t.createCommentVNode("",!0)])):t.createCommentVNode("",!0),t.createElementVNode("textarea",{ref:"input",class:"form-control textarea-src-target",style:t.normalizeStyle({"text-align":l.rtl?"right":"left"}),readonly:"",spellcheck:"false"},null,4),a.data?(t.openBlock(),t.createElementBlock("p",W,Z)):t.createCommentVNode("",!0)])}var tt=d(Y,[["render",v]]);const et={props:{data:{type:Object,default:null}},data(){return{name:"Definitions"}}},nt={key:0,class:"card border-success text-success section"},st={class:"card-header"},at={class:"list-group list-group-flush"},rt={class:"card-title text-muted title"},lt=t.createElementVNode("br",null,null,-1),ot={class:"text-muted"};function ct(e,s,a,i,n,l){return a.data&&a.data.definitions?(t.openBlock(),t.createElementBlock("div",nt,[t.createElementVNode("div",st,t.toDisplayString(n.name),1),t.createElementVNode("ul",at,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.data.definitions,(o,r)=>(t.openBlock(),t.createElementBlock("li",{key:`${o.pos}-${r}`,class:"list-group-item"},[t.createElementVNode("h5",rt,t.toDisplayString(o.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.definition_id}-${_}`},[t.createElementVNode("span",null,t.toDisplayString(c.gloss),1),lt,t.createElementVNode("small",ot,t.toDisplayString(c.example),1)]))),128))]))),128))])])):t.createCommentVNode("",!0)}var it=d(et,[["render",ct]]);const dt={props:{data:{type:Object,default:null}},data(){return{name:"Translations"}},methods:{translate(e){this.$emit("translate",e)}}},pt={key:0,class:"card border-primary text-primary section"},mt={class:"card-header"},_t={class:"list-group list-group-flush"},ht={class:"card-title text-muted title"},ft=["onClick"],kt={class:"text-muted"};function gt(e,s,a,i,n,l){return a.data&&a.data.dict?(t.openBlock(),t.createElementBlock("div",pt,[t.createElementVNode("div",mt,t.toDisplayString(n.name),1),t.createElementVNode("ul",_t,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.data.dict,(o,r)=>(t.openBlock(),t.createElementBlock("li",{key:`${o.pos}-${r}`,class:"list-group-item"},[t.createElementVNode("h5",ht,t.toDisplayString(o.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.word}-${_}`},[t.createElementVNode("span",{class:"badge bg-primary",onClick:h=>l.translate(c.word)},t.toDisplayString(c.word),9,ft),t.createElementVNode("small",kt," \u2015 "+t.toDisplayString(c.reverse_translation.join(", ")),1)]))),128))]))),128))])])):t.createCommentVNode("",!0)}var yt=d(dt,[["render",gt]]);const ut={props:{data:{type:Object,default:null}},data(){return{name:"Examples",more:!1}}},Et={key:0,class:"card border-dark text-dark section"},Bt={class:"card-header"},Nt={class:"list-group list-group-flush"},xt=["innerHTML"],Vt={key:0,class:"list-group list-group-flush"},Ct=["innerHTML"];function Tt(e,s,a,i,n,l){const o=t.resolveComponent("b-icon");return a.data&&a.data.examples?(t.openBlock(),t.createElementBlock("div",Et,[t.createElementVNode("div",Bt,[t.createTextVNode(t.toDisplayString(n.name)+" ",1),a.data.examples.example.length>1&&!n.more?(t.openBlock(),t.createElementBlock("span",{key:0,style:{float:"right"},onClick:s[0]||(s[0]=r=>n.more=!0)},[t.createVNode(o,{icon:"arrows-expand"})])):t.createCommentVNode("",!0),a.data.examples.example.length>1&&n.more?(t.openBlock(),t.createElementBlock("span",{key:1,style:{float:"right"},onClick:s[1]||(s[1]=r=>n.more=!1)},[t.createVNode(o,{icon:"arrows-collapse"})])):t.createCommentVNode("",!0)]),t.createElementVNode("ul",Nt,[t.createElementVNode("li",{class:"list-group-item",innerHTML:a.data.examples.example[0].text},null,8,xt)]),t.createVNode(t.Transition,{name:"fade"},{default:t.withCtx(()=>[n.more?(t.openBlock(),t.createElementBlock("ul",Vt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.data.examples.example.slice(1),(r,c)=>(t.openBlock(),t.createElementBlock("li",{key:`${r.definition_id}-${c}`,class:"list-group-item",innerHTML:r.text},null,8,Ct))),128))])):t.createCommentVNode("",!0)]),_:1})])):t.createCommentVNode("",!0)}var $t=d(ut,[["render",Tt]]);const bt={props:{data:{type:Object,default:null}},data(){return{name:"Synonyms"}}},St={key:0,class:"card border-info text-info section"},wt={class:"card-header"},Lt={class:"list-group list-group-flush"},Dt={class:"card-title text-muted title"},It=["onClick"],Ot=t.createElementVNode("span",null,null,-1);function jt(e,s,a,i,n,l){return a.data&&a.data.synsets?(t.openBlock(),t.createElementBlock("div",St,[t.createElementVNode("div",wt,t.toDisplayString(n.name),1),t.createElementVNode("ul",Lt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.data.synsets,(o,r)=>(t.openBlock(),t.createElementBlock("li",{key:`${o.pos}-${r}`,class:"list-group-item"},[t.createElementVNode("h5",Dt,t.toDisplayString(o.pos),1),(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(o.entry,(c,_)=>(t.openBlock(),t.createElementBlock("div",{key:`${c.definition_id}-${_}`},[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(c.synonym,(h,u)=>(t.openBlock(),t.createElementBlock("span",{key:`${h}-${u}`},[t.createElementVNode("span",{class:"badge bg-info clickable-badge",onClick:N=>e.$emit("translate",h)},t.toDisplayString(h),9,It),Ot]))),128))]))),128))]))),128))])])):t.createCommentVNode("",!0)}var Ht=d(bt,[["render",jt]]);const Mt={props:{data:{type:Object,default:null}},data(){return{name:"See also"}}},At={key:0,class:"card border-secondary text-secondary section"},Pt={class:"card-header"},Rt={class:"card-body"},Ut=["onClick"],Ft=t.createElementVNode("span",null,null,-1);function Gt(e,s,a,i,n,l){return a.data&&a.data.related_words&&a.data.related_words.word?(t.openBlock(),t.createElementBlock("div",At,[t.createElementVNode("div",Pt,t.toDisplayString(n.name),1),t.createElementVNode("div",Rt,[(t.openBlock(!0),t.createElementBlock(t.Fragment,null,t.renderList(a.data.related_words.word,(o,r)=>(t.openBlock(),t.createElementBlock("span",{key:`${o}-${r}`},[t.createElementVNode("span",{class:"badge bg-secondary clickable-badge",onClick:c=>e.$emit("translate",o)},t.toDisplayString(o),9,Ut),Ft]))),128))])])):t.createCommentVNode("",!0)}var zt=d(Mt,[["render",Gt]]);const Xt={name:"Popup",components:{appSelects:D,appInput:J,appResult:tt,appDictSrc:it,appDictTarget:yt,appExample:$t,appSyno:Ht,appMore:zt},props:{export_data:{type:Object,default:null},export_select:{type:Object,default:null},export_tts:{type:Object,default:null}},data(){return{data:null,select:null,tts:null,replace:""}},computed:{rtl(){return this.data?y.isRTL(this.data.target):!1}},watch:{export_data(e){this.data=e,e.text&&this.replace!=e.text&&(this.replace=e.text)},export_select(e){this.select=e},export_tts(e){this.tts=e}},methods:{clear(){this.data=null,this.$emit("clear")},translateReplace(e){return this.translate(e,!0)},translateSwap(e){return this.translate(e,!0,!0)},translate(e,s,a){if(a){if(!this.data.src||this.data.src==="auto"||!this.data.target)return;const i=JSON.parse(JSON.stringify(this.select));i.src=this.data.target,i.target=this.data.src,this.$emit("srctarget",i)}window.scrollTo(0,0),this.clear(),s&&(this.replace=e),this.$emit("translate",e)},srctarget(e){if(this.$emit("srctarget",e),this.data){const s=this.data.sentences.map(a=>a.orig).join("");this.$emit("translate",s)}}}},Jt={class:"row section"};function Yt(e,s,a,i,n,l){const o=t.resolveComponent("app-selects"),r=t.resolveComponent("app-input"),c=t.resolveComponent("app-result"),_=t.resolveComponent("app-dict-target"),h=t.resolveComponent("app-dict-src"),u=t.resolveComponent("app-syno"),N=t.resolveComponent("app-more"),Kt=t.resolveComponent("app-example");return t.openBlock(),t.createElementBlock("div",null,[t.createVNode(o,{select:n.select,onSrctarget:l.srctarget},null,8,["select","onSrctarget"]),t.createElementVNode("div",Jt,[t.createVNode(r,{data:n.data,tts:n.tts,replace:n.replace,onTranslate:l.translate,onClear:l.clear},null,8,["data","tts","replace","onTranslate","onClear"]),t.createVNode(c,{data:n.data,tts:n.tts},null,8,["data","tts"])]),t.createElementVNode("div",{class:"card-columns",style:t.normalizeStyle({"text-align":l.rtl?"right":"left"})},[t.createVNode(_,{data:n.data,onTranslate:l.translateSwap},null,8,["data","onTranslate"]),t.createVNode(h,{data:n.data},null,8,["data"]),t.createVNode(u,{data:n.data,onTranslate:l.translateReplace},null,8,["data","onTranslate"]),t.createVNode(N,{data:n.data,onTranslate:l.translateReplace},null,8,["data","onTranslate"]),t.createVNode(Kt,{data:n.data},null,8,["data"])],4)])}var qt=d(Xt,[["render",Yt]]);p.default=qt,Object.defineProperty(p,"__esModule",{value:!0}),p[Symbol.toStringTag]="Module"});
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ddict/popup",
|
|
3
|
+
"version": "0.3.19",
|
|
4
|
+
"files": ["dist"],
|
|
5
|
+
"main": "./dist/popup.umd.js",
|
|
6
|
+
"module": "./dist/popup.es.js",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"lint": "eslint src",
|
|
10
|
+
"dev": "vite",
|
|
11
|
+
"build": "vite build",
|
|
12
|
+
"preview": "vite preview"
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"vue": "^3.2.25"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@vitejs/plugin-vue": "^2.0.0",
|
|
19
|
+
"bootstrap": "^5.1.3",
|
|
20
|
+
"bootstrap-vue-3": "^0.1.0",
|
|
21
|
+
"eslint": "^8.6.0",
|
|
22
|
+
"eslint-plugin-vue": "^8.2.0",
|
|
23
|
+
"vite": "^2.7.2"
|
|
24
|
+
}
|
|
25
|
+
}
|