Comments (6)
I get it work by give a docID from template helper.
the problem is that i want to set its init content instead of session value.
Template['editor'].helpers({
docId: function () {
return this._id;
},
config: function () {
var content = this.content;
return function (editor) {
// ace.setTheme('ace/theme/monokai');
editor.setShowPrintMargin(false);
editor.getSession().setUseWrapMode(true);
editor.setValue(content);
console.log(editor);
console.log(content);
}
}
});
Content is loaded right, but just a second, it disappeared and overwrited by content the last time I edited.
So may be I can edit the content from the document collection or something?
from meteor-sharejs.
I think this is a problem with how we can react to updated data in Blaze, similar to Meteor-Community-Packages/meteor-autocomplete#30. The current system is a bit of a hack until the Blaze Component API is finalized. You are probably not using the helper as recommended, hence the bug. I'm not planning to completely fix this until an API for components is better defined.
Can you please provide the templates that you are using to load the editor? At least, you should try loading the package the way that the demo does it.
You may also be talking about the ShareJS option to replace a document's data when connecting. We don't really support that right now because the editor is initialized along with the open command.
Can you also please verify that you are on the latest version?
from meteor-sharejs.
Here is my editor related code:
- iron-router controller:
var EditorController = RouteController.extend({
template: 'editor',
data: function () {
return Posts.findOne(this.params._id);
}
});
Router.map(function () {
this.route('home', {
path: '/home',
controller: HomeController
});
this.route('editor', {
path: '/home/editor/:_id',
controller: EditorController
});
});
- editor template
<template name="editor">
{{> sharejsAce docid=docId callback=config id="editor"}}
</template>
- editor template helper
Template['editor'].helpers({
docId: function () {
return this._id;
},
config: function () {
var content = this.content;
return function (editor) {
// ace.setTheme('ace/theme/monokai');
editor.setShowPrintMargin(false);
editor.getSession().setUseWrapMode(true);
editor.setValue(content);
console.log(editor);
console.log(content);
}
}
});
- my Posts collection has a property
content
stored markdown text.
from meteor-sharejs.
When the editor refill its value from cache, it outputs the following line in the terminal:
I20140613-14:38:39.071(8)? Catchup X4pi9bCmWGQS5RDMn 0 -> 8
I just want to overwrite its init value, not from cache, but programmable initialize it.
from meteor-sharejs.
I can't tell from your description whether this is a UI issue that's causing the editor to be hooked up to the wrong document, or a feature request that is unsupported.
If you connect to a document with a certain name, you will get the contents of that document. That is what you are seeing with the Catchup ...
stuff as ShareJS is sending over the operations. If you want to "overwrite" the contents of the document, you can either replace it with something else, or just create a new empty document and write in the contents. What is it exactly that you are trying to do?
from meteor-sharejs.
Closing due to lack of response from @vampirefan.
In order to change the contents of documents, you will have to submit operations to the ShareJS server from either server or client code. Simply changing the value of the editor won't cut it. There are also some other options such as opening the ShareJS operation with the replace
option.
If you explain your use case better, I could provide some other suggestions. I have a feeling it's not necessary to do what you are doing now.
from meteor-sharejs.
Related Issues (20)
- ReferenceError: Cannot access 'ShareJS' before initialization HOT 2
- Editor permissions HOT 4
- ShareJS object not exported? HOT 2
- Multiple Ace Editor IDs HOT 2
- mizzao:[email protected] causes app to crash HOT 1
- broken with multiple app instances? HOT 1
- Uncaught Error: Cannot find module 'share/node_modules/browserchannel/dist/bcsocket-uncompressed' HOT 1
- Failed to get ops HOT 39
- Update CodeMirror? HOT 2
- Still Active? HOT 2
- Need to declare use of ecmascript HOT 3
- Update to codemirror 5.25.0
- ShareJS.model.on('applyOp',... causes textarea to lose focus HOT 1
- Alternative package for ShareDB and Meteor HOT 1
- Saving editor content to database HOT 1
- how to sync share js to the local file when something change on the server
- No compatible binary build found for mizzao:[email protected] HOT 1
- ShareJS not defined in Meteor 1.6 HOT 10
- Document was opened but closed right away
- does not save document HOT 1
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 meteor-sharejs.