zefyr

main.dart 1.0KB

12345678910111213141516171819202122232425262728
  1. // Copyright (c) 2018, the Zefyr project authors. Please see the AUTHORS file
  2. // for details. All rights reserved. Use of this source code is governed by a
  3. // BSD-style license that can be found in the LICENSE file.
  4. import 'package:notus/notus.dart';
  5. void main() {
  6. final doc = new NotusDocument();
  7. // Modify this document with insert, delete and format operations
  8. doc.insert(
  9. 0, 'Notus package provides rich text document model for Zefyr editor');
  10. doc.format(0, 5, NotusAttribute.bold); // Makes first word bold.
  11. doc.format(0, 0, NotusAttribute.h1); // Makes first line a heading.
  12. doc.delete(23, 10); // Deletes "rich text " segment.
  13. // Collects style attributes at 1 character in this document.
  14. doc.collectStyle(1, 0); // returned style would include "bold" and "h1".
  15. // Listen to all changes applied to this document.
  16. doc.changes.listen((change){
  17. print(change);
  18. });
  19. // Dispose resources allocated by this document, e.g. closes "changes" stream.
  20. // After document is closed it cannot be modified.
  21. doc.close();
  22. }