Giter VIP home page Giter VIP logo

sketch-sh's Introduction

ReasonML playground

A note writing application for teaching and sharing ReasonML code with inline evaluation.

CircleCI

How does it work?

This project uses rtop-evaluator for evaluating the input. The evaluator loads refmt & js_of_ocaml compiler as a web worker in the browser. We're not using BuckleScript since it currently doesn't support toplevel evaluation. That means BuckleScript modules like Js are not available, and instead one has to run functions from the OCaml stdlib like print_string. Belt however works well with js_of_ocaml and support is coming soon!

Contributions

See DEVELOPING.md for more information

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

LICENSE

Apache 2.0. See the included LICENSE file for more information

sketch-sh's People

Contributors

0xflotus avatar acoll avatar andrii-antiukhov avatar cnguy avatar dependabot[bot] avatar feihong avatar jasim avatar jchavarri avatar khady avatar matthiaskern avatar maxlibin avatar monkeywithacupcake avatar nimish-gupta avatar no-stack-dub-sack avatar thangngoc89 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sketch-sh's Issues

Design decisions

This is a main tracker for client side routing and pages, pretty everything are unimplemented but I need a place to keep track of ideas in my head.

IDs

I'm using NanoId to generate 22 characters id for pretty much everything that need random ids. It has smaller collision chance then UUID

Authentication

  • Currently only Github login is supported. In the future, I can support passwordless login method. I want to avoid the responsibility of storing user's password

Sketches

/s/:sketch-id/

Design decisions:

  • Having the url encoded of note content means that we always have an offline fallback when user is offline, and in the worst event, the server went down but all playground links are still available and well

/u/:user-id

List all notes of a user

Data format: serialization and deserialization

I want the data to be as portable as possible so here are some of my thoughts about data serialization and deserialization:

Source code format (.re, .ml):

Any notebook should be a valid ReasonML program.

When serialize a note into source code format, text block will be block comment like this:

/*:  # ReasonML playground */
(*:  # ReasonML playground *)

Notice the colon, it's used to distinguish between text block and actual code comment in deserialization.

Markdown format

~~Simply convert code blocks into markdown's codeblock with fences ~~

From @jordwalke in #98

Another approach to permanence, would be to have an export/import feature. Imagine importing a standard markdown file where `reason tags become the runnable example code blocks.

`reason-norun could become blocks embedded as code that doesn't become a runnable block, but instead is only syntax highlighted.


TODO:

  • Source code format:
    • Serialize
    • Deserialize
  • Markdown format:
    • Serialize
    • Deserialize

Implementing fork feature

Top priority is to remove the read only mode. It's quite annoying.
This would allow user to freely play with the playground and save it to a fork when they hit save.

Support anonymous editing after creating a note

  • Add a new column calls edit_token in note table. Noone could select this column. And this should be nullable.
  • On saving a new note anonymously, set the edit_token.
  • Save edit_token in localStorage
  • On updating a new anonymous note, send the edit_token for permission checking.

Better positioning of evaluated result

From kennetpostigo on Discord

  1. Evaluate only highlighted or active cursor line and any of the previous lines it depends on
  2. If the evaluated output isn't long show it along side the actual line.
  3. If it's really long output then show it directly underneath that line and allow the output to be collapsible
  4. evaluate each cell onChange instead of shift + enter, of course add something like debounce

Support OCaml syntax

Currently for separating each directive (for executing and getting result back), I'm using a very dumb approach: try to execute the code when encountering a semicolon. This works perfectly fine in ReasonML. For OCaml, there is ;; that could be used as separator. It's a valid syntax but nobody uses it in real code anyway.

So for supporting OCaml syntax, there are 3 steps:

  • add UI for ocaml syntax, user must use ;; for separating structures (ui inspirations
    https://rebench.github.io/ (press on the red RED button on top-left corner)
  • use toplevel parser to slice code into directives
  • support converting reason-ocaml syntax convertion. For re -> ml, pipe the result through ocaml format because refmt's output is so bad

Don't display evaluated result after an error

Unlike the normal compiler, when encountering an error (syntax error, type error) toplevel skips the current directive and move on to the next on.

To simulate a normal compiler behaviour, I hides all all warnings/errors report after the first error. The same thing needs to be done for type evaluation as well.

Make markdown links clickable

Use doc.markText to replace the link with another node with replaceWith option. Next thing is to figure out how to find the links

Github auth via a popup

I already have the localStorage listener in place. You for a better oauth experience, we can open a new pop up

Connected code blocks don't work

Remove comlink, interacting with web worker directly

This would solve several issues like:

  • Working loading state: #1
  • Prevent infinite loops: #39
  • More type safety
  • More browser supports (comlink uses ES6 proxy)

I actually have no idea how to achieving this yet so if you have some ideas, please comment

Title handling

Currently, on the Note page has the correct title, setup Helmet for all pages`

Add ability to reorder blocks

Right now if you have a code block then a text block, it's not easy to move the text block above the code without copy/pasting the content. Would be nice to have a move up/down button to control the blocks.

Wrong error location reporting

type network = Bitcoin | Testnet | Litecoin;

[@bs.module "bitcoinjs-lib"] [@bs.new] external new_tx_builder : network => 'a = "TransactionBuilder";

let createTxBuilder = (~network: option(network)=?, ()) => {
  let network = switch (network) {
  | Some(n) => n
  | None => Testnet
  };
  new_tx_builder(network);
};

This is OCaml's compiler acting up. This is the error message:

File "", Characters -1--1:
Error: The external function `TransactionBuilder' is not available

Add some way to import/export the content

It would be nice to be able to export the entire contents of the page to some text format that can be re-imported later.

I think ideally it would work like other tools where the content is encoded in the URL, but perhaps this is easier to implement and will make the tool usable more quickly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.