Releases: prismicio/javascript-kit
1.0.18
Breaking change: The content in StructuredText is now escaped. This was a bug that had to be fixed, but if you relied on it to include custom HTML it will no longer work. You can use a custom html serializer to get the behavior you need.
Bugfixes
- The content in StructuredText is now escaped.
- #64 Fixed grouping lists
1.0.17
1.0.14
1.0.13
1.0.12
Features
- Release IDs now exposed from
/api. - Document objects now expose their LinkedDocument objects.
Internal
- The
Documentsclass was renamed toResponsefor consistency with kits in other technologies. This class wasn't even exported, so this shouldn't change a thing to people using the kit.
1.0.11
New feature
- Cache on the
Apiinstantiation: all the other API calls were cached eternally, but you had to call the/apidocument once for each page your users were building; now we make sure/apidoes not get requested more than once every few seconds. - Added
altattribute to HTML serialization of images (as an image fragment or as an image in a structured text). asText()now exists for all fragment classes and for theDocclass, just likeasHtml().Docnow has agetColor()method.Refnow exposesscheduledAt, if it belongs to a scheduled content release.
Bugfix
- In the
/apiendpoint, the refs of content releases that are scheduled have ascheduledAtfield, which wasn't exposed in theApiclass; it now is. - Serialization of structured text fragments that start with a list item was buggy (the first item was out of the
<ul>). StructuredText.getFirstImagewas throwing an exception, now returns a proper result.- Support for legacy Internet Explorer
1.0.10
New feature
- Support for Group fragments
- HTML serialization of preformatted blocks within structured text fragments
- page, pageSize and orderings helper functions
Bugfix
- Using JSON.parse rather then
evalin tests (we did not useevalin the lib) - Removed the append of
#jsonto each API call, which used to make Internet Explorer grumpy, and wasn't needed.
1.0.9
New feature
- Pagination specifics are now exposed. This means now you still get your results paginated 20 by 20, but for each API call you also get the total number of pages, the total amount of results, the page number you're on, etc... which makes it trivial for you to build a pagination.
Potentially breaking changes
Note that the change introduced in this version will break all of your existing API query calls, so if you were using an earlier version of the prismic.io Javascript kit, _you will be most likely affected_.
Since 1.0.8, the callback in your submit function used to take err and results, an array of Doc objects. Now, pagination specifics are returned too, so your submit callback takes err and documents, an object of the class Documents, which contains the pagination specifics and the array of Doc objects (contained in documents.results).
Here's a real-life example to help you understand what you need to do:
You need to transform this:
api.form("everything").ref(ctx.ref).submit(function(err, results){
/* Do something */
results.forEach(function(result) { /* Do something */ }
/* Do something */
});into this:
api.form("everything").ref(ctx.ref).submit(function(err, documents){
/* Do something */
documents.results.forEach(function(result) { /* Do something */ }
/* Do something */
/* Do something new with documents.total_results_size, if you want */
});Note that the line where you have to change results into documents.results does not need to be right within your submit callback, but can be located in a function called by your submit callback. Specifically, if you use an MVC framework, the submit call is most likely in the controller, while the line you need to change may be in the view.
1.0.8
Potentially breaking changes
Note that the change introduced in this version will break all of your existing API query calls and API instantiations, so if you were using an earlier version of the prismic.io Javascript kit, _you will be most likely affected_.
The signature of the callback methods for the library's endpoint (Prismic.Api) and for the submit functions both have changed to include the possibility of an error callback, from callback(data) to callback(err, data).
Here's a real-life example to help you understand what you need to do:
You need to transform this:
Prismic.Api(
api_endpoint,
function(api) {
/* Do what needs to be done with api */
},
potential_token,
potential_request_handler
);into this:
Prismic.Api(
api_endpoint,
function(err, api) {
if (err) { /* Do whatever you want with err, for instance display err.message */ }
else { /* Do what needs to be done with api */ }
},
potential_token,
potential_request_handler
);And you need to transform this:
api.form("everything").ref(ctx.ref).submit(function(results){
/* Do what needs to be done with the results array */
});into this:
api.form("everything").ref(ctx.ref).submit(function(err, results){
if (err) { /* Do whatever you want with err, for instance display err.message */ }
else { /* Do what needs to be done with the results array */ }
});If your project is based on one of our JavaScript starter projects, look for a "Bump to 1.0.8" commit in the starter project's repository.