Skip to content

Commit

Permalink
Removed LTR attribute, using LTR as default direction
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir-P committed Sep 23, 2021
1 parent f1a6fa0 commit 21b1c3a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 35 deletions.
7 changes: 1 addition & 6 deletions packages/notus/lib/src/document/attributes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,9 @@ class NotusAttribute<T> implements NotusAttributeBuilder<T> {
/// Direction attribute
static const direction = DirectionAttributeBuilder._();

/// Alias for [NotusAttribute.direction.ltr].
/// Alias for [NotusAttribute.direction.rtl].
static NotusAttribute<String> get rtl => direction.rtl;

/// Alias for [NotusAttribute.direction.ltr].
static NotusAttribute<String> get ltr => direction.ltr;

static NotusAttribute _fromKeyValue(String key, dynamic value) {
if (!_registry.containsKey(key)) {
throw ArgumentError.value(
Expand Down Expand Up @@ -418,6 +415,4 @@ class DirectionAttributeBuilder extends NotusAttributeBuilder<String> {
: super._(_kDirection, NotusAttributeScope.line);

NotusAttribute<String> get rtl => NotusAttribute<String>._(key, scope, 'rtl');

NotusAttribute<String> get ltr => NotusAttribute<String>._(key, scope, 'ltr');
}
33 changes: 17 additions & 16 deletions packages/zefyr/lib/src/widgets/editable_text_block.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ class EditableTextBlock extends StatelessWidget {
final preferredDirection = node.style.get(NotusAttribute.direction);
if (preferredDirection == NotusAttribute.rtl) {
return TextDirection.rtl;
} else if (preferredDirection == NotusAttribute.ltr) {
return TextDirection.ltr;
}
return Directionality.of(context);
return TextDirection.ltr;
}

List<Widget> _buildChildren(BuildContext context) {
Expand All @@ -68,23 +66,26 @@ class EditableTextBlock extends StatelessWidget {
index++;
final nodeTextDirection =
getTextDirectionForNode(context, line as LineNode);
children.add(EditableTextLine(
node: line,
children.add(Directionality(
textDirection: nodeTextDirection,
spacing: _getSpacingForLine(line, index, count, theme),
leading: _buildLeading(context, line, index, count),
indentWidth: _getIndentWidth(),
devicePixelRatio: MediaQuery.of(context).devicePixelRatio,
body: TextLine(
child: EditableTextLine(
node: line,
embedBuilder: embedBuilder,
textDirection: nodeTextDirection,
spacing: _getSpacingForLine(line, index, count, theme),
leading: _buildLeading(context, line, index, count),
indentWidth: _getIndentWidth(),
devicePixelRatio: MediaQuery.of(context).devicePixelRatio,
body: TextLine(
node: line,
embedBuilder: embedBuilder,
textDirection: nodeTextDirection,
),
cursorController: cursorController,
selection: selection,
selectionColor: selectionColor,
enableInteractiveSelection: enableInteractiveSelection,
hasFocus: hasFocus,
),
cursorController: cursorController,
selection: selection,
selectionColor: selectionColor,
enableInteractiveSelection: enableInteractiveSelection,
hasFocus: hasFocus,
));
}
return children.toList(growable: false);
Expand Down
6 changes: 2 additions & 4 deletions packages/zefyr/lib/src/widgets/editor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1137,14 +1137,12 @@ class RawEditorState extends EditorState
);
}

TextDirection getTextDirectionForStyledNode(StyledNode node){
TextDirection getTextDirectionForStyledNode(StyledNode node) {
final preferredDirection = node.style.get(NotusAttribute.direction);
if (preferredDirection == NotusAttribute.rtl) {
return TextDirection.rtl;
} else if (preferredDirection == NotusAttribute.ltr) {
return TextDirection.ltr;
}
return _textDirection;
return TextDirection.ltr;
}

List<Widget> _buildChildren(BuildContext context) {
Expand Down
9 changes: 0 additions & 9 deletions packages/zefyr/lib/src/widgets/editor_toolbar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,6 @@ class ZefyrToolbar extends StatefulWidget implements PreferredSizeWidget {
visible: !hideDirection,
child: VerticalDivider(
indent: 16, endIndent: 16, color: Colors.grey.shade400)),
Visibility(
visible: !hideDirection,
child: ToggleStyleButton(
attribute: NotusAttribute.ltr,
icon: Icons.format_textdirection_l_to_r,
controller: controller,
),
),
SizedBox(width: 1),
Visibility(
visible: !hideDirection,
child: ToggleStyleButton(
Expand Down

0 comments on commit 21b1c3a

Please sign in to comment.