zefyr 0.2.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 86

Zefyr Build Status codecov

Soft and gentle rich text editing for Flutter applications.

Zefyr is currently in early preview. If you have a feature request or found a bug, please file it at the issue tracker.

Important: Zefyr currently tracks latest development version of Flutter (master branch) and may not work with Flutter beta channel if there are breaking changes.

For documentation see https://github.com/memspace/zefyr.

zefyr screenshot

0.2.0 #

  • Breaking change: ZefyrImageDelegate.createImageProvider replaced with ZefyrImageDelegate.buildImage.
  • Fixed redundant updates on composing range for Android.
  • Added TextCapitalization.sentences
  • Added docs for embedding images.

0.1.2 #

  • Fixed analysis warnings.
  • UX: User taps on padding area around the editor and in empty space inside it now look for the nearest paragraph to move caret to.
  • UX: Toggle selection toolbar on double tap instead of refreshing it.

0.1.1 #

  • Fixed: Prevent sending excessive value updates to the native side which cause race conditions (#12).

0.1.0 #

  • Initial release.

example/lib/main.dart

// Copyright (c) 2018, the Zefyr project authors.  Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:quill_delta/quill_delta.dart';
import 'package:zefyr/zefyr.dart';

void main() {
  runApp(new ZefyrApp());
}

class ZefyrLogo extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Text('Ze'),
        FlutterLogo(size: 24.0),
        Text('yr'),
      ],
    );
  }
}

class ZefyrApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Zefyr Editor',
      theme: new ThemeData(primarySwatch: Colors.cyan),
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

final doc =
    r'[{"insert":"Zefyr"},{"insert":"\n","attributes":{"heading":1}},{"insert":"Soft and gentle rich text editing for Flutter applications.","attributes":{"i":true}},{"insert":"\n"},{"insert":"​","attributes":{"embed":{"type":"image","source":"asset://images/breeze.jpg"}}},{"insert":"\n"},{"insert":"Photo by Hiroyuki Takeda.","attributes":{"i":true}},{"insert":"\nZefyr is currently in "},{"insert":"early preview","attributes":{"b":true}},{"insert":". If you have a feature request or found a bug, please file it at the "},{"insert":"issue tracker","attributes":{"a":"https://github.com/memspace/zefyr/issues"}},{"insert":'
    r'".\nDocumentation"},{"insert":"\n","attributes":{"heading":3}},{"insert":"Quick Start","attributes":{"a":"https://github.com/memspace/zefyr/blob/master/doc/quick_start.md"}},{"insert":"\n","attributes":{"block":"ul"}},{"insert":"Data Format and Document Model","attributes":{"a":"https://github.com/memspace/zefyr/blob/master/doc/data_and_document.md"}},{"insert":"\n","attributes":{"block":"ul"}},{"insert":"Style Attributes","attributes":{"a":"https://github.com/memspace/zefyr/blob/master/doc/attr'
    r'ibutes.md"}},{"insert":"\n","attributes":{"block":"ul"}},{"insert":"Heuristic Rules","attributes":{"a":"https://github.com/memspace/zefyr/blob/master/doc/heuristics.md"}},{"insert":"\n","attributes":{"block":"ul"}},{"insert":"FAQ","attributes":{"a":"https://github.com/memspace/zefyr/blob/master/doc/faq.md"}},{"insert":"\n","attributes":{"block":"ul"}},{"insert":"Clean and modern look"},{"insert":"\n","attributes":{"heading":2}},{"insert":"Zefyr’s rich text editor is built with simplicity and fle'
    r'xibility in mind. It provides clean interface for distraction-free editing. Think Medium.com-like experience.\nMarkdown inspired semantics"},{"insert":"\n","attributes":{"heading":2}},{"insert":"Ever needed to have a heading line inside of a quote block, like this:\nI’m a Markdown heading"},{"insert":"\n","attributes":{"block":"quote","heading":3}},{"insert":"And I’m a regular paragraph"},{"insert":"\n","attributes":{"block":"quote"}},{"insert":"Code blocks"},{"insert":"\n","attributes":{"headin'
    r'g":2}},{"insert":"Of course:\nimport ‘package:flutter/material.dart’;"},{"insert":"\n","attributes":{"block":"code"}},{"insert":"import ‘package:zefyr/zefyr.dart’;"},{"insert":"\n\n","attributes":{"block":"code"}},{"insert":"void main() {"},{"insert":"\n","attributes":{"block":"code"}},{"insert":" runApp(MyZefyrApp());"},{"insert":"\n","attributes":{"block":"code"}},{"insert":"}"},{"insert":"\n","attributes":{"block":"code"}},{"insert":"\n\n\n"}]';

Delta getDelta() {
  return Delta.fromJson(json.decode(doc));
}

class _MyHomePageState extends State<MyHomePage> {
  final ZefyrController _controller =
      ZefyrController(NotusDocument.fromDelta(getDelta()));
  final FocusNode _focusNode = new FocusNode();
  bool _editing = false;

