Skip to content

Commit dd9641c

Browse files
author
克隆(宗可龙)
committed
Merge branch 'main' of https://github.com/onlook-dev/onlook into translation_zh
2 parents 84897c4 + 7b0b6fb commit dd9641c

File tree

10 files changed

+420
-43
lines changed

10 files changed

+420
-43
lines changed

apps/studio/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"productName": "Onlook",
33
"name": "@onlook/studio",
4-
"version": "0.2.17",
4+
"version": "0.2.18",
55
"homepage": "https://onlook.com",
66
"main": "dist-electron/main/index.js",
77
"description": "The first-ever devtool for designers",

apps/studio/src/lib/editor/engine/history/helpers.ts

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,45 @@ export function undoAction(action: Action): Action {
9393
}
9494
}
9595

96+
function handleUpdateStyleAction(
97+
actions: Action[],
98+
existingActionIndex: number,
99+
newAction: UpdateStyleAction,
100+
): Action[] {
101+
const existingAction = actions[existingActionIndex] as UpdateStyleAction;
102+
const mergedTargets = [...existingAction.targets];
103+
104+
for (const newTarget of newAction.targets) {
105+
const existingTarget = mergedTargets.find((et) => et.domId === newTarget.domId);
106+
107+
if (existingTarget) {
108+
existingTarget.change = {
109+
updated: { ...existingTarget.change.updated, ...newTarget.change.updated },
110+
original: { ...existingTarget.change.original, ...newTarget.change.original },
111+
};
112+
} else {
113+
mergedTargets.push(newTarget);
114+
}
115+
}
116+
117+
return actions.map((a, i) =>
118+
i === existingActionIndex ? { type: 'update-style', targets: mergedTargets } : a,
119+
);
120+
}
121+
96122
export function updateTransactionActions(actions: Action[], newAction: Action): Action[] {
97-
// Only allow one action per type, otherwise, overwrite the existing action
98-
if (actions.some((a) => a.type === newAction.type)) {
99-
return actions.map((a) => (a.type === newAction.type ? newAction : a));
123+
const existingActionIndex = actions.findIndex((a) => a.type === newAction.type);
124+
if (existingActionIndex === -1) {
125+
return [...actions, newAction];
100126
}
101-
return [...actions, newAction];
127+
128+
if (newAction.type === 'update-style') {
129+
return handleUpdateStyleAction(
130+
actions,
131+
existingActionIndex,
132+
newAction as UpdateStyleAction,
133+
);
134+
}
135+
136+
return actions.map((a, i) => (i === existingActionIndex ? newAction : a));
102137
}

apps/studio/src/routes/editor/EditPanel/StylesTab/single/ColorInput/ColorBrandPicker.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import { useEditorEngine } from '@/components/Context';
2+
import type { CompoundStyle } from '@/lib/editor/styles/models';
23
import type { ColorItem } from '@/routes/editor/LayersPanel/BrandTab/ColorPanel/ColorPalletGroup';
34
import { Icons } from '@onlook/ui/icons/index';
45
import { Input } from '@onlook/ui/input';
56
import { Popover, PopoverContent, PopoverTrigger } from '@onlook/ui/popover';
67
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@onlook/ui/tabs';
78
import { Color } from '@onlook/utility';
8-
import { memo, useEffect, useMemo, useRef, useState } from 'react';
9+
import { memo, useEffect, useRef, useState } from 'react';
10+
import { isBackgroundImageEmpty } from '.';
911
import ColorButton from './ColorButton';
1012
import ColorPickerContent from './ColorPicker';
1113
import ImagePickerContent from './ImagePicker';
12-
import type { CompoundStyle } from '@/lib/editor/styles/models';
13-
import { isBackgroundImageEmpty } from '.';
1414

1515
interface ColorBrandPickerProps {
1616
color: Color;
@@ -72,7 +72,7 @@ const ColorGroup = ({
7272
);
7373
};
7474

75-
const BrandPopoverPicker = memo(
75+
export const BrandPopoverPicker = memo(
7676
({ color, onChange, onChangeEnd, backgroundImage, compoundStyle }: ColorBrandPickerProps) => {
7777
const editorEngine = useEditorEngine();
7878
const [isOpen, toggleOpen] = useState(false);
@@ -132,8 +132,9 @@ const BrandPopoverPicker = memo(
132132
<ColorButton value={color} onClick={() => toggleOpen(!isOpen)} />
133133
</PopoverTrigger>
134134
<PopoverContent
135-
align="end"
136135
className="backdrop-blur-lg z-10 rounded-lg p-0 shadow-xl overflow-hidden w-56"
136+
side="left"
137+
align="start"
137138
>
138139
<div>
139140
<Tabs defaultValue={defaultValue} className="bg-transparent pb-0">
@@ -222,5 +223,3 @@ const BrandPopoverPicker = memo(
222223
);
223224

224225
BrandPopoverPicker.displayName = 'BrandPopoverPicker';
225-
226-
export default BrandPopoverPicker;

apps/studio/src/routes/editor/EditPanel/StylesTab/single/ColorInput/Popover.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ enum TabValue {
2222
IMAGE = 'image',
2323
}
2424

25-
const PopoverPicker = memo(
25+
export const PopoverPicker = memo(
2626
({ color, onChange, onChangeEnd, backgroundImage, compoundStyle }: PopoverPickerProps) => {
2727
const editorEngine = useEditorEngine();
2828
const [isOpen, toggleOpen] = useState(false);
@@ -102,5 +102,3 @@ const PopoverPicker = memo(
102102
);
103103

104104
PopoverPicker.displayName = 'PopoverPicker';
105-
106-
export default PopoverPicker;

apps/studio/src/routes/editor/EditPanel/StylesTab/single/ColorInput/index.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { Icons } from '@onlook/ui/icons';
77
import { Color, isColorEmpty } from '@onlook/utility';
88
import { observer } from 'mobx-react-lite';
99
import { memo, useCallback, useEffect, useMemo, useState } from 'react';
10-
import BrandPopoverPicker from './ColorBrandPicker';
11-
// import PopoverPicker from './Popover';
10+
// import { BrandPopoverPicker } from './ColorBrandPicker';
11+
import { PopoverPicker } from './Popover';
1212

1313
const stripUrlWrapper = (url: string) => {
1414
return url.replace(/^url\((['"]?)(.*)\1\)/, '$2');
@@ -200,21 +200,21 @@ const ColorInput = observer(
200200
};
201201
return (
202202
<div className="w-32 p-[6px] gap-2 flex flex-row rounded cursor-pointer bg-background-onlook/75">
203-
<BrandPopoverPicker
203+
{/* <BrandPopoverPicker
204204
color={color}
205205
onChange={sendStyleUpdate}
206206
onChangeEnd={sendStyleUpdate}
207207
backgroundImage={backgroundImage}
208208
compoundStyle={compoundStyle}
209-
/>
209+
/> */}
210210

211-
{/* <PopoverPicker
211+
<PopoverPicker
212212
color={color}
213213
onChange={sendStyleUpdate}
214214
onChangeEnd={sendStyleUpdate}
215215
backgroundImage={backgroundImage}
216216
compoundStyle={compoundStyle}
217-
/> */}
217+
/>
218218
<ColorTextInput
219219
value={value}
220220
isFocused={isFocused}

apps/studio/src/routes/editor/LayersPanel/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ export const LayersPanel = observer(() => {
156156

157157
<button
158158
className={cn(
159-
'w-16 h-16 rounded-xl flex flex-col items-center justify-center gap-1.5 p-2',
159+
'w-16 h-16 rounded-xl flex flex-col items-center justify-center gap-1.5 p-2 hidden',
160160
selectedTab === TabValue.BRAND && isLocked
161161
? 'bg-accent text-foreground border-[0.5px] border-foreground/20'
162162
: 'text-muted-foreground hover:text-foreground hover:bg-accent/50',

apps/studio/src/routes/editor/TopBar/Publish/Dropdown/Domain.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const DomainSection = observer(
7979
return;
8080
}
8181
domainManager.publish({
82-
skipBadge: type === DomainType.CUSTOM || plan === UsagePlanType.PRO,
82+
skipBadge: type === DomainType.CUSTOM,
8383
buildFlags: userManager.settings.settings?.editor?.buildFlags,
8484
});
8585
};

0 commit comments

Comments
 (0)