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

Content Model: Improve cache behavior #1999

Merged
merged 6 commits into from
Aug 4, 2023
Merged

Conversation

JiuqingSong
Copy link
Collaborator

  • Move allowCacheElement from DomToModelFormatContext to EditorContext, so we will only allow cache element in Content Model when create content model from editor
  • Remove disableCacheElement from DomToModelOption since now we always allow cache element for Content Model from editor, and always disallow cache element when create Content Model from other sources
  • In API cloneModel, add an options parameter, and now by default cachedElement will not be included in cloned model. For entity and general model, we will put a cloned element as the wrapper element. We will include cached element and directly put the same reference to entity only when options.includeCachedElement is true. So that when clone model for cut/copy, the new model can be fully disconnected from editor content
  • Fix some selection bugs in ContentModelCopyPastePlugin
  • Fix Content Model: "Copy" can delete entity #1997, copy content using Content Model won't make entity disappear even cached model is used
  • Use common API formatWithContentModel for cut action in ContentModelCopyPastePlugin
  • Fix all related test cases

@JiuqingSong JiuqingSong marked this pull request as ready for review August 2, 2023 20:42
@BryanValverdeU
Copy link
Contributor

BryanValverdeU commented Aug 4, 2023

It seems that copying a entity is changing the color and the background color.

<div>asdsadsad&nbsp;<span class="entityDelimiterBefore">​</span><span style="display: inline-block;" class="_Entity _EType_asdasd _EId_asdasd_35 _EReadonly_1" contenteditable="false"><span>| entity |</span></span><span class="entityDelimiterAfter">​</span>&nbsp;asdsadsadsad</div><!--{"type":0,"isDarkMode":true,"start":[0,0,0],"end":[0,4,13]}-->

With this change, copying and pasting the first line
image

Before
image

@JiuqingSong
Copy link
Collaborator Author

It seems that copying a entity is changing the color and the background color.

<div>asdsadsad&nbsp;<span class="entityDelimiterBefore">​</span><span style="display: inline-block;" class="_Entity _EType_asdasd _EId_asdasd_35 _EReadonly_1" contenteditable="false"><span>| entity |</span></span><span class="entityDelimiterAfter">​</span>&nbsp;asdsadsadsad</div><!--{"type":0,"isDarkMode":true,"start":[0,0,0],"end":[0,4,13]}-->

With this change, copying and pasting the first line image

Before image

Thanks for caching this. I fixed it by adding it back into handleEntity.

Now entity model will always have the original wrapper element, and we only handle the separation when

  1. clone model
  2. write back

