@ibodr/editor 0.1.11 → 0.1.13
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 +7 -5
- package/dist/index.mjs +51 -2
- package/dist/index.mjs.map +1 -1
- package/editor.css +12 -5
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -49,7 +49,7 @@ interface DrUserPreferences {
|
|
|
49
49
|
animationSpeed?: number | null;
|
|
50
50
|
areKeyboardShortcutsEnabled?: boolean | null;
|
|
51
51
|
edgeScrollSpeed?: number | null;
|
|
52
|
-
colorScheme?: 'light' | 'dark' | 'system';
|
|
52
|
+
colorScheme?: 'light' | 'dark' | 'system' | 'inherit';
|
|
53
53
|
isSnapMode?: boolean | null;
|
|
54
54
|
isWrapMode?: boolean | null;
|
|
55
55
|
isDynamicSizeMode?: boolean | null;
|
|
@@ -4160,7 +4160,7 @@ declare class UserPreferencesManager {
|
|
|
4160
4160
|
systemColorScheme: _ibodr_state.Atom<"light" | "dark", unknown>;
|
|
4161
4161
|
disposables: Set<() => void>;
|
|
4162
4162
|
dispose(): void;
|
|
4163
|
-
constructor(user: DrCurrentUser, colorScheme: 'light' | 'dark' | 'system');
|
|
4163
|
+
constructor(user: DrCurrentUser, colorScheme: 'light' | 'dark' | 'system' | 'inherit');
|
|
4164
4164
|
updateUserPreferences(userPreferences: Partial<DrUserPreferences>): void;
|
|
4165
4165
|
getUserPreferences(): {
|
|
4166
4166
|
id: string;
|
|
@@ -4170,7 +4170,7 @@ declare class UserPreferencesManager {
|
|
|
4170
4170
|
animationSpeed: number;
|
|
4171
4171
|
areKeyboardShortcutsEnabled: boolean;
|
|
4172
4172
|
isSnapMode: boolean;
|
|
4173
|
-
colorScheme: "light" | "dark" | "system" | undefined;
|
|
4173
|
+
colorScheme: "light" | "dark" | "system" | "inherit" | undefined;
|
|
4174
4174
|
isDarkMode: boolean;
|
|
4175
4175
|
isWrapMode: boolean;
|
|
4176
4176
|
isDynamicResizeMode: boolean;
|
|
@@ -4535,7 +4535,7 @@ interface DrEditorOptions {
|
|
|
4535
4535
|
* - `'dark'` - Always use dark mode.
|
|
4536
4536
|
* - `'system'` - Follow the OS color scheme preference.
|
|
4537
4537
|
*/
|
|
4538
|
-
colorScheme?: 'light' | 'dark' | 'system';
|
|
4538
|
+
colorScheme?: 'light' | 'dark' | 'system' | 'inherit';
|
|
4539
4539
|
/**
|
|
4540
4540
|
* Additional configuration options for the tldraw editor.
|
|
4541
4541
|
*/
|
|
@@ -10003,8 +10003,10 @@ interface DrawEditorBaseProps {
|
|
|
10003
10003
|
* - `'light'` - Always use light mode.
|
|
10004
10004
|
* - `'dark'` - Always use dark mode.
|
|
10005
10005
|
* - `'system'` - Follow the OS color scheme preference.
|
|
10006
|
+
* - `'inherit'` - Follow the nearest ancestor's `data-color-mode` attribute
|
|
10007
|
+
* (for embedding inside a host app that manages its own theme).
|
|
10006
10008
|
*/
|
|
10007
|
-
colorScheme?: 'light' | 'dark' | 'system';
|
|
10009
|
+
colorScheme?: 'light' | 'dark' | 'system' | 'inherit';
|
|
10008
10010
|
/**
|
|
10009
10011
|
* Named themes for the editor.
|
|
10010
10012
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -5043,7 +5043,7 @@ var userTypeValidator = T.object({
|
|
|
5043
5043
|
animationSpeed: T.number.nullable().optional(),
|
|
5044
5044
|
areKeyboardShortcutsEnabled: T.boolean.nullable().optional(),
|
|
5045
5045
|
edgeScrollSpeed: T.number.nullable().optional(),
|
|
5046
|
-
colorScheme: T.literalEnum("light", "dark", "system").optional(),
|
|
5046
|
+
colorScheme: T.literalEnum("light", "dark", "system", "inherit").optional(),
|
|
5047
5047
|
isSnapMode: T.boolean.nullable().optional(),
|
|
5048
5048
|
isWrapMode: T.boolean.nullable().optional(),
|
|
5049
5049
|
isDynamicSizeMode: T.boolean.nullable().optional(),
|
|
@@ -24543,6 +24543,25 @@ var Stadium2d = class extends Geometry2d {
|
|
|
24543
24543
|
return [a, b, c, d].map((p, i) => p.getSvgPathData(i === 0)).join(" ") + " Z";
|
|
24544
24544
|
}
|
|
24545
24545
|
};
|
|
24546
|
+
|
|
24547
|
+
// src/lib/utils/resolveInheritedColorMode.ts
|
|
24548
|
+
function resolveInheritedColorMode(container) {
|
|
24549
|
+
const doc = container.ownerDocument;
|
|
24550
|
+
const candidates = [];
|
|
24551
|
+
let el = container.parentElement;
|
|
24552
|
+
while (el) {
|
|
24553
|
+
candidates.push(el);
|
|
24554
|
+
el = el.parentElement;
|
|
24555
|
+
}
|
|
24556
|
+
if (doc?.documentElement) {
|
|
24557
|
+
candidates.push(doc.documentElement);
|
|
24558
|
+
}
|
|
24559
|
+
for (const node of candidates) {
|
|
24560
|
+
const mode = node.getAttribute("data-color-mode");
|
|
24561
|
+
if (mode === "dark" || mode === "light") return mode;
|
|
24562
|
+
}
|
|
24563
|
+
return null;
|
|
24564
|
+
}
|
|
24546
24565
|
function useDarkMode() {
|
|
24547
24566
|
const editor = useEditor();
|
|
24548
24567
|
const container = useContainer();
|
|
@@ -24858,6 +24877,36 @@ function DrawEditorWithReadyStore({
|
|
|
24858
24877
|
editor.setCurrentTheme(initialTheme);
|
|
24859
24878
|
}
|
|
24860
24879
|
}, [editor, initialTheme]);
|
|
24880
|
+
useLayoutEffect(() => {
|
|
24881
|
+
if (!editor || !colorScheme || colorScheme === "system" || colorScheme === "inherit") return;
|
|
24882
|
+
editor.setColorMode(colorScheme);
|
|
24883
|
+
}, [editor, colorScheme]);
|
|
24884
|
+
useLayoutEffect(() => {
|
|
24885
|
+
if (!editor || colorScheme !== "inherit") return;
|
|
24886
|
+
const container2 = editor.getContainer();
|
|
24887
|
+
const sync = () => {
|
|
24888
|
+
const inherited = resolveInheritedColorMode(container2);
|
|
24889
|
+
if (inherited) {
|
|
24890
|
+
editor.setColorMode(inherited);
|
|
24891
|
+
}
|
|
24892
|
+
};
|
|
24893
|
+
sync();
|
|
24894
|
+
const observer = new MutationObserver(sync);
|
|
24895
|
+
const targets = /* @__PURE__ */ new Set();
|
|
24896
|
+
let el = container2.parentElement;
|
|
24897
|
+
while (el) {
|
|
24898
|
+
targets.add(el);
|
|
24899
|
+
el = el.parentElement;
|
|
24900
|
+
}
|
|
24901
|
+
targets.add(container2.ownerDocument.documentElement);
|
|
24902
|
+
for (const target of targets) {
|
|
24903
|
+
observer.observe(target, {
|
|
24904
|
+
attributes: true,
|
|
24905
|
+
attributeFilter: ["data-color-mode", "class"]
|
|
24906
|
+
});
|
|
24907
|
+
}
|
|
24908
|
+
return () => observer.disconnect();
|
|
24909
|
+
}, [editor, colorScheme]);
|
|
24861
24910
|
const crashingError = useSyncExternalStore(
|
|
24862
24911
|
useCallback(
|
|
24863
24912
|
(onStoreChange) => {
|
|
@@ -25058,7 +25107,7 @@ function getFontsFromRichText(editor, richText, initialState2) {
|
|
|
25058
25107
|
// src/index.ts
|
|
25059
25108
|
registerDrawLibraryVersion(
|
|
25060
25109
|
"@ibodr/editor",
|
|
25061
|
-
"0.1.
|
|
25110
|
+
"0.1.13",
|
|
25062
25111
|
"esm"
|
|
25063
25112
|
);
|
|
25064
25113
|
/*!
|