-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alec Gibson
committed
May 20, 2020
1 parent
25b77a9
commit c0ad0f9
Showing
9 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ coverage/ | |
# Consumers will override this anyway, so don't bother committing | ||
package-lock.json | ||
yarn.lock | ||
!/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import QuillCursors from './quill-cursors/quill-cursors'; | ||
import Cursor from './quill-cursors/cursor'; | ||
import '../assets/quill-cursors.scss'; | ||
export { QuillCursors as default, Cursor }; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import IQuillCursorsOptions from './i-quill-cursors-options'; | ||
import IQuillRange from './i-range'; | ||
export default class Cursor { | ||
static readonly CONTAINER_ELEMENT_TAG = "SPAN"; | ||
static readonly SELECTION_ELEMENT_TAG = "SPAN"; | ||
static readonly CURSOR_CLASS = "ql-cursor"; | ||
static readonly SELECTION_CLASS = "ql-cursor-selections"; | ||
static readonly SELECTION_BLOCK_CLASS = "ql-cursor-selection-block"; | ||
static readonly CARET_CLASS = "ql-cursor-caret"; | ||
static readonly CARET_CONTAINER_CLASS = "ql-cursor-caret-container"; | ||
static readonly FLAG_CLASS = "ql-cursor-flag"; | ||
static readonly SHOW_FLAG_CLASS = "show-flag"; | ||
static readonly FLAG_FLIPPED_CLASS = "flag-flipped"; | ||
static readonly NAME_CLASS = "ql-cursor-name"; | ||
static readonly HIDDEN_CLASS = "hidden"; | ||
static readonly NO_DELAY_CLASS = "no-delay"; | ||
readonly id: string; | ||
readonly name: string; | ||
readonly color: string; | ||
range: IQuillRange; | ||
private _el; | ||
private _selectionEl; | ||
private _caretEl; | ||
private _flagEl; | ||
private _hideDelay; | ||
private _hideSpeedMs; | ||
private _positionFlag; | ||
constructor(id: string, name: string, color: string); | ||
build(options: IQuillCursorsOptions): HTMLElement; | ||
show(): void; | ||
hide(): void; | ||
remove(): void; | ||
toggleFlag(shouldShow?: boolean): void; | ||
updateCaret(rectangle: ClientRect, container: ClientRect): void; | ||
updateSelection(selections: ClientRect[], container: ClientRect): void; | ||
private _updateCaretFlag; | ||
private _clearSelection; | ||
private _addSelection; | ||
private _selectionBlock; | ||
private _sortByDomPosition; | ||
private _sanitize; | ||
private _serialize; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default interface IDelta { | ||
ops: IOp[]; | ||
} | ||
export interface IOp { | ||
insert?: any; | ||
delete?: number; | ||
retain?: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default interface IQuillCursorsOptions { | ||
template?: string; | ||
containerClass?: string; | ||
selectionChangeSource?: string; | ||
hideDelayMs?: number; | ||
hideSpeedMs?: number; | ||
transformOnTextChange?: boolean; | ||
boundsContainer?: HTMLElement; | ||
positionFlag?: (flag: HTMLElement, caretRectangle: ClientRect, container: ClientRect) => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default interface IQuillRange { | ||
index: number; | ||
length: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import IQuillCursorsOptions from './i-quill-cursors-options'; | ||
import Cursor from './cursor'; | ||
import IQuillRange from './i-range'; | ||
export default class QuillCursors { | ||
private readonly _cursors; | ||
private readonly _quill; | ||
private readonly _container; | ||
private readonly _boundsContainer; | ||
private readonly _options; | ||
private _currentSelection; | ||
constructor(quill: any, options?: IQuillCursorsOptions); | ||
createCursor(id: string, name: string, color: string): Cursor; | ||
moveCursor(id: string, range: IQuillRange): void; | ||
removeCursor(id: string): void; | ||
update(): void; | ||
clearCursors(): void; | ||
toggleFlag(id: string, shouldShow?: boolean): void; | ||
cursors(): Cursor[]; | ||
private _registerSelectionChangeListeners; | ||
private _registerTextChangeListener; | ||
private _registerDomListeners; | ||
private _updateCursor; | ||
private _indexWithinQuillBounds; | ||
private _leafIsValid; | ||
private _handleTextChange; | ||
private _emitSelection; | ||
private _setDefaults; | ||
private _lineRanges; | ||
private _transformCursors; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
declare const template: string; | ||
export default template; |