Commit Graph
102 Commits
Author SHA1 Message Date
Ivan Starkov 38d49f9f69 feat: Add native select control (#3616)
## Description

rename of #3609

## New

- Native Select

## Changes

- Improved detection algorithm to include invisible elements (like
`option` or `display:none`).
- Added interceptor to handle pointer down events, preventing select
from opening.
- Enhanced element selection on canvas to support `display:none` and
option selection.
- Fixed prop types generation (previously, the value property was
broken).
- Memory props has effect on canvas only
- Recreate component on Canvas in case of defaultValue has changed


## Steps for reproduction

Add `Select` 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-26 07:07:37 +03:00
Bogdan Chadkin 56fbabf56d fix: clear format in text toolbar (#3544)
Here upgraded to the latest lexical version
and fixed the issue with updating buttons state
after format clearing.

<img width="321" alt="Screenshot 2024-06-12 at 16 59 26"
src="https://github.com/webstudio-is/webstudio/assets/5635476/7753070d-f627-4ac6-bee9-159dad9447eb">
2024-06-13 02:35:28 +03:00
Bogdan Chadkin 193d446aeb fix: show error on canvas when collection data is invalid (#3486)
Fixes https://github.com/webstudio-is/webstudio/issues/3481
https://github.com/webstudio-is/webstudio/issues/3473

<img width="964" alt="Screenshot 2024-06-04 at 12 54 22"
src="https://github.com/webstudio-is/webstudio/assets/5635476/569fbbb1-df82-40dd-a897-0bda2d28a2de">
2024-06-04 20:32:05 +03:00
Oleg Isonen 59ff9c23db refactor: Move text placeholders to meta templates (#3410)
## Description

Part of https://github.com/webstudio-is/webstudio/issues/3149 this
allows us to understand if an instance has text child.
With this knowledge we can place instances into components that don't
have text children and after them if they do.

## Steps for reproduction

1. insert text or paragraph
2. see there is expected placeholder text which is editable
3. select it, tell AI to change color or something
4. see it works and see in payload it didn't send placeholder text
5. try text editing on empty body - shouldn't allow it

## 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-05-24 13:53:19 +02:00
Bogdan Chadkin 4579e638e4 fix: show drop stub when collection is empty (#3391)
Empty stub was used as drop target in empty collection. Missing stub
does not work for this case.

<img width="655" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5635476/2cea1b50-3493-4073-a9d7-9a686f8c5eb5">
2024-05-20 23:15:35 +03:00
Bogdan Chadkin 1cb8225a67 fix: show visually missing component in canvas (#3383)
AI sometimes adds components we don't have
here is just a hint for user that some component is missing.

<img width="686" alt="Screenshot 2024-05-19 at 14 25 16"
src="https://github.com/webstudio-is/webstudio/assets/5635476/7ca3faee-7703-4d02-9786-5f5f0a6193d0">

Here's json to paste

```json
{
  "@webstudio/template": [
    {
      "type": "instance",
      "component": "ContentEmbed",
      "children": []
    }
  ]
}
```
2024-05-20 09:07:33 +03:00
Ivan Starkov 36d477e5f5 fix: Slow performance on a large site during text editing (#3351)
## Description

Update edited element on blur


https://fast-canvas-edit.development.webstudio.is/builder/ab3439dc-8eab-4050-a5b4-71247fba7d4c

## 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-14 19:19:04 +03:00
Bogdan Chadkin 6afc136bc1 build: drop eslint-plugin-react (#3332)
Most rules protect from legacy and class component apis.
Many rules are checked by typescript.
A few rules just do not bring much value.
The package brings too many dependencies.
2024-05-09 14:46:30 +04:00
Bogdan Chadkin cacfbee307 experimental: add content embed aka rich text component (#3315)
Ref https://github.com/webstudio-is/webstudio/issues/2903

Embed Content is a component with a way to bind html from cms with
ability to style itself and all descendants generated from cms rich
text. All Content Embed children are "virtual" Descendant instances with
predefined selector.

<img width="1404" alt="image"
src="https://github.com/webstudio-is/webstudio/assets/5635476/8d7cf210-32cb-4e63-bfe7-8af8c3e2d78d">
2024-05-09 13:20:47 +04:00
Bogdan Chadkin 305436f820 experimental: add descendent component (#3313)
Ref https://github.com/webstudio-is/webstudio/issues/2903

Here added support for new `<ws:descendent />` component. It allows to
style any children or descendents of components. Primary usage is for
embed content which renders html and need to style tags.

Descendent component accepts "selector" prop which can be suffix like `
img`, ` .image` or `::first-child` pseudo-element.

Potentially it could be used as tag styling for any element.

Can be tested in any element by dropping "Descendent" component from
"internal" category.
2024-05-06 23:36:34 +04:00
Bogdan Chadkin 9f897f5d41 refactor: reimplement canvas style renderer (#3253)
Here refactored canvas styles with nesting rules which allow to update
each declaration incrementally and closer to our data format.

Things to test
- initial rendering
- updating values
- ephemeral values
- selecting state, rendered as separate stylesheet

Added shim.ts to contain simplified polyfills for future methods like
Set.prototype.difference which I use here to find added and deleted
styles.

Removed warning from parseCssValue which pollutes log with outdated
messages.

Additionally fixed old bugs
- support ephemeral styles with selector state, for example hover was
not updated on on canvas while updating ephemeral styles
- remove ephemeral custom property from body (bug appeared when added
support ephemeral styles in tokens)
2024-05-02 17:51:09 +04:00
Bogdan Chadkin 9d76108d3b fix: Fix deleting a link in rich text (#3150)
Fixes https://github.com/webstudio-is/webstudio/issues/3127

Here fixed the issue with deleting remix link while editing rich text
with lexical. Some quirky remix logic broke react rendering. Fixed by
rendering plain link while in builder.
2024-04-13 00:04:52 +07:00
Ivan Starkov 3205c81c51 fix: Broken rich text panel (#3095)
Broke rich text, what to do is written in reopened issue.
https://github.com/webstudio-is/webstudio/issues/3021
2024-04-04 22:10:47 +07:00
Ivan Starkov 348b5709b5 fix: Text Content does not propagate changes from Settings Panel if Previous Edit was on Canvas (#3040)
## Description

Closes #3021

The issue was that TextEditor when you switch on setting panel were
active and in no way synchronized with state having it's uncontrollable
nature.

Here we are disabling editing mode on editor blur.


## 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-25 19:02:50 +03:00
Oleg Isonen cd0174807d chore: use console.info instead of console.log (#3049)
## Description

We allow console.info (btw we should also allow warn/error/info), we
only disallow console.log in the linter because that's what we use for
debugging.

## Steps for reproduction

1. click button
2. expect xyz

## 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-03-24 12:52:46 +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
Bogdan Chadkin c0702ba10a fix: polish collection component (#2767)
Ref https://github.com/webstudio-is/webstudio/issues/2532

- fixed collection icon color
- allow to specify expression in embed template children
- tweaked default collection template
- allow to specify variable aliases in embed template children
- renamed collectionItem variable to Collection Item
- moved collection component to "Data" category
- fix broken canvas when bind object to text content
- add better tooltips why cannot remove parameter and used variables
2024-01-16 15:13:18 +07:00
Bogdan Chadkin ed188ef215 feat: support binding in text content (#2756)
Ref https://github.com/webstudio-is/webstudio/issues/2532

- added new expression type to instance children
- added binding to text content setting
- prevented deleting variable bound to instance child
- rendered computed child in canvas and preview
- supported expression child in component generator

What's missing

- copy paste support (will add later)

<img width="880" alt="Screenshot 2024-01-13 at 09 59 58"
src="https://github.com/webstudio-is/webstudio/assets/5635476/1275d5b3-420b-4f97-9d72-407ff39932e5">
2024-01-13 16:50:08 +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
Oleg Isonen c6bdef5084 feat: CSS engine has now a Style Sheet rendering with atomic classes which will lead to a 10x smaller bundle size (#2713)
## Description

CSS engine has now a Style Sheet rendering with atomic classes which
will lead to a much smaller bundle size

## 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
2023-12-30 21:08:37 +01: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 3cfa10ae22 refactor: compute props contextually (#2628)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Here refactored props values computing to reuse in both canvas and
settings panel and support future collections which need to provide
different values for same variables.

Grouped whole logic and covered with tests.

## Testing

- check image src is working
- check link switch page in preview
2023-11-18 20:54:51 +03:00
Bogdan Chadkin f3a75d150a refactor: simplify text child rendering (#2611)
Remove responsibility for text rendering from webstudio component to
instances tree renderer. Will simplify future collection management.
2023-11-14 16:41:35 +03:00
Bogdan Chadkin 4e9986d6e3 refactor: inline expressions into props (#2603)
Ref https://github.com/webstudio-is/webstudio/issues/2532

Collections will introduce nested scope within same component and some
expressions at component scope will not be able to access collection
item. For example

```ts
const PageComponent = () => {
  let [value, set$value] = useState('')
  let show = value === 'error'
  let arialabel = item + ' label'
  return <Form>
    <ErrorMessage data-ws-show={show}></ErrorMessage>
    {list.map(item =>
      <Button aria-label={arialabel}></Button>
    )}
  </Form>
}
```

So the easiest way to workaround it without complicated scope selecting
is just inline all expressions into props.

```ts
const PageComponent = () => {
  let [value, set$value] = useState('')
  return <Form>
    <ErrorMessage data-ws-show={value === 'error'}></ErrorMessage>
    {list.map(item =>
      <Button aria-label={item + ' label'}></Button>
    )}
  </Form>
}
```

## Steps for reproduction

1. Create `Form`
2. Try to change `state` prop
2023-11-12 13:07:14 +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 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 4ddac0e7ff refactor: replace editor events with commands (#2508)
Ref https://github.com/webstudio-is/webstudio/issues/2354

We are moving away from emitting events and subscriptions. Here migrated
lexical toolbar to canvas commands.

Command handlers rely on global active editor to update currently edited
instance.

In the future we can explore alternative way to synchronize text editor
between builder and canvas with yjs.
2023-10-19 20:28:48 +04:00
Bogdan Chadkin 00826c636a fix: fix various text editor bugs (#2420)
- add missing placeholder to Text component
- fix wrapping buttons and links with span
- preserve node content when entering editing mode if instance has no
children
- hide "link" button in text toolbar when edit link component to prevent
nested links
2023-10-06 01:37:38 +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 22a1067ed6 refactor: move props logic to canvas (#2361)
Moved canvas props logic from react-sdk to builder. Added new context to
pass props store, not global because depends on params.
2023-09-25 14:17:40 +04:00
Bogdan Chadkin 87e69b2e85 Move style schema into css-engine (#2251)
Css-data now responsible for generated data and parsers which requires
heavy dependencies like csstree and openai.

Here moved style schema into css-engine which makes is responsible for
own input representation. So now schema and serialization are co-located
in single package.

Cli install size

```diff
du -ck node_modules
- 42680
+ 35516
```
2023-09-06 15:55:41 +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 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 86ff9d406d Improve radix components (#2201)
Here addressed of some recent feedback

- removed cursor: pointer from all buttons
- added active states to accordion and tabs triggers
- replaced X with svg icon in dialog and sheet close button
- updated item icon for all components
- removed dir and orientation props from accordion initials
2023-08-28 20:04:26 +04:00
Bogdan Chadkin c48f6613a8 Fix focus navigation in preview (#2179)
Ref https://github.com/webstudio-is/webstudio-builder/issues/2151
https://github.com/webstudio-is/webstudio-builder/pull/2112

Here splitted webstudio component wrapper for preview and canvas. This
allows us to have more granular control over preview behavior. For
example canvas requres all elements to be focusable for instance
selection to work. Prevew should be close to published sites and reflect
user experience.
2023-08-25 17:47:40 +04:00
Bogdan Chadkin 75c5cdc179 Prevent editing of radix input and textarea in canvas mode (#2160)
Ref https://github.com/webstudio-is/webstudio-builder/issues/2151

Here added new logic to intercept bubbled to html element events

- handle click on links in preview
- prevent forms submit
- prevent keydown on input and textarea in canvas

This allows to remove some props overrides from webstudio component and
fixes editing of radix input and textarea.
2023-08-25 00:25:16 +04:00
Bogdan Chadkin 0679c9eef8 Improve props bypassing in canvas (#2088)
Here fixing the issue with props not bypassed from parent component in
canvas mode. This is important for radix triggers with asChild which
bypass props to child button.
2023-08-10 18:57:59 +04:00
Ivan Starkov da7e17b2fe Fix button duplicate text on edit (#2066)
## Description

Double click on button cause text duplication

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



## 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-08-08 01:12:50 +03:00
Ivan Starkov 7d635c4940 Fix Toolbar dissapears in the tooltip (#2061)
## Description

Fixes 3

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

Toolbar selection is not working inside tooltip content text.

## Steps for reproduction

Open tooltip, start editing tooltip content text. Select some text with
mouse. Mouse is now visible

## 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-08-06 19:00:24 +03:00
Ivan Starkov 3df5c96a9c Fix jumps on editing text inside tooltips, and probably other components (#2054)
## Description


![image](https://github.com/webstudio-is/webstudio-builder/assets/5077042/dc764c12-8612-4ea4-9a07-46384a8ed5a7)

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

## 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-08-06 14:09:57 +03:00
Ivan Starkov 1b4b2db376 Partially fix tooltip trigger editing (#2041)
## Description

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

<img width="180" alt="image"
src="https://cdn.discordapp.com/attachments/1137094092417941695/1137094092640231454/Screen_Recording_2023-08-04_at_21.43.44.gif">

Fixes positioning. But still have tooltip content blink, seems like
tooltip doesn't like changing trigger on the fly.

Blinking will not be fixed until we change how editor works

I created a simple reproducible example changing the trigger using
setInterval and get same behaviour as we have

![Screen Recording 2023-08-05 at 10 00
02](https://github.com/webstudio-is/webstudio-builder/assets/5077042/67655855-4b61-41a3-9ea4-c4664c0ebf38)





## 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-08-05 21:10:24 +03:00
Ivan Starkov 4f10bc26f8 Attempt to hover/select without element (#2014)
## Description

Removes `div style="display:contents"` arount Radix etc Components.

Below in Implementation is written why SelectedInstanceConnector was
moved into standalone root level hook.
In short
- [x] - No issues with visually hidden components.
- [x] - Allows us to not use refs for the builder support. (Now our
components can be without refs)
- [ ] - cc @TrySound ContentEditable could also use
getAllElementsBoundingBox from domUtils to get element ref this will
allow to remove useRef from WebstudioDevComponent

Changes from previous behavior:

- Now on preview elements are not selected (now is like in webflow).
- On changing marign etc we do not hide outline as before



## Implementation: 

having `instanceSelector` we can 
- Find all elements with attribute `data-ws-selector` which ends with
`instanceSelector`
- Then find "root/parent" elements of found elements. _(We can find few
subtrees)_
- Then use that elements instead of wrapper element.

This works fine with tree hovering and selections.
This allows us to not use `refs` inside our WebstudioDevComponent at
all.

### Below is why SelectedInstanceConnector was rewritten

The issue arises when such element is duplicated by radix into
VisuallyHidden element.

There is no way to detect now inside `WebstudioComponentDev` does
current Component is inside VisuallyHidden
(We have no reference element to detect that.)

So current approach makes any additional changes useless.
I'm going to close this. And leave just for example




## 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-08-04 13:34:14 +03:00
Bogdan Chadkin 6500e01397 Move getBrowserStyle utility into builder (#2004)
getBrowserStyle is used only inside of builder and should not be part of
sdk importable by all component libraries. It also depends on global
types which need to be included in every package dependent on react-sdk.
2023-07-30 20:56:29 +04:00
Ivan Starkov 74092f66bf Add radix popover (#1997)
## Description

 - [x] - clicks not working

## 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-07-27 23:35:00 +03:00
Ivan Starkov a190deb48b Fix selection on visually hidden elements (#1996)
## Description
Avoid any selection on Visually Hidden elements

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


## 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-07-27 17:29:42 +03:00
Ivan Starkov f5cbd28962 Add tooltip (#1957)
## Description

Left
- [ ] - storybook (next PR)
- [ ] - default styles (next PR)
- [x] - Add property to edit tooltip
- [ ] - Contraints - do not allow delete Trigger and Content (next PRs)
- [ ] - Icons  (next PRs)

### Whats done to make tooltip to work.

1. Portals support through passing
[selectorIdAttribute](https://github.com/webstudio-is/webstudio-builder/blob/20c3b9fdea4a6f8e7a2cc00211b6e4ca95db13a5/apps/builder/app/canvas/features/webstudio-component/webstudio-component.tsx#L290)
2. [Hidden ScreenReader elements
detection](https://github.com/webstudio-is/webstudio-builder/blob/20c3b9fdea4a6f8e7a2cc00211b6e4ca95db13a5/apps/builder/app/canvas/features/webstudio-component/webstudio-component.tsx#L129)
3. [New elements on Canvas
detection]https://github.com/webstudio-is/webstudio-builder/blob/20c3b9fdea4a6f8e7a2cc00211b6e4ca95db13a5/apps/builder/app/canvas/features/webstudio-component/webstudio-component.tsx#L179



- [x] Collapsed
- [x] Do composeEventHandlers 
- [x] Radix add spans of tooltip content 
To support screen readers

https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
Radix here

https://github.com/radix-ui/primitives/blob/main/packages/react/tooltip/src/Tooltip.tsx#L552-L556
Cloning our content

https://github.com/radix-ui/primitives/blob/main/packages/react/visually-hidden/src/VisuallyHidden.tsx

## Steps for reproduction

1. click button
3. 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-07-24 14:50:15 +03:00
Bogdan Chadkin 05df3910f5 Support effectful expressions in component actions (#1914)
Here added support for callbacks or event handlers on components which
basically can do only assignment to variables for now with extended
(with assignment operator) syntax of expressions.
2023-07-11 20:27:06 +03:00
Ivan StarkovandOleg Isonen 7632b05fe7 Fix hash scroll (#1861)
## Description

closes #1824

- [x] single edgecase left if id is equal to `hello%20world` nothing
works
- [x] fix back button cause chrome bug
https://discord.com/channels/955905230107738152/1122839004375691355
- [x] allow edit form in preview mode to close issue above

Fix corresponding issue in RR
https://github.com/remix-run/react-router/pull/10642

At SaaS patched too

## Steps for reproduction

create links on pages with anchor
<img width="254" alt="image"
src="https://github.com/webstudio-is/webstudio-builder/assets/5077042/46a880f3-cdd0-4e19-8cb4-b608bdc4f96a">

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

---------

Co-authored-by: Oleg Isonen <oleg008@gmail.com>
2023-06-28 10:06:54 +04:00