Skip to content

Commit

Permalink
feat: support for lr only
Browse files Browse the repository at this point in the history
  • Loading branch information
Egor Didenko committed Jul 25, 2024
1 parent 77fe52f commit 154537d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 68 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ We use [JSDoc type annotations](https://www.typescriptlang.org/docs/handbook/int

```html
<script type="module">
import * as UC from 'https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@{{PACKAGE_VERSION}}/web/blocks.min.js';
import * as UC from 'https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@1/web/blocks.min.js';
UC.registerBlocks(UC);
</script>
Expand All @@ -82,7 +82,7 @@ We use [JSDoc type annotations](https://www.typescriptlang.org/docs/handbook/int
```html
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@{{PACKAGE_VERSION}}/web/uc-file-uploader-regular.min.css"
href="https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@1/web/uc-file-uploader-regular.min.css"
/>

<uc-file-uploader-regular ctx-name="my-uploader"> </uc-file-uploader-regular>
Expand All @@ -92,7 +92,7 @@ We use [JSDoc type annotations](https://www.typescriptlang.org/docs/handbook/int

### From NPM

1. Install Uploadcare Blocks package: `npm i --save-exact @uploadcare/file-uploader`
1. Install Uploadcare Blocks package: `npm i @uploadcare/file-uploader`
2. Connect `Blocks` from your script file:

```js
Expand All @@ -106,7 +106,7 @@ UC.registerBlocks(UC);
```html
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@{{PACKAGE_VERSION}}/web/uc-file-uploader-regular.min.css"
href="https://cdn.jsdelivr.net/npm/@uploadcare/file-uploader@1/web/uc-file-uploader-regular.min.css"
/>

<uc-file-uploader-inline ctx-name="my-uploader"> </uc-file-uploader-inline>
Expand Down
14 changes: 3 additions & 11 deletions abstract/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { sharedConfigKey } from './sharedConfigKey.js';
import { A11y } from './a11y.js';

const TAG_PREFIX = 'uc-';
const LEGACY_TAG_PREFIX = 'lr-';

// @ts-ignore TODO: fix this
export class Block extends BaseComponent {
Expand Down Expand Up @@ -327,21 +326,14 @@ export class Block extends BaseComponent {
console.log(`[${this.ctxName}]`, ...consoleArgs);
}

/**
* @param {String} [name]
* @param {Boolean} [isAlias]
*/
static reg(name, isAlias = false) {
/** @param {String} [name] */
static reg(name) {
if (!name) {
super.reg();
return;
}
if (name.startsWith(TAG_PREFIX)) {
super.reg(name, isAlias);
}

if (name.startsWith(LEGACY_TAG_PREFIX)) {
super.reg(name, isAlias);
super.reg(name);
}
}
}
Expand Down
14 changes: 2 additions & 12 deletions abstract/registerBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,11 @@ export function registerBlocks(blockExports) {
tagName = tagName.replace('-', '');
}

let currentTagName = '';
if (!tagName.startsWith('uc-')) {
currentTagName = addPrefix('uc-', tagName);
tagName = 'uc-' + tagName;
}

let legacyTagName = '';
if (!tagName.startsWith('lr-')) {
legacyTagName = addPrefix('lr-', tagName);
}

if (blockExports[blockName].reg) {
blockExports[blockName].reg(currentTagName);
blockExports[blockName].reg(legacyTagName, true);
blockExports[blockName].reg(tagName);
}
}
}

const addPrefix = (prefix, name) => prefix + name;
41 changes: 0 additions & 41 deletions types/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,46 +59,5 @@ declare namespace JSX {
'uc-file-uploader-inline': CustomElement<FileUploaderInline, CtxAttributes>;
'uc-upload-ctx-provider': CustomElement<InstanceType<UploadCtxProvider>, CtxAttributes>;
'uc-config': CustomElement<InstanceType<Config>, CtxAttributes & Partial<ConfigPlainType>>;

'lr-crop-frame': any;
'lr-editor-crop-button-control': any;
'lr-editor-filter-control': any;
'lr-editor-operation-control': any;
'lr-editor-image-cropper': any;
'lr-editor-image-fader': any;
'lr-editor-scroller': any;
'lr-editor-slider': any;
'lr-editor-toolbar': any;
'lr-lr-btn-ui': any;
'lr-line-loader-ui': any;
'lr-presence-toggle': any;
'lr-slider-ui': any;
'lr-icon': any;
'lr-img': any;
'lr-simple-btn': any;
'lr-start-from': any;
'lr-drop-area': any;
'lr-source-btn': any;
'lr-source-list': any;
'lr-file-item': any;
'lr-modal': any;
'lr-upload-list': any;
'lr-url-source': any;
'lr-camera-source': any;
'lr-progress-bar-common': any;
'lr-progress-bar': any;
'lr-external-source': any;
'lr-cloud-image-editor-activity': any;
'lr-cloud-image-editor-block': CustomElement<
CloudImageEditorBlock,
CtxAttributes & ({ uuid: string } | { 'cdn-url': string }) & Partial<{ tabs: string; 'crop-preset': string }>
>;
'lr-cloud-image-editor': CustomElement<CloudImageEditorBlock, JSX.IntrinsicElements['lr-cloud-image-editor-block']>;
'lr-form-input': CustomElement<FormInput, CtxAttributes>;
'lr-file-uploader-regular': CustomElement<FileUploaderRegular, CtxAttributes>;
'lr-file-uploader-minimal': CustomElement<FileUploaderMinimal, CtxAttributes>;
'lr-file-uploader-inline': CustomElement<FileUploaderInline, CtxAttributes>;
'lr-upload-ctx-provider': CustomElement<InstanceType<UploadCtxProvider>, CtxAttributes>;
'lr-config': CustomElement<InstanceType<Config>, CtxAttributes & Partial<ConfigPlainType>>;
}
}

0 comments on commit 154537d

Please sign in to comment.