-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(inline-tools): Inline tools rendered as popover #2718
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
Merged
Merged
Changes from 118 commits
Commits
Show all changes
128 commits
Select commit
Hold shift + click to select a range
392ff54
Add custom item
TatianaFomina 0d506c2
Remove customcontent parameter from popover
TatianaFomina bf3bffb
Tests
TatianaFomina d93cdea
Cleanup
TatianaFomina 6fe4b44
Cleanup
TatianaFomina a70eeae
Lint
TatianaFomina f398168
Cleanup
TatianaFomina af24b9c
Rename custom to html, add enum with item types
TatianaFomina 005e170
Fix tests
TatianaFomina 3ed7f7e
Support hint
TatianaFomina b713e63
Merge branch 'next' into feat/popover-hint
TatianaFomina 26053ad
Rename hint content to hint
TatianaFomina 9b30fac
Align hint left
TatianaFomina 34e3f1e
Move types and exports
TatianaFomina 04f2851
Merge branch 'next' into feat/hint-2
TatianaFomina b0b2e29
Update changelog
TatianaFomina 7f053d9
Cleanup
TatianaFomina 17982a6
Add todos
TatianaFomina 5c7415c
Change the way hint is disabled for mobile
TatianaFomina 7e90001
Get rid of buildItems override
TatianaFomina 4daf8f9
Update comment
TatianaFomina 53a6cbd
tmp
TatianaFomina 95685db
Positioning
TatianaFomina 65e30e9
Add convert to
TatianaFomina 0f34f0f
Make conversion menu searchable
TatianaFomina 6383acf
Toggling actions
TatianaFomina ecc8204
Cleanup
TatianaFomina 1a1120a
Progress
TatianaFomina 7b67565
Cleanup
TatianaFomina 10ef904
Progress
TatianaFomina 4d7befc
Merge branch 'next' into feat/popover-horizontal
TatianaFomina acb5d82
Hint alignment
TatianaFomina 1700b62
Hide tooltip on popover close
TatianaFomina adf1bec
Button sizes
TatianaFomina 7a6b361
Fix positioning
TatianaFomina adadfe8
Remove info about conversion toolbar
TatianaFomina 5a8d23d
Fix ts/eslint warnings
TatianaFomina 16e0560
Fix closeOnActivate for nested popover
TatianaFomina e5e0a5d
Remove conversion styles
TatianaFomina e945a01
Cleanup
TatianaFomina a86faf4
Conversion label
TatianaFomina c5899e7
Close nested popover on outclick
TatianaFomina cf768c2
Close nested popover on other item click
TatianaFomina 80f930f
Fix invisible nested popover on mobile
TatianaFomina f5ce3b8
Styles
TatianaFomina dd22923
Fix selection problem on nested popover open
TatianaFomina eeb4271
Comment
TatianaFomina 76d4ecc
Styles updates
TatianaFomina 0d34bce
Fix selection issue
TatianaFomina 72bd1e9
Merge branch 'next' into feat/popover-horizontal
TatianaFomina fd45af8
Lint
TatianaFomina ed18292
Update bold tool
TatianaFomina fc64f13
Fix sanitize test
TatianaFomina 075f6f8
Fix link tool shortcut
TatianaFomina 73eb18a
Lint
TatianaFomina 8a14940
Fix link bug
TatianaFomina ef9c169
Fix inline toolbar tests
TatianaFomina e50c437
Fix safari bug
TatianaFomina 134ec7b
Add convert to hint
TatianaFomina af58965
Fix icon sizes
TatianaFomina 6752f9c
Unify active state
TatianaFomina f8a93aa
Fix tests
TatianaFomina 8ae5465
Change inline tools order for header in index.html
TatianaFomina 8700f84
Rewrite getConvertToItems util with editor api
TatianaFomina 834391c
Rename
TatianaFomina f71a4a3
Lint
TatianaFomina d5a8ed0
Fix colors in mobile safari
TatianaFomina c1e9807
Hide hint on mobile for inline popover
TatianaFomina d28c66e
Revert "Rewrite getConvertToItems util with editor api"
TatianaFomina bde339f
Revert "Rename"
TatianaFomina aa17a98
Move getConvertToItems() to conversion module
TatianaFomina 52b0bb4
Update comment
TatianaFomina d9da2fc
Use const
TatianaFomina b88e184
Add some tests
TatianaFomina fd855cf
Update changelog
TatianaFomina 8e83f0e
Replace div with button in popover-item-default
TatianaFomina 19e94b9
Fix import
TatianaFomina dfa849d
Use isToolConvertable
TatianaFomina 38776c0
fixup! Replace div with button in popover-item-default
TatianaFomina 840532f
fixup! Replace div with button in popover-item-default
TatianaFomina b4b9a9a
Lint
TatianaFomina 4432e5a
Update types
TatianaFomina 24e54b5
Better renderActions handling
TatianaFomina 37ccf2f
fixup! Update types
TatianaFomina 29dc873
Lint
TatianaFomina 407fa3f
Remove getActiveToolboxEntryOfBlock
TatianaFomina 0128650
Call querySelector on popoverEl instead of document
TatianaFomina ace83f1
Clarify hasAutoFocusableElements
TatianaFomina 6312177
rename setTriggerItemPositionProperty
TatianaFomina 97e1f7a
Add comment about nesting level
TatianaFomina 18f5899
Move adding css class .ce-popover--nested-level-1 to inline popover
TatianaFomina 6d535fa
add destroy for search
TatianaFomina 960c8fa
Fix comments
TatianaFomina 84dcad9
Rename events
TatianaFomina 9fc2221
Rename isExpanded to isOpen
TatianaFomina 7543506
Fix comment
TatianaFomina c8b2fde
Replace comment with return
TatianaFomina 76261fd
Rename events
TatianaFomina eb77804
Deprecate TunesMenuConfig
TatianaFomina 848a49f
Update tools
TatianaFomina dd39c61
Fixes
TatianaFomina 66ebe0f
Convert to as tool
TatianaFomina be27d82
Save selection inside conversion tool
TatianaFomina f60624a
Remove redundant events
TatianaFomina d8e3621
Force add convertTo
TatianaFomina a67cc10
Remove hardcoded conversion menu
TatianaFomina 9e1f822
Fix for mobile
TatianaFomina 9a992d7
Fix padding
TatianaFomina 4b5f980
Merge branch 'next' into feat/popover-horizontal
TatianaFomina b7ca60e
Clear toolsInstances
TatianaFomina 81e6584
Add activateItemByName()
TatianaFomina 877193a
Deprecate Inline tool's surround and checkState
TatianaFomina f69bf96
Lint
TatianaFomina 460da98
Remove getCurrentSelection API method
TatianaFomina 9e0e837
Use getConvertibleToolsForBlock fn
TatianaFomina 49b85ea
Use getConvertibleToolsForBlock in Block Tunes
TatianaFomina e67ff5c
Remove Conversion module
TatianaFomina fdeef79
Return TunesMenuConfigItem type
TatianaFomina 603e177
Clarify comment
TatianaFomina b2a02f8
Use block.save() instead of data
TatianaFomina 84287c1
Fix exported block api
TatianaFomina 8cb10ab
Add inline toolbar tests and lint
TatianaFomina 07347ed
Update changelog
TatianaFomina 872b012
Fix tests
TatianaFomina 0e1774e
Lint
TatianaFomina 45a5b63
Clarify comments
TatianaFomina d875ebc
Align left
TatianaFomina 9dc3fdb
Update input style
TatianaFomina File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule checklist
updated
12 files
+28 −5 | .github/workflows/npm-publish.yml | |
+1 −2 | .npmignore | |
+20 −3 | README.md | |
+ − | ...70656c6c612e706963732f66303939646439622d313332312d343766362d623965312d3937666331656634306236612e6a7067.jpeg | |
+17 −20 | package.json | |
+0 −7 | postcss.config.js | |
+40 −88 | src/index.css | |
+4 −25 | src/index.js | |
+5 −5 | src/utils.js | |
+0 −23 | vite.config.js | |
+44 −0 | webpack.config.js | |
+3,528 −219 | yarn.lock |
Submodule code
updated
9 files
+1 −1 | .github/workflows/npm-publish.yml | |
+1 −1 | .npmignore | |
+3 −0 | .postcssrc | |
+132 −0 | .stylelintrc | |
+20 −3 | README.md | |
+13 −17 | package.json | |
+0 −23 | vite.config.js | |
+34 −0 | webpack.config.js | |
+3,427 −180 | yarn.lock |
Submodule delimiter
updated
8 files
+28 −5 | .github/workflows/npm-publish.yml | |
+1 −1 | .npmignore | |
+23 −6 | README.md | |
+ − | ...70656c6c612e706963732f64653730653766382d353663642d343737392d383438662d3532633366363864656234372e6a7067.jpeg | |
+14 −16 | package.json | |
+0 −23 | vite.config.js | |
+34 −0 | webpack.config.js | |
+3,910 −185 | yarn.lock |
Submodule embed
updated
12 files
+7 −3 | .babelrc | |
+1 −1 | .github/workflows/npm-publish.yml | |
+0 −4 | .github/workflows/test.yml | |
+1 −2 | .npmignore | |
+14 −4 | README.md | |
+17 −22 | package.json | |
+0 −6 | postcss.config.js | |
+4 −12 | src/services.js | |
+2 −28 | test/services.js | |
+0 −23 | vite.config.js | |
+40 −0 | webpack.config.js | |
+2,777 −1,368 | yarn.lock |
Submodule image
updated
12 files
+11 −0 | .babelrc | |
+28 −5 | .github/workflows/npm-publish.yml | |
+1 −2 | .npmignore | |
+23 −19 | README.md | |
+1 −4 | dev/server.js | |
+17 −17 | package.json | |
+0 −7 | postcss.config.js | |
+10 −11 | src/index.css | |
+5 −5 | src/index.js | |
+0 −23 | vite.config.js | |
+49 −0 | webpack.config.js | |
+3,023 −258 | yarn.lock |
Submodule inline-code
updated
7 files
+28 −5 | .github/workflows/npm-publish.yml | |
+1 −1 | .npmignore | |
+20 −3 | README.md | |
+13 −16 | package.json | |
+0 −23 | vite.config.js | |
+42 −0 | webpack.config.js | |
+3,411 −183 | yarn.lock |
Submodule link
updated
9 files
+4 −0 | .babelrc | |
+28 −5 | .github/workflows/npm-publish.yml | |
+2 −2 | .npmignore | |
+16 −3 | README.md | |
+15 −16 | package.json | |
+0 −6 | postcss.config.js | |
+0 −23 | vite.config.js | |
+41 −0 | webpack.config.js | |
+3,606 −226 | yarn.lock |
Submodule list
updated
from a6dc6a to f0e9f0
Submodule marker
updated
7 files
+28 −5 | .github/workflows/npm-publish.yml | |
+1 −1 | .npmignore | |
+20 −3 | README.md | |
+13 −16 | package.json | |
+0 −23 | vite.config.js | |
+42 −0 | webpack.config.js | |
+3,411 −183 | yarn.lock |
Submodule nested-list
updated
from 95b374 to 53a12f
Submodule quote
updated
7 files
+28 −5 | .github/workflows/npm-publish.yml | |
+1 −1 | .npmignore | |
+20 −3 | README.md | |
+14 −17 | package.json | |
+0 −23 | vite.config.js | |
+42 −0 | webpack.config.js | |
+3,453 −183 | yarn.lock |
Submodule raw
updated
10 files
+83 −0 | .eslintrc | |
+28 −5 | .github/workflows/npm-publish.yml | |
+4 −1 | .npmignore | |
+3 −0 | .postcssrc | |
+132 −0 | .stylelintrc | |
+20 −3 | README.md | |
+12 −16 | package.json | |
+0 −23 | vite.config.js | |
+34 −0 | webpack.config.js | |
+3,818 −179 | yarn.lock |
Submodule table
updated
13 files
+28 −5 | .github/workflows/npm-publish.yml | |
+1 −1 | .npmignore | |
+5 −14 | README.md | |
+ − | ...70656c6c612e706963732f34313239346365632d613262332d343135372d383339392d6666656665643364386666642e6a7067.jpeg | |
+11 −18 | package.json | |
+7 −0 | src/img/toolboxIcon.svg | |
+0 −44 | src/plugin.js | |
+2 −2 | src/styles/table.pcss | |
+2 −2 | src/table.js | |
+14 −15 | src/toolbox.js | |
+0 −23 | vite.config.js | |
+28 −0 | webpack.config.js | |
+2,008 −197 | yarn.lock |
Submodule warning
updated
9 files
+28 −5 | .github/workflows/npm-publish.yml | |
+1 −1 | .npmignore | |
+21 −4 | README.md | |
+ − | assets/2d7b7bc1-ac46-4020-89c9-390d1a7297e2.jpg | |
+13 −16 | package.json | |
+1 −1 | src/index.js | |
+0 −23 | vite.config.js | |
+38 −0 | webpack.config.js | |
+3,584 −183 | yarn.lock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { IconReplace } from '@codexteam/icons'; | ||
import { InlineTool, API } from '../../../types'; | ||
import { MenuConfig } from '../../../types/tools'; | ||
import * as _ from '../utils'; | ||
import { Blocks, Selection, Tools, I18n, Caret } from '../../../types/api'; | ||
import SelectionUtils from '../selection'; | ||
import { getConvertibleToolsForBlock } from '../utils/blocks'; | ||
|
||
/** | ||
* Inline tools for converting blocks | ||
*/ | ||
export default class ConvertInlineTool implements InlineTool { | ||
/** | ||
* Specifies Tool as Inline Toolbar Tool | ||
*/ | ||
public static isInline = true; | ||
|
||
/** | ||
* API for working with editor blocks | ||
*/ | ||
private readonly blocksAPI: Blocks; | ||
|
||
/** | ||
* API for working with Selection | ||
*/ | ||
private readonly selectionAPI: Selection; | ||
|
||
/** | ||
* API for working with Tools | ||
*/ | ||
private readonly toolsAPI: Tools; | ||
|
||
/** | ||
* I18n API | ||
*/ | ||
private readonly i18nAPI: I18n; | ||
|
||
/** | ||
* API for working with Caret | ||
*/ | ||
private readonly caretAPI: Caret; | ||
|
||
/** | ||
* @param api - Editor.js API | ||
*/ | ||
constructor({ api }: { api: API }) { | ||
this.i18nAPI = api.i18n; | ||
this.blocksAPI = api.blocks; | ||
this.selectionAPI = api.selection; | ||
this.toolsAPI = api.tools; | ||
this.caretAPI = api.caret; | ||
} | ||
|
||
/** | ||
* Returns tool's UI config | ||
*/ | ||
public async render(): Promise<MenuConfig> { | ||
const currentSelection = SelectionUtils.get(); | ||
const currentBlock = this.blocksAPI.getBlockByElement(currentSelection.anchorNode as HTMLElement); | ||
const allBlockTools = this.toolsAPI.getBlockTools(); | ||
const convertibleTools = await getConvertibleToolsForBlock(currentBlock, allBlockTools); | ||
|
||
if (convertibleTools.length === 0) { | ||
return []; | ||
} | ||
|
||
const convertToItems = convertibleTools.reduce((result, tool) => { | ||
tool.toolbox.forEach((toolboxItem) => { | ||
result.push({ | ||
icon: toolboxItem.icon, | ||
title: toolboxItem.title, | ||
name: tool.name, | ||
closeOnActivate: true, | ||
onActivate: async () => { | ||
const newBlock = await this.blocksAPI.convert(currentBlock.id, tool.name, toolboxItem.data); | ||
|
||
this.caretAPI.setToBlock(newBlock, 'end'); | ||
}, | ||
}); | ||
}); | ||
|
||
return result; | ||
}, []); | ||
|
||
const currentBlockToolboxItem = await currentBlock.getActiveToolboxEntry(); | ||
const icon = currentBlockToolboxItem !== undefined ? currentBlockToolboxItem.icon : IconReplace; | ||
const isDesktop = !_.isMobileScreen(); | ||
|
||
return { | ||
icon, | ||
name: 'convert-to', | ||
hint: { | ||
title: this.i18nAPI.t('Convert to'), | ||
}, | ||
children: { | ||
searchable: isDesktop, | ||
items: convertToItems, | ||
onOpen: () => { | ||
if (isDesktop) { | ||
this.selectionAPI.setFakeBackground(); | ||
this.selectionAPI.save(); | ||
} | ||
}, | ||
onClose: () => { | ||
if (isDesktop) { | ||
this.selectionAPI.restore(); | ||
this.selectionAPI.removeFakeBackground(); | ||
} | ||
}, | ||
}, | ||
}; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Tools as ToolsAPIInterface } from '../../../../types/api'; | ||
import Module from '../../__module'; | ||
|
||
/** | ||
* Provides methods for accessing installed Editor tools | ||
*/ | ||
export default class ToolsAPI extends Module { | ||
/** | ||
* Available methods | ||
*/ | ||
public get methods(): ToolsAPIInterface { | ||
return { | ||
getBlockTools: () => Array.from(this.Editor.Tools.blockTools.values()), | ||
}; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.