Files
pwap/pezkuwi-sdk-ui/packages/react-components/src/Editor.tsx
T
pezkuwichain 971df8edba Rebrand: Remove 3rd party chains, update domains to PezkuwiChain
- Remove all 3rd party parachain configurations from endpoints:
  - productionRelayPolkadot.ts: Keep only system parachains
  - productionRelayDicle.ts: Keep only system parachains
  - testingRelayZagros.ts: Keep only system parachains
  - testingRelayTeyrChain.ts: Keep only system parachains

- Update domain references:
  - polkadot.js.org → pezkuwichain.app
  - wiki.polkadot.network → wiki.pezkuwichain.io
  - dotapps.io → pezkuwichain.app
  - statement.polkadot.network → docs.pezkuwichain.io/statement
  - support.polkadot.network → docs.pezkuwichain.io

- Update repository references:
  - github.com/pezkuwi-js/apps → github.com/pezkuwichain/pwap

- Rename system parachains to Pezkuwi ecosystem:
  - PolkadotAssetHub → PezkuwiAssetHub
  - polkadotBridgeHub → pezkuwiBridgeHub
  - polkadotCollectives → pezkuwiCollectives
  - polkadotCoretime → pezkuwiCoretime
  - polkadotPeople → pezkuwiPeople

- Update network name in claims utility:
  - Polkadot → Pezkuwi
2026-01-09 03:08:11 +03:00

87 lines
2.2 KiB
TypeScript

// Copyright 2017-2026 @pezkuwi/react-components authors & contributors
// SPDX-License-Identifier: Apache-2.0
// Something is seriously going wrong here...
/* eslint-disable @typescript-eslint/no-unnecessary-type-assertion */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-call */
import CodeFlask from 'codeflask';
import React, { useEffect, useRef, useState } from 'react';
import { styled } from './styled.js';
interface Props {
className?: string;
code: string;
isValid?: boolean;
onEdit: (code: string) => void;
}
/**
* @name Editor
* @summary A code editor based on the codeflask npm module
* @description It allows to live-edit code examples and JSON files.
*
* @example
* <BR>
*
* ```javascript
* import {Editor} from '@pezkuwi/react-components';
*
* <Editor
* className={string} // optional
* code={string}
* isValid={boolean}, // optional
* onEdit={() => callbackFunction}
* />
* ```
*/
function Editor ({ className = '', code, isValid, onEdit }: Props): React.ReactElement<Props> {
const [editorId] = useState(() => `flask-${Date.now()}`);
const editorRef = useRef<CodeFlask | null>(null);
useEffect((): void => {
const editor = new CodeFlask(`#${editorId}`, {
language: 'js',
lineNumbers: true
});
editor.updateCode(code);
(editor as any).editorRoot.addEventListener('keydown', (): void => {
(editor as unknown as Record<string, (value: unknown) => void>).onUpdate(onEdit);
});
editorRef.current = editor;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
useEffect((): void => {
editorRef.current && editorRef.current.updateCode(code);
}, [code]);
return (
<StyledDiv
className={`${className} ui-Editor ${isValid === false ? 'invalid' : ''}`}
id={editorId}
/>
);
}
const StyledDiv = styled.div`
.codeflask {
border: 1px solid var(--border-input);
background: transparent;
}
&.invalid {
.codeflask {
background-color: #fff6f6;
border-color: #e0b4b4;
}
}
`;
export default React.memo(Editor);