This repository has been archived by the owner on May 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Master odoo add prepend nby #226
Open
Goaman
wants to merge
1
commit into
master
Choose a base branch
from
master-odoo-add-prepend-nby
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
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 |
---|---|---|
|
@@ -175,6 +175,32 @@ export class DomHelpers<T extends JWPluginConfig = JWPluginConfig> extends JWPlu | |
} | ||
await this.editor.dispatcher.dispatchHooks('@redraw'); | ||
} | ||
/** | ||
* Prepend a DOM Node to another DOM Node's children. | ||
* | ||
* @param params | ||
*/ | ||
async prepend(container: Node, node: Node): Promise<void> { | ||
const toNodes = this.getNodes(node); | ||
const toNode = toNodes[toNodes.length - 1]; | ||
for (const vnode of this.getNodes(container).reverse()) { | ||
vnode.prepend(toNode); | ||
} | ||
await this.editor.dispatcher.dispatchHooks('@redraw'); | ||
} | ||
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. So... the implementation is alright by me, but I have questions regarding the concept. We have 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. The reason is that we do not want to check if there is a child or not. |
||
/** | ||
* Append a DOM Node to another DOM Node's children. | ||
* | ||
* @param params | ||
*/ | ||
async append(container: Node, node: Node): Promise<void> { | ||
const toNodes = this.getNodes(node); | ||
const toNode = toNodes[toNodes.length - 1]; | ||
for (const vnode of this.getNodes(container)) { | ||
vnode.append(toNode); | ||
} | ||
await this.editor.dispatcher.dispatchHooks('@redraw'); | ||
} | ||
/** | ||
* Insert html content before, after or inside a DOM Node. If no DOM Node | ||
* was provided, empty the range and insert the html content before the it. | ||
|
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.
We discussed with @Zinston and the only proper way in english is to say "prepend X to Y" so we would switch the order of the parameters. Same for
append
, obviously.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.
I disagree with the english argument. As we saw with sge and the command insertHTML, it is confusing to have to think about what english rule is for any command. It is far simpler to always set the node that will be modified as the first argument as 99% of our helpers.
It make sense to be like english only when it helps rather than create confusion.
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.
Well actually either way
node
has to be first...insertHTML
has the html to insert as first argument soprepend
should have the node to insert as first argument as well.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.
No, all other command except
insertHTML
has the "target" as the first argument. It'sinsertHTML
that should have it's current argument changed.