@poveste/app 0.1.3 → 0.2.0
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/app/style/floating.pcss +4 -4
- package/dist/app/style/main.pcss +2 -2
- package/dist/app/style/sandbox.css +1 -1
- package/dist/bundle-main.js +2 -0
- package/dist/bundled/App.vue2.js +81 -37
- package/dist/bundled/app.css +51 -46
- package/dist/bundled/components/HomeView.vue2.js +3 -3
- package/dist/bundled/components/app/AppActions.vue.js +5 -0
- package/dist/bundled/components/app/AppActions.vue2.js +76 -0
- package/dist/bundled/components/app/AppHeader.vue2.js +5 -47
- package/dist/bundled/components/app/Breadcrumb.vue.js +1 -1
- package/dist/bundled/components/app/Breadcrumb.vue2.js +9 -9
- package/dist/bundled/components/app/HomeCounter.vue2.js +5 -5
- package/dist/bundled/components/app/InitialLoading.vue2.js +5 -5
- package/dist/bundled/components/app/MobileOverlay.vue2.js +5 -5
- package/dist/bundled/components/app/TopBar.vue.js +5 -0
- package/dist/bundled/components/app/TopBar.vue2.js +73 -0
- package/dist/bundled/components/app/TopBarChip.vue.js +13 -0
- package/dist/bundled/components/app/TopBarChipItem.vue.js +13 -0
- package/dist/bundled/components/base/BaseButton.vue2.js +3 -3
- package/dist/bundled/components/base/BaseCheckbox.vue2.js +8 -8
- package/dist/bundled/components/base/BaseEmpty.vue.js +2 -2
- package/dist/bundled/components/base/BaseKeyboardShortcut.vue2.js +1 -1
- package/dist/bundled/components/base/BaseListItem.vue2.js +2 -2
- package/dist/bundled/components/base/BaseListItemLink.vue.js +2 -2
- package/dist/bundled/components/base/BaseOverflowMenu.vue2.js +4 -4
- package/dist/bundled/components/base/BaseOverflowTab.vue.js +3 -3
- package/dist/bundled/components/base/BaseSelect.vue2.js +6 -6
- package/dist/bundled/components/base/BaseSplitPane.vue.js +1 -1
- package/dist/bundled/components/base/BaseSplitPane.vue2.js +20 -16
- package/dist/bundled/components/base/BaseTab.vue.js +3 -3
- package/dist/bundled/components/base/BaseTag.vue.js +1 -1
- package/dist/bundled/components/command/CommandPrompts.vue2.js +5 -5
- package/dist/bundled/components/command/CommandPromptsModal.vue2.js +3 -3
- package/dist/bundled/components/command/PromptSelect.vue2.js +12 -12
- package/dist/bundled/components/command/PromptText.vue2.js +4 -4
- package/dist/bundled/components/layout/LayoutItem.vue.js +5 -0
- package/dist/bundled/components/layout/LayoutItem.vue2.js +44 -0
- package/dist/bundled/components/layout/LayoutItemGroup.vue.js +5 -0
- package/dist/bundled/components/layout/LayoutItemGroup.vue2.js +25 -0
- package/dist/bundled/components/layout/LayoutModal.vue.js +5 -0
- package/dist/bundled/components/layout/LayoutModal.vue2.js +68 -0
- package/dist/bundled/components/layout/LayoutPane.vue.js +5 -0
- package/dist/bundled/components/layout/LayoutPane.vue2.js +59 -0
- package/dist/bundled/components/panel/ControlsComponentPropItem.vue2.js +2 -2
- package/dist/bundled/components/panel/ControlsComponentProps.vue2.js +4 -4
- package/dist/bundled/components/panel/ControlsComponentState.vue2.js +2 -2
- package/dist/bundled/components/panel/PaneTabs.vue2.js +4 -4
- package/dist/bundled/components/panel/StatePresets.vue2.js +13 -13
- package/dist/bundled/components/panel/StoryControls.vue2.js +6 -6
- package/dist/bundled/components/panel/StoryDocs.vue2.js +4 -4
- package/dist/bundled/components/panel/StoryEvent.vue2.js +7 -7
- package/dist/bundled/components/panel/StoryEvents.vue2.js +1 -1
- package/dist/bundled/components/panel/StorySidePanel.vue2.js +58 -47
- package/dist/bundled/components/panel/StorySourceCode.vue.js +1 -1
- package/dist/bundled/components/panel/StorySourceCode.vue2.js +19 -19
- package/dist/bundled/components/search/SearchItem.vue.js +1 -1
- package/dist/bundled/components/search/SearchItem.vue2.js +3 -3
- package/dist/bundled/components/search/SearchItemContent.vue2.js +9 -9
- package/dist/bundled/components/search/SearchLoading.vue2.js +2 -2
- package/dist/bundled/components/search/SearchModal.vue2.js +3 -3
- package/dist/bundled/components/search/SearchPane.vue2.js +4 -4
- package/dist/bundled/components/story/StoryResponsivePreview.vue.js +1 -1
- package/dist/bundled/components/story/StoryResponsivePreview.vue2.js +21 -21
- package/dist/bundled/components/story/StoryVariantGrid.vue2.js +7 -26
- package/dist/bundled/components/story/StoryVariantGridItem.vue.js +1 -1
- package/dist/bundled/components/story/StoryVariantGridItem.vue2.js +36 -21
- package/dist/bundled/components/story/StoryVariantListItem.vue.js +1 -1
- package/dist/bundled/components/story/StoryVariantListItem.vue2.js +5 -5
- package/dist/bundled/components/story/StoryVariantSingle.vue.js +1 -1
- package/dist/bundled/components/story/StoryVariantSingle.vue2.js +10 -10
- package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue2.js +6 -5
- package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue2.js +33 -8
- package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +8 -39
- package/dist/bundled/components/story/StoryView.vue2.js +21 -11
- package/dist/bundled/components/story/StoryViewer.vue.js +1 -1
- package/dist/bundled/components/story/StoryViewer.vue2.js +2 -2
- package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue2.js +13 -9
- package/dist/bundled/components/toolbar/ToolbarBackground.vue.js +1 -1
- package/dist/bundled/components/toolbar/ToolbarBackground.vue2.js +62 -33
- package/dist/bundled/components/toolbar/ToolbarNewTab.vue2.js +13 -10
- package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue2.js +14 -14
- package/dist/bundled/components/toolbar/ToolbarTextDirection.vue2.js +13 -9
- package/dist/bundled/components/toolbar/ToolbarTitle.vue.js +4 -1
- package/dist/bundled/components/toolbar/ToolbarTitle.vue2.js +30 -7
- package/dist/bundled/components/tree/StoryGroup.vue2.js +5 -5
- package/dist/bundled/components/tree/StoryList.vue2.js +1 -1
- package/dist/bundled/components/tree/StoryListFolder.vue.js +1 -1
- package/dist/bundled/components/tree/StoryListFolder.vue2.js +7 -7
- package/dist/bundled/components/tree/StoryListItem.vue.js +1 -1
- package/dist/bundled/components/tree/StoryListItem.vue2.js +8 -8
- package/dist/bundled/index.js +3 -0
- package/dist/bundled/sandbox.js +41 -15
- package/dist/bundled/stores/layout.js +16 -0
- package/dist/bundled/stores/preview-settings.js +19 -4
- package/dist/bundled/util/color-scheme.js +27 -0
- package/dist/bundled/util/const.js +2 -0
- package/dist/bundled/util/dark.js +3 -3
- package/dist/bundled/util/keyboard.js +60 -32
- package/dist/bundled/util/preview-settings.js +11 -0
- package/dist/bundled/util/tooltip.js +2 -2
- package/dist/style.css +644 -529
- package/package.json +8 -8
- package/src/app/App.vue +109 -66
- package/src/app/components/HomeView.vue +3 -3
- package/src/app/components/app/AppActions.vue +58 -0
- package/src/app/components/app/AppHeader.vue +4 -47
- package/src/app/components/app/Breadcrumb.vue +8 -8
- package/src/app/components/app/HomeCounter.vue +5 -5
- package/src/app/components/app/InitialLoading.vue +5 -5
- package/src/app/components/app/MobileOverlay.vue +5 -5
- package/src/app/components/app/TopBar.vue +60 -0
- package/src/app/components/app/TopBarChip.vue +5 -0
- package/src/app/components/app/TopBarChipItem.vue +7 -0
- package/src/app/components/base/BaseButton.vue +3 -3
- package/src/app/components/base/BaseCheckbox.vue +9 -9
- package/src/app/components/base/BaseCopyIcon.vue +1 -1
- package/src/app/components/base/BaseEmpty.vue +4 -4
- package/src/app/components/base/BaseKeyboardShortcut.vue +1 -1
- package/src/app/components/base/BaseListItem.vue +3 -3
- package/src/app/components/base/BaseListItemLink.vue +3 -3
- package/src/app/components/base/BaseOverflowMenu.vue +4 -4
- package/src/app/components/base/BaseOverflowTab.vue +3 -3
- package/src/app/components/base/BaseSelect.vue +6 -6
- package/src/app/components/base/BaseSplitPane.vue +21 -16
- package/src/app/components/base/BaseTab.vue +3 -3
- package/src/app/components/base/BaseTag.vue +1 -1
- package/src/app/components/command/CommandPrompts.vue +5 -5
- package/src/app/components/command/CommandPromptsModal.vue +3 -3
- package/src/app/components/command/PromptSelect.vue +14 -14
- package/src/app/components/command/PromptText.vue +4 -4
- package/src/app/components/layout/LayoutItem.vue +36 -0
- package/src/app/components/layout/LayoutItemGroup.vue +18 -0
- package/src/app/components/layout/LayoutModal.vue +60 -0
- package/src/app/components/layout/LayoutPane.vue +45 -0
- package/src/app/components/panel/ControlsComponentPropItem.vue +2 -2
- package/src/app/components/panel/ControlsComponentProps.vue +3 -3
- package/src/app/components/panel/ControlsComponentState.vue +2 -2
- package/src/app/components/panel/PaneTabs.vue +4 -4
- package/src/app/components/panel/StatePresets.vue +13 -13
- package/src/app/components/panel/StoryControls.vue +6 -6
- package/src/app/components/panel/StoryDocs.vue +4 -4
- package/src/app/components/panel/StoryEvent.vue +7 -7
- package/src/app/components/panel/StoryEvents.vue +1 -1
- package/src/app/components/panel/StorySidePanel.vue +51 -41
- package/src/app/components/panel/StorySourceCode.vue +19 -19
- package/src/app/components/search/SearchItem.vue +2 -2
- package/src/app/components/search/SearchItemContent.vue +9 -9
- package/src/app/components/search/SearchLoading.vue +2 -2
- package/src/app/components/search/SearchModal.vue +3 -3
- package/src/app/components/search/SearchPane.vue +4 -4
- package/src/app/components/story/StoryResponsivePreview.vue +27 -27
- package/src/app/components/story/StoryVariantGrid.vue +5 -24
- package/src/app/components/story/StoryVariantGridItem.vue +36 -17
- package/src/app/components/story/StoryVariantListItem.vue +4 -4
- package/src/app/components/story/StoryVariantSingle.vue +9 -9
- package/src/app/components/story/StoryVariantSinglePreviewNative.vue +7 -5
- package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +37 -7
- package/src/app/components/story/StoryVariantSingleView.vue +1 -34
- package/src/app/components/story/StoryView.vue +23 -8
- package/src/app/components/story/StoryViewer.vue +1 -1
- package/src/app/components/toolbar/DevOnlyToolbarOpenInEditor.vue +5 -4
- package/src/app/components/toolbar/ToolbarBackground.vue +62 -25
- package/src/app/components/toolbar/ToolbarNewTab.vue +5 -4
- package/src/app/components/toolbar/ToolbarResponsiveSize.vue +15 -15
- package/src/app/components/toolbar/ToolbarTextDirection.vue +5 -4
- package/src/app/components/toolbar/ToolbarTitle.vue +32 -8
- package/src/app/components/tree/StoryGroup.vue +5 -5
- package/src/app/components/tree/StoryList.vue +1 -1
- package/src/app/components/tree/StoryListFolder.vue +6 -6
- package/src/app/components/tree/StoryListItem.vue +6 -6
- package/src/app/index.ts +3 -0
- package/src/app/sandbox.ts +59 -15
- package/src/app/stores/layout.ts +22 -0
- package/src/app/stores/preview-settings.ts +26 -2
- package/src/app/style/floating.pcss +4 -4
- package/src/app/style/main.pcss +2 -2
- package/src/app/style/sandbox.css +1 -1
- package/src/app/types.ts +49 -0
- package/src/app/util/color-scheme.ts +36 -0
- package/src/app/util/const.ts +1 -0
- package/src/app/util/dark.ts +3 -3
- package/src/app/util/keyboard.ts +65 -32
- package/src/app/util/preview-settings.ts +16 -0
- package/src/app/util/tooltip.ts +2 -2
- package/src/bundle-main.js +2 -0
- package/src/shim.d.ts +2 -2
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useStorage } from "@poveste/vendors/vue-use";
|
|
2
|
+
import { defineStore } from "@poveste/vendors/pinia";
|
|
3
|
+
"use strict";
|
|
4
|
+
const useLayoutStore = defineStore("layout", () => {
|
|
5
|
+
const settings = useStorage("_poveste-layout-v1", {
|
|
6
|
+
storyListVisible: true,
|
|
7
|
+
storyOptionsVisible: true,
|
|
8
|
+
storyOptionsPlacement: "right"
|
|
9
|
+
});
|
|
10
|
+
return {
|
|
11
|
+
settings
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
export {
|
|
15
|
+
useLayoutStore
|
|
16
|
+
};
|
|
@@ -1,17 +1,32 @@
|
|
|
1
1
|
import { useStorage } from "@poveste/vendors/vue-use";
|
|
2
2
|
import { defineStore } from "@poveste/vendors/pinia";
|
|
3
|
+
import { defaultPreviewColorScheme } from "../util/color-scheme.js";
|
|
4
|
+
import { povesteConfig } from "../util/config.js";
|
|
5
|
+
import { PREVIEW_SETTINGS_STORAGE_KEY } from "../util/preview-settings.js";
|
|
3
6
|
"use strict";
|
|
4
7
|
const usePreviewSettingsStore = defineStore("preview-settings", () => {
|
|
5
|
-
const currentSettings = useStorage(
|
|
8
|
+
const currentSettings = useStorage(PREVIEW_SETTINGS_STORAGE_KEY, {
|
|
6
9
|
responsiveWidth: 720,
|
|
7
10
|
responsiveHeight: null,
|
|
8
11
|
rotate: false,
|
|
9
|
-
backgroundColor: "transparent",
|
|
12
|
+
backgroundColor: povesteConfig.defaultBackgroundColor ?? "transparent",
|
|
13
|
+
backgroundColorPicked: false,
|
|
10
14
|
checkerboard: false,
|
|
11
|
-
textDirection: "ltr"
|
|
15
|
+
textDirection: "ltr",
|
|
16
|
+
colorScheme: defaultPreviewColorScheme
|
|
12
17
|
});
|
|
18
|
+
const configBg = povesteConfig.defaultBackgroundColor;
|
|
19
|
+
if (configBg && !currentSettings.value.backgroundColorPicked) {
|
|
20
|
+
currentSettings.value.backgroundColor = configBg;
|
|
21
|
+
}
|
|
22
|
+
currentSettings.value.colorScheme ??= defaultPreviewColorScheme;
|
|
23
|
+
function setBackgroundColor(color) {
|
|
24
|
+
currentSettings.value.backgroundColor = color;
|
|
25
|
+
currentSettings.value.backgroundColorPicked = true;
|
|
26
|
+
}
|
|
13
27
|
return {
|
|
14
|
-
currentSettings
|
|
28
|
+
currentSettings,
|
|
29
|
+
setBackgroundColor
|
|
15
30
|
};
|
|
16
31
|
});
|
|
17
32
|
export {
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { usePreferredDark } from "@poveste/vendors/vue-use";
|
|
2
|
+
import { computed } from "@poveste/vendors/vue";
|
|
3
|
+
import { povesteConfig } from "./config.js";
|
|
4
|
+
import { isDark } from "./dark.js";
|
|
5
|
+
"use strict";
|
|
6
|
+
const defaultPreviewColorScheme = povesteConfig.theme.defaultColorScheme ?? "auto";
|
|
7
|
+
function resolvePreviewDark(colorScheme, prefersDark, chromeDark) {
|
|
8
|
+
switch (colorScheme) {
|
|
9
|
+
case "light":
|
|
10
|
+
return false;
|
|
11
|
+
case "dark":
|
|
12
|
+
return true;
|
|
13
|
+
case "auto":
|
|
14
|
+
return prefersDark;
|
|
15
|
+
default:
|
|
16
|
+
return chromeDark;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function usePreviewDark(settings) {
|
|
20
|
+
const prefersDark = usePreferredDark();
|
|
21
|
+
return computed(() => resolvePreviewDark(settings.colorScheme, prefersDark.value, isDark.value));
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
defaultPreviewColorScheme,
|
|
25
|
+
resolvePreviewDark,
|
|
26
|
+
usePreviewDark
|
|
27
|
+
};
|
|
@@ -2,9 +2,11 @@ const STATE_SYNC = "__poveste:state-sync";
|
|
|
2
2
|
const SANDBOX_READY = "__poveste:sandbox-ready";
|
|
3
3
|
const EVENT_SEND = "__poveste:event";
|
|
4
4
|
const PREVIEW_SETTINGS_SYNC = "__poveste:preview-settings-sync";
|
|
5
|
+
const SANDBOX_HEIGHT = "__poveste:sandbox-height";
|
|
5
6
|
export {
|
|
6
7
|
EVENT_SEND,
|
|
7
8
|
PREVIEW_SETTINGS_SYNC,
|
|
9
|
+
SANDBOX_HEIGHT,
|
|
8
10
|
SANDBOX_READY,
|
|
9
11
|
STATE_SYNC
|
|
10
12
|
};
|
|
@@ -3,14 +3,14 @@ import { watch } from "@poveste/vendors/vue";
|
|
|
3
3
|
import { povesteConfig } from "./config.js";
|
|
4
4
|
"use strict";
|
|
5
5
|
const isDark = useDark({
|
|
6
|
-
valueDark: "
|
|
6
|
+
valueDark: "ptw-dark",
|
|
7
7
|
initialValue: povesteConfig.theme.defaultColorScheme,
|
|
8
8
|
storageKey: "poveste-color-scheme",
|
|
9
9
|
storage: povesteConfig.theme.storeColorScheme ? localStorage : sessionStorage
|
|
10
10
|
});
|
|
11
11
|
const toggleDark = useToggle(isDark);
|
|
12
12
|
function applyDarkToControls() {
|
|
13
|
-
window.
|
|
13
|
+
window.__pvt_controls_dark?.forEach((ref) => {
|
|
14
14
|
ref.value = isDark.value;
|
|
15
15
|
});
|
|
16
16
|
}
|
|
@@ -19,7 +19,7 @@ watch(isDark, () => {
|
|
|
19
19
|
}, {
|
|
20
20
|
immediate: true
|
|
21
21
|
});
|
|
22
|
-
window.
|
|
22
|
+
window.__pvt_controls_dark_ready = () => {
|
|
23
23
|
applyDarkToControls();
|
|
24
24
|
};
|
|
25
25
|
export {
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import { useEventListener } from "@poveste/vendors/vue-use";
|
|
2
|
-
import { isRef } from "@poveste/vendors/vue";
|
|
2
|
+
import { shallowRef, isRef } from "@poveste/vendors/vue";
|
|
3
3
|
import { isMac } from "./env.js";
|
|
4
4
|
"use strict";
|
|
5
|
-
function onKeyboardShortcut(shortcut, handler, options = {}) {
|
|
6
|
-
useEventListener(options.event ?? "keydown", (event) => {
|
|
7
|
-
if (isMatchingShortcut(isRef(shortcut) ? shortcut.value : shortcut)) {
|
|
8
|
-
handler(event);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
5
|
const modifiers = {
|
|
13
6
|
ctrl: { key: "Control", pressed: false },
|
|
14
7
|
alt: { key: "Alt", pressed: false },
|
|
@@ -16,35 +9,69 @@ const modifiers = {
|
|
|
16
9
|
meta: { key: "Meta", pressed: false }
|
|
17
10
|
};
|
|
18
11
|
const pressedKeys = /* @__PURE__ */ new Set();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (mod.key === event.key) {
|
|
23
|
-
mod.pressed = true;
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
pressedKeys.add(event.key.toLocaleLowerCase());
|
|
28
|
-
});
|
|
29
|
-
window.addEventListener("keyup", (event) => {
|
|
30
|
-
requestAnimationFrame(() => {
|
|
31
|
-
pressedKeys.clear();
|
|
12
|
+
const trackedWindows = shallowRef([]);
|
|
13
|
+
function bindTracking(target) {
|
|
14
|
+
const onKeydown = (event) => {
|
|
32
15
|
for (const i in modifiers) {
|
|
33
16
|
const mod = modifiers[i];
|
|
34
17
|
if (mod.key === event.key) {
|
|
35
|
-
mod.pressed =
|
|
36
|
-
|
|
18
|
+
mod.pressed = true;
|
|
19
|
+
return;
|
|
37
20
|
}
|
|
38
21
|
}
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
22
|
+
pressedKeys.add(event.key.toLocaleLowerCase());
|
|
23
|
+
};
|
|
24
|
+
const onKeyup = (event) => {
|
|
25
|
+
requestAnimationFrame(() => {
|
|
26
|
+
pressedKeys.clear();
|
|
27
|
+
for (const i in modifiers) {
|
|
28
|
+
const mod = modifiers[i];
|
|
29
|
+
if (mod.key === event.key) {
|
|
30
|
+
mod.pressed = false;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const onBlur = () => {
|
|
37
|
+
pressedKeys.clear();
|
|
38
|
+
for (const i in modifiers) {
|
|
39
|
+
modifiers[i].pressed = false;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
target.addEventListener("keydown", onKeydown);
|
|
43
|
+
target.addEventListener("keyup", onKeyup);
|
|
44
|
+
target.addEventListener("blur", onBlur);
|
|
45
|
+
return () => {
|
|
46
|
+
target.removeEventListener("keydown", onKeydown);
|
|
47
|
+
target.removeEventListener("keyup", onKeyup);
|
|
48
|
+
target.removeEventListener("blur", onBlur);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function trackWindow(target) {
|
|
52
|
+
if (trackedWindows.value.includes(target)) {
|
|
53
|
+
return () => {
|
|
54
|
+
};
|
|
46
55
|
}
|
|
47
|
-
|
|
56
|
+
const cleanup = bindTracking(target);
|
|
57
|
+
trackedWindows.value = [...trackedWindows.value, target];
|
|
58
|
+
return () => {
|
|
59
|
+
cleanup();
|
|
60
|
+
trackedWindows.value = trackedWindows.value.filter((w) => w !== target);
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
trackWindow(window);
|
|
64
|
+
function onKeyboardShortcut(shortcut, handler, options = {}) {
|
|
65
|
+
useEventListener(trackedWindows, options.event ?? "keydown", (event) => {
|
|
66
|
+
modifiers.ctrl.pressed = event.ctrlKey;
|
|
67
|
+
modifiers.alt.pressed = event.altKey;
|
|
68
|
+
modifiers.shift.pressed = event.shiftKey;
|
|
69
|
+
modifiers.meta.pressed = event.metaKey;
|
|
70
|
+
if (isMatchingShortcut(isRef(shortcut) ? shortcut.value : shortcut)) {
|
|
71
|
+
handler(event);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
}
|
|
48
75
|
function isMatchingShortcut(shortcut) {
|
|
49
76
|
for (const combination of shortcut) {
|
|
50
77
|
if (isMatchingCombination(combination.toLowerCase())) {
|
|
@@ -86,5 +113,6 @@ function formatKey(key) {
|
|
|
86
113
|
}
|
|
87
114
|
export {
|
|
88
115
|
formatKey,
|
|
89
|
-
onKeyboardShortcut
|
|
116
|
+
onKeyboardShortcut,
|
|
117
|
+
trackWindow
|
|
90
118
|
};
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
import { reactive } from "@poveste/vendors/vue";
|
|
2
2
|
import { povesteConfig } from "./config.js";
|
|
3
3
|
"use strict";
|
|
4
|
+
const PREVIEW_SETTINGS_STORAGE_KEY = "_poveste-sandbox-settings-v3";
|
|
4
5
|
const receivedSettings = reactive({});
|
|
6
|
+
function loadStoredPreviewSettings() {
|
|
7
|
+
try {
|
|
8
|
+
const raw = localStorage.getItem(PREVIEW_SETTINGS_STORAGE_KEY);
|
|
9
|
+
return raw ? JSON.parse(raw) : null;
|
|
10
|
+
} catch {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
5
14
|
function applyPreviewSettings(settings) {
|
|
6
15
|
Object.assign(receivedSettings, settings);
|
|
7
16
|
document.documentElement.setAttribute("dir", settings.textDirection);
|
|
@@ -16,7 +25,9 @@ function getContrastColor(setting) {
|
|
|
16
25
|
return povesteConfig.backgroundPresets.find((preset) => preset.color === setting.backgroundColor)?.contrastColor ?? "unset";
|
|
17
26
|
}
|
|
18
27
|
export {
|
|
28
|
+
PREVIEW_SETTINGS_STORAGE_KEY,
|
|
19
29
|
applyPreviewSettings,
|
|
20
30
|
getContrastColor,
|
|
31
|
+
loadStoredPreviewSettings,
|
|
21
32
|
receivedSettings
|
|
22
33
|
};
|
|
@@ -3,12 +3,12 @@ import { formatKey } from "./keyboard.js";
|
|
|
3
3
|
"use strict";
|
|
4
4
|
function makeTooltip(descriptionHtml, keyboardShortcut) {
|
|
5
5
|
return {
|
|
6
|
-
content: `<div>${descriptionHtml}</div><div class="
|
|
6
|
+
content: `<div>${descriptionHtml}</div><div class="ptw-flex ptw-items-center ptw-gap-1 ptw-mt-2 ptw-text-sm">${genKeyboardShortcutHtml(keyboardShortcut({ isMac }))}</div>`,
|
|
7
7
|
html: true
|
|
8
8
|
};
|
|
9
9
|
}
|
|
10
10
|
function genKeyboardShortcutHtml(shortcut) {
|
|
11
|
-
return `<span class="
|
|
11
|
+
return `<span class="ptw-border ptw-border-gray-600 ptw-px-1 ptw-rounded-sm ptw-text-gray-400">${shortcut.split("+").map((k) => formatKey(k.trim())).join(" ")}</span>`;
|
|
12
12
|
}
|
|
13
13
|
export {
|
|
14
14
|
makeTooltip
|