@tldraw/editor 3.9.0 → 3.10.0-canary.3176429f9d1b
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-cjs/index.d.ts +243 -5
- package/dist-cjs/index.js +9 -1
- package/dist-cjs/index.js.map +2 -2
- package/dist-cjs/lib/TldrawEditor.js +32 -6
- package/dist-cjs/lib/TldrawEditor.js.map +2 -2
- package/dist-cjs/lib/components/LiveCollaborators.js +5 -0
- package/dist-cjs/lib/components/LiveCollaborators.js.map +2 -2
- package/dist-cjs/lib/components/Shape.js +7 -0
- package/dist-cjs/lib/components/Shape.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultBrush.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCollaboratorHint.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultCursor.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultScribble.js.map +2 -2
- package/dist-cjs/lib/components/default-components/DefaultShapeIndicator.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +68 -13
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/FontManager.js +166 -0
- package/dist-cjs/lib/editor/managers/FontManager.js.map +7 -0
- package/dist-cjs/lib/editor/managers/TextManager.js +23 -17
- package/dist-cjs/lib/editor/managers/TextManager.js.map +2 -2
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js +11 -0
- package/dist-cjs/lib/editor/shapes/ShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
- package/dist-cjs/lib/editor/types/external-content.js.map +1 -1
- package/dist-cjs/lib/exports/FontEmbedder.js +7 -2
- package/dist-cjs/lib/exports/FontEmbedder.js.map +2 -2
- package/dist-cjs/lib/exports/StyleEmbedder.js +1 -1
- package/dist-cjs/lib/exports/StyleEmbedder.js.map +2 -2
- package/dist-cjs/lib/exports/exportToSvg.js +3 -2
- package/dist-cjs/lib/exports/exportToSvg.js.map +2 -2
- package/dist-cjs/lib/exports/getSvgJsx.js +18 -1
- package/dist-cjs/lib/exports/getSvgJsx.js.map +2 -2
- package/dist-cjs/lib/exports/parseCss.js +1 -0
- package/dist-cjs/lib/exports/parseCss.js.map +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js +2 -2
- package/dist-cjs/lib/hooks/useCanvasEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js +1 -1
- package/dist-cjs/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js +48 -0
- package/dist-cjs/lib/hooks/usePassThroughMouseOverEvents.js.map +7 -0
- package/dist-cjs/lib/hooks/usePassThroughWheelEvents.js.map +2 -2
- package/dist-cjs/lib/hooks/usePeerIds.js.map +1 -1
- package/dist-cjs/lib/hooks/usePresence.js.map +1 -1
- package/dist-cjs/lib/hooks/useViewportHeight.js +56 -0
- package/dist-cjs/lib/hooks/useViewportHeight.js.map +7 -0
- package/dist-cjs/lib/options.js +2 -1
- package/dist-cjs/lib/options.js.map +2 -2
- package/dist-cjs/lib/utils/dom.js +1 -1
- package/dist-cjs/lib/utils/dom.js.map +2 -2
- package/dist-cjs/lib/utils/richText.js +46 -0
- package/dist-cjs/lib/utils/richText.js.map +7 -0
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +243 -5
- package/dist-esm/index.mjs +13 -1
- package/dist-esm/index.mjs.map +2 -2
- package/dist-esm/lib/TldrawEditor.mjs +33 -7
- package/dist-esm/lib/TldrawEditor.mjs.map +2 -2
- package/dist-esm/lib/components/LiveCollaborators.mjs +5 -0
- package/dist-esm/lib/components/LiveCollaborators.mjs.map +2 -2
- package/dist-esm/lib/components/Shape.mjs +8 -1
- package/dist-esm/lib/components/Shape.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultBrush.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCollaboratorHint.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultCursor.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultScribble.mjs.map +2 -2
- package/dist-esm/lib/components/default-components/DefaultShapeIndicator.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +71 -9
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/FontManager.mjs +152 -0
- package/dist-esm/lib/editor/managers/FontManager.mjs.map +7 -0
- package/dist-esm/lib/editor/managers/TextManager.mjs +23 -17
- package/dist-esm/lib/editor/managers/TextManager.mjs.map +2 -2
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs +11 -0
- package/dist-esm/lib/editor/shapes/ShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/exports/FontEmbedder.mjs +7 -2
- package/dist-esm/lib/exports/FontEmbedder.mjs.map +2 -2
- package/dist-esm/lib/exports/StyleEmbedder.mjs +1 -1
- package/dist-esm/lib/exports/StyleEmbedder.mjs.map +2 -2
- package/dist-esm/lib/exports/exportToSvg.mjs +3 -2
- package/dist-esm/lib/exports/exportToSvg.mjs.map +2 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs +19 -2
- package/dist-esm/lib/exports/getSvgJsx.mjs.map +2 -2
- package/dist-esm/lib/exports/parseCss.mjs +1 -0
- package/dist-esm/lib/exports/parseCss.mjs.map +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs +2 -2
- package/dist-esm/lib/hooks/useCanvasEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs +1 -1
- package/dist-esm/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs +28 -0
- package/dist-esm/lib/hooks/usePassThroughMouseOverEvents.mjs.map +7 -0
- package/dist-esm/lib/hooks/usePassThroughWheelEvents.mjs.map +2 -2
- package/dist-esm/lib/hooks/usePeerIds.mjs.map +1 -1
- package/dist-esm/lib/hooks/usePresence.mjs.map +1 -1
- package/dist-esm/lib/hooks/useViewportHeight.mjs +36 -0
- package/dist-esm/lib/hooks/useViewportHeight.mjs.map +7 -0
- package/dist-esm/lib/options.mjs +2 -1
- package/dist-esm/lib/options.mjs.map +2 -2
- package/dist-esm/lib/utils/dom.mjs +1 -1
- package/dist-esm/lib/utils/dom.mjs.map +2 -2
- package/dist-esm/lib/utils/richText.mjs +26 -0
- package/dist-esm/lib/utils/richText.mjs.map +7 -0
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +127 -13
- package/package.json +10 -7
- package/src/index.ts +15 -0
- package/src/lib/TldrawEditor.tsx +52 -4
- package/src/lib/components/LiveCollaborators.tsx +5 -0
- package/src/lib/components/Shape.tsx +9 -1
- package/src/lib/components/default-components/DefaultBrush.tsx +1 -0
- package/src/lib/components/default-components/DefaultCollaboratorHint.tsx +1 -0
- package/src/lib/components/default-components/DefaultCursor.tsx +1 -0
- package/src/lib/components/default-components/DefaultScribble.tsx +1 -0
- package/src/lib/components/default-components/DefaultShapeIndicator.tsx +1 -0
- package/src/lib/editor/Editor.ts +91 -7
- package/src/lib/editor/managers/FontManager.ts +251 -0
- package/src/lib/editor/managers/TextManager.ts +42 -17
- package/src/lib/editor/shapes/ShapeUtil.ts +13 -0
- package/src/lib/editor/types/emit-types.ts +1 -0
- package/src/lib/editor/types/external-content.ts +1 -0
- package/src/lib/exports/FontEmbedder.ts +13 -1
- package/src/lib/exports/StyleEmbedder.ts +1 -1
- package/src/lib/exports/exportToSvg.tsx +4 -3
- package/src/lib/exports/getSvgJsx.tsx +22 -2
- package/src/lib/exports/parseCss.ts +1 -0
- package/src/lib/hooks/useCanvasEvents.ts +2 -1
- package/src/lib/hooks/useFixSafariDoubleTapZoomPencilEvents.ts +1 -0
- package/src/lib/hooks/usePassThroughMouseOverEvents.ts +29 -0
- package/src/lib/hooks/usePassThroughWheelEvents.ts +0 -1
- package/src/lib/hooks/usePeerIds.ts +1 -1
- package/src/lib/hooks/usePresence.ts +2 -2
- package/src/lib/hooks/useViewportHeight.ts +37 -0
- package/src/lib/options.ts +7 -0
- package/src/lib/utils/dom.ts +1 -1
- package/src/lib/utils/richText.ts +72 -0
- package/src/version.ts +3 -3
|
@@ -46,8 +46,15 @@ var __privateIn = (member, obj) => Object(obj) !== obj ? __typeError('Cannot use
|
|
|
46
46
|
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
47
47
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
48
48
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
49
|
-
var __setMetaKeyTimeout_dec, __setCtrlKeyTimeout_dec, __setAltKeyTimeout_dec, __setShiftKeyTimeout_dec, _getIsReadonly_dec, _getIsFocused_dec, _getSharedOpacity_dec, _getSharedStyles_dec, __getSelectionSharedStyles_dec, __getBindingsIndexCache_dec, _getCurrentPageRenderingShapesSorted_dec, _getCurrentPageShapesSorted_dec, _getCurrentPageShapes_dec, _getCurrentPageBounds_dec, _getCulledShapes_dec, __notVisibleShapes_dec, __getShapeMaskedPageBoundsCache_dec, __getShapeMaskCache_dec, __getShapeClipPathCache_dec, __getShapePageBoundsCache_dec, __getShapePageTransformCache_dec, __getShapeHandlesCache_dec, __getAllAssetsQuery_dec, _getCurrentPageShapeIdsSorted_dec, _getCurrentPageId_dec, _getPages_dec, __getAllPagesQuery_dec, _getRenderingShapes_dec, _getCollaboratorsOnCurrentPage_dec, _getCollaborators_dec, __getCollaboratorsQuery_dec, _getViewportPageBounds_dec, _getViewportScreenCenter_dec, _getViewportScreenBounds_dec, _getZoomLevel_dec, _getCameraForFollowing_dec, _getViewportPageBoundsForFollowing_dec, _getCamera_dec, __unsafe_getCameraId_dec, _getErasingShapes_dec, _getErasingShapeIds_dec, _getHintingShape_dec, _getHintingShapeIds_dec, _getHoveredShape_dec, _getHoveredShapeId_dec, _getEditingShape_dec, _getEditingShapeId_dec, _getFocusedGroup_dec, _getFocusedGroupId_dec, _getSelectionRotatedScreenBounds_dec, _getSelectionRotatedPageBounds_dec, _getSelectionRotation_dec, _getSelectionPageBounds_dec, _getOnlySelectedShape_dec, _getOnlySelectedShapeId_dec, _getSelectedShapes_dec, _getSelectedShapeIds_dec, __getCurrentPageStateId_dec, _getCurrentPageState_dec, __getPageStatesQuery_dec, _getPageStates_dec, _getIsMenuOpen_dec, _getOpenMenus_dec, _getInstanceState_dec, _getDocumentSettings_dec, _getCurrentToolId_dec, _getCurrentTool_dec, _getPath_dec, _getCanRedo_dec, _getCanUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
|
|
50
|
-
import {
|
|
49
|
+
var __setMetaKeyTimeout_dec, __setCtrlKeyTimeout_dec, __setAltKeyTimeout_dec, __setShiftKeyTimeout_dec, _getIsReadonly_dec, _getIsFocused_dec, _getSharedOpacity_dec, _getSharedStyles_dec, __getSelectionSharedStyles_dec, __getBindingsIndexCache_dec, _getCurrentPageRenderingShapesSorted_dec, _getCurrentPageShapesSorted_dec, _getCurrentPageShapes_dec, _getCurrentPageBounds_dec, _getCulledShapes_dec, __notVisibleShapes_dec, __getShapeMaskedPageBoundsCache_dec, __getShapeMaskCache_dec, __getShapeClipPathCache_dec, __getShapePageBoundsCache_dec, __getShapePageTransformCache_dec, __getShapeHandlesCache_dec, __getAllAssetsQuery_dec, _getCurrentPageShapeIdsSorted_dec, _getCurrentPageId_dec, _getPages_dec, __getAllPagesQuery_dec, _getRenderingShapes_dec, _getCollaboratorsOnCurrentPage_dec, _getCollaborators_dec, __getCollaboratorsQuery_dec, _getViewportPageBounds_dec, _getViewportScreenCenter_dec, _getViewportScreenBounds_dec, _getZoomLevel_dec, _getCameraForFollowing_dec, _getViewportPageBoundsForFollowing_dec, _getCamera_dec, __unsafe_getCameraId_dec, _getErasingShapes_dec, _getErasingShapeIds_dec, _getHintingShape_dec, _getHintingShapeIds_dec, _getHoveredShape_dec, _getHoveredShapeId_dec, _getRichTextEditor_dec, _getEditingShape_dec, _getEditingShapeId_dec, _getFocusedGroup_dec, _getFocusedGroupId_dec, _getSelectionRotatedScreenBounds_dec, _getSelectionRotatedPageBounds_dec, _getSelectionRotation_dec, _getSelectionPageBounds_dec, _getOnlySelectedShape_dec, _getOnlySelectedShapeId_dec, _getSelectedShapes_dec, _getSelectedShapeIds_dec, __getCurrentPageStateId_dec, _getCurrentPageState_dec, __getPageStatesQuery_dec, _getPageStates_dec, _getIsMenuOpen_dec, _getOpenMenus_dec, _getInstanceState_dec, _getDocumentSettings_dec, _getCurrentToolId_dec, _getCurrentTool_dec, _getPath_dec, _getCanRedo_dec, _getCanUndo_dec, _getIsShapeHiddenCache_dec, _a, _init;
|
|
50
|
+
import {
|
|
51
|
+
EMPTY_ARRAY,
|
|
52
|
+
atom,
|
|
53
|
+
computed,
|
|
54
|
+
react,
|
|
55
|
+
transact,
|
|
56
|
+
unsafe__withoutCapture
|
|
57
|
+
} from "@tldraw/state";
|
|
51
58
|
import {
|
|
52
59
|
reverseRecordsDiff
|
|
53
60
|
} from "@tldraw/store";
|
|
@@ -92,7 +99,6 @@ import {
|
|
|
92
99
|
structuredClone,
|
|
93
100
|
uniqueId
|
|
94
101
|
} from "@tldraw/utils";
|
|
95
|
-
import { Number } from "core-js";
|
|
96
102
|
import EventEmitter from "eventemitter3";
|
|
97
103
|
import {
|
|
98
104
|
getSnapshot,
|
|
@@ -142,6 +148,7 @@ import { deriveShapeIdsInCurrentPage } from "./derivations/shapeIdsInCurrentPage
|
|
|
142
148
|
import { ClickManager } from "./managers/ClickManager.mjs";
|
|
143
149
|
import { EdgeScrollManager } from "./managers/EdgeScrollManager.mjs";
|
|
144
150
|
import { FocusManager } from "./managers/FocusManager.mjs";
|
|
151
|
+
import { FontManager } from "./managers/FontManager.mjs";
|
|
145
152
|
import { HistoryManager } from "./managers/HistoryManager.mjs";
|
|
146
153
|
import { ScribbleManager } from "./managers/ScribbleManager.mjs";
|
|
147
154
|
import { SnapManager } from "./managers/SnapManager/SnapManager.mjs";
|
|
@@ -149,7 +156,7 @@ import { TextManager } from "./managers/TextManager.mjs";
|
|
|
149
156
|
import { TickManager } from "./managers/TickManager.mjs";
|
|
150
157
|
import { UserPreferencesManager } from "./managers/UserPreferencesManager.mjs";
|
|
151
158
|
import { RootState } from "./tools/RootState.mjs";
|
|
152
|
-
class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _getCanUndo_dec = [computed], _getCanRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed], _getOpenMenus_dec = [computed], _getIsMenuOpen_dec = [computed], _getPageStates_dec = [computed], __getPageStatesQuery_dec = [computed], _getCurrentPageState_dec = [computed], __getCurrentPageStateId_dec = [computed], _getSelectedShapeIds_dec = [computed], _getSelectedShapes_dec = [computed], _getOnlySelectedShapeId_dec = [computed], _getOnlySelectedShape_dec = [computed], _getSelectionPageBounds_dec = [computed], _getSelectionRotation_dec = [computed], _getSelectionRotatedPageBounds_dec = [computed], _getSelectionRotatedScreenBounds_dec = [computed], _getFocusedGroupId_dec = [computed], _getFocusedGroup_dec = [computed], _getEditingShapeId_dec = [computed], _getEditingShape_dec = [computed], _getHoveredShapeId_dec = [computed], _getHoveredShape_dec = [computed], _getHintingShapeIds_dec = [computed], _getHintingShape_dec = [computed], _getErasingShapeIds_dec = [computed], _getErasingShapes_dec = [computed], __unsafe_getCameraId_dec = [computed], _getCamera_dec = [computed], _getViewportPageBoundsForFollowing_dec = [computed], _getCameraForFollowing_dec = [computed], _getZoomLevel_dec = [computed], _getViewportScreenBounds_dec = [computed], _getViewportScreenCenter_dec = [computed], _getViewportPageBounds_dec = [computed], __getCollaboratorsQuery_dec = [computed], _getCollaborators_dec = [computed], _getCollaboratorsOnCurrentPage_dec = [computed], _getRenderingShapes_dec = [computed], __getAllPagesQuery_dec = [computed], _getPages_dec = [computed], _getCurrentPageId_dec = [computed], _getCurrentPageShapeIdsSorted_dec = [computed], __getAllAssetsQuery_dec = [computed], __getShapeHandlesCache_dec = [computed], __getShapePageTransformCache_dec = [computed], __getShapePageBoundsCache_dec = [computed], __getShapeClipPathCache_dec = [computed], __getShapeMaskCache_dec = [computed], __getShapeMaskedPageBoundsCache_dec = [computed], __notVisibleShapes_dec = [computed], _getCulledShapes_dec = [computed], _getCurrentPageBounds_dec = [computed], _getCurrentPageShapes_dec = [computed], _getCurrentPageShapesSorted_dec = [computed], _getCurrentPageRenderingShapesSorted_dec = [computed], __getBindingsIndexCache_dec = [computed], __getSelectionSharedStyles_dec = [computed], _getSharedStyles_dec = [computed({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [computed], _getIsFocused_dec = [computed], _getIsReadonly_dec = [computed], __setShiftKeyTimeout_dec = [bind], __setAltKeyTimeout_dec = [bind], __setCtrlKeyTimeout_dec = [bind], __setMetaKeyTimeout_dec = [bind], _a) {
|
|
159
|
+
class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed], _getCanUndo_dec = [computed], _getCanRedo_dec = [computed], _getPath_dec = [computed], _getCurrentTool_dec = [computed], _getCurrentToolId_dec = [computed], _getDocumentSettings_dec = [computed], _getInstanceState_dec = [computed], _getOpenMenus_dec = [computed], _getIsMenuOpen_dec = [computed], _getPageStates_dec = [computed], __getPageStatesQuery_dec = [computed], _getCurrentPageState_dec = [computed], __getCurrentPageStateId_dec = [computed], _getSelectedShapeIds_dec = [computed], _getSelectedShapes_dec = [computed], _getOnlySelectedShapeId_dec = [computed], _getOnlySelectedShape_dec = [computed], _getSelectionPageBounds_dec = [computed], _getSelectionRotation_dec = [computed], _getSelectionRotatedPageBounds_dec = [computed], _getSelectionRotatedScreenBounds_dec = [computed], _getFocusedGroupId_dec = [computed], _getFocusedGroup_dec = [computed], _getEditingShapeId_dec = [computed], _getEditingShape_dec = [computed], _getRichTextEditor_dec = [computed], _getHoveredShapeId_dec = [computed], _getHoveredShape_dec = [computed], _getHintingShapeIds_dec = [computed], _getHintingShape_dec = [computed], _getErasingShapeIds_dec = [computed], _getErasingShapes_dec = [computed], __unsafe_getCameraId_dec = [computed], _getCamera_dec = [computed], _getViewportPageBoundsForFollowing_dec = [computed], _getCameraForFollowing_dec = [computed], _getZoomLevel_dec = [computed], _getViewportScreenBounds_dec = [computed], _getViewportScreenCenter_dec = [computed], _getViewportPageBounds_dec = [computed], __getCollaboratorsQuery_dec = [computed], _getCollaborators_dec = [computed], _getCollaboratorsOnCurrentPage_dec = [computed], _getRenderingShapes_dec = [computed], __getAllPagesQuery_dec = [computed], _getPages_dec = [computed], _getCurrentPageId_dec = [computed], _getCurrentPageShapeIdsSorted_dec = [computed], __getAllAssetsQuery_dec = [computed], __getShapeHandlesCache_dec = [computed], __getShapePageTransformCache_dec = [computed], __getShapePageBoundsCache_dec = [computed], __getShapeClipPathCache_dec = [computed], __getShapeMaskCache_dec = [computed], __getShapeMaskedPageBoundsCache_dec = [computed], __notVisibleShapes_dec = [computed], _getCulledShapes_dec = [computed], _getCurrentPageBounds_dec = [computed], _getCurrentPageShapes_dec = [computed], _getCurrentPageShapesSorted_dec = [computed], _getCurrentPageRenderingShapesSorted_dec = [computed], __getBindingsIndexCache_dec = [computed], __getSelectionSharedStyles_dec = [computed], _getSharedStyles_dec = [computed({ isEqual: (a, b) => a.equals(b) })], _getSharedOpacity_dec = [computed], _getIsFocused_dec = [computed], _getIsReadonly_dec = [computed], __setShiftKeyTimeout_dec = [bind], __setAltKeyTimeout_dec = [bind], __setCtrlKeyTimeout_dec = [bind], __setMetaKeyTimeout_dec = [bind], _a) {
|
|
153
160
|
constructor({
|
|
154
161
|
store,
|
|
155
162
|
user,
|
|
@@ -158,14 +165,17 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
158
165
|
tools,
|
|
159
166
|
getContainer,
|
|
160
167
|
cameraOptions,
|
|
168
|
+
textOptions,
|
|
161
169
|
initialState,
|
|
162
170
|
autoFocus,
|
|
163
171
|
inferDarkMode,
|
|
164
172
|
options,
|
|
165
|
-
isShapeHidden
|
|
173
|
+
isShapeHidden,
|
|
174
|
+
fontAssetUrls
|
|
166
175
|
}) {
|
|
167
176
|
super();
|
|
168
177
|
__runInitializers(_init, 5, this);
|
|
178
|
+
__publicField(this, "id", uniqueId());
|
|
169
179
|
__publicField(this, "_isShapeHiddenPredicate");
|
|
170
180
|
__publicField(this, "options");
|
|
171
181
|
__publicField(this, "contextId", uniqueId());
|
|
@@ -220,6 +230,12 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
220
230
|
* @public
|
|
221
231
|
*/
|
|
222
232
|
__publicField(this, "textMeasure");
|
|
233
|
+
/**
|
|
234
|
+
* A utility for managing the set of fonts that should be rendered in the document.
|
|
235
|
+
*
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
238
|
+
__publicField(this, "fonts");
|
|
223
239
|
/**
|
|
224
240
|
* A manager for the editor's environment.
|
|
225
241
|
*
|
|
@@ -291,6 +307,9 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
291
307
|
__publicField(this, "_isChangingStyleTimeout", -1);
|
|
292
308
|
// Menus
|
|
293
309
|
__publicField(this, "menus", tlmenus.forContext(this.contextId));
|
|
310
|
+
// Rich text editor
|
|
311
|
+
__publicField(this, "_currentRichTextEditor", atom("rich text editor", null));
|
|
312
|
+
__publicField(this, "_textOptions");
|
|
294
313
|
__publicField(this, "_cameraOptions", atom("camera options", DEFAULT_CAMERA_OPTIONS));
|
|
295
314
|
/** @internal */
|
|
296
315
|
__publicField(this, "_viewportAnimation", null);
|
|
@@ -438,10 +457,12 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
438
457
|
this.snaps = new SnapManager(this);
|
|
439
458
|
this.disposables.add(this.timers.dispose);
|
|
440
459
|
this._cameraOptions.set({ ...DEFAULT_CAMERA_OPTIONS, ...cameraOptions });
|
|
460
|
+
this._textOptions = atom("text options", textOptions ?? null);
|
|
441
461
|
this.user = new UserPreferencesManager(user ?? createTLUser(), inferDarkMode ?? false);
|
|
442
462
|
this.disposables.add(() => this.user.dispose());
|
|
443
463
|
this.getContainer = getContainer;
|
|
444
464
|
this.textMeasure = new TextManager(this);
|
|
465
|
+
this.fonts = new FontManager(this, fontAssetUrls);
|
|
445
466
|
this._tickManager = new TickManager(this);
|
|
446
467
|
class NewRoot extends RootState {
|
|
447
468
|
static initial = initialState ?? "";
|
|
@@ -1613,6 +1634,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1613
1634
|
*/
|
|
1614
1635
|
setEditingShape(shape) {
|
|
1615
1636
|
const id = typeof shape === "string" ? shape : shape?.id ?? null;
|
|
1637
|
+
this.setRichTextEditor(null);
|
|
1616
1638
|
if (id !== this.getEditingShapeId()) {
|
|
1617
1639
|
if (id) {
|
|
1618
1640
|
const shape2 = this.getShape(id);
|
|
@@ -1629,12 +1651,36 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1629
1651
|
this.run(
|
|
1630
1652
|
() => {
|
|
1631
1653
|
this._updateCurrentPageState({ editingShapeId: null });
|
|
1654
|
+
this._currentRichTextEditor.set(null);
|
|
1632
1655
|
},
|
|
1633
1656
|
{ history: "ignore" }
|
|
1634
1657
|
);
|
|
1635
1658
|
}
|
|
1636
1659
|
return this;
|
|
1637
1660
|
}
|
|
1661
|
+
getRichTextEditor() {
|
|
1662
|
+
return this._currentRichTextEditor.get();
|
|
1663
|
+
}
|
|
1664
|
+
/**
|
|
1665
|
+
* Set the current editing shape's rich text editor.
|
|
1666
|
+
*
|
|
1667
|
+
* @example
|
|
1668
|
+
* ```ts
|
|
1669
|
+
* editor.setRichTextEditor(richTextEditorView)
|
|
1670
|
+
* ```
|
|
1671
|
+
*
|
|
1672
|
+
* @param textEditor - The text editor to set as the current editing shape's text editor.
|
|
1673
|
+
*
|
|
1674
|
+
* @public
|
|
1675
|
+
*/
|
|
1676
|
+
setRichTextEditor(textEditor) {
|
|
1677
|
+
const current = this._currentRichTextEditor.__unsafe__getWithoutCapture();
|
|
1678
|
+
if (current !== textEditor) {
|
|
1679
|
+
current?.destroy();
|
|
1680
|
+
}
|
|
1681
|
+
this._currentRichTextEditor.set(textEditor);
|
|
1682
|
+
return this;
|
|
1683
|
+
}
|
|
1638
1684
|
getHoveredShapeId() {
|
|
1639
1685
|
return this.getCurrentPageState().hoveredShapeId;
|
|
1640
1686
|
}
|
|
@@ -1780,6 +1826,18 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
1780
1826
|
}
|
|
1781
1827
|
return this;
|
|
1782
1828
|
}
|
|
1829
|
+
/**
|
|
1830
|
+
* Get the current text options.
|
|
1831
|
+
*
|
|
1832
|
+
* @example
|
|
1833
|
+
* ```ts
|
|
1834
|
+
* editor.getTextOptions()
|
|
1835
|
+
* ```
|
|
1836
|
+
*
|
|
1837
|
+
* @public */
|
|
1838
|
+
getTextOptions() {
|
|
1839
|
+
return assertExists(this._textOptions.get(), "Cannot use text without setting textOptions");
|
|
1840
|
+
}
|
|
1783
1841
|
_unsafe_getCameraId() {
|
|
1784
1842
|
return CameraRecordType.createId(this.getCurrentPageId());
|
|
1785
1843
|
}
|
|
@@ -3244,7 +3302,10 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
3244
3302
|
if (!this._shapeGeometryCaches[context]) {
|
|
3245
3303
|
this._shapeGeometryCaches[context] = this.store.createComputedCache(
|
|
3246
3304
|
"bounds",
|
|
3247
|
-
(shape2) =>
|
|
3305
|
+
(shape2) => {
|
|
3306
|
+
this.fonts.trackFontsForShape(shape2);
|
|
3307
|
+
return this.getShapeUtil(shape2).getGeometry(shape2, opts);
|
|
3308
|
+
},
|
|
3248
3309
|
{ areRecordsEqual: (a, b) => a.props === b.props }
|
|
3249
3310
|
);
|
|
3250
3311
|
}
|
|
@@ -3652,7 +3713,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
3652
3713
|
const geometry = this.getShapeGeometry(shape);
|
|
3653
3714
|
const isGroup = geometry instanceof Group2d;
|
|
3654
3715
|
const pointInShapeSpace = this.getPointInShapeSpace(shape, point);
|
|
3655
|
-
if (this.isShapeOfType(shape, "frame") ||
|
|
3716
|
+
if (this.isShapeOfType(shape, "frame") || this.isShapeOfType(shape, "arrow") && shape.props.text.trim() || (this.isShapeOfType(shape, "note") || this.isShapeOfType(shape, "geo") && shape.props.fill === "none") && this.getShapeUtil(shape).getText(shape)?.trim()) {
|
|
3656
3717
|
for (const childGeometry of geometry.children) {
|
|
3657
3718
|
if (childGeometry.isLabel && childGeometry.isPointInBounds(pointInShapeSpace)) {
|
|
3658
3719
|
return shape;
|
|
@@ -5465,7 +5526,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5465
5526
|
* @example
|
|
5466
5527
|
* ```ts
|
|
5467
5528
|
* editor.createShape(myShape)
|
|
5468
|
-
* editor.createShape({ id: 'box1', type: 'text', props: {
|
|
5529
|
+
* editor.createShape({ id: 'box1', type: 'text', props: { richText: toRichText("ok") } })
|
|
5469
5530
|
* ```
|
|
5470
5531
|
*
|
|
5471
5532
|
* @param shape - The shape (or shape partial) to create.
|
|
@@ -5482,7 +5543,7 @@ class Editor extends (_a = EventEmitter, _getIsShapeHiddenCache_dec = [computed]
|
|
|
5482
5543
|
* @example
|
|
5483
5544
|
* ```ts
|
|
5484
5545
|
* editor.createShapes([myShape])
|
|
5485
|
-
* editor.createShapes([{ id: 'box1', type: 'text', props: {
|
|
5546
|
+
* editor.createShapes([{ id: 'box1', type: 'text', props: { richText: toRichText("ok") } }])
|
|
5486
5547
|
* ```
|
|
5487
5548
|
*
|
|
5488
5549
|
* @param shapes - The shapes (or shape partials) to create.
|
|
@@ -7487,6 +7548,7 @@ __decorateElement(_init, 1, "getFocusedGroupId", _getFocusedGroupId_dec, Editor)
|
|
|
7487
7548
|
__decorateElement(_init, 1, "getFocusedGroup", _getFocusedGroup_dec, Editor);
|
|
7488
7549
|
__decorateElement(_init, 1, "getEditingShapeId", _getEditingShapeId_dec, Editor);
|
|
7489
7550
|
__decorateElement(_init, 1, "getEditingShape", _getEditingShape_dec, Editor);
|
|
7551
|
+
__decorateElement(_init, 1, "getRichTextEditor", _getRichTextEditor_dec, Editor);
|
|
7490
7552
|
__decorateElement(_init, 1, "getHoveredShapeId", _getHoveredShapeId_dec, Editor);
|
|
7491
7553
|
__decorateElement(_init, 1, "getHoveredShape", _getHoveredShape_dec, Editor);
|
|
7492
7554
|
__decorateElement(_init, 1, "getHintingShapeIds", _getHintingShapeIds_dec, Editor);
|