{"action":"created","comment":{"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/comments/61541961","id":61541961,"diff_hunk":"@@ -0,0 +1,266 @@\n+/**\n+ * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.\n+ * For licensing, see LICENSE.md.\n+ */\n+\n+'use strict';\n+\n+import {\n+\tinsertElement,\n+\tsetAttribute,\n+\tremoveAttribute,\n+\twrap,\n+\tunwrap\n+} from '/ckeditor5/engine/treecontroller/model-to-view-converters.js';\n+\n+import ViewAttributeElement from '/ckeditor5/engine/treeview/attributeelement.js';\n+import ViewContainerElement from '/ckeditor5/engine/treeview/containerelement.js';\n+\n+/**\n+ * Provides chainable, high-level API to easily build basic model-to-view converters that are appended to given\n+ * dispatchers. In many cases, this is the API that should be used to specify how abstract model elements and\n+ * attributes should be represented in the view (and then later in DOM). Instances of this class are created by\n+ * {@link engine.treeController.BuildModelConverterFor}.\n+ *\n+ * If you need more complex converters, see {@link engine.treeController.ModelConversionDispatcher},\n+ * {@link engine.treeController.modelToView}, {@link engine.treeController.ModelConsumable}, {@link engine.treeController.Mapper}.\n+ *\n+ * Using this API it is possible to create three kinds of converters:\n+ *\n+ * 1. Model element to view element converter. This is a converter that takes the model element and represents it\n+ * in the view.\n+ *\n+ *\t\tBuildModelConverterFor( dispatcher ).fromElement( 'paragraph' ).toElement( 'p' );\n+ *\t\tBuildModelConverterFor( dispatcher ).fromElement( 'image' ).toElement( 'img' );\n+ *\n+ * 2. Model attribute to view attribute converter. This is a converter that operates on model element attributes\n+ * and converts them to view element attributes. It is suitable for elements like `image` (`src`, `title` attributes).\n+ *\n+ *\t\tBuildModelConverterFor( dispatcher ).fromElement( 'image' ).toElement( 'img' );\n+ *\t\tBuildModelConverterFor( dispatcher ).fromAttribute( 'src' ).toAttribute();\n+ *\n+ * 3. Model attribute to view element converter. This is a converter that takes model attributes and represents them\n+ * as view elements. Those view elements are wrapping view elements are node that correspond to model elements and\n+ * nodes which had converter attribute. It is suitable for attributes like `bold`, where `bold` attribute set on model\n+ * text nodes is converter to `strong` view element.\n+ *\n+ *\t\tBuildModelConverterFor( dispatcher ).fromAttribute( 'bold' ).toElement( 'strong' );\n+ *\n+ * It is possible to provide various different parameters for {@link engine.treeController.ModelConverterBuilder#toElement}\n+ * and {@link engine.treeController.ModelConverterBuilder#toAttribute} methods. See their descriptions to learn more.\n+ *\n+ * It is also possible to {@link engine.treeController.ModelConverterBuilder#withPriority change default priority}\n+ * of created converters to decide which converter should be fired earlier and which later. This is useful if you provide\n+ * a general converter but want to provide different converter for a specific-case (i.e. given model element is converted\n+ * always to given view element, but if it has given attribute it is converter to other view element). For this,\n+ * use {@link engine.treeController.ModelConverterBuilder#withPriority withPriority} right after `from...` method.\n+ *\n+ * Note that `to...` methods are \"terminators\", which means that should be the last one used in building converter.\n+ *\n+ * You can use {@link engine.treeController.ViewConverterBuilder} to create \"opposite\" converters - from view to model.\n+ *\n+ * @memberOf engine.treeController\n+ */\n+class ModelConverterBuilder {\n+\t/**\n+\t * Creates `ModelConverterBuilder` with given `dispatchers` registered to it.\n+\t *\n+\t * @param {Array.<engine.treeController.ModelConversionDispatcher>} dispatchers Dispatchers to which converters will\n+\t * be attached.\n+\t */\n+\tconstructor( dispatchers ) {\n+\t\t/**\n+\t\t * Dispatchers to which converters will be attached.\n+\t\t *\n+\t\t * @type {Array.<engine.treeController.ModelConversionDispatcher>}\n+\t\t * @private\n+\t\t */\n+\t\tthis._dispatchers = dispatchers;\n+\n+\t\t/**\n+\t\t * Contains data about registered \"from\" query.\n+\t\t *\n+\t\t * @type {Object}\n+\t\t * @private\n+\t\t */\n+\t\tthis._from = null;\n+\t}\n+\n+\t/**\n+\t * Registers what model element should be converted.\n+\t *\n+\t * @chainable\n+\t * @param {String} elementName Name of element to convert.\n+\t * @returns {engine.treeController.ModelConverterBuilder}\n+\t */\n+\tfromElement( elementName ) {\n+\t\tthis._from = {\n+\t\t\ttype: 'element',\n+\t\t\tname: elementName,\n+\t\t\tpriority: null\n+\t\t};\n+\n+\t\treturn this;\n+\t}\n+\n+\t/**\n+\t * Registers what model attribute should be converted.\n+\t *\n+\t * @chainable\n+\t * @param {String} key Key of attribute to convert.\n+\t * @returns {engine.treeController.ModelConverterBuilder}\n+\t */\n+\tfromAttribute( key ) {\n+\t\tthis._from = {\n+\t\t\ttype: 'attribute',\n+\t\t\tkey: key,\n+\t\t\tpriority: null\n+\t\t};\n+\n+\t\treturn this;\n+\t}\n+\n+\t/**\n+\t * Changes default priority for built converter.\n+\t *\n+\t * @param {Number} priority Converter priority.\n+\t * @returns {engine.treeController.ModelConverterBuilder}\n+\t */\n+\twithPriority( priority ) {","path":"src/treecontroller/model-converter-builder.js","position":129,"original_position":129,"commit_id":"568773c23d6064edcecc3fd38ee0203c6feffdb8","original_commit_id":"568773c23d6064edcecc3fd38ee0203c6feffdb8","user":{"login":"scofalik","id":1502228,"avatar_url":"https://avatars.githubusercontent.com/u/1502228?v=3","gravatar_id":"","url":"https://api.github.com/users/scofalik","html_url":"https://github.com/scofalik","followers_url":"https://api.github.com/users/scofalik/followers","following_url":"https://api.github.com/users/scofalik/following{/other_user}","gists_url":"https://api.github.com/users/scofalik/gists{/gist_id}","starred_url":"https://api.github.com/users/scofalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scofalik/subscriptions","organizations_url":"https://api.github.com/users/scofalik/orgs","repos_url":"https://api.github.com/users/scofalik/repos","events_url":"https://api.github.com/users/scofalik/events{/privacy}","received_events_url":"https://api.github.com/users/scofalik/received_events","type":"User","site_admin":false},"body":"Added","created_at":"2016-04-29T07:24:03Z","updated_at":"2016-04-29T07:24:03Z","html_url":"https://github.com/ckeditor/ckeditor5-engine/pull/376#discussion_r61541961","pull_request_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/376","_links":{"self":{"href":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/comments/61541961"},"html":{"href":"https://github.com/ckeditor/ckeditor5-engine/pull/376#discussion_r61541961"},"pull_request":{"href":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/376"}}},"pull_request":{"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/376","id":67729753,"html_url":"https://github.com/ckeditor/ckeditor5-engine/pull/376","diff_url":"https://github.com/ckeditor/ckeditor5-engine/pull/376.diff","patch_url":"https://github.com/ckeditor/ckeditor5-engine/pull/376.patch","issue_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/376","number":376,"state":"open","locked":false,"title":"T/296 Build Converters","user":{"login":"scofalik","id":1502228,"avatar_url":"https://avatars.githubusercontent.com/u/1502228?v=3","gravatar_id":"","url":"https://api.github.com/users/scofalik","html_url":"https://github.com/scofalik","followers_url":"https://api.github.com/users/scofalik/followers","following_url":"https://api.github.com/users/scofalik/following{/other_user}","gists_url":"https://api.github.com/users/scofalik/gists{/gist_id}","starred_url":"https://api.github.com/users/scofalik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scofalik/subscriptions","organizations_url":"https://api.github.com/users/scofalik/orgs","repos_url":"https://api.github.com/users/scofalik/repos","events_url":"https://api.github.com/users/scofalik/events{/privacy}","received_events_url":"https://api.github.com/users/scofalik/received_events","type":"User","site_admin":false},"body":"Fixes #296 \r\n\r\nThere are still no attributes priorities as this is waiting for #372.","created_at":"2016-04-25T14:32:37Z","updated_at":"2016-04-29T07:24:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e88f8c2d2040c6668181258418fe7c22b758f08e","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/376/commits","review_comments_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/376/comments","review_comment_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/376/comments","statuses_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/statuses/568773c23d6064edcecc3fd38ee0203c6feffdb8","head":{"label":"ckeditor:t/296","ref":"t/296","sha":"568773c23d6064edcecc3fd38ee0203c6feffdb8","user":{"login":"ckeditor","id":825710,"avatar_url":"https://avatars.githubusercontent.com/u/825710?v=3","gravatar_id":"","url":"https://api.github.com/users/ckeditor","html_url":"https://github.com/ckeditor","followers_url":"https://api.github.com/users/ckeditor/followers","following_url":"https://api.github.com/users/ckeditor/following{/other_user}","gists_url":"https://api.github.com/users/ckeditor/gists{/gist_id}","starred_url":"https://api.github.com/users/ckeditor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckeditor/subscriptions","organizations_url":"https://api.github.com/users/ckeditor/orgs","repos_url":"https://api.github.com/users/ckeditor/repos","events_url":"https://api.github.com/users/ckeditor/events{/privacy}","received_events_url":"https://api.github.com/users/ckeditor/received_events","type":"Organization","site_admin":false},"repo":{"id":28972890,"name":"ckeditor5-engine","full_name":"ckeditor/ckeditor5-engine","owner":{"login":"ckeditor","id":825710,"avatar_url":"https://avatars.githubusercontent.com/u/825710?v=3","gravatar_id":"","url":"https://api.github.com/users/ckeditor","html_url":"https://github.com/ckeditor","followers_url":"https://api.github.com/users/ckeditor/followers","following_url":"https://api.github.com/users/ckeditor/following{/other_user}","gists_url":"https://api.github.com/users/ckeditor/gists{/gist_id}","starred_url":"https://api.github.com/users/ckeditor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckeditor/subscriptions","organizations_url":"https://api.github.com/users/ckeditor/orgs","repos_url":"https://api.github.com/users/ckeditor/repos","events_url":"https://api.github.com/users/ckeditor/events{/privacy}","received_events_url":"https://api.github.com/users/ckeditor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ckeditor/ckeditor5-engine","description":"CKEditor 5 Editing Engine.","fork":false,"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine","forks_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/forks","keys_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/teams","hooks_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/hooks","issue_events_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/events{/number}","events_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/events","assignees_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/assignees{/user}","branches_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/branches{/branch}","tags_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/tags","blobs_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/statuses/{sha}","languages_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/languages","stargazers_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/stargazers","contributors_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/contributors","subscribers_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/subscribers","subscription_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/subscription","commits_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/contents/{+path}","compare_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/merges","archive_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/downloads","issues_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues{/number}","pulls_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls{/number}","milestones_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/milestones{/number}","notifications_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/labels{/name}","releases_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/releases{/id}","deployments_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/deployments","created_at":"2015-01-08T15:47:45Z","updated_at":"2016-04-21T20:08:40Z","pushed_at":"2016-04-28T15:23:43Z","git_url":"git://github.com/ckeditor/ckeditor5-engine.git","ssh_url":"git@github.com:ckeditor/ckeditor5-engine.git","clone_url":"https://github.com/ckeditor/ckeditor5-engine.git","svn_url":"https://github.com/ckeditor/ckeditor5-engine","homepage":"","size":2555,"stargazers_count":25,"watchers_count":25,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":78,"forks":16,"open_issues":78,"watchers":25,"default_branch":"master"}},"base":{"label":"ckeditor:master","ref":"master","sha":"58c47051dd234a28c68d3085a7850e3024677981","user":{"login":"ckeditor","id":825710,"avatar_url":"https://avatars.githubusercontent.com/u/825710?v=3","gravatar_id":"","url":"https://api.github.com/users/ckeditor","html_url":"https://github.com/ckeditor","followers_url":"https://api.github.com/users/ckeditor/followers","following_url":"https://api.github.com/users/ckeditor/following{/other_user}","gists_url":"https://api.github.com/users/ckeditor/gists{/gist_id}","starred_url":"https://api.github.com/users/ckeditor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckeditor/subscriptions","organizations_url":"https://api.github.com/users/ckeditor/orgs","repos_url":"https://api.github.com/users/ckeditor/repos","events_url":"https://api.github.com/users/ckeditor/events{/privacy}","received_events_url":"https://api.github.com/users/ckeditor/received_events","type":"Organization","site_admin":false},"repo":{"id":28972890,"name":"ckeditor5-engine","full_name":"ckeditor/ckeditor5-engine","owner":{"login":"ckeditor","id":825710,"avatar_url":"https://avatars.githubusercontent.com/u/825710?v=3","gravatar_id":"","url":"https://api.github.com/users/ckeditor","html_url":"https://github.com/ckeditor","followers_url":"https://api.github.com/users/ckeditor/followers","following_url":"https://api.github.com/users/ckeditor/following{/other_user}","gists_url":"https://api.github.com/users/ckeditor/gists{/gist_id}","starred_url":"https://api.github.com/users/ckeditor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ckeditor/subscriptions","organizations_url":"https://api.github.com/users/ckeditor/orgs","repos_url":"https://api.github.com/users/ckeditor/repos","events_url":"https://api.github.com/users/ckeditor/events{/privacy}","received_events_url":"https://api.github.com/users/ckeditor/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ckeditor/ckeditor5-engine","description":"CKEditor 5 Editing Engine.","fork":false,"url":"https://api.github.com/repos/ckeditor/ckeditor5-engine","forks_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/forks","keys_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/teams","hooks_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/hooks","issue_events_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/events{/number}","events_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/events","assignees_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/assignees{/user}","branches_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/branches{/branch}","tags_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/tags","blobs_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/git/refs{/sha}","trees_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/statuses/{sha}","languages_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/languages","stargazers_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/stargazers","contributors_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/contributors","subscribers_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/subscribers","subscription_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/subscription","commits_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/commits{/sha}","git_commits_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/git/commits{/sha}","comments_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/comments{/number}","issue_comment_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/comments{/number}","contents_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/contents/{+path}","compare_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/merges","archive_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/downloads","issues_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues{/number}","pulls_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls{/number}","milestones_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/milestones{/number}","notifications_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/labels{/name}","releases_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/releases{/id}","deployments_url":"https://api.github.com/repos/ckeditor/ckeditor5-engine/deployments","created_at":"2015-01-08T15:47:45Z","updated_at":"2016-04-21T20:08:40Z","pushed_at":"2016-04-28T15:23:43Z","git_url":"git://github.com/ckeditor/ckeditor5-engine.git","ssh_url":"git@github.com:ckeditor/ckeditor5-engine.git","clone_url":"https://github.com/ckeditor/ckeditor5-engine.git","svn_url":"https://github.com/ckeditor/ckeditor5-engine","homepage":"","size":2555,"stargazers_count":25,"watchers_count":25,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":78,"forks":16,"open_issues":78,"watchers":25,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/376"},"html":{"href":"https://github.com/ckeditor/ckeditor5-engine/pull/376"},"issue":{"href":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/376"},"comments":{"href":"https://api.github.com/repos/ckeditor/ckeditor5-engine/issues/376/comments"},"review_comments":{"href":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/376/comments"},"review_comment":{"href":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ckeditor/ckeditor5-engine/pulls/376/commits"},"statuses":{"href":"https://api.github.com/repos/ckeditor/ckeditor5-engine/statuses/568773c23d6064edcecc3fd38ee0203c6feffdb8"}}}}