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

UVE: Enable Inline editing in text fields for Angular SDK #28973

Closed
5 tasks done
fmontes opened this issue Jun 21, 2024 · 7 comments · Fixed by #29124
Closed
5 tasks done

UVE: Enable Inline editing in text fields for Angular SDK #28973

fmontes opened this issue Jun 21, 2024 · 7 comments · Fixed by #29124

Comments

@fmontes
Copy link
Member

fmontes commented Jun 21, 2024

Related to

#28944

Task Description

As an author, I want to enable inline editing in text fields for pages in the Universal Visual Editor, so that users can easily edit text content directly on the page.

Acceptance Criteria

Preview Give feedback

Proposed Objective

Core Features

Proposed Priority

Priority 3 - Average

External Links... Slack Conversations, Support Tickets, Figma Designs, etc.:

In the traditional approach, developers need to "mark" sections of the contentlet being rendered that can be inline edited.

Example Markup

<h1 
    *ngIf="EDIT_MODE" 
    [attr.data-language]="CONTENT_LANGUAGE"
    [attr.data-mode]="'minimal'"
    [attr.data-inode]="ContentInode"
    [attr.data-field-name]="'title'"
>
    {{ title }}
</h1>

This markup shows a blue border around the text to indicate to the user that this is editable, and when the user clicks, it will start TinyMCE floating on top of the element.

Warning

If the contentlet lives in more than one page, it will pop up the corresponding dialog.

Developers need to pass four data attributes to their HTML in the container:

  • language: the language of the content.
  • mode: sets up the TinyMCE toolbar, either big or small. See image here.
  • inode: the unique identifier for the contentlet.
  • field-name: the variable name of the contentlet field that the user can edit.

With this information, we can trigger a workflow action (REST) to save/update the corresponding contentlet field:

fetch("http://localhost:8080/api/v1/workflow/actions/default/fire/EDIT?inode=a196bf08-a1bd-4c1c-8709-786b6385545d", {
  body: JSON.stringify({
    contentlet: {
      inode: "a196bf08-a1bd-4c1c-8709-786b6385545d",
      title: "Explore the World 123"
    }
  }),
  method: "PUT"
});

This will edit the contentlet and save the new text.

Headless

Since we should not inject anything into our customer's headless implementations, we need to write a component in our SDK that allows developers to "mark" the text they want to be editable.

We need to provide a component. It should work the same way, but we have a new mode: plain, which uses the contenteditable attribute instead of TinyMCE. plain should be the default mode, meaning if no mode is passed, it defaults to plain. So now we have three modes:

  • full: TinyMCE with a big toolbar
  • minimal: TinyMCE with a small toolbar
  • plain: NO TinyMCE, just contenteditable (default mode)

Example Usage in Angular Application

import { Component, Input } from '@angular/core';
import { EditableText } from '@dotcms/angular';

@Component({
  selector: 'app-banner',
  templateUrl: './banner.component.html',
  styleUrls: ['./banner.component.css']
})
export class BannerComponent {
  @Input() contentlet: unknown;
}

And the HTML:

<div class="banner">
  <img [src]="contentlet.image" [alt]="contentlet.title">
  <div class="content">
    <h2>
      <editable-text mode="minimal" [inode]="contentlet.inode" field="title" [lang]="contentlet.language">{{ contentlet.title }}</editable-text>
    </h2>
    <p>{{ contentlet.caption }}</p>
    <a [href]="link">{{ contentlet.buttonText }}</a>
  </div>
</div>

EditableText Component

  1. It will show a blue border to indicate that it is editable.
  2. OnClick, it will initialize TinyMCE if the mode is full or minimal, or use the contenteditable attribute for plain.
  3. OnBlur, it will save the content by posting a message with the required information to the UVE.
  4. If the user deletes all text and blurs out, we don't emit anything and just return the old text.
  5. If the user clicks, changes nothing, and blurs out, we do nothing.
  6. Undo/Redo: should work, TinyCME might handle this.
  7. Error handling: if the request to save fails, we need to show a toast with the error and return to the previours text.
  8. ESC key: should cancel the editing and no save changes.

Loading TinyMCE

  1. TinyMCE has an official Angular component we can use.
  2. We only load TinyMCE in EDIT_MODE.
  3. In LIVE_MODE, no trace of TinyMCE should be in the bundle.
  4. You might want to dynamically load this if possible.

