<commit_before>/**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import 'neuroglancer/image_user_layer';
import 'neuroglancer/segmentation_user_layer';
import 'neuroglancer/single_mesh_user_layer';
import 'neuroglancer/annotation/user_layer';

import {makeDefaultKeyBindings} from 'neuroglancer/default_key_bindings';
import {makeDefaultViewer} from 'neuroglancer/default_viewer';
import {getCurrentState} from 'neuroglancer/url_hash_state';

window.addEventListener('DOMContentLoaded', () => {
  let viewer = (<any>window)['viewer'] = makeDefaultViewer();
  makeDefaultKeyBindings(viewer.keyMap);

  document.addEventListener('copy', (event: ClipboardEvent) => {
    const {tagName} = (<HTMLElement>event.target);
    if (tagName === 'TEXTAREA' || tagName === 'INPUT') {
      return;
    }
    const state = getCurrentState();
    event.clipboardData.setData('text/plain', JSON.stringify(state, undefined, '  '));
    event.preventDefault();
  });
});
<commit_msg>fix: ensure default copy action is performed when there is a selection.<commit_after>/**
 * @license
 * Copyright 2016 Google Inc.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import 'neuroglancer/image_user_layer';
import 'neuroglancer/segmentation_user_layer';
import 'neuroglancer/single_mesh_user_layer';
import 'neuroglancer/annotation/user_layer';

import {makeDefaultKeyBindings} from 'neuroglancer/default_key_bindings';
import {makeDefaultViewer} from 'neuroglancer/default_viewer';
import {getCurrentState} from 'neuroglancer/url_hash_state';

window.addEventListener('DOMContentLoaded', () => {
  let viewer = (<any>window)['viewer'] = makeDefaultViewer();
  makeDefaultKeyBindings(viewer.keyMap);

  document.addEventListener('copy', (event: ClipboardEvent) => {
    const selection = window.getSelection();
    if (!selection.isCollapsed) {
      return;
    }
    const {tagName} = (<HTMLElement>event.target);
    if (tagName === 'TEXTAREA' || tagName === 'INPUT') {
      return;
    }
    const state = getCurrentState();
    event.clipboardData.setData('text/plain', JSON.stringify(state, undefined, '  '));
    event.preventDefault();
  });
});

{'fraction_non_alphanumeric': 0.11426787386824852, 'fraction_numerical': 0.004995316890415236, 'mean_word_length': 4.804347826086956, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7502847', 'n_tokens_mistral': 921, 'n_tokens_neox': 906, 'n_words': 275}