Skip to content

Commit

Permalink
feat(editor): rewrite definitions to context
Browse files Browse the repository at this point in the history
  • Loading branch information
maarten2424 committed May 8, 2024
1 parent 4a37ec9 commit d6eb96c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,8 @@ function RichTextEditor(props: RichTextProps) {
event.preventDefault();

const nextSlateValue = convertRichTextElementsToEditorValue(
duplicateConfig(selectedRichTextComponentConfig, definitions).elements[
locale
]
duplicateConfig(selectedRichTextComponentConfig, { definitions })
.elements[locale]
);

const temporaryEditor = createTemporaryEditor(editor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function getRichTextComponentConfigFragment(

const { path, range } = parseFocusedRichTextPartConfigPath(focusedField);

const newTextPartConfig = duplicateConfig(textPartConfig, definitions);
const newTextPartConfig = duplicateConfig(textPartConfig, { definitions });

if (range) {
newTextPartConfig.value = textPartConfig.value.slice(...range);
Expand Down
12 changes: 8 additions & 4 deletions packages/editor/src/useCanvasGlobalKeyboardShortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ function useCanvasGlobalKeyboardShortcuts() {
if (!canHandleCopyPaste(focussedField, event)) {
return;
}
const configs = getConfigsToCopy(focussedField, formValues, definitions);
const configs = getConfigsToCopy(focussedField, formValues, {
definitions,
});

event.preventDefault();
event.clipboardData?.setData(
Expand All @@ -114,7 +116,9 @@ function useCanvasGlobalKeyboardShortcuts() {
return;
}

const configs = getConfigsToCopy(focussedField, formValues, definitions);
const configs = getConfigsToCopy(focussedField, formValues, {
definitions,
});

event.preventDefault();
event.clipboardData?.setData(
Expand Down Expand Up @@ -180,12 +184,12 @@ function isTargetHtmlElement(
function getConfigsToCopy(
paths: string[],
formValues: any,
definitions: AnyContextWithDefinitions
context: AnyContextWithDefinitions
) {
const sortedPaths = [...paths].sort(preOrderPathComparator("ascending"));
return sortedPaths.map((path) => {
const config = dotNotationGet(formValues, path);
return duplicateConfig(config, definitions);
return duplicateConfig(config, context);
});
}

Expand Down

0 comments on commit d6eb96c

Please sign in to comment.