Commit Graph
74 Commits
Author SHA1 Message Date
Bogdan Chadkin d060fd552a refactor: insert fragments with multiple roots (#3582)
Ref https://github.com/webstudio-is/webstudio/issues/2647

Here fixed the issue with detecting root as first instance in the
fragment. The idea of this utility is to not rely on any root but
instead insert with new ids all instances outside of portals/components.
Roots semantics is left for outer utilities.
2024-06-18 02:19:02 +03:00
Bogdan Chadkin 8a522f1705 fix: allow deleting unknown instance without meta (#3488)
Fixes https://github.com/webstudio-is/webstudio/issues/3468
2024-06-04 17:54:15 +03:00
Oleg Isonen 700c9b95ab feat: Improve autoplacement when inserting component via 1-click in components panel or via paste (#3422)
Closes https://github.com/webstudio-is/webstudio/issues/3149

## Description

As a user when I have Heading, Text or similar instances selected which
have a single text node instance, I expect an added component to insert
AFTER such instances.

## Steps for reproduction

1. add heading
2. select heading instance
3. 1-click box
4. see box was added after the heading
5. repeat the same with paste
6. repeat the same with any instance that has only text inside

## Code Review

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

- [ ] hi @johnsicili , I need you to do
  - 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-27 10:18:22 +02:00
Oleg Isonen 3512b0e77b chore: Highlight slot and it's children in the navigator and on canvas with purple color (#3193)
## Description

Added new colors for navigator to mark slot and it's children

<img width="818" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/52824/988b991d-1fee-4cec-9c6a-920736f781de">


## 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-04-19 10:55:43 +02:00
Bogdan Chadkin beb3438224 experimental: support custom properties (#3047)
Ref https://github.com/webstudio-is/webstudio/issues/1536

Here added support for css custom properties in style object model.
Added guaranteed-invalid value to schema to represent initial value of
custom properties.
2024-03-25 19:44:32 +07:00
Bogdan Chadkin dad898e6a4 refactor: move expressions into base sdk (#3032)
We need to move stuff not related to react out of react-sdk into
universal sdk package.
2024-03-19 02:02:07 +07:00
Bogdan Chadkin df579f7c72 refactor: switch to acorn expressions everywhere (#3028)
Ref https://github.com/webstudio-is/webstudio/issues/2903

Here switched the rest of usages to acorn based expressions. Added
getExpressionIdentifiers utility to extract used variables names to
avoid using transpiler replaceVariable callback for this.
2024-03-18 14:41:57 +07:00
Jaya Krishna Namburu 0687ae1035 feat: Add FunctionValue to the css-engine to describe css functions effeciently. (#2986)
## Description

This PR adds a new `FunctionValue` type to the `css-engine`. This helps
in defining `blur(5px)`, `drop-shadow(10px 10px 10px red)` and
`translate3d(42px, -62px, -135px)` type of functions more clearly. There
is a flag in the `FunctionValue` with the name `seperator` which defined
that type of separator to be used while passing the function arguments.
In `css-tree` they use a `Operator` node. But we don't have something
similar to that in the schema. So, using a new flag to define it.

## 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

- [x] made a self-review

## Before merging

- [x] tested locally and on preview environment (preview dev login:
5de6)
- [x] updated [test
cases](https://github.com/webstudio-is/webstudio/blob/main/apps/builder/docs/test-cases.md)
document
- [x] added tests
2024-03-10 18:24:20 +01:00
Oleg IsonenandBogdan Chadkin dd425afd6d experimental: marketplace for templates (#2916)
## Description

Foundation for the future marketplace where free and paid templates,
apps and other integrations can be offered. This first version is
limited to a few items that we will add there.

Generally, we call items we list on that marketplace "products" and they
can open an iframe either in the same left panel or in a dialog.

1. Product listing is effectively a webstudio website that can also be
functional standalone as well as inside the builder.
2. That website wraps individual section templates with a utility
component that handles click-to-insert

<img width="281" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/52824/0511f516-fb95-41b4-afa5-7a91f238c353">
<img width="290" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/52824/881fdee8-47ac-4d3a-ac01-7fdb9fdab236">


https://share.descript.com/view/bIgPI8aGiYA


## Steps for reproduction

1. no need to test for now

## Code Review

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

## 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>
2024-02-26 10:01:36 +01:00
Bogdan Chadkin 9e37075e7d refactor: move insert instance children logic into utility (#2931)
Here split and consolidated utility for adding children to instances. It
can be universally reused almost everywhere.
2024-02-21 17:08:10 +07:00
Bogdan Chadkin bf6223902e refactor: allow to extract webstudio fragment from any data (#2927)
Here refactored to extract fragment or copy from any data not only
global stores.
2024-02-19 17:33:26 +07:00
Bogdan Chadkin 3863abec2a refactor: rename instances slice to webstudio fragment (#2925)
Here renamed everywhere in the code instances slice to webstudio
fragment to keep naming consistent across whole app.
2024-02-18 17:43:07 +07:00
Bogdan Chadkin 29df24bfaf experimental: update variables when duplicate page (#2886)
Here improved page duplicate logic to support replacing old variables in
page meta and path params variable with new references.

Also improved path duplicating to preserve path params by prefixing with
`/copy-n` subpath.
2024-02-09 23:53:37 +07: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
Bogdan Chadkin d8922a0dd4 fix: prevent editing body (#2833)
Fixes https://github.com/webstudio-is/webstudio/issues/2732
https://discord.com/channels/955905230107738152/1192842837583212655
2024-01-27 00:02:06 +07:00
Bogdan Chadkin 3fb1368023 feat: support copy pasting resources (#2796)
Closes https://github.com/webstudio-is/webstudio/issues/2532

Last one
2024-01-22 13:09:13 +07:00
Bogdan Chadkin eb5f9809ba fix: insert copy on reparent (#2787)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here replaced reparent implementation with copy/paste logic to support
changing scope of variables.
2024-01-21 21:31:39 +07:00
Bogdan Chadkin 0c9ee38235 feat: support copy pasting text content bindings (#2788)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Extended existing tests and logic to support expressions in instance
children beside prop expressions.
2024-01-21 17:46:19 +07:00
Bogdan Chadkin 1e7ef26dc9 refactor: make inserting fragments copy composable (#2783)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here refactored insertInstancesSliceCopy to accept webstudio data
instead of creating transaction.

This let us avoid hacky callbacks in duplicate instance and duplicate
page functionalities.

Note: review with hidden whitespaces
2024-01-21 12:15:08 +07:00
Bogdan Chadkin a84320666d refactor: make delete instance composable (#2781)
Here refactored delete instance to accept and mutate webstudio data
instead of accessing data stores.
Now we can avoid double transaction when delete pages.

Note: review with hidden whitespaces
2024-01-19 22:55:10 +07:00
Bogdan Chadkin f620e2e1f2 refactor: generalize transferrable fragments (#2780)
Here added two new types

WebstudioFragment - reusable fragment of webstudio data which can be
generated (markdown, embed template), transferred (copied or stored in
marketplace) and inserted.

WebstudioData - all available normalized data to allow composing
multiple operations within single transaction like delete instance and
then insert into other part of the page.
2024-01-19 22:24:59 +07:00
Bogdan Chadkin a76c29fc05 feat: inline variables outside current component/slot (#2778)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Important constrain on the way to custom components to not use data
sources defined in other components when copy paste.

## Steps for reproduction

1. Test covers it
2024-01-18 23:37:50 +07:00
Bogdan Chadkin f85d7fa4fd feat: delete resources along with variables (#2749)
Ref https://github.com/webstudio-is/webstudio/issues/2532

- fixed deleting when delete in variables section
- fixed deleting when delete instance
2024-01-10 19:23:57 +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 61d664fc87 refactor: support parameter data source for collection item (#2671)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here added dataSource.type = 'parameter' without initial value because
value is always provided by context. It let us fix a few issues with
variables without complicating logic.

- prevent deleting parameter variable (collection item) in variables
panel
- allow changing only name of parameter variable
- show only name in the list of variables
- fix removing expression from collection data
- hide item parameter from collection variable list
- prevent editing parameter value from props
- make collection unstylable
2023-12-08 11:42:18 +07:00
Bogdan Chadkin 8e1683ed86 refactor: switch to instances slice for copy paste (#2666)
Use same well tested utility to slice and insert its copy for copy
paste. Moved most utilities inside of instance plugin and added more
tests for it.

## Steps for reproduction

1. play with copy paste
2023-12-06 23:49:48 +07:00
Bogdan Chadkin f0b3d8fd6e feat: support duplicating pages (#2664)
Fix https://github.com/webstudio-is/webstudio/issues/2516

Here added "duplicate" button to page settings and implemented logic
based on recent instances slice utilities.

## Steps for reproduction

1. open pages
2. click on page
3. click "copy" button
2023-11-30 00:37:29 +03:00
Bogdan Chadkin d361c9ecee feat: add collection component to builder (#2657)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here added a "core" collection component to support iterating over json
arrays.

There is a lot of room for unification of all this logic though would
require building reactive tree abstraction.

Canvas automatically renders stub component for collection to make it
droppable. We can do the same for slot component.

Slot and Fragment eventually will go to "core" components too.

Added json/parameter prop types to embed template to support collection.

Fixed loosing focus while typing in json prop.

## Steps for reproduction

1. Drop collection component
2. play with it
2023-11-29 17:07:28 +03:00
Bogdan Chadkin 33509db139 refactor: reimplement duplicating instances (#2663)
Part of https://github.com/webstudio-is/webstudio/issues/2516

Here added new copy implementation. There are 2 differences

- it does not change existing instances and not change their children,
we will need this to copy pages
- it handles cross-project copy of portals (slots) properly, now each
portal content is inserted separately if the root does not exist and
skips otherwise
- much better covered with tests

## Steps for reproduction

1. try duplicating form and change form state prop
2. try duplicating form error message and change form state prop
2023-11-29 13:45:09 +03:00
Bogdan Chadkin 6dd5b0687a refactor: drop legeacy data source prop support (#2600)
Ref https://github.com/webstudio-is/webstudio/issues/2532

We successfullly migrated prod to expression prop. Now we can safely
remove legacy data source prop
handling across codebase.
2023-11-11 18:07:17 +03:00
Bogdan Chadkin 052fe4e3ce refactor: add expression prop (#2582)
Ref https://github.com/webstudio-is/webstudio/issues/2532

On the last discussion about bindings we agreed expression are always
bound to single prop and cannot be reused.

Here added new prop.type = 'expression' as a replacement to
dataSource.type = 'expression'.

This will let us unify expression/variable reference and avoid deep
dependencies. Expressions and actions become similar.

For now both expression prop and legacy expression data source are
supported until we migrate completely in db.
2023-11-08 20:46:57 +03:00
Bogdan Chadkin fa06b7d495 feat: reuse variables on copy/paste within same tree (#2580)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here improved copy/paste behavior.

Before variables outside of copied tree were inlined. For example
ErrorMessage were loosing its expression when duplicated within same
form.

Now expressions and variables are preserved
and variables are inlined into expressions when paste target do not have
such variable. For example ErrorMessage get `"initial" == "error"`. With
upcoming UI it will be more obvious. The main idea here to not loose all
expressions but only references to unavailable variables.
2023-11-07 18:58:50 +03:00
Bogdan Chadkin 0d735c2bf8 refactor: compile prop expressions (#2569)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here changed accessing expression from data source id to prop id in
builder and data source name to prop name in generated code.

This is another step to migrate expressions from data sources to props.

See generated output for clarification.

Note: review with hidden spaces
2023-11-06 13:14:34 +03:00
Bogdan Chadkin 78d9ea912d refactor: split instances slice into separate utility (#2521)
Split instances slicer into separate utility from copy paste plugin.
Will be used to duplicate pages. Along with splitting added more tests
to better cover behavior.
2023-10-25 23:55:11 +04:00
Bogdan Chadkin 45aca18843 feat: select sibling after delete instance (#2476)
Quite requested improvement. Instead of selecting parent on delete
select next or previous sibling to be able to clean items within
collections with minimal amount of actions.

For testing
- delete first item in a list
- delete last item in a list
- delete the only item in a list
2023-10-15 12:49:22 +04:00
Bogdan Chadkin 392b6b1005 fix: prevent deleting Body (#2467)
Moved root detection logic into "deleteInstance" utility and covered
with test.
2023-10-13 17:58:13 +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 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 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 2fab05137f fix: prevent error when insert components (#2345)
This fixes the issue with computing data sources logic.
insertTemplateData first calls propsStore.set and then
dataSourceStore.set which triggers computing 2 times and first time prop
refers to not existing data source.

Here fixed by setting data sources first and then props.
2023-09-20 18:27:34 +04:00
Bogdan Chadkin ee0e0f7e7a Drop prisma from cli (#2241)
Here moved types and utilities from project-build to sdk package. This
removed huge prisma from cli.

```
du -ck node_modules
137460
72464
```
2023-09-04 12:43:56 +04:00
Bogdan Chadkin 5794e8d1e7 Move app schema to sdk (#2237)
We are planning to decouple cli from prisma and all unrelated packages.
Here moved whole app schema into sdk package.
2023-09-03 22:27:30 +04:00
Bogdan Chadkin cc0336e50d Drag on canvas closest detachable (#2197)
Before when start dragging we searched for closest rich editor under
cursor and did nothing when the instance is not detachable (for example
select value or switch indicator).

Here I changed the behavior to also look for closest detachable instance
and drag whole thing. This way we do not need toast like in navigator
and can canvas dnd just work.

Also fixed placeholder in "Select Value" component. Before was no way to
change it.
2023-08-27 21:28:33 +04:00
Bogdan Chadkin 5e900ff2e8 Add component tokens support (#2147)
Ref https://github.com/webstudio-is/webstudio-builder/issues/2137

Here added static tokens support to meta. Id of resulting style source
become persistent like this "componentName:tokenName". Such token styles
are inserted only if style source with same id not exist. This way we
prevent breaking styles already changed by user.

Style source input now autocomplete global tokens and suggest to create
predefined component tokens.

Also disabled spell check in style source input.

<img width="244" alt="Screenshot 2023-08-20 at 17 18 37"
src="https://github.com/webstudio-is/webstudio-builder/assets/5635476/9572f5b1-6243-49fa-83be-a0315f104987">
2023-08-20 18:48:16 +04:00
Bogdan Chadkin f240c46027 Infer label from component name (#2106)
Here made meta.label optional to simplify adding new stuff. Most of the
time label is just a "humanized" version of component name. With radix
there is an additional action to strip namespace. But still would be
less repetition if the name is just inferred.
2023-08-13 13:12:51 +04:00
Bogdan Chadkin d88939b477 Fix breadcrumbs labels (#2038)
Ref
https://discord.com/channels/955905230107738152/1137068758511394929/1137068758511394929

Full component name was used instead of meta or instance labels.
Also removed unnecessary instance labels.
2023-08-05 11:39:12 +04:00
Bogdan Chadkin 9328961b87 Allow to disable components detaching (#1986)
Here added meta.detachable flag which allows when set to true disable
copying, dragging and deleting instances of this component without ts
parent instance.

This is necessary to constrain components based on external code and
prevent deleting hidden components user cannot add again.
2023-07-27 20:43:46 +03:00
Bogdan Chadkin b226343599 Support copy pasting of data sources (#1963)
Here fixed the case when copy pasted form looses state and give errors
on submit.

Immerhin now converted to esm to work in tests.
Added tests for instances copy paste plugin.
The new logic is copy data sources as is if they are bound to copied
instances.

The new computeExpressionsDependencies used to detect if expression
depends on data sources outside of copied instances scope.
2023-07-23 11:56:13 +03:00
Bogdan Chadkin 6037a039b7 Compute insert constraints for tree (#1954)
Fixes https://github.com/webstudio-is/webstudio-builder/issues/1950

Here added new utility to compute constraints for tree when insert embed
template, paste something or reparent. I previous implementation all
constraints were merged which gave us false positives like when paste
List>ListItem we got "requiredAncestors: [List]". Here tree layout is
considered to exclude such false positives.

For testing try to copy paste List>ListItem
2023-07-19 22:23:34 +03:00
Bogdan Chadkin eb0bc5ff77 Support pasting embed templates (#1936)
Here refactored copy paste plugin system to try each plugin until it
succeeds. This way we can have multiple solutions to copy paste from
plain text. For example embed template is hand written text and should
succeed before markdown starts parsing it.

```json
{
  "@webstudio/template": [
    {
      "type": "instance",
      "component": "Box",
      "children": [
        { "type": "text", "value": "Hello, I'm Box!" }
      ]
    }
  ]
}
```
2023-07-16 13:38:07 +03:00