|
@@ -90,6 +90,54 @@ void main() {
|
90
|
90
|
expect(controller.lastChangeSource, ChangeSource.local);
|
91
|
91
|
});
|
92
|
92
|
|
|
93
|
+ test('formatText with toggled style enabled', () {
|
|
94
|
+ bool notified = false;
|
|
95
|
+ controller.addListener(() {
|
|
96
|
+ notified = true;
|
|
97
|
+ });
|
|
98
|
+ controller.replaceText(0, 0, 'Words');
|
|
99
|
+ controller.formatText(2, 0, NotusAttribute.bold);
|
|
100
|
+
|
|
101
|
+ controller.replaceText(2, 0, '');
|
|
102
|
+ controller.replaceText(2, 0, 'n');
|
|
103
|
+ controller.formatText(3, 0, NotusAttribute.bold);
|
|
104
|
+ controller.replaceText(3, 0, 'B');
|
|
105
|
+ expect(notified, isTrue);
|
|
106
|
+
|
|
107
|
+ expect(
|
|
108
|
+ controller.document.toDelta(),
|
|
109
|
+ new Delta()
|
|
110
|
+ ..insert('Won')
|
|
111
|
+ ..insert('B', NotusAttribute.bold.toJson())
|
|
112
|
+ ..insert('rds')
|
|
113
|
+ ..insert('\n'),
|
|
114
|
+ );
|
|
115
|
+ expect(controller.lastChangeSource, ChangeSource.local);
|
|
116
|
+ });
|
|
117
|
+
|
|
118
|
+ test('insert text with toggled style unset', () {
|
|
119
|
+ bool notified = false;
|
|
120
|
+ controller.addListener(() {
|
|
121
|
+ notified = true;
|
|
122
|
+ });
|
|
123
|
+ controller.replaceText(0, 0, 'Words');
|
|
124
|
+ controller.formatText(1, 0, NotusAttribute.bold);
|
|
125
|
+ controller.replaceText(1, 0, 'B');
|
|
126
|
+ controller.formatText(2, 0, NotusAttribute.bold.unset);
|
|
127
|
+ controller.replaceText(2, 0, 'u');
|
|
128
|
+
|
|
129
|
+ expect(notified, isTrue);
|
|
130
|
+ expect(
|
|
131
|
+ controller.document.toDelta(),
|
|
132
|
+ new Delta()
|
|
133
|
+ ..insert('W')
|
|
134
|
+ ..insert('B', NotusAttribute.bold.toJson())
|
|
135
|
+ ..insert('uords')
|
|
136
|
+ ..insert('\n'),
|
|
137
|
+ );
|
|
138
|
+ expect(controller.lastChangeSource, ChangeSource.local);
|
|
139
|
+ });
|
|
140
|
+
|
93
|
141
|
test('formatSelection', () {
|
94
|
142
|
bool notified = false;
|
95
|
143
|
controller.addListener(() {
|
|
@@ -113,5 +161,14 @@ void main() {
|
113
|
161
|
var result = controller.getSelectionStyle();
|
114
|
162
|
expect(result.values, [NotusAttribute.bold]);
|
115
|
163
|
});
|
|
164
|
+
|
|
165
|
+ test('getSelectionStyle with toggled style', () {
|
|
166
|
+ var selection = new TextSelection.collapsed(offset: 3);
|
|
167
|
+ controller.replaceText(0, 0, 'Words', selection: selection);
|
|
168
|
+ controller.formatText(3, 0, NotusAttribute.bold);
|
|
169
|
+
|
|
170
|
+ var result = controller.getSelectionStyle();
|
|
171
|
+ expect(result.values, [NotusAttribute.bold]);
|
|
172
|
+ });
|
116
|
173
|
});
|
117
|
174
|
}
|