- Fixed: The babel plugin generated incorrect AST because of some AST nodes being duplicated. Fixed by cloning the nodes instead of reusing them.
- Added:
djedi.removeAdmin
.
- Fixed:
Content-Type: application/json; charset=utf-8
is now accepted for the nodes API response, not justContent-Type: application/json
. - Improved: Light validation for the node API response, rather than crashing or
silently doing the wrong thing. Previously a returned string would be treated
as
string.length
nodes.
- Added:
djedi.injectAdmin
now supports the 204 response code that Djedi 1.3.0 uses when the user is not a logged in as a Djedi user. The old 403 status code is also supported for backwards compatibility. The new 204 status code avoids the annoying/confusing red errors in the browser console of a “failed” request. (Older versions of djedi-react won’t crash if you try to use them with Djedi 1.3.0. An unnecessaryMutationObserver
will be installed for all visitors, but it shouldn’t matter much.)
- Improved: The admin sidebar is now updated as nodes come and go on the page in more cases. It also works better when hot reloading code while the sidebar is open.
- Improved:
<ForceNodes>
now accepts objects (and arrays) of nodes.
- Changed: djedi-react no longer depends on
isomorphic-unfetch.
Instead, you must set
djedi.options.fetch
to afetch
-like function. For example, you could still use isomorphic-unfetch:djedi.options.fetch = unfetch
. This lets you use the samefetch
as the rest of your app, and customize requests (such as adding headers). (Breaking change.) - Changed:
state.error
indefaultRender
and therender
prop now has a slightly different message and properties.error.status
anderror.responseText
have been replaced witherror.response
(which might be missing). (Breaking change.) - Added:
<ForceNodes>
. This component lets you force nodes to load and appear in the Djedi sidebar, even if the nodes are not shown usually. Useful for error messages.
- Fixed: Non-default languages now fetch the correct node content when server-side rendering.
-
Improved:
<Node>
now uses contextType. This reduces the nesting visible in the React devtools. This is a breaking change since React 16.6.0 or later is now required.Before:
<NodeWithContext> <NodeContext.Consumer> <Node> <span>Your text</span> </Node> </NodeContext.Consumer> </NodeWithContext>
After:
<Node> <span>Your text</span> </Node>
- Added: react@">=16.3.0" as a peer dependency. At least 16.3.0 has been required since 3.0.0 – this makes it explicit.
- Fixed: There was an error in the new 3.0.0 cache that caused edited nodes never to be updated when server-rendered.
- Fixed:
djedi.prefetch()
can no longer end up requesting all nodes on your entire site after a while. The fix was to change how the caching works. This means that the cache may now serve stale nodes, and nothing is ever deleted from the cache, only added. The cache must be able to fit all of your nodes in memory. This is a breaking change. - Removed: Support for custom caches, since the caching has gotten some very specific behavior because of the above fix above and it’s not clear if it’s an actual use case to provide your own cache. This is a breaking change.
- Changed: The promise returned by
djedi.prefetch()
no longer resolves to anything. Instead you need to doconst nodes = djedi.track()
, which is more explicit. This is a breaking change. - Added: Support for multiple languages, via
<NodeContext.Provider value={currentLanguage}>
anddjedi.options.languages
. This uses React’s new Context API added in 16.3.0, so at least that version of React is now required, which makes this a breaking change. - Added: The
render
prop anddjedi.options.defaultRender
now receive the current language, allowing for translating for example “Loading…” into several languages. - Changed: The default language is now set by doing for example
djedi.options.languages.default = "sv-se"
, due to the above multiple language support. The old way should still work, but is not recommended. - Improved: The Babel plugin now gives better errors and handles comments in some cases.
- Changed: Upgraded to isomorphic-unfetch@^3.0.0.
- Updated documentation with security advice. No code changes.
- Fixed: Dedenting is now more intuitive. This is a breaking change. See below for more information.
- Changed: Custom caches must now implement a
delete(uri: string): void
method. This is a breaking change. - Fixed: Changes to
<Node>
defaults now update correctly during development. As a side effect, rendering the same node URI twice with different defaults no longer logs a warning (instead, the newer default replaces the old one). - Improved: Documentation. More examples, clarifications and notes on quirks.
Previously, refactoring this:
const node = (
<Node uri="uri">{md`
text
`}</Node>
);
… into this:
const text = md`
text
`;
console.log(text);
const node = (
<Node uri="uri">{text}</Node>
);
… was surprising. The text
variable included the whitespace (as seen with the
console.log
), but <Node>
dedented it away. That caused the node to be
rendered differently when it was fetched by <Node>
versus when text
was
passed to djedi.prefetch({ extra: [{ uri: "uri", value: text }] })
. Four
spaces of indentation can cause a code block in markdown.
Version 2.0.0 removes the auto-dedenting in <Node>
. Instead the md
tag now
dedents. This makes the above case more intuitive. As a side effect, the md
tag now allows interpolation and no longer warns about that, but the Babel
plugin still errors in that case so it doesn’t really matter.
When writing plain JSX text the dedenting in <Node>
wasn’t needed anyway, due
to Babel’s JSX whitespace rules:
<Node uri="uri">
This is fine!
</Node>
In all other cases it is better to use the md
tag anyway.
The "dedent" package has also been swapped for the "dedent-js" package. The latter handles JS escapes correctly.
- No changes, just marking as stable.
- Fixed: The admin sidebar is now properly updated as nodes come and go on the page.
- Fixed: Nodes with null values returned from the server are now handled correctly. This happens when there’s neither a default value nor a database value. Previously this resulted in an error being rendered. Now an empty node is rendered, as expected.
- Initial release.