File tree Expand file tree Collapse file tree 2 files changed +25
-12
lines changed Expand file tree Collapse file tree 2 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -347,12 +347,7 @@ class _ExampleEditorState extends State<ExampleEditor> {
347
347
elevation: 5 ,
348
348
onPressed: () {
349
349
setState (() {
350
- _debugConfig = _debugConfig != null
351
- ? null
352
- : const SuperEditorDebugVisualsConfig (
353
- showFocus: true ,
354
- showImeConnection: true ,
355
- );
350
+ _docEditor.execute ([InsertInlinePlaceholderAtCaretRequest (ExamplePlaceholder ())]);
356
351
});
357
352
},
358
353
child: const Icon (
@@ -415,6 +410,7 @@ class _ExampleEditorState extends State<ExampleEditor> {
415
410
selectionColor: Colors .red.withValues (alpha: 0.3 ),
416
411
),
417
412
stylesheet: defaultStylesheet.copyWith (
413
+ inlineWidgetBuilders: [inlineWidgetBuilder],
418
414
addRulesAfter: [
419
415
if (! isLight) ..._darkModeStyles,
420
416
taskStyles,
@@ -548,3 +544,23 @@ final _darkModeStyles = [
548
544
},
549
545
),
550
546
];
547
+
548
+ Widget ? inlineWidgetBuilder (BuildContext context, TextStyle textStyle, Object placeholder) {
549
+ if (placeholder is ! ExamplePlaceholder ) {
550
+ return null ;
551
+ }
552
+
553
+ return LineHeight (
554
+ style: textStyle,
555
+ child: Container (
556
+ color: Colors .red,
557
+ padding: EdgeInsets .symmetric (horizontal: 8 ),
558
+ child: Text (
559
+ 'placeholder' ,
560
+ style: textStyle,
561
+ )));
562
+ }
563
+
564
+ class ExamplePlaceholder {
565
+ const ExamplePlaceholder ();
566
+ }
Original file line number Diff line number Diff line change 1
1
import 'package:example/demos/example_editor/_example_document.dart' ;
2
+ import 'package:example/demos/example_editor/example_editor.dart' ;
3
+ import 'package:example/l10n/app_localizations.dart' ;
2
4
import 'package:flutter/material.dart' ;
3
- import 'package:flutter_gen/gen_l10n/app_localizations.dart' ;
4
5
import 'package:flutter_localizations/flutter_localizations.dart' ;
5
6
import 'package:logging/logging.dart' ;
6
7
import 'package:super_editor/super_editor.dart' ;
@@ -79,11 +80,7 @@ class _DemoState extends State<_Demo> {
79
80
return Row (
80
81
children: [
81
82
Expanded (
82
- child: _StandardEditor (
83
- document: _document,
84
- composer: _composer,
85
- editor: _docEditor,
86
- ),
83
+ child: ExampleEditor (),
87
84
),
88
85
_buildToolbar (),
89
86
],
You can’t perform that action at this time.
0 commit comments