@tldraw/editor 5.7.0-canary.d16cdeb71af9 → 5.7.0-canary.d6509f68e355
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 +6 -1
- package/dist-cjs/index.js +1 -1
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js +91 -29
- package/dist-cjs/lib/components/default-components/DefaultErrorFallback.js.map +2 -2
- package/dist-cjs/lib/editor/Editor.js +18 -5
- package/dist-cjs/lib/editor/Editor.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js +3 -1
- package/dist-cjs/lib/editor/managers/ThemeManager/defaultThemes.js.map +2 -2
- package/dist-cjs/lib/editor/managers/ThemeManager/drawFontCheckbox.js +35 -0
- package/dist-cjs/lib/editor/managers/ThemeManager/drawFontCheckbox.js.map +7 -0
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js +8 -0
- package/dist-cjs/lib/editor/shapes/group/GroupShapeUtil.js.map +2 -2
- package/dist-cjs/lib/editor/types/emit-types.js.map +1 -1
- package/dist-cjs/lib/license/LicenseManager.js +2 -2
- package/dist-cjs/lib/license/LicenseManager.js.map +2 -2
- package/dist-cjs/version.js +3 -3
- package/dist-cjs/version.js.map +1 -1
- package/dist-esm/index.d.mts +6 -1
- package/dist-esm/index.mjs +1 -1
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs +91 -29
- package/dist-esm/lib/components/default-components/DefaultErrorFallback.mjs.map +2 -2
- package/dist-esm/lib/editor/Editor.mjs +18 -5
- package/dist-esm/lib/editor/Editor.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs +3 -1
- package/dist-esm/lib/editor/managers/ThemeManager/defaultThemes.mjs.map +2 -2
- package/dist-esm/lib/editor/managers/ThemeManager/drawFontCheckbox.mjs +15 -0
- package/dist-esm/lib/editor/managers/ThemeManager/drawFontCheckbox.mjs.map +7 -0
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs +8 -0
- package/dist-esm/lib/editor/shapes/group/GroupShapeUtil.mjs.map +2 -2
- package/dist-esm/lib/license/LicenseManager.mjs +2 -2
- package/dist-esm/lib/license/LicenseManager.mjs.map +2 -2
- package/dist-esm/version.mjs +3 -3
- package/dist-esm/version.mjs.map +1 -1
- package/editor.css +266 -58
- package/package.json +7 -7
- package/src/lib/components/default-components/DefaultErrorFallback.tsx +84 -38
- package/src/lib/editor/Editor.ts +16 -5
- package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +2 -0
- package/src/lib/editor/managers/ThemeManager/drawFontCheckbox.ts +18 -0
- package/src/lib/editor/shapes/group/GroupShapeUtil.tsx +10 -0
- package/src/lib/editor/types/emit-types.ts +1 -0
- package/src/lib/license/LicenseManager.test.ts +19 -18
- package/src/lib/license/LicenseManager.ts +5 -5
- package/src/version.ts +3 -3
package/dist-cjs/index.d.ts
CHANGED
|
@@ -1977,7 +1977,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
1977
1977
|
* @public
|
|
1978
1978
|
*/
|
|
1979
1979
|
getCurrentPageShapesInReadingOrder(): TLShape[];
|
|
1980
|
-
|
|
1980
|
+
/* Excluded from this release type: getShapesInReadingOrder */
|
|
1981
1981
|
/**
|
|
1982
1982
|
* Find the nearest adjacent shape in a specific direction.
|
|
1983
1983
|
*
|
|
@@ -4059,6 +4059,7 @@ export declare class Editor extends EventEmitter<TLEventMap> {
|
|
|
4059
4059
|
* @param historyOptions - The history options for the change.
|
|
4060
4060
|
*/
|
|
4061
4061
|
setOpacityForNextShapes(opacity: number, historyOptions?: TLHistoryBatchOptions): this;
|
|
4062
|
+
private getOpacityForNextShape;
|
|
4062
4063
|
/**
|
|
4063
4064
|
* Set the current opacity. This will effect any selected shapes.
|
|
4064
4065
|
*
|
|
@@ -5119,6 +5120,7 @@ export declare class GroupShapeUtil extends ShapeUtil<TLGroupShape> {
|
|
|
5119
5120
|
static type: 'group';
|
|
5120
5121
|
static props: RecordProps<TLGroupShape>;
|
|
5121
5122
|
static migrations: TLPropsMigrations;
|
|
5123
|
+
getShapeName(): string;
|
|
5122
5124
|
hideSelectionBoundsFg(shape: TLGroupShape): boolean;
|
|
5123
5125
|
canFlip(): boolean;
|
|
5124
5126
|
canBind(): boolean;
|
|
@@ -8791,6 +8793,9 @@ export declare interface TLEventMap {
|
|
|
8791
8793
|
name: string;
|
|
8792
8794
|
pageId: TLPageId;
|
|
8793
8795
|
}];
|
|
8796
|
+
'confirm-open-link': [{
|
|
8797
|
+
url: string;
|
|
8798
|
+
}];
|
|
8794
8799
|
change: [HistoryEntry<TLRecord>];
|
|
8795
8800
|
update: [];
|
|
8796
8801
|
crash: [{
|
package/dist-cjs/index.js
CHANGED
|
@@ -398,7 +398,7 @@ var import_uniq = require("./lib/utils/uniq");
|
|
|
398
398
|
var import_defaultThemes2 = require("./lib/editor/managers/ThemeManager/defaultThemes");
|
|
399
399
|
(0, import_utils.registerTldrawLibraryVersion)(
|
|
400
400
|
"@tldraw/editor",
|
|
401
|
-
"5.7.0-canary.
|
|
401
|
+
"5.7.0-canary.d6509f68e355",
|
|
402
402
|
"cjs"
|
|
403
403
|
);
|
|
404
404
|
//# sourceMappingURL=index.js.map
|
|
@@ -63,6 +63,7 @@ const messages = (0, import_TLI18n.defineMessages)({
|
|
|
63
63
|
id: "error.reset-note",
|
|
64
64
|
defaultMessage: "Resetting will erase your current project and any unsaved work."
|
|
65
65
|
},
|
|
66
|
+
// No longer rendered, but still published translation keys that apps may override.
|
|
66
67
|
messageLabel: { id: "error.message-label", defaultMessage: "Message:" },
|
|
67
68
|
stackTraceLabel: { id: "error.stack-trace-label", defaultMessage: "Stack trace:" },
|
|
68
69
|
copy: { id: "error.copy", defaultMessage: "Copy" },
|
|
@@ -97,6 +98,8 @@ function DefaultErrorFallback({ error, editor }) {
|
|
|
97
98
|
}
|
|
98
99
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
99
100
|
const errorStack = error instanceof Error ? error.stack : null;
|
|
101
|
+
const errorDetails = errorStack && !errorStack.includes(errorMessage) ? `${errorMessage}
|
|
102
|
+
${errorStack}` : errorStack ?? errorMessage;
|
|
100
103
|
const isDarkModeFromApp = (0, import_state_react.useValue)(
|
|
101
104
|
"isDarkMode",
|
|
102
105
|
() => {
|
|
@@ -143,7 +146,7 @@ function DefaultErrorFallback({ error, editor }) {
|
|
|
143
146
|
const copyError = () => {
|
|
144
147
|
const doc = (0, import_domUtils.getOwnerDocument)(containerRef.current);
|
|
145
148
|
const textarea = doc.createElement("textarea");
|
|
146
|
-
textarea.value =
|
|
149
|
+
textarea.value = errorDetails;
|
|
147
150
|
doc.body.appendChild(textarea);
|
|
148
151
|
textarea.select();
|
|
149
152
|
doc.execCommand("copy");
|
|
@@ -196,48 +199,87 @@ My browser: ${navigator.userAgent}`
|
|
|
196
199
|
"tl-error-boundary__content__expanded": shouldShowError && !shouldShowResetConfirmation
|
|
197
200
|
}),
|
|
198
201
|
children: shouldShowResetConfirmation ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
199
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: msg(messages.confirmResetTitle) }),
|
|
200
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: msg(messages.confirmResetDescription) }),
|
|
202
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "tl-error-boundary__title", children: msg(messages.confirmResetTitle) }),
|
|
203
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "tl-error-boundary__body", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: msg(messages.confirmResetDescription) }) }),
|
|
201
204
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tl-error-boundary__content__actions", children: [
|
|
202
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("
|
|
203
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
205
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {}),
|
|
206
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tl-error-boundary__content__actions__group", children: [
|
|
207
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
208
|
+
"button",
|
|
209
|
+
{
|
|
210
|
+
className: "tlui-button tl-error-boundary__button",
|
|
211
|
+
onClick: () => setShouldShowResetConfirmation(false),
|
|
212
|
+
children: msg(messages.cancel)
|
|
213
|
+
}
|
|
214
|
+
),
|
|
215
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
216
|
+
"button",
|
|
217
|
+
{
|
|
218
|
+
className: "tlui-button tl-error-boundary__button tl-error-boundary__reset",
|
|
219
|
+
onClick: resetLocalState,
|
|
220
|
+
children: msg(messages.resetData)
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
] })
|
|
204
224
|
] })
|
|
205
225
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
206
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { children: msg(messages.title) }),
|
|
207
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
226
|
-
|
|
226
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "tl-error-boundary__title", children: msg(messages.title) }),
|
|
227
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tl-error-boundary__body", children: [
|
|
228
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
229
|
+
msg(messages.refreshHint),
|
|
230
|
+
" ",
|
|
231
|
+
msg(messages.resetHint),
|
|
232
|
+
" ",
|
|
233
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: msg(messages.noteLabel) }),
|
|
234
|
+
" ",
|
|
235
|
+
msg(messages.resetNote)
|
|
236
|
+
] }),
|
|
237
|
+
process.env.NODE_ENV !== "production" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { children: [
|
|
238
|
+
"If you're developing with the SDK and need help, join us on",
|
|
239
|
+
" ",
|
|
240
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", { href: "https://discord.tldraw.com/?utm_source=sdk&utm_medium=organic&utm_campaign=error-screen", children: "Discord" }),
|
|
241
|
+
"."
|
|
242
|
+
] }),
|
|
243
|
+
shouldShowError && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tl-error-boundary__stack", "data-copied": didCopy, children: [
|
|
244
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { children: errorDetails }) }),
|
|
245
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
246
|
+
"button",
|
|
247
|
+
{
|
|
248
|
+
className: "tlui-button tl-error-boundary__button tl-error-boundary__copy",
|
|
249
|
+
onClick: copyError,
|
|
250
|
+
title: didCopy ? msg(messages.copied) : msg(messages.copy),
|
|
251
|
+
"aria-label": didCopy ? msg(messages.copied) : msg(messages.copy),
|
|
252
|
+
children: didCopy ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CheckIcon, {}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyIcon, {})
|
|
253
|
+
}
|
|
254
|
+
)
|
|
227
255
|
] })
|
|
228
256
|
] }),
|
|
229
257
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tl-error-boundary__content__actions", children: [
|
|
230
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
258
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
259
|
+
"button",
|
|
260
|
+
{
|
|
261
|
+
className: "tlui-button tl-error-boundary__button",
|
|
262
|
+
onClick: () => setShouldShowError(!shouldShowError),
|
|
263
|
+
children: shouldShowError ? msg(messages.hideDetails) : msg(messages.showDetails)
|
|
264
|
+
}
|
|
265
|
+
),
|
|
231
266
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "tl-error-boundary__content__actions__group", children: [
|
|
232
267
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
233
268
|
"button",
|
|
234
269
|
{
|
|
235
|
-
className: "tlui-button tl-error-boundary__reset",
|
|
270
|
+
className: "tlui-button tl-error-boundary__button tl-error-boundary__reset",
|
|
236
271
|
onClick: () => setShouldShowResetConfirmation(true),
|
|
237
272
|
children: msg(messages.resetData)
|
|
238
273
|
}
|
|
239
274
|
),
|
|
240
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
275
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
276
|
+
"button",
|
|
277
|
+
{
|
|
278
|
+
className: "tlui-button tl-error-boundary__button tl-error-boundary__refresh",
|
|
279
|
+
onClick: refresh,
|
|
280
|
+
children: msg(messages.refreshPage)
|
|
281
|
+
}
|
|
282
|
+
)
|
|
241
283
|
] })
|
|
242
284
|
] })
|
|
243
285
|
] })
|
|
@@ -247,4 +289,24 @@ My browser: ${navigator.userAgent}`
|
|
|
247
289
|
}
|
|
248
290
|
);
|
|
249
291
|
}
|
|
292
|
+
function CopyIcon() {
|
|
293
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 30 30", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
294
|
+
"path",
|
|
295
|
+
{
|
|
296
|
+
fillRule: "evenodd",
|
|
297
|
+
clipRule: "evenodd",
|
|
298
|
+
d: "M2 19.0001C2 20.6569 3.34315 22.0001 5 22.0001H8L8 20.0001H5C4.44772 20.0001 4 19.5524 4 19.0001L4 5.00009C4 4.44781 4.44772 4.00009 5 4.00009L19 4.00009C19.5523 4.00009 20 4.44781 20 5.00009V8.00001H11C9.34315 8.00001 8 9.34316 8 11V25C8 26.6569 9.34315 28 11 28H25C26.6569 28 28 26.6569 28 25V11C28 9.34316 26.6569 8.00001 25 8.00001H22V5.00009C22 3.34324 20.6569 2.00009 19 2.00009H5C3.34315 2.00009 2 3.34324 2 5.00009V19.0001ZM10 11C10 10.4477 10.4477 10 11 10H25C25.5523 10 26 10.4477 26 11V25C26 25.5523 25.5523 26 25 26H11C10.4477 26 10 25.5523 10 25V11Z",
|
|
299
|
+
fill: "currentColor"
|
|
300
|
+
}
|
|
301
|
+
) });
|
|
302
|
+
}
|
|
303
|
+
function CheckIcon() {
|
|
304
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 30 30", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
305
|
+
"path",
|
|
306
|
+
{
|
|
307
|
+
d: "M22.9339 7.45369C23.5118 7.83148 23.6739 8.60615 23.2961 9.18396L14.7961 22.184C14.5958 22.4903 14.2712 22.6935 13.9082 22.7398C13.5451 22.7862 13.1799 22.6711 12.909 22.4248L7.40905 17.4248C6.89822 16.9604 6.86058 16.1699 7.32496 15.6591C7.78935 15.1482 8.57991 15.1106 9.09073 15.575L13.506 19.5888L21.2037 7.81584C21.5815 7.23803 22.3561 7.07589 22.9339 7.45369Z",
|
|
308
|
+
fill: "currentColor"
|
|
309
|
+
}
|
|
310
|
+
) });
|
|
311
|
+
}
|
|
250
312
|
//# sourceMappingURL=DefaultErrorFallback.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/components/default-components/DefaultErrorFallback.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useValue } from '@tldraw/state-react'\nimport { noop } from '@tldraw/utils'\nimport classNames from 'classnames'\nimport { ComponentType, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport {\n\tdefineMessages,\n\ttranslateMessage,\n\ttype TLI18nMessage,\n\ttype TLI18nValues,\n} from '../../config/TLI18n'\nimport { Editor } from '../../editor/Editor'\nimport { getOwnerDocument } from '../../exports/domUtils'\nimport { useEditorComponents } from '../../hooks/EditorComponentsContext'\nimport { EditorProvider } from '../../hooks/useEditor'\nimport { getGlobalWindow } from '../../utils/dom'\nimport { hardResetEditor, refreshPage } from '../../utils/runtime'\nimport { ErrorBoundary } from '../ErrorBoundary'\n\nconst BASE_ERROR_URL = 'https://github.com/tldraw/tldraw/issues/new'\n\nconst messages = defineMessages({\n\tconfirmResetTitle: { id: 'error.confirm-reset.title', defaultMessage: 'Are you sure?' },\n\tconfirmResetDescription: {\n\t\tid: 'error.confirm-reset.description',\n\t\tdefaultMessage: 'Resetting your data will delete your drawing and cannot be undone.',\n\t},\n\tcancel: { id: 'error.cancel', defaultMessage: 'Cancel' },\n\tresetData: { id: 'error.reset-data', defaultMessage: 'Reset data' },\n\ttitle: { id: 'error.title', defaultMessage: 'Something went wrong' },\n\trefreshHint: { id: 'error.refresh-hint', defaultMessage: 'Please refresh your browser.' },\n\tresetHint: {\n\t\tid: 'error.reset-hint',\n\t\tdefaultMessage:\n\t\t\t'If the issue continues after refreshing, you may need to reset the tldraw data stored on your device.',\n\t},\n\tnoteLabel: { id: 'error.note-label', defaultMessage: 'Note:' },\n\tresetNote: {\n\t\tid: 'error.reset-note',\n\t\tdefaultMessage: 'Resetting will erase your current project and any unsaved work.',\n\t},\n\tmessageLabel: { id: 'error.message-label', defaultMessage: 'Message:' },\n\tstackTraceLabel: { id: 'error.stack-trace-label', defaultMessage: 'Stack trace:' },\n\tcopy: { id: 'error.copy', defaultMessage: 'Copy' },\n\tcopied: { id: 'error.copied', defaultMessage: 'Copied!' },\n\tshowDetails: { id: 'error.show-details', defaultMessage: 'Show details' },\n\thideDetails: { id: 'error.hide-details', defaultMessage: 'Hide details' },\n\trefreshPage: { id: 'error.refresh-page', defaultMessage: 'Refresh page' },\n})\n\n// This renders because something already threw, so reading the editor is done defensively the way\n// the rest of this component reads it: English beats a second crash on the error screen.\nfunction useErrorMsg(editor: Editor | undefined) {\n\treturn useCallback(\n\t\t(message: TLI18nMessage, values?: TLI18nValues) => {\n\t\t\ttry {\n\t\t\t\treturn translateMessage(editor?.i18n(), message, values)\n\t\t\t} catch {\n\t\t\t\treturn message.defaultMessage\n\t\t\t}\n\t\t},\n\t\t[editor]\n\t)\n}\n\n/** @public */\nexport interface TLErrorFallbackProps {\n\t/** The error that was caught. */\n\terror: unknown\n\t/**\n\t * Only set when the caller renders the fallback with an editor; the editor's own error\n\t * boundaries pass just `error`.\n\t */\n\teditor?: Editor\n}\n\n/** @public */\nexport type TLErrorFallbackComponent = ComponentType<TLErrorFallbackProps>\n\n/** @public @react */\nexport function DefaultErrorFallback({ error, editor }: TLErrorFallbackProps) {\n\tconst msg = useErrorMsg(editor)\n\tconst containerRef = useRef<HTMLDivElement>(null)\n\tconst [shouldShowError, setShouldShowError] = useState(process.env.NODE_ENV === 'development')\n\tconst [didCopy, setDidCopy] = useState(false)\n\tconst [shouldShowResetConfirmation, setShouldShowResetConfirmation] = useState(false)\n\n\tlet Canvas: React.ComponentType | null = null\n\ttry {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst components = useEditorComponents()\n\t\tCanvas = components.Canvas ?? null\n\t} catch {\n\t\t// allow this to fail silently\n\t}\n\n\tconst errorMessage = error instanceof Error ? error.message : String(error)\n\tconst errorStack = error instanceof Error ? error.stack : null\n\n\tconst isDarkModeFromApp = useValue(\n\t\t'isDarkMode',\n\t\t() => {\n\t\t\ttry {\n\t\t\t\tif (editor) {\n\t\t\t\t\treturn editor.user.getIsDarkMode()\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// we're in a funky error state so this might not work for spooky\n\t\t\t\t// reasons. if not, we'll have another attempt later:\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\t[editor]\n\t)\n\tconst [isDarkMode, setIsDarkMode] = useState<null | boolean>(null)\n\tuseLayoutEffect(() => {\n\t\t// if we found a theme class from the app, we can just use that\n\t\tif (isDarkModeFromApp !== null) {\n\t\t\tsetIsDarkMode(isDarkModeFromApp)\n\t\t}\n\n\t\t// do any of our parents have a theme class? if yes then we can just\n\t\t// rely on that and don't need to set our own class\n\t\tlet parent = containerRef.current?.parentElement\n\t\tlet foundParentThemeClass = false\n\t\twhile (parent) {\n\t\t\tif (\n\t\t\t\tparent.classList.contains('tl-theme__dark') ||\n\t\t\t\tparent.classList.contains('tl-theme__light')\n\t\t\t) {\n\t\t\t\tfoundParentThemeClass = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tparent = parent.parentElement\n\t\t}\n\t\tif (foundParentThemeClass) {\n\t\t\tsetIsDarkMode(null)\n\t\t\treturn\n\t\t}\n\n\t\t// if we can't find a theme class from the app or from a parent, we have\n\t\t// to fall back on using a media query:\n\t\tif (typeof window !== 'undefined' && getGlobalWindow().matchMedia) {\n\t\t\tsetIsDarkMode(getGlobalWindow().matchMedia('(prefers-color-scheme: dark)').matches)\n\t\t}\n\t}, [isDarkModeFromApp])\n\n\tuseEffect(() => {\n\t\tif (didCopy) {\n\t\t\tconst timeout = editor?.timers.setTimeout(() => {\n\t\t\t\tsetDidCopy(false)\n\t\t\t}, 2000)\n\t\t\treturn () => clearTimeout(timeout)\n\t\t}\n\t}, [didCopy, editor])\n\n\tconst copyError = () => {\n\t\tconst doc = getOwnerDocument(containerRef.current)\n\t\tconst textarea = doc.createElement('textarea')\n\t\ttextarea.value = errorStack ?? errorMessage\n\t\tdoc.body.appendChild(textarea)\n\t\ttextarea.select()\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tdoc.execCommand('copy')\n\t\ttextarea.remove()\n\t\tsetDidCopy(true)\n\t}\n\n\tconst refresh = () => {\n\t\trefreshPage()\n\t}\n\n\tconst resetLocalState = async () => {\n\t\thardResetEditor()\n\t}\n\n\tconst url = new URL(BASE_ERROR_URL)\n\turl.searchParams.set('title', errorMessage)\n\turl.searchParams.set('labels', `bug`)\n\turl.searchParams.set(\n\t\t'body',\n\t\t`Hey, I ran into an error while using tldraw:\n\n\\`\\`\\`js\n${errorStack ?? errorMessage}\n\\`\\`\\`\n\nMy browser: ${navigator.userAgent}`\n\t)\n\n\treturn (\n\t\t<div\n\t\t\tref={containerRef}\n\t\t\tclassName={classNames(\n\t\t\t\t'tl-container tl-error-boundary',\n\t\t\t\t// error-boundary is sometimes used outside of the theme\n\t\t\t\t// container, so we need to provide it with a theme for our\n\t\t\t\t// styles to work correctly\n\t\t\t\tisDarkMode === null ? '' : isDarkMode ? 'tl-theme__dark' : 'tl-theme__light'\n\t\t\t)}\n\t\t>\n\t\t\t<div className=\"tl-error-boundary__overlay\" />\n\t\t\t{editor && (\n\t\t\t\t// opportunistically attempt to render the canvas to reassure\n\t\t\t\t// the user that their document is still there. there's a good\n\t\t\t\t// chance this won't work (ie the error that we're currently\n\t\t\t\t// notifying the user about originates in the canvas) so it's\n\t\t\t\t// not a big deal if it doesn't work - in that case we just have\n\t\t\t\t// a plain grey background.\n\t\t\t\t<ErrorBoundary onError={noop} fallback={() => null}>\n\t\t\t\t\t<EditorProvider editor={editor}>\n\t\t\t\t\t\t<div className=\"tl-overlay tl-error-boundary__canvas\">{Canvas ? <Canvas /> : null}</div>\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</ErrorBoundary>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tclassName={classNames('tl-modal', 'tl-error-boundary__content', {\n\t\t\t\t\t'tl-error-boundary__content__expanded': shouldShowError && !shouldShowResetConfirmation,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{shouldShowResetConfirmation ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<h2>{msg(messages.confirmResetTitle)}</h2>\n\t\t\t\t\t\t<p>{msg(messages.confirmResetDescription)}</p>\n\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions\">\n\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={() => setShouldShowResetConfirmation(false)}>\n\t\t\t\t\t\t\t\t{msg(messages.cancel)}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<button className=\"tlui-button tl-error-boundary__reset\" onClick={resetLocalState}>\n\t\t\t\t\t\t\t\t{msg(messages.resetData)}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<h2>{msg(messages.title)}</h2>\n\t\t\t\t\t\t<p>{msg(messages.refreshHint)}</p>\n\t\t\t\t\t\t<p>{msg(messages.resetHint)}</p>\n\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t<strong>{msg(messages.noteLabel)}</strong> {msg(messages.resetNote)}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{process.env.NODE_ENV !== 'production' && (\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\tIf you're developing with the SDK and need help, join us on{' '}\n\t\t\t\t\t\t\t\t<a href=\"https://discord.tldraw.com/?utm_source=sdk&utm_medium=organic&utm_campaign=error-screen\">\n\t\t\t\t\t\t\t\t\tDiscord\n\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t.\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t{shouldShowError && (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{msg(messages.messageLabel)}\n\t\t\t\t\t\t\t\t<h4>\n\t\t\t\t\t\t\t\t\t<code>{errorMessage}</code>\n\t\t\t\t\t\t\t\t</h4>\n\t\t\t\t\t\t\t\t{msg(messages.stackTraceLabel)}\n\t\t\t\t\t\t\t\t<div className=\"tl-error-boundary__content__error\">\n\t\t\t\t\t\t\t\t\t<pre>\n\t\t\t\t\t\t\t\t\t\t<code>{errorStack ?? errorMessage}</code>\n\t\t\t\t\t\t\t\t\t</pre>\n\t\t\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={copyError}>\n\t\t\t\t\t\t\t\t\t\t{didCopy ? msg(messages.copied) : msg(messages.copy)}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions\">\n\t\t\t\t\t\t\t<button className=\"tlui-button\" onClick={() => setShouldShowError(!shouldShowError)}>\n\t\t\t\t\t\t\t\t{shouldShowError ? msg(messages.hideDetails) : msg(messages.showDetails)}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions__group\">\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-button tl-error-boundary__reset\"\n\t\t\t\t\t\t\t\t\tonClick={() => setShouldShowResetConfirmation(true)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{msg(messages.resetData)}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<button className=\"tlui-button tl-error-boundary__refresh\" onClick={refresh}>\n\t\t\t\t\t\t\t\t\t{msg(messages.refreshPage)}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { useValue } from '@tldraw/state-react'\nimport { noop } from '@tldraw/utils'\nimport classNames from 'classnames'\nimport { ComponentType, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport {\n\tdefineMessages,\n\ttranslateMessage,\n\ttype TLI18nMessage,\n\ttype TLI18nValues,\n} from '../../config/TLI18n'\nimport { Editor } from '../../editor/Editor'\nimport { getOwnerDocument } from '../../exports/domUtils'\nimport { useEditorComponents } from '../../hooks/EditorComponentsContext'\nimport { EditorProvider } from '../../hooks/useEditor'\nimport { getGlobalWindow } from '../../utils/dom'\nimport { hardResetEditor, refreshPage } from '../../utils/runtime'\nimport { ErrorBoundary } from '../ErrorBoundary'\n\nconst BASE_ERROR_URL = 'https://github.com/tldraw/tldraw/issues/new'\n\nconst messages = defineMessages({\n\tconfirmResetTitle: { id: 'error.confirm-reset.title', defaultMessage: 'Are you sure?' },\n\tconfirmResetDescription: {\n\t\tid: 'error.confirm-reset.description',\n\t\tdefaultMessage: 'Resetting your data will delete your drawing and cannot be undone.',\n\t},\n\tcancel: { id: 'error.cancel', defaultMessage: 'Cancel' },\n\tresetData: { id: 'error.reset-data', defaultMessage: 'Reset data' },\n\ttitle: { id: 'error.title', defaultMessage: 'Something went wrong' },\n\trefreshHint: { id: 'error.refresh-hint', defaultMessage: 'Please refresh your browser.' },\n\tresetHint: {\n\t\tid: 'error.reset-hint',\n\t\tdefaultMessage:\n\t\t\t'If the issue continues after refreshing, you may need to reset the tldraw data stored on your device.',\n\t},\n\tnoteLabel: { id: 'error.note-label', defaultMessage: 'Note:' },\n\tresetNote: {\n\t\tid: 'error.reset-note',\n\t\tdefaultMessage: 'Resetting will erase your current project and any unsaved work.',\n\t},\n\t// No longer rendered, but still published translation keys that apps may override.\n\tmessageLabel: { id: 'error.message-label', defaultMessage: 'Message:' },\n\tstackTraceLabel: { id: 'error.stack-trace-label', defaultMessage: 'Stack trace:' },\n\tcopy: { id: 'error.copy', defaultMessage: 'Copy' },\n\tcopied: { id: 'error.copied', defaultMessage: 'Copied!' },\n\tshowDetails: { id: 'error.show-details', defaultMessage: 'Show details' },\n\thideDetails: { id: 'error.hide-details', defaultMessage: 'Hide details' },\n\trefreshPage: { id: 'error.refresh-page', defaultMessage: 'Refresh page' },\n})\n\n// This renders because something already threw, so reading the editor is done defensively the way\n// the rest of this component reads it: English beats a second crash on the error screen.\nfunction useErrorMsg(editor: Editor | undefined) {\n\treturn useCallback(\n\t\t(message: TLI18nMessage, values?: TLI18nValues) => {\n\t\t\ttry {\n\t\t\t\treturn translateMessage(editor?.i18n(), message, values)\n\t\t\t} catch {\n\t\t\t\treturn message.defaultMessage\n\t\t\t}\n\t\t},\n\t\t[editor]\n\t)\n}\n\n/** @public */\nexport interface TLErrorFallbackProps {\n\t/** The error that was caught. */\n\terror: unknown\n\t/**\n\t * Only set when the caller renders the fallback with an editor; the editor's own error\n\t * boundaries pass just `error`.\n\t */\n\teditor?: Editor\n}\n\n/** @public */\nexport type TLErrorFallbackComponent = ComponentType<TLErrorFallbackProps>\n\n/** @public @react */\nexport function DefaultErrorFallback({ error, editor }: TLErrorFallbackProps) {\n\tconst msg = useErrorMsg(editor)\n\tconst containerRef = useRef<HTMLDivElement>(null)\n\tconst [shouldShowError, setShouldShowError] = useState(process.env.NODE_ENV === 'development')\n\tconst [didCopy, setDidCopy] = useState(false)\n\tconst [shouldShowResetConfirmation, setShouldShowResetConfirmation] = useState(false)\n\n\tlet Canvas: React.ComponentType | null = null\n\ttry {\n\t\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\t\tconst components = useEditorComponents()\n\t\tCanvas = components.Canvas ?? null\n\t} catch {\n\t\t// allow this to fail silently\n\t}\n\n\tconst errorMessage = error instanceof Error ? error.message : String(error)\n\tconst errorStack = error instanceof Error ? error.stack : null\n\t// Chrome's stack starts with the message; Safari and Firefox leave it out.\n\tconst errorDetails =\n\t\terrorStack && !errorStack.includes(errorMessage)\n\t\t\t? `${errorMessage}\\n${errorStack}`\n\t\t\t: (errorStack ?? errorMessage)\n\n\tconst isDarkModeFromApp = useValue(\n\t\t'isDarkMode',\n\t\t() => {\n\t\t\ttry {\n\t\t\t\tif (editor) {\n\t\t\t\t\treturn editor.user.getIsDarkMode()\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\t// we're in a funky error state so this might not work for spooky\n\t\t\t\t// reasons. if not, we'll have another attempt later:\n\t\t\t}\n\t\t\treturn null\n\t\t},\n\t\t[editor]\n\t)\n\tconst [isDarkMode, setIsDarkMode] = useState<null | boolean>(null)\n\tuseLayoutEffect(() => {\n\t\t// if we found a theme class from the app, we can just use that\n\t\tif (isDarkModeFromApp !== null) {\n\t\t\tsetIsDarkMode(isDarkModeFromApp)\n\t\t}\n\n\t\t// do any of our parents have a theme class? if yes then we can just\n\t\t// rely on that and don't need to set our own class\n\t\tlet parent = containerRef.current?.parentElement\n\t\tlet foundParentThemeClass = false\n\t\twhile (parent) {\n\t\t\tif (\n\t\t\t\tparent.classList.contains('tl-theme__dark') ||\n\t\t\t\tparent.classList.contains('tl-theme__light')\n\t\t\t) {\n\t\t\t\tfoundParentThemeClass = true\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tparent = parent.parentElement\n\t\t}\n\t\tif (foundParentThemeClass) {\n\t\t\tsetIsDarkMode(null)\n\t\t\treturn\n\t\t}\n\n\t\t// if we can't find a theme class from the app or from a parent, we have\n\t\t// to fall back on using a media query:\n\t\tif (typeof window !== 'undefined' && getGlobalWindow().matchMedia) {\n\t\t\tsetIsDarkMode(getGlobalWindow().matchMedia('(prefers-color-scheme: dark)').matches)\n\t\t}\n\t}, [isDarkModeFromApp])\n\n\tuseEffect(() => {\n\t\tif (didCopy) {\n\t\t\tconst timeout = editor?.timers.setTimeout(() => {\n\t\t\t\tsetDidCopy(false)\n\t\t\t}, 2000)\n\t\t\treturn () => clearTimeout(timeout)\n\t\t}\n\t}, [didCopy, editor])\n\n\tconst copyError = () => {\n\t\tconst doc = getOwnerDocument(containerRef.current)\n\t\tconst textarea = doc.createElement('textarea')\n\t\ttextarea.value = errorDetails\n\t\tdoc.body.appendChild(textarea)\n\t\ttextarea.select()\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated\n\t\tdoc.execCommand('copy')\n\t\ttextarea.remove()\n\t\tsetDidCopy(true)\n\t}\n\n\tconst refresh = () => {\n\t\trefreshPage()\n\t}\n\n\tconst resetLocalState = async () => {\n\t\thardResetEditor()\n\t}\n\n\tconst url = new URL(BASE_ERROR_URL)\n\turl.searchParams.set('title', errorMessage)\n\turl.searchParams.set('labels', `bug`)\n\turl.searchParams.set(\n\t\t'body',\n\t\t`Hey, I ran into an error while using tldraw:\n\n\\`\\`\\`js\n${errorStack ?? errorMessage}\n\\`\\`\\`\n\nMy browser: ${navigator.userAgent}`\n\t)\n\n\treturn (\n\t\t<div\n\t\t\tref={containerRef}\n\t\t\tclassName={classNames(\n\t\t\t\t'tl-container tl-error-boundary',\n\t\t\t\t// error-boundary is sometimes used outside of the theme\n\t\t\t\t// container, so we need to provide it with a theme for our\n\t\t\t\t// styles to work correctly\n\t\t\t\tisDarkMode === null ? '' : isDarkMode ? 'tl-theme__dark' : 'tl-theme__light'\n\t\t\t)}\n\t\t>\n\t\t\t<div className=\"tl-error-boundary__overlay\" />\n\t\t\t{editor && (\n\t\t\t\t// opportunistically attempt to render the canvas to reassure\n\t\t\t\t// the user that their document is still there. there's a good\n\t\t\t\t// chance this won't work (ie the error that we're currently\n\t\t\t\t// notifying the user about originates in the canvas) so it's\n\t\t\t\t// not a big deal if it doesn't work - in that case we just have\n\t\t\t\t// a plain grey background.\n\t\t\t\t<ErrorBoundary onError={noop} fallback={() => null}>\n\t\t\t\t\t<EditorProvider editor={editor}>\n\t\t\t\t\t\t<div className=\"tl-overlay tl-error-boundary__canvas\">{Canvas ? <Canvas /> : null}</div>\n\t\t\t\t\t</EditorProvider>\n\t\t\t\t</ErrorBoundary>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tclassName={classNames('tl-modal', 'tl-error-boundary__content', {\n\t\t\t\t\t'tl-error-boundary__content__expanded': shouldShowError && !shouldShowResetConfirmation,\n\t\t\t\t})}\n\t\t\t>\n\t\t\t\t{shouldShowResetConfirmation ? (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<h2 className=\"tl-error-boundary__title\">{msg(messages.confirmResetTitle)}</h2>\n\t\t\t\t\t\t<div className=\"tl-error-boundary__body\">\n\t\t\t\t\t\t\t<p>{msg(messages.confirmResetDescription)}</p>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions\">\n\t\t\t\t\t\t\t<div />\n\t\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions__group\">\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-button tl-error-boundary__button\"\n\t\t\t\t\t\t\t\t\tonClick={() => setShouldShowResetConfirmation(false)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{msg(messages.cancel)}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-button tl-error-boundary__button tl-error-boundary__reset\"\n\t\t\t\t\t\t\t\t\tonClick={resetLocalState}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{msg(messages.resetData)}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<h2 className=\"tl-error-boundary__title\">{msg(messages.title)}</h2>\n\t\t\t\t\t\t<div className=\"tl-error-boundary__body\">\n\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t{msg(messages.refreshHint)} {msg(messages.resetHint)}{' '}\n\t\t\t\t\t\t\t\t<strong>{msg(messages.noteLabel)}</strong> {msg(messages.resetNote)}\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t{process.env.NODE_ENV !== 'production' && (\n\t\t\t\t\t\t\t\t<p>\n\t\t\t\t\t\t\t\t\tIf you're developing with the SDK and need help, join us on{' '}\n\t\t\t\t\t\t\t\t\t<a href=\"https://discord.tldraw.com/?utm_source=sdk&utm_medium=organic&utm_campaign=error-screen\">\n\t\t\t\t\t\t\t\t\t\tDiscord\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t\t.\n\t\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t{shouldShowError && (\n\t\t\t\t\t\t\t\t<div className=\"tl-error-boundary__stack\" data-copied={didCopy}>\n\t\t\t\t\t\t\t\t\t<pre>\n\t\t\t\t\t\t\t\t\t\t<code>{errorDetails}</code>\n\t\t\t\t\t\t\t\t\t</pre>\n\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\tclassName=\"tlui-button tl-error-boundary__button tl-error-boundary__copy\"\n\t\t\t\t\t\t\t\t\t\tonClick={copyError}\n\t\t\t\t\t\t\t\t\t\ttitle={didCopy ? msg(messages.copied) : msg(messages.copy)}\n\t\t\t\t\t\t\t\t\t\taria-label={didCopy ? msg(messages.copied) : msg(messages.copy)}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{didCopy ? <CheckIcon /> : <CopyIcon />}\n\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions\">\n\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\tclassName=\"tlui-button tl-error-boundary__button\"\n\t\t\t\t\t\t\t\tonClick={() => setShouldShowError(!shouldShowError)}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{shouldShowError ? msg(messages.hideDetails) : msg(messages.showDetails)}\n\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t<div className=\"tl-error-boundary__content__actions__group\">\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-button tl-error-boundary__button tl-error-boundary__reset\"\n\t\t\t\t\t\t\t\t\tonClick={() => setShouldShowResetConfirmation(true)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{msg(messages.resetData)}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\tclassName=\"tlui-button tl-error-boundary__button tl-error-boundary__refresh\"\n\t\t\t\t\t\t\t\t\tonClick={refresh}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{msg(messages.refreshPage)}\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</>\n\t\t\t\t)}\n\t\t\t</div>\n\t\t</div>\n\t)\n}\n\nfunction CopyIcon() {\n\treturn (\n\t\t<svg width=\"16\" height=\"16\" viewBox=\"0 0 30 30\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\tfillRule=\"evenodd\"\n\t\t\t\tclipRule=\"evenodd\"\n\t\t\t\td=\"M2 19.0001C2 20.6569 3.34315 22.0001 5 22.0001H8L8 20.0001H5C4.44772 20.0001 4 19.5524 4 19.0001L4 5.00009C4 4.44781 4.44772 4.00009 5 4.00009L19 4.00009C19.5523 4.00009 20 4.44781 20 5.00009V8.00001H11C9.34315 8.00001 8 9.34316 8 11V25C8 26.6569 9.34315 28 11 28H25C26.6569 28 28 26.6569 28 25V11C28 9.34316 26.6569 8.00001 25 8.00001H22V5.00009C22 3.34324 20.6569 2.00009 19 2.00009H5C3.34315 2.00009 2 3.34324 2 5.00009V19.0001ZM10 11C10 10.4477 10.4477 10 11 10H25C25.5523 10 26 10.4477 26 11V25C26 25.5523 25.5523 26 25 26H11C10.4477 26 10 25.5523 10 25V11Z\"\n\t\t\t\tfill=\"currentColor\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n\nfunction CheckIcon() {\n\treturn (\n\t\t<svg width=\"16\" height=\"16\" viewBox=\"0 0 30 30\" fill=\"none\" aria-hidden=\"true\">\n\t\t\t<path\n\t\t\t\td=\"M22.9339 7.45369C23.5118 7.83148 23.6739 8.60615 23.2961 9.18396L14.7961 22.184C14.5958 22.4903 14.2712 22.6935 13.9082 22.7398C13.5451 22.7862 13.1799 22.6711 12.909 22.4248L7.40905 17.4248C6.89822 16.9604 6.86058 16.1699 7.32496 15.6591C7.78935 15.1482 8.57991 15.1106 9.09073 15.575L13.506 19.5888L21.2037 7.81584C21.5815 7.23803 22.3561 7.07589 22.9339 7.45369Z\"\n\t\t\t\tfill=\"currentColor\"\n\t\t\t/>\n\t\t</svg>\n\t)\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8MG;AA9MH,yBAAyB;AACzB,mBAAqB;AACrB,wBAAuB;AACvB,mBAAyF;AACzF,oBAKO;AAEP,sBAAiC;AACjC,qCAAoC;AACpC,uBAA+B;AAC/B,iBAAgC;AAChC,qBAA6C;AAC7C,2BAA8B;AAE9B,MAAM,iBAAiB;AAEvB,MAAM,eAAW,8BAAe;AAAA,EAC/B,mBAAmB,EAAE,IAAI,6BAA6B,gBAAgB,gBAAgB;AAAA,EACtF,yBAAyB;AAAA,IACxB,IAAI;AAAA,IACJ,gBAAgB;AAAA,EACjB;AAAA,EACA,QAAQ,EAAE,IAAI,gBAAgB,gBAAgB,SAAS;AAAA,EACvD,WAAW,EAAE,IAAI,oBAAoB,gBAAgB,aAAa;AAAA,EAClE,OAAO,EAAE,IAAI,eAAe,gBAAgB,uBAAuB;AAAA,EACnE,aAAa,EAAE,IAAI,sBAAsB,gBAAgB,+BAA+B;AAAA,EACxF,WAAW;AAAA,IACV,IAAI;AAAA,IACJ,gBACC;AAAA,EACF;AAAA,EACA,WAAW,EAAE,IAAI,oBAAoB,gBAAgB,QAAQ;AAAA,EAC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SAAS,WAAW,IAAI,IAAI,SAAS,WAAW;AAAA;AAAA,gBACxE;AAAA,gBACA,6CAAC,SAAI,WAAU,8CACd;AAAA;AAAA,oBAAC;AAAA;AAAA,sBACA,WAAU;AAAA,sBACV,SAAS,MAAM,+BAA+B,IAAI;AAAA,sBAEjD,cAAI,SAAS,SAAS;AAAA;AAAA,kBACxB;AAAA,kBACA;AAAA,oBAAC;AAAA;AAAA,sBACA,WAAU;AAAA,sBACV,SAAS;AAAA,sBAER,cAAI,SAAS,WAAW;AAAA;AAAA,kBAC1B;AAAA,mBACD;AAAA,iBACD;AAAA,eACD;AAAA;AAAA,QAEF;AAAA;AAAA;AAAA,EACD;AAEF;AAEA,SAAS,WAAW;AACnB,SACC,4CAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA,IAAC;AAAA;AAAA,MACA,UAAS;AAAA,MACT,UAAS;AAAA,MACT,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACN,GACD;AAEF;AAEA,SAAS,YAAY;AACpB,SACC,4CAAC,SAAI,OAAM,MAAK,QAAO,MAAK,SAAQ,aAAY,MAAK,QAAO,eAAY,QACvE;AAAA,IAAC;AAAA;AAAA,MACA,GAAE;AAAA,MACF,MAAK;AAAA;AAAA,EACN,GACD;AAEF;",
|
|
6
6
|
"names": ["classNames"]
|
|
7
7
|
}
|
|
@@ -1627,7 +1627,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
1627
1627
|
const filteredShapes = this.getCurrentPageShapes().filter(
|
|
1628
1628
|
(shape2) => isSelectedWithinContainer ? shape2.parentId === firstParentId : (0, import_tlschema.isPageId)(shape2.parentId)
|
|
1629
1629
|
);
|
|
1630
|
-
const readingOrderShapes = this.
|
|
1630
|
+
const readingOrderShapes = this.getShapesInReadingOrder(filteredShapes);
|
|
1631
1631
|
const currentShapeId = selectedShapeIds.length === 1 ? selectedShapeIds[0] : readingOrderShapes.find((shape2) => selectedShapeIds.includes(shape2.id))?.id;
|
|
1632
1632
|
let adjacentShapeId;
|
|
1633
1633
|
if (direction === "next" || direction === "prev") {
|
|
@@ -1647,9 +1647,16 @@ class Editor extends import_eventemitter3.default {
|
|
|
1647
1647
|
}
|
|
1648
1648
|
getCurrentPageShapesInReadingOrder() {
|
|
1649
1649
|
const shapes = this.getCurrentPageShapes().filter((shape) => (0, import_tlschema.isPageId)(shape.parentId));
|
|
1650
|
-
return this.
|
|
1650
|
+
return this.getShapesInReadingOrder(shapes);
|
|
1651
1651
|
}
|
|
1652
|
-
|
|
1652
|
+
/**
|
|
1653
|
+
* Sort the given shapes into reading order (left-to-right, top-to-bottom), dropping any that
|
|
1654
|
+
* can't be tabbed to. Use this for the children of a frame or group, which
|
|
1655
|
+
* {@link Editor.getCurrentPageShapesInReadingOrder} leaves out.
|
|
1656
|
+
*
|
|
1657
|
+
* @internal
|
|
1658
|
+
*/
|
|
1659
|
+
getShapesInReadingOrder(shapes) {
|
|
1653
1660
|
const SHALLOW_ANGLE = 20;
|
|
1654
1661
|
const ROW_THRESHOLD = 100;
|
|
1655
1662
|
const tabbableShapes = shapes.filter((shape) => this.getShapeUtil(shape).canTabTo(shape));
|
|
@@ -1763,7 +1770,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
1763
1770
|
const children = (0, import_utils.compact)(
|
|
1764
1771
|
this.getSortedChildIdsForParent(selectedShape.id).map((id) => this.getShape(id))
|
|
1765
1772
|
);
|
|
1766
|
-
const sortedChildren = this.
|
|
1773
|
+
const sortedChildren = this.getShapesInReadingOrder(children);
|
|
1767
1774
|
if (sortedChildren.length === 0) return;
|
|
1768
1775
|
this._selectShapesAndZoom([sortedChildren[0].id]);
|
|
1769
1776
|
}
|
|
@@ -6618,7 +6625,7 @@ class Editor extends import_eventemitter3.default {
|
|
|
6618
6625
|
}
|
|
6619
6626
|
if (opacity !== null) return { type: "shared", value: opacity };
|
|
6620
6627
|
}
|
|
6621
|
-
return { type: "shared", value: this.
|
|
6628
|
+
return { type: "shared", value: this.getOpacityForNextShape() };
|
|
6622
6629
|
}
|
|
6623
6630
|
/**
|
|
6624
6631
|
* Set the opacity for the next shapes. This will effect subsequently created shapes.
|
|
@@ -6635,6 +6642,9 @@ class Editor extends import_eventemitter3.default {
|
|
|
6635
6642
|
this.updateInstanceState({ opacityForNextShape: opacity }, historyOptions);
|
|
6636
6643
|
return this;
|
|
6637
6644
|
}
|
|
6645
|
+
getOpacityForNextShape() {
|
|
6646
|
+
return this.getInstanceState().opacityForNextShape;
|
|
6647
|
+
}
|
|
6638
6648
|
/**
|
|
6639
6649
|
* Set the current opacity. This will effect any selected shapes.
|
|
6640
6650
|
*
|
|
@@ -8623,6 +8633,9 @@ __decorateClass([
|
|
|
8623
8633
|
__decorateClass([
|
|
8624
8634
|
import_state.computed
|
|
8625
8635
|
], Editor.prototype, "getSharedOpacity", 1);
|
|
8636
|
+
__decorateClass([
|
|
8637
|
+
import_state.computed
|
|
8638
|
+
], Editor.prototype, "getOpacityForNextShape", 1);
|
|
8626
8639
|
__decorateClass([
|
|
8627
8640
|
import_state.computed
|
|
8628
8641
|
], Editor.prototype, "getIsFocused", 1);
|