qubitproducts / cherrytree Goto Github PK
View Code? Open in Web Editor NEWA flexible nested router.
License: MIT License
A flexible nested router.
License: MIT License
Right now I'm trying out CherryTree as a possible replacement for Zim. However, I have found two issues with it.
With every rich-text editing app I've tried, when at the front of an item in a bullet list (IE: the caret is before the text, but after the bullet and space), pressing tab will indent the bullet item's level. CherryTree does not follow this pattern, and instead indents the text while leaving the bullet alone. In order to indent the list item's level, you need to indent before the bullet.
The second issue is that when you are on a list item's line and press return, the indent level is not preserved.
So, if you had a list like this:
And then hit return, the indentation level goes back to the first one, instead of matching the indent level of the third item. So, you would get this:
Instead of this:
These are the only main issues I have so far that I find problematic. Of course, it is entirely possible that the real issue is that CherryTree doesn't support proper list indentation levels, in which case this bug report can be treated as a feature/enhancement request.
if onURLChanged throws an exception - the errors get swallowed - they shouldn't be.
I may just have a misunderstanding of the purpose of willTransition here, but I would have thought that willTransition would be called whenever a transition occurs?
Example of what I am seeing:
router.addRoute("foo", Route.extend({
willTransition: function () {
console.log('bar');
}
});
router.startRouting();
router.transitionTo("foo");
router.transitionTo("foo");
The above example will only log bar once.
In the documentation, it says the default is true
Explore a way to activate a state right after it's model is fetched without waiting for child states. Atm it's possible to just call this.activate()
in the model manually, but if a transition away from this route occurs, cherrytree won't deactivate the route as it was never entered (?). Latest versions of router.js has the substates, so those might be the answer.
Code
history.js
to browser.js
Docs
Other
reactjs + webpack + npm version
If the parent route has a key "foo" in the context and the child route tries to set "foo" in the context - throw an exception. This is most likely an error. You typically never want to overwrite / shadow the context.
And it's easy to do so accidentally by returning some raw
Took me a while to work out what was wrong! The worked example in requirebin has the (correct) version of router.addRoute, whereas the docs refer directly to router.routes.
this way less need to access parent things like this.parent.view?
This will make all route names more consistent.
Try using saucelabs or testling
When using cherrytree.transitionTo() or generate() the root is appended twice. Seems to be that HistoryLocation.formatURL and LocationBar.update both add it.
Should HistoryLocation.formatURL return path unmodified if pushState is true?
This will make it cleared that it's something that bubbles and 'false' can be returned to stop propagation,
This allows continue using links for things, but helps manage history more granulary.
existance of update method should indicate that the route won't be reloaded, returning false overrides that behaviour?
only pass it into the various hooks as router.js
does
sometimes we could parallelize the model calls for faster transitions
If it overwrites the context of the route or shadows context of the parent routes.
Proposal: returning in the model hook should only be used for blocking, not for anything else. If someone wants to block and then put the return data somewhere, they can do that manually. This is much simpler and much more transparent.
In general, the context stuff needs to be simplified greatly.
I want to name the models so that the child routes could easily access them via the name, but I can't figure out a simple way to do that, e.g. this is clunky:
model: function () {
var model1 = new Model();
var model2 = new Model();
return when.join(model1.fetch(), model2.fetch()).then(function () {
return {
model1: model1,
model2: model2
}
});
}
With the above snippet, child routes can do this.get("model1")
and they'll get the model1 since it's been "named" in the context - the return value of model.
First it's missing jquery
as a dependency, but after adding that, I'm still getting:
~/github/cherrytree/examples/hello-world 826b1df|master ✹✭
6:14PM ᐅ npm start
> [email protected] start /Users/nblack/github/cherrytree/examples/hello-world
> webpack-dev-server --colors --no-info --port=8000 --content-base .
http://localhost:8000/webpack-dev-server/
webpack result is served from /
content is served from /Users/nblack/github/cherrytree/examples/hello-world
Hash: 9590aaacd90b7edeaa10
Version: webpack 1.10.5
Time: 1033ms
Asset Size Chunks Chunk Names
bundle.js 272 kB 0 [emitted] main
bundle.js.map 343 kB 0 [emitted] main
chunk {0} bundle.js, bundle.js.map (main) 260 kB [rendered]
[0] ./index.js 4.36 kB {0} [built]
[1] ./~/jquery/dist/jquery.js 248 kB {0} [built]
[2] /Users/nblack/github/cherrytree/index.js 56 bytes {0} [built] [1 error]
[3] ./style.css 1.17 kB {0} [built]
[4] ./~/css-loader!./style.css 999 bytes {0} [built]
[5] ./~/css-loader/cssToString.js 352 bytes {0} [built]
[6] ./~/style-loader/addStyles.js 5.51 kB {0} [built]
ERROR in /Users/nblack/github/cherrytree/index.js
Module not found: Error: Cannot resolve module 'babel' in /Users/nblack/github/cherrytree
@ /Users/nblack/github/cherrytree/index.js 3:17-40
does it also need loader: 'babel?optional=runtime'
like the main project? Sorry I have no experience with webpack.
Alternatively requirebin should be sufficient.
Either vendorize router.js, route-recognizer and use a light promise shim instead of rsvp (it's unlikely someone wants router.js and route-recognizer separately, but they could also be exposed from within cherrytree).
Alternatively, help router.js, route-recognizer and rsvp sort their stuff out in terms of global/amd/cjs/bower/npm builds.. none of those are working together at this point.
There are a couple of events in the routes: willTransition, error and queryParamsDidChange - consider making it explicit that they're events by putting them into route.events.willTransition or so like the original router.js does it.
Events are special in that they're called from the right most route to the top, and the propagation of them can be stopped so it's worth making them look different from the rest of the hooks.
Rename it to locations/memory
.
In the "benefits" section, a generate
method is mentioned, but its API is never documented.
We never want someone to change that object and affect the router state.
Hey there :
Context:
router.map(function() {
this.route("launch", { path: "/launch"});
});`
`router.handlers['launch'] = Route.extend({ before, model,after})`
By doing it this way i get this error Uncaught TypeError: Cannot set property 'launch' of undefined
If i change it to (works):
router.routes["launch"] = Route.extend({});
However I've read the docs and they say the former it's the way to go, also notice you committed the change 2a8a0ca
I'm on version "cherrytree": "^0.5.0",
Installed via NPM.
Using Browserify browserify router-amd.js > router.js
,
Not sure what's wrong here, also I'm following this tut --> http://requirebin.com/?gist=aa3edb9fb05fa01c59f0#
E.g. if I return {foo: this.get("foo"); } in the model hook. The next time this model hook is called, the "foo" will be the old foo, not the current foo of the parent.
Very confusing overall. Need to simplify the context stuff.
The documentation for where to use pushState
and other location options should be updated to explicitly say that the these options should be inside a locationOptions
key inside the options. That will save some development time to someone else :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.