GitHub PullRequestReviewCommentEvent at 2014-01-08 17:14:53
Repository: Aloha-Editor
Actor: najor
Payload: {"comment":{"url":"https://api.github.com/repos/alohaeditor/Aloha-Editor/pulls/comments/8731212","id":8731212,"diff_hunk":"@@ -0,0 +1,219 @@\n+/**\n+ * paste.js is part of Aloha Editor project http://aloha-editor.org\n+ *\n+ * Aloha Editor is a WYSIWYG HTML5 inline editing library and editor.\n+ * Copyright (c) 2010-2013 Gentics Software GmbH, Vienna, Austria.\n+ * Contributors http://aloha-editor.org/contribution.php\n+ */\n+define([\n+\t'editing',\n+\t'events',\n+\t'boundaries',\n+\t'dom',\n+\t'html',\n+\t'mutation',\n+\t'paste-transform-html',\n+\t'ms-word-transform',\n+\t'paste-transform-plaintext',\n+\t'paste-utils',\n+\t'ranges'\n+], function(\n+\tEditing,\n+\tEvents,\n+\tBoundaries,\n+\tDom,\n+\tHtml,\n+\tMutation,\n+\tPasteTransform,\n+    WordTrasnform,\n+    PasteTransformPlainText,\n+    PasteUtils,\n+    Ranges\n+) {\n+\t'use strict';\n+\n+\t/**\n+\t * Check if `event` is a Paste Event.\n+\t * @param {Event} event\n+\t * @return {boolean}\n+\t */\n+\tfunction isPasteEvent(event) {\n+\t\treturn (event && (event.type === 'paste' || event.clipboardData !== undefined)) ? true : false;\n+\t}\n+\n+\t/**\n+\t * Gets paste content depending on type content.\n+\t * @param {!Event} event\n+\t * @param {string} type\n+\t * @return {string}\n+\t */\n+\tfunction getPasteContent(event, type) {\n+\t\treturn event.clipboardData.getData(type);\n+\t}\n+\n+\t/**\n+\t * Gets html paste content.\n+\t * @param {!Event} event\n+\t * @return {string}\n+\t */\n+\tfunction getHtmlPasteContent(event) {\n+\t\treturn getPasteContent(event, 'text/html');\n+\t}\n+\n+\t/**\n+\t * Gets plain text paste content.\n+\t * @param {!Event} event\n+\t * @return {string}\n+\t */\n+\tfunction getPlainTextPasteContent(event) {\n+\t\treturn getPasteContent(event, 'text/plain');\n+\t}\n+\n+\n+\t/**\n+\t * Gets the reference node where paste should be inserted.\n+\t * @return {Node}\n+\t */\n+\tfunction getReferenceNode() {\n+\t\tvar startElement = Ranges.get().startContainer;\n+\n+\t\twhile (!Html.hasBlockStyle(startElement)) {\n+\t\t\tstartElement = startElement.parentNode;\n+\t\t}\n+\n+\t\treturn startElement.nextSibling;\n+\t}\n+\n+\t/**\n+\t * Sets the selection after `node`.\n+\t * @param {Node} node\n+\t * @return {Range}\n+\t */\n+\tfunction setSelectionAfter(node) {\n+\t\tvar range = Ranges.get();\n+\n+\t\trange.setStartAfter(node);\n+\t\trange.setEndAfter(node);","path":"src/paste.js","position":96,"original_position":96,"commit_id":"24846fbbabb60c642eb74a67dc327b8892cd79f1","original_commit_id":"ca159eb325fd55d50389ceceecd0069147c47155","user":{"login":"najor","id":5479033,"avatar_url":"https://gravatar.com/avatar/f51f8e39c4a8480bb2d54cb4e8947e10?d=https%3A%2F%2Fidenticons.github.com%2F08a37088427d9f8fb01a548673f73d55.png&r=x","gravatar_id":"f51f8e39c4a8480bb2d54cb4e8947e10","url":"https://api.github.com/users/najor","html_url":"https://github.com/najor","followers_url":"https://api.github.com/users/najor/followers","following_url":"https://api.github.com/users/najor/following{/other_user}","gists_url":"https://api.github.com/users/najor/gists{/gist_id}","starred_url":"https://api.github.com/users/najor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/najor/subscriptions","organizations_url":"https://api.github.com/users/najor/orgs","repos_url":"https://api.github.com/users/najor/repos","events_url":"https://api.github.com/users/najor/events{/privacy}","received_events_url":"https://api.github.com/users/najor/received_events","type":"User","site_admin":false},"body":"You are right, working with the ranges should be more easy. Using Boundaries it doesn't make easier but different. Selection.js is the API to work with ranges, but it is not completed. This should be refactored once the selections.js API is completed.","created_at":"2014-01-08T17:14:53Z","updated_at":"2014-01-08T17:14:53Z","html_url":"https://github.com/alohaeditor/Aloha-Editor/pull/1055#discussion_r8731212","pull_request_url":"https://api.github.com/repos/alohaeditor/Aloha-Editor/pulls/1055","_links":{"self":{"href":"https://api.github.com/repos/alohaeditor/Aloha-Editor/pulls/comments/8731212"},"html":{"href":"https://github.com/alohaeditor/Aloha-Editor/pull/1055#discussion_r8731212"},"pull_request":{"href":"https://api.github.com/repos/alohaeditor/Aloha-Editor/pulls/1055"}}}}