Skip to content

Commit 4b3ea8f

Browse files
knoppmatthew-carroll
authored andcommitted
[SuperEditor][SuperReader] - Push SliverToBoxAdapter down to SingleColumnDocumentLayout (#1916)
1 parent 4f7434c commit 4b3ea8f

File tree

40 files changed

+878
-726
lines changed

40 files changed

+878
-726
lines changed

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,10 @@ class _ExampleEditorState extends State<ExampleEditor> {
149149
// text.
150150
// TODO: switch this to use a Leader and Follower
151151
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
152-
final docBoundingBox = (_docLayoutKey.currentState as DocumentLayout)
153-
.getRectForSelection(_composer.selection!.base, _composer.selection!.extent)!;
154-
final docBox = _docLayoutKey.currentContext!.findRenderObject() as RenderBox;
155-
final overlayBoundingBox = Rect.fromPoints(
156-
docBox.localToGlobal(docBoundingBox.topLeft),
157-
docBox.localToGlobal(docBoundingBox.bottomRight),
158-
);
152+
final layout = _docLayoutKey.currentState as DocumentLayout;
153+
final docBoundingBox = layout.getRectForSelection(_composer.selection!.base, _composer.selection!.extent)!;
154+
final globalOffset = layout.getGlobalOffsetFromDocumentOffset(Offset.zero);
155+
final overlayBoundingBox = docBoundingBox.shift(globalOffset);
159156

160157
_textSelectionAnchor.value = overlayBoundingBox.topCenter;
161158
});

super_editor/example/lib/demos/in_the_lab/feature_action_tags.dart

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -106,49 +106,48 @@ class _ActionTagsFeatureDemoState extends State<ActionTagsFeatureDemo> {
106106
}
107107

