@@ -36,8 +36,6 @@ import {
36
36
getIndexesWithinAncestors ,
37
37
type AnyComponent ,
38
38
textContentAttribute ,
39
- editingPlaceholderVariable ,
40
- editablePlaceholderVariable ,
41
39
} from "@webstudio-is/react-sdk" ;
42
40
import { rawTheme } from "@webstudio-is/design-system" ;
43
41
import {
@@ -68,8 +66,10 @@ import {
68
66
} from "~/canvas/elements" ;
69
67
import { Block } from "../build-mode/block" ;
70
68
import { BlockTemplate } from "../build-mode/block-template" ;
71
- import { getInstanceLabel } from "~/shared/instance-utils" ;
72
- import { editablePlaceholderComponents } from "~/canvas/shared/styles" ;
69
+ import {
70
+ editablePlaceholderAttribute ,
71
+ editingPlaceholderVariable ,
72
+ } from "~/canvas/shared/styles" ;
73
73
74
74
const ContentEditable = ( {
75
75
placeholder,
@@ -376,19 +376,14 @@ const getEditableComponentPlaceholder = (
376
376
metas : Map < string , WsComponentMeta > ,
377
377
mode : "editing" | "editable"
378
378
) => {
379
- if ( ! editablePlaceholderComponents . includes ( instance . component ) ) {
379
+ const meta = metas . get ( instance . component ) ;
380
+ if ( meta ?. placeholder === undefined ) {
380
381
return ;
381
382
}
382
383
383
384
const isContentBlockChild =
384
385
undefined !== findBlockSelector ( instanceSelector , instances ) ;
385
386
386
- const meta = metas . get ( instance . component ) ;
387
-
388
- const label = meta
389
- ? getInstanceLabel ( instance , meta )
390
- : ( instance . label ?? instance . component ) ;
391
-
392
387
const isParagraph = instance . component === "Paragraph" ;
393
388
394
389
if ( isParagraph && isContentBlockChild ) {
@@ -398,7 +393,7 @@ const getEditableComponentPlaceholder = (
398
393
undefined ;
399
394
}
400
395
401
- return label ;
396
+ return meta . placeholder ;
402
397
} ;
403
398
404
399
export const WebstudioComponentCanvas = forwardRef <
@@ -498,14 +493,6 @@ export const WebstudioComponentCanvas = forwardRef<
498
493
Component = BlockTemplate ;
499
494
}
500
495
501
- const placeholder = getEditableComponentPlaceholder (
502
- instance ,
503
- instanceSelector ,
504
- instances ,
505
- metas ,
506
- "editable"
507
- ) ;
508
-
509
496
const mergedProps = mergeProps ( restProps , instanceProps , "delete" ) ;
510
497
511
498
const props : {
@@ -514,20 +501,19 @@ export const WebstudioComponentCanvas = forwardRef<
514
501
[ selectorIdAttribute ] : string ;
515
502
} & Record < string , unknown > = {
516
503
...mergedProps ,
517
- ...( placeholder !== undefined
518
- ? {
519
- style : {
520
- ...mergedProps . style ,
521
- [ editablePlaceholderVariable ] : `'${ placeholder . replaceAll ( "'" , "\\'" ) } '` ,
522
- } ,
523
- }
524
- : null ) ,
525
504
// current props should override bypassed from parent
526
505
// important for data-ws-* props
527
506
tabIndex : 0 ,
528
507
[ selectorIdAttribute ] : instanceSelector . join ( "," ) ,
529
508
[ componentAttribute ] : instance . component ,
530
509
[ idAttribute ] : instance . id ,
510
+ [ editablePlaceholderAttribute ] : getEditableComponentPlaceholder (
511
+ instance ,
512
+ instanceSelector ,
513
+ instances ,
514
+ metas ,
515
+ "editable"
516
+ ) ,
531
517
} ;
532
518
533
519
// React ignores defaultValue changes after first render.
0 commit comments