Comments (6)
From seeing how my kids use it, I would go with option A.
On Mar 22, 2014 5:11 AM, "David Bau" [email protected] wrote:
In multi-tab browsers, when you open two editing sessions to the same
file, it is too easy to lose track of which tab has your most recent edits
and overwrite them by accident.We should either avoid this situation or make it less confusing.
A few possible alternative ideas for the user model here:
(A) Make it less confusing: Edits in one tab are immediately reflected in
all tabs editing the same file. So it doesn't matter which tab you use;
they're all equivalent and in sync.(B) Avoid this situation, favoring the new tab: Opening a new tab for
editing a file closes (or moves to the parent directory) the old tab that
was editing the same file. Unsaved edits should be transferred from the old
tab to the new tab.(C) Avoid this situation, favoring the old tab: Opening a new tab for
editing a file that is already open in another tab opens the file in a
read-only mode, with a message that the file is already open for edit in
another tab.We could use localStorage to detect the multiple-tab case: a tab editing a
file can "ping" its editor-start-time and last-alive-time timestamps into
localStorage while it is open; and a new editor tab can see the other tab's
presence in localStorage, etc.Interested in comments about whether we think A, B, or C (or something
else) is the way to go.Reply to this email directly or view it on GitHubhttps://github.com//issues/55
.
from pencilcode.
Makes sense. I think you're right. Option A is probably the most forgiving.
Thinking about implementation: I think the technique to use to sync tabs in the same browser will be localStorage events. It's a new API and slightly different on different browsers.
http://stackoverflow.com/questions/4679023/bug-with-chromes-localstorage-implementation
from pencilcode.
Hi, is this issue still open.? I'm interested in implementation of this feature. So I was going through the codebase, and needed some help in identifying the parts of code to work on.
As far as I could see, the view listens for ~pickblock and ~selectpalette events, and logs it. We could use that function to also set a localStorage item. And then have a handler listen to "storage" events ~pickblock and ~selectpalette. The handler would call get localStorage and then call fireEvent of the window.pencilcode.view object to execute the just-saved object.
Is this the right approach.? (I'm unsure of how to use the view.js function fireEvent in controller.js)
from pencilcode.
Hello, sorry for the slow response (I've been at a conference). This is a pretty interesting bug to take on.
pickblock and selectpalette aren't the right events to track - those are all "getting ready to make a change but not necessarily making a change."
I would listen to "change" events from the underlying editors, in the dropletEditor.on('change' and the session.on('change',... in view.js.
These underlying events might not be exposed the way you need; if you need a new event from view.js to controller.js, then just wire one up by calling fireEvent in view.js and calling on('yourevent',...) in controller.js.
from pencilcode.
I tried it out and apparently it didn't require anything in controller.js. So I added some code in view.js -
/* placed in setPaneEditorData() */
window.addEventListener("storage", function(e) {
dropletEditor.setValue_raw(localStorage.getItem('dropletEditorValue'));
}, false);
session.on('change', function() {
...
localStorage.setItem('dropletEditorValue', dropletEditor.getValue());
...
});
It looks sweet to see two tabs syncing across, typing in one and seeing blocks form in the other. I used the dropletEditor.setValue_raw()
function since using setValue()
triggers the session.on('change')
listener again, which we don't want.
I didn't make a PR since this needs to be polished probably -
- Currently it would be triggered on any localStorage event, and though the actual text wouldn't be affected, it might be inefficient and slow down the tab.
- Controller logic in view.js - What you said above, using fireEvent we could access controller.js from view.js, but actually this I think requires access to dropletEditor in view.js triggered from controller.js. We can call a view function from controller, but those functions are defined in global scope thus cannot access
pane.dropletEditor
. So it was a problem. - To ensure cross-browser compatibility and for modularity, this npm module https://github.com/bevacqua/local-storage could be integrated - more robust in handling localStorage events.
Any recommendations.?
from pencilcode.
Terrific. Go ahead an open a PR, and we can take a closer look and discuss there.
Question on the local-storage wrapper:
- Do you know how big it is (pencilcode is too big already, so I want to be careful about picking up new dependencies)
- Do you know which browser incompatibilities it deals with?
from pencilcode.
Related Issues (20)
- Not working properly in mobile HOT 1
- Email button not working HOT 3
- p5.js not working? HOT 1
- Don't return placeholder HTML for non-existing .js files
- Feature Request: API for "create new file with starter code"
- UX: Blocks mode activates keyboard too often on mobile device
- Pencil Code Embed: setCode also resets palette.
- File icon is not saved if it's a new file
- Custom Block Palette: inconsistent behavior about multi-line snippets HOT 1
- trying to install pencil code at my server and getting ERROR when run GRUNT HOT 3
- how to integrate g+ into pencilcode
- error [email protected] install: `node-gyp configure build HOT 1
- I can't install pencilcode. please help!
- How to insert new block?
- Thumbnail popover is a bit misaligned when a new thumbnail is created
- Something worng when run grunt HOT 1
- Blocks for adding elements to array
- Custom palette using guide requires user be logged in, making link sharing difficult
- Unable to type properly on mobile devices
- Error while running grunt 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 pencilcode.