mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Merge pull request #2497 from ether/image-support-hook
clean support for image hook
This commit is contained in:
commit
4de42da2e3
2 changed files with 35 additions and 1 deletions
|
@ -203,6 +203,29 @@ Things in context:
|
||||||
|
|
||||||
This hook is called before the content of a node is collected by the usual methods. The cc object can be used to do a bunch of things that modify the content of the pad. See, for example, the heading1 plugin for etherpad original.
|
This hook is called before the content of a node is collected by the usual methods. The cc object can be used to do a bunch of things that modify the content of the pad. See, for example, the heading1 plugin for etherpad original.
|
||||||
|
|
||||||
|
## collectContentImage
|
||||||
|
Called from: src/static/js/contentcollector.js
|
||||||
|
|
||||||
|
Things in context:
|
||||||
|
|
||||||
|
1. cc - the contentcollector object
|
||||||
|
2. state - the current state of the change being made
|
||||||
|
3. tname - the tag name of this node currently being processed
|
||||||
|
4. style - the style applied to the node (probably CSS)
|
||||||
|
5. cls - the HTML class string of the node
|
||||||
|
6. node - the node being modified
|
||||||
|
|
||||||
|
This hook is called before the content of an image node is collected by the usual methods. The cc object can be used to do a bunch of things that modify the content of the pad.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```
|
||||||
|
exports.collectContentImage = function(name, context){
|
||||||
|
context.state.lineAttributes.img = context.node.outerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## collectContentPost
|
## collectContentPost
|
||||||
Called from: src/static/js/contentcollector.js
|
Called from: src/static/js/contentcollector.js
|
||||||
|
|
||||||
|
|
|
@ -458,7 +458,18 @@ function makeContentCollector(collectStyles, abrowser, apool, domInterface, clas
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var tname = (dom.nodeTagName(node) || "").toLowerCase();
|
var tname = (dom.nodeTagName(node) || "").toLowerCase();
|
||||||
if (tname == "br")
|
|
||||||
|
if (tname == "img"){
|
||||||
|
var context = hooks.callAll('collectContentImage', {
|
||||||
|
cc: cc,
|
||||||
|
state: state,
|
||||||
|
tname: tname,
|
||||||
|
styl: styl,
|
||||||
|
cls: cls,
|
||||||
|
node: node
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (tname == "br")
|
||||||
{
|
{
|
||||||
this.breakLine = true;
|
this.breakLine = true;
|
||||||
var tvalue = dom.nodeAttr(node, 'value');
|
var tvalue = dom.nodeAttr(node, 'value');
|
||||||
|
|
Loading…
Reference in a new issue