Commit Graph
43 Commits
Author SHA1 Message Date
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 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 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 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 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 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 afc75f1d99 Drop unused db validation (#2231)
We had db data validation enabled before but it made api requests very
slow. We disabled this validation and seems like there is no need to
enable again.

Also dropped all zod list types of our data because validation was the
only use case.
2023-09-01 23:57:59 +04: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 64f3f37256 Fix insert into container without children (#1802)
Ref
https://discord.com/channels/955905230107738152/955907841070346300/1118910260871168021

Container without children got additional empty text wrapper. Here fixed
this by checking children existence.
2023-06-15 21:55:21 +03:00
Bogdan Chadkin 21f8d1aab2 Merge text and block components (#1742)
Ref https://github.com/webstudio-is/webstudio-builder/pull/1703
https://github.com/webstudio-is/webstudio-builder/issues/1677

- renamed TextBlock to Text in db and meta
- replaced LinkBlock with Link in db and meta
- renamed Styled Text label to Text
2023-06-11 14:58:34 +03:00
Bogdan Chadkin dcae1b5a9d Allow inserting into editable containers (#1735)
Here I removed "rich-text" type from components. Instead "container" can
be edited when has only text or rich text children.

And any time user can drop into editablle container which will wrap all
text and rich text children into "Span" component.

Had to implement position adjustment to consider text children which do
not have representation in navigator tree and canvas dnd.

Span has temporary SpanContainer name to not conflict with existinig
Span for styled text in rich text. Will rename in other PR when remove
no longer necessary components.
2023-06-10 00:55:46 +03:00
Bogdan Chadkin 7c66afef74 Add requiredAncestors and invalidAncestors to meta (#1684)
Here added two component restrictions to meta.

requiredAncestors prevent inserting components outside of required ones
here restricted ListItem to always be inside of List.

invalidAncestors prevent inserting components inside of invalid ones
here prevented nested buttons
2023-05-30 12:33:44 +07:00
Bogdan Chadkin 40e97a1086 Replace meta.children with meta.template (#1676)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1569

Here we change template in meta to include current component instead of
implicitly creating it.

This way we can provide insert composition of components instead of
single one for example input+label. Or even wrap current component like
label>input.

Another usecase is ability to set local styles and props for current
component.

Note: review with hidden whitespaces
2023-05-25 23:41:08 +07:00
Bogdan Chadkin a167d702f7 Fix copy paste of style sources (#1570)
Ref
https://discord.com/channels/955905230107738152/955907841070346300/1103260031048241182

Here style sources were pasted without copying. Here I renamed the
utility to clarify a little and provided proper list of instance ids.
2023-05-05 14:34:51 +07:00
Bogdan Chadkin 4e31256b2a Restrict allowed parents with config in meta (#1542)
Added `allowedParentComponents: string[]` option to meta which prevents
dropping, inserting or pasting components into wrong parents. For
example ListItem now can be placed only inside of List component.

This will unlock better experience with compound radix components.
2023-05-02 15:20:22 +08:00
Bogdan Chadkin 5595742f75 Insert styles from embed template (#1538)
Now embed templates can define simplified version of our styles which is
useful for radix components and as AI output.

```
styles: [
  {
    property: 'backgroundColor',
    value: { type: 'keyword', value: 'red' }
  }
]
```
2023-04-28 12:07:10 +07:00
Bogdan Chadkin 0f615afd01 Add props support in embed template instances (#1519)
Ref https://github.com/webstudio-is/webstudio-builder/pull/1516

This will allow further customization of react components through meta
2023-04-23 00:47:44 +07:00
Bogdan Chadkin 30be97deef Allow to specify tree template in component meta (#1517)
Ref https://github.com/webstudio-is/webstudio-builder/pull/1516

Here added new utility "tree template" to describe children in component
meta and generate instances from it while inserting.

Added simple template to form component as example.
2023-04-22 23:20:39 +07:00
Bogdan Chadkin 972bbf174d Prevent cyclic slot reparent (#1496)
Here consider this scenario when reparenting

- Create a slot
- Put a Box in it
- Copy the Slot
- Drag copy of the slot inside Box in the original slot
2023-04-20 15:40:34 +07:00
Bogdan Chadkin d61c39f22d Rename InstancesItem to Instance type (#1444)
InstancesItem is newer type introduced separately for gradual migration.
Not all legacy tree Instance is migrated away so we can finally use
better naming across whole system.
2023-04-14 00:17:12 +07:00
Bogdan Chadkin e42e346d1b Drop legacy root instance store (#1441)
Ref https://github.com/webstudio-is/webstudio-builder/issues/696

The last piece with denormalized tree. Now we rely only on normalized
instances map.
2023-04-13 13:08:26 +07:00
Bogdan Chadkin 0d30e1c419 Support cross-project breakpoints copy paste (#1332)
Here added utility to merge pasted breakpoints into existing ones or add
new one if breakpoint does not match any.
2023-04-01 15:06:28 +07:00
Bogdan Chadkin 59b9c6fedc Support cross-project instance copy paste (#1326)
Here a little refactored copy paste instance plugin.

Now we copy all data including slots and tokens though paste write them
as is or do not write at all if already exist.

This let us to not do unnecessary patches for copy paste within project
while still have whole UI pasted in different project.

There is still a problem with pasting styles which always have different
breakpoint ids in each project. We will need to implement merging in
other PR.
2023-03-31 11:38:19 +07:00
Bogdan Chadkin 68af3b58b6 Fix possible cyclic slot and hide its styles and props panels (#1306)
One cyclic case I missed. When paste slot into itself as target then
check miss unresolved fragment inside. Here added additional check
before copying and covered with tests.

For slots show only settings panel.
2023-03-28 18:46:18 +07:00
Bogdan Chadkin 12814190d7 Implement slots (#1294)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1116

Slot is copy pastable part of the tree which is always in sync. Kinda
like primitive components.

The idea is the following. Slot is copy pasted as any other instance
though its children are preserved as is without cloning with new ids.

This lead to the problem with multiple slot children. While copy paste
they are preserved as is though when add new child to slot, the other
instance of it will not get new child.

To workaround this we add another Fragment component which groups all
children into single one and new children are always reflected in all
slot copies.
2023-03-28 00:48:02 +07:00
Bogdan Chadkin 9b6511f4e2 Migrate style computing to instance selectors (#1291)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1116

This is the last one slots blocker for sure.

Refactored inherited styles to compute from selectors and got rid of
legacy traverser utility.
2023-03-27 17:45:27 +07:00
Oleg Isonen b22dfe038e Components Panel (#1284)
## Description

Implements all design changes and accessibility for components add panel



https://user-images.githubusercontent.com/52824/227720011-344b31f8-ce17-4d13-ad4d-2d506ca3bcce.mp4



## Code Review

- [ ] hi @rpominov , 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-03-26 13:36:05 +02:00
Bogdan Chadkin cd0e01ea56 Select span node with selector (#1285)
Here bit less straightfforward as lexical<>instances conversion is not
very straightfforward because lexical represents a few instances with
its formats.

To solve conversion complexity used almost same ancestor traverser as
before but finish once eiditing node is reached.

Pass instance selector for each webstudio-component ot identify selected
and editing instances.
2023-03-24 23:06:31 +07:00
Bogdan Chadkin bac73301c8 Refactor insert and reparent operations with selectors (#1283)
- in many places root check can be replaced with selector.length === 1
- reparent and insert utilities now accept selectors
- findClosestDroppableTarget output end instead of last index and always
fallback to root
2023-03-24 14:56:30 +07:00
Bogdan Chadkin f1750dde04 Refactor canvas drag and drop to rely on instance selectors (#1278)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1116

Drag payload produce 2 kinds of actions insert and reparent and output
tree compatible drop target.
2023-03-23 16:35:55 +07:00
Bogdan Chadkin 863ca74688 Replace tree preview with navigator tree (#1239)
Ref https://github.com/webstudio-is/webstudio-builder/issues/248

Tree preview requires a lot of work to support with all data changes
2023-03-23 10:24:08 +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 cd2032eddb Migrate all left updates to normalized instances (#1226)
Ref https://github.com/webstudio-is/webstudio-builder/issues/696

Here the last pieces to get rid of hacky patchInstancesMutable utility.
Now will be easier to integrate slots.
2023-03-11 19:23:31 +03:00
Bogdan Chadkin e888ddd4cd Export instances tree lookup from project-build (#1219)
This utility is needed to filter loaded data per page on published
sites. We aleady have it in builder so easy to move.
2023-03-10 13:30:03 +03:00
Bogdan Chadkin 57c39c4a52 Paste markdown as normalized instances (#1195)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

Refactored markdown parser to produce normalized instances and added
multiple roots support for insert utility.

Note: can be reviewed with hidden spaces
2023-03-08 23:06:04 +03:00
Bogdan Chadkin 37ed4b7820 Copy data before paste (#1167)
Here changed data flow a little. Instead of cloning data on copy.
Clipboard store original as is and insert with new ids on every paste.
2023-03-02 21:33:25 +03:00
Bogdan Chadkin 22c13b8972 Migrate delete normalized instances (#1163)
We found a bug a bug after release. Any instances changes on the page
erase instances of other pages.

Recently I migrated to normalized instances though didn't have time to
migrate utilities and just added patchInstancesMutable utility to
synchronize changes from denormalized rootInstance to normalized
instances.

Though after merging instances of all pages into single list this
synchronization started to clear instances not found in rootInstance.

To solve this I stopped clearing instances in patchInstancesMutable and
migrate delete instances utility to mutating normalized instances
directly.
2023-03-02 11:47:00 +03:00
Bogdan Chadkin bfeda0ff08 Find closest rich text with instances index (#1093)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

Previous findClosestNonInlineParent required additional check to handle
drag of root instance or editing non rich text.

Now we can simplify logic because we know exact component type of
matched instance.
2023-02-21 15:22:52 +03:00
Bogdan Chadkin 86178234ab Refactor getInstancePath with instances index (#1080)
Ref https://github.com/webstudio-is/webstudio-designer/issues/696

We no longer need to traverse tree to access parents. Index provide
precomputed map of instance to parent.

## Code Review

- [ ] hi @kof, I need you to do
  - conceptual review (architecture, feature-correctness)
  - test it on preview
- [ ] hi @istarkov, I need you to do
  - 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-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-02-20 12:31:23 +03:00
Andras Bacsai ac413cdd5f rename designer to builder 2023-02-14 11:15:24 +01:00