@webround/editor 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blocks.d.ts +90 -0
- package/dist/blocks.js +119 -0
- package/dist/bridge.d.ts +96 -0
- package/dist/bridge.js +970 -0
- package/dist/check/aria.d.ts +19 -0
- package/dist/check/aria.js +106 -0
- package/dist/check/cli.d.ts +3 -0
- package/dist/check/cli.js +30 -0
- package/dist/check/css.d.ts +13 -0
- package/dist/check/css.js +63 -0
- package/dist/check/html.d.ts +8 -0
- package/dist/check/html.js +29 -0
- package/dist/check/index.d.ts +4 -0
- package/dist/check/index.js +5 -0
- package/dist/check/links.d.ts +7 -0
- package/dist/check/links.js +23 -0
- package/dist/check/orphans.d.ts +20 -0
- package/dist/check/orphans.js +57 -0
- package/dist/check/producer-code.d.ts +53 -0
- package/dist/check/producer-code.js +379 -0
- package/dist/check/producer-dom.d.ts +21 -0
- package/dist/check/producer-dom.js +52 -0
- package/dist/check/project.d.ts +20 -0
- package/dist/check/project.js +51 -0
- package/dist/check/rules.d.ts +7 -0
- package/dist/check/rules.js +517 -0
- package/dist/check/types.d.ts +160 -0
- package/dist/check/types.js +22 -0
- package/dist/components/WrAltcha.d.ts +5 -0
- package/dist/components/WrAltcha.js +8 -0
- package/dist/components/WrButton.d.ts +8 -0
- package/dist/components/WrButton.js +34 -0
- package/dist/components/WrForm.d.ts +6 -0
- package/dist/components/WrForm.js +29 -0
- package/dist/components/WrFormPrivacy.d.ts +4 -0
- package/dist/components/WrFormPrivacy.js +7 -0
- package/dist/components/WrFormSuccess.d.ts +4 -0
- package/dist/components/WrFormSuccess.js +12 -0
- package/dist/components/WrIframe.d.ts +12 -0
- package/dist/components/WrIframe.js +30 -0
- package/dist/components/WrImage.d.ts +9 -0
- package/dist/components/WrImage.js +28 -0
- package/dist/components/WrInput.d.ts +8 -0
- package/dist/components/WrInput.js +29 -0
- package/dist/components/WrLink.d.ts +10 -0
- package/dist/components/WrLink.js +38 -0
- package/dist/components/WrNav.d.ts +26 -0
- package/dist/components/WrNav.js +30 -0
- package/dist/components/WrSection.d.ts +11 -0
- package/dist/components/WrSection.js +5 -0
- package/dist/components/WrShared.d.ts +12 -0
- package/dist/components/WrShared.js +20 -0
- package/dist/components/WrText.d.ts +11 -0
- package/dist/components/WrText.js +41 -0
- package/dist/components/WrVideo.d.ts +9 -0
- package/dist/components/WrVideo.js +73 -0
- package/dist/components/text-editor/CodeThemeContext.d.ts +8 -0
- package/dist/components/text-editor/CodeThemeContext.js +10 -0
- package/dist/components/text-editor/ExampleTheme.d.ts +77 -0
- package/dist/components/text-editor/ExampleTheme.js +76 -0
- package/dist/components/text-editor/ToolbarContext.d.ts +17 -0
- package/dist/components/text-editor/ToolbarContext.js +32 -0
- package/dist/components/text-editor/WrTextEditor.d.ts +13 -0
- package/dist/components/text-editor/WrTextEditor.js +48 -0
- package/dist/components/text-editor/common/constants.d.ts +109 -0
- package/dist/components/text-editor/common/constants.js +58 -0
- package/dist/components/text-editor/common/surface.d.ts +3 -0
- package/dist/components/text-editor/common/surface.js +8 -0
- package/dist/components/text-editor/common/utils.d.ts +7 -0
- package/dist/components/text-editor/common/utils.js +78 -0
- package/dist/components/text-editor/hooks/useLexicalCommitOnBlur.d.ts +5 -0
- package/dist/components/text-editor/hooks/useLexicalCommitOnBlur.js +41 -0
- package/dist/components/text-editor/hooks/useLexicalMarkdown.d.ts +33 -0
- package/dist/components/text-editor/hooks/useLexicalMarkdown.js +284 -0
- package/dist/components/text-editor/nodes/CodeBlockNode.d.ts +23 -0
- package/dist/components/text-editor/nodes/CodeBlockNode.js +138 -0
- package/dist/components/text-editor/nodes/HorizontalRuleNode.d.ts +13 -0
- package/dist/components/text-editor/nodes/HorizontalRuleNode.js +22 -0
- package/dist/components/text-editor/plugins/CodeBlockPlugin.d.ts +2 -0
- package/dist/components/text-editor/plugins/CodeBlockPlugin.js +38 -0
- package/dist/components/text-editor/plugins/FontPlugin.d.ts +12 -0
- package/dist/components/text-editor/plugins/FontPlugin.js +114 -0
- package/dist/components/text-editor/plugins/FontSizePlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/FontSizePlugin.js +105 -0
- package/dist/components/text-editor/plugins/FontWeightPlugin.d.ts +6 -0
- package/dist/components/text-editor/plugins/FontWeightPlugin.js +103 -0
- package/dist/components/text-editor/plugins/HTMLTagPlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/HTMLTagPlugin.js +82 -0
- package/dist/components/text-editor/plugins/HorizontalRulePlugin.d.ts +2 -0
- package/dist/components/text-editor/plugins/HorizontalRulePlugin.js +35 -0
- package/dist/components/text-editor/plugins/LineSpacingPlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/LineSpacingPlugin.js +83 -0
- package/dist/components/text-editor/plugins/LinkPlugin.d.ts +8 -0
- package/dist/components/text-editor/plugins/LinkPlugin.js +183 -0
- package/dist/components/text-editor/plugins/ListToolbarPlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/ListToolbarPlugin.js +40 -0
- package/dist/components/text-editor/plugins/LoadContentPlugin.d.ts +4 -0
- package/dist/components/text-editor/plugins/LoadContentPlugin.js +63 -0
- package/dist/components/text-editor/plugins/MarkdownExportPlugin.d.ts +4 -0
- package/dist/components/text-editor/plugins/MarkdownExportPlugin.js +17 -0
- package/dist/components/text-editor/plugins/MarkdownPastePlugin.d.ts +2 -0
- package/dist/components/text-editor/plugins/MarkdownPastePlugin.js +45 -0
- package/dist/components/text-editor/plugins/SanitizePastePlugin.d.ts +3 -0
- package/dist/components/text-editor/plugins/SanitizePastePlugin.js +40 -0
- package/dist/components/text-editor/plugins/TextAlignPlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/TextAlignPlugin.js +65 -0
- package/dist/components/text-editor/plugins/TextColorPlugin.d.ts +7 -0
- package/dist/components/text-editor/plugins/TextColorPlugin.js +117 -0
- package/dist/components/text-editor/plugins/ToolbarPlugin.d.ts +10 -0
- package/dist/components/text-editor/plugins/ToolbarPlugin.js +73 -0
- package/dist/components/text-editor/theme-colors.d.ts +11 -0
- package/dist/components/text-editor/theme-colors.js +28 -0
- package/dist/context/WrAppContext.d.ts +35 -0
- package/dist/context/WrAppContext.js +113 -0
- package/dist/context/WrLayout.d.ts +15 -0
- package/dist/context/WrLayout.js +22 -0
- package/dist/context/WrPageContext.d.ts +28 -0
- package/dist/context/WrPageContext.js +282 -0
- package/dist/context/restoreValues.d.ts +2 -0
- package/dist/context/restoreValues.js +6 -0
- package/dist/contrast.d.ts +45 -0
- package/dist/contrast.js +122 -0
- package/dist/drop.d.ts +7 -0
- package/dist/drop.js +51 -0
- package/dist/gaps.d.ts +14 -0
- package/dist/gaps.js +50 -0
- package/dist/hooks/useWrMessage.d.ts +5 -0
- package/dist/hooks/useWrMessage.js +24 -0
- package/dist/hooks/useWrSave.d.ts +2 -0
- package/dist/hooks/useWrSave.js +11 -0
- package/dist/index.css +467 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +20 -0
- package/dist/interactive.d.ts +8 -0
- package/dist/interactive.js +13 -0
- package/dist/measure-rules.d.ts +34 -0
- package/dist/measure-rules.js +54 -0
- package/dist/measure.d.ts +11 -0
- package/dist/measure.js +139 -0
- package/dist/messages.d.ts +860 -0
- package/dist/messages.js +2 -0
- package/dist/nav.d.ts +5 -0
- package/dist/nav.js +10 -0
- package/dist/operations/animations-store.d.ts +6 -0
- package/dist/operations/animations-store.js +63 -0
- package/dist/operations/cli.d.ts +3 -0
- package/dist/operations/cli.js +52 -0
- package/dist/operations/comments-store.d.ts +17 -0
- package/dist/operations/comments-store.js +62 -0
- package/dist/operations/context.d.ts +12 -0
- package/dist/operations/context.js +35 -0
- package/dist/operations/define.d.ts +81 -0
- package/dist/operations/define.js +86 -0
- package/dist/operations/index.d.ts +6 -0
- package/dist/operations/index.js +6 -0
- package/dist/operations/ops/check.d.ts +5 -0
- package/dist/operations/ops/check.js +53 -0
- package/dist/operations/ops/comments.d.ts +6 -0
- package/dist/operations/ops/comments.js +133 -0
- package/dist/operations/ops/content.d.ts +16 -0
- package/dist/operations/ops/content.js +73 -0
- package/dist/operations/ops/json.d.ts +4 -0
- package/dist/operations/ops/json.js +27 -0
- package/dist/operations/ops/langs.d.ts +4 -0
- package/dist/operations/ops/langs.js +32 -0
- package/dist/operations/ops/nodes.d.ts +8 -0
- package/dist/operations/ops/nodes.js +270 -0
- package/dist/operations/ops/pages.d.ts +8 -0
- package/dist/operations/ops/pages.js +154 -0
- package/dist/operations/ops/project.d.ts +36 -0
- package/dist/operations/ops/project.js +97 -0
- package/dist/operations/ops/seo.d.ts +17 -0
- package/dist/operations/ops/seo.js +358 -0
- package/dist/operations/ops/style.d.ts +76 -0
- package/dist/operations/ops/style.js +268 -0
- package/dist/operations/ops/stylesets.d.ts +9 -0
- package/dist/operations/ops/stylesets.js +145 -0
- package/dist/operations/ops/theme.d.ts +6 -0
- package/dist/operations/ops/theme.js +304 -0
- package/dist/operations/registry.d.ts +8 -0
- package/dist/operations/registry.js +19 -0
- package/dist/operations/stylesets-store.d.ts +50 -0
- package/dist/operations/stylesets-store.js +216 -0
- package/dist/registry.d.ts +5 -0
- package/dist/registry.js +24 -0
- package/dist/save.d.ts +65 -0
- package/dist/save.js +86 -0
- package/dist/schema.d.ts +69 -0
- package/dist/schema.js +110 -0
- package/dist/scope.d.ts +41 -0
- package/dist/scope.js +44 -0
- package/dist/vite-plugins/ast.d.ts +3 -0
- package/dist/vite-plugins/ast.js +238 -0
- package/dist/vite-plugins/core-swap.d.ts +3 -0
- package/dist/vite-plugins/core-swap.js +57 -0
- package/dist/vite-plugins/create-page.d.ts +4 -0
- package/dist/vite-plugins/create-page.js +59 -0
- package/dist/vite-plugins/guard.d.ts +15 -0
- package/dist/vite-plugins/guard.js +35 -0
- package/dist/vite-plugins/head.d.ts +13 -0
- package/dist/vite-plugins/head.js +53 -0
- package/dist/vite-plugins/index.d.ts +7 -0
- package/dist/vite-plugins/index.js +7 -0
- package/dist/vite-plugins/jsx-tree.d.ts +118 -0
- package/dist/vite-plugins/jsx-tree.js +686 -0
- package/dist/vite-plugins/langs.d.ts +3 -0
- package/dist/vite-plugins/langs.js +44 -0
- package/dist/vite-plugins/operations.d.ts +10 -0
- package/dist/vite-plugins/operations.js +66 -0
- package/dist/vite-plugins/pages-api.d.ts +3 -0
- package/dist/vite-plugins/pages-api.js +112 -0
- package/dist/vite-plugins/pages.d.ts +3 -0
- package/dist/vite-plugins/pages.js +64 -0
- package/dist/vite-plugins/read.d.ts +3 -0
- package/dist/vite-plugins/read.js +45 -0
- package/dist/vite-plugins/seo-files.d.ts +8 -0
- package/dist/vite-plugins/seo-files.js +42 -0
- package/dist/vite-plugins/theme.d.ts +3 -0
- package/dist/vite-plugins/theme.js +207 -0
- package/dist/vite-plugins/update.d.ts +3 -0
- package/dist/vite-plugins/update.js +46 -0
- package/dist/vite-plugins/wr-plugins.d.ts +15 -0
- package/dist/vite-plugins/wr-plugins.js +34 -0
- package/dist/vite-plugins.d.ts +11 -0
- package/dist/vite-plugins.js +518 -0
- package/package.json +96 -5
- package/README.md +0 -3
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The neutral tree: what a rule sees. Two producers fill it (the code, the DOM); the rules never know which one did.
|
|
2
|
+
/** The page name an issue about the whole site carries (the way `_shared/header` names what is not a page). */
|
|
3
|
+
export const CHECK_SITE = '_site';
|
|
4
|
+
/**
|
|
5
|
+
* The identity of a problem: its rule, where it is (a page, or `_shared` for the header and footer, which every page shows), and what it is about.
|
|
6
|
+
* NOT the words (a count in them changes) nor the languages (one decision covers them all).
|
|
7
|
+
*/
|
|
8
|
+
export function issueKey(parts) {
|
|
9
|
+
const fix = parts.fix ? `${parts.fix.kind}:${'field' in parts.fix ? parts.fix.field : parts.fix.scope}` : '';
|
|
10
|
+
return [parts.rule, parts.page, parts.subject ?? '', fix].join('|');
|
|
11
|
+
}
|
|
12
|
+
/** Depth-first, in document order. */
|
|
13
|
+
export function walk(nodes, visit) {
|
|
14
|
+
for (const node of nodes) {
|
|
15
|
+
visit(node);
|
|
16
|
+
walk(node.children, visit);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function stripTags(html) {
|
|
20
|
+
return html.replace(/<[^>]*>/g, ' ').replace(/ /g, ' ').replace(/\s+/g, ' ').trim();
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type WrAltchaViewProps } from '@webround/core/form-react';
|
|
3
|
+
/** The proof in the editor runs in test mode (the form's transport says so): the checkbox can be clicked and nothing is asked of the backend. */
|
|
4
|
+
export declare function WrAltcha(props: Omit<WrAltchaViewProps, 'rootProps'>): React.ReactElement | null;
|
|
5
|
+
//# sourceMappingURL=WrAltcha.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { WrAltchaView } from '@webround/core/form-react';
|
|
3
|
+
import { wrInteractive } from '../interactive';
|
|
4
|
+
/** The proof in the editor runs in test mode (the form's transport says so): the checkbox can be clicked and nothing is asked of the backend. */
|
|
5
|
+
export function WrAltcha(props) {
|
|
6
|
+
return _jsx(WrAltchaView, { ...props, rootProps: wrInteractive });
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=WrAltcha.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface WrButtonOwnProps {
|
|
3
|
+
id: string;
|
|
4
|
+
}
|
|
5
|
+
type WrButtonProps = WrButtonOwnProps & Omit<React.ComponentPropsWithoutRef<'button'>, 'id'>;
|
|
6
|
+
export declare function WrButton({ id, children, ...props }: WrButtonProps): React.ReactElement;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=WrButton.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { wrAriaLabel, wrLocalized, wrSetLocalized } from '@webround/core/localized';
|
|
3
|
+
import { useWrApp } from '../context/WrAppContext';
|
|
4
|
+
import { useWrMessage } from '../hooks/useWrMessage';
|
|
5
|
+
import { wrSavePage } from '../save';
|
|
6
|
+
import { useWrPage, useWrPageMeta, useWrPageUpdate } from '../context/WrPageContext';
|
|
7
|
+
import { wrInteractive } from '../interactive';
|
|
8
|
+
import { useWrSubmitGate } from '@webround/core/form-react';
|
|
9
|
+
export function WrButton({ id, children, ...props }) {
|
|
10
|
+
const config = useWrPage(id);
|
|
11
|
+
const updateConfig = useWrPageUpdate();
|
|
12
|
+
const pageName = useWrPageMeta();
|
|
13
|
+
const { lang } = useWrApp();
|
|
14
|
+
const rawContent = config?.content;
|
|
15
|
+
const content = rawContent !== undefined ? (wrLocalized(rawContent, lang) ?? '') : undefined;
|
|
16
|
+
const ariaLabel = wrAriaLabel(config, props['aria-label'], lang);
|
|
17
|
+
// A button that submits a form waits for the form to be ready (the fields, the proof, the consent)
|
|
18
|
+
const gate = useWrSubmitGate();
|
|
19
|
+
const disabled = props.disabled ?? (gate && (props.type ?? 'submit') === 'submit' ? gate.disabled : undefined);
|
|
20
|
+
useWrMessage('wr:button:update', id, async (msg) => {
|
|
21
|
+
const mergedContent = msg.content !== undefined ? wrSetLocalized(rawContent, lang, msg.content) : rawContent;
|
|
22
|
+
const patch = {
|
|
23
|
+
...(mergedContent !== undefined ? { content: mergedContent } : {}),
|
|
24
|
+
...(msg.ariaLabel !== undefined ? { ariaLabel: wrSetLocalized(config?.ariaLabel, lang, msg.ariaLabel) } : {}),
|
|
25
|
+
...(msg.hidden !== undefined ? { hidden: msg.hidden } : {}),
|
|
26
|
+
};
|
|
27
|
+
updateConfig(id, patch);
|
|
28
|
+
await wrSavePage(pageName, id, { ...config, ...patch });
|
|
29
|
+
});
|
|
30
|
+
if (config?.hidden)
|
|
31
|
+
return _jsx(_Fragment, {});
|
|
32
|
+
return (_jsx("button", { "data-wr-id": id, "data-wr-type": "button", ...wrInteractive, ...props, disabled: disabled, "aria-label": ariaLabel, children: content !== undefined ? _jsx("span", { dangerouslySetInnerHTML: { __html: content } }) : children }));
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=WrButton.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type WrFormViewProps } from '@webround/core/form-react';
|
|
3
|
+
type WrFormProps = Omit<WrFormViewProps, 'lang' | 'config' | 'transport'>;
|
|
4
|
+
export declare function WrForm(props: WrFormProps): React.ReactElement | null;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=WrForm.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { wrSetLocalized } from '@webround/core/localized';
|
|
3
|
+
import { WR_FORM_MESSAGE_CODES } from '@webround/core/form';
|
|
4
|
+
import { WrFormView } from '@webround/core/form-react';
|
|
5
|
+
import { useWrApp } from '../context/WrAppContext';
|
|
6
|
+
import { useWrPage, useWrPageMeta, useWrPageUpdate } from '../context/WrPageContext';
|
|
7
|
+
import { useWrMessage } from '../hooks/useWrMessage';
|
|
8
|
+
import { wrSavePage } from '../save';
|
|
9
|
+
/** In the editor nothing is sent: after a test send the form stays on its confirmation (where it can be edited) until its "Back to the form" button is pressed (see `WrFormSuccess`). Altcha runs with a mock challenge. */
|
|
10
|
+
const SIMULATED = { mock: true, send: async () => null };
|
|
11
|
+
export function WrForm(props) {
|
|
12
|
+
const { id } = props;
|
|
13
|
+
const config = useWrPage(id);
|
|
14
|
+
const updateConfig = useWrPageUpdate();
|
|
15
|
+
const pageName = useWrPageMeta();
|
|
16
|
+
const { lang } = useWrApp();
|
|
17
|
+
useWrMessage('wr:form:update', id, async (msg) => {
|
|
18
|
+
const patch = { ...(msg.hidden !== undefined ? { hidden: msg.hidden } : {}) };
|
|
19
|
+
for (const code of WR_FORM_MESSAGE_CODES) {
|
|
20
|
+
const key = `msg-${code}`;
|
|
21
|
+
if (msg[key] !== undefined)
|
|
22
|
+
patch[key] = wrSetLocalized(config?.[key], lang, msg[key]);
|
|
23
|
+
}
|
|
24
|
+
updateConfig(id, patch);
|
|
25
|
+
await wrSavePage(pageName, id, { ...config, ...patch });
|
|
26
|
+
});
|
|
27
|
+
return _jsx(WrFormView, { ...props, lang: lang, config: config, transport: SIMULATED });
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=WrForm.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { WrFormPrivacyView } from '@webround/core/form-react';
|
|
3
|
+
import { wrInteractive } from '../interactive';
|
|
4
|
+
export function WrFormPrivacy(props) {
|
|
5
|
+
return _jsx(WrFormPrivacyView, { ...props, rootProps: wrInteractive });
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=WrFormPrivacy.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { WrFormSuccessView, useWrForm } from '@webround/core/form-react';
|
|
3
|
+
// Only in the editor: the form sends nothing, so after a test send it stays on this confirmation (where it can be written and styled) until this button is pressed.
|
|
4
|
+
const BACK_STYLE = {
|
|
5
|
+
display: 'block', margin: '0.75rem auto 0', padding: '0.25rem 0.75rem', borderRadius: '9999px', border: 'none', cursor: 'pointer',
|
|
6
|
+
fontSize: '12px', fontWeight: 600, background: 'var(--wr-accent, #4f46e5)', color: 'var(--wr-on-accent, #fff)',
|
|
7
|
+
};
|
|
8
|
+
export function WrFormSuccess(props) {
|
|
9
|
+
const form = useWrForm();
|
|
10
|
+
return (_jsxs(WrFormSuccessView, { ...props, children: [props.children, _jsx("button", { type: "button", "data-wr-editor-ui": true, style: BACK_STYLE, onClick: () => form?.reset(), children: "Back to the form" })] }));
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=WrFormSuccess.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface WrIframeOwnProps {
|
|
3
|
+
id: string;
|
|
4
|
+
}
|
|
5
|
+
type WrIframeProps = WrIframeOwnProps & Omit<React.ComponentPropsWithoutRef<'iframe'>, 'id'>;
|
|
6
|
+
/**
|
|
7
|
+
* Same props and same element as the core's WrIframe. It is interactive (see interactive.ts): the page inside takes the clicks, as it
|
|
8
|
+
* does on the site, and the iframe is selected from the handle that appears when the pointer is over it, like a link.
|
|
9
|
+
*/
|
|
10
|
+
export declare function WrIframe({ id, loading, ...props }: WrIframeProps): React.ReactElement;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=WrIframe.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { wrAriaLabel, wrSetLocalized } from '@webround/core/localized';
|
|
3
|
+
import { useWrApp } from '../context/WrAppContext';
|
|
4
|
+
import { useWrPage, useWrPageMeta, useWrPageUpdate } from '../context/WrPageContext';
|
|
5
|
+
import { useWrMessage } from '../hooks/useWrMessage';
|
|
6
|
+
import { wrSavePage } from '../save';
|
|
7
|
+
import { wrInteractive } from '../interactive';
|
|
8
|
+
/**
|
|
9
|
+
* Same props and same element as the core's WrIframe. It is interactive (see interactive.ts): the page inside takes the clicks, as it
|
|
10
|
+
* does on the site, and the iframe is selected from the handle that appears when the pointer is over it, like a link.
|
|
11
|
+
*/
|
|
12
|
+
export function WrIframe({ id, loading = 'lazy', ...props }) {
|
|
13
|
+
const config = useWrPage(id);
|
|
14
|
+
const updateConfig = useWrPageUpdate();
|
|
15
|
+
const pageName = useWrPageMeta();
|
|
16
|
+
const { lang } = useWrApp();
|
|
17
|
+
const ariaLabel = wrAriaLabel(config, props['aria-label'], lang);
|
|
18
|
+
useWrMessage('wr:iframe:update', id, async (msg) => {
|
|
19
|
+
const patch = {
|
|
20
|
+
...(msg.ariaLabel !== undefined ? { ariaLabel: wrSetLocalized(config?.ariaLabel, lang, msg.ariaLabel) } : {}),
|
|
21
|
+
...(msg.hidden !== undefined ? { hidden: msg.hidden } : {}),
|
|
22
|
+
};
|
|
23
|
+
updateConfig(id, patch);
|
|
24
|
+
await wrSavePage(pageName, id, { ...config, ...patch });
|
|
25
|
+
});
|
|
26
|
+
if (config?.hidden)
|
|
27
|
+
return _jsx(_Fragment, {});
|
|
28
|
+
return (_jsx("iframe", { loading: loading, "data-wr-id": id, "data-wr-type": "iframe", ...wrInteractive, ...props, "aria-label": ariaLabel }));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=WrIframe.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface WrImageOwnProps {
|
|
3
|
+
id: string;
|
|
4
|
+
objectFit?: React.CSSProperties['objectFit'];
|
|
5
|
+
}
|
|
6
|
+
type WrImageProps = WrImageOwnProps & Omit<React.ComponentPropsWithoutRef<'img'>, 'id'>;
|
|
7
|
+
export declare function WrImage({ id, objectFit, style, alt: codeAlt, ...props }: WrImageProps): React.ReactElement;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=WrImage.d.ts.map
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { wrAriaLabel, wrLocalized, wrSetLocalized } from '@webround/core/localized';
|
|
3
|
+
import { useWrPage, useWrPageMeta, useWrPageUpdate } from '../context/WrPageContext';
|
|
4
|
+
import { useWrApp } from '../context/WrAppContext';
|
|
5
|
+
import { useWrMessage } from '../hooks/useWrMessage';
|
|
6
|
+
import { wrSavePage } from '../save';
|
|
7
|
+
export function WrImage({ id, objectFit, style, alt: codeAlt, ...props }) {
|
|
8
|
+
const config = useWrPage(id);
|
|
9
|
+
const updateConfig = useWrPageUpdate();
|
|
10
|
+
const pageName = useWrPageMeta();
|
|
11
|
+
const { lang } = useWrApp();
|
|
12
|
+
const rawAlt = config?.alt;
|
|
13
|
+
const ariaLabel = wrAriaLabel(config, props['aria-label'], lang);
|
|
14
|
+
useWrMessage('wr:image:update', id, async (msg) => {
|
|
15
|
+
const newAlt = msg.alt !== undefined ? wrSetLocalized(rawAlt, lang, msg.alt) : (rawAlt ?? {});
|
|
16
|
+
const patch = {
|
|
17
|
+
alt: newAlt,
|
|
18
|
+
...(msg.ariaLabel !== undefined ? { ariaLabel: wrSetLocalized(config?.ariaLabel, lang, msg.ariaLabel) } : {}),
|
|
19
|
+
...(msg.hidden !== undefined ? { hidden: msg.hidden } : {}),
|
|
20
|
+
};
|
|
21
|
+
updateConfig(id, patch);
|
|
22
|
+
await wrSavePage(pageName, id, { ...config, ...patch });
|
|
23
|
+
});
|
|
24
|
+
if (config?.hidden)
|
|
25
|
+
return _jsx(_Fragment, {});
|
|
26
|
+
return (_jsx("img", { alt: wrLocalized(rawAlt, lang) ?? codeAlt ?? '', "data-wr-id": id, "data-wr-type": "image", style: { objectFit, ...style }, ...props, "aria-label": ariaLabel }));
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=WrImage.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type WrInputViewProps } from '@webround/core/form-react';
|
|
3
|
+
type WrInputProps = Omit<WrInputViewProps, 'lang' | 'config' | 'type' | 'rootProps'> & {
|
|
4
|
+
type?: WrInputViewProps['type'];
|
|
5
|
+
};
|
|
6
|
+
export declare function WrInput({ type, ...props }: WrInputProps): React.ReactElement | null;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=WrInput.d.ts.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { wrAriaLabel, wrSetLocalized } from '@webround/core/localized';
|
|
3
|
+
import { WrInputView } from '@webround/core/form-react';
|
|
4
|
+
import { useWrApp } from '../context/WrAppContext';
|
|
5
|
+
import { useWrPage, useWrPageMeta, useWrPageUpdate } from '../context/WrPageContext';
|
|
6
|
+
import { useWrMessage } from '../hooks/useWrMessage';
|
|
7
|
+
import { wrInteractive } from '../interactive';
|
|
8
|
+
import { wrSavePage } from '../save';
|
|
9
|
+
// Typing into it works in the preview (that is how a form is tried); it is selected from its handle, as a link or a button is.
|
|
10
|
+
export function WrInput({ type = 'text', ...props }) {
|
|
11
|
+
const { id } = props;
|
|
12
|
+
const config = useWrPage(id);
|
|
13
|
+
const updateConfig = useWrPageUpdate();
|
|
14
|
+
const pageName = useWrPageMeta();
|
|
15
|
+
const { lang } = useWrApp();
|
|
16
|
+
useWrMessage('wr:input:update', id, async (msg) => {
|
|
17
|
+
const patch = {
|
|
18
|
+
...(msg.label !== undefined ? { label: wrSetLocalized(config?.label, lang, msg.label) } : {}),
|
|
19
|
+
...(msg.placeholder !== undefined ? { placeholder: wrSetLocalized(config?.placeholder, lang, msg.placeholder) } : {}),
|
|
20
|
+
...(msg.ariaLabel !== undefined ? { ariaLabel: wrSetLocalized(config?.ariaLabel, lang, msg.ariaLabel) } : {}),
|
|
21
|
+
...(msg.hidden !== undefined ? { hidden: msg.hidden } : {}),
|
|
22
|
+
};
|
|
23
|
+
updateConfig(id, patch);
|
|
24
|
+
await wrSavePage(pageName, id, { ...config, ...patch });
|
|
25
|
+
});
|
|
26
|
+
const view = config && { ...config, ariaLabel: wrAriaLabel(config, undefined, lang) };
|
|
27
|
+
return _jsx(WrInputView, { ...props, type: type, lang: lang, config: view, rootProps: wrInteractive });
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=WrInput.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface WrLinkOwnProps {
|
|
3
|
+
id: string;
|
|
4
|
+
href?: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
}
|
|
7
|
+
type WrLinkProps = WrLinkOwnProps & Omit<React.ComponentPropsWithoutRef<'a'>, 'id'>;
|
|
8
|
+
export declare function WrLink({ id, href, children, target, rel, ...props }: WrLinkProps): React.ReactElement;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=WrLink.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { wrAriaLabel, wrLocalized, wrSetLocalized } from '@webround/core/localized';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { useWrPage, useWrPageUpdate, useWrPageMeta } from '../context/WrPageContext';
|
|
5
|
+
import { useWrApp } from '../context/WrAppContext';
|
|
6
|
+
import { useWrMessage } from '../hooks/useWrMessage';
|
|
7
|
+
import { wrSavePage } from '../save';
|
|
8
|
+
import { wrIsExternalHref, wrLocalizeHref } from '@webround/core/routing';
|
|
9
|
+
import { wrInteractive } from '../interactive';
|
|
10
|
+
export function WrLink({ id, href = '#', children, target, rel, ...props }) {
|
|
11
|
+
const config = useWrPage(id);
|
|
12
|
+
const updateConfig = useWrPageUpdate();
|
|
13
|
+
const pageName = useWrPageMeta();
|
|
14
|
+
const { lang } = useWrApp();
|
|
15
|
+
const rawContent = config?.content;
|
|
16
|
+
const content = rawContent !== undefined ? (wrLocalized(rawContent, lang) ?? '') : undefined;
|
|
17
|
+
const inner = content !== undefined ? _jsx("span", { dangerouslySetInnerHTML: { __html: content } }) : children;
|
|
18
|
+
const ariaLabel = wrAriaLabel(config, props['aria-label'], lang);
|
|
19
|
+
useWrMessage('wr:link:update', id, async (msg) => {
|
|
20
|
+
const mergedContent = msg.content !== undefined ? wrSetLocalized(rawContent, lang, msg.content) : rawContent;
|
|
21
|
+
const patch = {
|
|
22
|
+
content: mergedContent ?? { default: '' },
|
|
23
|
+
...(msg.ariaLabel !== undefined ? { ariaLabel: wrSetLocalized(config?.ariaLabel, lang, msg.ariaLabel) } : {}),
|
|
24
|
+
...(msg.hidden !== undefined ? { hidden: msg.hidden } : {}),
|
|
25
|
+
};
|
|
26
|
+
updateConfig(id, patch);
|
|
27
|
+
await wrSavePage(pageName, id, { ...config, ...patch });
|
|
28
|
+
});
|
|
29
|
+
if (config?.hidden)
|
|
30
|
+
return _jsx(_Fragment, {});
|
|
31
|
+
// An address of the site is a router `Link` and nothing else (a `target` it was given is not used); only one that leaves the site is an `<a>`
|
|
32
|
+
const external = wrIsExternalHref(href);
|
|
33
|
+
if (external) {
|
|
34
|
+
return (_jsx("a", { href: href, target: target, rel: rel, "data-wr-id": id, "data-wr-type": "link", ...wrInteractive, ...props, "aria-label": ariaLabel, children: inner }));
|
|
35
|
+
}
|
|
36
|
+
return (_jsx(Link, { to: wrLocalizeHref(href, lang), "data-wr-id": id, "data-wr-type": "link", ...wrInteractive, ...props, "aria-label": ariaLabel, children: inner }));
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=WrLink.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { WrNavItem } from '@webround/core/types';
|
|
3
|
+
interface WrNavOwnProps {
|
|
4
|
+
id: string;
|
|
5
|
+
/** What the menu draws: its items, the language, and what the nav was asked to show besides (`accountMenu`: the visitor's account in the header; `cartMenu`: their cart; the site draws both: this package knows nothing of customers). */
|
|
6
|
+
children: (items: WrNavItem[], lang: string, options: WrNavOptions) => React.ReactNode;
|
|
7
|
+
/** The button that switches the site between its light and dark theme (it shows only if the site has a dark theme). */
|
|
8
|
+
themeToggle?: boolean;
|
|
9
|
+
/** The visitor's account in the header (an icon with a sign-in or its shortcuts): the site draws it, this only says whether it is asked for. */
|
|
10
|
+
accountMenu?: boolean;
|
|
11
|
+
/** The visitor's cart in the header (an icon with how many things are in it): the site draws it, this only says whether it is asked for. */
|
|
12
|
+
cartMenu?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* What the nav was asked to show, given to what draws the menu. `ariaLabel` is the name of the menu in the language shown (the editor's, or the `aria-label` written in the code): it goes on the `<nav>` that the
|
|
16
|
+
* menu draws, because on this box (a `div`) a name is ignored by screen readers.
|
|
17
|
+
*/
|
|
18
|
+
export interface WrNavOptions {
|
|
19
|
+
accountMenu: boolean;
|
|
20
|
+
cartMenu: boolean;
|
|
21
|
+
ariaLabel: string | undefined;
|
|
22
|
+
}
|
|
23
|
+
type WrNavProps = WrNavOwnProps & Omit<React.HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
24
|
+
export declare function WrNav({ id, children, themeToggle, accountMenu, cartMenu, ...props }: WrNavProps): React.ReactElement;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=WrNav.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { wrAriaLabel, wrSetLocalized } from '@webround/core/localized';
|
|
3
|
+
import { useWrApp } from '../context/WrAppContext';
|
|
4
|
+
import { useWrMessage } from '../hooks/useWrMessage';
|
|
5
|
+
import { wrSavePage } from '../save';
|
|
6
|
+
import { useWrPage, useWrPageMeta, useWrPageUpdate } from '../context/WrPageContext';
|
|
7
|
+
import { wrLocalizeHref } from '@webround/core/routing';
|
|
8
|
+
import { WrThemeToggle } from '@webround/core/theme-toggle';
|
|
9
|
+
export function WrNav({ id, children, themeToggle, accountMenu, cartMenu, ...props }) {
|
|
10
|
+
const config = useWrPage(id);
|
|
11
|
+
const updateConfig = useWrPageUpdate();
|
|
12
|
+
const pageName = useWrPageMeta();
|
|
13
|
+
const { lang } = useWrApp();
|
|
14
|
+
const items = config?.items ?? [];
|
|
15
|
+
const ariaLabel = wrAriaLabel(config, props['aria-label'], lang);
|
|
16
|
+
const localizedItems = items.map((item) => ({ ...item, href: wrLocalizeHref(item.href, lang) }));
|
|
17
|
+
useWrMessage('wr:nav:update', id, async (msg) => {
|
|
18
|
+
const patch = {
|
|
19
|
+
items: msg.items,
|
|
20
|
+
...(msg.ariaLabel !== undefined ? { ariaLabel: wrSetLocalized(config?.ariaLabel, lang, msg.ariaLabel) } : {}),
|
|
21
|
+
...(msg.hidden !== undefined ? { hidden: msg.hidden } : {}),
|
|
22
|
+
};
|
|
23
|
+
updateConfig(id, patch);
|
|
24
|
+
await wrSavePage(pageName, id, { ...config, ...patch });
|
|
25
|
+
});
|
|
26
|
+
if (config?.hidden)
|
|
27
|
+
return _jsx(_Fragment, {});
|
|
28
|
+
return (_jsxs("div", { "data-wr-id": id, "data-wr-type": "nav", ...props, "aria-label": undefined, children: [children(localizedItems, lang, { accountMenu: accountMenu === true, cartMenu: cartMenu === true, ariaLabel }), themeToggle && _jsx(WrThemeToggle, {})] }));
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=WrNav.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WrSectionTag } from '@webround/core/kinds';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface WrSectionOwnProps {
|
|
4
|
+
id: string;
|
|
5
|
+
tag?: WrSectionTag;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
type WrSectionProps = WrSectionOwnProps & Omit<React.HTMLAttributes<HTMLElement>, 'id'>;
|
|
9
|
+
export declare function WrSection({ id, tag: Tag, children, ...props }: WrSectionProps): React.ReactElement;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=WrSection.d.ts.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function WrSection({ id, tag: Tag = 'section', children, ...props }) {
|
|
3
|
+
return (_jsx(Tag, { "data-wr-id": id, "data-wr-type": "section", ...props, children: children }));
|
|
4
|
+
}
|
|
5
|
+
//# sourceMappingURL=WrSection.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* The root of a shared component (same API and same output as the core's, plus the scope for the editor): what is inside reads and writes
|
|
4
|
+
* the component's own JSON (`config/pages/_shared/<name>.json`) and the editor writes its code in the component's file, whatever page it is
|
|
5
|
+
* on. It is a `display: contents` box that carries the scope: it draws nothing. A component the site has not declared in `config/shared.json`
|
|
6
|
+
* cannot be edited from here: it is said, and what is inside is shown as it is.
|
|
7
|
+
*/
|
|
8
|
+
export declare function WrShared({ name, children }: {
|
|
9
|
+
name: string;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=WrShared.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { wrSharedName } from '@webround/core/routing';
|
|
3
|
+
import { WrScopeProvider } from '../context/WrPageContext';
|
|
4
|
+
import { useWrSharedScopes } from '../context/WrAppContext';
|
|
5
|
+
import { wrScopeProps } from '../scope';
|
|
6
|
+
/**
|
|
7
|
+
* The root of a shared component (same API and same output as the core's, plus the scope for the editor): what is inside reads and writes
|
|
8
|
+
* the component's own JSON (`config/pages/_shared/<name>.json`) and the editor writes its code in the component's file, whatever page it is
|
|
9
|
+
* on. It is a `display: contents` box that carries the scope: it draws nothing. A component the site has not declared in `config/shared.json`
|
|
10
|
+
* cannot be edited from here: it is said, and what is inside is shown as it is.
|
|
11
|
+
*/
|
|
12
|
+
export function WrShared({ name, children }) {
|
|
13
|
+
const scope = useWrSharedScopes().find(candidate => candidate.name === wrSharedName(name));
|
|
14
|
+
if (!scope) {
|
|
15
|
+
console.warn(`[wr] WrShared "${name}" is not declared in src/config/shared.json: its elements cannot be edited`);
|
|
16
|
+
return _jsx(_Fragment, { children: children });
|
|
17
|
+
}
|
|
18
|
+
return (_jsx("div", { style: { display: 'contents' }, ...wrScopeProps(scope), children: _jsx(WrScopeProvider, { config: {}, pageName: scope.name, children: children }) }));
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=WrShared.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { WrTextTag } from '@webround/core/kinds';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface WrTextOwnProps {
|
|
4
|
+
id: string;
|
|
5
|
+
tag?: WrTextTag;
|
|
6
|
+
html?: string;
|
|
7
|
+
}
|
|
8
|
+
type WrTextProps = WrTextOwnProps & Omit<React.HTMLAttributes<HTMLElement>, 'id' | 'dangerouslySetInnerHTML'>;
|
|
9
|
+
export declare function WrText({ id, tag, html: fallback, ...props }: WrTextProps): React.JSX.Element;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=WrText.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { WrTextView } from '@webround/core/text-react';
|
|
3
|
+
import { wrLocalized, wrSetLocalized } from '@webround/core/localized';
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
import { useWrPage, useWrPageUpdate, useWrPageMeta } from '../context/WrPageContext';
|
|
6
|
+
import { useWrApp } from '../context/WrAppContext';
|
|
7
|
+
import { wrSavePage } from '../save';
|
|
8
|
+
function isEmptyHtml(html) {
|
|
9
|
+
return html.replace(/<[^>]*>/g, '').trim().length === 0;
|
|
10
|
+
}
|
|
11
|
+
const PLACEHOLDER_HTML = '<span style="opacity:0.4">Type something...</span>';
|
|
12
|
+
export function WrText({ id, tag, html: fallback = '', ...props }) {
|
|
13
|
+
const config = useWrPage(id);
|
|
14
|
+
const [editing, setEditing] = useState(false);
|
|
15
|
+
const [Editor, setEditor] = useState(null);
|
|
16
|
+
const { lang } = useWrApp();
|
|
17
|
+
const updateConfig = useWrPageUpdate();
|
|
18
|
+
const pageName = useWrPageMeta();
|
|
19
|
+
const rawContent = config?.content;
|
|
20
|
+
const content = (wrLocalized(rawContent, lang) ?? fallback);
|
|
21
|
+
const empty = isEmptyHtml(content);
|
|
22
|
+
const handleClick = async () => {
|
|
23
|
+
if (!Editor) {
|
|
24
|
+
const mod = await import('./text-editor/WrTextEditor');
|
|
25
|
+
setEditor(() => mod.WrTextEditor);
|
|
26
|
+
}
|
|
27
|
+
setEditing(true);
|
|
28
|
+
};
|
|
29
|
+
if (editing && Editor) {
|
|
30
|
+
return (_jsx(Editor, { editorPathKey: id, initialHtml: empty ? '' : content, style: props.style, className: props.className, onSave: async (html) => {
|
|
31
|
+
const newContent = wrSetLocalized(rawContent, lang, html);
|
|
32
|
+
const value = { content: newContent };
|
|
33
|
+
updateConfig(id, value);
|
|
34
|
+
await wrSavePage(pageName, id, value);
|
|
35
|
+
setEditing(false);
|
|
36
|
+
}, onCancel: () => setEditing(false) }));
|
|
37
|
+
}
|
|
38
|
+
// In the editor a text is written by clicking it: the cursor says so (on the published site it does not, a text there is only read)
|
|
39
|
+
return _jsx(WrTextView, { ...props, style: { cursor: 'text', ...props.style }, id: id, tag: tag, html: empty ? PLACEHOLDER_HTML : content, onClick: handleClick });
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=WrText.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface WrVideoOwnProps {
|
|
3
|
+
id: string;
|
|
4
|
+
src?: string;
|
|
5
|
+
}
|
|
6
|
+
type WrVideoProps = WrVideoOwnProps & Omit<React.ComponentPropsWithoutRef<'video'>, 'id'>;
|
|
7
|
+
export declare function WrVideo({ id, src, autoPlay, muted, loop, controls, style, ...props }: WrVideoProps): React.ReactElement;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=WrVideo.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { wrAriaLabel, wrSetLocalized } from '@webround/core/localized';
|
|
3
|
+
import { useWrApp } from '../context/WrAppContext';
|
|
4
|
+
import { useEffect, useRef } from 'react';
|
|
5
|
+
import { useWrPage, useWrPageMeta, useWrPageUpdate } from '../context/WrPageContext';
|
|
6
|
+
import { useWrMessage } from '../hooks/useWrMessage';
|
|
7
|
+
import { wrSavePage } from '../save';
|
|
8
|
+
function isHlsSrc(src) {
|
|
9
|
+
return src.endsWith('.m3u8') || src.includes('.m3u8?');
|
|
10
|
+
}
|
|
11
|
+
export function WrVideo({ id, src, autoPlay = false, muted = false, loop = false, controls = false, style, ...props }) {
|
|
12
|
+
const config = useWrPage(id);
|
|
13
|
+
const { lang } = useWrApp();
|
|
14
|
+
const ariaLabel = wrAriaLabel(config, props['aria-label'], lang);
|
|
15
|
+
const updateConfig = useWrPageUpdate();
|
|
16
|
+
const pageName = useWrPageMeta();
|
|
17
|
+
const videoRef = useRef(null);
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
const video = videoRef.current;
|
|
20
|
+
if (!video || !src)
|
|
21
|
+
return;
|
|
22
|
+
const onEnded = () => {
|
|
23
|
+
if (loop) {
|
|
24
|
+
video.currentTime = 0;
|
|
25
|
+
video.play().catch(() => { });
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
video.addEventListener('ended', onEnded);
|
|
29
|
+
let hlsInstance = null;
|
|
30
|
+
let cancelled = false;
|
|
31
|
+
if (isHlsSrc(src)) {
|
|
32
|
+
import('hls.js').then(({ default: Hls }) => {
|
|
33
|
+
if (cancelled || !video)
|
|
34
|
+
return;
|
|
35
|
+
if (Hls.isSupported()) {
|
|
36
|
+
const hls = new Hls({ enableWorker: true });
|
|
37
|
+
hlsInstance = hls;
|
|
38
|
+
hls.loadSource(src);
|
|
39
|
+
hls.attachMedia(video);
|
|
40
|
+
hls.on(Hls.Events.MANIFEST_PARSED, () => { if (autoPlay)
|
|
41
|
+
video.play().catch(() => { }); });
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
video.src = src;
|
|
45
|
+
if (autoPlay)
|
|
46
|
+
video.play().catch(() => { });
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
video.src = src;
|
|
52
|
+
if (autoPlay)
|
|
53
|
+
video.play().catch(() => { });
|
|
54
|
+
}
|
|
55
|
+
return () => {
|
|
56
|
+
cancelled = true;
|
|
57
|
+
hlsInstance?.destroy();
|
|
58
|
+
video.removeEventListener('ended', onEnded);
|
|
59
|
+
};
|
|
60
|
+
}, [src, autoPlay, loop]);
|
|
61
|
+
useWrMessage('wr:video:update', id, async (msg) => {
|
|
62
|
+
const patch = {
|
|
63
|
+
...(msg.ariaLabel !== undefined ? { ariaLabel: wrSetLocalized(config?.ariaLabel, lang, msg.ariaLabel) } : {}),
|
|
64
|
+
...(msg.hidden !== undefined ? { hidden: msg.hidden } : {}),
|
|
65
|
+
};
|
|
66
|
+
updateConfig(id, patch);
|
|
67
|
+
await wrSavePage(pageName, id, { ...config, ...patch });
|
|
68
|
+
});
|
|
69
|
+
if (config?.hidden)
|
|
70
|
+
return _jsx(_Fragment, {});
|
|
71
|
+
return (_jsx("video", { ref: videoRef, ...props, muted: muted, controls: controls, "aria-label": ariaLabel, "data-wr-id": id, "data-wr-type": "video", style: style }));
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=WrVideo.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function CodeThemeProvider({ children }: {
|
|
2
|
+
children: React.ReactNode;
|
|
3
|
+
}): import("react").JSX.Element;
|
|
4
|
+
export declare const useCodeTheme: () => {
|
|
5
|
+
theme: "vs-dark" | "light";
|
|
6
|
+
toggle: () => void;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=CodeThemeContext.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext, useState } from "react";
|
|
3
|
+
const CodeThemeContext = createContext({ theme: "vs-dark", toggle: () => { } });
|
|
4
|
+
export function CodeThemeProvider({ children }) {
|
|
5
|
+
const [theme, setTheme] = useState("vs-dark");
|
|
6
|
+
const toggle = () => setTheme(t => t === "vs-dark" ? "light" : "vs-dark");
|
|
7
|
+
return (_jsx(CodeThemeContext.Provider, { value: { theme, toggle }, children: children }));
|
|
8
|
+
}
|
|
9
|
+
export const useCodeTheme = () => useContext(CodeThemeContext);
|
|
10
|
+
//# sourceMappingURL=CodeThemeContext.js.map
|