Assumptions & Initiation Needs

  • This includes traditional and headless rendering.
  • It should not break the API we had for the old editor in traditional mode.
  • It should use the latest version of TinyMCE.
  • This doesn't include inline editing for block editor fields.

Quality Assurance Notes & Workarounds

N/A

@fmontes fmontes changed the title UVE: Inline Editing Component Integration UVE: Enable Inline editing in text fields for Angular SDK Jun 21, 2024
@fmontes fmontes moved this to Next 1-3 Sprints in dotCMS - Product Planning Jun 24, 2024
@rjvelazco rjvelazco self-assigned this Jul 3, 2024
@rjvelazco rjvelazco moved this from Next 1-3 Sprints to In Progress in dotCMS - Product Planning Jul 3, 2024
@rjvelazco rjvelazco linked a pull request Jul 4, 2024 that will close this issue
2 tasks
@zJaaal zJaaal assigned zJaaal and unassigned zJaaal Jul 5, 2024
@rjvelazco rjvelazco moved this from In Progress to In Review in dotCMS - Product Planning Jul 17, 2024
@github-project-automation github-project-automation bot moved this from In Review to Internal QA in dotCMS - Product Planning Jul 17, 2024
@rjvelazco rjvelazco removed their assignment Jul 17, 2024
@rjvelazco rjvelazco reopened this Jul 17, 2024
@github-project-automation github-project-automation bot moved this from Internal QA to Current Sprint Backlog in dotCMS - Product Planning Jul 17, 2024
@rjvelazco rjvelazco moved this from Current Sprint Backlog to Internal QA in dotCMS - Product Planning Jul 18, 2024
@rjvelazco
Copy link
Contributor

rjvelazco commented Jul 22, 2024

Blocked by #29311

@KevinDavilaDotCMS
Copy link
Contributor

Passed IQA

Tested in qa-master with Angular example

Screen.Recording.2024-07-24.at.2.19.20.PM.mov

@KevinDavilaDotCMS KevinDavilaDotCMS moved this from Internal QA to QA - Backlog in dotCMS - Product Planning Jul 24, 2024
@github-project-automation github-project-automation bot moved this from QA - Backlog to Internal QA in dotCMS - Product Planning Jul 25, 2024
@bryanboza
Copy link
Contributor

This is breaking the regular editing, new case opened here #29426

This one, needs to be retest after fix the related problem...

@bryanboza bryanboza moved this from QA - Backlog to QA - Rejected in dotCMS - Product Planning Aug 1, 2024
@nollymar nollymar reopened this Aug 1, 2024
@github-project-automation github-project-automation bot moved this from QA - Rejected to Current Sprint Backlog in dotCMS - Product Planning Aug 1, 2024
@bryanboza bryanboza added Release : 24.08.20 AI Fixed and removed Release : 24.08.05 Portlets Plugins labels Aug 6, 2024
@nollymar nollymar moved this from Current Sprint Backlog to Internal QA in dotCMS - Product Planning Aug 12, 2024
@zJaaal zJaaal assigned zJaaal and unassigned zJaaal Aug 13, 2024
@zJaaal
Copy link
Contributor

zJaaal commented Aug 13, 2024

IOA Passed

Now inline editing is working as expected on Angular Example

Screenshot

Screen.Recording.2024-08-13.at.6.mp4

@zJaaal zJaaal closed this as completed Aug 13, 2024
@zJaaal
Copy link
Contributor

zJaaal commented Aug 13, 2024

Note to QA

Be sure that you are in the 0.0.1-alpha.31 version of the libs or above to test this correctly.

@zJaaal zJaaal removed their assignment Aug 13, 2024
@bryanboza bryanboza added Release : 24.08.27 Custom templates and loggin fixes and removed Release : 24.08.20 AI Fixed labels Aug 20, 2024
@bryanboza
Copy link
Contributor

@zJaaal We need to make sure we are doing the internal using the docker image with the latest version of trunk, to avoid inconsistencies with libraries, versions etc...

@bryanboza bryanboza added Release : 24.09.21 UVE // Java21 and removed Release : 24.08.27 Custom templates and loggin fixes labels Aug 27, 2024
@josemejias11
Copy link
Contributor

Approved: Tested on trunk_b8fe837, Docker, macOS 14.5, FF v126.0.1

@josemejias11 josemejias11 moved this from QA - In Progress to Done in dotCMS - Product Planning Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment