Skip to content

Fix(#7401, #7415): resolve visual editing issues #7405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
'decap-cms-widget-object': '<rootDir>/packages/decap-cms-widget-object/src/index.js',
'\\.(css|less)$': '<rootDir>/__mocks__/styleMock.js',
},
modulePathIgnorePatterns: ['.nx', 'dist'],
snapshotSerializers: ['@emotion/jest/serializer'],
transformIgnorePatterns: [
'node_modules/(?!copy-text-to-clipboard|clean-stack|escape-string-regexp)',
Expand Down
1 change: 1 addition & 0 deletions packages/decap-cms-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ declare module 'decap-cms-core' {
hide?: boolean;
editor?: {
preview?: boolean;
visualEditing?: boolean;
};
publish?: boolean;
nested?: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
import Frame, { FrameContextConsumer } from 'react-frame-component';
import { lengths } from 'decap-cms-ui-default';
import { connect } from 'react-redux';
import { encodeEntry } from 'decap-cms-lib-util/src/stega';

import { encodeEntry } from '../../../lib/stega';
import {
resolveWidget,
getPreviewTemplate,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { vercelStegaEncode } from '@vercel/stega';

import { isImmutableMap, isImmutableList } from './types';
import { isImmutableMap, isImmutableList } from 'decap-cms-lib-util/src/types';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again, I think this will actually have a similar issue. In general, I don't think we should ever use imports that directly reach into <package>/src/.

Possible fixes...

  • import { ... } from 'decap-cms-lib-util/dist/esm/types'
  • re-export these methods in decap-cms-lib-util/src/index.ts and import { ... } from 'decap-cms-lib-util'
  • move these isImmutable* methods into decap-cms-core, as they aren't used anywhere else currently

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, good catch! I moved the type guards to types/immutable.ts in the core package – a file which was already there. I think this is a good fit.


import type { Map as ImmutableMap, List } from 'immutable';
import type { CmsField } from 'decap-cms-core';
Expand Down
1 change: 1 addition & 0 deletions packages/decap-cms-core/src/types/redux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ export interface CmsCollection {
delete?: boolean;
editor?: {
preview?: boolean;
visualEditing?: boolean;
};
publish?: boolean;
nested?: {
Expand Down