Comments (4)
After some more investigating I think I've found part of the solution.
Say we have this inside an editable region:
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
This is how it shows up in the Google Chrome Web Inspector Panel:
Now, when I click with the mouse after the first sentence, the inspector suddenly shows this:
Obviously, nothing has changed in the actual html layout, but the web inspector shows a different layout. I suspect this is because of the <em>
markers that get placed (and immediately removed) by Mercury at the start and end of a selection. You can even see this in the inspector where an element is added and removed in a flash.
So after clicking even once in an editable region, Mercury falsely detects changes and shows a confirm box before leaving the page.
This also happens when the page is first loaded, without any (clicking) action being triggered by the user. But it doesn't happen every single time in this case. So I think this has something to do with Mercury focussing the first element in a specific way IF the element couldn't be focussed in the default browser way (I think I read something about this in the code or the readme). So in this situation, it happens, not not every time.
I also can't see any changes in the inspector in this situation, but I suspect this is because it happens immediately when the page is loaded, and no change is visible because the cursor is actually placed at the start of the region, so no splitting of lines is taking place in the inspector.
from mercury.
You're right about most of this stuff, and it's impressive that you remember all of these details.. Yeah, the placing of the selection element totally breaks any "text" nodes, which is tremendously annoying -- it limits some of the things that are possible -- like placing the cursor in a word and wrapping that whole word in bold when you click the bold button (because it's now in two text nodes, which makes it way more complicated than it needs to be).. I'll eventually get around to refactoring all of that to use a better selection object -- if possible.. but I digress.
Mercury doesn't prompt when leaving unless it thinks there are changes.. there's a lot of things that tell mercury that changes have been made, and at some point that must be happening when no changes are made.. this has actually been on my list for a while, so I'll try and get to it today.
from mercury.
So the only way I could get this to happen is by hitting meta+r to refresh the page.. navigating around was fine for me -- so you may have something that's breaking it (calling region.execCommand or something), or you could be seeing what I'm seeing and just mis-interpreting it like I did.
I've made some adjustments to how the changes are tracked, and moved them to keyup instead of keydown.. that way the browser will do it's thing on keydown, and on keyup, if the browser hasn't done anything like refreshed the page we'll assume changes were made.
Hope that solves your issue, but I'm curious if you were just seeing what I was seeing as well as it seems likely.
from mercury.
Well, what I was seeing was a notification from mercury before page unload (either through a refresh or clicking a link on the page (outside editable regions). The notice always showed in this situation if I had clicked inside an editable region before navigating away and it would sometimes show when not doing anything on the page at all, simply navigating to the page and then navigating away right away triggered the warning.
I haven't tested this last scenario to the full extend yet, so I will do that when I get back to my workstation on Monday, and will see if your changes solved things.
from mercury.
Related Issues (20)
- Routes method is patch, can we do it?
- Is mercury stopped since 2013 dec? HOT 2
- How to prevent loading mercury.js on all pages?
- Paste image from clipboard
- Can we use mecury editor as docx editing tool ? HOT 1
- mercury editor blank page in heroku HOT 1
- Mercury2 normal html example ?
- Snippets with javascripts included HOT 1
- Snippet options not saved correctly [$15]
- Mercury2 on HTML
- Uncaught TypeError: Cannot read property 'stylesheets' of undefined
- /usr/local/rvm/gems/ruby-2.3.0/gems/actionpack-4.2.5/lib/action_dispatch/routing/mapper.rb:238:in `add_request_method': You should not use the `match` method in your router without specifying an HTTP method. (ArgumentError)
- 34324
- bundler 1.13.1 objects to git protocol
- Section: Rails support in Readme.md? HOT 1
- How to remove mercury? HOT 1
- Neither install or post_install are working in Rails 5.2 HOT 2
- Regular Expression DoS vulnerability
- Mercury failed to load Live www.domain.com HOT 1
- Mode Set is closed
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 mercury.