Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get entered content as HTML format in iOS / Android app? #186

Open
jazzbpn opened this issue Oct 22, 2019 · 16 comments
Open

How to get entered content as HTML format in iOS / Android app? #186

jazzbpn opened this issue Oct 22, 2019 · 16 comments

Comments

@jazzbpn
Copy link

jazzbpn commented Oct 22, 2019

I am trying to get entered content as HTML format from this ZefyrField. If it is possible how?

  `return ZefyrTheme(
  data: theme,
  child: ZefyrField(
    height: 200.0,
    decoration: InputDecoration(labelText: 'Description'),
    controller: _controller,
    focusNode: _focusNode,
    autofocus: true,
    imageDelegate: CustomImageDelegate(),
    physics: ClampingScrollPhysics(),
  ),
);`

_controller.document.toJson() and _controller.document.toString() gives the content in json and string format. But what if want to get that entered content as HTML format?

@virskor
Copy link

virskor commented Oct 22, 2019

🙋‍♂️I do need this. Thanks

@silviocandido
Copy link

I do need this too, Thanks.

@nalbion
Copy link

nalbion commented Oct 24, 2019

There's a PR #178
...and a PR for the PR: Yom3n#1

@sil-main-coo
Copy link

I had this problem just now.
I have found this package: markdown
And code:

Delta _delta = _controller.document.toDelta();
String html = markdownToHtml(notusMarkdown.encode(_delta) .toString()); 
print(html);

@virskor
Copy link

virskor commented Oct 24, 2019

@sil-main-coo Dose these methods works well? it will help me a lot if so. Thanks

@sil-main-coo
Copy link

@sil-main-coo Dose these methods works well? it will help me a lot if so. Thanks

It supports markdown conversion to html. For my project it is very good. Please read the documentation for reference.
But if you require more complicated tags, find something else.
You can also refer to @nalbion 's pull request above.

@nalbion
Copy link

nalbion commented Oct 24, 2019

If you want to use the HTML codec in my PR right now, add the following to your pubspec.yaml:

dependency_overrides:
  notus:
    git:
      url: git://github.com/nalbion/zefyr.git
      path: packages/notus

This is how I'm using my Markdown decoder:

_saveNotes() {
    final markdown = notusMarkdown.encode(_notesController.document.toDelta());
    // save the markdown string
  }

  NotusDocument _loadNotes() {
    // load a markdown string
    var markdown = null; // 'This is **Markdown**'

    if (markdown == null) {
      return NotusDocument();
    }

    return NotusDocument.fromDelta(notusMarkdown.decode(markdown));
  }

@jazzbpn
Copy link
Author

jazzbpn commented Oct 25, 2019

I had this problem just now.
I have found this package: markdown
And code:

Delta _delta = _controller.document.toDelta();
String html = markdownToHtml(notusMarkdown.encode(_delta) .toString()); 
print(html);

How to use create notusMaskdown object? Please checkout the screenshot below.

Screen Shot 2019-10-25 at 10 38 50

@sil-main-coo
Copy link

sil-main-coo commented Oct 25, 2019

I had this problem just now.
I have found this package: markdown
And code:

Delta _delta = _controller.document.toDelta();
String html = markdownToHtml(notusMarkdown.encode(_delta) .toString()); 
print(html);

How to use create notusMaskdown object? Please checkout the screenshot below.

Screen Shot 2019-10-25 at 10 38 50

Sorry. I wrote missing a package: Notus.
And Delta Package if u need

@nalbion
Copy link

nalbion commented Oct 25, 2019

You need to add import 'package:notus/convert.dart'; and use the HTML codec instead of Markdown

@jazzbpn
Copy link
Author

jazzbpn commented Oct 26, 2019

Awesome thanks!!.

@Adamgortych
Copy link

Does anyone know how to make it from the other way? How to display html inside zephyr? I'am trying to convert html to Notusdocument

@clipsmm
Copy link

clipsmm commented Jun 15, 2020

You need to add import 'package:notus/convert.dart'; and use the HTML codec instead of Markdown

Do you have any examples?

@tiwariritesh1700
Copy link

Anyone Has complete code for reference

@azulmouad
Copy link

import 'package:markdown/markdown.dart' as markdown;
import 'package:notus/convert.dart';

Delta _delta = _controller.document.toDelta();
      
          String html = markdown
              .markdownToHtml(notusMarkdown.encode(_delta).toString());

          print(html);

@singerdmx
Copy link

What is package:markdown/markdown.dart?
BTW, it is also possible to do it at server side.
We found a Golang package to do it singerdmx/BulletJournal@16fc1c2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants