Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
polish jsdocs description and example
Sultan7f057486e777
diff --git a/app/shared/design-system/components/primitives/createContentController.js b/app/shared/design-system/components/primitives/createContentController.jsindex e3893cb9cd..c04679879a 100644--- a/app/shared/design-system/components/primitives/createContentController.js+++ b/app/shared/design-system/components/primitives/createContentController.js@@ -1,16 +1,23 @@-/*- @example-- const {update, disconnectedCallback} = createContentController(document.querySelector('input'), {- contents: [- { name: 'unit', match: (value) => value === 'px' },- { name: 'number', match: (value) => isNaN(parseFloat(value)) === false },- { name: 'unknown', match: (value) => true },- ],- onMouseMove: ({name, value, position}) => { },- onCaretMove: ({name, value, position}) => { },- });-*/+/**+ * @description+ * - detects whether the pointer/keyboard is on any given token as specified by the {contents: []} contract.+ * - pointermove/keyup in turn dispatch onMouseMove/onCaretMove with the current state if and when within a configured content token.+ * - returns two methods {update, disconnectedCallback} the former of which dispatches a content update(while preserving the caret position if any)+ * - read/write methods are called when reading from the passed element or when updating/writing to the same element.+ * @example+ * const target = document.querySelector('input');+ * const {update, disconnectedCallback} = createContentController(target, {+ * contents: [+ * { name: 'unit', match: (value) => value === 'px' },+ * { name: 'number', match: (value) => isNaN(parseFloat(value)) === false },+ * { name: 'unknown', match: (value) => true },+ * ],+ * onMouseMove: ({name, value, position}) => { },+ * onCaretMove: ({name, value, position}) => { },+ * read: (value) => target.value,+ * write: (value) => target.value = value,+ * });+ */const canvasContext = globalThis.document?.createElement("canvas").getContext("2d");@@ -94,7 +101,7 @@ export const createContentController = (return {update: (value) => {let { selectionStart, selectionEnd } = targetNode;- write(targetNode, value);+ write(value);targetNode.setSelectionRange?.(selectionStart, selectionEnd);},disconnectedCallback: () => {