Repository navigation
Releases
v0.2.2
Patch Changes
-
#36
83c9eadThanks @kriss145! - The Admin's document list takes alimitof 100 at most, and the plugin no longer has a health route.Behaviour changes - read before upgrading
GET /admin/cms/collections/:collection/documentsanswers400to alimitover 100, as the version and media lists do. Read more documents page by page withoffset.GET /admin/cms/healthis removed and answers404. Medusa's ownGET /healthchecks the server. A CMS config that does not resolve shows on every CMS route as a500with its problem, andvalidateConfig(config)from@mostrajs/cmsfinds it in a test of your project.
v0.2.1
Patch Changes
-
#31
2a8444aThanks @kriss145! - The rich text editor gains Markdown shortcuts, a Markdown view and a drag handle, and each of its tools is a feature a field can leave out.Behaviour changes - read before upgrading
- A field whose
featuresis a list of its own shows no full-screen button until the list holdsFullScreenFeature(). A field on the defaults, or with a function ofdefaultFeaturesorrootFeatures, keeps it.
Features
MarkdownShortcutsFeature()- Markdown typed or pasted, such as##,-or**bold**, turns into what the field's features allow. On by default.DragHandleFeature()- a paragraph, heading, list or quote moves above or below another by the handle beside it. On by default.FullScreenFeature()- the button that opens the editor over the whole Admin. On by default.MarkdownViewFeature()- the field edited as Markdown from the editor's Actions menu, and saved as the same document. Underline, subscript and superscript lose their format when the view opens, and undo brings it back. Off by default.RichTextFeatureKeyhas the keysmarkdownShortcuts,dragHandle,fullScreenandmarkdownView, which an exhaustiveswitchhandles.
- A field whose
-
#34
9c45ac5Thanks @kriss145! - A rich text field can hold horizontal rules, whichHorizontalRuleFeature()turns on.Features
HorizontalRuleFeature()- a toolbar button inserts a rule between blocks, and---alone on a line makes one. Off by default.- The renderers write a rule as
<hr>, under the component keyhorizontalRule. RichTextFeatureKeyhas the keyhorizontalRule, which an exhaustiveswitchhandles.
v0.2.0
Minor Changes
-
#26
298f915Thanks @kriss145! - The plugin's exports drop theCmsprefix:CmsTableConfigisTableConfig,defineCmsOptionsHookisdefineOptionsHook. Three take another name:CmsTextisConfigText,CmsDocumentisDocumentRow, andCmsBlockPlaceisBlockPlaceLevel. The workflows and steps keep their names.ConfigValue,DefaultsValue,RichTextTextFormat,ResolvedRichTextFeatureOfandCmsDocumentSourceare no longer exported. -
#26
24be38dThanks @kriss145! - Rich text has an entry of its own,@mostrajs/cms/shared/rich-text, with shorter names, and@mostrajs/cms/sharedkeeps the sanitizers and the slug.Behaviour changes - read before upgrading
-
Import rich text from
@mostrajs/cms/shared/rich-text, and rename what you use:Before, from @mostrajs/cms/sharedNow, from @mostrajs/cms/shared/rich-textvalidateRichTextvalidateDocumentparseRichTextparseDocumentisRichTextEmptyisDocumentEmptybuildRichTextRenderTreebuildRenderTreefindRichTextFeaturefindFeatureDEFAULT_RICH_TEXT_FEATURESDEFAULT_FEATURESRICH_TEXT_HEADINGSHEADINGSformatHtml,formatPlainText, the feature factories and theRichText*andRender*types keep their names and move to the new entry too. The package root exportsfindFeaturein place offindRichTextFeature.RichTextstays in@mostrajs/cms/shared/rich-text/renderers/react.// before import { escapeHtml, formatHtml, parseRichText } from "@mostrajs/cms/shared" // now import { escapeHtml } from "@mostrajs/cms/shared" import { formatHtml, parseDocument } from "@mostrajs/cms/shared/rich-text"
-
Patch Changes
-
#26
e0268a2Thanks @kriss145! - The rich text editor shows lists and bold italic text as they are saved on a project that installs the plugin from npm, and it follows a field that is disabled or enabled after it shows.Behaviour changes - read before upgrading
-
DEFAULT_FEATURESand the features arichText.featuresfunction gets are typed as read-only lists. A config that pushes intoDEFAULT_FEATURES,defaultFeaturesorrootFeatures, or types them asResolvedRichTextFeature[], fails to compile. Build a new list instead:features: ({ defaultFeatures }) => [ ...defaultFeatures.filter(({ key }) => key !== "heading"), HeadingFeature({ enabledHeadingSizes: ["h2"] }), ]
Fixes
- A bulleted list shows its bullets and a numbered list its numbers, where both showed no marker.
- Text that is both bold and italic shows in italic too.
- The last paragraph leaves no empty space below it.
- A rich text field of the form toolkit that a form disables after it shows becomes read-only, and editable again once enabled, where only its toolbar changed.
- A save refuses a rich text document nested more than 64 levels deep with a
400at the field, where a very deep one failed with a500. The renderers already drop what sits below that level. - A save refuses a link whose title holds a control character, and a text format holding a bit Lexical gives no format.
- A rich text field whose editor fails, on a stored text it cannot read or a chunk that fails to load, shows a message in its place, and the rest of the form keeps its changes.
-
-
#26
b675367Thanks @kriss145! - A rich text field offers underline, strikethrough, inline code, subscript, and superscript, and the plugin's renderers draw them as<u>,<s>,<code>,<sub>, and<sup>.Behaviour changes - read before upgrading
-
A rich text field that uses the default features shows the five new format buttons after the upgrade. So does a config whose
richText.featuresis a function ofdefaultFeatures. To keep the fields as they were, filter the five out in the config'srichText.features:features: ({ defaultFeatures }) => defaultFeatures.filter( ({ key }) => ![ "underline", "strikethrough", "inlineCode", "subscript", "superscript", ].includes(key) )
-
A storefront that renders rich text by hand and ignores the new format bits shows such text unstyled. The rich text format lists every bit.
Features
UnderlineFeature(),StrikethroughFeature(),InlineCodeFeature(),SubscriptFeature(), andSuperscriptFeature(), from the package root and@mostrajs/cms/shared/rich-text.- The render keys
underline,strikethrough,inlineCode,subscript, andsuperscript, for your own component of each. - A save refuses a text that is both subscript and superscript.
-
-
#24
67e8a94Thanks @kriss145! - The last button of a rich text toolbar opens the editor over the whole Admin, and Escape closes it with the text and undo kept. -
#26
b1f2b03Thanks @kriss145! - The bold and italic buttons of a rich text toolbar show their letters in bold and in italic on a project that installs the plugin from npm.
v0.1.3
Patch Changes
-
#21
85c78daThanks @kriss145! - In the document form, a field's description sits under its input, so the fields of a row line up whether or not each one has a description. -
#19
0dcbdf2Thanks @kriss145! - A storefront installs the plugin without Medusa's backend and renders a rich text field with the plugin's own code:RichTextfrom@mostrajs/cms/shared/rich-text/renderers/react, or HTML fromformatHtmlin@mostrajs/cms/shared.Features
RichText, a React component that renders in a server or a client component, on React 18 or 19, and takes your own component for any element, such as a router's link.formatHtml, for a storefront in any framework, andbuildRichTextRenderTreefor a renderer of your own.- Every text and attribute is escaped, and a link is written only when its URL is safe. A node the renderer does not know renders as its children, with a warning.
escapeHtmlandisSafeLinkUrlin@mostrajs/cms/shared, for any value you write into HTML.- Every peer dependency is optional and
reacttakes 18 or 19, so a storefront that installs the plugin gets no Medusa package and no Admin library.
v0.1.2
Patch Changes
-
#17
d297ebdThanks @kriss145! - The Admin's forms, tabs and rich text editor look as intended in a project that installs the plugin from npm.Fixes
- A form with tabs shows only the open tab's fields, where it showed every tab's fields at once.
- The rich text editor keeps its height when empty, its redo button shows a mirrored arrow, and a quote shows its left border.
- A link in the rich text editor takes Medusa's interactive colour on hover, in place of an underline the Admin never drew.
- A block's sections are divided by a line, with none above the first.
-
#14
6d27584Thanks @kriss145! - The package's description on npm is shorter and matches the README: a CMS inside your Medusa v2 project, with content as data models, edited in the Admin and served by the Store API. -
#16
83d6e94Thanks @kriss145! -translationKey(key, options?)names a translation as a text of the config, in place of a({ t }) => t(key)function of your own.Features
translationKeyis exported from@mostrajs/cmsand takes the options oft,nsincluded:label: translationKey("page.singular").- The README's basic setup says that a label written as a string shows the same in every language, and links to the page on translations.
v0.1.1
Patch Changes
-
#12
5c11c9dThanks @kriss145! - Clearer error messages, and documentation that is easier to read.- Messages. These messages now say what is wrong in plainer words. If your code or tests match one of them, update the text:
The media provider "<identifier>" does not support search, when the Admin searches a provider withoutlistmedia "<field>" stores "url", but the media provider "<identifier>" stores only "id", at startupadmin "edit" needs "page" or "drawer", at startupadmin "edit" "drawer" takes no "drafts: true", as a drawer shows no status and cannot publish, at startupa singleton takes no "drafts: true", as its page shows no status, publish actions, or version history, at startupfield "<name>" is filterable, but only a boolean field can be filterable, at startupOptions unavailable: no hook named "<name>" is registered, in the Admin, in English and Polish
- Documentation. Every page is laid out for scanning, with options in tables, data shapes and responses in code blocks, and failures in lists, and it is written in plainer English. It now also covers the save checks of blocks, the startup checks of tables, singletons and store lists, the media routes' errors, and when
serverPublishValidationruns.
- Messages. These messages now say what is wrong in plainer words. If your code or tests match one of them, update the text:
v0.1.0
Minor Changes
-
#7
d325210Thanks @kriss145! - The first release of Mostra as@mostrajs/cms: a CMS inside your Medusa v2 project, with content modelled as Medusa data models, edited in Medusa Admin and served through the store API.Moving from
@codee-sh/medusa-plugin-cms- This is the plugin published as
@codee-sh/medusa-plugin-cmsup to0.1.1, under its new name; that package is deprecated. No data, table, route or config key changes. - Swap the package:
npm uninstall @codee-sh/medusa-plugin-cmsandnpm install @mostrajs/cms. - Rename every import and the plugin's
resolveinmedusa-config.tsfrom@codee-sh/medusa-plugin-cmsto@mostrajs/cms, its/workflows,/admin-extensionsand/sharedentry points with it, then deletenode_modules/.vitebefore starting the Admin.
Features
- Content model
- Collections and singletons as Medusa data models in a module of your own, described by one typed config
- Blocks in areas, ordered and nested, for page builders and repeated content
- Fields: text, number, boolean, date, select, combobox, text list, slug, URL, rich text, media and relationships between collections
- Editing in Medusa Admin
- Pages under Content: routes that group collections, tables with filters and sorting, forms in sections and tabs, editing on a page or in a drawer
- Drafts and versions per collection: Publish, Unpublish, Discard changes and a version history to restore from
- Rich text edited with Lexical, with the features you allow per field
- Validation with Zod schemas on the server, mirrored in the form, and your own rules in a
validatehook - Extensions: your own field components, options loaded by a hook, widgets in the plugin's pages
- Admin texts in English and Polish, and your config's texts translatable
- Media
- Media fields over Medusa's File Module, or a media provider of your own
- Safe input
- Links checked against a link policy,
javascript:anddata:never allowed, control characters refused
- Links checked against a link policy,
- Store and backend
- Store API for published documents: a list, by id or by slug, with field selection, filters and paging
- Admin API, workflows, steps and document events exported for your own routes and subscribers
Getting started
npm install @mostrajs/cms- Write a module with your content models and a CMS config with
defineConfig, and register the plugin withoptions: { config }inmedusa-config.ts - Run
npx medusa db:generate <your module>andnpx medusa db:migrate - The whole setup is in the README
Documentation
- This is the plugin published as