  @override
  Widget build(BuildContext context) {
    final theme = new ZefyrThemeData(
      toolbarTheme: ZefyrToolbarTheme.fallback(context).copyWith(
        color: Colors.grey.shade800,
        toggleColor: Colors.grey.shade900,
        iconColor: Colors.white,
        disabledIconColor: Colors.grey.shade500,
      ),
    );

    final done = _editing
        ? [new FlatButton(onPressed: _stopEditing, child: Text('DONE'))]
        : [new FlatButton(onPressed: _startEditing, child: Text('EDIT'))];
    return Scaffold(
      resizeToAvoidBottomPadding: true,
      appBar: AppBar(
        elevation: 1.0,
        backgroundColor: Colors.grey.shade200,
        brightness: Brightness.light,
        title: ZefyrLogo(),
        actions: done,
      ),
      body: ZefyrTheme(
        data: theme,
        child: ZefyrEditor(
          controller: _controller,
          focusNode: _focusNode,
          enabled: _editing,
          imageDelegate: new CustomImageDelegate(),
        ),
      ),
    );
  }

  void _startEditing() {
    setState(() {
      _editing = true;
    });
  }

  void _stopEditing() {
    setState(() {
      _editing = false;
    });
  }
}

/// Custom image delegate used by this example to load image from application
/// assets.
///
/// Default image delegate only supports [FileImage]s.
class CustomImageDelegate extends ZefyrDefaultImageDelegate {
  @override
  Widget buildImage(BuildContext context, String imageSource) {
    // We use custom "asset" scheme to distinguish asset images from other files.
    if (imageSource.startsWith('asset://')) {
      final asset = new AssetImage(imageSource.replaceFirst('asset://', ''));
      return new Image(image: asset);
    } else {
      return super.buildImage(context, imageSource);
    }
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  zefyr: ^0.2.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:zefyr/zefyr.dart';
  
Version Uploaded Documentation Archive
0.5.0 Mar 10, 2019 Go to the documentation of zefyr 0.5.0 Download zefyr 0.5.0 archive
0.4.0 Feb 14, 2019 Go to the documentation of zefyr 0.4.0 Download zefyr 0.4.0 archive
0.3.1 Jan 28, 2019 Go to the documentation of zefyr 0.3.1 Download zefyr 0.3.1 archive
0.3.0 Nov 15, 2018 Go to the documentation of zefyr 0.3.0 Download zefyr 0.3.0 archive
0.2.0 Oct 22, 2018 Go to the documentation of zefyr 0.2.0 Download zefyr 0.2.0 archive
0.1.2 Jul 24, 2018 Go to the documentation of zefyr 0.1.2 Download zefyr 0.1.2 archive
0.1.1 Jul 18, 2018 Go to the documentation of zefyr 0.1.1 Download zefyr 0.1.1 archive
0.1.0 Jul 15, 2018 Go to the documentation of zefyr 0.1.0 Download zefyr 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
89
Health:
Code health derived from static analysis. [more]
70
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

We analyzed this package on May 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.0
  • pana: 0.12.15
  • Flutter: 1.5.8

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Fix lib/src/widgets/input.dart. (-25 points)

Analysis of lib/src/widgets/input.dart failed with 1 error:

line 11 col 7: Missing concrete implementation of TextInputClient.updateFloatingCursor.

Fix lib/src/widgets/editable_box.dart. (-2.48 points)

Analysis of lib/src/widgets/editable_box.dart reported 5 hints:

line 80 col 21: Avoid wrapping fields in getters and setters just to be "safe".

line 82 col 3: Avoid return types on setters.

line 82 col 12: Avoid wrapping fields in getters and setters just to be "safe".

line 88 col 3: Avoid return types on setters.

line 94 col 3: Avoid return types on setters.

Fix lib/src/widgets/rich_text.dart. (-2.48 points)

Analysis of lib/src/widgets/rich_text.dart reported 5 hints:

line 69 col 16: Avoid wrapping fields in getters and setters just to be "safe".

line 71 col 3: Avoid return types on setters.

line 71 col 12: Avoid wrapping fields in getters and setters just to be "safe".

line 171 col 7: Avoid using unnecessary statements.

line 183 col 3: Avoid return types on setters.

Fix additional 4 files with analysis or formatting issues. (-1.99 points)

Additional issues in the following files:

  • lib/src/widgets/image.dart (3 hints)
  • lib/src/widgets/selection.dart (1 hint)
  • lib/src/widgets/controller.dart (Run flutter format to format lib/src/widgets/controller.dart.)
  • lib/util.dart (Run flutter format to format lib/util.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.58.0 <3.0.0
collection ^1.14.6 1.14.11
flutter 0.0.0
image_picker ^0.4.5 0.4.12+1 0.6.0+2
meta ^1.1.0 1.1.6 1.1.7
notus ^0.1.0 0.1.3
quill_delta ^1.0.0-dev.1.0 1.0.0-dev.4.0
url_launcher ^3.0.0 3.0.3 5.0.2
Transitive dependencies
quiver_hashcode 2.0.0
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test