@ibodr/editor 0.1.8 → 0.1.10
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/index.d.ts +6 -5
- package/dist/index.mjs +66 -48
- package/dist/index.mjs.map +1 -1
- package/editor.css +105 -0
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import * as _ibodr_store from '@ibodr/store';
|
|
|
6
6
|
import { LegacyMigrations, MigrationSequence, UnknownRecord, SerializedSchema, RecordsDiff, Store, AtomSet, HistoryEntry, StoreSideEffects, SerializedStore, StoreSchema } from '@ibodr/store';
|
|
7
7
|
export * from '@ibodr/store';
|
|
8
8
|
import * as _ibodr_schema from '@ibodr/schema';
|
|
9
|
-
import { DrAsset, RecordProps, DrPropsMigrations, DrUnknownAsset, DrAssetId, DrBinding, DrUnknownBinding, DrShape, VecModel, BoxModel, DrHandle, DrShapeId, DrCursorType, DrUnknownShape, DrShapePartial, DrFontFace, DrShapeCrop, DrParentId, DrGroupShape, DrPageId, DrStore, DrStoreSnapshot, DrUser, DrRichText, StyleProp, DrInstancePresence, DrScribble, DrDefaultHorizontalAlignStyle, DrRecord, DrThemes, DrThemeId, DrTheme, DrInstancePageState, DrInstance, DrDocument, DrCursor, DrCamera, DrPage, DrImageAsset, DrVideoAsset, DrAssetPartial, DrBindingId, DrBindingCreate, DrBindingUpdate, DrCreateShapePartial, StylePropValue, DrAssetStore, DrUserStore, DrStoreProps, CustomRecordInfo, DrThemeColors, DrDefaultColorStyle, DrDefaultColor, ExtractShapeByProps, DrDefaultDashStyle, DrBaseShape, DrStoreSchema } from '@ibodr/schema';
|
|
9
|
+
import { DrAsset, RecordProps, DrPropsMigrations, DrUnknownAsset, DrAssetId, DrBinding, DrUnknownBinding, DrShape, VecModel, BoxModel, DrHandle, DrShapeId, DrCursorType, DrUnknownShape, DrShapePartial, DrFontFace, DrShapeCrop, DrParentId, DrGroupShape, DrPageId, DrBoardBackgroundType, DrStore, DrStoreSnapshot, DrUser, DrRichText, StyleProp, DrInstancePresence, DrScribble, DrDefaultHorizontalAlignStyle, DrRecord, DrThemes, DrThemeId, DrTheme, DrInstancePageState, DrInstance, DrDocument, DrCursor, DrCamera, DrPage, DrImageAsset, DrVideoAsset, DrAssetPartial, DrBindingId, DrBindingCreate, DrBindingUpdate, DrCreateShapePartial, StylePropValue, DrAssetStore, DrUserStore, DrStoreProps, CustomRecordInfo, DrThemeColors, DrDefaultColorStyle, DrDefaultColor, ExtractShapeByProps, DrDefaultDashStyle, DrBaseShape, DrStoreSchema } from '@ibodr/schema';
|
|
10
10
|
export * from '@ibodr/schema';
|
|
11
11
|
import { IndexKey, Awaitable, PerformanceTracker, JsonObject, Timers } from '@ibodr/utils';
|
|
12
12
|
export * from '@ibodr/utils';
|
|
@@ -2258,6 +2258,7 @@ interface DrSessionStateSnapshot {
|
|
|
2258
2258
|
isDebugMode?: boolean;
|
|
2259
2259
|
isToolLocked?: boolean;
|
|
2260
2260
|
isGridMode?: boolean;
|
|
2261
|
+
backgroundType?: DrBoardBackgroundType;
|
|
2261
2262
|
pageStates?: Array<{
|
|
2262
2263
|
pageId: DrPageId;
|
|
2263
2264
|
camera?: {
|
|
@@ -4168,7 +4169,7 @@ declare class UserPreferencesManager {
|
|
|
4168
4169
|
isWrapMode: boolean;
|
|
4169
4170
|
isDynamicResizeMode: boolean;
|
|
4170
4171
|
enhancedA11yMode: boolean;
|
|
4171
|
-
inputMode: "
|
|
4172
|
+
inputMode: "trackpad" | "mouse" | null;
|
|
4172
4173
|
isZoomDirectionInverted: boolean;
|
|
4173
4174
|
};
|
|
4174
4175
|
getIsDarkMode(): boolean;
|
|
@@ -4187,7 +4188,7 @@ declare class UserPreferencesManager {
|
|
|
4187
4188
|
getIsDynamicResizeMode(): boolean;
|
|
4188
4189
|
getIsPasteAtCursorMode(): boolean;
|
|
4189
4190
|
getEnhancedA11yMode(): boolean;
|
|
4190
|
-
getInputMode(): "
|
|
4191
|
+
getInputMode(): "trackpad" | "mouse" | null;
|
|
4191
4192
|
getIsZoomDirectionInverted(): boolean;
|
|
4192
4193
|
}
|
|
4193
4194
|
|
|
@@ -8352,12 +8353,12 @@ declare class ErrorBoundary extends React$1.Component<React$1.PropsWithChildren<
|
|
|
8352
8353
|
error: null;
|
|
8353
8354
|
};
|
|
8354
8355
|
componentDidCatch(error: unknown): void;
|
|
8355
|
-
render(): string | number | bigint | boolean |
|
|
8356
|
+
render(): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
8356
8357
|
}
|
|
8357
8358
|
/** @internal */
|
|
8358
8359
|
declare function OptionalErrorBoundary({ children, fallback, ...props }: Omit<DrErrorBoundaryProps, 'fallback'> & {
|
|
8359
8360
|
fallback: DrErrorFallbackComponent;
|
|
8360
|
-
}): string | number | bigint | boolean |
|
|
8361
|
+
}): string | number | bigint | boolean | Iterable<React$1.ReactNode> | Promise<string | number | bigint | boolean | React$1.ReactPortal | React$1.ReactElement<unknown, string | React$1.JSXElementConstructor<any>> | Iterable<React$1.ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
8361
8362
|
|
|
8362
8363
|
/** @public */
|
|
8363
8364
|
type HTMLContainerProps = React$1.HTMLAttributes<HTMLDivElement>;
|
package/dist/index.mjs
CHANGED
|
@@ -6,14 +6,14 @@ import { useQuickReactor, useStateTracking, useValue, useReactor, useAtom, useCo
|
|
|
6
6
|
export * from '@ibodr/state-react';
|
|
7
7
|
import { createComputedCache, Store, squashRecordDiffs, isRecordsDiffEmpty, reverseRecordsDiff, squashRecordDiffsMutable, createEmptyRecordsDiff, AtomMap, AtomSet, IncrementalSetConstructor } from '@ibodr/store';
|
|
8
8
|
export * from '@ibodr/store';
|
|
9
|
-
import { getDefaultTranslationLocale, pageIdValidator, shapeIdValidator, DefaultFontFamilies, UserRecordType, createUserId, registerColorsFromThemes, registerFontsFromThemes, groupShapeProps, groupShapeMigrations, getShapePropKeysByStyle, isShapeId, CameraRecordType, InstancePageStateRecordType, isPageId, PageRecordType, DrDOCUMENT_ID, DrINSTANCE_ID, createBindingId, createShapeId, createCachedUserResolve, isShape, DrPOINTER_ID, pluckPreservingValues, createDrSchema } from '@ibodr/schema';
|
|
9
|
+
import { getDefaultTranslationLocale, pageIdValidator, shapeIdValidator, DR_BOARD_BACKGROUND_TYPES, DefaultFontFamilies, UserRecordType, createUserId, registerColorsFromThemes, registerFontsFromThemes, groupShapeProps, groupShapeMigrations, getShapePropKeysByStyle, isShapeId, CameraRecordType, InstancePageStateRecordType, isPageId, PageRecordType, DrDOCUMENT_ID, DrINSTANCE_ID, createBindingId, createShapeId, createCachedUserResolve, isShape, DrPOINTER_ID, pluckPreservingValues, createDrSchema } from '@ibodr/schema';
|
|
10
10
|
export * from '@ibodr/schema';
|
|
11
11
|
import { T } from '@ibodr/validate';
|
|
12
12
|
export * from '@ibodr/validate';
|
|
13
|
-
import
|
|
14
|
-
import classNames from 'classnames';
|
|
13
|
+
import classNames2 from 'classnames';
|
|
15
14
|
import * as React from 'react';
|
|
16
15
|
import React__default, { createContext, memo, useRef, useEffect, useLayoutEffect, useCallback, forwardRef, useState, useMemo, useSyncExternalStore, useContext, Fragment as Fragment$1, useDebugValue, useId } from 'react';
|
|
16
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
17
17
|
import { flushSync } from 'react-dom';
|
|
18
18
|
import { openDB, deleteDB } from 'idb';
|
|
19
19
|
import EventEmitter from 'eventemitter3';
|
|
@@ -32,8 +32,56 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
32
32
|
if (result) __defProp(target, key, result);
|
|
33
33
|
return result;
|
|
34
34
|
};
|
|
35
|
+
function suffixSafeId(id, suffix) {
|
|
36
|
+
return sanitizeId(`${id}_${suffix}`);
|
|
37
|
+
}
|
|
38
|
+
function useUniqueSafeId(suffix) {
|
|
39
|
+
return sanitizeId(`${useId()}${suffix ?? ""}`);
|
|
40
|
+
}
|
|
41
|
+
function useSharedSafeId(id) {
|
|
42
|
+
const idScope = assertExists(useContext(IdContext));
|
|
43
|
+
return sanitizeId(`${idScope}_${id}`);
|
|
44
|
+
}
|
|
45
|
+
function sanitizeId(id) {
|
|
46
|
+
return id.replace(/:/g, "_");
|
|
47
|
+
}
|
|
48
|
+
var IdContext = createContext(null);
|
|
49
|
+
function IdProvider({ children }) {
|
|
50
|
+
const id = useUniqueSafeId();
|
|
51
|
+
return /* @__PURE__ */ jsx(IdContext.Provider, { value: id, children });
|
|
52
|
+
}
|
|
53
|
+
var EditorContext = createContext(null);
|
|
54
|
+
function useEditor() {
|
|
55
|
+
const editor = React__default.useContext(EditorContext);
|
|
56
|
+
if (!editor) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
"useEditor must be used inside of the <Draw /> or <DrawEditor /> components"
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
return editor;
|
|
62
|
+
}
|
|
63
|
+
function useMaybeEditor() {
|
|
64
|
+
return React__default.useContext(EditorContext);
|
|
65
|
+
}
|
|
66
|
+
function EditorProvider({ editor, children }) {
|
|
67
|
+
return /* @__PURE__ */ jsx(EditorContext.Provider, { value: editor, children: /* @__PURE__ */ jsx(IdProvider, { children }) });
|
|
68
|
+
}
|
|
35
69
|
function DefaultBackground() {
|
|
36
|
-
|
|
70
|
+
const editor = useEditor();
|
|
71
|
+
const backgroundType = useValue(
|
|
72
|
+
"backgroundType",
|
|
73
|
+
() => editor.getInstanceState().backgroundType,
|
|
74
|
+
[editor]
|
|
75
|
+
);
|
|
76
|
+
return /* @__PURE__ */ jsx(
|
|
77
|
+
"div",
|
|
78
|
+
{
|
|
79
|
+
className: classNames2(
|
|
80
|
+
"dr-background",
|
|
81
|
+
backgroundType !== "none" && `dr-background__${backgroundType}`
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
);
|
|
37
85
|
}
|
|
38
86
|
var featureFlags = {};
|
|
39
87
|
var pointerCaptureTrackingObject = createDebugValue(
|
|
@@ -326,40 +374,6 @@ function getPointerInfo(editor, e) {
|
|
|
326
374
|
isPen: e.pointerType === "pen"
|
|
327
375
|
};
|
|
328
376
|
}
|
|
329
|
-
function suffixSafeId(id, suffix) {
|
|
330
|
-
return sanitizeId(`${id}_${suffix}`);
|
|
331
|
-
}
|
|
332
|
-
function useUniqueSafeId(suffix) {
|
|
333
|
-
return sanitizeId(`${useId()}${suffix ?? ""}`);
|
|
334
|
-
}
|
|
335
|
-
function useSharedSafeId(id) {
|
|
336
|
-
const idScope = assertExists(useContext(IdContext));
|
|
337
|
-
return sanitizeId(`${idScope}_${id}`);
|
|
338
|
-
}
|
|
339
|
-
function sanitizeId(id) {
|
|
340
|
-
return id.replace(/:/g, "_");
|
|
341
|
-
}
|
|
342
|
-
var IdContext = createContext(null);
|
|
343
|
-
function IdProvider({ children }) {
|
|
344
|
-
const id = useUniqueSafeId();
|
|
345
|
-
return /* @__PURE__ */ jsx(IdContext.Provider, { value: id, children });
|
|
346
|
-
}
|
|
347
|
-
var EditorContext = createContext(null);
|
|
348
|
-
function useEditor() {
|
|
349
|
-
const editor = React__default.useContext(EditorContext);
|
|
350
|
-
if (!editor) {
|
|
351
|
-
throw new Error(
|
|
352
|
-
"useEditor must be used inside of the <Draw /> or <DrawEditor /> components"
|
|
353
|
-
);
|
|
354
|
-
}
|
|
355
|
-
return editor;
|
|
356
|
-
}
|
|
357
|
-
function useMaybeEditor() {
|
|
358
|
-
return React__default.useContext(EditorContext);
|
|
359
|
-
}
|
|
360
|
-
function EditorProvider({ editor, children }) {
|
|
361
|
-
return /* @__PURE__ */ jsx(EditorContext.Provider, { value: editor, children: /* @__PURE__ */ jsx(IdProvider, { children }) });
|
|
362
|
-
}
|
|
363
377
|
|
|
364
378
|
// src/lib/hooks/useCanvasEvents.ts
|
|
365
379
|
function useCanvasEvents() {
|
|
@@ -4041,7 +4055,7 @@ function DefaultCanvas({ className }) {
|
|
|
4041
4055
|
{
|
|
4042
4056
|
ref: rCanvas,
|
|
4043
4057
|
draggable: false,
|
|
4044
|
-
className:
|
|
4058
|
+
className: classNames2("dr-canvas", className),
|
|
4045
4059
|
"data-testid": "canvas",
|
|
4046
4060
|
...events,
|
|
4047
4061
|
children: [
|
|
@@ -4231,7 +4245,7 @@ function MovingCameraHitTestBlocker() {
|
|
|
4231
4245
|
return /* @__PURE__ */ jsx(
|
|
4232
4246
|
"div",
|
|
4233
4247
|
{
|
|
4234
|
-
className:
|
|
4248
|
+
className: classNames2("dr-hit-test-blocker", {
|
|
4235
4249
|
"dr-hit-test-blocker__hidden": cameraState === "idle"
|
|
4236
4250
|
})
|
|
4237
4251
|
}
|
|
@@ -4612,7 +4626,7 @@ My browser: ${navigator.userAgent}`
|
|
|
4612
4626
|
"div",
|
|
4613
4627
|
{
|
|
4614
4628
|
ref: containerRef,
|
|
4615
|
-
className:
|
|
4629
|
+
className: classNames2(
|
|
4616
4630
|
"dr-container tl-error-boundary",
|
|
4617
4631
|
// error-boundary is sometimes used outside of the theme
|
|
4618
4632
|
// container, so we need to provide it with a theme for our
|
|
@@ -4631,7 +4645,7 @@ My browser: ${navigator.userAgent}`
|
|
|
4631
4645
|
/* @__PURE__ */ jsx(
|
|
4632
4646
|
"div",
|
|
4633
4647
|
{
|
|
4634
|
-
className:
|
|
4648
|
+
className: classNames2("dr-modal", "dr-error-boundary__content", {
|
|
4635
4649
|
"dr-error-boundary__content__expanded": shouldShowError && !shouldShowResetConfirmation
|
|
4636
4650
|
}),
|
|
4637
4651
|
children: shouldShowResetConfirmation ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4752,7 +4766,7 @@ var DefaultShapeWrapper = forwardRef(function DefaultShapeWrapper2({ children, s
|
|
|
4752
4766
|
"data-shape-id": shape.id,
|
|
4753
4767
|
draggable: false,
|
|
4754
4768
|
...props,
|
|
4755
|
-
className:
|
|
4769
|
+
className: classNames2("dr-shape", isBackground && "dr-shape-background", props.className),
|
|
4756
4770
|
children
|
|
4757
4771
|
}
|
|
4758
4772
|
);
|
|
@@ -4766,7 +4780,7 @@ function DefaultSpinner(props) {
|
|
|
4766
4780
|
viewBox: "0 0 16 16",
|
|
4767
4781
|
"aria-hidden": "false",
|
|
4768
4782
|
...props,
|
|
4769
|
-
className:
|
|
4783
|
+
className: classNames2("dr-spinner", props.className),
|
|
4770
4784
|
children: /* @__PURE__ */ jsxs("g", { strokeWidth: 2, fill: "none", fillRule: "evenodd", children: [
|
|
4771
4785
|
/* @__PURE__ */ jsx("circle", { strokeOpacity: 0.25, cx: 8, cy: 8, r: 7, stroke: "currentColor" }),
|
|
4772
4786
|
/* @__PURE__ */ jsx("path", { strokeLinecap: "round", d: "M15 8c0-4.5-4.5-7-7-7", stroke: "currentColor" })
|
|
@@ -4780,10 +4794,10 @@ var DefaultSvgDefs = () => {
|
|
|
4780
4794
|
return null;
|
|
4781
4795
|
};
|
|
4782
4796
|
function HTMLContainer({ children, className = "", ...rest }) {
|
|
4783
|
-
return /* @__PURE__ */ jsx("div", { ...rest, className:
|
|
4797
|
+
return /* @__PURE__ */ jsx("div", { ...rest, className: classNames2("dr-html-container", className), children });
|
|
4784
4798
|
}
|
|
4785
4799
|
function SVGContainer({ children, className = "", ...rest }) {
|
|
4786
|
-
return /* @__PURE__ */ jsx("svg", { ...rest, className:
|
|
4800
|
+
return /* @__PURE__ */ jsx("svg", { ...rest, className: classNames2("dr-svg-container", className), "aria-hidden": "true", children });
|
|
4787
4801
|
}
|
|
4788
4802
|
function useIdentity(value, isEqual2) {
|
|
4789
4803
|
const ref = useRef(value);
|
|
@@ -5906,6 +5920,7 @@ var sessionStateSnapshotValidator = T.object({
|
|
|
5906
5920
|
isDebugMode: T.boolean.optional(),
|
|
5907
5921
|
isToolLocked: T.boolean.optional(),
|
|
5908
5922
|
isGridMode: T.boolean.optional(),
|
|
5923
|
+
backgroundType: T.literalEnum(...DR_BOARD_BACKGROUND_TYPES).optional(),
|
|
5909
5924
|
pageStates: T.arrayOf(
|
|
5910
5925
|
T.object({
|
|
5911
5926
|
pageId: pageIdValidator,
|
|
@@ -5955,6 +5970,7 @@ function createSessionStateSnapshotSignal(store) {
|
|
|
5955
5970
|
isDebugMode: instanceState.isDebugMode,
|
|
5956
5971
|
isToolLocked: instanceState.isToolLocked,
|
|
5957
5972
|
isGridMode: instanceState.isGridMode,
|
|
5973
|
+
backgroundType: instanceState.backgroundType,
|
|
5958
5974
|
pageStates: allPageIds.map((id) => {
|
|
5959
5975
|
const ps = store.get(InstancePageStateRecordType.createId(id));
|
|
5960
5976
|
const camera = store.get(CameraRecordType.createId(id));
|
|
@@ -5990,6 +6006,7 @@ function loadSessionStateSnapshotIntoStore(store, snapshot, opts) {
|
|
|
5990
6006
|
isFocusMode: primary?.isFocusMode ?? secondary?.isFocusMode,
|
|
5991
6007
|
isToolLocked: primary?.isToolLocked ?? secondary?.isToolLocked,
|
|
5992
6008
|
isGridMode: primary?.isGridMode ?? secondary?.isGridMode,
|
|
6009
|
+
backgroundType: primary?.backgroundType ?? secondary?.backgroundType,
|
|
5993
6010
|
exportBackground: primary?.exportBackground ?? secondary?.exportBackground
|
|
5994
6011
|
});
|
|
5995
6012
|
store.atomic(() => {
|
|
@@ -6037,6 +6054,7 @@ function extractSessionStateFromLegacySnapshot(store) {
|
|
|
6037
6054
|
isDebugMode: !!oldInstance.isDebugMode,
|
|
6038
6055
|
isToolLocked: !!oldInstance.isToolLocked,
|
|
6039
6056
|
isGridMode: false,
|
|
6057
|
+
backgroundType: oldInstance.backgroundType ?? "none",
|
|
6040
6058
|
pageStates: instanceRecords.filter((r) => r.typeName === "instance_page_state" && r.instanceId === oldInstance.id).map((ps) => {
|
|
6041
6059
|
const camera = store[ps.cameraId] ?? { x: 0, y: 0, z: 1 };
|
|
6042
6060
|
return {
|
|
@@ -24430,7 +24448,7 @@ var DrawEditor = memo(function DrawEditor2({
|
|
|
24430
24448
|
ref: setContainer,
|
|
24431
24449
|
"data-tldraw": version,
|
|
24432
24450
|
draggable: false,
|
|
24433
|
-
className:
|
|
24451
|
+
className: classNames2(`${TL_CONTAINER_CLASS} tl-theme__light`, className),
|
|
24434
24452
|
tabIndex: -1,
|
|
24435
24453
|
role: "application",
|
|
24436
24454
|
"aria-label": _options?.branding ?? "tldraw",
|
|
@@ -24842,7 +24860,7 @@ function getFontsFromRichText(editor, richText, initialState2) {
|
|
|
24842
24860
|
// src/index.ts
|
|
24843
24861
|
registerDrawLibraryVersion(
|
|
24844
24862
|
"@ibodr/editor",
|
|
24845
|
-
"0.1.
|
|
24863
|
+
"0.1.10",
|
|
24846
24864
|
"esm"
|
|
24847
24865
|
);
|
|
24848
24866
|
/*!
|