-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Read only mode #1035
Read only mode #1035
Changes from 1 commit
e78b22d
e40c591
2a32659
b710e5e
d259339
0586a81
cb2622e
fac51fd
7b1cffe
f2b4018
1a4fff1
f5e9a66
7c726d4
552d090
4c0d806
d42042d
1a6f9a1
ffa78fd
e671a6e
0680c4d
21cac86
b32b2cb
968280a
775ccbc
f4c4051
2997ed0
c66105b
4a81699
7eb642d
72213f2
7f876e8
8456da7
66e70fa
5941ef0
9b92e6c
77534fe
4f6164c
5218a6a
ae8591c
c3ba372
f291aa0
ec63dcd
6edb7bc
05766a6
65f51c2
b90b8c5
6e79df6
b90532e
f6b7b2e
e3410be
b0ddb10
1eb6d81
5fe8b08
7c3bf76
ffe5bbc
ff6bd2d
e1500f7
26b19a3
8341c33
239aaf6
4cea66f
0e374ab
7992995
cefe8da
9bbf37d
884baf2
f983a5a
d7d8be8
f07886d
c82d359
ea75bf2
5772c04
96a1780
22dd508
a296077
8f74b37
4aaddfe
1a61d3f
a00090a
99d074a
014ea48
f02e49c
93829a0
5921260
6ec8d06
1af17f0
e8efd87
edece25
f0b5dc0
189e7b6
34a425f
7a3162f
748aa7d
6977b33
ef17dbf
a318dff
b2865ad
15b2794
d04f1ae
7f1ffcd
efef57f
cd6d263
899dd3f
59b2688
24ab8f9
d671342
29945ae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -158,7 +158,7 @@ export default class BlockManager extends Module { | |
private _blocks: Blocks = null; | ||
|
||
/** | ||
* Binded listener ids | ||
* listener identifiers bound on elements | ||
*/ | ||
private listenerIds: string[] = []; | ||
|
||
|
@@ -222,10 +222,10 @@ export default class BlockManager extends Module { | |
* @param {boolean} readOnlyEnabled - "read only" state | ||
*/ | ||
public toggleReadOnly(readOnlyEnabled: boolean): void { | ||
if (readOnlyEnabled) { | ||
this.disableModuleEvents(); | ||
if (!readOnlyEnabled) { | ||
this.enableModuleBindings(); | ||
} else { | ||
this.enableModuleEvents(); | ||
this.disableModuleBindings(); | ||
} | ||
} | ||
|
||
|
@@ -688,12 +688,6 @@ export default class BlockManager extends Module { | |
private bindBlockEvents(block: Block): void { | ||
const { BlockEvents, Listeners } = this.Editor; | ||
|
||
// this.listenerIds.push( | ||
// Listeners.on(block.holder, 'mousedown', (event: MouseEvent) => { | ||
// BlockEvents.mouseDown(event); | ||
// }) | ||
// ); | ||
|
||
this.listenerIds.push( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you remove |
||
Listeners.on(block.holder, 'keydown', (event: KeyboardEvent) => { | ||
BlockEvents.keydown(event); | ||
|
@@ -725,7 +719,7 @@ export default class BlockManager extends Module { | |
* - Removes all listeners by id | ||
* - Removes all shortcuts | ||
*/ | ||
private disableModuleEvents(): void { | ||
private disableModuleBindings(): void { | ||
const { Listeners } = this.Editor; | ||
|
||
for (const id of this.listenerIds) { | ||
|
@@ -742,7 +736,7 @@ export default class BlockManager extends Module { | |
* - Restore `copy` and `cut` bindings | ||
* - Bind all events handlers for all Blocks | ||
*/ | ||
private enableModuleEvents(): void { | ||
private enableModuleBindings(): void { | ||
this.blocks.forEach((block: Block) => { | ||
this.bindBlockEvents(block); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,15 @@ export default class CrossBlockSelection extends Module { | |
private lastSelectedBlock: Block; | ||
|
||
/** | ||
* Module preparation | ||
* | ||
* @returns {Promise} | ||
*/ | ||
public async prepare(): Promise<void> { | ||
const { Listeners } = this.Editor; | ||
|
||
Listeners.on(document, 'mousedown', (event: MouseEvent) => { | ||
neSpecc marked this conversation as resolved.
Show resolved
Hide resolved
|
||
this.handleCBSMouseDown(event); | ||
this.enableCrossBlockSelection(event); | ||
}); | ||
} | ||
|
||
|
@@ -56,9 +58,11 @@ export default class CrossBlockSelection extends Module { | |
} | ||
|
||
/** | ||
* @param {MouseEvent} event | ||
* Enables Cross Block Selection | ||
* | ||
* @param {MouseEvent} event - mouse down event | ||
*/ | ||
public handleCBSMouseDown(event: MouseEvent): void { | ||
private enableCrossBlockSelection(event: MouseEvent): void { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think |
||
/** | ||
* Each mouse down on Block must disable selectAll state | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As user can pass anything to
readOnly
property, I think it's better to cast it to boolean