Browse Source

Support data-attribute.

pull/1122/head
Sebastian Stehle 1 year ago
parent
commit
54e0ba21a3
  1. 2
      backend/src/Squidex/wwwroot/scripts/embed-sdk.js
  2. 2
      backend/src/Squidex/wwwroot/scripts/embed-sdk.js.map
  3. 5
      sdk/.gitignore
  4. 30
      sdk/package-lock.json
  5. 1
      sdk/size-plugin.json
  6. 8
      sdk/src/components/overlay-container.tsx
  7. 4
      sdk/src/template.html

2
backend/src/Squidex/wwwroot/scripts/embed-sdk.js

File diff suppressed because one or more lines are too long

2
backend/src/Squidex/wwwroot/scripts/embed-sdk.js.map

File diff suppressed because one or more lines are too long

5
sdk/.gitignore

@ -1,3 +1,8 @@
node_modules
/build
/dist
/*.log
size-plugin.json

30
sdk/package-lock.json

@ -4232,14 +4232,24 @@
}
},
"node_modules/caniuse-lite": {
"version": "1.0.30001300",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001300.tgz",
"integrity": "sha512-cVjiJHWGcNlJi8TZVKNMnvMid3Z3TTdDHmLDzlOdIiZq138Exvo0G+G0wTdVYolxKb4AYwC+38pxodiInVtJSA==",
"version": "1.0.30001651",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz",
"integrity": "sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==",
"dev": true,
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/browserslist"
}
"funding": [
{
"type": "opencollective",
"url": "https://opencollective.com/browserslist"
},
{
"type": "tidelift",
"url": "https://tidelift.com/funding/github/npm/caniuse-lite"
},
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
]
},
"node_modules/caseless": {
"version": "0.12.0",
@ -24344,9 +24354,9 @@
}
},
"caniuse-lite": {
"version": "1.0.30001300",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001300.tgz",
"integrity": "sha512-cVjiJHWGcNlJi8TZVKNMnvMid3Z3TTdDHmLDzlOdIiZq138Exvo0G+G0wTdVYolxKb4AYwC+38pxodiInVtJSA==",
"version": "1.0.30001651",
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001651.tgz",
"integrity": "sha512-9Cf+Xv1jJNe1xPZLGuUXLNkE1BoDkqRqYyFJ9TDYSqhduqA4hu4oR9HluGoWYQC/aj8WHjsGVV+bwkh0+tegRg==",
"dev": true
},
"caseless": {

1
sdk/size-plugin.json

File diff suppressed because one or more lines are too long

8
sdk/src/components/overlay-container.tsx

@ -1,7 +1,7 @@
import { h } from 'preact';
import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
import { IFrame } from './iframe';
import { Overlay } from './Overlay';
import { Overlay } from './overlay';
import { TokenInfo } from './shared';
export interface OverlayContainerProps {
@ -165,7 +165,11 @@ function parseTokenInPath(target: HTMLElement, baseUrls: string[]): { token?: To
}
function parseToken(target: HTMLElement, baseUrls: string[]): TokenInfo | null {
const value = target.getAttribute('squidex-token');
const value =
target.getAttribute('sq-token') ||
target.getAttribute('squidex-token') ||
target.getAttribute('data-sq-token') ||
target.getAttribute('data-squidex-token');
if (!value && target.nodeName === 'IMG') {
const src = (target as any)['src'] as string;

4
sdk/src/template.html

@ -72,11 +72,11 @@
<body>
<% preact.bodyEnd %>
<div class="element element-top" squidex-token="eyJhIjoic3F1aWRleC13ZWJzaXRlIiwicyI6ImJsb2ciLCJpIjoiZmQxZDkzNjYtNDY3ZS00MmFiLWE5MzYtYmNmNDk3NjIxYjk4IiwidSI6Imh0dHBzOi8vbG9jYWxob3N0OjUwMDEvIn0=">
<div class="element element-top" data-squidex-token="eyJhIjoic3F1aWRleC13ZWJzaXRlIiwicyI6ImJsb2ciLCJpIjoiZmQxZDkzNjYtNDY3ZS00MmFiLWE5MzYtYmNmNDk3NjIxYjk4IiwidSI6Imh0dHBzOi8vbG9jYWxob3N0OjUwMDEvIn0=">
Top Aligned
</div>
<div class="element element-right" squidex-token="ewogICJ1IjogImh0dHBzOi8vbG9jYWxob3N0OjUwMDEiLAogICJhIjogInRlc3QiLAogICJzIjogInRlc3QiLAogICJpIjogIjI0ZWQxMWJhLWJjNzItNDMzZS04ODRjLWE0NGE3ODIwYjU1MSIgIAp9">
<div class="element element-right" data-squidex-token="ewogICJ1IjogImh0dHBzOi8vbG9jYWxob3N0OjUwMDEiLAogICJhIjogInRlc3QiLAogICJzIjogInRlc3QiLAogICJpIjogIjI0ZWQxMWJhLWJjNzItNDMzZS04ODRjLWE0NGE3ODIwYjU1MSIgIAp9">
Right Aligned
</div>

Loading…
Cancel
Save