Skip to content

Commit

Permalink
fix: replace crypto uuid generation with randomly generated hash string
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohan Bansal committed Dec 31, 2024
1 parent d15b96c commit 62a0096
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion atable/src/stores/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineStore } from 'pinia'
import { type CSSProperties, computed, ref } from 'vue'

import type { CellContext, TableColumn, TableConfig, TableDisplay, TableModal, TableRow } from '../types'
import { generateHash } from '../utils'

/**
* Create a table store
Expand All @@ -18,7 +19,7 @@ export const createTableStore = (initData: {
display?: TableDisplay[]
modal?: TableModal
}) => {
const id = initData.id || crypto.randomUUID()
const id = initData.id || generateHash()
const createStore = defineStore(`table-${id}`, () => {
// util functions
const createTableObject = () => {
Expand Down
4 changes: 4 additions & 0 deletions atable/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ export const isHtmlString = (htmlString: string) => {
const $document = new DOMParser().parseFromString(htmlString, 'text/html')
return Array.from($document.body.childNodes).some(node => node.nodeType === 1)
}

export const generateHash = (length = 8) => {
return Array.from({ length }, () => Math.floor(Math.random() * 16).toString(16)).join('')
}

0 comments on commit 62a0096

Please sign in to comment.