@tldraw/editor 5.7.0-next.0ef3ff64787a → 5.7.0-next.147eae59044f
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 +5 -8
- 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 +8 -2
- 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/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 +5 -8
- 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 +8 -2
- 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/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 +6 -2
- package/src/lib/editor/managers/ThemeManager/defaultThemes.ts +2 -0
- package/src/lib/editor/managers/ThemeManager/drawFontCheckbox.ts +18 -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
|
@@ -33,6 +33,7 @@ const messages = defineMessages({
|
|
|
33
33
|
id: "error.reset-note",
|
|
34
34
|
defaultMessage: "Resetting will erase your current project and any unsaved work."
|
|
35
35
|
},
|
|
36
|
+
// No longer rendered, but still published translation keys that apps may override.
|
|
36
37
|
messageLabel: { id: "error.message-label", defaultMessage: "Message:" },
|
|
37
38
|
stackTraceLabel: { id: "error.stack-trace-label", defaultMessage: "Stack trace:" },
|
|
38
39
|
copy: { id: "error.copy", defaultMessage: "Copy" },
|
|
@@ -67,6 +68,8 @@ function DefaultErrorFallback({ error, editor }) {
|
|
|
67
68
|
}
|
|
68
69
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
69
70
|
const errorStack = error instanceof Error ? error.stack : null;
|
|
71
|
+
const errorDetails = errorStack && !errorStack.includes(errorMessage) ? `${errorMessage}
|
|
72
|
+
${errorStack}` : errorStack ?? errorMessage;
|
|
70
73
|
const isDarkModeFromApp = useValue(
|
|
71
74
|
"isDarkMode",
|
|
72
75
|
() => {
|
|
@@ -113,7 +116,7 @@ function DefaultErrorFallback({ error, editor }) {
|
|
|
113
116
|
const copyError = () => {
|
|
114
117
|
const doc = getOwnerDocument(containerRef.current);
|
|
115
118
|
const textarea = doc.createElement("textarea");
|
|
116
|
-
textarea.value =
|
|
119
|
+
textarea.value = errorDetails;
|
|
117
120
|
doc.body.appendChild(textarea);
|
|
118
121
|
textarea.select();
|
|
119
122
|
doc.execCommand("copy");
|
|
@@ -166,48 +169,87 @@ My browser: ${navigator.userAgent}`
|
|
|
166
169
|
"tl-error-boundary__content__expanded": shouldShowError && !shouldShowResetConfirmation
|
|
167
170
|
}),
|
|
168
171
|
children: shouldShowResetConfirmation ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
169
|
-
/* @__PURE__ */ jsx("h2", { children: msg(messages.confirmResetTitle) }),
|
|
170
|
-
/* @__PURE__ */ jsx("p", { children: msg(messages.confirmResetDescription) }),
|
|
172
|
+
/* @__PURE__ */ jsx("h2", { className: "tl-error-boundary__title", children: msg(messages.confirmResetTitle) }),
|
|
173
|
+
/* @__PURE__ */ jsx("div", { className: "tl-error-boundary__body", children: /* @__PURE__ */ jsx("p", { children: msg(messages.confirmResetDescription) }) }),
|
|
171
174
|
/* @__PURE__ */ jsxs("div", { className: "tl-error-boundary__content__actions", children: [
|
|
172
|
-
/* @__PURE__ */ jsx("
|
|
173
|
-
/* @__PURE__ */
|
|
175
|
+
/* @__PURE__ */ jsx("div", {}),
|
|
176
|
+
/* @__PURE__ */ jsxs("div", { className: "tl-error-boundary__content__actions__group", children: [
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
"button",
|
|
179
|
+
{
|
|
180
|
+
className: "tlui-button tl-error-boundary__button",
|
|
181
|
+
onClick: () => setShouldShowResetConfirmation(false),
|
|
182
|
+
children: msg(messages.cancel)
|
|
183
|
+
}
|
|
184
|
+
),
|
|
185
|
+
/* @__PURE__ */ jsx(
|
|
186
|
+
"button",
|
|
187
|
+
{
|
|
188
|
+
className: "tlui-button tl-error-boundary__button tl-error-boundary__reset",
|
|
189
|
+
onClick: resetLocalState,
|
|
190
|
+
children: msg(messages.resetData)
|
|
191
|
+
}
|
|
192
|
+
)
|
|
193
|
+
] })
|
|
174
194
|
] })
|
|
175
195
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
176
|
-
/* @__PURE__ */ jsx("h2", { children: msg(messages.title) }),
|
|
177
|
-
/* @__PURE__ */
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
/* @__PURE__ */
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
/* @__PURE__ */ jsx(
|
|
196
|
-
|
|
196
|
+
/* @__PURE__ */ jsx("h2", { className: "tl-error-boundary__title", children: msg(messages.title) }),
|
|
197
|
+
/* @__PURE__ */ jsxs("div", { className: "tl-error-boundary__body", children: [
|
|
198
|
+
/* @__PURE__ */ jsxs("p", { children: [
|
|
199
|
+
msg(messages.refreshHint),
|
|
200
|
+
" ",
|
|
201
|
+
msg(messages.resetHint),
|
|
202
|
+
" ",
|
|
203
|
+
/* @__PURE__ */ jsx("strong", { children: msg(messages.noteLabel) }),
|
|
204
|
+
" ",
|
|
205
|
+
msg(messages.resetNote)
|
|
206
|
+
] }),
|
|
207
|
+
process.env.NODE_ENV !== "production" && /* @__PURE__ */ jsxs("p", { children: [
|
|
208
|
+
"If you're developing with the SDK and need help, join us on",
|
|
209
|
+
" ",
|
|
210
|
+
/* @__PURE__ */ jsx("a", { href: "https://discord.tldraw.com/?utm_source=sdk&utm_medium=organic&utm_campaign=error-screen", children: "Discord" }),
|
|
211
|
+
"."
|
|
212
|
+
] }),
|
|
213
|
+
shouldShowError && /* @__PURE__ */ jsxs("div", { className: "tl-error-boundary__stack", "data-copied": didCopy, children: [
|
|
214
|
+
/* @__PURE__ */ jsx("pre", { children: /* @__PURE__ */ jsx("code", { children: errorDetails }) }),
|
|
215
|
+
/* @__PURE__ */ jsx(
|
|
216
|
+
"button",
|
|
217
|
+
{
|
|
218
|
+
className: "tlui-button tl-error-boundary__button tl-error-boundary__copy",
|
|
219
|
+
onClick: copyError,
|
|
220
|
+
title: didCopy ? msg(messages.copied) : msg(messages.copy),
|
|
221
|
+
"aria-label": didCopy ? msg(messages.copied) : msg(messages.copy),
|
|
222
|
+
children: didCopy ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {})
|
|
223
|
+
}
|
|
224
|
+
)
|
|
197
225
|
] })
|
|
198
226
|
] }),
|
|
199
227
|
/* @__PURE__ */ jsxs("div", { className: "tl-error-boundary__content__actions", children: [
|
|
200
|
-
/* @__PURE__ */ jsx(
|
|
228
|
+
/* @__PURE__ */ jsx(
|
|
229
|
+
"button",
|
|
230
|
+
{
|
|
231
|
+
className: "tlui-button tl-error-boundary__button",
|
|
232
|
+
onClick: () => setShouldShowError(!shouldShowError),
|
|
233
|
+
children: shouldShowError ? msg(messages.hideDetails) : msg(messages.showDetails)
|
|
234
|
+
}
|
|
235
|
+
),
|
|
201
236
|
/* @__PURE__ */ jsxs("div", { className: "tl-error-boundary__content__actions__group", children: [
|
|
202
237
|
/* @__PURE__ */ jsx(
|
|
203
238
|
"button",
|
|
204
239
|
{
|
|
205
|
-
className: "tlui-button tl-error-boundary__reset",
|
|
240
|
+
className: "tlui-button tl-error-boundary__button tl-error-boundary__reset",
|
|
206
241
|
onClick: () => setShouldShowResetConfirmation(true),
|
|
207
242
|
children: msg(messages.resetData)
|
|
208
243
|
}
|
|
209
244
|
),
|
|
210
|
-
/* @__PURE__ */ jsx(
|
|
245
|
+
/* @__PURE__ */ jsx(
|
|
246
|
+
"button",
|
|
247
|
+
{
|
|
248
|
+
className: "tlui-button tl-error-boundary__button tl-error-boundary__refresh",
|
|
249
|
+
onClick: refresh,
|
|
250
|
+
children: msg(messages.refreshPage)
|
|
251
|
+
}
|
|
252
|
+
)
|
|
211
253
|
] })
|
|
212
254
|
] })
|
|
213
255
|
] })
|
|
@@ -217,6 +259,26 @@ My browser: ${navigator.userAgent}`
|
|
|
217
259
|
}
|
|
218
260
|
);
|
|
219
261
|
}
|
|
262
|
+
function CopyIcon() {
|
|
263
|
+
return /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 30 30", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
|
|
264
|
+
"path",
|
|
265
|
+
{
|
|
266
|
+
fillRule: "evenodd",
|
|
267
|
+
clipRule: "evenodd",
|
|
268
|
+
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",
|
|
269
|
+
fill: "currentColor"
|
|
270
|
+
}
|
|
271
|
+
) });
|
|
272
|
+
}
|
|
273
|
+
function CheckIcon() {
|
|
274
|
+
return /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 30 30", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
|
|
275
|
+
"path",
|
|
276
|
+
{
|
|
277
|
+
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",
|
|
278
|
+
fill: "currentColor"
|
|
279
|
+
}
|
|
280
|
+
) });
|
|
281
|
+
}
|
|
220
282
|
export {
|
|
221
283
|
DefaultErrorFallback
|
|
222
284
|
};
|
|
@@ -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": "
|
|
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": "AA8MG,SAoBE,UApBF,KA2BI,YA3BJ;AA9MH,SAAS,gBAAgB;AACzB,SAAS,YAAY;AACrB,OAAO,gBAAgB;AACvB,SAAwB,aAAa,WAAW,iBAAiB,QAAQ,gBAAgB;AACzF;AAAA,EACC;AAAA,EACA;AAAA,OAGM;AAEP,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,iBAAiB,mBAAmB;AAC7C,SAAS,qBAAqB;AAE9B,MAAM,iBAAiB;AAEvB,MAAM,WAAW,eAAe;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,W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AEjD,4BAAkB,IAAI,SAAS,WAAW,IAAI,IAAI,SAAS,WAAW;AAAA;AAAA,gBACxE;AAAA,gBACA,qBAAC,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,oBAAC,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,oBAAC,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": []
|
|
7
7
|
}
|
|
@@ -1696,7 +1696,7 @@ class Editor extends EventEmitter {
|
|
|
1696
1696
|
* can't be tabbed to. Use this for the children of a frame or group, which
|
|
1697
1697
|
* {@link Editor.getCurrentPageShapesInReadingOrder} leaves out.
|
|
1698
1698
|
*
|
|
1699
|
-
* @
|
|
1699
|
+
* @internal
|
|
1700
1700
|
*/
|
|
1701
1701
|
getShapesInReadingOrder(shapes) {
|
|
1702
1702
|
const SHALLOW_ANGLE = 20;
|
|
@@ -6667,7 +6667,7 @@ class Editor extends EventEmitter {
|
|
|
6667
6667
|
}
|
|
6668
6668
|
if (opacity !== null) return { type: "shared", value: opacity };
|
|
6669
6669
|
}
|
|
6670
|
-
return { type: "shared", value: this.
|
|
6670
|
+
return { type: "shared", value: this.getOpacityForNextShape() };
|
|
6671
6671
|
}
|
|
6672
6672
|
/**
|
|
6673
6673
|
* Set the opacity for the next shapes. This will effect subsequently created shapes.
|
|
@@ -6684,6 +6684,9 @@ class Editor extends EventEmitter {
|
|
|
6684
6684
|
this.updateInstanceState({ opacityForNextShape: opacity }, historyOptions);
|
|
6685
6685
|
return this;
|
|
6686
6686
|
}
|
|
6687
|
+
getOpacityForNextShape() {
|
|
6688
|
+
return this.getInstanceState().opacityForNextShape;
|
|
6689
|
+
}
|
|
6687
6690
|
/**
|
|
6688
6691
|
* Set the current opacity. This will effect any selected shapes.
|
|
6689
6692
|
*
|
|
@@ -8672,6 +8675,9 @@ __decorateClass([
|
|
|
8672
8675
|
__decorateClass([
|
|
8673
8676
|
computed
|
|
8674
8677
|
], Editor.prototype, "getSharedOpacity", 1);
|
|
8678
|
+
__decorateClass([
|
|
8679
|
+
computed
|
|
8680
|
+
], Editor.prototype, "getOpacityForNextShape", 1);
|
|
8675
8681
|
__decorateClass([
|
|
8676
8682
|
computed
|
|
8677
8683
|
], Editor.prototype, "getIsFocused", 1);
|