This repository has been archived by the owner on Jun 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
StylesProcessor is no longer singleton #1826
Merged
Changes from 32 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
09acfe9
Added "#document" property to "view.Node" (and inherited classes) and…
pomek 3ffb904
Corrected view.DowncastWriter() tests.
pomek 2d99f8f
Added #document property to view.UpcastWriter().
pomek 414f1c1
Adjusted tests and fixed "view.Text#_clone()" and "view.Element#_clon…
pomek 2f4357f
Reverted invalid changes.
pomek 3b361f8
Assign parent element document to the inserted children.
jodator c7e0226
Cannot based on checking the "#document" property on view elements be…
pomek 9831535
DomConverter.domToView() requires an instance of view.Document as a f…
pomek 88b9089
Removed obsolete and invalid code.
pomek 034b044
Use more precise name for an argument in the "needsPlaceholder()" fun…
pomek 8af8720
Adjusted all tests.
pomek 1fdcb8b
Added test for checking whether #document property is being updated a…
pomek dd78af1
Improved writers constructor docs.
pomek 8b56db1
StylesProcessor is not singleton anymore.
pomek 8681e0a
Styles Processor must be unique across the entire editor instance.
pomek a23ad5d
Updated tests to new APIs.
pomek 5145ce0
Update missing StylesProcessor instances in constructors.
jodator 821ae00
Add missing StylesProcessor instance.
jodator 2ce8492
Aligned to changes in Editor class.
pomek e2ed99c
Aligned tests to changes in API.
pomek d431e83
Simplified the code.
pomek e7f04b5
Merge branch 'master' into i/6091
pomek 066db20
Requested changes during the review.
pomek c62176b
Fixed docs after moving method between classes.
pomek 42fa0f7
Simplified tests.
pomek 6b9ac71
Remove empty before.
jodator cd0f3b6
Reverted changes in Renderer class.
pomek 3c3e902
"This should be inlined."
pomek fabfb3a
Merge branch 'i/6091' of github.com:ckeditor/ckeditor5-engine into i/…
pomek 5a4ab82
Merge branch 'master' into i/6091
jodator 21390a9
Removed the 'model.Node#document.' property.
pomek 8039a8d
Added a new method (#isAttached()) to both (view and model) Nodes cla…
pomek b21a415
Removed the dataProcessor argument, as it was never used in practice.
Reinmar 054d8a2
Docs.
Reinmar 13dd24c
Docs and code simplification.
Reinmar 16301a1
Docs and other improvements.
Reinmar fb8e77a
Docs and other improvements.
Reinmar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -46,11 +46,12 @@ export default class DataController { | |||||||||
/** | ||||||||||
* Creates a data controller instance. | ||||||||||
* | ||||||||||
* @param {module:engine/view/stylesmap~StylesProcessor} stylesProcessor Styles processor. | ||||||||||
* @param {module:engine/model/model~Model} model Data model. | ||||||||||
* @param {module:engine/dataprocessor/dataprocessor~DataProcessor} [dataProcessor] Data processor that should be used | ||||||||||
* by the controller. | ||||||||||
*/ | ||||||||||
constructor( model, dataProcessor ) { | ||||||||||
constructor( stylesProcessor, model, dataProcessor ) { | ||||||||||
/** | ||||||||||
* Data model. | ||||||||||
* | ||||||||||
|
@@ -59,6 +60,14 @@ export default class DataController { | |||||||||
*/ | ||||||||||
this.model = model; | ||||||||||
|
||||||||||
/** | ||||||||||
* StylesProcessor is responsible for writing and reading a normalized styles object. | ||||||||||
* | ||||||||||
* @readonly | ||||||||||
* @member {module:engine/view/stylesmap~StylesProcessor} | ||||||||||
*/ | ||||||||||
this.stylesProcessor = stylesProcessor; | ||||||||||
|
||||||||||
/** | ||||||||||
* Data processor used during the conversion. | ||||||||||
* | ||||||||||
|
@@ -187,12 +196,13 @@ export default class DataController { | |||||||||
|
||||||||||
// First, convert elements. | ||||||||||
const modelRange = ModelRange._createIn( modelElementOrFragment ); | ||||||||||
const viewDocument = new ViewDocument( this.stylesProcessor ); | ||||||||||
|
||||||||||
const viewDocumentFragment = new ViewDocumentFragment(); | ||||||||||
const viewDocumentFragment = new ViewDocumentFragment( viewDocument ); | ||||||||||
|
||||||||||
// Create separate ViewDowncastWriter just for data conversion purposes. | ||||||||||
// We have no view controller and rendering do DOM in DataController so view.change() block is not used here. | ||||||||||
const viewWriter = new ViewDowncastWriter( new ViewDocument() ); | ||||||||||
const viewWriter = new ViewDowncastWriter( viewDocument ); | ||||||||||
this.mapper.bindElements( modelElementOrFragment, viewDocumentFragment ); | ||||||||||
|
||||||||||
this.downcastDispatcher.convertInsert( modelRange, viewWriter ); | ||||||||||
|
@@ -371,6 +381,22 @@ export default class DataController { | |||||||||
} ); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Adds a style processor normalization rules. | ||||||||||
* | ||||||||||
* The available style processors: | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
* | ||||||||||
* * background: {@link module:engine/view/styles/background~addBackgroundRules} | ||||||||||
* * border: {@link module:engine/view/styles/border~addBorderRules} | ||||||||||
* * margin: {@link module:engine/view/styles/margin~addMarginRules} | ||||||||||
* * padding: {@link module:engine/view/styles/padding~addPaddingRules} | ||||||||||
* | ||||||||||
* @param {Function} callback | ||||||||||
*/ | ||||||||||
addStyleProcessorRules( callback ) { | ||||||||||
callback( this.stylesProcessor ); | ||||||||||
} | ||||||||||
|
||||||||||
/** | ||||||||||
* Removes all event listeners set by the DataController. | ||||||||||
*/ | ||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -189,20 +189,12 @@ export default class Node { | |||||||
} | ||||||||
|
||||||||
/** | ||||||||
* {@link module:engine/model/document~Document Document} that owns this node or `null` if the node has no parent or is inside | ||||||||
* a {@link module:engine/model/documentfragment~DocumentFragment DocumentFragment}. | ||||||||
* Returns true if a node is in a tree rooted in an element of the root type. | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
* | ||||||||
* @readonly | ||||||||
* @type {module:engine/model/document~Document|null} | ||||||||
* @returns {Boolean} | ||||||||
*/ | ||||||||
get document() { | ||||||||
// This is a top element of a sub-tree. | ||||||||
if ( this.root == this ) { | ||||||||
return null; | ||||||||
} | ||||||||
|
||||||||
// Root may be `DocumentFragment` which does not have document property. | ||||||||
return this.root.document || null; | ||||||||
isAttached() { | ||||||||
return this.root.is( 'rootElement' ); | ||||||||
} | ||||||||
|
||||||||
/** | ||||||||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this the first param? It should be the last one. It is the last one in the
EditingController
already.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
dataProcessor
is not required. Following the docs:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also a test that says the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still, the
model
is required. So if anything, this should be the 2nd arg.