Skip to content

Commit 02cac20

Browse files
committed
Simplify class names by dropping/replacing Boustro
1 parent 156a4f9 commit 02cac20

File tree

8 files changed

+83
-83
lines changed

8 files changed

+83
-83
lines changed

example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class _HomeScreenState extends State<HomeScreen> {
142142
Navigator.of(context)
143143
.push<void>(MaterialPageRoute<void>(builder: (context) {
144144
return Scaffold(
145-
body: BoustroView(
145+
body: DocumentView(
146146
document: controller.toDocument(),
147147
),
148148
);
@@ -155,7 +155,7 @@ class _HomeScreenState extends State<HomeScreen> {
155155
body: Column(
156156
children: [
157157
Expanded(
158-
child: BoustroEditor(
158+
child: DocumentEditor(
159159
controller: controller,
160160
),
161161
),

packages/boustro/lib/src/convert/convert_delta.dart

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,9 @@ TextAttributeDeltaCodec deltaBoolAttributeCodec(
9898
);
9999
}
100100

101-
/// Convert a boustro document to or from a list of insert operations in Quill's
101+
/// Convert a document to or from a list of insert operations in Quill's
102102
/// delta format.
103-
class BoustroDocumentDeltaConverter extends Codec<BoustroDocument, List<Op>> {
103+
class BoustroDocumentDeltaConverter extends Codec<Document, List<Op>> {
104104
/// Create a delta converter
105105
BoustroDocumentDeltaConverter(
106106
List<TextAttributeDeltaCodec> attributeCodecs,
@@ -132,16 +132,16 @@ class BoustroDocumentDeltaConverter extends Codec<BoustroDocument, List<Op>> {
132132
final Map<Type, EmbedEncoder> embedEncoders;
133133

134134
@override
135-
Converter<List<Op>, BoustroDocument> get decoder =>
135+
Converter<List<Op>, Document> get decoder =>
136136
BoustroDocumentDeltaDecoder(attributeDecoders, embedDecoders);
137137

138138
@override
139-
Converter<BoustroDocument, List<Op>> get encoder =>
139+
Converter<Document, List<Op>> get encoder =>
140140
BoustroDocumentDeltaEncoder(attributeEncoder, embedEncoders);
141141
}
142142

143-
/// Encodes a boustro document to a list of Quill delta insert operations.
144-
class BoustroDocumentDeltaEncoder extends Converter<BoustroDocument, List<Op>> {
143+
/// Encodes a document to a list of Quill delta insert operations.
144+
class BoustroDocumentDeltaEncoder extends Converter<Document, List<Op>> {
145145
/// Create an encoder.
146146
const BoustroDocumentDeltaEncoder(
147147
this.attributeEncoder,
@@ -155,17 +155,17 @@ class BoustroDocumentDeltaEncoder extends Converter<BoustroDocument, List<Op>> {
155155
final Map<Type, EmbedEncoder> embedEncoders;
156156

157157
@override
158-
List<Op> convert(BoustroDocument input) {
158+
List<Op> convert(Document input) {
159159
throw UnimplementedError();
160160
}
161161
}
162162

163-
/// Convert a list of Quill delta format insert operations to a boustro
163+
/// Convert a list of Quill delta format insert operations to a
164164
/// document.
165165
///
166166
/// Throws [ArgumentError] when an attribute is encountered with no entry in
167167
/// [attributeCodecs].
168-
class BoustroDocumentDeltaDecoder extends Converter<List<Op>, BoustroDocument> {
168+
class BoustroDocumentDeltaDecoder extends Converter<List<Op>, Document> {
169169
/// Create a decoder.
170170
const BoustroDocumentDeltaDecoder(
171171
this.attributeCodecs,
@@ -179,10 +179,10 @@ class BoustroDocumentDeltaDecoder extends Converter<List<Op>, BoustroDocument> {
179179
final Map<String, EmbedDecoder> embedDecoders;
180180

181181
@override
182-
BoustroDocument convert(List<Op> input) {
182+
Document convert(List<Op> input) {
183183
// First group or split ops by lines (\n) because each line maps to a
184184
// BoustroParagraph.
185-
final paragraphs = <BoustroParagraph>[];
185+
final paragraphs = <Paragraph>[];
186186
for (final line in _groupByLines(input)) {
187187
final first = line.ops.firstOrNull;
188188
if (first is InsertObjectOp) {
@@ -204,7 +204,7 @@ class BoustroDocumentDeltaDecoder extends Converter<List<Op>, BoustroDocument> {
204204
}
205205
}
206206

207-
return BoustroDocument(paragraphs.build());
207+
return Document(paragraphs.build());
208208
}
209209

210210
Iterable<_DeltaLine> _groupByLines(List<Op> ops) sync* {
@@ -258,7 +258,7 @@ class BoustroDocumentDeltaDecoder extends Converter<List<Op>, BoustroDocument> {
258258
}
259259
}
260260

261-
BoustroLine _opsToLine(_DeltaLine line) {
261+
TextLine _opsToLine(_DeltaLine line) {
262262
final buffer = StringBuffer();
263263
final segments = <AttributeSegment>[];
264264

@@ -295,7 +295,7 @@ class BoustroDocumentDeltaDecoder extends Converter<List<Op>, BoustroDocument> {
295295

296296
final text =
297297
segments.fold<String>('', (str, segment) => str + segment.text.string);
298-
return BoustroLine(text: text, spans: spans);
298+
return TextLine(text: text, spans: spans);
299299
}
300300
}
301301

packages/boustro/lib/src/document.dart

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@ import 'package:flutter_spanned_controller/flutter_spanned_controller.dart';
77

88
import 'scope.dart';
99

10-
/// Rich text represented as a list of [BoustroParagraph]s.
10+
/// Rich text represented as a list of [Paragraph]s.
1111
@immutable
12-
class BoustroDocument {
13-
/// Create a new boustro document.
14-
const BoustroDocument(this.paragraphs);
12+
class Document {
13+
/// Create a new document.
14+
const Document(this.paragraphs);
1515

1616
/// The list of paragraphs in this document.
17-
final BuiltList<BoustroParagraph> paragraphs;
17+
final BuiltList<Paragraph> paragraphs;
1818
}
1919

20-
/// A paragraph in a [BoustroDocument]. Is either a [BoustroLine] for rich text,
20+
/// A paragraph in a [Document]. Is either a [TextLine] for rich text,
2121
/// or a [ParagraphEmbed] for other content.
2222
@immutable
23-
abstract class BoustroParagraph {
24-
const BoustroParagraph._();
23+
abstract class Paragraph {
24+
const Paragraph._();
2525

26-
/// Execute [line] if this is a [BoustroLine] and [embed] if this is a
26+
/// Execute [line] if this is a [TextLine] and [embed] if this is a
2727
/// [ParagraphEmbed].
2828
T match<T>({
29-
required T Function(BoustroLine) line,
29+
required T Function(TextLine) line,
3030
required T Function(ParagraphEmbed) embed,
3131
});
3232
}
3333

34-
/// Immutable representation of a line of rich text in a [BoustroDocument].
34+
/// Immutable representation of a line of rich text in a [Document].
3535
@immutable
36-
class BoustroLine extends BoustroParagraph with EquatableMixin {
37-
/// Create a boustro line.
38-
BoustroLine({
36+
class TextLine extends Paragraph with EquatableMixin {
37+
/// Create a line of rich text.
38+
TextLine({
3939
required String text,
4040
required SpanList spans,
4141
List<LineModifier>? modifiers,
@@ -45,8 +45,8 @@ class BoustroLine extends BoustroParagraph with EquatableMixin {
4545
modifiers: modifiers?.build() ?? BuiltList<LineModifier>(),
4646
);
4747

48-
/// Create a boustro line with the text and spans of [string].
49-
BoustroLine.fromSpanned({
48+
/// Create a line with the text and spans of [string].
49+
TextLine.fromSpanned({
5050
required SpannedString string,
5151
List<LineModifier>? modifiers,
5252
}) : this.built(
@@ -55,8 +55,8 @@ class BoustroLine extends BoustroParagraph with EquatableMixin {
5555
modifiers: modifiers?.build() ?? BuiltList<LineModifier>(),
5656
);
5757

58-
/// Create a boustro line with directly initialized fields.
59-
BoustroLine.built({
58+
/// Create a line with directly initialized fields.
59+
TextLine.built({
6060
required this.text,
6161
required this.spans,
6262
required this.modifiers,
@@ -76,7 +76,7 @@ class BoustroLine extends BoustroParagraph with EquatableMixin {
7676

7777
@override
7878
T match<T>({
79-
required T Function(BoustroLine) line,
79+
required T Function(TextLine) line,
8080
required T Function(ParagraphEmbed) embed,
8181
}) =>
8282
line(this);
@@ -92,13 +92,13 @@ class BoustroLine extends BoustroParagraph with EquatableMixin {
9292

9393
/// Interface for paragraph embeds.
9494
@immutable
95-
abstract class ParagraphEmbed extends BoustroParagraph {
95+
abstract class ParagraphEmbed extends Paragraph {
9696
/// Constant base constructor for implementations.
9797
const ParagraphEmbed() : super._();
9898

9999
@override
100100
T match<T>({
101-
required T Function(BoustroLine) line,
101+
required T Function(TextLine) line,
102102
required T Function(ParagraphEmbed) embed,
103103
}) =>
104104
embed(this);
@@ -110,9 +110,9 @@ abstract class ParagraphEmbed extends BoustroParagraph {
110110
});
111111
}
112112

113-
/// Builds a [BoustroDocument]. Can be used fluently with cascades.
113+
/// Builds a [Document]. Can be used fluently with cascades.
114114
class DocumentBuilder {
115-
final List<BoustroParagraph> _paragraphs = [];
115+
final List<Paragraph> _paragraphs = [];
116116
final SpannedStringBuilder _lineBuilder = SpannedStringBuilder();
117117

118118
/// Add a line of rich text to the document.
@@ -122,7 +122,7 @@ class DocumentBuilder {
122122
]) {
123123
build(_lineBuilder);
124124
final str = _lineBuilder.build();
125-
final line = BoustroLine.fromSpanned(string: str, modifiers: modifiers);
125+
final line = TextLine.fromSpanned(string: str, modifiers: modifiers);
126126
_paragraphs.add(line);
127127
}
128128

@@ -134,8 +134,8 @@ class DocumentBuilder {
134134
/// Finishes building and returns the created document.
135135
///
136136
/// The builder will be reset and can be reused.
137-
BoustroDocument build() {
138-
final doc = BoustroDocument(_paragraphs.build());
137+
Document build() {
138+
final doc = Document(_paragraphs.build());
139139
_paragraphs.clear();
140140
return doc;
141141
}

packages/boustro/lib/src/scope.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,21 @@ import 'document.dart';
55
import 'widgets/document_controller.dart';
66
import 'widgets/editor.dart';
77

8-
/// Inherited widget that carries information about a boustro document.
8+
/// Inherited widget that carries information about a document.
99
@immutable
1010
class BoustroScope extends InheritedWidget {
11-
/// Create a scope for an editable document with a document controller.
11+
/// Create a scope for an editable document with a [DocumentController].
1212
const BoustroScope.editable({
1313
Key? key,
1414
required DocumentController this.controller,
1515
required Widget child,
1616
}) : document = null,
1717
super(key: key, child: child);
1818

19-
/// Create a scope for a read-only document with a boustro document controller.
19+
/// Create a scope for a read-only document with a [Document].
2020
const BoustroScope.readonly({
2121
Key? key,
22-
required BoustroDocument this.document,
22+
required Document this.document,
2323
required Widget child,
2424
}) : controller = null,
2525
super(key: key, child: child);
@@ -28,9 +28,9 @@ class BoustroScope extends InheritedWidget {
2828
/// used.
2929
final DocumentController? controller;
3030

31-
/// Document of the [BoustroView]. Null if [BoustroScope.readonly] was
31+
/// Document of the [DocumentView]. Null if [BoustroScope.readonly] was
3232
/// used.
33-
final BoustroDocument? document;
33+
final Document? document;
3434

3535
/// True if [BoustroScope.editable] was used, false if [BoustroScope.readonly]
3636
/// was used.
@@ -39,7 +39,7 @@ class BoustroScope extends InheritedWidget {
3939
/// Call [editable] if [isEditable] is true or [readonly] if it is not.
4040
T match<T>({
4141
required T Function(DocumentController) editable,
42-
required T Function(BoustroDocument) readonly,
42+
required T Function(Document) readonly,
4343
}) {
4444
return isEditable ? editable(controller!) : readonly(document!);
4545
}
@@ -81,7 +81,7 @@ class BoustroScope extends InheritedWidget {
8181
..add(DiagnosticsProperty<bool>('isEditable', isEditable))
8282
..add(DiagnosticsProperty<DocumentController?>('controller', controller,
8383
defaultValue: null))
84-
..add(DiagnosticsProperty<BoustroDocument?>('document', document,
84+
..add(DiagnosticsProperty<Document?>('document', document,
8585
defaultValue: null));
8686
}
8787
}

packages/boustro/lib/src/widgets/document_controller.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flutter_spanned_controller/flutter_spanned_controller.dart';
77
import '../document.dart';
88
import 'editor.dart';
99

10-
/// Holds state for a paragraph of a boustro document.
10+
/// Holds state for a paragraph of a document.
1111
@immutable
1212
abstract class ParagraphState {
1313
/// Create a paragraph.
@@ -34,7 +34,7 @@ abstract class ParagraphState {
3434

3535
/// Holds focus node and state for a line of text.
3636
///
37-
/// This is the editable variant of [BoustroLine].
37+
/// This is the editable variant of [TextLine].
3838
@immutable
3939
class LineState extends ParagraphState {
4040
/// Create a text line.
@@ -91,7 +91,7 @@ class LineState extends ParagraphState {
9191
line(this);
9292
}
9393

94-
/// Holds [FocusNode] and content for a boustro embed.
94+
/// Holds [FocusNode] and content for an embed.
9595
@immutable
9696
class EmbedState extends ParagraphState {
9797
/// Create an embed.
@@ -111,7 +111,7 @@ class EmbedState extends ParagraphState {
111111
embed(this);
112112
}
113113

114-
/// Manages the contents of a [BoustroEditor].
114+
/// Manages the contents of a [DocumentEditor].
115115
///
116116
/// Keeps track of the state of its paragraphs and editor:
117117
///
@@ -130,7 +130,7 @@ class DocumentController extends ValueNotifier<BuiltList<ParagraphState>> {
130130
/// Create a document controller.
131131
DocumentController({
132132
ScrollController? scrollController,
133-
Iterable<BoustroParagraph>? paragraphs,
133+
Iterable<Paragraph>? paragraphs,
134134
this.attributeTheme,
135135
}) : scrollController = scrollController ?? ScrollController(),
136136
super(BuiltList()) {
@@ -221,7 +221,7 @@ class DocumentController extends ValueNotifier<BuiltList<ParagraphState>> {
221221
final nextLine = t.collapse(end: indexAfterNewline);
222222
insertLine(
223223
lineIndex + 1,
224-
BoustroLine.built(
224+
TextLine.built(
225225
text: nextLine.text,
226226
spans: nextLine.spans,
227227
modifiers: currentLine.modifiers,
@@ -247,27 +247,27 @@ class DocumentController extends ValueNotifier<BuiltList<ParagraphState>> {
247247
);
248248
}
249249

250-
/// Get the contents of this controller represented as a boustro document.
251-
BoustroDocument toDocument() {
250+
/// Get the contents of this controller represented as a document.
251+
Document toDocument() {
252252
final paragraphs = this
253253
.paragraphs
254-
.map((p) => p.match<BoustroParagraph>(
254+
.map((p) => p.match<Paragraph>(
255255
line: (l) =>
256-
BoustroLine.fromSpanned(string: l.controller.spannedString),
256+
TextLine.fromSpanned(string: l.controller.spannedString),
257257
// TODO need a controller to modify embed state.
258258
embed: (e) => e.content,
259259
))
260260
.toBuiltList();
261-
return BoustroDocument(paragraphs);
261+
return Document(paragraphs);
262262
}
263263

264264
/// Add a line after all existing paragraphs.
265-
LineState appendLine([BoustroLine? line]) {
265+
LineState appendLine([TextLine? line]) {
266266
return insertLine(paragraphs.length, line);
267267
}
268268

269269
/// Insert a line at [index].
270-
LineState insertLine(int index, [BoustroLine? line]) {
270+
LineState insertLine(int index, [TextLine? line]) {
271271
final spanController = SpannedTextEditingController(
272272
processTextValue: _processTextValue,
273273
text: line?.text.string,

0 commit comments

Comments
 (0)