@chili-publish/publisher-interface
Advanced tools
Weekly downloads
Readme
The Publisher Interface was designed to make integrating into CHILI publish Online easy.
As a happy side effect, the setter for document.domain
, which many integrations rely on, will become immutable at the beginning of January 2023. This means that the Publisher Interface will be the only supported way to communicate with Publisher via an <iframe>
.
All the magic happens with PublisherInterface
PublisherInterface is a class object that allows you to interact with the CHILI Editor editorObject via postMessage without the complexity of postMessage.
This project is officially supported by CHILI publish.
Notes:
You can find complete documentation on the wiki
editorObject
can no longer be used when communicating with an <iframe>
.PublisherInterface
and editorObject
.editorObject
to Publisher Interface.PublisherInterface
class and associated types. Even though it is auto-generated, the comments therein were written with insight.You can install PublisherInterface via npm
npm i @chili-publish/publisher-interface
or through yarn
yarn add @chili-publish/publisher-interface
You can also use it directly in the browser via unpkg.
import {PublisherInterface} from "https://unpkg.com/@chili-publish/publisher-interface@latest/dist/PublisherInterface.min.js";
The Publisher Interface has 1 dependency which is the Penpal library.
All other dependencies are only for the developer tools such as auto generating docs, testing, and packaging.
This means that their is very little security concerns, and the limitations are the same as those found in Penpal
Publisher Interface runs successfully on the most recent versions of Chrome, Firefox, Safari, and Edge. Internet Explorer is not supported.
The easiest way to get started is to pull the package from unpkg.
import {PublisherInterface} from "https://unpkg.com/@chili-publish/publisher-interface@latest/dist/PublisherInterface.min.js";
If you downloaded via NPM you can import it with
import {PublisherInterface} from "@chili-publish/publisher-interface";
Then in your JavaScript code, get the iframe which is loading the Publisher editor, and pass that iframe element into the build()
function of PublisherInterface
.
const iframe = document.getElementById("editor-iframe");
const publisher = PublisherInterface.build(iframe).then(
PublisherInterface => PublisherInterface.alert("Hi!")
);
🚨 Important - make sure that you call build()
before the iframe onload
event is fired. In practice this means that you should never call build()
when that event is fired.
Here is a complete example:
<body>
<iframe id="editor-iframe" style="width:1200px; height:800px"
src="https://example.chili-publish.online/example/editor_html.aspx?doc=3d178228-a9b9-49d0-90d9-c1c8f8b67f05&apiKey=Sczs1ruhiZcaFiqg0G07gMFMq07X+SG2o8KlW8oAeZGvqoB1a0YvkbeZU1wJK15aIhANgZmhg+13NQlxpBEq7Q=="></iframe>
<script type="module">
import {PublisherInterface} from 'https://unpkg.com/@chili-publish/publisher-interface@latest/dist/PublisherInterface.min.js';
const iframe = document.getElementById("editor-iframe");
(async () => {
const publisher = await PublisherInterface.build(iframe);
const documentName = await publisher.getObject("document.name");
console.log(documentName);
})();
</script>
</body>
To read more, check out our documentation.
FAQs
PublisherInterface is a class object that allows you to interact with the CHILI Publisher editorObject via postMessage without the complexity of postMessage.
The npm package @chili-publish/publisher-interface receives a total of 610 weekly downloads. As such, @chili-publish/publisher-interface popularity was classified as not popular.
We found that @chili-publish/publisher-interface demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket installs a Github app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.