rangy

javascript execCommand('delete') not delete all selection div in chrome

我的梦境 提交于 2019-12-12 10:48:40
问题 I try to write an editor with contenteditable & execCommand Everything works fine on Firefox, but in chrome has an error with 'delete' command. Please view bellow photo: This is my code: var $obj = $('#myBlockDivId'); var selection = rangy.getSelection(); if (selection.rangeCount > 0) selection.removeAllRanges(); var range = rangy.createRange(); range.selectNode($obj[0]); selection.addRange(range); range.select(); when i console log: rangy.getSelection().toHtml() ==> it's right but when i

User-select: none behaves differently in Safari

巧了我就是萌 提交于 2019-12-12 09:38:49
问题 What I am trying to achieve I am building input-like content editable div. You are supposed to click some tags outside the div to add them inside the div while also being able to type around said tags. The problem and how to reproduce it I am using user-select: none (normal and webkit) to keep tag buttons from being selected, therefore losing my caret's position. It works in Firefox and Chrome but not in Safari (I aware of the -webkit- prefix and using it). Here is a fiddle where you can

How to get the HTML before, inside, and after a selection (not in textarea)?

放肆的年华 提交于 2019-12-12 09:36:00
问题 Here is what I am trying to accomplish: When a user uses a mouse, keyboard, or touch to select text inside "myDiv" I want to acquire three discreet chunks of HTML: the HTML before the selection (to the "left" of it), the HTML inside the selection, and the HTML after the selection (to the "right" of it). The html should be as it would appear with myDiv.innerHTML. The selection might start or end inside a tag pair (i.e., the isolated selection isn't necessarily valid HTML). I don't need to deal

Could not complete the operation due to error 800a025e

别来无恙 提交于 2019-12-12 08:39:39
问题 What does this error mean in IE10/11: Error: Could not complete the operation due to error 800a025e. And how would I debug it? It says its this line: this.nativeSelection.removeAllRanges(); https://code.google.com/p/rangy/source/browse/trunk/src/js/core/wrappedselection.js#416 See it in action here: http://panmedia.github.io/raptor-editor/tests/cases/selection/selection-expand.html 回答1: I had this error coming up recently, I fixed it with the following chceck: var sel = window.document

Object <object> has no method 'methodeX'

我的未来我决定 提交于 2019-12-12 03:32:02
问题 i get an error in chrome: Uncaught TypeError: Object s1A has no method 'applyToSelection' in Firefox(firebug) i get this: TypeError: val.applyToSelection is not a function i use the rangy-core and the rangy-cssclassappliere my Code: <script type="text/javascript"> window.onload = function() { rangy.init(); s1A = rangy.createCssClassApplier("css_1", true); }; //this is the Problem. function dosome (el) { var val = el.value; val.applyToSelection(); } </script> <body> <button value="s1A" onclick

Why Rangy library doesn't work with contenteditable in Opera?

只谈情不闲聊 提交于 2019-12-11 18:49:12
问题 I am using popular Rangy library inside contenteditable DIV. My code is pretty simple: var saved_selection = false; $('#contenteditable').bind('keypress mouseup', function(e){ $(this).find('.rangySelectionBoundary').remove(); saved_selection = rangy.saveSelection(); });​ Now this works pretty good in Chrome and FF. However, in Opera it behaves very strangely, because it doesn't allow to insert any characters in contenteditable and it rather looses focus, or at least it seems so. I have

Rangy: Creating a new highlight is remembering the old highlight

落爺英雄遲暮 提交于 2019-12-11 11:25:30
问题 I am using the highlighter module in Rangy. I have a div element, which has some html. The html is actually loaded from a file using ajax, I have a button which does this loading. Once the text is loaded, I can select a portion of the displayed html and press my "Highlight" button. This calls some Rangy code and highlights the text as desired... //called on document load rangy.init(); cssApplier = rangy.createCssClassApplier(highlightClassName, { normalize: true }); highlighter = rangy

Rangy - Module 'WrappedSelection' Not Supported

♀尐吖头ヾ 提交于 2019-12-11 02:54:53
问题 I am trying to use Rangy in my Google Chrome extension, but I keep on receiving the error "Module 'WrappedSelection' not supported". This is a bare-bones extension so I have not implemented any code in this project other then Rangy. Does anyone know if Rangy is compatible with a Google Chrome extension? 回答1: I'm no expert in Google Chrome extensions but I don't believe there's any reason why Rangy couldn't be used in one. I believe it's done using content scripts. A project called Feltipen

Rangy & ContentEditable - Set the Caret

一个人想着一个人 提交于 2019-12-10 10:17:24
问题 I'm trying out the latest version of the "rangy" jQuery plugin (1.2 beta) to set the caret in a contenteditable DIV with a specific offset. However, it responds with a weird error in Firefox: Security error" code: "1000 Here is the offending code: var el = $("#editablediv"), index = 11; var range = rangy.createRange(); range.setStart(el, index); var sel = rangy.getSelection(); sel.setSingleRange(range); The code fails when calling the setStart function. Could anyone give an example of the

Restore multiple selections from db using Rangy

核能气质少年 提交于 2019-12-08 05:59:41
问题 What i want to do : ->Show a plain HTML page to a user ->User has the ability to highlight text on that page ->When user logs in next time , i should be able to retrieve and show his previous (multiple) highlight on the page. What i have done : I used the Library/API : Rangy.With this iam able to select the text and highlight it with the users preferred color. The Problem : I tried the serialize and de-serialize function , but when i try to deserialize (after page has been reloaded) it gives