Skip to content

Commit

Permalink
Add complex attribute support
Browse files Browse the repository at this point in the history
This change moves our `quill-delta` dependency onto our own forked
version, which has support for [complex attributes][1], which we need
for track changes.

[1]: slab/delta#48
  • Loading branch information
Alec Gibson committed Mar 30, 2020
1 parent ffb5c69 commit 511393d
Show file tree
Hide file tree
Showing 4 changed files with 332 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
language: node_js
node_js: '6'
node_js: '10'
script:
- npm test
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# Rich Text OT Type [![Build Status](https://travis-ci.org/ottypes/rich-text.svg?branch=master)](https://travis-ci.org/ottypes/rich-text)

## Why fork?
## Reedsy: Why fork?

We're running on a fork of the original [`rich-text` operational transform type](https://github.com/ottypes/rich-text). This is because we have a need to store metadata on our rich text documents so that we can determine which book a given piece of content belongs to. We need to know this so that we can validate a user's access to the content in middleware.
We need the following features on top of the original `rich-text` type:

The alternative to this solution would have been to store a separate Mongo document that maps a book to all the chapters it owns, requiring a database lookup every time we submit an op, which would be quite heavy. This could naturally be eased a bit with caching, but cache invalidation is generally non-trivial, and storing metadata on the chapter itself feels more "natural".
- additional metadata fields
- support for complex attributes

The result is an extremely small wrapper around the original type, which stores a metadata object on the document. Note that intermittent deltas should remain entirely unaffected, and it will only be stored on creation, and restored on fetch.
### Metadata fields

In order to perform authentication on our documents, the documents must have a concept of which book they belong to. We add this into an additional metadata field, which the original `rich-text` type does not support.

### Complex attributes

Attributes are typically only "1 layer" deep. We need arbitrarily-nested attributes, which can be partially updated, in order to support track changes. For more details, see [this pull request](https://github.com/quilljs/delta/pull/48).

## Introduction

Expand Down
Loading

0 comments on commit 511393d

Please sign in to comment.