@antv/infographic 0.2.11 → 0.2.12
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/dist/infographic.min.js +1 -1
- package/dist/infographic.min.js.map +1 -1
- package/esm/designs/components/Btn.js +15 -4
- package/esm/designs/components/BtnsGroup.js +1 -1
- package/esm/designs/components/Illus.js +15 -3
- package/esm/designs/components/ItemDesc.js +17 -11
- package/esm/designs/components/ItemIcon.js +17 -18
- package/esm/designs/components/ItemLabel.js +17 -11
- package/esm/designs/components/ItemValue.js +17 -12
- package/esm/designs/components/ItemsGroup.js +1 -1
- package/esm/designs/components/ShapesGroup.js +1 -1
- package/esm/designs/components/Title.js +2 -2
- package/esm/designs/decorations/simple-arrow.js +14 -2
- package/esm/designs/decorations/triangle.js +14 -2
- package/esm/designs/defs/DropShadow.js +13 -2
- package/esm/designs/defs/LinearGradient.js +1 -1
- package/esm/designs/items/BadgeCard.js +2 -2
- package/esm/designs/items/CandyCardLite.js +1 -1
- package/esm/designs/items/CapsuleItem.js +3 -3
- package/esm/designs/items/CircleNode.js +1 -1
- package/esm/designs/items/CircularProgress.js +3 -2
- package/esm/designs/items/CompactCard.js +1 -1
- package/esm/designs/items/DoneList.js +1 -1
- package/esm/designs/items/HorizontalIconArrow.js +2 -2
- package/esm/designs/items/HorizontalIconLine.js +2 -2
- package/esm/designs/items/IconBadge.js +4 -3
- package/esm/designs/items/IndexedCard.js +1 -1
- package/esm/designs/items/LCornerCard.js +1 -1
- package/esm/designs/items/LetterCard.js +4 -3
- package/esm/designs/items/LinedText.js +6 -5
- package/esm/designs/items/PillBadge.js +2 -2
- package/esm/designs/items/PlainText.js +4 -4
- package/esm/designs/items/ProgressCard.js +4 -4
- package/esm/designs/items/QuarterCircular.js +1 -1
- package/esm/designs/items/QuarterSimpleCard.js +1 -1
- package/esm/designs/items/RibbonCard.js +2 -2
- package/esm/designs/items/RoundedRectNode.js +2 -2
- package/esm/designs/items/SimpleCircleNode.js +1 -1
- package/esm/designs/items/SimpleHorizontalArrow.js +2 -2
- package/esm/designs/items/SimpleIllusItem.js +1 -1
- package/esm/designs/items/SimpleItem.js +3 -3
- package/esm/designs/items/SimpleVerticalArrow.js +2 -2
- package/esm/designs/items/UnderlineText.js +1 -1
- package/esm/designs/items/VerticalIconArrow.js +2 -2
- package/esm/designs/layouts/Align.js +22 -15
- package/esm/designs/layouts/Flex.js +23 -16
- package/esm/designs/structures/chart-bar.js +7 -5
- package/esm/designs/structures/chart-column.js +3 -2
- package/esm/designs/structures/chart-line.js +7 -5
- package/esm/designs/structures/chart-pie.js +4 -3
- package/esm/designs/structures/chart-wordcloud.js +5 -14
- package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
- package/esm/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
- package/esm/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
- package/esm/designs/structures/compare-hierarchy-left-right.js +6 -5
- package/esm/designs/structures/compare-hierarchy-row.js +3 -2
- package/esm/designs/structures/compare-quadrant.js +2 -3
- package/esm/designs/structures/hierarchy-mindmap.js +19 -19
- package/esm/designs/structures/hierarchy-structure.js +1 -1
- package/esm/designs/structures/hierarchy-tree.js +15 -24
- package/esm/designs/structures/list-sector.js +5 -6
- package/esm/designs/structures/list-zigzag.js +2 -1
- package/esm/designs/structures/relation-dagre-flow.js +30 -35
- package/esm/designs/structures/relation-network.js +2 -2
- package/esm/designs/structures/sequence-funnel.js +1 -1
- package/esm/designs/structures/sequence-mountain.js +4 -4
- package/esm/designs/structures/sequence-pyramid.js +1 -1
- package/esm/designs/structures/sequence-zigzag-steps.js +2 -1
- package/esm/designs/utils/color.js +8 -4
- package/esm/designs/utils/item.js +3 -2
- package/esm/editor/commands/Batch.js +21 -8
- package/esm/editor/commands/UpdateElement.js +25 -22
- package/esm/editor/commands/UpdateOptions.js +23 -10
- package/esm/editor/commands/UpdateText.js +24 -11
- package/esm/editor/interactions/brush-select.js +27 -13
- package/esm/editor/interactions/click-select.js +13 -3
- package/esm/editor/interactions/dblclick-edit-text.js +36 -20
- package/esm/editor/interactions/drag-element.js +23 -9
- package/esm/editor/interactions/hotkey-history.js +17 -7
- package/esm/editor/interactions/select-highlight.js +5 -9
- package/esm/editor/interactions/zoom-wheel.js +2 -1
- package/esm/editor/managers/command.js +45 -27
- package/esm/editor/managers/interaction.js +46 -33
- package/esm/editor/managers/state.js +1 -1
- package/esm/editor/plugins/edit-bar/components/color-picker.js +9 -6
- package/esm/editor/plugins/edit-bar/components/popover.js +15 -12
- package/esm/editor/plugins/edit-bar/components/select.js +10 -8
- package/esm/editor/plugins/edit-bar/edit-bar.js +7 -25
- package/esm/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
- package/esm/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
- package/esm/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
- package/esm/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
- package/esm/editor/plugins/resize-element.js +6 -4
- package/esm/editor/utils/click-handler.js +6 -3
- package/esm/editor/utils/coordinate.js +2 -1
- package/esm/editor/utils/element.js +2 -1
- package/esm/editor/utils/event.js +2 -1
- package/esm/editor/utils/extension.js +1 -1
- package/esm/editor/utils/hotkey.js +2 -1
- package/esm/exporter/font.js +106 -90
- package/esm/exporter/png.js +49 -37
- package/esm/exporter/svg.js +55 -38
- package/esm/jsx/components/Ellipse.js +5 -4
- package/esm/jsx/components/Path.js +2 -4
- package/esm/jsx/components/Polygon.js +15 -6
- package/esm/jsx/components/Text.js +21 -41
- package/esm/jsx/renderer.js +15 -7
- package/esm/jsx/utils/bounds.js +18 -16
- package/esm/jsx/utils/children.js +2 -1
- package/esm/jsx/utils/clone.js +13 -2
- package/esm/jsx/utils/element.js +2 -1
- package/esm/options/parser.js +45 -46
- package/esm/renderer/composites/background.js +3 -2
- package/esm/renderer/composites/icon.js +14 -19
- package/esm/renderer/composites/illus.js +17 -22
- package/esm/renderer/composites/shape.js +4 -2
- package/esm/renderer/composites/svg.js +2 -1
- package/esm/renderer/composites/text.js +5 -3
- package/esm/renderer/fonts/loader.js +4 -3
- package/esm/renderer/fonts/registry.js +1 -1
- package/esm/renderer/palettes/utils.js +3 -2
- package/esm/renderer/renderer.js +7 -5
- package/esm/renderer/stylize/gradient.js +3 -2
- package/esm/renderer/stylize/pattern.js +15 -8
- package/esm/renderer/stylize/rough.js +1 -1
- package/esm/resource/load-tracker.js +22 -10
- package/esm/resource/loader.js +80 -67
- package/esm/resource/loaders/image.js +71 -59
- package/esm/resource/loaders/remote.js +26 -15
- package/esm/resource/loaders/search.js +38 -25
- package/esm/resource/utils/parser.js +2 -1
- package/esm/runtime/Infographic.js +26 -13
- package/esm/runtime/utils.js +5 -8
- package/esm/ssr/renderer.js +42 -35
- package/esm/syntax/index.js +19 -6
- package/esm/syntax/mapper.js +2 -2
- package/esm/templates/built-in.js +96 -200
- package/esm/templates/hierarchy-mindmap.js +1 -5
- package/esm/templates/hierarchy-tree.js +1 -5
- package/esm/templates/relation-dagre-flow.js +4 -28
- package/esm/themes/generator.js +8 -14
- package/esm/utils/fetch.js +48 -35
- package/esm/utils/icon.js +1 -4
- package/esm/utils/is-browser.js +2 -2
- package/esm/utils/measure-text.js +2 -1
- package/esm/utils/padding.js +1 -1
- package/esm/utils/recognizer.js +2 -1
- package/esm/utils/text.js +14 -3
- package/esm/version.d.ts +1 -1
- package/esm/version.js +1 -1
- package/lib/designs/components/Btn.js +15 -4
- package/lib/designs/components/BtnsGroup.js +1 -1
- package/lib/designs/components/Illus.js +15 -3
- package/lib/designs/components/ItemDesc.js +17 -11
- package/lib/designs/components/ItemIcon.js +17 -18
- package/lib/designs/components/ItemLabel.js +17 -11
- package/lib/designs/components/ItemValue.js +17 -12
- package/lib/designs/components/ItemsGroup.js +1 -1
- package/lib/designs/components/ShapesGroup.js +1 -1
- package/lib/designs/components/Title.js +2 -2
- package/lib/designs/decorations/simple-arrow.js +14 -2
- package/lib/designs/decorations/triangle.js +14 -2
- package/lib/designs/defs/DropShadow.js +13 -2
- package/lib/designs/defs/LinearGradient.js +1 -1
- package/lib/designs/items/BadgeCard.js +2 -2
- package/lib/designs/items/CandyCardLite.js +1 -1
- package/lib/designs/items/CapsuleItem.js +3 -3
- package/lib/designs/items/CircleNode.js +1 -1
- package/lib/designs/items/CircularProgress.js +3 -2
- package/lib/designs/items/CompactCard.js +1 -1
- package/lib/designs/items/DoneList.js +1 -1
- package/lib/designs/items/HorizontalIconArrow.js +2 -2
- package/lib/designs/items/HorizontalIconLine.js +2 -2
- package/lib/designs/items/IconBadge.js +4 -3
- package/lib/designs/items/IndexedCard.js +1 -1
- package/lib/designs/items/LCornerCard.js +1 -1
- package/lib/designs/items/LetterCard.js +4 -3
- package/lib/designs/items/LinedText.js +6 -5
- package/lib/designs/items/PillBadge.js +2 -2
- package/lib/designs/items/PlainText.js +4 -4
- package/lib/designs/items/ProgressCard.js +4 -4
- package/lib/designs/items/QuarterCircular.js +1 -1
- package/lib/designs/items/QuarterSimpleCard.js +1 -1
- package/lib/designs/items/RibbonCard.js +2 -2
- package/lib/designs/items/RoundedRectNode.js +2 -2
- package/lib/designs/items/SimpleCircleNode.js +1 -1
- package/lib/designs/items/SimpleHorizontalArrow.js +2 -2
- package/lib/designs/items/SimpleIllusItem.js +1 -1
- package/lib/designs/items/SimpleItem.js +3 -3
- package/lib/designs/items/SimpleVerticalArrow.js +2 -2
- package/lib/designs/items/UnderlineText.js +1 -1
- package/lib/designs/items/VerticalIconArrow.js +2 -2
- package/lib/designs/layouts/Align.js +22 -15
- package/lib/designs/layouts/Flex.js +23 -16
- package/lib/designs/structures/chart-bar.js +7 -5
- package/lib/designs/structures/chart-column.js +3 -2
- package/lib/designs/structures/chart-line.js +7 -5
- package/lib/designs/structures/chart-pie.js +4 -3
- package/lib/designs/structures/chart-wordcloud.js +5 -14
- package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-arrow.js +1 -1
- package/lib/designs/structures/compare-binary-horizontal/dividers/pros-cons-fold.js +1 -1
- package/lib/designs/structures/compare-binary-horizontal/dividers/types.js +2 -1
- package/lib/designs/structures/compare-hierarchy-left-right.js +6 -5
- package/lib/designs/structures/compare-hierarchy-row.js +3 -2
- package/lib/designs/structures/compare-quadrant.js +2 -3
- package/lib/designs/structures/hierarchy-mindmap.js +19 -19
- package/lib/designs/structures/hierarchy-structure.js +1 -1
- package/lib/designs/structures/hierarchy-tree.js +15 -24
- package/lib/designs/structures/list-sector.js +5 -6
- package/lib/designs/structures/list-zigzag.js +2 -1
- package/lib/designs/structures/relation-dagre-flow.js +30 -35
- package/lib/designs/structures/relation-network.js +2 -2
- package/lib/designs/structures/sequence-funnel.js +1 -1
- package/lib/designs/structures/sequence-mountain.js +4 -4
- package/lib/designs/structures/sequence-pyramid.js +1 -1
- package/lib/designs/structures/sequence-zigzag-steps.js +2 -1
- package/lib/designs/utils/color.js +8 -4
- package/lib/designs/utils/item.js +3 -2
- package/lib/editor/commands/Batch.js +21 -8
- package/lib/editor/commands/UpdateElement.js +25 -22
- package/lib/editor/commands/UpdateOptions.js +23 -10
- package/lib/editor/commands/UpdateText.js +24 -11
- package/lib/editor/interactions/brush-select.js +27 -13
- package/lib/editor/interactions/click-select.js +13 -3
- package/lib/editor/interactions/dblclick-edit-text.js +36 -20
- package/lib/editor/interactions/drag-element.js +23 -9
- package/lib/editor/interactions/hotkey-history.js +17 -7
- package/lib/editor/interactions/select-highlight.js +5 -9
- package/lib/editor/interactions/zoom-wheel.js +2 -1
- package/lib/editor/managers/command.js +43 -25
- package/lib/editor/managers/interaction.js +46 -33
- package/lib/editor/managers/state.js +1 -1
- package/lib/editor/plugins/edit-bar/components/color-picker.js +9 -6
- package/lib/editor/plugins/edit-bar/components/popover.js +15 -12
- package/lib/editor/plugins/edit-bar/components/select.js +10 -8
- package/lib/editor/plugins/edit-bar/edit-bar.js +7 -25
- package/lib/editor/plugins/edit-bar/edit-items/align-elements.js +5 -3
- package/lib/editor/plugins/edit-bar/edit-items/font-align.js +1 -1
- package/lib/editor/plugins/edit-bar/edit-items/font-color.js +2 -2
- package/lib/editor/plugins/edit-bar/edit-items/icon-color.js +2 -2
- package/lib/editor/plugins/resize-element.js +6 -4
- package/lib/editor/utils/click-handler.js +6 -3
- package/lib/editor/utils/coordinate.js +2 -1
- package/lib/editor/utils/element.js +2 -1
- package/lib/editor/utils/event.js +2 -1
- package/lib/editor/utils/extension.js +1 -1
- package/lib/editor/utils/hotkey.js +2 -1
- package/lib/exporter/font.js +106 -90
- package/lib/exporter/png.js +49 -37
- package/lib/exporter/svg.js +55 -38
- package/lib/jsx/components/Ellipse.js +5 -4
- package/lib/jsx/components/Path.js +2 -4
- package/lib/jsx/components/Polygon.js +15 -6
- package/lib/jsx/components/Text.js +21 -41
- package/lib/jsx/renderer.js +15 -7
- package/lib/jsx/utils/bounds.js +18 -16
- package/lib/jsx/utils/children.js +2 -1
- package/lib/jsx/utils/clone.js +13 -2
- package/lib/jsx/utils/element.js +2 -1
- package/lib/options/parser.js +45 -46
- package/lib/renderer/composites/background.js +3 -2
- package/lib/renderer/composites/icon.js +14 -19
- package/lib/renderer/composites/illus.js +17 -22
- package/lib/renderer/composites/shape.js +4 -2
- package/lib/renderer/composites/svg.js +2 -1
- package/lib/renderer/composites/text.js +5 -3
- package/lib/renderer/fonts/loader.js +4 -3
- package/lib/renderer/fonts/registry.js +1 -1
- package/lib/renderer/palettes/utils.js +3 -2
- package/lib/renderer/renderer.js +7 -5
- package/lib/renderer/stylize/gradient.js +3 -2
- package/lib/renderer/stylize/pattern.js +15 -8
- package/lib/renderer/stylize/rough.js +1 -1
- package/lib/resource/load-tracker.js +22 -10
- package/lib/resource/loader.js +80 -67
- package/lib/resource/loaders/image.js +71 -59
- package/lib/resource/loaders/remote.js +26 -15
- package/lib/resource/loaders/search.js +38 -25
- package/lib/resource/utils/parser.js +2 -1
- package/lib/runtime/Infographic.js +26 -13
- package/lib/runtime/utils.js +5 -8
- package/lib/ssr/renderer.js +42 -35
- package/lib/syntax/index.js +19 -6
- package/lib/syntax/mapper.js +2 -2
- package/lib/templates/built-in.js +96 -200
- package/lib/templates/hierarchy-mindmap.js +1 -5
- package/lib/templates/hierarchy-tree.js +1 -5
- package/lib/templates/relation-dagre-flow.js +4 -28
- package/lib/themes/generator.js +8 -14
- package/lib/utils/fetch.js +48 -35
- package/lib/utils/icon.js +1 -4
- package/lib/utils/is-browser.js +2 -2
- package/lib/utils/measure-text.js +2 -1
- package/lib/utils/padding.js +1 -1
- package/lib/utils/recognizer.js +2 -1
- package/lib/utils/text.js +14 -3
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/src/version.ts +1 -1
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { getCombinedBounds } from '../../jsx/utils/bounds.js';
|
|
2
11
|
import { createElement, getAttributes, isEditableText, isEditingText, setAttributes, } from '../../utils/index.js';
|
|
3
12
|
import { UpdateElementCommand } from '../commands/index.js';
|
|
@@ -114,9 +123,11 @@ export class DragElement extends Interaction {
|
|
|
114
123
|
if (this.dragItems.length === 0)
|
|
115
124
|
return false;
|
|
116
125
|
let started = false;
|
|
117
|
-
this.interaction.executeExclusiveInteraction(this,
|
|
118
|
-
|
|
119
|
-
|
|
126
|
+
this.interaction.executeExclusiveInteraction(this, () => __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
return new Promise((resolve) => {
|
|
128
|
+
this.completeInteraction = resolve;
|
|
129
|
+
started = true;
|
|
130
|
+
});
|
|
120
131
|
}));
|
|
121
132
|
this.exclusiveStarted = started;
|
|
122
133
|
return started;
|
|
@@ -252,7 +263,8 @@ export class DragElement extends Interaction {
|
|
|
252
263
|
return rest && rest.length ? `${translate} ${rest}` : translate;
|
|
253
264
|
}
|
|
254
265
|
emitGeometryChange() {
|
|
255
|
-
|
|
266
|
+
var _a;
|
|
267
|
+
const target = (_a = this.dragItems[0]) === null || _a === void 0 ? void 0 : _a.element;
|
|
256
268
|
if (!target)
|
|
257
269
|
return;
|
|
258
270
|
const rect = getElementViewportBounds(this.editor.getDocument(), target);
|
|
@@ -268,6 +280,7 @@ export class DragElement extends Interaction {
|
|
|
268
280
|
window.removeEventListener('pointercancel', this.handleEnd);
|
|
269
281
|
}
|
|
270
282
|
reset() {
|
|
283
|
+
var _a;
|
|
271
284
|
this.detachPointerListeners();
|
|
272
285
|
this.clearGuides();
|
|
273
286
|
this.pointerId = undefined;
|
|
@@ -280,7 +293,7 @@ export class DragElement extends Interaction {
|
|
|
280
293
|
this.dragging = false;
|
|
281
294
|
this.startBounds = undefined;
|
|
282
295
|
this.guideCandidates = undefined;
|
|
283
|
-
this.completeInteraction
|
|
296
|
+
(_a = this.completeInteraction) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
284
297
|
this.completeInteraction = undefined;
|
|
285
298
|
}
|
|
286
299
|
getSelectionBounds(selection) {
|
|
@@ -315,8 +328,8 @@ export class DragElement extends Interaction {
|
|
|
315
328
|
const snapX = this.getSnapOffset([moving.x, moving.x + moving.width / 2, moving.x + moving.width], this.guideCandidates.vertical);
|
|
316
329
|
const snapY = this.getSnapOffset([moving.y, moving.y + moving.height / 2, moving.y + moving.height], this.guideCandidates.horizontal);
|
|
317
330
|
return {
|
|
318
|
-
dx: dx + (snapX
|
|
319
|
-
dy: dy + (snapY
|
|
331
|
+
dx: dx + ((snapX === null || snapX === void 0 ? void 0 : snapX.offset) || 0),
|
|
332
|
+
dy: dy + ((snapY === null || snapY === void 0 ? void 0 : snapY.offset) || 0),
|
|
320
333
|
snapX,
|
|
321
334
|
snapY,
|
|
322
335
|
};
|
|
@@ -383,8 +396,9 @@ export class DragElement extends Interaction {
|
|
|
383
396
|
}
|
|
384
397
|
}
|
|
385
398
|
clearGuides() {
|
|
386
|
-
|
|
387
|
-
this.
|
|
399
|
+
var _a, _b;
|
|
400
|
+
(_a = this.guideVertical) === null || _a === void 0 ? void 0 : _a.remove();
|
|
401
|
+
(_b = this.guideHorizontal) === null || _b === void 0 ? void 0 : _b.remove();
|
|
388
402
|
this.guideVertical = undefined;
|
|
389
403
|
this.guideHorizontal = undefined;
|
|
390
404
|
}
|
|
@@ -1,17 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { Hotkey } from '../utils/index.js';
|
|
2
11
|
import { Interaction } from './base.js';
|
|
3
12
|
export class HotkeyHistory extends Interaction {
|
|
4
13
|
constructor() {
|
|
5
14
|
super(...arguments);
|
|
6
15
|
this.name = 'hotkey-history';
|
|
7
|
-
this.handleUndo =
|
|
16
|
+
this.handleUndo = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
8
17
|
event.preventDefault();
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
this.handleRedo =
|
|
18
|
+
yield this.commander.undo();
|
|
19
|
+
});
|
|
20
|
+
this.handleRedo = (event) => __awaiter(this, void 0, void 0, function* () {
|
|
12
21
|
event.preventDefault();
|
|
13
|
-
|
|
14
|
-
};
|
|
22
|
+
yield this.commander.redo();
|
|
23
|
+
});
|
|
15
24
|
}
|
|
16
25
|
init(options) {
|
|
17
26
|
super.init(options);
|
|
@@ -22,6 +31,7 @@ export class HotkeyHistory extends Interaction {
|
|
|
22
31
|
this.hotkey.bind(['mod+shift+z', 'mod+y'], this.handleRedo);
|
|
23
32
|
}
|
|
24
33
|
destroy() {
|
|
25
|
-
|
|
34
|
+
var _a;
|
|
35
|
+
(_a = this.hotkey) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
26
36
|
}
|
|
27
37
|
}
|
|
@@ -70,19 +70,14 @@ export class SelectHighlight extends Interaction {
|
|
|
70
70
|
this.highlightMasks = this.highlightMasks.slice(0, selection.length);
|
|
71
71
|
}
|
|
72
72
|
drawCombinedBoundsMask(selection) {
|
|
73
|
+
var _a;
|
|
73
74
|
if (selection.length < 2) {
|
|
74
|
-
this.combinedBoundsMask
|
|
75
|
+
(_a = this.combinedBoundsMask) === null || _a === void 0 ? void 0 : _a.remove();
|
|
75
76
|
this.combinedBoundsMask = undefined;
|
|
76
77
|
return;
|
|
77
78
|
}
|
|
78
79
|
const bounds = getCombinedBounds(selection.map((element) => getElementViewportBounds(this.editor.getDocument(), element)));
|
|
79
|
-
const attrs = {
|
|
80
|
-
...bounds,
|
|
81
|
-
fill: 'none',
|
|
82
|
-
stroke: '#3384F5',
|
|
83
|
-
'stroke-width': 2,
|
|
84
|
-
'pointer-events': 'none',
|
|
85
|
-
};
|
|
80
|
+
const attrs = Object.assign(Object.assign({}, bounds), { fill: 'none', stroke: '#3384F5', 'stroke-width': 2, 'pointer-events': 'none' });
|
|
86
81
|
if (this.combinedBoundsMask) {
|
|
87
82
|
setAttributes(this.combinedBoundsMask, attrs);
|
|
88
83
|
}
|
|
@@ -91,9 +86,10 @@ export class SelectHighlight extends Interaction {
|
|
|
91
86
|
}
|
|
92
87
|
}
|
|
93
88
|
clearMasks() {
|
|
89
|
+
var _a;
|
|
94
90
|
this.highlightMasks.forEach((mask) => mask.remove());
|
|
95
91
|
this.highlightMasks = [];
|
|
96
|
-
this.combinedBoundsMask
|
|
92
|
+
(_a = this.combinedBoundsMask) === null || _a === void 0 ? void 0 : _a.remove();
|
|
97
93
|
this.combinedBoundsMask = undefined;
|
|
98
94
|
}
|
|
99
95
|
}
|
|
@@ -10,6 +10,7 @@ export class ZoomWheel extends Interaction {
|
|
|
10
10
|
super(...arguments);
|
|
11
11
|
this.name = 'zoom-wheel';
|
|
12
12
|
this.wheelListener = (event) => {
|
|
13
|
+
var _a;
|
|
13
14
|
if (!this.interaction.isActive())
|
|
14
15
|
return;
|
|
15
16
|
if (!event.ctrlKey && !event.metaKey)
|
|
@@ -17,7 +18,7 @@ export class ZoomWheel extends Interaction {
|
|
|
17
18
|
event.preventDefault();
|
|
18
19
|
const factor = event.deltaY > 0 ? 1.1 : 0.9;
|
|
19
20
|
const current = this.state.getOptions();
|
|
20
|
-
const currentPadding = current.padding
|
|
21
|
+
const currentPadding = (_a = current.padding) !== null && _a !== void 0 ? _a : 0;
|
|
21
22
|
const parsed = parsePadding(currentPadding);
|
|
22
23
|
const svg = this.editor.getDocument();
|
|
23
24
|
const bbox = svg.getBBox();
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { BatchCommand } from '../commands/index.js';
|
|
2
11
|
export class CommandManager {
|
|
3
12
|
constructor() {
|
|
@@ -7,33 +16,41 @@ export class CommandManager {
|
|
|
7
16
|
init(options) {
|
|
8
17
|
Object.assign(this, options);
|
|
9
18
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.redoStack = [];
|
|
14
|
-
this.emitHistoryChange('execute');
|
|
15
|
-
}
|
|
16
|
-
async executeBatch(commands) {
|
|
17
|
-
if (commands.length === 0)
|
|
18
|
-
return;
|
|
19
|
-
const batchCommand = new BatchCommand(commands);
|
|
20
|
-
await this.execute(batchCommand);
|
|
21
|
-
}
|
|
22
|
-
async undo() {
|
|
23
|
-
const command = this.undoStack.pop();
|
|
24
|
-
if (command) {
|
|
25
|
-
await command.undo(this.state);
|
|
26
|
-
this.redoStack.push(command);
|
|
27
|
-
this.emitHistoryChange('undo');
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
async redo() {
|
|
31
|
-
const command = this.redoStack.pop();
|
|
32
|
-
if (command) {
|
|
33
|
-
await command.apply(this.state);
|
|
19
|
+
execute(command) {
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
yield command.apply(this.state);
|
|
34
22
|
this.undoStack.push(command);
|
|
35
|
-
this.
|
|
36
|
-
|
|
23
|
+
this.redoStack = [];
|
|
24
|
+
this.emitHistoryChange('execute');
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
executeBatch(commands) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
if (commands.length === 0)
|
|
30
|
+
return;
|
|
31
|
+
const batchCommand = new BatchCommand(commands);
|
|
32
|
+
yield this.execute(batchCommand);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
undo() {
|
|
36
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
37
|
+
const command = this.undoStack.pop();
|
|
38
|
+
if (command) {
|
|
39
|
+
yield command.undo(this.state);
|
|
40
|
+
this.redoStack.push(command);
|
|
41
|
+
this.emitHistoryChange('undo');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
redo() {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
const command = this.redoStack.pop();
|
|
48
|
+
if (command) {
|
|
49
|
+
yield command.apply(this.state);
|
|
50
|
+
this.undoStack.push(command);
|
|
51
|
+
this.emitHistoryChange('redo');
|
|
52
|
+
}
|
|
53
|
+
});
|
|
37
54
|
}
|
|
38
55
|
serialize() {
|
|
39
56
|
return this.undoStack.map((cmd) => cmd.serialize());
|
|
@@ -55,7 +72,8 @@ export class CommandManager {
|
|
|
55
72
|
this.clear();
|
|
56
73
|
}
|
|
57
74
|
emitHistoryChange(action) {
|
|
58
|
-
|
|
75
|
+
var _a;
|
|
76
|
+
(_a = this.emitter) === null || _a === void 0 ? void 0 : _a.emit('history:change', {
|
|
59
77
|
type: 'history:change',
|
|
60
78
|
action,
|
|
61
79
|
});
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { createElement, getElementByRole, isInfographicComponent, setElementRole, } from '../../utils/index.js';
|
|
2
11
|
import { Extension } from '../utils/index.js';
|
|
3
12
|
export class InteractionManager {
|
|
@@ -127,43 +136,47 @@ export class InteractionManager {
|
|
|
127
136
|
/**
|
|
128
137
|
* 执行互斥交互操作(同一时间只能有一个互斥交互在进行)
|
|
129
138
|
*/
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
139
|
+
executeExclusiveInteraction(instance, callback) {
|
|
140
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
141
|
+
// 如果未激活或已有互斥交互在运行,则拒绝执行
|
|
142
|
+
if (!this.active || this.running)
|
|
143
|
+
return;
|
|
144
|
+
this.running = instance;
|
|
145
|
+
try {
|
|
146
|
+
this.emitter.emit('interaction:started', instance);
|
|
147
|
+
yield callback();
|
|
148
|
+
this.emitter.emit('interaction:ended', instance);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
console.error(`Error occurred during exclusive interaction "${instance.name}":`, error);
|
|
152
|
+
this.emitter.emit('interaction:error', instance, error);
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
this.running = null;
|
|
156
|
+
}
|
|
157
|
+
});
|
|
147
158
|
}
|
|
148
159
|
/**
|
|
149
160
|
* 执行协同交互操作(允许多个协同交互同时进行)
|
|
150
161
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
executeConcurrentInteraction(instance, callback) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
if (!this.active)
|
|
165
|
+
return;
|
|
166
|
+
this.concurrentInteractions.add(instance);
|
|
167
|
+
try {
|
|
168
|
+
this.emitter.emit('interaction:started', instance);
|
|
169
|
+
yield callback();
|
|
170
|
+
this.emitter.emit('interaction:ended', instance);
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
console.error(`Error occurred during concurrent interaction "${instance.name}":`, error);
|
|
174
|
+
this.emitter.emit('interaction:error', instance, error);
|
|
175
|
+
}
|
|
176
|
+
finally {
|
|
177
|
+
this.concurrentInteractions.delete(instance);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
167
180
|
}
|
|
168
181
|
getOrCreateTransientContainer() {
|
|
169
182
|
const role = 'transient-container';
|
|
@@ -75,7 +75,7 @@ export class StateManager {
|
|
|
75
75
|
this.updateBuiltInElement(element, props);
|
|
76
76
|
}
|
|
77
77
|
updateOptions(options) {
|
|
78
|
-
this.options = {
|
|
78
|
+
this.options = Object.assign(Object.assign({}, this.options), options);
|
|
79
79
|
if (this.options.padding !== undefined) {
|
|
80
80
|
setSVGPadding(this.editor.getDocument(), parsePadding(this.options.padding));
|
|
81
81
|
}
|
|
@@ -42,6 +42,7 @@ const DEFAULT_SWATCHES = [
|
|
|
42
42
|
'rgba(255, 255, 255, 0.85)',
|
|
43
43
|
];
|
|
44
44
|
export function ColorPicker(props) {
|
|
45
|
+
var _a, _b, _c;
|
|
45
46
|
if (typeof document === 'undefined') {
|
|
46
47
|
throw new Error('ColorPicker can only be used in the browser.');
|
|
47
48
|
}
|
|
@@ -72,15 +73,14 @@ export function ColorPicker(props) {
|
|
|
72
73
|
formatSwitch.appendChild(createSwitchLabel('RGBA'));
|
|
73
74
|
formatToggle.appendChild(formatSwitch);
|
|
74
75
|
let format = 'hexa';
|
|
75
|
-
let color = parseColor(props.value)
|
|
76
|
-
parseColor(DEFAULT_COLOR) ?? {
|
|
76
|
+
let color = (_b = (_a = parseColor(props.value)) !== null && _a !== void 0 ? _a : parseColor(DEFAULT_COLOR)) !== null && _b !== void 0 ? _b : {
|
|
77
77
|
r: 31,
|
|
78
78
|
g: 31,
|
|
79
79
|
b: 31,
|
|
80
80
|
a: 1,
|
|
81
81
|
};
|
|
82
82
|
const swatchButtons = [];
|
|
83
|
-
const swatches = props.swatches
|
|
83
|
+
const swatches = ((_c = props.swatches) === null || _c === void 0 ? void 0 : _c.length) ? props.swatches : DEFAULT_SWATCHES;
|
|
84
84
|
swatches.forEach((value) => {
|
|
85
85
|
const parsed = parseColor(value);
|
|
86
86
|
if (!parsed)
|
|
@@ -128,15 +128,17 @@ export function ColorPicker(props) {
|
|
|
128
128
|
setColor(parsed);
|
|
129
129
|
}
|
|
130
130
|
function setFormat(next, emitChange) {
|
|
131
|
+
var _a;
|
|
131
132
|
if (format === next)
|
|
132
133
|
return;
|
|
133
134
|
format = next;
|
|
134
135
|
syncUI();
|
|
135
136
|
if (emitChange) {
|
|
136
|
-
props.onChange
|
|
137
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, formatColor(color, format));
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
140
|
function setColor(next, emitChange = true) {
|
|
141
|
+
var _a;
|
|
140
142
|
if (isSameColor(color, next)) {
|
|
141
143
|
syncUI();
|
|
142
144
|
return;
|
|
@@ -144,7 +146,7 @@ export function ColorPicker(props) {
|
|
|
144
146
|
color = next;
|
|
145
147
|
syncUI();
|
|
146
148
|
if (emitChange) {
|
|
147
|
-
props.onChange
|
|
149
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, formatColor(color, format));
|
|
148
150
|
}
|
|
149
151
|
}
|
|
150
152
|
function syncUI() {
|
|
@@ -173,6 +175,7 @@ export function ColorPicker(props) {
|
|
|
173
175
|
}
|
|
174
176
|
}
|
|
175
177
|
function parseColor(value) {
|
|
178
|
+
var _a;
|
|
176
179
|
if (!value)
|
|
177
180
|
return undefined;
|
|
178
181
|
const parsed = parse(value);
|
|
@@ -183,7 +186,7 @@ function parseColor(value) {
|
|
|
183
186
|
r: clampByte(rgb.r),
|
|
184
187
|
g: clampByte(rgb.g),
|
|
185
188
|
b: clampByte(rgb.b),
|
|
186
|
-
a: clamp01(rgb.alpha
|
|
189
|
+
a: clamp01((_a = rgb.alpha) !== null && _a !== void 0 ? _a : 1),
|
|
187
190
|
};
|
|
188
191
|
}
|
|
189
192
|
function formatColor(color, format) {
|
|
@@ -5,29 +5,30 @@ const POPOVER_CONTENT_CLASS = `${POPOVER_CLASS}__content`;
|
|
|
5
5
|
const POPOVER_ARROW_CLASS = `${POPOVER_CLASS}__arrow`;
|
|
6
6
|
const POPOVER_STYLE_ID = 'infographic-edit-popover-style';
|
|
7
7
|
export function Popover(props) {
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
8
9
|
ensurePopoverStyle();
|
|
9
|
-
const placement = props.placement
|
|
10
|
-
const closeOnOutsideClick = props.closeOnOutsideClick
|
|
10
|
+
const placement = (_a = props.placement) !== null && _a !== void 0 ? _a : 'top';
|
|
11
|
+
const closeOnOutsideClick = (_b = props.closeOnOutsideClick) !== null && _b !== void 0 ? _b : true;
|
|
11
12
|
const triggerActions = Array.isArray(props.trigger)
|
|
12
13
|
? props.trigger
|
|
13
14
|
: [props.trigger || 'hover'];
|
|
14
|
-
const hoverOpenDelay = props.mouseEnterDelay
|
|
15
|
-
const hoverCloseDelay = props.mouseLeaveDelay
|
|
16
|
-
const offset = props.offset
|
|
15
|
+
const hoverOpenDelay = (_c = props.mouseEnterDelay) !== null && _c !== void 0 ? _c : 50;
|
|
16
|
+
const hoverCloseDelay = (_d = props.mouseLeaveDelay) !== null && _d !== void 0 ? _d : 150;
|
|
17
|
+
const offset = (_e = props.offset) !== null && _e !== void 0 ? _e : 8;
|
|
17
18
|
const arrowSize = 8;
|
|
18
19
|
const arrowInnerSize = 7;
|
|
19
20
|
const bodyPadding = typeof props.padding === 'number'
|
|
20
21
|
? `${props.padding}px`
|
|
21
|
-
: (props.padding
|
|
22
|
+
: ((_f = props.padding) !== null && _f !== void 0 ? _f : '4px');
|
|
22
23
|
const container = document.createElement('div');
|
|
23
24
|
container.classList.add(POPOVER_CLASS);
|
|
24
|
-
const trigger = props.target
|
|
25
|
+
const trigger = (_g = props.target) !== null && _g !== void 0 ? _g : document.createElement('div');
|
|
25
26
|
container.appendChild(trigger);
|
|
26
27
|
const getContentContainer = () => {
|
|
27
28
|
const next = typeof props.getContainer === 'function'
|
|
28
29
|
? props.getContainer()
|
|
29
30
|
: props.getContainer;
|
|
30
|
-
return next
|
|
31
|
+
return next !== null && next !== void 0 ? next : document.body;
|
|
31
32
|
};
|
|
32
33
|
const content = document.createElement('div');
|
|
33
34
|
content.classList.add(POPOVER_CONTENT_CLASS);
|
|
@@ -51,8 +52,9 @@ export function Popover(props) {
|
|
|
51
52
|
contentContainer.appendChild(content);
|
|
52
53
|
let open = Boolean(props.open);
|
|
53
54
|
let placementPriority = Array.isArray(placement) ? placement : [placement];
|
|
54
|
-
let currentPlacement = placementPriority[0]
|
|
55
|
+
let currentPlacement = (_h = placementPriority[0]) !== null && _h !== void 0 ? _h : 'top';
|
|
55
56
|
const updatePosition = () => {
|
|
57
|
+
var _a;
|
|
56
58
|
const targetRect = trigger.getBoundingClientRect();
|
|
57
59
|
const contentRect = content.getBoundingClientRect();
|
|
58
60
|
const scrollX = window.scrollX || document.documentElement.scrollLeft;
|
|
@@ -102,7 +104,7 @@ export function Popover(props) {
|
|
|
102
104
|
nextTop >= scrollY &&
|
|
103
105
|
nextLeft + contentRect.width <= scrollX + viewportWidth &&
|
|
104
106
|
nextTop + contentRect.height <= scrollY + viewportHeight;
|
|
105
|
-
let chosenPlacement = placementPriority[0]
|
|
107
|
+
let chosenPlacement = (_a = placementPriority[0]) !== null && _a !== void 0 ? _a : 'top';
|
|
106
108
|
let position = calcPosition(chosenPlacement);
|
|
107
109
|
for (const candidate of placementPriority) {
|
|
108
110
|
const nextPosition = calcPosition(candidate);
|
|
@@ -138,13 +140,14 @@ export function Popover(props) {
|
|
|
138
140
|
body.appendChild(nextContent);
|
|
139
141
|
}
|
|
140
142
|
else {
|
|
141
|
-
body.textContent = nextContent
|
|
143
|
+
body.textContent = nextContent !== null && nextContent !== void 0 ? nextContent : '';
|
|
142
144
|
}
|
|
143
145
|
updatePosition();
|
|
144
146
|
};
|
|
145
147
|
const setPlacement = (next) => {
|
|
148
|
+
var _a;
|
|
146
149
|
placementPriority = Array.isArray(next) ? next : [next];
|
|
147
|
-
currentPlacement = placementPriority[0]
|
|
150
|
+
currentPlacement = (_a = placementPriority[0]) !== null && _a !== void 0 ? _a : 'top';
|
|
148
151
|
updatePosition();
|
|
149
152
|
};
|
|
150
153
|
const setOpen = (value) => {
|
|
@@ -35,8 +35,9 @@ export function Select(props) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
const renderLabel = () => {
|
|
38
|
+
var _a, _b, _c;
|
|
38
39
|
const option = options.find((opt) => opt.value === selected);
|
|
39
|
-
const custom = props.renderLabel
|
|
40
|
+
const custom = (_a = props.renderLabel) === null || _a === void 0 ? void 0 : _a.call(props, option);
|
|
40
41
|
if (typeof custom === 'string') {
|
|
41
42
|
label.textContent = custom;
|
|
42
43
|
}
|
|
@@ -45,10 +46,10 @@ export function Select(props) {
|
|
|
45
46
|
}
|
|
46
47
|
else if (custom === null || custom === undefined) {
|
|
47
48
|
if (option) {
|
|
48
|
-
label.textContent = option.label
|
|
49
|
+
label.textContent = (_b = option.label) !== null && _b !== void 0 ? _b : option.value;
|
|
49
50
|
}
|
|
50
51
|
else {
|
|
51
|
-
label.textContent = props.placeholder
|
|
52
|
+
label.textContent = (_c = props.placeholder) !== null && _c !== void 0 ? _c : '请选择';
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
else {
|
|
@@ -58,9 +59,8 @@ export function Select(props) {
|
|
|
58
59
|
const renderOptions = () => {
|
|
59
60
|
dropdown.innerHTML = '';
|
|
60
61
|
options.forEach((option) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
defaultOptionNode(option);
|
|
62
|
+
var _a, _b, _c, _d;
|
|
63
|
+
const optionNode = (_d = (_b = (_a = props.renderOption) === null || _a === void 0 ? void 0 : _a.call(props, option)) !== null && _b !== void 0 ? _b : (_c = option.render) === null || _c === void 0 ? void 0 : _c.call(option)) !== null && _d !== void 0 ? _d : defaultOptionNode(option);
|
|
64
64
|
optionNode.classList.add(OPTION_CLASS);
|
|
65
65
|
optionNode.setAttribute('data-value', option.value);
|
|
66
66
|
if (option.disabled) {
|
|
@@ -76,9 +76,10 @@ export function Select(props) {
|
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
const selectValue = (value, option) => {
|
|
79
|
+
var _a;
|
|
79
80
|
selected = value;
|
|
80
81
|
renderLabel();
|
|
81
|
-
props.onChange
|
|
82
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, value, option);
|
|
82
83
|
setOpen(false);
|
|
83
84
|
};
|
|
84
85
|
const setOpen = (value) => {
|
|
@@ -195,7 +196,8 @@ function ensureSelectStyle() {
|
|
|
195
196
|
`);
|
|
196
197
|
}
|
|
197
198
|
function defaultOptionNode(option) {
|
|
199
|
+
var _a;
|
|
198
200
|
const node = document.createElement('div');
|
|
199
|
-
node.textContent = option.label
|
|
201
|
+
node.textContent = (_a = option.label) !== null && _a !== void 0 ? _a : option.value;
|
|
200
202
|
return node;
|
|
201
203
|
}
|
|
@@ -47,11 +47,12 @@ export class EditBar extends Plugin {
|
|
|
47
47
|
emitter.on('history:change', this.handleHistoryChanged);
|
|
48
48
|
}
|
|
49
49
|
destroy() {
|
|
50
|
+
var _a;
|
|
50
51
|
const { emitter } = this;
|
|
51
52
|
emitter.off('selection:change', this.handleSelectionChanged);
|
|
52
53
|
emitter.off('selection:geometrychange', this.handleGeometryChanged);
|
|
53
54
|
emitter.off('history:change', this.handleHistoryChanged);
|
|
54
|
-
this.container
|
|
55
|
+
(_a = this.container) === null || _a === void 0 ? void 0 : _a.remove();
|
|
55
56
|
}
|
|
56
57
|
getEditItems(selection) {
|
|
57
58
|
let hasText = false;
|
|
@@ -102,26 +103,7 @@ export class EditBar extends Plugin {
|
|
|
102
103
|
return this.container;
|
|
103
104
|
const { style, className } = this.options || {};
|
|
104
105
|
const container = document.createElement('div');
|
|
105
|
-
Object.assign(container.style, {
|
|
106
|
-
visibility: 'hidden',
|
|
107
|
-
position: 'absolute',
|
|
108
|
-
left: '0',
|
|
109
|
-
top: '0',
|
|
110
|
-
display: 'flex',
|
|
111
|
-
flexFlow: 'row',
|
|
112
|
-
justifyContent: 'center',
|
|
113
|
-
alignItems: 'center',
|
|
114
|
-
height: '40px',
|
|
115
|
-
minWidth: '40px',
|
|
116
|
-
minHeight: '40px',
|
|
117
|
-
borderRadius: '8px',
|
|
118
|
-
padding: '0 4px',
|
|
119
|
-
backgroundColor: '#fff',
|
|
120
|
-
border: '1px solid rgba(239, 240, 240, 0.9)',
|
|
121
|
-
zIndex: '9999',
|
|
122
|
-
boxShadow: 'rgba(0, 0, 0, 0.08) 0px 1px 2px -2px, rgba(0, 0, 0, 0.04) 0px 2px 6px, rgba(0, 0, 0, 0.02) 0px 4px 8px 1px',
|
|
123
|
-
...style,
|
|
124
|
-
});
|
|
106
|
+
Object.assign(container.style, Object.assign({ visibility: 'hidden', position: 'absolute', left: '0', top: '0', display: 'flex', flexFlow: 'row', justifyContent: 'center', alignItems: 'center', height: '40px', minWidth: '40px', minHeight: '40px', borderRadius: '8px', padding: '0 4px', backgroundColor: '#fff', border: '1px solid rgba(239, 240, 240, 0.9)', zIndex: '9999', boxShadow: 'rgba(0, 0, 0, 0.08) 0px 1px 2px -2px, rgba(0, 0, 0, 0.04) 0px 2px 6px, rgba(0, 0, 0, 0.02) 0px 4px 8px 1px' }, style));
|
|
125
107
|
if (className) {
|
|
126
108
|
container.classList.add(className);
|
|
127
109
|
}
|
|
@@ -129,8 +111,8 @@ export class EditBar extends Plugin {
|
|
|
129
111
|
this.container = container;
|
|
130
112
|
const { getContainer } = this.options || {};
|
|
131
113
|
const resolvedContainer = typeof getContainer === 'function' ? getContainer() : getContainer;
|
|
132
|
-
const containerParent = resolvedContainer
|
|
133
|
-
containerParent
|
|
114
|
+
const containerParent = resolvedContainer !== null && resolvedContainer !== void 0 ? resolvedContainer : document.body;
|
|
115
|
+
containerParent === null || containerParent === void 0 ? void 0 : containerParent.appendChild(container);
|
|
134
116
|
return container;
|
|
135
117
|
}
|
|
136
118
|
getTextEditItems(text) {
|
|
@@ -168,11 +150,11 @@ export class EditBar extends Plugin {
|
|
|
168
150
|
];
|
|
169
151
|
}
|
|
170
152
|
placeEditBar(container, selection) {
|
|
153
|
+
var _a;
|
|
171
154
|
if (selection.length === 0)
|
|
172
155
|
return;
|
|
173
156
|
const combinedBounds = getCombinedBounds(selection.map((element) => element.getBoundingClientRect()));
|
|
174
|
-
const offsetParent = container.offsetParent
|
|
175
|
-
document.documentElement;
|
|
157
|
+
const offsetParent = (_a = container.offsetParent) !== null && _a !== void 0 ? _a : document.documentElement;
|
|
176
158
|
const viewportHeight = document.documentElement.clientHeight;
|
|
177
159
|
const viewportWidth = document.documentElement.clientWidth;
|
|
178
160
|
const containerRect = container.getBoundingClientRect();
|