Skip to content

Commit

Permalink
[newswires] add gu-note when dropping snippet which includes any us…
Browse files Browse the repository at this point in the history
…age note (or fallback message)
  • Loading branch information
twrichards committed Oct 24, 2024
1 parent 91a08b7 commit 1c9e0fe
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
9 changes: 5 additions & 4 deletions client/src/newswires/newswiresIntegration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const NewswiresIntegration = () => {

const [state, setState] = useState<{
selectedHTML: string;
mountPoint: HTMLElement;
containerElement: HTMLElement;
firstButtonPosition: ButtonPosition;
lastButtonPosition: ButtonPosition;
} | null>(null);
Expand Down Expand Up @@ -64,7 +64,7 @@ export const NewswiresIntegration = () => {
);
setState({
selectedHTML: maybeClonedTargetEl.innerHTML,
mountPoint: maybeOriginalTargetEl,
containerElement: maybeOriginalTargetEl,
firstButtonPosition: newFirstButtonCoords,
lastButtonPosition: newLastButtonCoords,
});
Expand All @@ -80,7 +80,7 @@ export const NewswiresIntegration = () => {
);
setState({
selectedHTML: tempEl.innerHTML,
mountPoint: maybeOriginalTargetEl,
containerElement: maybeOriginalTargetEl,
firstButtonPosition: newFirstButtonCoords,
lastButtonPosition: newLastButtonCoords,
});
Expand Down Expand Up @@ -124,6 +124,7 @@ export const NewswiresIntegration = () => {
payload: {
embeddableHtml: state.selectedHTML,
embeddableUrl: window.location.href,
maybeUsageNote: state.containerElement.dataset.usageNote,
},
});
setIsExpanded(true);
Expand Down Expand Up @@ -196,7 +197,7 @@ export const NewswiresIntegration = () => {
)
)}
</root.div>,
state.mountPoint
state.containerElement
)}
</>
);
Expand Down
8 changes: 7 additions & 1 deletion client/src/payloadDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,13 @@ export const PayloadDisplay = ({

event.dataTransfer.setData(
"text/html",
sanitizeHtml(payloadAndType.payload.embeddableHtml)
// TODO consider also add a gu-note for who shared it and when
`${sanitizeHtml(
payloadAndType.payload.embeddableHtml
)}<br/><gu-note>${
payloadAndType.payload.maybeUsageNote ||
"NO USAGE NOTE IN THE WIRE"
}</gu-note>`
);
} else {
event.dataTransfer.setData("URL", payload.embeddableUrl);
Expand Down
1 change: 1 addition & 0 deletions client/src/types/PayloadAndType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface PayloadWithApiUrl extends PayloadCommon {

export interface PayloadWithSnippet extends PayloadCommon {
embeddableHtml: string;
maybeUsageNote: string | undefined;
}

type Payload =
Expand Down

0 comments on commit 1c9e0fe

Please sign in to comment.