All Projects → Cirru → respo-cirru-editor

Cirru / respo-cirru-editor

Licence: other
Cirru Editor in calcit-js Respo

Programming Languages

Cirru
14 projects
HTML
75241 projects
CSS
56736 projects
javascript
184084 projects - #8 most used programming language

Labels

Respo Cirru Editor, calcit-js version

Cirru Editor in Calcit-js Respo. Previous implemented in ClojureScript.

Demo http://repo.cirru.org/respo-cirru-editor/

Support several basic shortcuts from Clacit Editor.

Usage

Import comp-editor like this:

ns app.ns
  :require
    cirru-editor.comp.editor :refer $ comp-editor
    cirru-editor.util.dom :refer $ focus!

Arguments of comp-editor:

defn on-update! (snapshot dispatch!)
  dispatch! :update snapshot

defn on-command (snapshot dispatch! e)

defn schema $ {}
  :snaphot $ {}
    :tree ([])
    :focus ([])
    :clipboard []

; "states comes from [email protected] states management"
defn render (states snapshot)
  div
    {} (:style ({}))
    comp-editor states snapshot on-update! on-command

focus! is a side-effect. You have to make sure it's called only editor is changed. Respo does not provide a didMount hook, you have to handle it globally on you own.

Tree updater

Function cirru-editor.core/cirru-edit for editing:

cirru-edit snapshot op op-data

with snapshot in a structure:

{}
  :tree $ []
  :clipboard $ []
op op-data usage
:update-token [] coord new-token edit token
:after-token coord insert empty token after current position
:before-token coord add new token before of current token
:fold-node coord increase indentation
:unfold-expression coord decrease indentation
:unfold-token coord decrease indentation from token
:before-expression coord add new expression before current position
:after-expression coord add new expression after current position
:prepend-expression coord add new token at head of current expression
:append-expression coord add new token at tail of current expression
:remove-node coord remove at current position
:focus-to coord focus to position
:node-up coord move focus to parent
:expression-down coord move focus to first child
:node-left coord move focus to previous sibling
:node-right coord move focus to next sibling
:command-copy coord copy target to buffer
:command-cut coord cut target to buffer
:command-paste coord paste buffer at current position
:tree-reset tree reset
:duplicate-expression coord duplicate current expression

returns structure:

{}
  :tree $ []
  :clipboard $ []
  :focus $ []

Develop

https://github.com/calcit-lang/respo-calcit-workflow

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].