108108
Widget _buildEditor() {
109-
return IntrinsicHeight(
110-
child: SuperEditor(
111-
editor: _editor,
112-
focusNode: _editorFocusNode,
113-
componentBuilders: [
114-
TaskComponentBuilder(_editor),
115-
...defaultComponentBuilders,
116-
],
117-
stylesheet: defaultStylesheet.copyWith(
118-
inlineTextStyler: (attributions, existingStyle) {
119-
TextStyle style = defaultInlineTextStyler(attributions, existingStyle);
120-
121-
if (attributions.contains(actionTagComposingAttribution)) {
122-
style = style.copyWith(
123-
color: Colors.blue,
124-
);
125-
}
126-
127-
return style;
128-
},
129-
addRulesAfter: [
130-
...darkModeStyles,
131-
],
132-
),
133-
documentOverlayBuilders: [
134-
AttributedTextBoundsOverlay(
135-
selector: (a) => a == actionTagComposingAttribution,
136-
builder: (BuildContext context, Attribution attribution) {
137-
return Leader(
138-
link: _composingLink,
139-
child: const SizedBox(),
140-
);
141-
},
142-
),
143-
DefaultCaretOverlayBuilder(
144-
caretStyle: CaretStyle().copyWith(color: Colors.redAccent),
145-
),
146-
],
147-
plugins: {
148-
_actionTagPlugin,
109+
return SuperEditor(
110+
editor: _editor,
111+
focusNode: _editorFocusNode,
112+
componentBuilders: [
113+
TaskComponentBuilder(_editor),
114+
...defaultComponentBuilders,
115+
],
116+
shrinkWrap: true,
117+
stylesheet: defaultStylesheet.copyWith(
118+
inlineTextStyler: (attributions, existingStyle) {
119+
TextStyle style = defaultInlineTextStyler(attributions, existingStyle);
120+
121+
if (attributions.contains(actionTagComposingAttribution)) {
122+
style = style.copyWith(
123+
color: Colors.blue,
124+
);
125+
}
126+
127+
return style;
128+
},
129+
addRulesAfter: [
130+
...darkModeStyles,
131+
],
132+
),
133+
documentOverlayBuilders: [
134+
AttributedTextBoundsOverlay(
135+
selector: (a) => a == actionTagComposingAttribution,
136+
builder: (BuildContext context, Attribution attribution) {
137+
return Leader(
138+
link: _composingLink,
139+
child: const SizedBox(),
140+
);
149141
},
150142
),
151-
);
143+
DefaultCaretOverlayBuilder(
144+
caretStyle: CaretStyle().copyWith(color: Colors.redAccent),
145+
),
146+
],
147+
plugins: {
148+
_actionTagPlugin,
149+
},
150+
);
152151
}
153152

154153
Widget _buildTagList() {

super_editor/example/lib/demos/in_the_lab/feature_pattern_tags.dart

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -61,35 +61,34 @@ class _HashTagsFeatureDemoState extends State<HashTagsFeatureDemo> {
6161
}
6262

6363
Widget _buildEditor() {
64-
return IntrinsicHeight(
65-
child: SuperEditor(
66-
editor: _editor,
67-
stylesheet: defaultStylesheet.copyWith(
68-
inlineTextStyler: (attributions, existingStyle) {
69-
TextStyle style = defaultInlineTextStyler(attributions, existingStyle);
70-
71-
if (attributions.whereType<PatternTagAttribution>().isNotEmpty) {
72-
style = style.copyWith(
73-
color: Colors.orange,
74-
);
75-
}
76-
77-
return style;
78-
},
79-
addRulesAfter: [
80-
...darkModeStyles,
81-
],
82-
),
83-
documentOverlayBuilders: [
84-
DefaultCaretOverlayBuilder(
85-
caretStyle: CaretStyle().copyWith(color: Colors.redAccent),
86-
),
87-
],
88-
plugins: {
89-
_hashTagPlugin,
90-
},
64+
return SuperEditor(
65+
editor: _editor,
66+
shrinkWrap: true,
67+
stylesheet: defaultStylesheet.copyWith(
68+
inlineTextStyler: (attributions, existingStyle) {
69+
TextStyle style = defaultInlineTextStyler(attributions, existingStyle);
70+
71+
if (attributions.whereType<PatternTagAttribution>().isNotEmpty) {
72+
style = style.copyWith(
73+
color: Colors.orange,
74+
);
75+
}
76+
77+
return style;
78+
},
79+
addRulesAfter: [
80+
...darkModeStyles,
81+
],
82+
),
83+
documentOverlayBuilders: [
84+
DefaultCaretOverlayBuilder(
85+
caretStyle: CaretStyle().copyWith(color: Colors.redAccent),
9186
),
92-
);
87+
],
88+
plugins: {
89+
_hashTagPlugin,
90+
},
91+
);
9392
}
9493

9594
Widget _buildTagList() {

super_editor/example/lib/demos/in_the_lab/feature_stable_tags.dart

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -107,51 +107,50 @@ class _UserTagsFeatureDemoState extends State<UserTagsFeatureDemo> {
107107
}
108108

109109
Widget _buildEditor() {
110-
return IntrinsicHeight(
111-
child: SuperEditor(
112-
editor: _editor,
113-
focusNode: _editorFocusNode,
114-
stylesheet: defaultStylesheet.copyWith(
115-
inlineTextStyler: (attributions, existingStyle) {
116-
TextStyle style = defaultInlineTextStyler(attributions, existingStyle);
117-
118-
if (attributions.contains(stableTagComposingAttribution)) {
119-
style = style.copyWith(
120-
color: Colors.blue,
121-
);
122-
}
123-
124-
if (attributions.whereType<CommittedStableTagAttribution>().isNotEmpty) {
125-
style = style.copyWith(
126-
color: Colors.orange,
127-
);
128-
}
129-
130-
return style;
131-
},
132-
addRulesAfter: [
133-
...darkModeStyles,
134-
],
135-
),
136-
documentOverlayBuilders: [
137-
AttributedTextBoundsOverlay(
138-
selector: (a) => a == stableTagComposingAttribution,
139-
builder: (context, attribution) {
140-
return Leader(
141-
link: _composingLink,
142-
child: const SizedBox(),
143-
);
144-
},
145-
),
146-
DefaultCaretOverlayBuilder(
147-
caretStyle: CaretStyle().copyWith(color: Colors.redAccent),
148-
),
149-
],
150-
plugins: {
151-
_userTagPlugin,
110+
return SuperEditor(
111+
editor: _editor,
112+
focusNode: _editorFocusNode,
113+
shrinkWrap: true,
114+
stylesheet: defaultStylesheet.copyWith(
115+
inlineTextStyler: (attributions, existingStyle) {
116+
TextStyle style = defaultInlineTextStyler(attributions, existingStyle);
117+
118+
if (attributions.contains(stableTagComposingAttribution)) {
119+
style = style.copyWith(
120+
color: Colors.blue,
121+
);
122+
}
123+
124+
if (attributions.whereType<CommittedStableTagAttribution>().isNotEmpty) {
125+
style = style.copyWith(
126+
color: Colors.orange,
127+
);
128+
}
129+
130+
return style;
131+
},
132+
addRulesAfter: [
133+
...darkModeStyles,
134+
],
135+
),
136+
documentOverlayBuilders: [
137+
AttributedTextBoundsOverlay(
138+
selector: (a) => a == stableTagComposingAttribution,
139+
builder: (context, attribution) {
140+
return Leader(
141+
link: _composingLink,
142+
child: const SizedBox(),
143+
);
152144
},
153145
),
154-
);
146+
DefaultCaretOverlayBuilder(
147+
caretStyle: CaretStyle().copyWith(color: Colors.redAccent),
148+
),
149+
],
150+
plugins: {
151+
_userTagPlugin,
152+
},
153+
);
155154
}
156155

157156
Widget _buildTagList() {

super_editor/example/lib/demos/in_the_lab/selected_text_colors_demo.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,7 @@ class _SelectedTextColorsDemoState extends State<SelectedTextColorsDemo> {
6060
Widget build(BuildContext context) {
6161
return InTheLabScaffold(
6262
content: Center(
63-
child: IntrinsicHeight(
64-
child: _buildEditor(),
65-
),
63+
child: _buildEditor(),
6664
),
6765
supplemental: _buildControlPanel(),
6866
overlay: _buildOverlay(),
@@ -72,6 +70,7 @@ class _SelectedTextColorsDemoState extends State<SelectedTextColorsDemo> {
7270
Widget _buildEditor() {
7371
return SuperEditor(
7472
editor: _editor,
73+
shrinkWrap: true,
7574
stylesheet: defaultStylesheet.copyWith(
7675
selectedTextColorStrategy: _selectedTextColorStrategy,
7776
addRulesAfter: [

0 commit comments

Comments
 (0)