Skip to content

Commit 87bc4bf

Browse files
committed
updates
1 parent 2793ef8 commit 87bc4bf

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

super_editor/example/lib/demos/example_editor/example_editor.dart

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff 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+
}

super_editor/example/lib/main_super_editor.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
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';
24
import 'package:flutter/material.dart';
3-
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
45
import 'package:flutter_localizations/flutter_localizations.dart';
56
import 'package:logging/logging.dart';
67
import '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
],

0 commit comments

Comments
 (0)