lakelib 0.2.5 → 0.2.6
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 +3 -3
- package/dist/lake.css +57 -36
- package/dist/lake.min.js +22 -37
- package/dist/lake.min.js.map +1 -1
- package/lib/css/index.d.ts +1 -0
- package/lib/editor.d.ts +1 -1
- package/lib/i18n/en-US/index.d.ts +2 -0
- package/lib/i18n/ja/index.d.ts +2 -0
- package/lib/i18n/ko/index.d.ts +2 -0
- package/lib/i18n/types.d.ts +18 -2
- package/lib/i18n/zh-CN/index.d.ts +2 -0
- package/lib/lake.css +57 -36
- package/lib/lake.js +313 -118
- package/lib/lake.js.map +1 -1
- package/lib/types/corner-toolbar.d.ts +7 -0
- package/lib/ui/corner-toolbar.d.ts +18 -0
- package/lib/ui/floating-toolbar.d.ts +1 -1
- package/lib/ui/resizer.d.ts +0 -2
- package/package.json +2 -2
package/lib/lake.js
CHANGED
|
@@ -539,6 +539,7 @@ function debug(...data) {
|
|
|
539
539
|
// value is an array which include types and listeners.
|
|
540
540
|
const eventData = {};
|
|
541
541
|
let lastNodeId = 0;
|
|
542
|
+
// The Nodes class represents collections of nodes.
|
|
542
543
|
class Nodes {
|
|
543
544
|
constructor(node) {
|
|
544
545
|
node = node !== null && node !== void 0 ? node : [];
|
|
@@ -3898,6 +3899,8 @@ var enUS = {
|
|
|
3898
3899
|
originalWidth: 'Original image width',
|
|
3899
3900
|
imageWidth: '{0} image width',
|
|
3900
3901
|
open: 'Open image in new tab',
|
|
3902
|
+
caption: 'Caption',
|
|
3903
|
+
captionPlaceholder: 'Write a caption...',
|
|
3901
3904
|
},
|
|
3902
3905
|
file: {
|
|
3903
3906
|
download: 'Download',
|
|
@@ -3916,7 +3919,7 @@ var enUS = {
|
|
|
3916
3919
|
equation: {
|
|
3917
3920
|
save: 'Done',
|
|
3918
3921
|
help: 'Supported functions',
|
|
3919
|
-
placeholder: 'Type a TeX expression',
|
|
3922
|
+
placeholder: 'Type a TeX expression...',
|
|
3920
3923
|
},
|
|
3921
3924
|
};
|
|
3922
3925
|
|
|
@@ -4033,6 +4036,8 @@ var zhCN = {
|
|
|
4033
4036
|
originalWidth: '图片原始大小',
|
|
4034
4037
|
imageWidth: '{0} 图片大小',
|
|
4035
4038
|
open: '在新标签页中打开图片',
|
|
4039
|
+
caption: '图片描述',
|
|
4040
|
+
captionPlaceholder: '请输入图片描述',
|
|
4036
4041
|
},
|
|
4037
4042
|
file: {
|
|
4038
4043
|
download: '下载',
|
|
@@ -4168,6 +4173,8 @@ var ja = {
|
|
|
4168
4173
|
originalWidth: '画像の元のサイズ',
|
|
4169
4174
|
imageWidth: '{0} 画像サイズ',
|
|
4170
4175
|
open: '新しいタブで画像を開く',
|
|
4176
|
+
caption: 'キャプション',
|
|
4177
|
+
captionPlaceholder: 'キャプションを入力してください',
|
|
4171
4178
|
},
|
|
4172
4179
|
file: {
|
|
4173
4180
|
download: 'ダウンロード',
|
|
@@ -4186,7 +4193,7 @@ var ja = {
|
|
|
4186
4193
|
equation: {
|
|
4187
4194
|
save: '保存',
|
|
4188
4195
|
help: 'サポートされている機能',
|
|
4189
|
-
placeholder: 'TeX
|
|
4196
|
+
placeholder: 'TeX 数式を入力してください',
|
|
4190
4197
|
},
|
|
4191
4198
|
};
|
|
4192
4199
|
|
|
@@ -4303,6 +4310,8 @@ var ko = {
|
|
|
4303
4310
|
originalWidth: '원본 이미지 크기',
|
|
4304
4311
|
imageWidth: '{0} 이미지 크기',
|
|
4305
4312
|
open: '새 탭에서 이미지 열기',
|
|
4313
|
+
caption: '캡션',
|
|
4314
|
+
captionPlaceholder: '캡션을 입력하세요',
|
|
4306
4315
|
},
|
|
4307
4316
|
file: {
|
|
4308
4317
|
download: '다운로드',
|
|
@@ -5084,6 +5093,7 @@ class Box {
|
|
|
5084
5093
|
this.toolbar.updateState({
|
|
5085
5094
|
appliedItems,
|
|
5086
5095
|
});
|
|
5096
|
+
this.event.emit('renderfloatingtoolbar');
|
|
5087
5097
|
});
|
|
5088
5098
|
this.event.on('blur', () => {
|
|
5089
5099
|
if (this.toolbar) {
|
|
@@ -5207,6 +5217,7 @@ var index = /*#__PURE__*/Object.freeze({
|
|
|
5207
5217
|
wrapNodeList: wrapNodeList
|
|
5208
5218
|
});
|
|
5209
5219
|
|
|
5220
|
+
// The Fragment class represents a minimal document object that has no parent.
|
|
5210
5221
|
class Fragment {
|
|
5211
5222
|
constructor(fragment) {
|
|
5212
5223
|
this.fragment = fragment !== null && fragment !== void 0 ? fragment : document.createDocumentFragment();
|
|
@@ -5346,6 +5357,7 @@ function getElementRules() {
|
|
|
5346
5357
|
};
|
|
5347
5358
|
}
|
|
5348
5359
|
|
|
5360
|
+
// The HTMLParser class provides the ability to parse HTML source code by specified rules.
|
|
5349
5361
|
class HTMLParser {
|
|
5350
5362
|
constructor(content, rules = getElementRules()) {
|
|
5351
5363
|
this.rules = rules;
|
|
@@ -5516,6 +5528,7 @@ class HTMLParser {
|
|
|
5516
5528
|
}
|
|
5517
5529
|
}
|
|
5518
5530
|
|
|
5531
|
+
// The TextParser class provides the ability to parse a text into an HTML string or DocumentFragment object.
|
|
5519
5532
|
class TextParser {
|
|
5520
5533
|
constructor(content) {
|
|
5521
5534
|
this.content = content;
|
|
@@ -6353,7 +6366,7 @@ function removeBox(range) {
|
|
|
6353
6366
|
return box;
|
|
6354
6367
|
}
|
|
6355
6368
|
|
|
6356
|
-
var version = "0.2.
|
|
6369
|
+
var version = "0.2.6";
|
|
6357
6370
|
|
|
6358
6371
|
// Returns the attributes of the element as an key-value object.
|
|
6359
6372
|
function getAttributes(node) {
|
|
@@ -7105,7 +7118,7 @@ class Editor {
|
|
|
7105
7118
|
contenteditable: this.readonly ? 'false' : 'true',
|
|
7106
7119
|
spellcheck: this.config.spellcheck ? 'true' : 'false',
|
|
7107
7120
|
tabindex: this.config.tabIndex.toString(),
|
|
7108
|
-
|
|
7121
|
+
readonly: this.readonly ? 'true' : 'false',
|
|
7109
7122
|
});
|
|
7110
7123
|
if (this.config.placeholder !== '') {
|
|
7111
7124
|
this.container.attr('placeholder', this.config.placeholder);
|
|
@@ -7226,6 +7239,16 @@ class Editor {
|
|
|
7226
7239
|
this.handleInputEvent(event);
|
|
7227
7240
|
});
|
|
7228
7241
|
}
|
|
7242
|
+
// Removes all unused box instances.
|
|
7243
|
+
removeBoxGarbage() {
|
|
7244
|
+
const instanceMap = getInstanceMap(this.container.id);
|
|
7245
|
+
for (const box of instanceMap.values()) {
|
|
7246
|
+
if (!box.node.get(0).isConnected) {
|
|
7247
|
+
box.unmount();
|
|
7248
|
+
instanceMap.delete(box.node.id);
|
|
7249
|
+
}
|
|
7250
|
+
}
|
|
7251
|
+
}
|
|
7229
7252
|
// Binds events for history.
|
|
7230
7253
|
bindHistoryEvents() {
|
|
7231
7254
|
const executeCommonMethods = (value) => {
|
|
@@ -7316,16 +7339,6 @@ class Editor {
|
|
|
7316
7339
|
}
|
|
7317
7340
|
}
|
|
7318
7341
|
}
|
|
7319
|
-
// Removes all unused box instances.
|
|
7320
|
-
removeBoxGarbage() {
|
|
7321
|
-
const instanceMap = getInstanceMap(this.container.id);
|
|
7322
|
-
for (const box of instanceMap.values()) {
|
|
7323
|
-
if (!box.node.get(0).isConnected) {
|
|
7324
|
-
box.unmount();
|
|
7325
|
-
instanceMap.delete(box.node.id);
|
|
7326
|
-
}
|
|
7327
|
-
}
|
|
7328
|
-
}
|
|
7329
7342
|
// Renders all boxes that haven't been rendered yet.
|
|
7330
7343
|
renderBoxes() {
|
|
7331
7344
|
this.removeBoxGarbage();
|
|
@@ -7714,6 +7727,40 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
7714
7727
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
7715
7728
|
};
|
|
7716
7729
|
|
|
7730
|
+
class CornerToolbar {
|
|
7731
|
+
constructor(config) {
|
|
7732
|
+
this.config = config;
|
|
7733
|
+
this.locale = this.config.locale || i18nObject('en-US');
|
|
7734
|
+
this.root = config.root;
|
|
7735
|
+
this.container = query('<div class="lake-corner-toolbar" />');
|
|
7736
|
+
}
|
|
7737
|
+
appendButton(item) {
|
|
7738
|
+
const buttonNode = query(safeTemplate `
|
|
7739
|
+
<button type="button" name="${item.name}" tabindex="-1" />
|
|
7740
|
+
`);
|
|
7741
|
+
const tooltip = typeof item.tooltip === 'string' ? item.tooltip : item.tooltip(this.locale);
|
|
7742
|
+
buttonNode.attr('title', tooltip);
|
|
7743
|
+
if (item.icon) {
|
|
7744
|
+
buttonNode.append(item.icon);
|
|
7745
|
+
}
|
|
7746
|
+
this.container.append(buttonNode);
|
|
7747
|
+
buttonNode.on('click', event => {
|
|
7748
|
+
event.preventDefault();
|
|
7749
|
+
item.onClick(event);
|
|
7750
|
+
});
|
|
7751
|
+
}
|
|
7752
|
+
render() {
|
|
7753
|
+
const { items } = this.config;
|
|
7754
|
+
if (items.length === 0) {
|
|
7755
|
+
return;
|
|
7756
|
+
}
|
|
7757
|
+
this.root.append(this.container);
|
|
7758
|
+
for (const item of items) {
|
|
7759
|
+
this.appendButton(item);
|
|
7760
|
+
}
|
|
7761
|
+
}
|
|
7762
|
+
}
|
|
7763
|
+
|
|
7717
7764
|
class Resizer {
|
|
7718
7765
|
constructor(config) {
|
|
7719
7766
|
this.config = config;
|
|
@@ -7725,7 +7772,7 @@ class Resizer {
|
|
|
7725
7772
|
<div class="lake-resizer-top-right"></div>
|
|
7726
7773
|
<div class="lake-resizer-bottom-left"></div>
|
|
7727
7774
|
<div class="lake-resizer-bottom-right"></div>
|
|
7728
|
-
<div class="lake-resizer-info"
|
|
7775
|
+
<div class="lake-resizer-info"></div>
|
|
7729
7776
|
</div>
|
|
7730
7777
|
`);
|
|
7731
7778
|
}
|
|
@@ -7766,6 +7813,7 @@ class Resizer {
|
|
|
7766
7813
|
catch ( /* empty */_a) { /* empty */ }
|
|
7767
7814
|
clientX = pointerEvent.clientX;
|
|
7768
7815
|
width = target.width();
|
|
7816
|
+
infoNode.text(`${initialWidth} x ${initialHeight}`);
|
|
7769
7817
|
infoNode.show();
|
|
7770
7818
|
pointerNode.on('pointermove', pointermoveListener);
|
|
7771
7819
|
};
|
|
@@ -7799,8 +7847,46 @@ const alignValueMap$1 = {
|
|
|
7799
7847
|
start: 'left',
|
|
7800
7848
|
end: 'right',
|
|
7801
7849
|
};
|
|
7802
|
-
function
|
|
7850
|
+
function updateBoxMarginBottom(box, captionNode) {
|
|
7851
|
+
const height = captionNode.height();
|
|
7852
|
+
box.node.find('.lake-box-strip').css('margin-bottom', `${height}px`);
|
|
7853
|
+
}
|
|
7854
|
+
function showCaption(box, captionNode) {
|
|
7855
|
+
captionNode.show();
|
|
7856
|
+
updateBoxMarginBottom(box, captionNode);
|
|
7857
|
+
}
|
|
7858
|
+
function hideCaption(box, captionNode) {
|
|
7859
|
+
captionNode.hide();
|
|
7860
|
+
box.node.find('.lake-box-strip').css('margin-bottom', '');
|
|
7861
|
+
}
|
|
7862
|
+
// Creates floating toolbar for the box.
|
|
7863
|
+
function renderFloatingToolbar(box) {
|
|
7803
7864
|
const items = [
|
|
7865
|
+
{
|
|
7866
|
+
name: 'caption',
|
|
7867
|
+
type: 'button',
|
|
7868
|
+
icon: icons.get('caption'),
|
|
7869
|
+
tooltip: locale => locale.image.caption(),
|
|
7870
|
+
isSelected: () => {
|
|
7871
|
+
const boxContainer = box.getContainer();
|
|
7872
|
+
const captionNode = boxContainer.find('.lake-image-caption');
|
|
7873
|
+
return captionNode.length > 0 && captionNode.computedCSS('display') !== 'none';
|
|
7874
|
+
},
|
|
7875
|
+
onClick: () => {
|
|
7876
|
+
var _a;
|
|
7877
|
+
const boxContainer = box.getContainer();
|
|
7878
|
+
const captionNode = boxContainer.find('.lake-image-caption');
|
|
7879
|
+
const caption = captionNode.text().trim();
|
|
7880
|
+
if (caption === '') {
|
|
7881
|
+
captionNode.addClass('lake-placeholder');
|
|
7882
|
+
}
|
|
7883
|
+
showCaption(box, captionNode);
|
|
7884
|
+
captionNode.focus();
|
|
7885
|
+
(_a = box.toolbar) === null || _a === void 0 ? void 0 : _a.updateState({
|
|
7886
|
+
appliedItems: [],
|
|
7887
|
+
});
|
|
7888
|
+
},
|
|
7889
|
+
},
|
|
7804
7890
|
{
|
|
7805
7891
|
name: 'align',
|
|
7806
7892
|
type: 'dropdown',
|
|
@@ -7860,6 +7946,8 @@ function setFloatingToolbar$1(box) {
|
|
|
7860
7946
|
onSelect: (editor, value) => {
|
|
7861
7947
|
const { originalWidth, originalHeight } = box.value;
|
|
7862
7948
|
const boxContainer = box.getContainer();
|
|
7949
|
+
const rootNode = boxContainer.find('.lake-image');
|
|
7950
|
+
const captionNode = boxContainer.find('.lake-image-caption');
|
|
7863
7951
|
const rate = originalHeight / originalWidth;
|
|
7864
7952
|
let newWidth;
|
|
7865
7953
|
if (value === 'page') {
|
|
@@ -7869,10 +7957,12 @@ function setFloatingToolbar$1(box) {
|
|
|
7869
7957
|
newWidth = Math.round(originalWidth * Number(value));
|
|
7870
7958
|
}
|
|
7871
7959
|
const newHeight = Math.round(rate * newWidth);
|
|
7872
|
-
|
|
7960
|
+
rootNode.css({
|
|
7873
7961
|
width: `${newWidth}px`,
|
|
7874
7962
|
height: `${newHeight}px`,
|
|
7875
7963
|
});
|
|
7964
|
+
boxContainer.css('width', `${newWidth}px`);
|
|
7965
|
+
updateBoxMarginBottom(box, captionNode);
|
|
7876
7966
|
box.updateValue({
|
|
7877
7967
|
width: newWidth,
|
|
7878
7968
|
height: newHeight,
|
|
@@ -7927,7 +8017,7 @@ function getImageInfo(url) {
|
|
|
7927
8017
|
});
|
|
7928
8018
|
});
|
|
7929
8019
|
}
|
|
7930
|
-
//
|
|
8020
|
+
// Previews an image.
|
|
7931
8021
|
function openFullScreen(box) {
|
|
7932
8022
|
const editor = box.getEditor();
|
|
7933
8023
|
const dataSource = [];
|
|
@@ -8016,25 +8106,82 @@ function openFullScreen(box) {
|
|
|
8016
8106
|
lightbox.init();
|
|
8017
8107
|
lightbox.loadAndOpen(currentIndex);
|
|
8018
8108
|
}
|
|
8109
|
+
// Creates caption for image.
|
|
8110
|
+
function renderCaption(box) {
|
|
8111
|
+
const editor = box.getEditor();
|
|
8112
|
+
const boxContainer = box.getContainer();
|
|
8113
|
+
const defaultCaption = (box.value.caption || '').trim();
|
|
8114
|
+
const captionNode = query('<div class="lake-image-caption" />');
|
|
8115
|
+
captionNode.text(defaultCaption);
|
|
8116
|
+
boxContainer.append(captionNode);
|
|
8117
|
+
if (defaultCaption === '') {
|
|
8118
|
+
hideCaption(box, captionNode);
|
|
8119
|
+
}
|
|
8120
|
+
else {
|
|
8121
|
+
showCaption(box, captionNode);
|
|
8122
|
+
}
|
|
8123
|
+
if (editor.readonly) {
|
|
8124
|
+
captionNode.css('-webkit-user-modify', 'read-only');
|
|
8125
|
+
return captionNode;
|
|
8126
|
+
}
|
|
8127
|
+
captionNode.attr('contenteditable', 'true');
|
|
8128
|
+
captionNode.attr('placeholder', editor.locale.image.captionPlaceholder());
|
|
8129
|
+
const changeHandler = debounce((value) => {
|
|
8130
|
+
editor.selection.updateByRange();
|
|
8131
|
+
if (editor.isComposing) {
|
|
8132
|
+
return;
|
|
8133
|
+
}
|
|
8134
|
+
box.updateValue('caption', value);
|
|
8135
|
+
editor.history.save();
|
|
8136
|
+
}, 1, {
|
|
8137
|
+
immediate: false,
|
|
8138
|
+
});
|
|
8139
|
+
captionNode.on('input', () => {
|
|
8140
|
+
const caption = captionNode.text().trim();
|
|
8141
|
+
if (caption === '') {
|
|
8142
|
+
captionNode.addClass('lake-placeholder');
|
|
8143
|
+
}
|
|
8144
|
+
else {
|
|
8145
|
+
captionNode.removeClass('lake-placeholder');
|
|
8146
|
+
}
|
|
8147
|
+
const height = captionNode.height();
|
|
8148
|
+
box.node.find('.lake-box-strip').css('margin-bottom', `${height}px`);
|
|
8149
|
+
changeHandler(caption);
|
|
8150
|
+
});
|
|
8151
|
+
// For supporting "user-modify: read-write-plaintext-only" in Firefox
|
|
8152
|
+
captionNode.on('paste', event => {
|
|
8153
|
+
event.preventDefault();
|
|
8154
|
+
const dataTransfer = event.clipboardData;
|
|
8155
|
+
if (!dataTransfer) {
|
|
8156
|
+
return;
|
|
8157
|
+
}
|
|
8158
|
+
const text = dataTransfer.getData('text/plain').trim();
|
|
8159
|
+
document.execCommand('insertText', false, text);
|
|
8160
|
+
});
|
|
8161
|
+
captionNode.on('keydown', event => {
|
|
8162
|
+
if (isKeyHotkey('enter', event)) {
|
|
8163
|
+
event.preventDefault();
|
|
8164
|
+
editor.selection.selectBox(box);
|
|
8165
|
+
}
|
|
8166
|
+
});
|
|
8167
|
+
captionNode.on('focusout', () => {
|
|
8168
|
+
const caption = captionNode.text().trim();
|
|
8169
|
+
if (caption === '') {
|
|
8170
|
+
hideCaption(box, captionNode);
|
|
8171
|
+
}
|
|
8172
|
+
});
|
|
8173
|
+
return captionNode;
|
|
8174
|
+
}
|
|
8019
8175
|
// Displays error icon and filename.
|
|
8020
|
-
function renderError$1(
|
|
8176
|
+
function renderError$1(box) {
|
|
8021
8177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8022
8178
|
const editor = box.getEditor();
|
|
8179
|
+
const boxContainer = box.getContainer();
|
|
8023
8180
|
const value = box.value;
|
|
8024
|
-
|
|
8181
|
+
boxContainer.css({
|
|
8025
8182
|
width: '',
|
|
8026
8183
|
height: '',
|
|
8027
8184
|
});
|
|
8028
|
-
const buttonGroupNode = query(safeTemplate `
|
|
8029
|
-
<div class="lake-button-group">
|
|
8030
|
-
<button type="button" tabindex="-1" class="lake-button-remove" title="${editor.locale.image.remove()}"></button>
|
|
8031
|
-
</div>
|
|
8032
|
-
`);
|
|
8033
|
-
const removeButton = buttonGroupNode.find('.lake-button-remove');
|
|
8034
|
-
const removeIcon = icons.get('remove');
|
|
8035
|
-
if (removeIcon) {
|
|
8036
|
-
removeButton.append(removeIcon);
|
|
8037
|
-
}
|
|
8038
8185
|
const errorNode = query(safeTemplate `
|
|
8039
8186
|
<div class="lake-error">
|
|
8040
8187
|
<div class="lake-error-icon"></div>
|
|
@@ -8045,12 +8192,31 @@ function renderError$1(rootNode, box) {
|
|
|
8045
8192
|
if (imageBrokenIcon) {
|
|
8046
8193
|
errorNode.find('.lake-error-icon').append(imageBrokenIcon);
|
|
8047
8194
|
}
|
|
8048
|
-
rootNode
|
|
8195
|
+
const rootNode = query('<div class="lake-image" />');
|
|
8196
|
+
rootNode.addClass(`lake-image-${value.status}`);
|
|
8197
|
+
new CornerToolbar({
|
|
8198
|
+
locale: editor.locale,
|
|
8199
|
+
root: rootNode,
|
|
8200
|
+
items: [
|
|
8201
|
+
{
|
|
8202
|
+
name: 'remove',
|
|
8203
|
+
icon: icons.get('remove'),
|
|
8204
|
+
tooltip: editor.locale.image.remove(),
|
|
8205
|
+
onClick: event => {
|
|
8206
|
+
event.stopPropagation();
|
|
8207
|
+
editor.selection.removeBox(box);
|
|
8208
|
+
editor.history.save();
|
|
8209
|
+
},
|
|
8210
|
+
},
|
|
8211
|
+
],
|
|
8212
|
+
}).render();
|
|
8049
8213
|
rootNode.append(errorNode);
|
|
8214
|
+
boxContainer.empty();
|
|
8215
|
+
boxContainer.append(rootNode);
|
|
8050
8216
|
});
|
|
8051
8217
|
}
|
|
8052
8218
|
// Displays an image with uplaoding progress.
|
|
8053
|
-
function renderUploading(
|
|
8219
|
+
function renderUploading(box) {
|
|
8054
8220
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8055
8221
|
const editor = box.getEditor();
|
|
8056
8222
|
const boxContainer = box.getContainer();
|
|
@@ -8060,7 +8226,7 @@ function renderUploading(rootNode, box) {
|
|
|
8060
8226
|
return;
|
|
8061
8227
|
}
|
|
8062
8228
|
if (!imageInfo.width || !imageInfo.height) {
|
|
8063
|
-
yield renderError$1(
|
|
8229
|
+
yield renderError$1(box);
|
|
8064
8230
|
return;
|
|
8065
8231
|
}
|
|
8066
8232
|
const maxWidth = editor.container.innerWidth() - 2;
|
|
@@ -8072,20 +8238,10 @@ function renderUploading(rootNode, box) {
|
|
|
8072
8238
|
originalWidth: imageInfo.width,
|
|
8073
8239
|
originalHeight: imageInfo.height,
|
|
8074
8240
|
});
|
|
8075
|
-
|
|
8241
|
+
boxContainer.css({
|
|
8076
8242
|
width: `${width}px`,
|
|
8077
8243
|
height: `${height}px`,
|
|
8078
8244
|
});
|
|
8079
|
-
const buttonGroupNode = query(safeTemplate `
|
|
8080
|
-
<div class="lake-button-group">
|
|
8081
|
-
<button type="button" tabindex="-1" class="lake-button-remove" title="${editor.locale.image.remove()}"></button>
|
|
8082
|
-
</div>
|
|
8083
|
-
`);
|
|
8084
|
-
const removeButton = buttonGroupNode.find('.lake-button-remove');
|
|
8085
|
-
const removeIcon = icons.get('remove');
|
|
8086
|
-
if (removeIcon) {
|
|
8087
|
-
removeButton.append(removeIcon);
|
|
8088
|
-
}
|
|
8089
8245
|
const percent = Math.round(value.percent || 0);
|
|
8090
8246
|
const progressNode = query(safeTemplate `
|
|
8091
8247
|
<div class="lake-progress">
|
|
@@ -8105,13 +8261,32 @@ function renderUploading(rootNode, box) {
|
|
|
8105
8261
|
draggable: 'false',
|
|
8106
8262
|
alt: value.name,
|
|
8107
8263
|
});
|
|
8108
|
-
rootNode
|
|
8264
|
+
const rootNode = query('<div class="lake-image" />');
|
|
8265
|
+
rootNode.addClass(`lake-image-${value.status}`);
|
|
8266
|
+
new CornerToolbar({
|
|
8267
|
+
locale: editor.locale,
|
|
8268
|
+
root: rootNode,
|
|
8269
|
+
items: [
|
|
8270
|
+
{
|
|
8271
|
+
name: 'remove',
|
|
8272
|
+
icon: icons.get('remove'),
|
|
8273
|
+
tooltip: editor.locale.image.remove(),
|
|
8274
|
+
onClick: event => {
|
|
8275
|
+
event.stopPropagation();
|
|
8276
|
+
editor.selection.removeBox(box);
|
|
8277
|
+
editor.history.save();
|
|
8278
|
+
},
|
|
8279
|
+
},
|
|
8280
|
+
],
|
|
8281
|
+
}).render();
|
|
8109
8282
|
rootNode.append(progressNode);
|
|
8110
8283
|
rootNode.append(imgNode);
|
|
8284
|
+
boxContainer.empty();
|
|
8285
|
+
boxContainer.append(rootNode);
|
|
8111
8286
|
});
|
|
8112
8287
|
}
|
|
8113
8288
|
// Displays an image that can be previewed or removed.
|
|
8114
|
-
function renderDone(
|
|
8289
|
+
function renderDone(box) {
|
|
8115
8290
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8116
8291
|
const editor = box.getEditor();
|
|
8117
8292
|
const boxContainer = box.getContainer();
|
|
@@ -8121,9 +8296,15 @@ function renderDone(rootNode, box) {
|
|
|
8121
8296
|
return;
|
|
8122
8297
|
}
|
|
8123
8298
|
if (!imageInfo.width || !imageInfo.height) {
|
|
8124
|
-
yield renderError$1(
|
|
8299
|
+
yield renderError$1(box);
|
|
8125
8300
|
return;
|
|
8126
8301
|
}
|
|
8302
|
+
if (!value.originalWidth || !value.originalHeight) {
|
|
8303
|
+
box.updateValue({
|
|
8304
|
+
originalWidth: imageInfo.width,
|
|
8305
|
+
originalHeight: imageInfo.height,
|
|
8306
|
+
});
|
|
8307
|
+
}
|
|
8127
8308
|
let width = value.width;
|
|
8128
8309
|
let height = value.height;
|
|
8129
8310
|
if (!width || !height) {
|
|
@@ -8135,41 +8316,60 @@ function renderDone(rootNode, box) {
|
|
|
8135
8316
|
height,
|
|
8136
8317
|
});
|
|
8137
8318
|
}
|
|
8138
|
-
boxContainer.css({
|
|
8139
|
-
width: `${width}px`,
|
|
8140
|
-
height: `${height}px`,
|
|
8141
|
-
});
|
|
8142
|
-
const buttonGroupNode = query(safeTemplate `
|
|
8143
|
-
<div class="lake-button-group">
|
|
8144
|
-
<button type="button" tabindex="-1" class="lake-button-view" title="${editor.locale.image.view()}"></button>
|
|
8145
|
-
<button type="button" tabindex="-1" class="lake-button-remove" title="${editor.locale.image.remove()}"></button>
|
|
8146
|
-
</div>
|
|
8147
|
-
`);
|
|
8148
|
-
const viewButton = buttonGroupNode.find('.lake-button-view');
|
|
8149
|
-
const maximizeIcon = icons.get('maximize');
|
|
8150
|
-
if (maximizeIcon) {
|
|
8151
|
-
viewButton.append(maximizeIcon);
|
|
8152
|
-
}
|
|
8153
|
-
if (width < 80 || PhotoSwipeLightbox === null) {
|
|
8154
|
-
viewButton.hide();
|
|
8155
|
-
}
|
|
8156
|
-
const removeButton = buttonGroupNode.find('.lake-button-remove');
|
|
8157
|
-
const removeIcon = icons.get('remove');
|
|
8158
|
-
if (removeIcon) {
|
|
8159
|
-
removeButton.append(removeIcon);
|
|
8160
|
-
}
|
|
8161
8319
|
const imgNode = imageInfo.node;
|
|
8162
8320
|
imgNode.addClass('lake-image-img');
|
|
8163
8321
|
imgNode.attr({
|
|
8164
8322
|
draggable: 'false',
|
|
8165
8323
|
alt: value.name,
|
|
8166
8324
|
});
|
|
8167
|
-
rootNode
|
|
8325
|
+
const rootNode = query('<div class="lake-image" />');
|
|
8326
|
+
rootNode.addClass(`lake-image-${value.status}`);
|
|
8327
|
+
rootNode.css({
|
|
8328
|
+
width: `${width}px`,
|
|
8329
|
+
height: `${height}px`,
|
|
8330
|
+
});
|
|
8331
|
+
const cornerToolbarItems = [];
|
|
8332
|
+
if (width >= 80 && PhotoSwipeLightbox !== null) {
|
|
8333
|
+
cornerToolbarItems.push({
|
|
8334
|
+
name: 'view',
|
|
8335
|
+
icon: icons.get('maximize'),
|
|
8336
|
+
tooltip: editor.locale.image.view(),
|
|
8337
|
+
onClick: () => openFullScreen(box),
|
|
8338
|
+
});
|
|
8339
|
+
}
|
|
8340
|
+
if (!editor.readonly) {
|
|
8341
|
+
cornerToolbarItems.push({
|
|
8342
|
+
name: 'remove',
|
|
8343
|
+
icon: icons.get('remove'),
|
|
8344
|
+
tooltip: editor.locale.image.remove(),
|
|
8345
|
+
onClick: event => {
|
|
8346
|
+
event.stopPropagation();
|
|
8347
|
+
editor.selection.removeBox(box);
|
|
8348
|
+
editor.history.save();
|
|
8349
|
+
},
|
|
8350
|
+
});
|
|
8351
|
+
}
|
|
8352
|
+
new CornerToolbar({
|
|
8353
|
+
locale: editor.locale,
|
|
8354
|
+
root: rootNode,
|
|
8355
|
+
items: cornerToolbarItems,
|
|
8356
|
+
}).render();
|
|
8357
|
+
rootNode.append(imgNode);
|
|
8358
|
+
boxContainer.empty();
|
|
8359
|
+
boxContainer.append(rootNode);
|
|
8360
|
+
boxContainer.css({
|
|
8361
|
+
width: `${width}px`,
|
|
8362
|
+
height: '',
|
|
8363
|
+
});
|
|
8364
|
+
const captionNode = renderCaption(box);
|
|
8365
|
+
renderFloatingToolbar(box);
|
|
8168
8366
|
new Resizer({
|
|
8169
8367
|
root: rootNode,
|
|
8170
|
-
target:
|
|
8171
|
-
|
|
8172
|
-
|
|
8368
|
+
target: rootNode,
|
|
8369
|
+
onResize: newWidth => {
|
|
8370
|
+
boxContainer.css('width', `${newWidth}px`);
|
|
8371
|
+
updateBoxMarginBottom(box, captionNode);
|
|
8372
|
+
},
|
|
8173
8373
|
onStop: (newWidth, newHeight) => {
|
|
8174
8374
|
box.updateValue({
|
|
8175
8375
|
width: newWidth,
|
|
@@ -8178,7 +8378,6 @@ function renderDone(rootNode, box) {
|
|
|
8178
8378
|
editor.history.save();
|
|
8179
8379
|
},
|
|
8180
8380
|
}).render();
|
|
8181
|
-
rootNode.append(imgNode);
|
|
8182
8381
|
});
|
|
8183
8382
|
}
|
|
8184
8383
|
var imageBox = {
|
|
@@ -8216,40 +8415,22 @@ var imageBox = {
|
|
|
8216
8415
|
if (value.status === 'loading') {
|
|
8217
8416
|
return;
|
|
8218
8417
|
}
|
|
8219
|
-
const rootNode = query('<div class="lake-image" />');
|
|
8220
|
-
rootNode.addClass(`lake-image-${value.status}`);
|
|
8221
8418
|
let promise;
|
|
8222
8419
|
if (value.status === 'uploading') {
|
|
8223
|
-
promise = renderUploading(
|
|
8420
|
+
promise = renderUploading(box);
|
|
8224
8421
|
}
|
|
8225
8422
|
else if (value.status === 'error') {
|
|
8226
|
-
promise = renderError$1(
|
|
8423
|
+
promise = renderError$1(box);
|
|
8227
8424
|
}
|
|
8228
8425
|
else {
|
|
8229
|
-
promise = renderDone(
|
|
8426
|
+
promise = renderDone(box);
|
|
8230
8427
|
}
|
|
8231
8428
|
promise.then(() => {
|
|
8232
|
-
boxContainer.
|
|
8233
|
-
|
|
8234
|
-
|
|
8235
|
-
if (editor.readonly) {
|
|
8236
|
-
rootNode.find('.lake-button-remove').hide();
|
|
8237
|
-
}
|
|
8238
|
-
else {
|
|
8239
|
-
rootNode.find('.lake-button-remove').on('click', event => {
|
|
8240
|
-
event.stopPropagation();
|
|
8241
|
-
editor.selection.removeBox(box);
|
|
8242
|
-
editor.history.save();
|
|
8243
|
-
});
|
|
8244
|
-
if (value.status === 'done') {
|
|
8245
|
-
setFloatingToolbar$1(box);
|
|
8246
|
-
}
|
|
8247
|
-
}
|
|
8429
|
+
boxContainer.find('.lake-image').on('click', () => {
|
|
8430
|
+
editor.selection.selectBox(box);
|
|
8431
|
+
});
|
|
8248
8432
|
box.event.emit('render');
|
|
8249
8433
|
});
|
|
8250
|
-
rootNode.on('click', () => {
|
|
8251
|
-
editor.selection.selectBox(box);
|
|
8252
|
-
});
|
|
8253
8434
|
},
|
|
8254
8435
|
html: box => {
|
|
8255
8436
|
const rawValue = box.node.attr('value');
|
|
@@ -8264,23 +8445,23 @@ function getVideoId(url) {
|
|
|
8264
8445
|
function appendButtonGroup(box) {
|
|
8265
8446
|
const editor = box.getEditor();
|
|
8266
8447
|
const boxContainer = box.getContainer();
|
|
8267
|
-
const
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8275
|
-
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
|
|
8281
|
-
|
|
8282
|
-
|
|
8283
|
-
|
|
8448
|
+
const rootNode = boxContainer.find('.lake-video');
|
|
8449
|
+
new CornerToolbar({
|
|
8450
|
+
locale: editor.locale,
|
|
8451
|
+
root: rootNode,
|
|
8452
|
+
items: [
|
|
8453
|
+
{
|
|
8454
|
+
name: 'remove',
|
|
8455
|
+
icon: icons.get('remove'),
|
|
8456
|
+
tooltip: editor.locale.video.remove(),
|
|
8457
|
+
onClick: event => {
|
|
8458
|
+
event.stopPropagation();
|
|
8459
|
+
editor.selection.removeBox(box);
|
|
8460
|
+
editor.history.save();
|
|
8461
|
+
},
|
|
8462
|
+
},
|
|
8463
|
+
],
|
|
8464
|
+
}).render();
|
|
8284
8465
|
}
|
|
8285
8466
|
function showVideo(box) {
|
|
8286
8467
|
const editor = box.getEditor();
|
|
@@ -8310,11 +8491,25 @@ function showVideo(box) {
|
|
|
8310
8491
|
if (!editor.readonly) {
|
|
8311
8492
|
iframeNode.on('load', () => {
|
|
8312
8493
|
appendButtonGroup(box);
|
|
8494
|
+
new CornerToolbar({
|
|
8495
|
+
locale: editor.locale,
|
|
8496
|
+
root: rootNode,
|
|
8497
|
+
items: [
|
|
8498
|
+
{
|
|
8499
|
+
name: 'remove',
|
|
8500
|
+
icon: icons.get('remove'),
|
|
8501
|
+
tooltip: editor.locale.video.remove(),
|
|
8502
|
+
onClick: event => {
|
|
8503
|
+
event.stopPropagation();
|
|
8504
|
+
editor.selection.removeBox(box);
|
|
8505
|
+
editor.history.save();
|
|
8506
|
+
},
|
|
8507
|
+
},
|
|
8508
|
+
],
|
|
8509
|
+
}).render();
|
|
8313
8510
|
new Resizer({
|
|
8314
8511
|
root: rootNode,
|
|
8315
8512
|
target: boxContainer,
|
|
8316
|
-
width,
|
|
8317
|
-
height,
|
|
8318
8513
|
onResize: (newWidth, newHeight) => {
|
|
8319
8514
|
iframeNode.attr({
|
|
8320
8515
|
height: newHeight.toString(),
|