Giter Site home page Giter Site logo

prosemirror-go's Introduction

ProseMirror in Go

go.dev reference Build Status Go Report Card

Introduction

ProseMirror is a well-behaved rich semantic content editor based on contentEditable, with support for collaborative editing and custom document schemas. This repository contains a port in Go of prosemirror-model and prosemirror-transform in order to have the server part of the collaborative editing in Go.

Notes

  1. Only the code necessary for writing a server for collaborative editing will be ported, not things like translating a document to/from a DOM representation which are only useful on the clients.

  2. In go, the maps don't preserve the order of the key (and even the JSON spec doesn't say that there is an order for object fields). OrderedMap in the JS schema needs to be serialized in JSON to an array of tuples [key, value] to keep the order:

[
  ["em", { "inclusive": true, "group": "fontStyle" }],
  ["strong", { "inclusive": true, "group": "fontStyle" }]
]
  1. Go doesn't support optional arguments like JS does. We are emulating this with variadic arguments:
  // :: (number, number, (node: Node, pos: number, parent: Node, index: number) โ†’ ?bool, ?number)
  nodesBetween(from, to, f, startPos = 0) {
    this.content.nodesBetween(from, to, f, startPos, this)
  }
func (n *Node) NodesBetween(from, to int, fn NBCallback, startPos ...int) {
	s := 0
	if len(startPos) > 0 {
		s = startPos[0]
	}
	n.Content.NodesBetween(from, to, fn, s, n)
}
  1. Exceptions in JS can be manager in Go by returning an error, or with a panic. We have tried to panic only for logic bugs and out of bounds access, and returning an error everywhere else.

License

The port in Go of ProseMirror has been developed by Cozy Cloud and is distributed under the AGPL v3 license.

prosemirror-go's People

Contributors

nono 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

prosemirror-go's Issues

Care to license it under a permissive license?

I understand that for building a cloud service itself AGPL is a good choice and that your other repositories have AGPL license. But this is package is something which can be used in a wide range of different projects as a library and having then the whole other project become AGPL because of it is a bit far reaching, especially because the ProseMirror itself is licensed under MIT.

There is no ALGPL license to be similar to LGPL.

So I wonder, could you please relicense this package under some permissive license?

NodeType.DefaultAttrs not initialised properly

When creating a new node type the defaultAttrs function is used. But instead of setting up the default value, it adds the entire Attribute object there.
This leads to the created objects with CreateAndFill to have a bad format, this also affects the (n *Node) ToJSON method since the resulting object cannot be JSON-serialised if it has any Attributes.

Here is the original prosemirror-model counterpart of the method where you can see that attr.default is added to the map instead of just attr.
https://github.com/cozy/prosemirror-go/blob/master/model/schema.go#L21
https://github.com/ProseMirror/prosemirror-model/blob/master/src/schema.ts#L22

ToDOM

Hello,

Just wanted to say thanks for this port!

For our purposes, we needed this library and the ToDOM functions in Go. I have started porting most of the ToDOM code at https://github.com/shodgson/prosemirror-go.

Most of the tests from ProseMirror JS pass. The biggest limitation at the moment is that the DOMOutputSpec does not have a 0 (hole), and instead content is inserted in the last child of the html node.

If I continue development of the ToDOM module, would you be interested in merging it here?

(I am a novice in Go and ProseMirror... so this has been a very educational exercise and there is still plenty to do before it is polished)

Thanks.

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.