@pptx-editor.dev/react 0.6.1-canary.20261119032858.sha-95106bb → 0.7.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/README.md +2 -2
- package/dist/index.d.ts +5 -5
- package/dist/index.js +18 -16
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ export function App({ bytes }: { bytes: Uint8Array }) {
|
|
|
35
35
|
}
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
To build your own chrome, use `usePptxEditor()`, `useEditorState(selector)`, and `useEditorCommand(slotId)`. As in DOCX Editor, `useEditorCommand(slotId).execute()` returns `true` when the engine ran the command and `false` on a refusal. `disabledReason` is
|
|
38
|
+
To build your own chrome, use `usePptxEditor()`, `useEditorState(selector)`, and `useEditorCommand(slotId)`. As in DOCX Editor, `useEditorCommand(slotId).execute()` returns `true` when the engine ran the command and `false` on a refusal. `disabledReason` is readable text in the locale of `PptxEditor.Root`: the hook translates catalog keys and keeps the engine's own text.
|
|
39
39
|
|
|
40
40
|
## Slides and layouts
|
|
41
41
|
|
|
@@ -77,7 +77,7 @@ Each slot takes the customization ladder: `className`, `icon`, `asChild`, `hidde
|
|
|
77
77
|
| `onChange` | `(layoutId: string) => void` | required | Called with the picked layout's id |
|
|
78
78
|
| `layouts` | `readonly SlideLayoutSummary[]` | every layout of the deck | The layouts to show |
|
|
79
79
|
| `disabled` | `boolean` | `true` in viewing mode | Shows the tiles but takes no pick |
|
|
80
|
-
| `disabledReason` | `string \| null` | the viewing reason | Why the gallery takes no pick, in the tiles' tooltips: a catalog key, such as `useEditorCommand(slotId).disabledReason
|
|
80
|
+
| `disabledReason` | `string \| null` | the viewing reason | Why the gallery takes no pick, in the tiles' tooltips: a catalog key or text, such as `useEditorCommand(slotId).disabledReason` |
|
|
81
81
|
| `className` | `string` | none | A class name added to the gallery |
|
|
82
82
|
|
|
83
83
|
```tsx
|
package/dist/index.d.ts
CHANGED
|
@@ -1599,8 +1599,8 @@ interface UseEditorCommandReturn {
|
|
|
1599
1599
|
/** Whether a toggle control shows as pressed. */
|
|
1600
1600
|
readonly isActive: boolean;
|
|
1601
1601
|
/**
|
|
1602
|
-
* Why the command cannot run
|
|
1603
|
-
*
|
|
1602
|
+
* Why the command cannot run, as readable text in the locale of `PptxEditor.Root`. A
|
|
1603
|
+
* catalog key is translated; the engine's own text shows as itself.
|
|
1604
1604
|
*/
|
|
1605
1605
|
readonly disabledReason: string | null;
|
|
1606
1606
|
/** The value a value control shows (a font size, a family), when it has one. */
|
|
@@ -1636,7 +1636,7 @@ interface UseEditorValueCommandReturn<V, S = V> {
|
|
|
1636
1636
|
readonly options: readonly V[];
|
|
1637
1637
|
/** Whether the command can run now. */
|
|
1638
1638
|
readonly isEnabled: boolean;
|
|
1639
|
-
/** Why the command cannot run
|
|
1639
|
+
/** Why the command cannot run, as readable text in the locale of `PptxEditor.Root`. */
|
|
1640
1640
|
readonly disabledReason: string | null;
|
|
1641
1641
|
}
|
|
1642
1642
|
/**
|
|
@@ -2798,8 +2798,8 @@ interface LayoutGalleryProps {
|
|
|
2798
2798
|
/** Show the tiles but take no pick. Default: true while the deck is open for viewing. */
|
|
2799
2799
|
readonly disabled?: boolean;
|
|
2800
2800
|
/**
|
|
2801
|
-
* Why the gallery takes no pick, for the tiles' tooltips: a catalog key
|
|
2802
|
-
* `useEditorCommand(slotId).disabledReason`)
|
|
2801
|
+
* Why the gallery takes no pick, for the tiles' tooltips: a catalog key or text
|
|
2802
|
+
* (such as `useEditorCommand(slotId).disabledReason`). Default: the viewing reason.
|
|
2803
2803
|
*/
|
|
2804
2804
|
readonly disabledReason?: string | null;
|
|
2805
2805
|
}
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
platformShortcuts,
|
|
56
56
|
runToolbarCommand,
|
|
57
57
|
sameChromeCommandState,
|
|
58
|
+
translateKeyOrText,
|
|
58
59
|
valueSlotOptions,
|
|
59
60
|
valueSlotShown,
|
|
60
61
|
warnOutsideRoot
|
|
@@ -147,15 +148,17 @@ function useEditorCommand(slot) {
|
|
|
147
148
|
);
|
|
148
149
|
const notes = useNotesTarget(editor);
|
|
149
150
|
const format = NOTES_SLOTS[slot];
|
|
150
|
-
|
|
151
|
-
|
|
151
|
+
const { t } = useTranslation();
|
|
152
|
+
return useMemo(() => {
|
|
153
|
+
const state = notes && format ? {
|
|
152
154
|
execute: () => notes.apply(format),
|
|
153
155
|
isEnabled: !notes.readOnly && notes.canFormat,
|
|
154
156
|
isActive: notes.formats[format],
|
|
155
157
|
disabledReason: notes.readOnly ? "disabled.viewing" : notes.canFormat ? null : "disabled.selectNotesText"
|
|
156
|
-
} : engine
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
} : engine;
|
|
159
|
+
const reason = state.disabledReason ? translateKeyOrText(t, state.disabledReason) : null;
|
|
160
|
+
return reason === state.disabledReason ? state : { ...state, disabledReason: reason };
|
|
161
|
+
}, [notes, format, engine, t]);
|
|
159
162
|
}
|
|
160
163
|
function useOfferedControl(slot, control) {
|
|
161
164
|
const editor = usePptxEditor();
|
|
@@ -571,7 +574,7 @@ import {
|
|
|
571
574
|
panelItems,
|
|
572
575
|
placeSubmenu,
|
|
573
576
|
submenuPanelKey,
|
|
574
|
-
translateKeyOrText,
|
|
577
|
+
translateKeyOrText as translateKeyOrText2,
|
|
575
578
|
inFixedView,
|
|
576
579
|
placeInFixedFrame
|
|
577
580
|
} from "@pptx-editor.dev/core/editor";
|
|
@@ -709,7 +712,7 @@ function MenuSeparator() {
|
|
|
709
712
|
function MenuSubmenu(props) {
|
|
710
713
|
const { icon, paths, glyph, disabled, reason, className, children } = props;
|
|
711
714
|
const t = useContext4(TranslationContext);
|
|
712
|
-
const label = props.label ?? (props.labelKey ?
|
|
715
|
+
const label = props.label ?? (props.labelKey ? translateKeyOrText2(t, props.labelKey) : "");
|
|
713
716
|
const row = useRef3(null);
|
|
714
717
|
const panel = useRef3(null);
|
|
715
718
|
const [open, setOpen] = useState3(false);
|
|
@@ -799,12 +802,12 @@ function MenuSubmenu(props) {
|
|
|
799
802
|
}
|
|
800
803
|
|
|
801
804
|
// src/slot.ts
|
|
802
|
-
import { tooltipAttributes as tooltipAttributes3
|
|
805
|
+
import { tooltipAttributes as tooltipAttributes3 } from "@pptx-editor.dev/core/editor";
|
|
803
806
|
function useSlot(slot, control) {
|
|
804
807
|
const cmd = useEditorCommand(slot);
|
|
805
808
|
const { t } = useTranslation();
|
|
806
809
|
const label = t(control.labelKey);
|
|
807
|
-
const reason = cmd.disabledReason
|
|
810
|
+
const reason = cmd.disabledReason;
|
|
808
811
|
return { cmd, label, reason, tip: tooltipAttributes3(label, !cmd.isEnabled, reason) };
|
|
809
812
|
}
|
|
810
813
|
|
|
@@ -997,7 +1000,7 @@ import {
|
|
|
997
1000
|
localeContentKey,
|
|
998
1001
|
repaintSurfaceOf,
|
|
999
1002
|
reportFontError,
|
|
1000
|
-
translateKeyOrText as
|
|
1003
|
+
translateKeyOrText as translateKeyOrText20,
|
|
1001
1004
|
warnModulesChanged
|
|
1002
1005
|
} from "@pptx-editor.dev/core/editor";
|
|
1003
1006
|
|
|
@@ -7031,7 +7034,6 @@ import {
|
|
|
7031
7034
|
slideSorterMounted,
|
|
7032
7035
|
sorterKeyDown,
|
|
7033
7036
|
trackNotesInset,
|
|
7034
|
-
translateKeyOrText as translateKeyOrText20,
|
|
7035
7037
|
warnSlideSorterUnmounted
|
|
7036
7038
|
} from "@pptx-editor.dev/core/editor";
|
|
7037
7039
|
|
|
@@ -12984,7 +12986,7 @@ function ViewSwitch() {
|
|
|
12984
12986
|
const cmd = useEditorCommand("view.presentationView");
|
|
12985
12987
|
const options = STATUS_BAR_VIEW_OPTIONS;
|
|
12986
12988
|
const off = !cmd.isEnabled;
|
|
12987
|
-
const reason = cmd.disabledReason
|
|
12989
|
+
const reason = cmd.disabledReason;
|
|
12988
12990
|
const offAttrs = useAriaDisabled(off, reason);
|
|
12989
12991
|
const pick = (e, step) => {
|
|
12990
12992
|
if (off) return;
|
|
@@ -13163,7 +13165,7 @@ var PptxEditorRoot = forwardRef(
|
|
|
13163
13165
|
...props.readClipboardDrawing ? { readClipboardDrawing: props.readClipboardDrawing } : {},
|
|
13164
13166
|
...props.author ? { author: props.author } : {},
|
|
13165
13167
|
onFontError: (error) => reportFontError(error, callbacks.current.onFontError),
|
|
13166
|
-
translate: (key, params) =>
|
|
13168
|
+
translate: (key, params) => translateKeyOrText20(tRef.current, key, params)
|
|
13167
13169
|
});
|
|
13168
13170
|
createdFonts.current = props.fonts;
|
|
13169
13171
|
createdFamilies.current = props.fontFamilies;
|
|
@@ -13235,7 +13237,7 @@ function viewportLandmark(t, label) {
|
|
|
13235
13237
|
if (label === false) return {};
|
|
13236
13238
|
return {
|
|
13237
13239
|
role: "region",
|
|
13238
|
-
"aria-label": label ?
|
|
13240
|
+
"aria-label": label ? translateKeyOrText20(t, label) : t("viewport.ariaLabel")
|
|
13239
13241
|
};
|
|
13240
13242
|
}
|
|
13241
13243
|
function PptxEditorViewport({ className, label, children }) {
|
|
@@ -13621,7 +13623,7 @@ import {
|
|
|
13621
13623
|
ribbonInsertTab,
|
|
13622
13624
|
ribbonShownTab,
|
|
13623
13625
|
ribbonTabs,
|
|
13624
|
-
translateKeyOrText as
|
|
13626
|
+
translateKeyOrText as translateKeyOrText21,
|
|
13625
13627
|
warnRibbonChild
|
|
13626
13628
|
} from "@pptx-editor.dev/core/editor";
|
|
13627
13629
|
import { jsx as jsx66, jsxs as jsxs60 } from "react/jsx-runtime";
|
|
@@ -13664,7 +13666,7 @@ function Ribbon({
|
|
|
13664
13666
|
layout,
|
|
13665
13667
|
specs,
|
|
13666
13668
|
preset,
|
|
13667
|
-
(key) =>
|
|
13669
|
+
(key) => translateKeyOrText21(t, key),
|
|
13668
13670
|
"Ribbon.Tab"
|
|
13669
13671
|
);
|
|
13670
13672
|
const wanted = tab ?? own;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pptx-editor.dev/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "React adapter for PPTX Editor: a provider, hooks, and chrome compounds over the @pptx-editor.dev/core editor contract.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"api:check": "node ../../scripts/api-extractor.mjs --package @pptx-editor.dev/react"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@pptx-editor.dev/i18n": "0.
|
|
31
|
+
"@pptx-editor.dev/i18n": "^0.7.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@pptx-editor.dev/core": "0.
|
|
34
|
+
"@pptx-editor.dev/core": "~0.7.0",
|
|
35
35
|
"react": "^18.0.0 || ^19.0.0",
|
|
36
36
|
"react-dom": "^18.0.0 || ^19.0.0"
|
|
37
37
|
},
|