Skip to content

Instantly share code, notes, and snippets.

View damien-monni's full-sized avatar

Damien Monni damien-monni

View GitHub Profile
@justinpawela
justinpawela / config
Created August 3, 2016 01:39
AWS CodeCommit Multiple Account Config
# This file is: ~/.ssh/config
# You may have other (non-CodeCommit) SSH credentials stored in this
# config file – in addition to the CodeCommit settings shown below.
# NOTE: Make sure to run [ chmod 600 ~/.ssh/config ] after creating this file!
# Credentials for Account1
Host awscc-account1 # 'awscc-account1' is a name you pick
Hostname git-codecommit.us-east-1.amazonaws.com # This points to CodeCommit in the 'US East' region
@johanneslumpe
johanneslumpe / callModifierForSelectedBlocks.js
Last active February 23, 2022 13:54
Draft.js utilities to inspect/modify selected block ranges
import { EditorState, SelectionState } from 'draft-js';
import getSelectedBlocks from './getSelectedBlocks';
/**
* Calls a provided `modifier` function with a selection for each
* selected block in the current editor selection. Passes through additional
* arguments to the modifier.
*
* Note: At the moment it will retain the original selection and override
@hperrin
hperrin / Get caret Y position in HTML (WYSIWYG) editor from document origin.
Created February 5, 2014 18:54
This function will give the Y position of the text cursor (caret) when it is in a contenteditable element. This particular one only works on CKEDITOR.
var getCaretYPosition = function(){
var editor = CKEDITOR.instances.editor1, //get your CKEDITOR instance here
sel = editor.getSelection(), // text selection
obj = sel.getStartElement().$, // the element the selected text resides in
range = editor.getSelection().getRanges(), // range of selection
container = range[0].startContainer.$, // get the DOM node of the selected text, probably a textnode
textlen = typeof obj.textContent === "undefined" ? obj.innerText.length : obj.textContent.length, // get the length of the text in the container
offset = range[0].startOffset; // get the offset from the beginning of the text in the container to the caret
if (container.nodeType === 3) { // if the container is a text node
while (container.previousSibling) { // add the length of all the preceding text nodes and elements in the same parent element