Skip to content

Instantly share code, notes, and snippets.

What is Substance?

  • Library for web-based WYSIWIG editors
  • Not a widget, as other existing editors
  • Substance => Customization
    • Data schema
    • Converters
    • Rendering
    • Toolbar / Tools
    • Keybindings

What is Substance?

Substance is a library for creating web-based WYSIWIG editors. With all the features you would expect from a WYSIWIG editor.

As opposed to other existing editors, such as TinyMCE, Aloha, etc. Substance is not just a widget you include into your web-application. It is a library. Widgets are just not enough. They lead to a bad UX. They are like alien isles within the web-app. And those are very limited regarding customization.

The unique point of Substance: Customizability. You can customize everything. And we try to make this as simple as possible for you.

Understanding Component.js stack-traces

With the new Component.js API it is now easier to debug errors in the render stack. Still it needs a basic understanding of how things are working.

There is an inherent problem with the approach of Component.js that makes it quite challenging to create a transparent debug experience. Component.js lets you compose VirtualElements a-priori, pass them around as props, and append them to a parent element at a later time. The context of definition, the owner component, is often different to the parent component.

Think of the following situation:

/*
This example shows how JS expression can be executed with dynamic context.
Consider you want to use symbols in an expression, for example
```
sum(1,2,PI)+ln(100)-x
```
The problem is, that eval() does not provide a means to ingest a context, so that
`sum`, `PI`, `ln`, or `x` could be evaluated.
@obuchtala
obuchtala / rebase.sh
Created September 21, 2017 14:22
Rebasing a branch and retain the original committer information.
#!/usr/bin/env bash
# Fix branch commit data to be the same as author data
set -o errexit -o pipefail -o noglob -o noclobber -o nounset
IFS=$'\n\t'
parent=$1
# The command to execute for each commit
@obuchtala
obuchtala / Decentralized OT - concept.md
Last active November 15, 2017 03:38
Substance OT on hypercore feeds

Summary

See https://github.com/substance/dot/blob/master/README.md for details.

Idea is to have a 'bare' repo consisting of meta data, and a set of log files. Every log is written just by a single user. The owner is maintaining meta-data and a master log.

The master.log is changed only by the owner, by merging pull-requests, where only fast-forward merges in terms of git are possible. It looks like this:

@obuchtala
obuchtala / typedoc-search-field.html
Last active November 30, 2017 23:51
How the search field of typedoc generated documentation works
<html>
<head>
<style type="text/css">
#tsd-search > ul > .current {
background: red;
}
</style>
</head>
<body>
<div id="tsd-search">

Custom Functions in Stencila

Nokome Bentley and Oliver Buchtala have investigated options to achieve this and found a very simple and generic solution. Stencila Cells can return a special value of type function. This does not differ very much from other return values, such as a number. Returned functions are however special, they are passed around just as the information necessary to ask the Stencila Host to actually run the function. This approach introduces only a rather tiny concept, but has a huge impact: for example a cell executed in R can register a function, which can be executed in every other context, e.g. in Javascript. Reactive evaluation, i.e. automatic updates, are coming for free, as functions are just treated as regular values.

Example

A function could be defined in Javascript