-
Notifications
You must be signed in to change notification settings - Fork 427
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To prevent an Annotator is undefined error, the constructor class is set by the object returned from the hypothesisConfig function. The documentation has also been updated.
- Loading branch information
1 parent
66439ec
commit 8f6f667
Showing
2 changed files
with
36 additions
and
22 deletions.
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 |
---|---|---|
@@ -1,26 +1,44 @@ | ||
Customized embedding | ||
#################### | ||
|
||
By default, Hypothesis instantiates the ``Annotator.Host`` class defined in | ||
the injected code loaded by ``embed.js``. It is possible to change this by | ||
assigning an alternate constructor to ``window.hypothesisRole``. To customize | ||
the plugins that are loaded, define a function ``window.hypothesisConfig`` which | ||
returns an options object. This is then passed to the constructor as the | ||
second argument:: | ||
To customize the plugins that are loaded, define a function ``window.hypothesisConfig`` | ||
which returns an options object:: | ||
|
||
|
||
window.hypothesisConfig = function () { | ||
return { | ||
app: 'https://example.com/custom_sidebar_iframe', | ||
Toolbar: {container: '.toolbar-wrapper'} | ||
Toolbar: {container: '.toolbar-wrapper'}, | ||
BucketBar: {container: '.bucketbar-wrapper'} | ||
}; | ||
}; | ||
|
||
With the exception of ``app``, the properties for the options object are the | ||
names of Annotator plugins and their values are the options passed to the | ||
individual plugin constructors. | ||
In the above example, the Toolbar will be attached to the element with the | ||
``.toolbar-wrapper`` class, and the BucketBar to the element with the ``.bucketbar-wrapper`` | ||
class. | ||
|
||
The full range of possibilities here is still in need of documentation and we | ||
would appreciate any help to improve that. | ||
|
||
With the exception of ``app`` and ``constructor``, the properties for the options object | ||
are the names of Annotator plugins and their values are the options passed to the individual | ||
plugin constructors. | ||
|
||
The ``app`` property should be a url pointing to the HTML document that will be | ||
embedded in the page. | ||
|
||
The full range of possibilities here is still in need of documentation and we | ||
would appreciate any help to improve that. | ||
The ``constructor`` property should be used in when you want to annotate an iframe on a host | ||
document. By instantiating the ``Annotator.Guest`` class inside the iframe you can capture | ||
selection data from the frame which will be accessible by a host annotator in a parent document. | ||
By default, Hypothesis instantiates the ``Annotator.Host`` class defined in the injected code | ||
loaded by ``embed.js``. It is possible to change this by assigning an alternate ``constructor`` | ||
in the options object returned by ``window.hypothesisConfig``. For example:: | ||
|
||
|
||
window.hypothesisConfig = function () { | ||
return { | ||
constructor: Annotator.Guest | ||
}; | ||
}; | ||
|
||
An Annotator Host can connect to multiple guests. |
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