@plait/core 0.12.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -660,6 +660,133 @@ const ViewportTransforms$1 = {
660
660
  setViewport
661
661
  };
662
662
 
663
+ /**
664
+ * @license
665
+ * Copyright Google LLC All Rights Reserved.
666
+ *
667
+ * Use of this source code is governed by an MIT-style license that can be
668
+ * found in the LICENSE file at https://angular.io/license
669
+ */
670
+ const MAC_ENTER = 3;
671
+ const BACKSPACE = 8;
672
+ const TAB = 9;
673
+ const NUM_CENTER = 12;
674
+ const ENTER = 13;
675
+ const SHIFT = 16;
676
+ const CONTROL = 17;
677
+ const ALT = 18;
678
+ const PAUSE = 19;
679
+ const CAPS_LOCK = 20;
680
+ const ESCAPE = 27;
681
+ const SPACE = 32;
682
+ const PAGE_UP = 33;
683
+ const PAGE_DOWN = 34;
684
+ const END = 35;
685
+ const HOME = 36;
686
+ const LEFT_ARROW = 37;
687
+ const UP_ARROW = 38;
688
+ const RIGHT_ARROW = 39;
689
+ const DOWN_ARROW = 40;
690
+ const PLUS_SIGN = 43;
691
+ const PRINT_SCREEN = 44;
692
+ const INSERT = 45;
693
+ const DELETE = 46;
694
+ const ZERO = 48;
695
+ const ONE = 49;
696
+ const TWO = 50;
697
+ const THREE = 51;
698
+ const FOUR = 52;
699
+ const FIVE = 53;
700
+ const SIX = 54;
701
+ const SEVEN = 55;
702
+ const EIGHT = 56;
703
+ const NINE = 57;
704
+ const FF_SEMICOLON = 59; // Firefox (Gecko) fires this for semicolon instead of 186
705
+ const FF_EQUALS = 61; // Firefox (Gecko) fires this for equals instead of 187
706
+ const QUESTION_MARK = 63;
707
+ const AT_SIGN = 64;
708
+ const A = 65;
709
+ const B = 66;
710
+ const C = 67;
711
+ const D = 68;
712
+ const E = 69;
713
+ const F = 70;
714
+ const G = 71;
715
+ const H = 72;
716
+ const I = 73;
717
+ const J = 74;
718
+ const K = 75;
719
+ const L = 76;
720
+ const M = 77;
721
+ const N = 78;
722
+ const O = 79;
723
+ const P = 80;
724
+ const Q = 81;
725
+ const R = 82;
726
+ const S = 83;
727
+ const T = 84;
728
+ const U = 85;
729
+ const V = 86;
730
+ const W = 87;
731
+ const X = 88;
732
+ const Y = 89;
733
+ const Z = 90;
734
+ const META = 91; // WIN_KEY_LEFT
735
+ const MAC_WK_CMD_LEFT = 91;
736
+ const MAC_WK_CMD_RIGHT = 93;
737
+ const CONTEXT_MENU = 93;
738
+ const NUMPAD_ZERO = 96;
739
+ const NUMPAD_ONE = 97;
740
+ const NUMPAD_TWO = 98;
741
+ const NUMPAD_THREE = 99;
742
+ const NUMPAD_FOUR = 100;
743
+ const NUMPAD_FIVE = 101;
744
+ const NUMPAD_SIX = 102;
745
+ const NUMPAD_SEVEN = 103;
746
+ const NUMPAD_EIGHT = 104;
747
+ const NUMPAD_NINE = 105;
748
+ const NUMPAD_MULTIPLY = 106;
749
+ const NUMPAD_PLUS = 107;
750
+ const NUMPAD_MINUS = 109;
751
+ const NUMPAD_PERIOD = 110;
752
+ const NUMPAD_DIVIDE = 111;
753
+ const F1 = 112;
754
+ const F2 = 113;
755
+ const F3 = 114;
756
+ const F4 = 115;
757
+ const F5 = 116;
758
+ const F6 = 117;
759
+ const F7 = 118;
760
+ const F8 = 119;
761
+ const F9 = 120;
762
+ const F10 = 121;
763
+ const F11 = 122;
764
+ const F12 = 123;
765
+ const NUM_LOCK = 144;
766
+ const SCROLL_LOCK = 145;
767
+ const FIRST_MEDIA = 166;
768
+ const FF_MINUS = 173;
769
+ const MUTE = 173; // Firefox (Gecko) fires 181 for MUTE
770
+ const VOLUME_DOWN = 174; // Firefox (Gecko) fires 182 for VOLUME_DOWN
771
+ const VOLUME_UP = 175; // Firefox (Gecko) fires 183 for VOLUME_UP
772
+ const FF_MUTE = 181;
773
+ const FF_VOLUME_DOWN = 182;
774
+ const LAST_MEDIA = 183;
775
+ const FF_VOLUME_UP = 183;
776
+ const SEMICOLON = 186; // Firefox (Gecko) fires 59 for SEMICOLON
777
+ const EQUALS = 187; // Firefox (Gecko) fires 61 for EQUALS
778
+ const COMMA = 188;
779
+ const DASH = 189; // Firefox (Gecko) fires 173 for DASH/MINUS
780
+ const PERIOD = 190;
781
+ const SLASH = 191;
782
+ const APOSTROPHE = 192;
783
+ const TILDE = 192;
784
+ const OPEN_SQUARE_BRACKET = 219;
785
+ const BACKSLASH = 220;
786
+ const CLOSE_SQUARE_BRACKET = 221;
787
+ const SINGLE_QUOTE = 222;
788
+ const MAC_META = 224;
789
+
663
790
  const CLIP_BOARD_FORMAT_KEY = 'x-plait-fragment';
