Sha256: f99d4ad2e95a4c5e00eb9966bdac546147b6eb0ef587fa316795253493aa6ef5

Contents?: true

Size: 1.43 KB

Versions: 26

Compression:

Stored size: 1.43 KB

Contents

import { getUISelection } from '../../document/UI.js';
import '../../utils/click/isClickableInput.js';
import '../../utils/dataTransfer/Clipboard.js';
import { getContentEditable } from '../../utils/edit/isContentEditable.js';
import '../../utils/edit/isEditable.js';
import '../../utils/edit/maxLength.js';
import { hasOwnSelection } from '../../utils/focus/selection.js';
import '../../utils/keyDef/readNextDescriptor.js';
import '../../utils/misc/level.js';
import '../../options.js';

/**
 * Determine which selection logic and selection ranges to consider.
 */ function getTargetTypeAndSelection(node) {
    const element = getElement(node);
    if (element && hasOwnSelection(element)) {
        return {
            type: 'input',
            selection: getUISelection(element)
        };
    }
    const selection = element === null || element === void 0 ? void 0 : element.ownerDocument.getSelection();
    // It is possible to extend a single-range selection into a contenteditable.
    // This results in the range acting like a range outside of contenteditable.
    const isCE = getContentEditable(node) && (selection === null || selection === void 0 ? void 0 : selection.anchorNode) && getContentEditable(selection.anchorNode);
    return {
        type: isCE ? 'contenteditable' : 'default',
        selection
    };
}
function getElement(node) {
    return node.nodeType === 1 ? node : node.parentElement;
}

export { getTargetTypeAndSelection };

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
clapton-0.0.26 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.25 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.24 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.23 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.22 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.21 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.20 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.19 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.18 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.17 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.16 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.15 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.14 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.13 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.12 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.11 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.10 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.9 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.8 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js
clapton-0.0.7 lib/clapton/javascripts/node_modules/@testing-library/user-event/dist/esm/event/selection/getTargetTypeAndSelection.js