rangy

Angular 4 and modules: Rangy

坚强是说给别人听的谎言 提交于 2019-12-08 05:08:28
问题 I'm new to Angular 4, I just created a simple app forking the Angular quickstart and now I'm trying to import Rangy. On package.json I now have the following dependencies: "rangy": "^1.3.0", "@types/rangy": "^0.0.27" I expected to be able to simply do a import {RangySelection} from 'rangy'; but that just gives me the error TS2306: File '/projects/mylittleapp/node_modules/@types/rangy/index.d.ts' is not a module. What am I doing wrong? EDIT: I understand that it has to do with SystemJS and how

Rangy: word under caret (again)

人走茶凉 提交于 2019-12-08 02:58:30
问题 I'm trying to create a typeahead code to add to a wysihtml5 rich text editor. Basically, I need to be able to insert People/hashtag references like Twitter/Github/Facebook... do. I found some code of people trying to achieve the same kind of thing. http://jsfiddle.net/A9z3D/ This works pretty fine except it only do suggestions for the last word and has some bugs. And I want a select box like Twitter, not a simple "selection switching" using the tab key. For that I tried to detect the

Rangy: word under caret (again)

若如初见. 提交于 2019-12-06 12:27:22
I'm trying to create a typeahead code to add to a wysihtml5 rich text editor. Basically, I need to be able to insert People/hashtag references like Twitter/Github/Facebook... do. I found some code of people trying to achieve the same kind of thing. http://jsfiddle.net/A9z3D/ This works pretty fine except it only do suggestions for the last word and has some bugs. And I want a select box like Twitter, not a simple "selection switching" using the tab key. For that I tried to detect the currently typed word. getCurrentlyTypedWord: function(e) { var iframe = this.$("iframe.wysihtml5-sandbox").get

Rangy & ContentEditable - Set the Caret

浪子不回头ぞ 提交于 2019-12-05 22:34:36
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 proper usage of rangy please? I found the issue, I was supposed to pass through the correct node which is

User-select: none behaves differently in Safari

白昼怎懂夜的黑 提交于 2019-12-05 09:30:29
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 reproduce the problem. What I've tried The root of my problem was maintaining the caret's position while

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

烈酒焚心 提交于 2019-12-05 02:11:30
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 with special scenarios like absolute-positioned elements within the selection; all of the selections I

Adding <h1> around a selection

喜欢而已 提交于 2019-12-04 22:38:00
I have a jsfiddle here - http://jsfiddle.net/88em6qq9/ - where I'm trying to add <h1> tags around a selection of the entire line: "Here is some content and here too" Selecting the entire line and releasing the mouse button goes into the handler but rounding off the start and end end points with setStartBefore() and setEndAfter() gets me to different start and end containers, so the surround doesn't work. If I put "Here is some content" in its own <span> - see http://jsfiddle.net/88em6qq9/1/ - then we round to the same container and the h1 insert does work. But I need a solution that puts <h1>

Getting the parent node for selected text with rangy library

别等时光非礼了梦想. 提交于 2019-12-04 21:54:35
问题 I'm using the rangy library and can select text in a content editable as follows: var sel = rangy.getSelection(); alert(sel); I can't figure out how to get the selected text parent node/element. For example, if I'm selecting text that is <strong>My Text</strong> or <h1>My Title</h1> how can I include the strong node or H1 element also? 回答1: sel.anchorNode.parentNode will get you the parent node of the node containing only one end of the selection. To get the innermost containing element for

Could not complete the operation due to error 800a025e

痞子三分冷 提交于 2019-12-04 03:18:27
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 I had this error coming up recently, I fixed it with the following chceck: var sel = window.document.getSelection(); if (sel.rangeCount > 0 && sel.getRangeAt(0).getClientRects().length > 0) { sel.removeAllRanges();

contenteditable div: IE8 not happy with backspace remove of HTML element

你。 提交于 2019-12-03 04:10:49
I am making use of a contenteditable div in combination with the rangy Javascript library to insert HTML at the cursor position. End of the day the contents of the div commonly looks like: <div contenteditable="true"> "Hello " <button contenteditable="false" data-id="147">@John Smith</button> " " </div> Users get suggested upon pressing '@' and get subsequently inserted as a button when selected (ala Google Plus). I also insert a   after this button. The button gets removed in Chrome/Safari/Firefox when you hit backspace (after first removing the   ), but not in IE8. In IE8 the cursor merely