Skip to content

Commit

Permalink
chore(block-editor): Fix #25591: Char count block editor correction (#…
Browse files Browse the repository at this point in the history
…26025)

* Jdcmsd char count fixes (#25780)

* Issue 25661 add an attribute to each and every piece of json that conforms the cli bundle (#25731)

* #25661 Add dotCMSObjectType field to language, content type and site models

Added a "dotCMSObjectType" field to the language, content type, and site models in the project to get better clarity. Additionally, new tests have been added to LanguageCommandTest, ContentTypeCommandTest, and SiteCommandTest. These tests ensure that the "dotCMSObjectType" field is present in the JSON and YAML files generated when the pull command is executed for languages, content types, and sites respectively.

This addition helps in identifying the object type when reviewing the JSON or YAML files, improving maintainability and understandability of the codes and files.

* #25661 Refactor ContentType class: "TYPE" made final

* #25661 Added a JsonProperty to ContentType class

* #25661 Added JsonViews and JsonProperty to handle JSON serialization.

This commit introduces JsonViews in AbstractLanguage, ContentType, and AbstractSiteView classes. This helps manage different JSON views and control serialization for different use cases. A JsonProperty "dotCMSObjectType" has been added to the ContentType class. Test cases for Content Type, Site and Language have been updated to include a command to push the changes back to the server, ensuring the structure is still correct. New functionalities for creating and updating language and content type have been provided with the ExternalView of Json, adding more security to the API calls. The CommonViews class has been added to handle different views for JSON serialization. This change enhances the control over data visibility in different scenarios.

* #25661 Cleanup

---------

Co-authored-by: Nollymar Longa <nollymar.longa@dotcms.com>

* Update dot-block-editor.component.ts

* Update dot-content-compare-block-editor.component.spec.ts

* Update TestDataUtils.java

* Update StoryBlockAPITest.java

* Update FolderAPITest.java

* Update ContentletIndexAPIImplTest.java

---------

Co-authored-by: Jonathan Gamba <jonathan.gamba@dotcms.com>
Co-authored-by: Nollymar Longa <nollymar.longa@dotcms.com>

* dev (block editor): build

---------

Co-authored-by: Jamie Mauro <102264829+jdcmsd@users.noreply.github.com>
Co-authored-by: Jonathan Gamba <jonathan.gamba@dotcms.com>
Co-authored-by: Nollymar Longa <nollymar.longa@dotcms.com>
Co-authored-by: Jose Castro <jose.castro@dotcms.com>
  • Loading branch information
5 people committed Sep 11, 2023
1 parent d30c794 commit 3cd5549
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const dotContentCompareTableDataMock: DotContentCompareTableData = {
hostName: 'demo.dotcms.com',
html: {
attrs: {
chartCount: 16,
charCount: 16,
readingTime: 1,
wordCount: 5
},
Expand Down Expand Up @@ -89,7 +89,7 @@ export const dotContentCompareTableDataMock: DotContentCompareTableData = {
hostName: 'demo.dotcms.com',
html: {
attrs: {
chartCount: 16,
charCount: 16,
readingTime: 1,
wordCount: 5
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ export class DotBlockEditorComponent implements OnInit, OnDestroy {
]
});

this.editor.on('create', () => this.updateChartCount());
this.editor.on('create', () => this.updateCharCount());
this.subject
.pipe(takeUntil(this.destroy$), debounceTime(250))
.subscribe(() => this.updateChartCount());
.subscribe(() => this.updateCharCount());

this.editor.on('transaction', ({ editor }) => {
this.freezeScroll = FREEZE_SCROLL_KEY.getState(editor.view.state)?.freezeScroll;
Expand All @@ -174,11 +174,11 @@ export class DotBlockEditorComponent implements OnInit, OnDestroy {
this.valueChange.emit(value);
}

private updateChartCount(): void {
private updateCharCount(): void {
const tr = this.editor.state.tr.setMeta('addToHistory', false);

if (this.characterCount.characters() != 0) {
tr.step(new SetDocAttrStep('chartCount', this.characterCount.characters()))
tr.step(new SetDocAttrStep('charCount', this.characterCount.characters()))
.step(new SetDocAttrStep('wordCount', this.characterCount.words()))
.step(new SetDocAttrStep('readingTime', this.readingTime));
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private void generateTestContentlets() throws Exception {
.host(host)
.setProperty("title", "genericContent")
.setProperty("author", "systemUser")
.setProperty("body", "{\"type\":\"doc\",\"attrs\":{\"chartCount\":20,\"wordCount\":3,\"readingTime\":1},\"content\":[{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":\"left\"},\"content\":[{\"type\":\"text\",\"text\":\"Generic Content Body\"}]}]}").nextPersisted();
.setProperty("body", "{\"type\":\"doc\",\"attrs\":{\"charCount\":20,\"wordCount\":3,\"readingTime\":1},\"content\":[{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":\"left\"},\"content\":[{\"type\":\"text\",\"text\":\"Generic Content Body\"}]}]}").nextPersisted();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class StoryBlockAPITest extends IntegrationTestBase {
"{\n" +
" \"type\":\"doc\",\n" +
" \"attrs\":{\n" +
" \"chartCount\":2,\n" +
" \"charCount\":2,\n" +
" \"wordCount\":1,\n" +
" \"readingTime\":1\n" +
" },\n" +
Expand Down Expand Up @@ -89,7 +89,7 @@ public class StoryBlockAPITest extends IntegrationTestBase {
" \"body\":{\n" +
" \"type\":\"doc\",\n" +
" \"attrs\":{\n" +
" \"chartCount\":1,\n" +
" \"charCount\":1,\n" +
" \"wordCount\":1,\n" +
" \"readingTime\":1\n" +
" },\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ public void testCopyFolderDoesNotDuplicateContent()
.host(host)
.setProperty("title", "genericContent")
.setProperty("author", "systemUser")
.setProperty("body", "{\"type\":\"doc\",\"attrs\":{\"chartCount\":20,\"wordCount\":3,\"readingTime\":1},\"content\":[{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":\"left\"},\"content\":[{\"type\":\"text\",\"text\":\"Generic Content Body\"}]}]}").nextPersisted();
.setProperty("body", "{\"type\":\"doc\",\"attrs\":{\"charCount\":20,\"wordCount\":3,\"readingTime\":1},\"content\":[{\"type\":\"paragraph\",\"attrs\":{\"textAlign\":\"left\"},\"content\":[{\"type\":\"text\",\"text\":\"Generic Content Body\"}]}]}").nextPersisted();

/*Relate content to page*/
final MultiTree multiTree = new MultiTree(htmlPageAsset.getIdentifier(),
Expand Down
2 changes: 1 addition & 1 deletion dotCMS/src/main/webapp/html/dotcms-block-editor.js

Large diffs are not rendered by default.

0 comments on commit 3cd5549

Please sign in to comment.