File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -347,12 +347,7 @@ class _ExampleEditorState extends State<ExampleEditor> {
347347 elevation: 5 ,
348348 onPressed: () {
349349 setState (() {
350- _debugConfig = _debugConfig != null
351- ? null
352- : const SuperEditorDebugVisualsConfig (
353- showFocus: true ,
354- showImeConnection: true ,
355- );
350+ _docEditor.execute ([InsertInlinePlaceholderAtCaretRequest (ExamplePlaceholder ())]);
356351 });
357352 },
358353 child: const Icon (
@@ -415,6 +410,7 @@ class _ExampleEditorState extends State<ExampleEditor> {
415410 selectionColor: Colors .red.withValues (alpha: 0.3 ),
416411 ),
417412 stylesheet: defaultStylesheet.copyWith (
413+ inlineWidgetBuilders: [inlineWidgetBuilder],
418414 addRulesAfter: [
419415 if (! isLight) ..._darkModeStyles,
420416 taskStyles,
@@ -548,3 +544,23 @@ final _darkModeStyles = [
548544 },
549545 ),
550546];
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 11import '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' ;
24import 'package:flutter/material.dart' ;
3- import 'package:flutter_gen/gen_l10n/app_localizations.dart' ;
45import 'package:flutter_localizations/flutter_localizations.dart' ;
56import 'package:logging/logging.dart' ;
67import 'package:super_editor/super_editor.dart' ;
@@ -79,11 +80,7 @@ class _DemoState extends State<_Demo> {
7980 return Row (
8081 children: [
8182 Expanded (
82- child: _StandardEditor (
83- document: _document,
84- composer: _composer,
85- editor: _docEditor,
86- ),
83+ child: ExampleEditor (),
8784 ),
8885 _buildToolbar (),
8986 ],
You can’t perform that action at this time.
0 commit comments