diff --git a/package-lock.json b/package-lock.json index 99dadf36..230269b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -45,7 +45,6 @@ "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", "lint-staged": "^15.2.2", - "nanoid": "^5.0.6", "ng-packagr": "^17.1.0", "prettier": "^3.2.5", "prettier-plugin-astro": "^0.13.0", @@ -12612,24 +12611,6 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, - "node_modules/nanoid": { - "version": "5.0.6", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.6.tgz", - "integrity": "sha512-rRq0eMHoGZxlvaFOUdK1Ev83Bd1IgzzR+WJ3IbDJ7QOSdAxYjlurSPqFs9s4lJg29RT6nPwizFtJhQS6V5xgiA==", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/ai" - } - ], - "bin": { - "nanoid": "bin/nanoid.js" - }, - "engines": { - "node": "^18 || >=20" - } - }, "node_modules/natural-compare": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", diff --git a/package.json b/package.json index 4e2dbc10..779ce01e 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,6 @@ "karma-jasmine": "~5.1.0", "karma-jasmine-html-reporter": "~2.1.0", "lint-staged": "^15.2.2", - "nanoid": "^5.0.6", "ng-packagr": "^17.1.0", "prettier": "^3.2.5", "prettier-plugin-astro": "^0.13.0", diff --git a/projects/ngx-editor/ng-package.json b/projects/ngx-editor/ng-package.json index 82d9370e..e9c4aba2 100644 --- a/projects/ngx-editor/ng-package.json +++ b/projects/ngx-editor/ng-package.json @@ -13,7 +13,6 @@ "prosemirror-commands", "prosemirror-history", "prosemirror-inputrules", - "nanoid", "@floating-ui/core", "@floating-ui/dom", "@types/trusted-types" diff --git a/projects/ngx-editor/package.json b/projects/ngx-editor/package.json index e5360c39..26857190 100644 --- a/projects/ngx-editor/package.json +++ b/projects/ngx-editor/package.json @@ -25,7 +25,6 @@ "@floating-ui/core": "1.6.0", "@floating-ui/dom": "1.6.3", "@types/trusted-types": "~2.0.7", - "nanoid": "^5.0.6", "prosemirror-commands": "1.5.2", "prosemirror-history": "1.3.2", "prosemirror-inputrules":"1.4.0", diff --git a/projects/ngx-editor/src/lib/modules/menu/image/image.component.ts b/projects/ngx-editor/src/lib/modules/menu/image/image.component.ts index 991c9ddc..64c3366a 100644 --- a/projects/ngx-editor/src/lib/modules/menu/image/image.component.ts +++ b/projects/ngx-editor/src/lib/modules/menu/image/image.component.ts @@ -6,7 +6,7 @@ import { AbstractControl, FormControl, FormGroup, Validators } from '@angular/fo import { NodeSelection } from 'prosemirror-state'; import { EditorView } from 'prosemirror-view'; import { Observable, Subscription } from 'rxjs'; -import { nanoid } from 'nanoid'; +import { uniq } from 'ngx-editor/utils'; import { NgxEditorService } from '../../../editor.service'; import { MenuService } from '../menu.service'; @@ -21,7 +21,7 @@ import { HTML } from '../../../trustedTypesUtil'; export class ImageComponent implements OnInit, OnDestroy { showPopup = false; isActive = false; - private componentId = nanoid(); + private componentId = uniq(); private updateSubscription: Subscription; form = new FormGroup({ diff --git a/projects/ngx-editor/src/lib/modules/menu/link/link.component.ts b/projects/ngx-editor/src/lib/modules/menu/link/link.component.ts index 378eed4f..7776f412 100644 --- a/projects/ngx-editor/src/lib/modules/menu/link/link.component.ts +++ b/projects/ngx-editor/src/lib/modules/menu/link/link.component.ts @@ -5,12 +5,12 @@ import { import { AbstractControl, FormControl, FormGroup, Validators } from '@angular/forms'; import { EditorView } from 'prosemirror-view'; import { Observable, Subscription } from 'rxjs'; +import { uniq } from 'ngx-editor/utils'; import { NgxEditorService } from '../../../editor.service'; import { MenuService } from '../menu.service'; import { Link as LinkCommand } from '../MenuCommands'; import { HTML } from '../../../trustedTypesUtil'; -import { nanoid } from 'nanoid'; @Component({ selector: 'ngx-link', @@ -22,7 +22,7 @@ export class LinkComponent implements OnInit, OnDestroy { showPopup = false; isActive = false; canExecute = true; - private componentId = nanoid(); + private componentId = uniq(); form: FormGroup; private editorView: EditorView; diff --git a/projects/ngx-editor/utils/public_api.ts b/projects/ngx-editor/utils/public_api.ts index a0e6ec0a..f595509f 100644 --- a/projects/ngx-editor/utils/public_api.ts +++ b/projects/ngx-editor/utils/public_api.ts @@ -1,3 +1,4 @@ export { default as isNil } from './isNil'; export { default as toStyleString } from './toStyleString'; export { default as NgxEditorError } from './error'; +export { default as uniq } from './uniq'; diff --git a/projects/ngx-editor/utils/uniq.ts b/projects/ngx-editor/utils/uniq.ts new file mode 100644 index 00000000..af66dd2c --- /dev/null +++ b/projects/ngx-editor/utils/uniq.ts @@ -0,0 +1,7 @@ +const uniq = (): string => { + const timeStamp = Date.now().toString(36); + const random = Math.random().toString(36).substring(2, 7); + return `${timeStamp}${random}`; +}; + +export default uniq;