@JiuqingSong JiuqingSong merged commit d6a390c into master Aug 4, 2023
@JiuqingSong JiuqingSong deleted the u/jisong/cacheimprove2 branch August 4, 2023 20:05
Andres-CT98 added a commit that referenced this pull request Aug 18, 2023
* Content Model: Improve cache behavior (#1999)

* Content Model: Improve cache behavior

* fix build

* fix comment

* Skip Trigger plugin event on plain text paste (#2011)

* init

* remove unneeded change

* Update return type

* Fix 218869: Do not allow dragging on readonly content (#2010)

* Fix 218869: Do not allow dragging readonly content

* fix test

* Content Model: Fix 194024 and 220289 (#2012)

* Content Model: Fix 221290 Support float for image (#2013)

* Content Model: improve formatWithContentModel 1 (#2001)

* Content Model: Improve cache behavior

* fix build

* Content Model: improve formatWithContentModel

* Content Model: improve formatWithContentModel 2 (#2002)

* Content Model: Improve cache behavior

* fix build

* Content Model: improve formatWithContentModel

* Content Model: improve formatWithContentModel 2

* fix format

* WIP

* fix handles

* MergeModel, do not inherit the styles of table when splitting the param (#2016)

* init

* init

* address comment

* update test names

* fixes

* Demo site: Fix insert link button in Content Model ribbon (#2018)

* Content Model: insertEntity API (#1800)

* Content Model insertEntity

* improve

* improve

* Content Model: Improve cache behavior

* fix build

* Content Model: improve formatWithContentModel

* Content Model: improve formatWithContentModel 2

* Improve

* fix build

* fix build

* improve

* add test

* add test

* add test

* add test

* fix dark color

* fix test

* fix build and test

* crop

* fix xase

* check cell exist

* Fix #1752, rename header to heading (#2020)

* fix cell empty cells

* fix flipped image

* Update logic to decide if we need to merge a table on paste. (#2022)

* Fix TableSelectionCopy

* update unit tests

* Fix 2

* address comment

* Content Model: Rename a test file (#2029)

* Fix Triple clicking a single cell selecting more than one (#2024)

* fix triple click, optimisation

* Remove `display: flex` style on paste (#2031)

* init

* Fix

* Replace first cell content if input while on cell selection (#2030)

* select first cell content and empty, add undo if change

* Content Model: Fix 222135 (#2035)

* Fix 222135

* fix build

* Content Model: Fix 219312 (#2036)

* Fix regression when creating the BeforePasteEvent (#2039)

* init

* fix build

* Content Model: Fix 220050 (#2037)

* Content Model: Fix 220050

* Fix build

* improve

* improve

* Simplify the domToModel call in `paste.ts` (#2040)

* add more changes

* fix build

* fix test

* Content Model: Support vertical-align for image (#2041)

* Content Model: Support vertical-align for image

* fix build and test

---------

Co-authored-by: Bryan Valverde U <[email protected]>

* version bump

---------

Co-authored-by: Jiuqing Song <[email protected]>
Co-authored-by: Bryan Valverde U <[email protected]>
Co-authored-by: Júlia Roldi <[email protected]>
Co-authored-by: Julia Roldi <[email protected]>
ianeli1 added a commit that referenced this pull request Sep 11, 2023
* Content Model: Improve cache behavior (#1999)

* Content Model: Improve cache behavior

* fix build

* fix comment

* Skip Trigger plugin event on plain text paste (#2011)

* init

* remove unneeded change

* Update return type

* Fix 218869: Do not allow dragging on readonly content (#2010)

* Fix 218869: Do not allow dragging readonly content

* fix test

* Content Model: Fix 194024 and 220289 (#2012)

* Content Model: Fix 221290 Support float for image (#2013)

* Content Model: improve formatWithContentModel 1 (#2001)

* Content Model: Improve cache behavior

* fix build

* Content Model: improve formatWithContentModel

* Content Model: improve formatWithContentModel 2 (#2002)

* Content Model: Improve cache behavior

* fix build

* Content Model: improve formatWithContentModel

* Content Model: improve formatWithContentModel 2

* fix format

* WIP

* fix handles

* MergeModel, do not inherit the styles of table when splitting the param (#2016)

* init

* init

* address comment

* update test names

* fixes

* Demo site: Fix insert link button in Content Model ribbon (#2018)

* Content Model: insertEntity API (#1800)

* Content Model insertEntity

* improve

* improve

* Content Model: Improve cache behavior

* fix build

* Content Model: improve formatWithContentModel

* Content Model: improve formatWithContentModel 2

* Improve

* fix build

* fix build

* improve

* add test

* add test

* add test

* add test

* fix dark color

* fix test

* fix build and test

* crop

* fix xase

* check cell exist

* Fix #1752, rename header to heading (#2020)

* fix cell empty cells

* fix flipped image

* Update logic to decide if we need to merge a table on paste. (#2022)

* Fix TableSelectionCopy

* update unit tests

* Fix 2

* address comment

* Content Model: Rename a test file (#2029)

* Fix Triple clicking a single cell selecting more than one (#2024)

* fix triple click, optimisation

* Remove `display: flex` style on paste (#2031)

* init

* Fix

* Replace first cell content if input while on cell selection (#2030)

* select first cell content and empty, add undo if change

* Content Model: Fix 222135 (#2035)

* Fix 222135

* fix build

* Content Model: Fix 219312 (#2036)

* Fix regression when creating the BeforePasteEvent (#2039)

* init

* fix build

* Content Model: Fix 220050 (#2037)

* Content Model: Fix 220050

* Fix build

* improve

* improve

* Simplify the domToModel call in `paste.ts` (#2040)

* add more changes

* fix build

* fix test

* Content Model: Support vertical-align for image (#2041)

* Content Model: Support vertical-align for image

* fix build and test

---------

Co-authored-by: Bryan Valverde U <[email protected]>

* Remove deprecated colors from borders, text and background. (#2045)

* Support more border styles

* init

* Revert  unrelated change

* Fix dependencies

* address comments

* try fix build

* reselection

* add space

* Content Model: Improve insertEntity (#2047)

* Content Model: Improve insertEntity

* fix test

* Content Model: Fix selection of entity (#2051)

* Content Model: Always return size in pt when getFormatState (#2052)

* Content Model: trigger ShadowEdit events (#2053)

* Content Model: trigger ShadowEdit events

* improve

* Content Model: Add solid paragraph in new table cell (#2055)

* Content Model: Do color transform for entity when copy/paste (#2056)

* Content Model: Do color transform for entity when copy/paste

* Call normalizeContentModel

* Content Model: Paste plain text applies current format (#2057)

* Content Model: Paste plain text applies current format

* fix build

* Content Model: Fix a regression of shadow edit (#2058)

* Update versions

* Fix double import

* Double import 2

---------

Co-authored-by: Jiuqing Song <[email protected]>
Co-authored-by: Bryan Valverde U <[email protected]>
Co-authored-by: Júlia Roldi <[email protected]>
Co-authored-by: Julia Roldi <[email protected]>
Co-authored-by: Andres-CT98 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Content Model: "Copy" can delete entity
3 participants