Skip to content
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

issue-559: Allow default selection on native inputs #564

Merged
merged 2 commits into from
Dec 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions dist/codex-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/example.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
{
type : 'paragraph',
data : {
text : 'Блоки — это структурные элементы, из которых состоит статья. Например <span class="inline-code">Параграф</span>, <span class="inline-code">Заголовок</span>, <span class="inline-code">Изображение</span>, <span class="inline-code">Видео</span> — это все Блоки. В CodeX Editor каждый Блок определяется плагином. Есть много готовых Блоков и простой API для создания новых. Например, вы можете создать Блок для Твиттера, Инстаграма, Опроса, Игры или CTA-кнопки.'
text : 'Блоки — это структурные элементы, из которых состоит статья. Например <code class="inline-code">Параграф</code>, <code class="inline-code">Заголовок</code>, <code class="inline-code">Изображение</code>, <code class="inline-code">Видео</code> — это все Блоки. В CodeX Editor каждый Блок определяется плагином. Есть много готовых Блоков и простой API для создания новых. Например, вы можете создать Блок для Твиттера, Инстаграма, Опроса, Игры или CTA-кнопки.'
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codex.editor",
"version": "2.7.10",
"version": "2.7.11",
"description": "Codex Editor. Native JS, based on API and Open Source",
"main": "dist/codex-editor.js",
"types": "./types/index.d.ts",
Expand Down
14 changes: 14 additions & 0 deletions src/components/modules/blockSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ export default class BlockSelection extends Module {
*/
private needToSelectAll: boolean = false;

/**
* Flag used to define native input selection
* In this case we allow double CMD+A to select Block
* @type {boolean}
*/
private nativeInputSelected: boolean = false;

/**
* SelectionUtils instance
* @type {SelectionUtils}
Expand Down Expand Up @@ -119,6 +126,7 @@ export default class BlockSelection extends Module {
*/
public clearSelection(restoreSelection = false) {
this.needToSelectAll = false;
this.nativeInputSelected = false;

if (!this.anyBlockSelected) {
return;
Expand All @@ -143,6 +151,12 @@ export default class BlockSelection extends Module {
* @param {keydown} event
*/
private handleCommandA(event): void {
/** allow default selection on native inputs */
if ($.isNativeInput(event.target) && !this.nativeInputSelected) {
this.nativeInputSelected = true;
return;
}

/** Prevent default selection */
event.preventDefault();

Expand Down