Commit Graph
72 Commits
Author SHA1 Message Date
Bogdan Chadkin f558311897 feat: load data before saving resource variable (#5392)
Ref https://github.com/webstudio-is/webstudio/issues/3691

- new resource loader with queue to avoid bloating network with huge
responses
- data can be loaded for new variable before saving, easier to preview
result



https://github.com/user-attachments/assets/5c26c5a2-fd33-401b-a4d2-a321c34ca083
2025-09-06 17:09:53 +03:00
Bogdan Chadkin 646c5b38e7 fix: normalize html attributes only when not defined by component (#5215)
Proper fix for https://github.com/webstudio-is/webstudio/pull/5211

Now props meta are available in component generator and can be used to
figure if prop is defined by component or comes from html attributes.
Added same logic in canvas and component generator.

Also got rid from no longer necessary registeredComponentPropsMetas
store since all props are described by component meta.
2025-05-17 10:11:56 +03:00
Bogdan Chadkin 95e6550098 perf: improve instance selection performance (#5151)
We had a few issues

- instance selector was resynced even though computed from awareness
- when click in navigator both click and focus events do selection

So fixed by reducing 6 or more reselections when click on instances in
navigator.
2025-04-21 15:03:20 +02:00
Bogdan Chadkin b14676bfd6 refactor: simplify css value input sizes (#4997)
- removed non-unit values from browser styles
- merged browser styles and unit sizes into single store; both objects
used in cize conversion
- use typed cssom to parse units instead of custom parser (sorry
firefox)
2025-03-14 20:59:57 +07:00
Bogdan Chadkin b798809870 refactor: decouple system store from variables (#4888)
We are moving away from binding system to variables and instead gonna
have one global variable.

Here moved system values into separate store coupled to pages instead of
variables.

Also fixed suggestions in address bar, probably broke while design
system refactorings.

Testing
- submit form with one named input
- check system value is rendered
- check system value can be inspected
2025-02-18 23:28:29 +07:00
Bogdan Chadkin 5408a11f19 perf: compute tags statically (#4687)
Got rid of computing tags from dom in canvas. Now tags are computed from
possible preset styles and tag prop if available.
2024-12-31 17:22:28 +07:00
Bogdan Chadkin a32d6329ed refactor: add templates meta support (#4653)
Here added one more description file for components `*.template.tsx`.

It is decoupled from component meta to fix the issue with some templates
like Sheet being treated as components though we don't have actual
components with this name.

Another reason is have it separately to not include builder specific
code and dependencies into CLI and published websites. Template package
is defined as optional in peer dependencies meta.

In this PR migrated only Button and List as examples. There is still not
support for data sources and styles.

Added support for text placeholders in children
2024-12-25 21:37:15 +07:00
Ivan Starkov ea88935731 feat: RichText edit / command menu (#4621)
## Description

ref #4595

Search is working

<img width="246" alt="image"
src="https://github.com/user-attachments/assets/5dc850e4-6a36-4996-9aaa-f051ac7e977f"
/>

Arrow keys, enter, mouse click is working.



https://p-15889dd9-ed47-46db-9411-fa18c1efb2fe-dot-edit.development.webstudio.is/

- [x] - Enter and click
- [ ] - Repeat > N then close menu (later)
- [x] - In case of select item clear cmd `/blabla`
- [x] - Put cursor inside 1st editable block of the new instance
- [x] - Should work only inside editable content

## 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:
0000)
- [ ] 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-12-20 16:21:56 +03:00
Ivan Starkov 5de42b2d02 fix: Ensure outline stays within canvas bounds (#4570)
## Description

Playground


https://p-183a0702-0620-49ac-84b6-066dbce1d300-dot-fix-outline.development.webstudio.is/


<img width="1229" alt="image"
src="https://github.com/user-attachments/assets/5c6a8c73-70e6-48af-8cbd-6c12144d55ee"
/>

todo:
- [x] - fix if horizontal scroll 
<img width="629" alt="image"
src="https://github.com/user-attachments/assets/d904d7ac-f74a-4116-993f-00b8b14c39dd"
/>

- [x] - fix if vertical

## 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:
0000)
- [ ] 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-12-12 13:09:51 +03:00
Ivan Starkov 9cf443a3c5 feat: Support new link selection in the text editor (#4509)
## Description

Same as #4505 but supports just created links too

ref #3994

## 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:
0000)
- [ ] 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-12-04 17:41:45 +03:00
Bogdan Chadkin e06de5322b refactor: add server as storage to sync engine (#4475)
Another layer in sync engine is composable storage.

Now you can specify a chain of storages. Each can listen transactions to
update some state. Though subscription for state is invoked one by one
until non-undefined is provided.

See tests to understand API.

Here I also migrated our server data loading and synchronization to this
storage api.
2024-12-03 21:43:39 +07:00
Ivan Starkov 71e0be8363 feat: Transform Plus button to Minus in case of Alt button is pressed (#4490)
## Description

ref #3994

<img width="260" alt="image"
src="https://github.com/user-attachments/assets/88652fef-7229-42cb-bf64-33ec07249426">

<img width="260" alt="image"
src="https://github.com/user-attachments/assets/e8199a7d-ebbc-4971-8641-d83424643ac8">

<img width="245" alt="image"
src="https://github.com/user-attachments/assets/804b8ef5-4f71-42b3-b9d1-5cf034706a02">


## 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:
0000)
- [ ] 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-12-01 18:29:13 +03:00
Ivan Starkov a66a674ad5 chore: Rename editable block component (#4489)
## Description

ref #3994

## 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:
0000)
- [ ] 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-12-01 06:02:09 +03:00
Ivan StarkovandOleg Isonen 2acb4ac596 feat: Add Editable Block Component (#4437)
## Description

ref #3994 

Outline for content mode Editable Childs


https://p-64ece825-f290-4de0-8dac-223c8e88c258-dot-editable-block.development.webstudio.is/?mode=content

Like in notion if eny keyboard event is occured inside outlined block,
we hide it
Also + hovers are only on canvas

## 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:
0000)
- [ ] 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

---------

Co-authored-by: Oleg Isonen <oleg008@gmail.com>
2024-11-24 10:04:09 +07:00
Bogdan Chadkin 524f83203e refactor: support nanostores as sync objects (#4454)
Here added support for syncing nanostores atoms
as sync objects. Had to add some tracking of update source though it
seems like a more solid solution than previous variant.

Need to test performance caz stores updates are now synchronous and not
debounced anymore.
2024-11-21 18:17:28 +07:00
Bogdan Chadkin 35ebd60b46 refactor: add sync object pool (#4453)
Sync client is getting some shape. Here I abstracted all immerhin
related api into SyncObject and added SyncObjectPool to combine multiple
objects. Objects are identified by unique name.
2024-11-21 10:41:51 +07:00
Bogdan Chadkin bf574fbc47 refactor: add new way to synchronize immerhin stores (#4451)
Here added SyncClient class which will be base for our new sync engine.
For now it can synchronize one immerhin store.

Event emitter is shared with canvas directly to avoid indirection of
iframe postMessage api.

This also partially fixes the issue with messages pollution and conflict
with react devtools.
2024-11-20 21:15:00 +07:00
Ivan Starkov 36ba02d30f feat: Add builderMode, add mode "edit" (#4376)
## Description
Part 1 Of #3994 

This PR introduces a feature flag, `contentEditableMode`, that hides the
`EditorButton` in the top bar. This button is now intended for **testing
purposes only** and will **never be used in production**.

<img width="154" alt="image"
src="https://github.com/user-attachments/assets/f4a37334-71b9-43d8-b4a8-afd518fc6833">

## Most Notable Things In The Content Edit Mode

1. **Notion-like Editing**: Elements are editable with a single click.
2. **Restricted Element Editing**: Binded elements, such as expressions,
are non-editable.
3. **Selective Property Editing**: Only properties for `img` and `link`
elements are editable.

Additional changes:
- **Copy/Paste and Drag/Drop**: Disabled to maintain a controlled
testing environment.

Refer to the issue `Part 1` for further details on upcoming changes and
planned enhancements.


## Steps for reproduction

Play play 

## 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-11-14 11:06:29 +04:00
Bogdan Chadkin 6b1ea5eb4a refactor: move selected page into awareness state (#4371)
Ref https://github.com/webstudio-is/webstudio/issues/4364

We need to implement universal linking of current user view. For this I
added "awareness" state which reflects terminology from collaboration
libraries.

First migrated selected page id and fixed usages.
2024-11-06 02:29:52 +04:00
Oleg Isonen 052fe9e55c feat: auto-detect font weight based on selected font family (#4134)
## Description

I rewrote the font weight display logiс in the following way:

1. We now detect for each font  which weights are supported
2. Unsupported weights are lighter gray in the list, but user can still
choose them, we just hint that the weight may not be supported, because
with font stacks, you can have different fonts supporting different
weights, we are testing the one user can see right now

## Steps for reproduction

1. try switching between different stacks and see that when hovering the
font width that is light gray, its not affecting canvas, meaning our
detection was correct and that weight is not supported
3. same thing for any custom font

## 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-10-01 22:55:10 +02:00
Ivan Starkov 02269af49d fix: Inserting Slots within Slots from the Marketplace causes infinite loop and crash (#4113)
## Description

closes #4111

- [x] - Fixes client side
- [x] - Fixes server side


https://github.com/user-attachments/assets/8bb6ffdc-2e78-45eb-b98b-e697daee822a

## Steps for reproduction

Now seems like impossible to save broken project. Tested locally on
broken project.


## 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-09-13 12:32:07 +03:00
Ivan Starkov 8f48a7bb79 fix: Disable auto-freezing for Safari structuredClone compatibility in sync-stores (#4106)
## Description

structuredClone fails sometimes on frozen objects

## 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` file
2024-09-11 17:15:57 +03:00
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