| Línea 25... |
Línea 25... |
| 25 |
import ImageModal from './imagemodal';
|
25 |
import ImageModal from './imagemodal';
|
| 26 |
import {getImagePermissions} from './options';
|
26 |
import {getImagePermissions} from './options';
|
| 27 |
import {getFilePicker} from 'editor_tiny/options';
|
27 |
import {getFilePicker} from 'editor_tiny/options';
|
| 28 |
import {ImageInsert} from 'tiny_media/imageinsert';
|
28 |
import {ImageInsert} from 'tiny_media/imageinsert';
|
| 29 |
import {ImageDetails} from 'tiny_media/imagedetails';
|
29 |
import {ImageDetails} from 'tiny_media/imagedetails';
|
| - |
|
30 |
import {prefetchStrings} from 'core/prefetch';
|
| 30 |
import {getString} from 'core/str';
|
31 |
import {getString} from 'core/str';
|
| 31 |
import {
|
32 |
import {
|
| 32 |
bodyImageInsert,
|
33 |
body,
|
| 33 |
footerImageInsert,
|
34 |
footer,
|
| 34 |
bodyImageDetails,
|
- |
|
| 35 |
footerImageDetails,
|
- |
|
| 36 |
showElements,
|
- |
|
| 37 |
hideElements,
|
35 |
hideElements,
|
| - |
|
36 |
showElements,
|
| 38 |
isPercentageValue,
|
37 |
isPercentageValue,
|
| 39 |
} from 'tiny_media/imagehelpers';
|
38 |
} from './helpers';
|
| - |
|
39 |
import {MAX_LENGTH_ALT} from './imagehelpers';
|
| - |
|
40 |
|
| - |
|
41 |
prefetchStrings('tiny_media', [
|
| - |
|
42 |
'imageurlrequired',
|
| - |
|
43 |
'sizecustom_help',
|
| - |
|
44 |
]);
|
| Línea 40... |
Línea 45... |
| 40 |
|
45 |
|
| 41 |
export default class MediaImage {
|
46 |
export default class MediaImage {
|
| 42 |
canShowFilePicker = false;
|
47 |
canShowFilePicker = false;
|
| 43 |
editor = null;
|
48 |
editor = null;
|
| Línea 80... |
Línea 85... |
| 80 |
loadInsertImage = async function() {
|
85 |
loadInsertImage = async function() {
|
| 81 |
const templateContext = {
|
86 |
const templateContext = {
|
| 82 |
elementid: this.editor.id,
|
87 |
elementid: this.editor.id,
|
| 83 |
showfilepicker: this.canShowFilePicker,
|
88 |
showfilepicker: this.canShowFilePicker,
|
| 84 |
showdropzone: this.canShowDropZone,
|
89 |
showdropzone: this.canShowDropZone,
|
| - |
|
90 |
bodyTemplate: Selectors.IMAGE.template.body.insertImageBody,
|
| - |
|
91 |
footerTemplate: Selectors.IMAGE.template.footer.insertImageFooter,
|
| - |
|
92 |
selector: Selectors.IMAGE.type,
|
| 85 |
};
|
93 |
};
|
| Línea 86... |
Línea 94... |
| 86 |
|
94 |
|
| 87 |
Promise.all([bodyImageInsert(templateContext, this.root), footerImageInsert(templateContext, this.root)])
|
95 |
Promise.all([body(templateContext, this.root), footer(templateContext, this.root)])
|
| 88 |
.then(() => {
|
96 |
.then(() => {
|
| 89 |
const imageinsert = new ImageInsert(
|
97 |
const imageinsert = new ImageInsert(
|
| 90 |
this.root,
|
98 |
this.root,
|
| 91 |
this.editor,
|
99 |
this.editor,
|
| Línea 136... |
Línea 144... |
| 136 |
*/
|
144 |
*/
|
| 137 |
loadPreviewImage = async function(url) {
|
145 |
loadPreviewImage = async function(url) {
|
| 138 |
this.startImageLoading();
|
146 |
this.startImageLoading();
|
| 139 |
const image = new Image();
|
147 |
const image = new Image();
|
| 140 |
image.src = url;
|
148 |
image.src = url;
|
| 141 |
image.addEventListener('error', () => {
|
149 |
image.addEventListener('error', async() => {
|
| 142 |
const urlWarningLabelEle = this.root.querySelector(Selectors.IMAGE.elements.urlWarning);
|
150 |
const urlWarningLabelEle = this.root.querySelector(Selectors.IMAGE.elements.urlWarning);
|
| 143 |
urlWarningLabelEle.innerHTML = this.langStrings.imageurlrequired;
|
151 |
urlWarningLabelEle.innerHTML = await getString('imageurlrequired', 'tiny_media');
|
| 144 |
showElements(Selectors.IMAGE.elements.urlWarning, this.root);
|
152 |
showElements(Selectors.IMAGE.elements.urlWarning, this.root);
|
| 145 |
this.stopImageLoading();
|
153 |
this.stopImageLoading();
|
| 146 |
});
|
154 |
});
|
| Línea 147... |
Línea 155... |
| 147 |
|
155 |
|
| 148 |
image.addEventListener('load', async() => {
|
156 |
image.addEventListener('load', async() => {
|
| 149 |
const currentImageData = await this.getCurrentImageData();
|
157 |
const currentImageData = await this.getCurrentImageData();
|
| 150 |
let templateContext = await this.getTemplateContext(currentImageData);
|
158 |
let templateContext = await this.getTemplateContext(currentImageData);
|
| - |
|
159 |
templateContext.sizecustomhelpicon = {text: await getString('sizecustom_help', 'tiny_media')};
|
| - |
|
160 |
templateContext.bodyTemplate = Selectors.IMAGE.template.body.insertImageDetailsBody;
|
| - |
|
161 |
templateContext.footerTemplate = Selectors.IMAGE.template.footer.insertImageDetailsFooter;
|
| - |
|
162 |
templateContext.selector = Selectors.IMAGE.type;
|
| Línea 151... |
Línea 163... |
| 151 |
templateContext.sizecustomhelpicon = {text: await getString('sizecustom_help', 'tiny_media')};
|
163 |
templateContext.maxlengthalt = MAX_LENGTH_ALT;
|
| 152 |
|
164 |
|
| 153 |
Promise.all([bodyImageDetails(templateContext, this.root), footerImageDetails(templateContext, this.root)])
|
165 |
Promise.all([body(templateContext, this.root), footer(templateContext, this.root)])
|
| 154 |
.then(() => {
|
166 |
.then(() => {
|
| 155 |
this.stopImageLoading();
|
167 |
this.stopImageLoading();
|
| 156 |
return;
|
168 |
return;
|