From f8a987e3d564c88b6af2343801936720fe475e11 Mon Sep 17 00:00:00 2001 From: joostdecock Date: Sat, 10 May 2025 15:47:00 +0200 Subject: [PATCH] [react] feat: Added docs for components/Editor --- .../Editor/components/menus/Container.mjs | 1 - packages/react/components/Editor/index.mjs | 18 +++++++++------- .../react/components/Editor/lib/editor.mjs | 21 +------------------ .../react/components/Editor/lib/index.mjs | 2 -- packages/react/mkdocs.sh | 1 + .../react/components/editor/readme.mdx | 18 +++++++++++++--- 6 files changed, 27 insertions(+), 34 deletions(-) diff --git a/packages/react/components/Editor/components/menus/Container.mjs b/packages/react/components/Editor/components/menus/Container.mjs index ddee87adacc..0c7d21f7b70 100644 --- a/packages/react/components/Editor/components/menus/Container.mjs +++ b/packages/react/components/Editor/components/menus/Container.mjs @@ -9,7 +9,6 @@ import { EditIcon, GroupIcon, OptionsIcon, ResetIcon } from '@freesewing/react/c import { FormControl } from '@freesewing/react/components/Input' import { MiniTip } from '@freesewing/react/components/Mini' -/** @type {String} class to apply to buttons on open menu items */ const iconButtonClass = 'tw:daisy-btn tw:daisy-btn-xs tw:daisy-btn-ghost tw:px-0 tw:text-accent' /** diff --git a/packages/react/components/Editor/index.mjs b/packages/react/components/Editor/index.mjs index f7029d2142f..9efc2c4d8c3 100644 --- a/packages/react/components/Editor/index.mjs +++ b/packages/react/components/Editor/index.mjs @@ -19,16 +19,18 @@ import { useAccount } from '../../hooks/useAccount/index.mjs' * FreeSewing's pattern editor * * Editor is the high-level FreeSewing component - * that provides the entire pattern editing environment + * that provides the entire pattern editing environment. * This is a high-level wrapper that figures out what view to load initially, - * and handles state for the pattern, including the view + * and handles state for the pattern, including the view. * + * @component * @param {object} props - All React props - * @param {object} props.config - A configuration object for the editor - * @param {object} props.design - A design name to force the editor to use this design - * @param {object} props.preload - Any state to preload - * @param {function} props.setTitle - A way to set the page title (optional) - * @param {object} props.localDesigns - A way to add local designs to the editor (optional) + * @param {object} [props.config = {}] - A configuration object for the editor + * @param {object} [props.design = false] - A design name to preset the editor to use this design + * @param {object} [props.preload = {}] - Any state to preload + * @param {function} [props.setTitle = false] - A way to set the page title + * @param {object} [props.localDesigns = {}] - A way to add local designs to the editor + * @param {function} [props.measurementsHelpProvider = false] - A function that should return to a URL for measurements help */ export const Editor = ({ config = {}, @@ -161,7 +163,7 @@ export const Editor = ({ ) } -/** +/* * Helper method to figure out what view to load * based on the props passed in, and destructure * the props we need for it. diff --git a/packages/react/components/Editor/lib/editor.mjs b/packages/react/components/Editor/lib/editor.mjs index 947cb8b8e10..85dd54ea40a 100644 --- a/packages/react/components/Editor/lib/editor.mjs +++ b/packages/react/components/Editor/lib/editor.mjs @@ -320,7 +320,7 @@ export function initialEditorState(preload = {}, config) { return initial } -/** +/* * round a value to the correct number of decimal places to display all supplied digits after multiplication * this is a workaround for floating point errors * examples: @@ -746,25 +746,6 @@ export function noop() { export function notEmpty(value) { return String(value).length > 0 } -/** - * Helper method to merge arrays of translation namespaces - * - * Note that this method is variadic - * - * @param {[string]} namespaces - A string or array of strings of namespaces - * @return {[string]} namespaces - A merged array of all namespaces - */ -export function nsMerge(...args) { - const ns = new Set() - for (const arg of args) { - if (typeof arg === 'string') ns.add(arg) - else if (Array.isArray(arg)) { - for (const el of nsMerge(...arg)) ns.add(el) - } - } - - return [...ns] -} /* * A translation fallback method in case none is passed in diff --git a/packages/react/components/Editor/lib/index.mjs b/packages/react/components/Editor/lib/index.mjs index 2258b5856c3..02bff627e84 100644 --- a/packages/react/components/Editor/lib/index.mjs +++ b/packages/react/components/Editor/lib/index.mjs @@ -28,7 +28,6 @@ import { menuValueWasChanged, noop, notEmpty, - nsMerge, objUpdate, sample, settingsValueIsCustom, @@ -91,7 +90,6 @@ export { menuValueWasChanged, noop, notEmpty, - nsMerge, objUpdate, sample, settingsValueIsCustom, diff --git a/packages/react/mkdocs.sh b/packages/react/mkdocs.sh index 9c8c531afc6..4f1e3e431c0 100755 --- a/packages/react/mkdocs.sh +++ b/packages/react/mkdocs.sh @@ -10,3 +10,4 @@ jsdoc -c jsdoc.json components/Control/* > ../../sites/dev/prebuild/jsdoc/react/ jsdoc -c jsdoc.json components/CuratedSet/* > ../../sites/dev/prebuild/jsdoc/react/components/curatedset.json jsdoc -c jsdoc.json components/Docusaurus/* > ../../sites/dev/prebuild/jsdoc/react/components/docusaurus.json jsdoc -c jsdoc.json components/Echart/* > ../../sites/dev/prebuild/jsdoc/react/components/echart.json +jsdoc -c jsdoc.json components/Editor/* > ../../sites/dev/prebuild/jsdoc/react/components/editor.json diff --git a/sites/dev/docs/reference/packages/react/components/editor/readme.mdx b/sites/dev/docs/reference/packages/react/components/editor/readme.mdx index 9c54f158219..9ff01e78407 100644 --- a/sites/dev/docs/reference/packages/react/components/editor/readme.mdx +++ b/sites/dev/docs/reference/packages/react/components/editor/readme.mdx @@ -2,6 +2,18 @@ title: Editor --- -:::note -This page is yet to be created -::: +import { DocusaurusDoc } from '@freesewing/react/components/Docusaurus' +import { ComponentDocs } from '@site/src/components/component-docs.js' +import { jsdocEditor } from '@site/prebuild/jsdoc/components.editor.mjs' +import { Editor } from '@freesewing/react/components/Editor' + + + +The **Editor** component family provides the following components: + +- [Editor](#editor) + +## Editor + + +