Commit Graph
17 Commits
Author SHA1 Message Date
Bogdan Chadkin 94b1fb9951 fix: consider Text and Link components as rich text (#5334)
This prevents editing Text and Link components parent and instead
enforces editing these components as rich text containers.
2025-07-23 20:50:24 +02:00
Bogdan Chadkin df9fecff3b fix: ignore content model checks for XmlNode component (#5268)
We rely on "tag" in legacy components though it is primary way to setup
tag on xml nodes. Here added exception for all xml components.
2025-06-11 15:10:50 +03:00
Bogdan Chadkin b64a0c077a fix: accept <source> as <video> child (#5264)
Transparent category was overriden by parent categories without merging
others from current element.
2025-06-10 18:42:38 +03:00
Bogdan Chadkin c630054c74 feat: use html elements for typography (#5226)
Html elements can completely replace legacy typography components. Here
replace component templates with element templates as part of sdk.

- moved content block to general section
- moved separator into typography section
- moved code text into typography section and used regular `<code>`
element for it
- made "Text Content" setting expandable
- fixed dragging templates onto canvas.

<img width="475" alt="Screenshot 2025-05-21 at 11 27 27"
src="https://github.com/user-attachments/assets/ab53c5ec-e51f-498d-b01b-cc7f2eb20c2d"
/>
<img width="515" alt="Screenshot 2025-05-21 at 11 27 20"
src="https://github.com/user-attachments/assets/0f560c26-7e51-4025-a487-6f7e4e3f43e3"
/>
2025-05-21 15:26:05 +03:00
Bogdan Chadkin 88c467c72a fix: make all radix components uncontrolled (#5227)
Here improved handling radix states by making all components
uncontrolled yet still synchronizing external state with local one.
2025-05-21 14:20:40 +03:00
Bogdan Chadkin 90aa42422d experimental: support html elements in content block (#5216)
Ref https://github.com/webstudio-is/webstudio/issues/3632

Now content block is relying on instances tags instead of component
names. Tested all cases. Should work smoothly.

Also dialog title now have placeholders inferred from tag as well
<img width="1025" alt="image"
src="https://github.com/user-attachments/assets/4c7817fb-cf68-4d61-a672-213b1e8d1cc7"
/>
2025-05-18 00:29:50 +03:00
Bogdan Chadkin 29e455a9b7 fix: remove Text Content property from Image component (#5195)
Was accidentally added when rewriting content model.

Also fixed two other issues

- user can override text color in error boundary with global root
- text content property now have tooltip with description and it can be
reset

<img width="320" alt="Screenshot 2025-05-10 at 18 14 19"
src="https://github.com/user-attachments/assets/ffb16efc-e7b5-44d1-a214-0a9251e9eb9d"
/>
2025-05-11 01:10:27 +04:00
Bogdan Chadkin 59b6471c4f experimental: support paste html (#5185)
Ref https://github.com/webstudio-is/webstudio/issues/4404

Slightly reworked paste story. Now minimal API to insert html looks like
this

```js
const fragment = generateFragmentFromHtml(html);
insertWebstudioFragmentAt(fragment);
```

- attributes are casted to string, number and boolean types
- text is wrapped with spans when outside of rich text
- unsupported tags are ignored in result



https://github.com/user-attachments/assets/c8072d86-72bd-4446-a26a-e678b193f93e
2025-05-06 13:31:13 +04:00
Bogdan Chadkin f13455394d feat: add descriptions to tags (#5164)
Ref https://github.com/webstudio-is/webstudio/issues/3632

Scraped descriptions from html spec to show in tag control.

<img width="297" alt="Screenshot 2025-04-26 at 12 46 21"
src="https://github.com/user-attachments/assets/444e319d-e24f-429e-b09d-1db95cc248d5"
/>
2025-04-26 17:04:31 +07:00
Bogdan Chadkin a449f66c77 refactor: describe descendants in component content model (#5140)
Here replaced "transparent" keyword with more explicit "descendants"
list in component content model.

This will enable use case with child constraint while allowing other
instances to be children like here

```
  contentModel: {
    category: "instance",
    children: [
      "instance",
      "AnimateText",
      "StaggerAnimation",
      "VideoAnimation",
    ],
  },
```

and descendants are described like this

```
  contentModel: {
    category: "instance",
    children: ["instance"],
    descendants: ["VimeoSpinner", "VimeoPlayButton", "VimeoPreviewImage"],
  },
```
2025-04-19 01:53:47 +07:00
Bogdan Chadkin bd77a252c2 refactor: detect empty tags and components (#5132)
Here replaced "embed" and "control" components with content model. Many
components now detect no content based on html content model like with
img or input tags. In other cases component meta can explicitly specify
empty array to not accept anything.

```
meta = {
  contentModel: {
    category: 'instance',
    children: []
  }
}
```
2025-04-17 23:23:20 +07:00
Bogdan Chadkin 3b8c58b435 refactor: use content model to detect rich text (#5109)
Ref https://github.com/webstudio-is/webstudio/issues/3632

Here I finally got rid from "rich-text-child" necessity. With html
elements in the tree it will no longer work so we need a new way to work
with rich text.

Added a few new utilities to content model which detect rich text by
text inside or any textual tags. Span and links can still be detected as
containers rather than children when not surrounded by text and other
textual elements.
2025-04-10 14:16:34 +07:00
Bogdan Chadkin 4b52aaa3dc refactor: add component content model (#5101)
Extended content model to support categories defined in component meta.
Most components has transparent children categories to pass through
constraints from parent, this way we allow descendants with non
category.

Here migrated only core and base components.
Will extend more for animations in another PR.
2025-04-08 13:09:54 +07:00
Bogdan Chadkin 31212266c7 refactor: paste new tag with webflow and markdown (#5092)
Ref https://github.com/webstudio-is/webstudio/issues/3632

Here migrated webflow and markdown paste plugins to instance.tag to
avoid adding more legacy "tag" prop.

Also fixed content model for instance.tag and rewrote its tests with
ws:element.
2025-04-05 13:52:25 +07:00
Bogdan Chadkin bb80555bc4 fix: allow placing labelable elements inside of labels (#5085)
Fixes the issue reported in discord
(https://discord.com/channels/955905230107738152/1356788803624501370/1357299346558816306)

Found the spec actually allows to place button and input inside a label.
So now we can generalize this logic.

Also content model validation no longer prevents inserting invalid
structure and only warns user is something went wrong. This will let us
to never block the user with false positives and maybe even figure out
the issue on their own.

<img width="993" alt="Screenshot 2025-04-04 at 01 28 53"
src="https://github.com/user-attachments/assets/46eb041f-2431-4140-b34e-8bc9ad757c47"
/>
2025-04-04 14:32:23 +07:00
Bogdan Chadkin a9ec11b90e fix: add more insert edge cases (#5078)
We introduced html content model which restricts how html elements can
be nested into each other. Here fixed two edge cases

- allow to put div into buttons, headings or any other phrasing content
- allow put images into interactive elements like a > img
2025-04-02 18:19:23 +07:00
Bogdan Chadkin d5bc0f9760 feat: enforce html content model (#5074)
Ref https://github.com/webstudio-is/webstudio/issues/3632

This is a big step into native html elements support. I scraped content
model from html spec and now enforcing all html tags structure so we no
longer need to write custom restrictions.

Now paragraph cannot be nested into heading. Box cannot be nested into
span Text though still can in div Text. Any interactive elements cannot
be nested automatically. List item should have a list as direct parent
(collection and slot are exception because they don't have elements
inside).

Most rules are defined in this table
https://html.spec.whatwg.org/multipage/indices.html#elements-3
2025-04-01 22:07:56 +07:00