664
791
  const SCROLL_BAR_WIDTH = 20;
665
792
  const MAX_RADIUS = 16;
@@ -783,7 +910,7 @@ const Selection = {
783
910
  }
784
911
  };
785
912
 
786
- const getHitElements = (board, selection) => {
913
+ const getHitElements = (board, selection, match = () => true) => {
787
914
  const realSelection = selection || board.selection;
788
915
  const selectedElements = [];
789
916
  const isCollapsed = realSelection && realSelection.ranges.length === 1 && Selection.isCollapsed(realSelection.ranges[0]);
@@ -792,6 +919,7 @@ const getHitElements = (board, selection) => {
792
919
  return;
793
920
  }
794
921
  if (!PlaitBoard.isBoard(node) &&
922
+ match(node) &&
795
923
  realSelection &&
796
924
  realSelection.ranges.some(range => {
797
925
  return board.isHitSelection(node, range);
@@ -980,6 +1108,8 @@ function updateForeignObject(g, width, height, x, y) {
980
1108
  }
981
1109
  }
982
1110
 
1111
+ const IS_MAC = typeof window != 'undefined' && /Mac|iPod|iPhone|iPad/.test(window.navigator.platform);
1112
+
983
1113
  const IS_IOS = typeof navigator !== 'undefined' &&
984
1114
  typeof window !== 'undefined' &&
985
1115
  /iPad|iPhone|iPod/.test(navigator.userAgent) &&
@@ -2928,6 +3058,130 @@ const clearNodeWeakMap = (object) => {
2928
3058
  });
2929
3059
  };
2930
3060
 
3061
+ /**
3062
+ * @license
3063
+ * Copyright Google LLC All Rights Reserved.
3064
+ *
3065
+ * Use of this source code is governed by an MIT-style license that can be
3066
+ * found in the LICENSE file at https://angular.io/license
3067
+ */
3068
+ /** Used to generate unique IDs for events. */
3069
+ let uniqueIds = 0;
3070
+ /**
3071
+ * Creates a browser MouseEvent with the specified options.
3072
+ * @docs-private
3073
+ */
3074
+ function createMouseEvent(type, clientX = 0, clientY = 0, offsetX = 1, offsetY = 1, button = 0, modifiers = {}) {
3075
+ // Note: We cannot determine the position of the mouse event based on the screen
3076
+ // because the dimensions and position of the browser window are not available
3077
+ // To provide reasonable `screenX` and `screenY` coordinates, we simply use the
3078
+ // client coordinates as if the browser is opened in fullscreen.
3079
+ const screenX = clientX;
3080
+ const screenY = clientY;
3081
+ const event = new MouseEvent(type, {
3082
+ bubbles: true,
3083
+ cancelable: true,
3084
+ composed: true,
3085
+ view: window,
3086
+ detail: 0,
3087
+ relatedTarget: null,
3088
+ screenX,
3089
+ screenY,
3090
+ clientX,
3091
+ clientY,
3092
+ ctrlKey: modifiers.control,
3093
+ altKey: modifiers.alt,
3094
+ shiftKey: modifiers.shift,
3095
+ metaKey: modifiers.meta,
3096
+ button: button,
3097
+ buttons: 1
3098
+ });
3099
+ // The `MouseEvent` constructor doesn't allow us to pass these properties into the constructor.
3100
+ // Override them to `1`, because they're used for fake screen reader event detection.
3101
+ if (offsetX != null) {
3102
+ defineReadonlyEventProperty(event, 'offsetX', offsetX);
3103
+ }
3104
+ if (offsetY != null) {
3105
+ defineReadonlyEventProperty(event, 'offsetY', offsetY);
3106
+ }
3107
+ return event;
3108
+ }
3109
+ /**
3110
+ * Creates a browser `PointerEvent` with the specified options. Pointer events
3111
+ * by default will appear as if they are the primary pointer of their type.
3112
+ * https://www.w3.org/TR/pointerevents2/#dom-pointerevent-isprimary.
3113
+ *
3114
+ * For example, if pointer events for a multi-touch interaction are created, the non-primary
3115
+ * pointer touches would need to be represented by non-primary pointer events.
3116
+ *
3117
+ * @docs-private
3118
+ */
3119
+ function createPointerEvent(type, clientX = 0, clientY = 0, offsetX, offsetY, options = { isPrimary: true }) {
3120
+ const event = new PointerEvent(type, Object.assign({ bubbles: true, cancelable: true, composed: true, view: window, clientX,
3121
+ clientY }, options));
3122
+ if (offsetX != null) {
3123
+ defineReadonlyEventProperty(event, 'offsetX', offsetX);
3124
+ }
3125
+ if (offsetY != null) {
3126
+ defineReadonlyEventProperty(event, 'offsetY', offsetY);
3127
+ }
3128
+ return event;
3129
+ }
3130
+ /**
3131
+ * Creates a browser TouchEvent with the specified pointer coordinates.
3132
+ * @docs-private
3133
+ */
3134
+ function createTouchEvent(type, pageX = 0, pageY = 0, clientX = 0, clientY = 0) {
3135
+ // We cannot use the `TouchEvent` or `Touch` because Firefox and Safari lack support.
3136
+ // TODO: Switch to the constructor API when it is available for Firefox and Safari.
3137
+ const event = document.createEvent('UIEvent');
3138
+ const touchDetails = { pageX, pageY, clientX, clientY, identifier: uniqueIds++ };
3139
+ // TS3.6 removes the initUIEvent method and suggests porting to "new UIEvent()".
3140
+ event.initUIEvent(type, true, true, window, 0);
3141
+ // Most of the browsers don't have a "initTouchEvent" method that can be used to define
3142
+ // the touch details.
3143
+ defineReadonlyEventProperty(event, 'touches', [touchDetails]);
3144
+ defineReadonlyEventProperty(event, 'targetTouches', [touchDetails]);
3145
+ defineReadonlyEventProperty(event, 'changedTouches', [touchDetails]);
3146
+ return event;
3147
+ }
3148
+ /**
3149
+ * Creates a keyboard event with the specified key and modifiers.
3150
+ * @docs-private
3151
+ */
3152
+ function createKeyboardEvent(type, keyCode = 0, key = '', modifiers = {}) {
3153
+ return new KeyboardEvent(type, {
3154
+ bubbles: true,
3155
+ cancelable: true,
3156
+ composed: true,
3157
+ view: window,
3158
+ keyCode: keyCode,
3159
+ key: key,
3160
+ shiftKey: modifiers.shift,
3161
+ metaKey: modifiers.meta,
3162
+ altKey: modifiers.alt,
3163
+ ctrlKey: modifiers.control
3164
+ });
3165
+ }
3166
+ /**
3167
+ * Creates a fake event object with any desired event type.
3168
+ * @docs-private
3169
+ */
3170
+ function createFakeEvent(type, bubbles = false, cancelable = true, composed = true) {
3171
+ return new Event(type, { bubbles, cancelable, composed });
3172
+ }
3173
+ /**
3174
+ * Defines a readonly property on the given event object. Readonly properties on an event object
3175
+ * are always set as configurable as that matches default readonly properties for DOM event objects.
3176
+ */
3177
+ function defineReadonlyEventProperty(event, propertyName, value) {
3178
+ Object.defineProperty(event, propertyName, { get: () => value, configurable: true });
3179
+ }
3180
+ function createModModifierKeys() {
3181
+ const modifiers = IS_MAC ? { meta: true } : { control: true };
3182
+ return modifiers;
3183
+ }
3184
+
2931
3185
  /*
2932
3186
  * Public API Surface of plait
2933
3187
  */
@@ -2936,5 +3190,5 @@ const clearNodeWeakMap = (object) => {
2936
3190
  * Generated bundle index. Do not edit.
2937
3191
  */
2938
3192
 
2939
- export { BOARD_TO_COMPONENT, BOARD_TO_ELEMENT_HOST, BOARD_TO_HOST, BOARD_TO_IS_SELECTION_MOVING, BOARD_TO_MOVING_ELEMENT, BOARD_TO_MOVING_POINT, BOARD_TO_ON_CHANGE, BOARD_TO_ROUGH_SVG, BOARD_TO_SELECTED_ELEMENT, BOARD_TO_TEMPORARY_ELEMENTS, BOARD_TO_VIEWPORT_ORIGINATION, BoardTransforms, CLIP_BOARD_FORMAT_KEY, ColorfulThemeColor, DarkThemeColor, DefaultThemeColor, ELEMENT_TO_COMPONENT, FLUSHING, IS_APPLE, IS_BOARD_CACHE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_IOS, IS_SAFARI, IS_TEXT_EDITABLE, MAX_RADIUS, MERGING, NODE_TO_INDEX, NODE_TO_PARENT, NS, PATH_REFS, POINTER_BUTTON, Path, PlaitBoard, PlaitBoardComponent, PlaitChildrenElement, PlaitElement, PlaitElementComponent, PlaitHistoryBoard, PlaitIslandBaseComponent, PlaitModule, PlaitNode, PlaitOperation, PlaitPluginElementComponent, PlaitPluginKey, PlaitPointerType, Point, RectangleClient, RetroThemeColor, SAVING, SCROLL_BAR_WIDTH, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, Selection, SoftThemeColor, StarryThemeColor, ThemeColorMode, ThemeColors, Transforms, Viewport, addMovingElements, addSelectedElement, arrowPoints, cacheMovingElements, cacheSelectedElements, clampZoomLevel, clearNodeWeakMap, clearSelectedElement, clearSelectionMoving, clearViewportOrigination, createForeignObject, createG, createPath, createSVG, createSelectionOuterG, createTestingBoard, createText, debounce, deleteTemporaryElements, depthFirstRecursion, distanceBetweenPointAndPoint, distanceBetweenPointAndRectangle, distanceBetweenPointAndSegment, downloadImage, drawAbstractRoundRectangle, drawArrow, drawCircle, drawLine, drawLinearPath, drawRoundRectangle, fakeNodeWeakMap, getBoardRectangle, getElementHostBBox, getHitElementOfRoot, getHitElements, getMovingElements, getRealScrollBarWidth, getRectangleByElements, getSelectedElements, getTemporaryElements, getViewBox, getViewBoxCenterPoint, getViewportContainerRect, getViewportOrigination, hasBeforeContextChange, hasInputOrTextareaTarget, hasOnBoardChange, hasOnContextChanged, hotkeys, idCreator, initializeViewBox, initializeViewportContainer, initializeViewportOffset, inverse, isDOMElement, isDOMNode, isFromScrolling, isFromViewportChange, isHitElements, isInPlaitBoard, isMainPointer, isNullOrUndefined, isSecondaryPointer, isSelectedElement, isSelectionMoving, isSetViewportOperation, normalizePoint, removeMovingElements, removeSelectedElement, rotate, scrollToRectangle, setIsFromScrolling, setIsFromViewportChange, setSVGViewBox, setSelectionMoving, shouldClear, shouldMerge, shouldSave, throttleRAF, toImage, toPoint, transformPoint, transformPoints, updateForeignObject, updateViewportContainerScroll, updateViewportOffset, updateViewportOrigination, withMoving, withOptions, withSelection };
3193
+ export { A, ALT, APOSTROPHE, AT_SIGN, B, BACKSLASH, BACKSPACE, BOARD_TO_COMPONENT, BOARD_TO_ELEMENT_HOST, BOARD_TO_HOST, BOARD_TO_IS_SELECTION_MOVING, BOARD_TO_MOVING_ELEMENT, BOARD_TO_MOVING_POINT, BOARD_TO_ON_CHANGE, BOARD_TO_ROUGH_SVG, BOARD_TO_SELECTED_ELEMENT, BOARD_TO_TEMPORARY_ELEMENTS, BOARD_TO_VIEWPORT_ORIGINATION, BoardTransforms, C, CAPS_LOCK, CLIP_BOARD_FORMAT_KEY, CLOSE_SQUARE_BRACKET, COMMA, CONTEXT_MENU, CONTROL, ColorfulThemeColor, D, DASH, DELETE, DOWN_ARROW, DarkThemeColor, DefaultThemeColor, E, EIGHT, ELEMENT_TO_COMPONENT, END, ENTER, EQUALS, ESCAPE, F, F1, F10, F11, F12, F2, F3, F4, F5, F6, F7, F8, F9, FF_EQUALS, FF_MINUS, FF_MUTE, FF_SEMICOLON, FF_VOLUME_DOWN, FF_VOLUME_UP, FIRST_MEDIA, FIVE, FLUSHING, FOUR, G, H, HOME, I, INSERT, IS_APPLE, IS_BOARD_CACHE, IS_CHROME, IS_CHROME_LEGACY, IS_EDGE_LEGACY, IS_FIREFOX, IS_IOS, IS_MAC, IS_SAFARI, IS_TEXT_EDITABLE, J, K, L, LAST_MEDIA, LEFT_ARROW, M, MAC_ENTER, MAC_META, MAC_WK_CMD_LEFT, MAC_WK_CMD_RIGHT, MAX_RADIUS, MERGING, META, MUTE, N, NINE, NODE_TO_INDEX, NODE_TO_PARENT, NS, NUMPAD_DIVIDE, NUMPAD_EIGHT, NUMPAD_FIVE, NUMPAD_FOUR, NUMPAD_MINUS, NUMPAD_MULTIPLY, NUMPAD_NINE, NUMPAD_ONE, NUMPAD_PERIOD, NUMPAD_PLUS, NUMPAD_SEVEN, NUMPAD_SIX, NUMPAD_THREE, NUMPAD_TWO, NUMPAD_ZERO, NUM_CENTER, NUM_LOCK, O, ONE, OPEN_SQUARE_BRACKET, P, PAGE_DOWN, PAGE_UP, PATH_REFS, PAUSE, PERIOD, PLUS_SIGN, POINTER_BUTTON, PRINT_SCREEN, Path, PlaitBoard, PlaitBoardComponent, PlaitChildrenElement, PlaitElement, PlaitElementComponent, PlaitHistoryBoard, PlaitIslandBaseComponent, PlaitModule, PlaitNode, PlaitOperation, PlaitPluginElementComponent, PlaitPluginKey, PlaitPointerType, Point, Q, QUESTION_MARK, R, RIGHT_ARROW, RectangleClient, RetroThemeColor, S, SAVING, SCROLL_BAR_WIDTH, SCROLL_LOCK, SELECTION_BORDER_COLOR, SELECTION_FILL_COLOR, SEMICOLON, SEVEN, SHIFT, SINGLE_QUOTE, SIX, SLASH, SPACE, Selection, SoftThemeColor, StarryThemeColor, T, TAB, THREE, TILDE, TWO, ThemeColorMode, ThemeColors, Transforms, U, UP_ARROW, V, VOLUME_DOWN, VOLUME_UP, Viewport, W, X, Y, Z, ZERO, addMovingElements, addSelectedElement, arrowPoints, cacheMovingElements, cacheSelectedElements, clampZoomLevel, clearNodeWeakMap, clearSelectedElement, clearSelectionMoving, clearViewportOrigination, createFakeEvent, createForeignObject, createG, createKeyboardEvent, createModModifierKeys, createMouseEvent, createPath, createPointerEvent, createSVG, createSelectionOuterG, createTestingBoard, createText, createTouchEvent, debounce, deleteTemporaryElements, depthFirstRecursion, distanceBetweenPointAndPoint, distanceBetweenPointAndRectangle, distanceBetweenPointAndSegment, downloadImage, drawAbstractRoundRectangle, drawArrow, drawCircle, drawLine, drawLinearPath, drawRoundRectangle, fakeNodeWeakMap, getBoardRectangle, getElementHostBBox, getHitElementOfRoot, getHitElements, getMovingElements, getRealScrollBarWidth, getRectangleByElements, getSelectedElements, getTemporaryElements, getViewBox, getViewBoxCenterPoint, getViewportContainerRect, getViewportOrigination, hasBeforeContextChange, hasInputOrTextareaTarget, hasOnBoardChange, hasOnContextChanged, hotkeys, idCreator, initializeViewBox, initializeViewportContainer, initializeViewportOffset, inverse, isDOMElement, isDOMNode, isFromScrolling, isFromViewportChange, isHitElements, isInPlaitBoard, isMainPointer, isNullOrUndefined, isSecondaryPointer, isSelectedElement, isSelectionMoving, isSetViewportOperation, normalizePoint, removeMovingElements, removeSelectedElement, rotate, scrollToRectangle, setIsFromScrolling, setIsFromViewportChange, setSVGViewBox, setSelectionMoving, shouldClear, shouldMerge, shouldSave, throttleRAF, toImage, toPoint, transformPoint, transformPoints, updateForeignObject, updateViewportContainerScroll, updateViewportOffset, updateViewportOrigination, withMoving, withOptions, withSelection };
2940
3194
  //# sourceMappingURL=plait-core.mjs.map