Commit Graph
33 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
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 39ee44b94e experimental: add system variable (#2997)
Ref https://github.com/webstudio-is/webstudio/issues/2903

Here added system variable to every page body instance. It will be used
to replace path params and support search params.

For now will be hidden until cms launch.

Added migration to modify every page in all projects. Added logic to
create and duplicate system data source along with pages.
2024-03-13 12:26:07 +07: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 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
Oleg Isonen 5a5382c975 feat: Page folders (#2745)
Ref https://github.com/webstudio-is/webstudio/issues/404

## Description

Implement ablity to organize pages in folders, not a complete
implementation, only:

- Implements data structure for folders
- Allows to create folders and select a parent folder from a folder
- Reparents orphaned pages/folders for the future collaboration mode

## Steps for reproduction

1. open pages
2. add folders
3. nest folders
4. delete folders

## 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-01-13 16:39:57 +01: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 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 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 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 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 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 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 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 b7081f3741 Add sdk-components-react package (#1693)
Ref https://github.com/webstudio-is/webstudio-builder/issues/1129

Splitted base components into separate package. Exposed 3 entry points

- @webstudio-is/sdk-components-react
- @webstudio-is/sdk-components-react/metas
- @webstudio-is/sdk-components-react/props
2023-06-03 09:58:04 +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