Skip to content

Instantly share code, notes, and snippets.

@tranduongms1
tranduongms1 / quill-figure-with-caption.js
Last active December 12, 2023 14:04
Quill figure with caption, base on BlockEmbed
import Quill from 'quill';
const Module = Quill.import('core/module');
const BlockEmbed = Quill.import('blots/block/embed');
class ImageBlot extends BlockEmbed {
static blotName = 'image';
static tagName = ['figure', 'image'];
static create(value) {
@nathanlogan
nathanlogan / component.js
Created November 15, 2016 19:29
Emulate URL anchor page scroll functionality in a React component
import React, { Component } from 'react'
class MyTopLevelComponent extends Component {
componentDidMount () {
this.scrollToHashId()
}
componentDidUpdate () {
this.scrollToHashId()
}
@renancouto
renancouto / color.lighten.js
Created January 30, 2013 17:58
Method to lighten / darken hex colors using Javascript.
var LightenColor = function(color, percent) {
var num = parseInt(color,16),
amt = Math.round(2.55 * percent),
R = (num >> 16) + amt,
B = (num >> 8 & 0x00FF) + amt,
G = (num & 0x0000FF) + amt;
return (0x1000000 + (R<255?R<1?0:R:255)*0x10000 + (B<255?B<1?0:B:255)*0x100 + (G<255?G<1?0:G:255)).toString(16).slice(1);
};