{"action":"created","comment":{"url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/comments/69995999","id":69995999,"diff_hunk":"@@ -356,24 +347,133 @@ export default class TextElement extends Component {\n     });\n   }\n \n-  handleDoubleClick = () => {\n-    console.log(\"DISCOUNTDOUBLECLICK\");\n+  handleClick = () => {\n+    this.editable.addEventListener(\"input\", this.handleInput);\n+    this.editable.addEventListener(\"keypress\", this.handleKeyPress);\n+    this.editable.addEventListener(\"blur\", this.createUpdateElementChildren());\n+    window.addEventListener(\"click\", this.createUpdateElementChildren());\n+\n+    if (this.editable && this.editable.childNodes.length) {\n+      const range = document.createRange();\n+      const sel = window.getSelection();\n+\n+      range.setStartAfter(this.editable.childNodes[0]);\n+      range.setEndAfter(this.editable.childNodes[0]);\n+      sel.removeAllRanges();\n+      sel.addRange(range);\n+    }\n+\n+    this.stopBlurEvent = false;\n+    this.editable.focus();\n+\n+    if (!this.props.component.children) {\n+      this.setState({ currentContent: \"\" });\n+    }\n+  }\n+\n+  handleKeyPress = (ev) => {\n+    if (ev.charCode === 13) {\n+      ev.preventDefault();\n+\n+      const sel = window.getSelection();\n+      const caretPostion = sel.anchorOffset;\n+      // trim an extra line break if it's at the end.\n+      const innerText = ev.target.innerText.replace(/\\n\\n$/, \"\\n\");\n+      const stringLength = innerText.length;\n+      const range = document.createRange();\n+\n+      range.selectNodeContents(this.editable);\n+      sel.removeAllRanges();\n+\n+      if (caretPostion === stringLength) {\n+        // add 2 line breaks because adding one doesn't create new line for some reason\n+        this.setState({ currentContent: `${innerText}\\n\\n` }, () => {\n+          range.setStart(this.editable.childNodes[0], this.state.currentContent.length);\n+          range.setEnd(this.editable.childNodes[0], this.state.currentContent.length);\n+          sel.addRange(range);\n+        });\n+      } else {\n+        this.setState({\n+          currentContent: `${innerText.slice(0, caretPostion)}\\n${innerText.slice(caretPostion)}`\n+        }, () => {\n+          range.setStart(this.editable.childNodes[0], caretPostion + 1);\n+          range.setEnd(this.editable.childNodes[0], caretPostion + 1);\n+          sel.addRange(range);\n+        });\n+      }\n+    }\n+  }\n+\n+  handleInput = (ev) => {\n+    ev.preventDefault();\n+\n+    this.setState({\n+      currentContent: ev.target.innerText\n+    });\n+  }\n+\n+  createUpdateElementChildren = () => {\n+    const {\n+      currentState,\n+      currentSlideIndex,\n+      currentElementIndex\n+    } = this.context.store;\n+\n+    const currentElementChildren =\n+      currentState.slides[currentSlideIndex].children[currentElementIndex].children;","path":"app/components/canvas/element-types/text-element/index.js","position":198,"original_position":198,"commit_id":"92d566b040ba8824dc775d8345c202ce82bd66e8","original_commit_id":"92d566b040ba8824dc775d8345c202ce82bd66e8","user":{"login":"rgerstenberger","id":710017,"avatar_url":"https://avatars.githubusercontent.com/u/710017?v=3","gravatar_id":"","url":"https://api.github.com/users/rgerstenberger","html_url":"https://github.com/rgerstenberger","followers_url":"https://api.github.com/users/rgerstenberger/followers","following_url":"https://api.github.com/users/rgerstenberger/following{/other_user}","gists_url":"https://api.github.com/users/rgerstenberger/gists{/gist_id}","starred_url":"https://api.github.com/users/rgerstenberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgerstenberger/subscriptions","organizations_url":"https://api.github.com/users/rgerstenberger/orgs","repos_url":"https://api.github.com/users/rgerstenberger/repos","events_url":"https://api.github.com/users/rgerstenberger/events{/privacy}","received_events_url":"https://api.github.com/users/rgerstenberger/received_events","type":"User","site_admin":false},"body":"You can just grab `currentElement` from the store.","created_at":"2016-07-07T22:03:10Z","updated_at":"2016-07-07T22:03:10Z","html_url":"https://github.com/FormidableLabs/spectacle-editor/pull/73#discussion_r69995999","pull_request_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/73","_links":{"self":{"href":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/comments/69995999"},"html":{"href":"https://github.com/FormidableLabs/spectacle-editor/pull/73#discussion_r69995999"},"pull_request":{"href":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/73"}}},"pull_request":{"url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/73","id":76670416,"html_url":"https://github.com/FormidableLabs/spectacle-editor/pull/73","diff_url":"https://github.com/FormidableLabs/spectacle-editor/pull/73.diff","patch_url":"https://github.com/FormidableLabs/spectacle-editor/pull/73.patch","issue_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/issues/73","number":73,"state":"open","locked":false,"title":"Feature editable text element","user":{"login":"mdaxtman","id":8061227,"avatar_url":"https://avatars.githubusercontent.com/u/8061227?v=3","gravatar_id":"","url":"https://api.github.com/users/mdaxtman","html_url":"https://github.com/mdaxtman","followers_url":"https://api.github.com/users/mdaxtman/followers","following_url":"https://api.github.com/users/mdaxtman/following{/other_user}","gists_url":"https://api.github.com/users/mdaxtman/gists{/gist_id}","starred_url":"https://api.github.com/users/mdaxtman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mdaxtman/subscriptions","organizations_url":"https://api.github.com/users/mdaxtman/orgs","repos_url":"https://api.github.com/users/mdaxtman/repos","events_url":"https://api.github.com/users/mdaxtman/events{/privacy}","received_events_url":"https://api.github.com/users/mdaxtman/received_events","type":"User","site_admin":false},"body":"@rgerstenberger \r\n\r\nPlease review. Code comments are there for things that look out of ordinary for clarification.\r\n\r\nWill handle text input:\r\n![screen shot 2016-07-07 at 2 41 24 pm](https://cloud.githubusercontent.com/assets/8061227/16670788/e88921cc-4450-11e6-8047-1b48110604ce.png)\r\n\r\nLine Breaks:\r\n![screen shot 2016-07-07 at 2 41 39 pm](https://cloud.githubusercontent.com/assets/8061227/16670803/fad9dbe6-4450-11e6-94cb-e41303226e66.png)\r\n\r\n\r\nWordWrapping on resize:\r\n![screen shot 2016-07-07 at 2 41 47 pm](https://cloud.githubusercontent.com/assets/8061227/16670812/0783d46e-4451-11e6-8cab-ce41e7fedb65.png)\r\n\r\n","created_at":"2016-07-07T21:43:13Z","updated_at":"2016-07-07T22:03:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7b71a270bbe67e505db5e996a75f1592ca44a87d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/73/commits","review_comments_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/73/comments","review_comment_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/issues/73/comments","statuses_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/statuses/92d566b040ba8824dc775d8345c202ce82bd66e8","head":{"label":"FormidableLabs:feature-editable-text-element","ref":"feature-editable-text-element","sha":"92d566b040ba8824dc775d8345c202ce82bd66e8","user":{"login":"FormidableLabs","id":5078602,"avatar_url":"https://avatars.githubusercontent.com/u/5078602?v=3","gravatar_id":"","url":"https://api.github.com/users/FormidableLabs","html_url":"https://github.com/FormidableLabs","followers_url":"https://api.github.com/users/FormidableLabs/followers","following_url":"https://api.github.com/users/FormidableLabs/following{/other_user}","gists_url":"https://api.github.com/users/FormidableLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/FormidableLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FormidableLabs/subscriptions","organizations_url":"https://api.github.com/users/FormidableLabs/orgs","repos_url":"https://api.github.com/users/FormidableLabs/repos","events_url":"https://api.github.com/users/FormidableLabs/events{/privacy}","received_events_url":"https://api.github.com/users/FormidableLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":58005358,"name":"spectacle-editor","full_name":"FormidableLabs/spectacle-editor","owner":{"login":"FormidableLabs","id":5078602,"avatar_url":"https://avatars.githubusercontent.com/u/5078602?v=3","gravatar_id":"","url":"https://api.github.com/users/FormidableLabs","html_url":"https://github.com/FormidableLabs","followers_url":"https://api.github.com/users/FormidableLabs/followers","following_url":"https://api.github.com/users/FormidableLabs/following{/other_user}","gists_url":"https://api.github.com/users/FormidableLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/FormidableLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FormidableLabs/subscriptions","organizations_url":"https://api.github.com/users/FormidableLabs/orgs","repos_url":"https://api.github.com/users/FormidableLabs/repos","events_url":"https://api.github.com/users/FormidableLabs/events{/privacy}","received_events_url":"https://api.github.com/users/FormidableLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FormidableLabs/spectacle-editor","description":"Drag and drop Spectacle editor.","fork":false,"url":"https://api.github.com/repos/FormidableLabs/spectacle-editor","forks_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/forks","keys_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/teams","hooks_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/hooks","issue_events_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/issues/events{/number}","events_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/events","assignees_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/assignees{/user}","branches_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/branches{/branch}","tags_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/tags","blobs_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/git/refs{/sha}","trees_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/statuses/{sha}","languages_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/languages","stargazers_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/stargazers","contributors_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/contributors","subscribers_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/subscribers","subscription_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/subscription","commits_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/commits{/sha}","git_commits_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/git/commits{/sha}","comments_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/comments{/number}","issue_comment_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/issues/comments{/number}","contents_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/contents/{+path}","compare_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/merges","archive_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/downloads","issues_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/issues{/number}","pulls_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls{/number}","milestones_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/milestones{/number}","notifications_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/labels{/name}","releases_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/releases{/id}","deployments_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/deployments","created_at":"2016-05-03T22:24:37Z","updated_at":"2016-07-07T14:37:42Z","pushed_at":"2016-07-07T21:43:13Z","git_url":"git://github.com/FormidableLabs/spectacle-editor.git","ssh_url":"git@github.com:FormidableLabs/spectacle-editor.git","clone_url":"https://github.com/FormidableLabs/spectacle-editor.git","svn_url":"https://github.com/FormidableLabs/spectacle-editor","homepage":null,"size":5889,"stargazers_count":62,"watchers_count":62,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":37,"forks":6,"open_issues":37,"watchers":62,"default_branch":"master"}},"base":{"label":"FormidableLabs:master","ref":"master","sha":"f3703ee081237a3a77e7d3b4b4d33f26a4025347","user":{"login":"FormidableLabs","id":5078602,"avatar_url":"https://avatars.githubusercontent.com/u/5078602?v=3","gravatar_id":"","url":"https://api.github.com/users/FormidableLabs","html_url":"https://github.com/FormidableLabs","followers_url":"https://api.github.com/users/FormidableLabs/followers","following_url":"https://api.github.com/users/FormidableLabs/following{/other_user}","gists_url":"https://api.github.com/users/FormidableLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/FormidableLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FormidableLabs/subscriptions","organizations_url":"https://api.github.com/users/FormidableLabs/orgs","repos_url":"https://api.github.com/users/FormidableLabs/repos","events_url":"https://api.github.com/users/FormidableLabs/events{/privacy}","received_events_url":"https://api.github.com/users/FormidableLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":58005358,"name":"spectacle-editor","full_name":"FormidableLabs/spectacle-editor","owner":{"login":"FormidableLabs","id":5078602,"avatar_url":"https://avatars.githubusercontent.com/u/5078602?v=3","gravatar_id":"","url":"https://api.github.com/users/FormidableLabs","html_url":"https://github.com/FormidableLabs","followers_url":"https://api.github.com/users/FormidableLabs/followers","following_url":"https://api.github.com/users/FormidableLabs/following{/other_user}","gists_url":"https://api.github.com/users/FormidableLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/FormidableLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FormidableLabs/subscriptions","organizations_url":"https://api.github.com/users/FormidableLabs/orgs","repos_url":"https://api.github.com/users/FormidableLabs/repos","events_url":"https://api.github.com/users/FormidableLabs/events{/privacy}","received_events_url":"https://api.github.com/users/FormidableLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FormidableLabs/spectacle-editor","description":"Drag and drop Spectacle editor.","fork":false,"url":"https://api.github.com/repos/FormidableLabs/spectacle-editor","forks_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/forks","keys_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/teams","hooks_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/hooks","issue_events_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/issues/events{/number}","events_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/events","assignees_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/assignees{/user}","branches_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/branches{/branch}","tags_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/tags","blobs_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/git/refs{/sha}","trees_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/statuses/{sha}","languages_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/languages","stargazers_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/stargazers","contributors_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/contributors","subscribers_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/subscribers","subscription_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/subscription","commits_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/commits{/sha}","git_commits_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/git/commits{/sha}","comments_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/comments{/number}","issue_comment_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/issues/comments{/number}","contents_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/contents/{+path}","compare_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/merges","archive_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/downloads","issues_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/issues{/number}","pulls_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls{/number}","milestones_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/milestones{/number}","notifications_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/labels{/name}","releases_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/releases{/id}","deployments_url":"https://api.github.com/repos/FormidableLabs/spectacle-editor/deployments","created_at":"2016-05-03T22:24:37Z","updated_at":"2016-07-07T14:37:42Z","pushed_at":"2016-07-07T21:43:13Z","git_url":"git://github.com/FormidableLabs/spectacle-editor.git","ssh_url":"git@github.com:FormidableLabs/spectacle-editor.git","clone_url":"https://github.com/FormidableLabs/spectacle-editor.git","svn_url":"https://github.com/FormidableLabs/spectacle-editor","homepage":null,"size":5889,"stargazers_count":62,"watchers_count":62,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":37,"forks":6,"open_issues":37,"watchers":62,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/73"},"html":{"href":"https://github.com/FormidableLabs/spectacle-editor/pull/73"},"issue":{"href":"https://api.github.com/repos/FormidableLabs/spectacle-editor/issues/73"},"comments":{"href":"https://api.github.com/repos/FormidableLabs/spectacle-editor/issues/73/comments"},"review_comments":{"href":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/73/comments"},"review_comment":{"href":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FormidableLabs/spectacle-editor/pulls/73/commits"},"statuses":{"href":"https://api.github.com/repos/FormidableLabs/spectacle-editor/statuses/92d566b040ba8824dc775d8345c202ce82bd66e8"}}}}
{"actor":{"display_login":"rgerstenberger"}}