Skip to content

Commit

Permalink
Merge pull request #259 from enonic/next
Browse files Browse the repository at this point in the history
v0.8.5
  • Loading branch information
sigdestad authored May 10, 2022
2 parents 1ff53fb + 05d5bd3 commit a611e08
Show file tree
Hide file tree
Showing 8 changed files with 2,134 additions and 2,349 deletions.
1,334 changes: 657 additions & 677 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@
"lint": "npx next lint"
},
"dependencies": {
"html-react-parser": "^1.4.11",
"html-react-parser": "^1.4.12",
"next": "^12.1.5",
"node-html-parser": "^5.3.3",
"react": "18.0.0",
"react-dom": "18.0.0"
"react": "18.1.0",
"react-dom": "18.1.0"
},
"devDependencies": {
"@types/node": "^17.0.25",
"@types/node": "^17.0.31",
"@types/next": "^9.0.0",
"@types/react": "18.0.7",
"@types/react-dom": "^18.0.1",
"eslint": "8.14.0",
"eslint-config-next": "12.1.5",
"@types/react": "18.0.9",
"@types/react-dom": "^18.0.3",
"eslint": "8.15.0",
"eslint-config-next": "12.1.6",
"prettier": "^2.6.2",
"typescript": "4.6.3"
"typescript": "4.6.4"
}
}
2 changes: 1 addition & 1 deletion src/_enonicAdapter/guillotine/getMetaData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const COMPONENTS_QUERY = `
configAsJson
}
text {
value(processHtml:{type:absolute}) {
value(processHtml:{type:absolute, imageWidths:[400, 800, 1200], imageSizes:"(max-width: 400px) 400px, (max-width: 800px) 800px, 1200px"}) {
processedHtml
links {
ref
Expand Down
17 changes: 9 additions & 8 deletions src/_enonicAdapter/views/Region.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ export interface RegionsProps {
/** Single region */
export const RegionView = (props: RegionProps) => {
const {name, components, common, meta, className} = props;
const regionAttrs: { [key: string]: string } = {
id: name + "Region",
[PORTAL_REGION_ATTRIBUTE]: name,
};
const regionAttrs: { [key: string]: string } = {};

if (className) {
regionAttrs.className = className;
}
Expand All @@ -34,11 +32,14 @@ export const RegionView = (props: RegionProps) => {
<BaseComponent key={regionAttrs.id + "-" + i} component={component} common={common} meta={meta}/>
))

if (meta.renderMode === RENDER_MODE.LIVE) {
// do not make region wrappers in live mode
return (<>{children}</>)
} else {
if (meta.renderMode === RENDER_MODE.EDIT) {
regionAttrs.id = name + "Region";
regionAttrs[PORTAL_REGION_ATTRIBUTE] = name;
}
if (Object.keys(regionAttrs).length) {
return <div {...regionAttrs}>{children}</div>;
} else {
return <>{children}</>
}
}

Expand Down
17 changes: 17 additions & 0 deletions src/_enonicAdapter/views/RichTextView.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react"
import {RENDER_MODE} from '../utils';
import {RichTextProcessor, TextData} from '../RichTextProcessor';

type Props = {
data: TextData,
mode?: RENDER_MODE,
tag?: string,
}

const RichTextView = ({tag, mode, data}: Props) => {
const CustomTag = tag as keyof JSX.IntrinsicElements || 'section';
const customMode = mode || RENDER_MODE.NEXT;
return <CustomTag dangerouslySetInnerHTML={{__html: RichTextProcessor.process(data, customMode)}}/>
}

export default RichTextView;
5 changes: 3 additions & 2 deletions src/_enonicAdapter/views/Text.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react"
import {LinkData, RichTextProcessor} from '../RichTextProcessor';
import {LinkData} from '../RichTextProcessor';
import {MetaData} from '../guillotine/getMetaData';
import RichTextView from './RichTextView';

type Props = {
meta: MetaData,
Expand All @@ -15,7 +16,7 @@ type Props = {
const DefaultTextView = ({component, meta}: Props) => (
// temporary workaround for TextComponent expecting section inside of a root element
<div>
<section dangerouslySetInnerHTML={{__html: RichTextProcessor.process(component.value, meta.renderMode)}}/>
<RichTextView data={component.value} mode={meta.renderMode}/>
</div>
);

Expand Down
2 changes: 1 addition & 1 deletion src/components/parts/Heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface HeadingData {
}

const HeadingView = ({part, common}: HeadingData) => (
<h2>{part?.config?.heading || common.displayName}</h2>
<h2>{part?.config?.heading || common?.get?.displayName}</h2>
);

export default HeadingView;
Loading

0 comments on commit a611e08

Please sign in to comment.