Commit Graph
50 Commits
Author SHA1 Message Date
Ivan Starkov a4d3f33bad fix: Dialog within collection issues (#3597)
## Description


https://discord.com/channels/955905230107738152/1251593079161491637/1251593079161491637

## Steps for reproduction


https://dialog-col.staging.webstudio.is/builder/be551fca-b3bc-4750-961a-c0bdc0557506?authToken=3d9f5902-0ecc-4645-ba12-9f7af2f81e09&mode=edit

https://dialog-saas-a7f4v.wstd.work/

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2024-06-21 20:54:04 +03:00
Ivan Starkov 863bb2a1bc feat: Adds the ability to place images on the canvas immediately during upload (#3546)
## Description

- Adds the ability to place images on the canvas immediately during
upload, using the file blob or a provided URL.
- Enables images to use width and height from asset metadata.
- Detects duplicate assets and displays a warning message.

<img width="323" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/fe810dd8-3e3d-4cab-8669-b0d739044f49">


These changes allow images to appear on the canvas upon pasting, even if
the asset is not fully uploaded yet.


## Steps for reproduction

Start uploading few files on a slow connection, select them before
upload, see image on canvas is changed

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2024-06-14 11:01:07 +03:00
Ivan Starkov 0e1d1cf963 feat: Image Manager drag/drop suport (#3505)
## Description

This is 1st PR In a series of PR's

Next: Image URL Links upload support.

Image Manager now support files drag/drop
(Images, Fonts etc)

## Steps for reproduction

Drag files on image manager see it works.

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env` file
2024-06-07 15:59:02 +03:00
Ivan Starkov 7d89ccfb09 fix: Fix focus bugs with text editing on canvas (#3454)
## Description

closes #3021

Currently if we are in a text edit mode we sometimes can't focus on any
input inside builder.
This fixes this.


## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2024-05-30 19:41:46 +03:00
Ivan Starkov 3c189aff97 fix: HTML Embed Code editor inside Dialog Content looses focus (#3020)
## Description

closes #2998

Also fixes name edits etc.
The same issue with radix as we had in the past, focus lock on any
mutation inside dialog aquires focus.
And we have no good way to prevent programmatic focus inside iframe.



## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2024-03-20 22:42:44 +03:00
Ivan Starkov d1469f9e1d feat: Add ability to disable clone and copy for view links (#2983)
## Description


### HAS MIGRATION, CAN'T BE TESTED ONLINE


Pro users can add additional permissions to auth tokens
<img width="358" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/df294ac3-e98c-465d-8115-f74ff075ff2d">

In case of cloning is disabled user will see

<img width="448" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/c77e5598-ba0a-4a40-82fc-3aab7c1d107f">

In case of copying

<img width="506" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5077042/a92ec66f-0b7a-4666-aa20-911de51c9d28">





## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2024-03-11 08:52:37 +03:00
f66a6bee31 experimental: Marketplace settings (#2949)
## Description

- split project settings
- add marketplace settings

## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory

---------

Co-authored-by: Bogdan Chadkin <trysound@yandex.ru>
Co-authored-by: istarkov <istarkov@gmail.com>
2024-03-04 13:06:49 +01:00
Bogdan Chadkin 39579c904b feat: preserve last selected style source on instances (#2873)
Fixes https://github.com/webstudio-is/webstudio/issues/2575
2024-02-06 20:22:59 +07:00
Oleg Isonen b2bf220ed6 chore: Rename all *Store to $store (#2747)
## Description

Pure renaming, nothing else.

## Code Review

- [ ] hi @TrySound , I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2024-01-09 13:32:51 +01:00
Bogdan Chadkin 11b799d4f7 feat: load resources in builder (#2714)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here improved resource management to load defined resources and store in
variable values to allow preview data. Builder requests data from proxy
route every time resources or their variables are changed.

<img width="1449" alt="Screenshot 2023-12-25 at 01 09 58"
src="https://github.com/webstudio-is/webstudio/assets/5635476/6614a356-0170-4606-9b60-d39b1bc09837">

Data to test is here
https://gist.githubusercontent.com/TrySound/56507c301ec85669db5f1541406a9259/raw/a49548730ab592c86b9e7781f5b29beec4765494/collection.json
2023-12-27 23:54:09 +07:00
Bogdan Chadkin 1a904b00b4 feat: add resource variables support in builder (#2711)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here added Value/Resource tabs to "new/edit variable" panel to support
creating both value and http request based variables.

Url, headers and body are expressions with support to all available in
scope value and page params variables.

Actual loading of resources in builder will be added later.

<img width="493" alt="Screenshot 2023-12-24 at 13 42 34"
src="https://github.com/webstudio-is/webstudio/assets/5635476/683876ec-4080-45fe-b2cc-e46e40256ce1">
<img width="481" alt="Screenshot 2023-12-24 at 13 42 20"
src="https://github.com/webstudio-is/webstudio/assets/5635476/b8937693-fb04-4ea5-a0aa-7092e3bec518">
2023-12-25 17:18:09 +07:00
Bogdan Chadkin 847a042ceb fix: show active style states as remote (#2654)
Succeeds https://github.com/webstudio-is/webstudio/pull/2136 in more
simple way. Active states are preresolved for everything except local
styles. And local styles shown as overwritten when defined state is
active.

Fixes
https://discord.com/channels/955905230107738152/1177028091227418654

## Steps for reproduction

1. create form component
2. choose error state
3. set background red
4. go to error state in style source menu
5. should be "remote" label
6. set background green
7. go to stateless style source
8. reset background color
9. should be "overwritten" label
2023-11-26 14:59:21 +03:00
Bogdan Chadkin 45f311150c refactor: render ephemeral styles with synced store (#2512)
Here replaced updateStyle and previewStyle pubsub events with
synchronized $ephemeralStyles store to reduce pubsub spread across the
codebase.
2023-10-20 15:17:25 +04:00
Bogdan Chadkin 3ce14f3784 fix: sync commands after builder and canvas initialized (#2455)
Found we have race condition because of handshake
which complicates synchronizatio of commands.

Here removed handshake. Instead iframe now rendered client side after
first effect and canvas sends "connect" event so builder start sending
updates.

In the future this can be simplified even more with computed updates
from current state like yjs does.

## Testing steps

- try to delete instance after selecting on canvas
- try to press enter to edit text after selecting from navigator
2023-10-13 01:41:48 +04:00
Bogdan Chadkin 331cbea835 fix: fix drag&drop issues (#2462)
- allow dragging control and embed components
- fix placement indicator for style sources and backgrounds
- synchronize drag and drop state between builder and canvas
2023-10-13 01:08:00 +04:00
Bogdan Chadkin a3b200fcda fix: listen hotkeys before first user interaction (#2436)
Here fixed the issue with initially missing hotkeys in builder. Add
queue in immerhin to collect
transactions until subscription. This let us create new transactions in
module scope without worrying
the event will not reach the other realm.
2023-10-09 18:03:26 +04:00
Bogdan Chadkin a379a98c1f refactor: split stores with server synchronization (#2410)
New version of immerhin moved global queue into store instance so we can
stop filtering and just call store.popAll().

Also replaced default store with webstudio own serverSyncStore instance.
Now auto import works much better.
2023-10-03 20:13:57 +04:00
Bogdan Chadkin af35ba937d fix: fix undo/redo (#2408)
Commands meta store introduced in latest changes polutted immerhin
history. Here created separate store for client only synchronization.
2023-10-03 13:48:59 +04:00
Bogdan Chadkin 92e6dbd118 refactor: move text editing into commands (#2394)
Here fixed two-way synchronization of commands between builder and
canvas. Added flag to not share hotkey with other apps.

Added first two commands specific to canvas: editInstanceText and
escapeSelection. Builder is able to reuse commands by specifying inn
"externalCommands" which basically extends the union of commands.
2023-09-30 14:13:10 +04:00
Bogdan Chadkin 743d2f1842 refactor: add commands emitter (#2389)
Added new commands emitter utility to manage hotkeys across plugins and
separate a lot of logic from canvas.

Here migrated only togglePreview as an example.

Later we can build commands panel and hotkeys overrides on top of this
utility.
2023-09-29 20:47:25 +04:00
Bogdan Chadkin 63f597225b refactor: drop react wrapper from preview mode store (#2365)
Nanostore react wrappers in many cases introduce additional renders
because of subscription even when only store.set is used. Searching for
references become complicated because we have both direct store access
and react wrapper.

Here migrated to use direct store access for preview mode store and
renamed it to $previewMode according to new convention.
2023-09-25 17:11:31 +04:00
Bogdan Chadkin 114817c266 Support data source expressions (#1882)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1529

Here introduced two types of data sources into "variable" and
"expression". First stores the value, the second only executable code.

Execute expressions now output results of all expressions so we could
access values globally with "computed" store

Embed template references now allow to define both variable reference
and expression.
2023-06-30 22:22:12 +03:00
Ivan Starkov cba00105db Sync pages change (#1856)
## Description

Changed pages synchronisation.

We had following path on link click in canvas:

- We intercept it in handleLinkClick and do publish('switchPage', {});
- We subscribe on 'switchPage' at builder and do navigate(builderPath, {
pageId});
- We subscribe on useSearchParams extract from there pageId and do
selectedPageIdStore.set(pageId)
- On Canvas we subscribe on selectedPageStore and finally render the
page

Now we just change
`selectedPageHashStore`, `selectedPageIdStore` in a single function
`switchPage`
`location.searchParams` used only for initial and popstate
synchronisation.


pageHashStore added for future use, no logic now.



## Steps for reproduction

1. click button
2. expect xyz

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-builder/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-06-26 10:22:13 +04:00
Bogdan Chadkin 07c6734f8c Support updating data source values (#1849)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1529

Added data source values store which can be updated from both components
and props panel.

```js
const { setState } = useContext(ReactSdkContext)
const instanceId = getInstanceIdFromComponentProps(props)

setState(instanceId, propName, value)
```
2023-06-25 12:05:02 +03:00
Bogdan Chadkin 730d897039 Support data source insert from template (#1826)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1529

- added data sources store
- added dataSource type to props
- insert data sources from template (prop.dataSourceReference allows to
bind several props to the same data source)
- convert to static prop on copying (simplification until requirements
are clear)
2023-06-21 19:57:42 +03:00
Bogdan Chadkin 6f6a4e7d34 Register props meta into store (#1655)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1545
https://github.com/webstudio-is/webstudio-builder/issues/1129

Here moved props meta into store. Both default and custom meta should be
registered as by default its empty.

Removed merging of overriden props with overrides because our cli still
resolves all types in component.

Supported two-directional store initialization by checking if there was
any .set calls. This let us send initial data from canvas.
2023-05-21 19:48:44 +07:00
Roman Pominov b5c8716460 selectedInstanceIsRendered -> selectedInstanceRenderState (#1640)
Fixes review comment:
https://github.com/webstudio-is/webstudio-builder/pull/1632#discussion_r1196082482
2023-05-17 12:03:20 +03:00
Roman Pominov 68243c6876 Assets copy-paste (#1636)
## Description

1. Closes #1325
2. Assets used in styles are copied
3. Assets used in props are copied
2023-05-16 14:34:42 +03:00
Oleg Isonen abb4c2f639 Forms (#1525)
https://github.com/webstudio-is/webstudio-builder/issues/84#issuecomment-1522834976

## Description

1. Added new components:
   - textarea
   - radio-button and radio-button-field
   - checkbox and checkbox-field
   - success-message
   - error-message
 2. Added `states` like `:disabled`, `:valid`, etc. to `input`
3. Added `custom-components/form` that renders success-message and
error-message conditionally
 4. Added `success` and `error` style states to `custom-components/form`
5. Style panel now shows "Select an instance on the canvas" if the
selected component is not rendered on canvas (e.g. error-message may not
be rendered)
 
Not in this PR:

- The mailer package
- Backend handler for forms (will be in a PR in SAAS)
- Logic in Form that actually submits to backend and shows success/error
messages

## Steps for reproduction

1. Add a "Form" to canvas
2. Add "Checkbox Field", "Radio Button Field", "Text Area" to the form
3. Try changing `initialState` property of the form
2023-05-02 14:14:06 +03:00
Ivan Starkov 885fa38885 Fix data not synchronized if you reopen the projects from the dashboard (#1508)
Fix data not synchronized if you reopen the projects from the dashboard
2023-04-21 21:29:02 +07:00
Bogdan Chadkin 197a03ede3 Add handshaken store (#1498)
Here replaced canvasReady and canvasReadyAck events with handshaken
store which reuses the logic from stores synchronization.
2023-04-20 17:40:43 +07:00
Ivan Starkov 5ad198f39e Concurency mode for React 18 (#1474)
## Description

Made handshake between canvas and builder.
Now publish actions are delayed in local array until handshake message
from destination is received

Switched on hydrateRoot to enable concurrent mode

unstable_batchedUpdates are removed

## Steps for reproduction



## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-builder/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-04-17 21:11:40 +04:00
Bogdan Chadkin a148507e48 Render style states (#1420)
Ref https://github.com/webstudio-is/webstudio-builder/issues/807

Refactored styles rendering in canvas to consider states and added style
states support to css text renderer.
2023-04-17 15:50:14 +07:00
Ivan Starkov 167d746107 UX improvement for Inputs that have both keywords and units (#1412)
## Description

closes #956

+ In case if user not edited the value but immediately clicked to unit
select we are trying to convert em px etc values

## Steps for reproduction

1. Edit `width` value, enter 10
go to unit select set `em` - see 10em as final result

2. Click on unit select of the width, change em to px see 10em converted
to 140px or like (depends on em size)

3. Enter `Auto` in width, click Enter. 
Click on UnitSelect select EM, see browser style is used to set em
width.

4. Enter Auto in width, switch on Unit select, set px, see browser style
is used.

5. See that now unit selector is visible always. With some exclusions
like aspectRatio as it has keywords and numeric values.




## Code Review

- [x] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-builder/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-04-11 16:01:23 +04:00
Oleg Isonen 48b4980d12 Breakpoints redesign stage 2 (#1366)
## Description

- Canvas behavior should be exactly as in Webflow now - responsive
canvas.
- No constraints for resizing, you can switch to different breakpoints
when you change the canvas width just like in preview

## Not done in this PR

- [ ] breakpoints dropdown menu redesign
- [ ] on-canvas resizable handles
- [ ] flash-animate breakpoints list when breakpoint is switched through
resize
- [ ] flash-animate left and right borders when breakpoint is switched
- [ ] gravity of resize handle dragging when reaching next breakpoint
- [ ] vertical labels with @media example that matches current
breakpoint
- [ ] migrate min-width 0 breakpoints to base?
- [ ] hide outline while changing size
- [ ] ensure there is never both min and max in one media

## Todo

- [x] draggable positioning calc
- [x] shortcuts for zoom
- [x] sync width and selected breakpoint
- [x] remove scale
- [x] fix mobile-first breakpoints
- [x] tabbable toolbar items
- [x] icon for base
- [x] fix flicker
- [x] After breakpoint delete/add CascadeIndicator doesn't refresh
- [x] fix when there is no base, min-width 0 should have still a full
width

## Steps for reproduction

1. click button
3. expect xyz

## Code Review

- [ ] hi @TrySound, @istarkov  , I need you to do
  - conceptual review (architecture, feature-correctness)
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [ ] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-builder/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-04-09 20:19:12 +02:00
Bogdan Chadkin 417b39833e Delete assets with patches (#1368)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1335

Here moved assets store to immerhin. Patches manage only delete
operation by diffing previous and patched list of assets.
2023-04-05 01:32:14 +07:00
Bogdan Chadkin 362cced071 Add assets store (#1361)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1335

Here I replaced assetContainersStore with assetsStore. Now deleting and
uploading states are maintained locally in assets provider. To preserve
the order of uploading assets assetsStore map has value as undefined.
This way assets.get(id) provides the same value. Though when iterating
we see missing asset.
2023-04-04 16:42:10 +07:00
Ivan Starkov 11e73390c2 Normalize css (#1333)
## Description

closes #473 

`${tag}:where([${componentAttribute}=${component}])` where is used to
not increase specificity

- [ ] todo remove from getInheritedInfo, as we don't know ancestor
tagName

## Steps for reproduction

See box-sizing etc props for newly created items

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)

- [ ] hi @TrySound , I need you to do
  - detailed review (read every line)
  - test it on preview

## Before requesting a review

- [x] made a self-review
- [ ] added inline comments where things may be not obvious (the "why",
not "what")

## Before merging

- [ ] tested locally and on preview environment (preview dev login:
5de6)
- [ ] updated [test
cases](https://github.com/webstudio-is/webstudio-builder/blob/main/apps/builder/docs/test-cases.md)
document
- [ ] added tests
- [ ] if any new env variables are added, added them to `.env.example`
and the `builder/env-check.js` if mandatory
2023-03-31 18:31:20 +04:00
Bogdan Chadkin 2c7184c069 Refactor selected outline with store (#1317)
One less pubsub event replaced with store. Now hovered and selected
logic is similar.
2023-03-30 11:39:36 +07:00
Bogdan Chadkin 1d62927462 Refactor text toolbar state (#1314)
- refactored with synchronized client store
- recompute toolbar position on scroll end
2023-03-29 00:41:12 +07:00
Bogdan Chadkin 3592df7bba Migrate text editing to selector (#1287)
The last piece to address instances by selectors

- the mode is represented as text editing instance selector
- reset editing mode along with selection on user input instead of
ssubscribing to selected store
- moved enter/esc shortcuts to shared between builder and canvas
- got rid of legacy subscriptions to stores
2023-03-25 11:35:29 +07:00
Bogdan Chadkin e0553200e9 Improve instance hovering (#1236)
Label again started flickering because hovered instance and hovered
outline store changes have delay in between. Solution as before is to
provide all info with outline. Here I just passed both label and
component to get the shape for getInstanceLabel.

Removed react hook from instance hovering and refactored with instance
selectors.
2023-03-14 19:51:34 +03:00
Bogdan Chadkin fddb67e924 Rename instance address to instance selector (#1234)
Selector makes more sense and allows to not introduce "instance element"
term.
2023-03-14 00:29:45 +03:00
Bogdan Chadkin 91fbdb2ee1 Address selected instance with tree path (#1228)
With slots there can be same ids in one tree so we need new way to
address instances. Here I propose the list from target instance to the
root.

Now instead of computing parents by normalized tree (one instance of
slot can have many parents) we just access already computed list from
rendered tree.

This address can be computed when user click in dom which can be
traversed or it can be passed top-down with props.

The main con of this approach is collaboration. Reparanted instances on
by one user makes "selected address" stale. Though we have similar
situation with single id when instance is deleted.

Isolated mode for slots/components will make this problem less
noticable.
2023-03-13 18:42:54 +03:00
Bogdan Chadkin 78f7882ddb Switch pages on client side (#1225)
Switching between pages takes very long time though all data already
loaded. Here I added validation to not reload builder data when page is
changed and render canvas with static id which is not really used for
anything so iframe no longer reloads.

Switching pages now instant.
2023-03-11 13:57:55 +03:00
Bogdan Chadkin 40b2000d2e Sync initial client store from builder to canvas (#1224)
Before we send initial data from canvas which broke preview mode. Now
builder is leader and fully maintain synchronization.
2023-03-11 00:03:18 +03:00
Bogdan Chadkin f91a4e3a19 Move initial data to builder (#1177)
Canvas no longer populate stores data. Builder load project build,
populate stores and synchronize them into canvas.

This way we can simplify data flow, make builder responsible for both
initial data and patches, do less work on canvas side.

This is also necessary to move pages management to client side.
2023-03-07 19:18:46 +03:00
Bogdan Chadkin df4c2e0384 Add root instance id to page schema (#1142)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1116

Before we assumed the first instance in the list of instances is the
root. Though we are gonna introduce slots and for this have to combine
instances of all pages into single array. So there can be many roots in
one list.

So now we gonna specify root instance id on page. treeId will be removed
once instances are migrated to Build table.
2023-02-28 19:41:20 +03:00
Bogdan Chadkin 83a44d9077 Patch normalized instances (#1112)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696
https://github.com/webstudio-is/webstudio-builder/issues/924

Moved temporary denormalization from server to client. Denormalized tree
patches are converted to normalized patches. Now we can enable
collaboration and get minimal conflicts to resolve.
2023-02-23 16:42:42 +03:00
Andras Bacsai ac413cdd5f rename designer to builder 2023-02-14 11:15:24 +01:00