plasmo icon indicating copy to clipboard operation
plasmo copied to clipboard

[How to fetch anchor innerText]

Open yangcancai opened this issue 1 year ago • 3 comments

What is the example you wish to see?

export const getInlineAnchorList: PlasmoGetInlineAnchorList = async () => {
  return document.querySelectorAll("div[id^='message-content']")
}

export const getShadowHostId = (anchor: PlasmoCSUIAnchor) => 
anchor.element.innerText + "plasmo-inline-example-unique-id"

const TranslateComponent = () => {
 // how to fetch anchor innerText
 const orgMsgText = anchor.element.innerText
 const newMsgText = (orgMsgText) => {}
  const [fontColor, _setColor] = useStorage("pickColor", "blue")
  return (
    <div style={{
        color: fontColor
    }}>
      <span> {newMsgText} </span>
    </div>
  )
}
export default TranslateComponent

Is there any context that might help us understand?

I want to fetch anchor innerText in TranslateComponent , I didn't find the corresponding solution in the documents and examples, Is there any way to solve it?

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct
  • [X] I checked the current issues for duplicate problems.

yangcancai avatar Dec 13 '23 08:12 yangcancai

It's 2024, and I'm also looking for a solution to this

dielect avatar Jun 13 '24 10:06 dielect

You can try this

...
const TranslateComponent = ({ anchor: { element } }) => {
...

LyceumHewun avatar Jul 23 '24 08:07 LyceumHewun

You can try this

...
const TranslateComponent = ({ anchor: { element } }) => {
...

Thank you, I discovered this usage after some time by reviewing some reference code, but it was not mentioned in the official documentation. In fact, I do not know how much more advanced usage I am unaware of.

dielect avatar Jul 23 '24 10:07 dielect