telegraph icon indicating copy to clipboard operation
telegraph copied to clipboard

refactor!: 2.0

Open dcdunkan opened this issue 2 years ago • 0 comments

2.0

BREAKING CHANGES. Re-wrote the whole library. Corrected a lot of mistakes I made when I first wrote it.

Closes #1, as I think its better to handle TG markdown in the plugin itself. Not in this library.

A lot have been changed:

Changelog

  • Switched to marked from marky for parsing Markdown to HTML.

  • Removed parseMarkdown and parseHTML in favor of a common method parse which takes two arguments: content and parse mode. (Closes #4 as it also tries to solve this in a different way)

    import { parse } from "https://deno.land/x/telegraph/mod.ts";
    
    const content = parse("**Bold**", "Markdown");
    const content = parse("<b>Bold</b>", "Markdown");
    
  • Removed setupAccount method and the abilities to create or edit account directly by passing it to the constructor. I think the new API is much clean.

  • upload function was improved.

    • Added ability to change API url.
  • Supports installing an error handler to catch and manage errors as you like. (Thanks to grammyjs/grammY)

  • Types have been improved.

  • iframe URLs are no longer transformed like it used to do. Now it only appends the URI encoded URL to /embed/{}?url={} after validation.

  • HTML is sanitized before parsing.

  • Line breaks have been improved.

  • docs: API reference documentation is copied to the code. So, users can have documentation right in their editor. Closes #2

#3 is still pending and need to be worked on before merging this.

dcdunkan avatar Mar 06 '23 21:03 dcdunkan