index.ts 793 B

123456789101112131415161718192021222324252627282930313233
  1. import { initialSDK as initialSDKRaw, sdk } from './sdk'
  2. import { setupAssociation } from './association'
  3. const presetViewElement = (layout: HTMLDivElement) => {
  4. const style = getComputedStyle(layout)
  5. const allows = ['relative', 'absolute', 'fixed']
  6. if (!allows.includes(style.position)) {
  7. layout.style.position = 'relative'
  8. }
  9. const el = document.createElement('div')
  10. el.style.cssText = `
  11. position: absolute;
  12. left: 0;
  13. right: 0;
  14. top: 0;
  15. bottom: 0;
  16. pointer-events: none;
  17. z-index:101
  18. `
  19. layout.appendChild(el)
  20. return el
  21. }
  22. export const initialSDK: typeof initialSDKRaw = async (props) => {
  23. await initialSDKRaw(props)
  24. setupAssociation(presetViewElement(props.layout))
  25. }
  26. export * from './association'
  27. export * from './sdk'
  28. export default sdk