Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Embed not working in chat messages due to replaceParent being true (v12 prototype 1) #10338

Closed
3 of 6 tasks
dylanpiera opened this issue Jan 10, 2024 · 5 comments
Closed
3 of 6 tasks
Assignees
Labels
bug Functionality which is not working as intended chat Issues related to Chat and Chat Messages journal Issues related to the Journal and Pages systems

Comments

@dylanpiera
Copy link

dylanpiera commented Jan 10, 2024

What happened?

In editor.js _enrichEmbeds the replaceParent option is set to true.

Snippet:

/**
   * Handle embedding Document content with @Embed[uuid]{label} text.
   * @param {Text[]} text                  The existing text content.
   * @param {EnrichmentOptions} [options]  Options provided to customize text enrichment.
   * @returns {Promise<boolean>}           Whether any embeds were replaced and the text nodes need to be updated.
   * @protected
   */
  static async _enrichEmbeds(text, options={}) {
    const rgx = /@Embed\[(?<config>[^\]]+)](?:{(?<label>[^}]+)})?/gi;
    return this._replaceTextContent(text, rgx, match => this._embedContent(match, options), { replaceParent: true }); // <-- this part
  }

Because of this the chat input @Embed[JournalEntry.DSQM9mLokwFDNUeH.JournalEntryPage.46riMQ1pGoYmrwmA] doesn't get embedded, however the input <span>@Embed[JournalEntry.DSQM9mLokwFDNUeH.JournalEntryPage.46riMQ1pGoYmrwmA]</span> or any similar HTML element for that matter; will work as it needs a parent to replace.

I noticed this difference while comparing it to _enrichContentLinks, locally removed the { replaceParent: true } making it work as expected, and from my brief testing doesn't appear to impact Journal Pages.

I'd personally imagine this is unintended behavior and @Embed should work similarly to @UUID.

What ways of accessing Foundry can you encounter this issue in?

  • Native App (Electron)
  • Chrome
  • Firefox
  • Safari
  • Other

Reproduction Steps

  1. Create a Journal Entry + Page and copy the Page's UUID.
  2. Paste this into an empty chat box: @Embed[uuid-of-journal-entry-page]
  3. The message will not embed
  4. Repeat step 2 but now with the following format: <span>@Embed[uuid-of-journal-entry-page]</span>
  5. The message will embed
  6. Remove {replaceParent: true} from TextEditor._enrichEmbeds
  7. Repeat step 2, unlike before it will now embed.

What core version are you reporting this for?

Version 12 (build 316)

Relevant log output

No response

Bug Checklist

  • The issue occurs while all Modules are disabled
@dylanpiera dylanpiera added the bug Functionality which is not working as intended label Jan 10, 2024
@aaclayton
Copy link
Contributor

@Fyorl this should be a hopefully simple fix, but one you can look at related to the new @Embed functionality.

@aaclayton aaclayton added journal Issues related to the Journal and Pages systems chat Issues related to Chat and Chat Messages labels Jan 11, 2024
@aaclayton aaclayton added this to the V12 - Prototype 2 milestone Jan 11, 2024
@aaclayton aaclayton removed this from the V12 - API Development 2 milestone Mar 26, 2024
@dylanpiera
Copy link
Author

@aaclayton @Fyorl Is this proofing more difficult than expected or is it flying under the radar?

It's a tedious issue for manually creating Embeds in chat during play.

@aaclayton
Copy link
Contributor

This issue is on our V12 project board - so we certainly hope to accomplish it - but it is assigned priority MEDIUM which means its waiting in line behind a bunch of HIGH priority stuff which our team feels is more essential to address.

I hope we'll get to it!

@aaclayton
Copy link
Contributor

@Fyorl let's take a look at this in the next milestone, since @Embed is a new feature it woul be good to clean this up before we call it stable.

@Fyorl
Copy link
Contributor

Fyorl commented May 13, 2024

Should be a relatively straightforward fix

@Fyorl Fyorl added this to the V12 User Testing 4 milestone May 14, 2024
@Fyorl Fyorl closed this as completed May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Functionality which is not working as intended chat Issues related to Chat and Chat Messages journal Issues related to the Journal and Pages systems
Projects
Status: Done
Development

No branches or pull requests

3 participants