Fix lot of eslint problems
This commit is contained in:
parent
5b9a0e6b34
commit
8b11c71384
17 changed files with 52 additions and 108 deletions
|
@ -95,17 +95,17 @@ export function Container(props: IContainerProps): JSX.Element {
|
|||
);
|
||||
}
|
||||
|
||||
function CreateReactCustomSVG(customSVG: string, props: IContainerProperties): React.ReactNode {
|
||||
function CreateReactCustomSVG(customSVG: string, properties: IContainerProperties): React.ReactNode {
|
||||
return <Interweave
|
||||
tagName='g'
|
||||
disableLineBreaks={true}
|
||||
content={customSVG}
|
||||
allowElements={true}
|
||||
transform={(node, children) => Transform(node, children, props)}
|
||||
transform={(node, children) => Transform(node, children, properties)}
|
||||
/>;
|
||||
}
|
||||
|
||||
function Transform(node: HTMLElement, children: Node[], props: IContainerProperties): React.ReactNode {
|
||||
function Transform(node: HTMLElement, children: Node[], properties: IContainerProperties): React.ReactNode {
|
||||
const supportedTags = ['line', 'path', 'rect'];
|
||||
if (supportedTags.includes(node.tagName.toLowerCase())) {
|
||||
const attributes: { [att: string]: string | object | null } = {};
|
||||
|
@ -118,13 +118,14 @@ function Transform(node: HTMLElement, children: Node[], props: IContainerPropert
|
|||
|
||||
if (attributeValue.startsWith('{userData.') && attributeValue.endsWith('}')) {
|
||||
// support for userData
|
||||
if (props.userData === undefined) {
|
||||
const userData = properties.userData;
|
||||
if (userData === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const userDataKey = attributeValue.replace(/userData\./, '');
|
||||
|
||||
const prop = Object.entries(props.userData).find(([key]) => `{${key}}` === userDataKey);
|
||||
const prop = Object.entries(userData).find(([key]) => `{${key}}` === userDataKey);
|
||||
if (prop !== undefined) {
|
||||
attributes[Camelize(attName)] = prop[1];
|
||||
return;
|
||||
|
@ -139,7 +140,7 @@ function Transform(node: HTMLElement, children: Node[], props: IContainerPropert
|
|||
return;
|
||||
}
|
||||
|
||||
const prop = Object.entries(props).find(([key]) => `{${key}}` === attributeValue);
|
||||
const prop = Object.entries(properties).find(([key]) => `{${key}}` === attributeValue);
|
||||
if (prop !== undefined) {
|
||||
attributes[Camelize(attName)] = prop[1];
|
||||
return;
|
||||
|
|
|
@ -26,6 +26,7 @@ export const ID = 'svg';
|
|||
|
||||
export function SVG(props: ISVGProps): JSX.Element {
|
||||
const [tool, setTool] = React.useState<Tool>(TOOL_PAN);
|
||||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
||||
const [value, setValue] = React.useState<Value>({} as Value);
|
||||
const [scale, setScale] = React.useState<number>(value.a ?? 1);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue