Commit graph

228 commits

Author SHA1 Message Date
Peter Savchenko 8276daa5ca
fix changelog (#2704) 2024-05-01 20:59:33 +03:00
Peter Savchenko 23858e0025
fix(conversion): restore caret after conversion though the Inline Toolbar and API (#2699)
* fix caret loosing after caret

* Refactor convert method to return Promise in Blocks API

* changelog upd

* Fix missing semicolon in blocks.cy.ts and BlockTunes.cy.ts

* add test for inline toolbar conversion

* Fix missing semicolon in InlineToolbar.cy.ts

* add test for toolbox shortcut

* api caret.setToBlock now can accept block api or index or id

* eslint fix

* Refactor test descriptions in caret.cy.ts

* rm tsconfig change

* lint

* lint

* Update CHANGELOG.md
2024-04-29 22:24:31 +03:00
Peter Savchenko efa0a34f8e
fix caret loosing after caret (#2697) 2024-04-27 21:19:12 +03:00
Peter Savchenko c48fca1be3
fix ios shift (#2696) 2024-04-27 21:09:16 +03:00
Peter Savchenko 1028577521
fix(scroll): acidental scroll to top on iOS devices (#2695)
* fix scroll on ios typing

* Update tsconfig.json

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update package.json

* Fix popover hide method to use isHidden flag
2024-04-27 21:04:26 +03:00
Tatiana Fomina 7821e35302
feat(block tunes): Conversion Menu in Block Tunes (#2692)
* Support delimiter

* Rename types, move types to popover-item folder

* Fix ts errors

* Add tests

* Review fixes

* Review fixes 2

* Fix delimiter while search

* Fix flipper issue

* Fix block tunes types

* Fix types

* tmp

* Fixes

* Make search input emit event

* Fix types

* Rename delimiter to separator

* Update chengelog

* Add convert to to block tunes

* i18n

* Lint

* Fix tests

* Fix tests 2

* Tests

* Add caching

* Rename

* Fix for miltiple toolbox entries

* Update changelog

* Update changelog

* Fix popover test

* Fix flipper tests

* Fix popover tests

* Remove type: 'default'

* Create isSameBlockData util

* Add testcase
2024-04-27 16:57:52 +03:00
Tatiana Fomina e1c70b4fb8
feat(popover): separator (#2690)
* Support delimiter

* Rename types, move types to popover-item folder

* Fix ts errors

* Add tests

* Review fixes

* Review fixes 2

* Fix delimiter while search

* Fix flipper issue

* Fix block tunes types

* Fix types

* Fixes

* Make search input emit event

* Fix types

* Rename delimiter to separator

* Update chengelog
2024-04-22 22:38:20 +03:00
Tatiana Fomina 5125f015dc
feat: nested popover (#2649)
* Move popover types to separate file

* tmp

* open top

* Fix bug with keyboard navigation

* Fix bug with scroll

* Fix mobile

* Add popover header class

* Display nested items on mobile

* Refactor history

* Fix positioning on desktop

* Fix tests

* Fix child popover indent left

* Fix ts errors in popover files

* Move files

* Rename cn to bem

* Clarify comments and rename method

* Refactor popover css classes

* Rename cls to css

* Split popover desktop and mobile classes

* Add ability to open popover to the left if not enough space to open to the right

* Add nested popover test

* Add popover test for mobile screens

* Fix tests

* Add union type for both popovers

* Add global window resize event

* Multiple fixes

* Move nodes initialization to constructor

* Rename handleShowingNestedItems to showNestedItems

* Replace WindowResize with EditorMobileLayoutToggled

* New doze of fixes

* Review fixes

* Fixes

* Fixes

* Make each nested popover decide itself if it should open top

* Update changelog

* Update changelog

* Update changelog
2024-04-13 17:34:26 +00:00
Peter Savchenko 1320b047a2
feat(merge): blocks of different types can be merged (#2671)
* feature: possibilities to merge blocks of different types

* fix: remove scope change

* feat: use convert config instead of defined property

* chore:: use built-in function for type check

* fix: remove console.log

* chore: remove styling added by mistakes

* test: add testing for different blocks types merging

* fix: remove unused import

* fix: remove type argument

* fix: use existing functions for data export

* chore: update changelog

* fix: re put await

* fix: remove unnecessary check

* fix: typo in test name

* fix: re-add condition for merge

* test: add caret position test

* fix caret issues, add sanitize

* make if-else statement more clear

* upgrade cypress

* Update cypress.yml

* upd cypress to 13

* make sanitize test simpler

* patch rc version

---------

Co-authored-by: GuillaumeOnepilot <guillaume@onepilot.co>
Co-authored-by: Guillaume Leon <97881811+GuillaumeOnepilot@users.noreply.github.com>
2024-04-01 12:29:47 +03:00
Alex Yang b355f1673c
fix: strict css type (#2573)
Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
Co-authored-by: Ilya Maroz <37909603+ilyamore88@users.noreply.github.com>
2024-03-13 17:57:52 +03:00
Peter Savchenko ee6433201d
fix(block-tunes): enter keydown problems (#2650)
* debug enter press

* fix sync set caret

* fix enter keydown problems + tests addedd

* Update search-input.ts

* add changelog

* add useful log to cypress custom comand

* Update commands.ts
2024-03-13 17:30:16 +03:00
VikhorKonstantin 8138ce95b2
fix issue #2523 (#2639)
* fix isMutationBelongsToElement function: make it return true if the whole text node is deleted inside of some descendant of the passed element

* isMutationBelongsToElement function shouldn't return true if some of the ancestors of the passed element were added or deleted, only if the element itself

* add test case verifying that 'onChange' is fired when the whole text inside some nested  descendant of the block is removed

* replace introduced dependency with ToolMock

* add comment explaining isMutationBelongsToElement behaviour in case of adding/removing the passed element itself

* fix formatting

* added some more explanation

* added record to the changelog

---------

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2024-02-28 20:08:08 +03:00
Peter Savchenko b619946e8f
fix(slash): do not handle / + shift/alt, support for ascii keyboard (#2599)
* fix(slash): do not handle / + shift/alt, support for ascii keyboard

* support keyboards without physical '/'
2024-01-28 13:45:01 +03:00
Betty Steger 4bdf7a12b7
chore(on-change): check data-mutation-free of parent nodes (#2548)
* add data-mutation-free=deep

* just use closest and reduce waiting time in test

* Update src/components/block/index.ts

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* Update test/cypress/tests/onchange.cy.ts

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* add data-mutation-free=deep

* just use closest and reduce waiting time in test

* Update src/components/block/index.ts

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* Update test/cypress/tests/onchange.cy.ts

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* add line in Changelog

* Update docs/CHANGELOG.md

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* add support for characterData mutations

* Update onchange.cy.ts

---------

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2024-01-10 22:27:19 +03:00
Peter Savchenko 11925ca980
fix(caret): caret loosing on mobile devices (#2570)
* fix(caret): caret loosing on mobile devices

* rm unused import
2023-12-22 23:31:46 +03:00
Peter Savchenko cd29c52e51
feat(ui): native-like tab behaviour, slash for toolbox (#2569)
* slash to open toolbox, tab for navigation

* tab, focus improvements

- remove "focused" block state
- tab navigation respects inputs
- allow to focus contentless blocks

* fix tests

* tests for Slash

* tab tests

* test for tabbing out of editor

* tests fixed

* review fixes
2023-12-22 23:15:35 +03:00
Peter Savchenko c5854eea14
fix(inline-toolbar): appearance logic improved (#2550)
* fix(inline-toolbar): appearing logic improved

* tests added

* fix tests

* debounce added

* fix test build in github action

* increase closeTo delta for ff
2023-12-09 02:05:27 +03:00
Peter Savchenko 5e8fe06dd6
fix: errors caused by events fired while editor is not initialized yet (#2532)
* fix(init): errors cause by events fired while editor is not initialized yet

* Update package.json
2023-11-08 22:35:52 +03:00
Peter Savchenko ee188bfe5d
feat(config): new style.nonce option for CSP (#2519) 2023-10-23 01:08:26 +03:00
Peter Savchenko 35337747c5
fix(inline-toolbar): editor element grow on inline toolbar close (#2516) 2023-10-19 00:44:06 +03:00
Peter Savchenko 7d0db9b622
chore(patch): pull 2.28.1 patch to the next (#2507)
* fix(paste): delay onPaste call to be sure that block is ready (#2506)

* chore(package.json): increment patch version

* Update CHANGELOG.md
2023-10-11 20:28:16 +03:00
Peter Savchenko ec569f9981
fix(toolbar): layout shrink after blocks removing (#2484) 2023-09-20 11:07:25 +03:00
Peter Savchenko 0369ff5827
fix(renderer): handle empty array as data.blocks (#2454) 2023-09-05 11:24:47 +03:00
Peter Savchenko 42612a0fd9
chore(blocks.render): mutex for onchange added to the blocks.render() (#2449) 2023-08-21 12:28:31 +03:00
Peter Savchenko 922dfd8741
chore(api): blocks.update(id, data) method improved (#2443)
* add custom Chai assertion "be.calledWithBatchedEvents" for testing onchange

* chore(api): blocks.update(id, data) method improved

- `blocks.update(id, data)` now can accept partial data object — it will update only passed properties, others will remain the same.
- `blocks.update(id, data)` now will trigger onChange with only `block-change` event.
- `blocks.update(id, data)` will return a promise with BlockAPI object of changed block.

* fix tests

* Update blocks.cy.ts
2023-08-19 07:53:42 +03:00
Peter Savchenko b39996616c
chore(perf): initialisation and rendering performance optimisations (#2430)
* renderer batching

* initialization and rendering performance optimized

* insertMany api method added

* Update index.html

* rm old method

* upd changelog

* upd paragraph

* paste tests fixed

* api blocks tests fixed

* backspace event tests fixed

* async issues in tests fixed

* eslint

* stub block added, tests added

* eslint

* eslint

* add test for insertMany()

* Update package.json
2023-08-08 22:17:09 +03:00
Peter Savchenko 022320940e
feat(shortcuts): convert block by tools shortcut (#2419)
* feat(conversion): allow to convert block using shortcut

* display shortcuts in conversion toolbar

* tests for the blocks.convert

* tests for the toolbox shortcuts

* Update CHANGELOG.md

* Update toolbox.cy.ts

* rm unused imports

* firefox test fixed

* test errors via to.throw
2023-07-20 23:27:18 +03:00
Peter Savchenko b24bebbc40
feat(blocks-dom): block ids exported as data-id attribute (#2404) 2023-07-06 23:59:28 +03:00
Peter Savchenko 2ab9eb13bc
feat(block-events): delete keydown handling added (#2402)
* feat(block-events): delete keydown logic added

* chore(ui-events): delete keydown will remove selected blocks

* backspace tests added

* delete keydown tests

* tests for ui added

* fix ci

* separate block events tests for several files

* Delete BlockEvents.cy.ts

* rm unused change

* add code-review fixes + corner cases handling

* Update blockEvents.ts

* allow merging only same type blocks
2023-07-06 23:45:12 +03:00
Peter Savchenko 9e64003c0a
fix(onchange): support data-mutation-free on attributes chane (#2393) 2023-06-22 20:42:14 +03:00
Peter Savchenko c8993332e3
fix(onchange): callback will be fired on removing of a whole text (#2392)
* fix(onchange): callback will be fired when the whole text is removed in a block

* whops
2023-06-21 20:32:25 +03:00
Peter Savchenko b7b00fd060
chore(onChange): bugfix, batching, improvements of ModificationsObserver (#2349)
* block onchange stash

* improve block filtration

* update tool root

* chore(block): remove willSelect und willUnselect

* onchange events batching

* get rid of CustomEvent extension, create custom event map instead

* improve types of EventsDispatcher

* fix tests

* custom sinon + chai matchers

* improve tests, add mutex for fake cursor

* add test for fake-cursor mutex

* test for batch filtering

* fix caret setting by enter press at the end of the block

* test for detectToolRootChange

* remove resolved todos

* changelog added

* fix tests

* Update CHANGELOG.md

* rename FakeCursorAboutToBeSet -> FakeCursorAboutToBeToggled

* update didMutated statements

* move inputs cache clearing to a separate method

* rm Record inheritance from Event maps

* add type alisases

* rename isElementContainsFakeCursor ->  isFakeCursorInsideContainer

* improve code style
2023-05-12 20:50:48 +03:00
Taly aafab1d395
Use Vite builder (#2300)
* vite builder initial

* save

* add displayName

* add paragraph from npm

* fix postcss apply

* remove some packages, fix tests

* Update cypress.yml

* remove logs

* remove unused packages

* update path to image

* update

* Update index.html

* Update cypress.yml

* Update cypress.yml

* Update cypress.yml

* remove displayName field

* update names

* Update index.ts

* Update index.ts

* update packages

* remove packages

* postcss preserve: true

* Update index.html

* Update editor-modules.d.ts

* use public dir for static

* Update vite.config.js

* update modules type

* Update CHANGELOG.md
2023-04-13 22:25:29 +03:00
Guillaume Leon 0491155e33
feat(toolbar-api): method for toggling toolbox (#2332)
* Expose toolbox control method

* Add test for toolbox

* rename method to toggleToolbox

* add missing test case

* Add changelog

* remove eslint rule

* Update changelog

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* fix linter problems

---------

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2023-04-13 20:02:46 +03:00
Ilya Maroz 75379c66a9
deps(TypeScript) - upgrade to v5, upgrade ts-loader, fix types error, fix pasteConfig getter wrapper (#2322)
* deps: upgrade typescript to v5, upgrade ts-loader to support newest TS

* Fix (??) type of `pasteConfig`

TypeScript 4.9 found something is wrong with this code, but it's unclear (to me) which line is wrong. This PR is a guess, do with it what you will.

In paste.ts there's a check to see if `pasteConfig === false`:
https://github.com/codex-team/editor.js/blob/next/src/components/modules/paste.ts#L287

However, this getter never returns false because if the LHS of the `||` is `false`, `{ }` is returned instead.

It seems like this meant to be `??` instead so that if `this.constructable[InternalBlockToolSettings.PasteConfig]` was `undefined` (missing), then `{}` would be returned instead. But maybe you meant `false` here - I don't know.

* feat: create alias for PasteConfig, fix lint

* fix: problems with types

* test: add case for disabling preventing default behavior of paste event handler, add cases for pasteConfig getter in BlockTool wrapper

* chore: upgrade CHANGELOG.md

* fix: interface naming convention

* chore: apply CHANGELOG.md suggestion

* refactor: create custom Editor instance inside test case

* fix: remove editor instance destroy after PR feedback

---------

Co-authored-by: Ryan Cavanaugh <RyanCavanaugh@users.noreply.github.com>
2023-04-02 16:52:42 +01:00
Peter Savchenko 5257b061c4
fix(block): remember plugin's content element instead of dom search (#2311)
* fix(block): remember plugin's content element instead of dom search

* improve doc

* test case added
2023-03-20 23:28:17 +03:00
Anwar Hussain 86c84d8555
hotfix: add popular grammar checker extension node names (#2096)
* hotfix: add popular grammar checker extension node names

* fix: prettier messed the existing code style

* update the changelog

* Update docs/CHANGELOG.md

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* Update CHANGELOG.md

---------

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2023-03-15 12:27:25 +00:00
Kirk Douglas Jr 9ae96b9e17
fix(move-up-tune): scroll up offset for blocks above viewport (#2298)
* fix: scroll up offset for blocks above viewport

* Update CHANGELOG.md

* Update CHANGELOG.md

---------

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2023-03-14 00:09:04 +03:00
Peter Savchenko dfb07ec4e4
fix(tests): fire mutation event on tune activation (#2281)
* fix(onchange): fire mutation event if there are other changes along with mutation-free nodes

* update header dependency

* use node 16 for windows

* fix onChange firing by manual dispatchChange() call

* eslint

* use node 16 for ci tests

* Update CHANGELOG.md
2023-02-20 00:59:10 +02:00
Tatiana Fomina 07b1ce2aca
Chore/popover refactoring (#2249)
* Add new popover class

* Add flipper

* confirmation

* confirmation

* Add confirmation support

* Add search

* Add toggle group support and update popover tests

* Add custom content support

* Fix scroll issue

* Add mobile version

* Integration

* Fix animation

* Cleanup

* Fix popover position for narrow mode

* Fix tests

* Update version and changelog

* Rename css classes

* Move files

* Stop using PopoverItem from outside of popover context

* Fix jsdoc

* Move error animation to popover item

* Update css variables

* Update docs/CHANGELOG.md

Co-authored-by: Ilya Maroz <37909603+ilyamore88@users.noreply.github.com>

* Update src/components/block-tunes/block-tune-move-down.ts

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* Update src/components/block-tunes/block-tune-move-up.ts

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* Fixes

* Fix imports

* Fix toolbox close event

* Move search-input file

* Fix comment

* Rename method

* Cleanup

* Remove onFlip callback from popover item

* Rename

* Fix removing event listener

* Move popover animations to popover.css file

* Cleanup styles

* Fix jsdoc

* Fix confirmation chains

* Close toolbox oly when it's open

* Change activation error animation

* Update version and changelog

* Fix overlay

* Update icon border-radius on mobile

* Disable item text select

* Update changelog

* Update yarn.lock

* Add rc postfix to version

---------

Co-authored-by: Ilya Maroz <37909603+ilyamore88@users.noreply.github.com>
Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2023-02-10 21:29:58 +03:00
Tatiana Fomina 870e265af0
fix(tunes): Make label an alias for title in tunes menu item (#2198)
* Make label an alias for title in tunes item

* Cleanup

* Update version and changelog

* Update changelog

* Move resolveAlias to utils

* Add fallback for popover item title

* Lint

* Lint

* Add fallback icon and title to popover

* Update version

* Lint

* Fix changelog

* Fallback to empty string

This reverts commit ae9d643557.

* Fix changelog again

* Cleanup

* Add deprecated
2022-12-14 23:46:36 +03:00
Umang G. Patel c97f0842f5
fix(paste): handle pasteConfig with tag names specified in upper case (#2217)
* toLower case added

* regression test case added

* change log update

* version updated

* Apply suggestions from code review

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

* Update docs/CHANGELOG.md

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2022-12-14 14:25:02 +05:30
Tatiana Fomina b9a0665672
fix(tunes): make installed tunes render above default tunes (#2204)
* Fix tunes order

* Update version and changelog

* Fix tests
2022-12-06 16:32:57 +03:00
Tatiana Fomina 913ad0c8dc
feat: Add toggle group support (#2195)
* Add toggle group support

* Update version and changelog

* Fix

* Simplify

* Update test/cypress/tests/utils/popover.spec.ts

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2022-12-01 20:58:58 +03:00
Peter Savchenko 509023e307
chore(submodule): paragraph submodule updated with the new icons (#2191)
* do not show tooltip on mobile

* paragraph submodule updated with the new icon
2022-11-29 15:01:02 +04:00
Peter Savchenko d56c07c3dc
chore(icons): icons size increased for mobile devices (#2190)
* popover icons size increased on mobile devices

* update icon size on mobile

* some mobile styles improvements

* inline tools click on mobile devices improved
2022-11-29 12:02:23 +04:00
Peter Savchenko 1a72d2153b
fix(toolbox): shortcuts appearance fixed, icons became optional (#2188)
* fix(toolbox): shortcuts appearing fixed, icons became optional

* rm only from test

* Update tools.spec.ts

* rm useless tests

* Update CHANGELOG.md
2022-11-29 01:57:48 +04:00
Peter Savchenko 73c9bdf40b
fix(block-events): split block with removing of selected text fragment (#2186)
* fix(block-events): split block with removing of selected text fragment

* Update BlockEvents.spec.ts
2022-11-28 20:23:30 +04:00
Valerii Varankin 811a41366b
Fix: check for Files substitutions before handling files paste (#1928)
* FIX: Paste text from MS Word instead of image

* changelog added

* Update CHANGELOG.md

* rm submodule change

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2022-11-26 01:24:17 +04:00
azibodusi osain 9b7da504e4
feat(blocks-api): the insert() method now has the optional id param
* refactor: added id to the insert method  to allow user pass and existing id to the method

When  working with multiple editor at the same and need to link  all  blocks to each editor and keeping the same ids in all.

* moved the position of the block_id params to the end to aaviod breaking cha

* doc: updated  the  documentation on insert method params

* refactor :  formatted  the code to  add/remove  space

* refactor: moved the position of the `id` and its description to the respective position

* refactor: rollback to previous commit

* added back the removed default value

* fix error, remove garbage

* test added, changelog added

Co-authored-by: Umang G. Patel <23169768+robonetphy@users.noreply.github.com>
Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
2022-11-25 23:59:38 +04:00