Comments (4)
If you want to build for the frontend you'd probably want to use browserify. Otherwise this project is currently packaged as a backend node.js project.
from rich-text.
Thanks for replying
I'd tried that but hadn't had any success so far - I'll keep chipping away at the issue though.
from rich-text.
What issue did you run into with browserify?
from rich-text.
Hi
My issue was that the rich-text ot type wasn't being assigned to the browser window.ottypes global object.
Using browserify I had to add this to the bottom of rich-text/lib/type.js:
if (typeof(window) !== 'undefined') {
var _types = window.ottypes = window.ottypes || {};
var _t = module.exports;
_types['rich-text'] = _t.type;
if (_t.uri) _types[_t.uri] = _t.type;
}
I'd hacked that from the 'after.js' script.
Then I browserified type.js and placed it in node_modules/share/webclient/
In my node app script i've
var livedb = require('livedb');
var sharejs = require('share');
var express = require('express');
var Duplex = require('stream').Duplex;
var browserChannel = require('browserchannel').server;
var backend = livedb.client(livedb.memory());
var share = require('share').server.createClient({backend: backend});
var otTypes = require('ottypes');
var richText = require('rich-text');
var app = express();
app.use(express.static('public'));
// Load static share.js file into front end
app.use(express.static(sharejs.scriptsDir));
// Register the share ot custom type!
livedb.ot.registerType(richText.type);
My front end js is currently looking like this:
var socket = new BCSocket(null, {reconnect: true});
var sjs = new sharejs.Connection(socket);
sharejs.registerType(window.ottypes['rich-text']);
var doc = sjs.get('docs', 'hello');
// Subscribe to changes
doc.subscribe();
// This will be called when we have a live copy of the server's data.
doc.whenReady(function() {
console.log('doc ready, data: ', doc, doc.getSnapshot());
// Create a rich-text doc
if (!doc.type) {
console.log('doc has not type - trying to create a rich-text doc');
doc.create('rich-text', '');
console.log('created as ', doc);
}
var editor = new Quill('#editor', {
modules: {
'authorship': { authorId: 'galadriel', enabled: true },
'multi-cursor': true,
'toolbar': { container: '#toolbar' },
'link-tooltip': true
},
theme: 'snow'
});
editor.on('selection-change', function(range) {
console.log('selection-change', range)
});
editor.on('text-change', function(delta, source) {
console.log('text-change', delta, source)
doc.submitOp(delta, function (error, appliedOp) {
console.log('submit op done', error, appliedOp);
});
});
// This is not currently picking up other clients changes
doc.on('remoteop', function(op) {
console.log('remote op received', op);
})
});
I'm not yet picking up the ot changes - but Im pretty happy so far as I seem to be on the right path
from rich-text.
Related Issues (20)
- NPM package rename to 'ot-rich-text'? HOT 2
- Bower package HOT 1
- Uncaught Error: diff() called on non-document HOT 6
- clarify if TP2 is supported HOT 2
- Insert Embed Operation HOT 1
- clone() implementation in op.js HOT 5
- Small documentation nit in Quick Example HOT 1
- diff() not working as expected HOT 7
- compose with { retain: 0 } does not work correctly HOT 1
- Question: Are operations invertable? HOT 1
- Get rid of package.json import in type.js HOT 1
- How to get a standalone browser client js? HOT 3
- transform insert at the same position - incorrect result HOT 3
- Presence HOT 3
- Implement transform(index)
- How this implementation relates to ot-text and ot-text-tp2? HOT 1
- delta.length() is wrong when you have implied retain at the end HOT 5
- Python port of the rich-text HOT 6
- Operation transformation apply deltas to server side HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rich-text.