<commit_before>/**
 * Dialog.js
 *
 * Released under LGPL License.
 * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */
import { Merger } from '@ephox/katamari';
import Tools from 'tinymce/core/api/util/Tools';

import Settings from '../api/Settings';
import HtmlToData from '../core/HtmlToData';
import Service from '../core/Service';
import Size from '../core/Size';
import UpdateHtml from '../core/UpdateHtml';

const unwrap = (data) => Merger.merge(data, {
  source1: data.source1.value,
  source2: data.source2.value,
  poster: data.poster.value
});

const wrap = (data) => Merger.merge(data, {
  source1: { value: data.source1 || '' },
  source2: { value: data.source2 || '' },
  poster: { value: data.poster || '' }
});

const handleError = function (editor) {
  return function (error) {
    const errorMessage = error && error.msg ?
      'Media embed handler error: ' + error.msg :
      'Media embed handler threw unknown error.';
    editor.notificationManager.open({ type: 'error', text: errorMessage });
  };
};

const snippetToData = (editor, embedSnippet) => {
  return Tools.extend({}, HtmlToData.htmlToData(Settings.getScripts(editor), embedSnippet));
};<commit_msg>TINY-2227: use Obj.get instead of truthy check<commit_after>/**
 * Dialog.js
 *
 * Released under LGPL License.
 * Copyright (c) 1999-2017 Ephox Corp. All rights reserved
 *
 * License: http://www.tinymce.com/license
 * Contributing: http://www.tinymce.com/contributing
 */
import { Merger, Obj } from '@ephox/katamari';
import Tools from 'tinymce/core/api/util/Tools';

import Settings from '../api/Settings';
import HtmlToData from '../core/HtmlToData';
import Service from '../core/Service';
import Size from '../core/Size';
import UpdateHtml from '../core/UpdateHtml';

const unwrap = (data) => Merger.merge(data, {
  source1: data.source1.value,
  source2: data.source2.value,
  poster: data.poster.value
});

const wrap = (data) => Merger.merge(data, {
  source1: { value: Obj.get(data, 'source1').getOr('') },
  source2: { value: Obj.get(data, 'source2').getOr('') },
  poster: { value: Obj.get(data, 'poster').getOr('') }
});

const handleError = function (editor) {
  return function (error) {
    const errorMessage = error && error.msg ?
      'Media embed handler error: ' + error.msg :
      'Media embed handler threw unknown error.';
    editor.notificationManager.open({ type: 'error', text: errorMessage });
  };
};

const snippetToData = (editor, embedSnippet) => {
  return Tools.extend({}, HtmlToData.htmlToData(Settings.getScripts(editor), embedSnippet));
};
{'fraction_non_alphanumeric': 0.16467065868263472, 'fraction_numerical': 0.01347305389221557, 'mean_word_length': 4.043396226415094, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '7543264', 'n_tokens_mistral': 889, 'n_tokens_neox': 869, 'n_words': 218}