-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Tiptap RTE: Style Menu extension kind #18918
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 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a40fbf9
Adds 'styleMenu' Tiptap toolbar extension kind
leekelleher e86cf12
Adds icons for `<h4>` and `<p>` tags
leekelleher 9ec2886
Adds commands to HTML Global Attributes extension
leekelleher 143ef49
Renamed "default-tiptap-toolbar-element.api.ts" file
leekelleher 6f50aca
Toolbar Menu: uses correct `item` value
leekelleher 97bbd01
Cascading Menu: adds localization for the label
leekelleher 5345529
Adds `label` attribute to UUI components
leekelleher bea0e40
Toolbar Menu: uses correct `appearance` value
leekelleher 59d3000
Removed unrequired `api` from Style Select
leekelleher 456f1eb
Destructs the `item.data` object
leekelleher 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
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
1 change: 1 addition & 0 deletions
1
src/Umbraco.Web.UI.Client/src/packages/core/icon-registry/icons/icon-heading-4.ts
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 @@ | ||
| export default `<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" class="lucide lucide-heading-4" viewBox="0 0 24 24"><path d="M12 18V6M17 10v3a1 1 0 0 0 1 1h3M21 10v8M4 12h8M4 18V6"/></svg>`; |
1 change: 1 addition & 0 deletions
1
src/Umbraco.Web.UI.Client/src/packages/core/icon-registry/icons/icon-paragraph.ts
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 @@ | ||
| export default `<svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.75" class="lucide lucide-pilcrow" viewBox="0 0 24 24"><path d="M13 4v16M17 4v16M19 4H9.5a4.5 4.5 0 0 0 0 9H13"/></svg>`; |
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
File renamed without changes.
33 changes: 33 additions & 0 deletions
33
...aco.Web.UI.Client/src/packages/tiptap/components/toolbar/style-menu.tiptap-toolbar-api.ts
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,33 @@ | ||
| import { UmbTiptapToolbarElementApiBase } from '../../extensions/base.js'; | ||
| import type { MetaTiptapToolbarStyleMenuItem } from '../../extensions/types.js'; | ||
| import type { ChainedCommands, Editor } from '@umbraco-cms/backoffice/external/tiptap'; | ||
|
|
||
| export default class UmbTiptapToolbarStyleMenuApi extends UmbTiptapToolbarElementApiBase { | ||
| #commands: Record<string, { type: string; command: (chain: ChainedCommands) => ChainedCommands }> = { | ||
| h1: { type: 'heading', command: (chain) => chain.toggleHeading({ level: 1 }) }, | ||
| h2: { type: 'heading', command: (chain) => chain.toggleHeading({ level: 2 }) }, | ||
| h3: { type: 'heading', command: (chain) => chain.toggleHeading({ level: 3 }) }, | ||
| h4: { type: 'heading', command: (chain) => chain.toggleHeading({ level: 4 }) }, | ||
| h5: { type: 'heading', command: (chain) => chain.toggleHeading({ level: 5 }) }, | ||
| h6: { type: 'heading', command: (chain) => chain.toggleHeading({ level: 6 }) }, | ||
| p: { type: 'paragraph', command: (chain) => chain.setParagraph() }, | ||
| blockquote: { type: 'blockquote', command: (chain) => chain.toggleBlockquote() }, | ||
| code: { type: 'code', command: (chain) => chain.toggleCode() }, | ||
| codeBlock: { type: 'codeBlock', command: (chain) => chain.toggleCodeBlock() }, | ||
| div: { type: 'div', command: (chain) => chain.toggleNode('div', 'paragraph') }, | ||
| em: { type: 'italic', command: (chain) => chain.setItalic() }, | ||
| ol: { type: 'orderedList', command: (chain) => chain.toggleOrderedList() }, | ||
| strong: { type: 'bold', command: (chain) => chain.setBold() }, | ||
| s: { type: 'strike', command: (chain) => chain.setStrike() }, | ||
| span: { type: 'span', command: (chain) => chain.toggleMark('span') }, | ||
| u: { type: 'underline', command: (chain) => chain.setUnderline() }, | ||
| ul: { type: 'bulletList', command: (chain) => chain.toggleBulletList() }, | ||
| }; | ||
|
|
||
| override execute(editor?: Editor, item?: MetaTiptapToolbarStyleMenuItem) { | ||
| if (!editor || !item?.data) return; | ||
| const focus = editor.chain().focus(); | ||
| const ext = item.data.tag ? this.#commands[item.data.tag] : null; | ||
| (ext?.command?.(focus) ?? focus).setId(item.data.id, ext?.type).setClassName(item.data.class, ext?.type).run(); | ||
| } | ||
|
Check warning on line 32 in src/Umbraco.Web.UI.Client/src/packages/tiptap/components/toolbar/style-menu.tiptap-toolbar-api.ts
|
||
| } | ||
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
65 changes: 42 additions & 23 deletions
65
src/Umbraco.Web.UI.Client/src/packages/tiptap/extensions/style-select/manifests.ts
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 |
|---|---|---|
| @@ -1,35 +1,54 @@ | ||
| export const manifests: Array<UmbExtensionManifest> = [ | ||
| { | ||
| type: 'tiptapToolbarExtension', | ||
| kind: 'menu', | ||
| kind: 'styleMenu', | ||
| alias: 'Umb.Tiptap.Toolbar.StyleSelect', | ||
| name: 'Style Select Tiptap Extension', | ||
| api: () => import('./style-select.tiptap-toolbar-api.js'), | ||
| items: [ | ||
| { | ||
| label: 'Headers', | ||
| items: [ | ||
| { | ||
| label: 'Page header', | ||
| appearance: { icon: 'icon-heading-2', style: 'font-size: x-large;font-weight: bold;' }, | ||
| data: { tag: 'h2' }, | ||
| }, | ||
| { | ||
| label: 'Section header', | ||
| appearance: { icon: 'icon-heading-3', style: 'font-size: large;font-weight: bold;' }, | ||
| data: { tag: 'h3' }, | ||
| }, | ||
| { | ||
| label: 'Paragraph header', | ||
| appearance: { icon: 'icon-heading-4', style: 'font-weight: bold;' }, | ||
| data: { tag: 'h4' }, | ||
| }, | ||
| ], | ||
| }, | ||
| { | ||
| label: 'Blocks', | ||
| items: [{ label: 'Paragraph', appearance: { icon: 'icon-paragraph' }, data: { tag: 'p' } }], | ||
| }, | ||
| { | ||
| label: 'Containers', | ||
| items: [ | ||
| { | ||
| label: 'Block quote', | ||
| appearance: { icon: 'icon-blockquote', style: 'font-style: italic;' }, | ||
| data: { tag: 'blockquote' }, | ||
| }, | ||
| { | ||
| label: 'Code block', | ||
| appearance: { icon: 'icon-code', style: 'font-family: monospace;' }, | ||
| data: { tag: 'codeBlock' }, | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| meta: { | ||
| alias: 'umbStyleSelect', | ||
| icon: 'icon-palette', | ||
| label: 'Style Select', | ||
| items: [ | ||
| { | ||
| label: 'Headers', | ||
| items: [ | ||
| { label: 'Page header', data: 'h2', style: 'font-size: x-large;font-weight: bold;' }, | ||
| { label: 'Section header', data: 'h3', style: 'font-size: large;font-weight: bold;' }, | ||
| { label: 'Paragraph header', data: 'h4', style: 'font-weight: bold;' }, | ||
| ], | ||
| }, | ||
| { | ||
| label: 'Blocks', | ||
| items: [{ label: 'Paragraph', data: 'p' }], | ||
| }, | ||
| { | ||
| label: 'Containers', | ||
| items: [ | ||
| { label: 'Quote', data: 'blockquote', style: 'font-style: italic;' }, | ||
| { label: 'Code', data: 'codeBlock', style: 'font-family: monospace;' }, | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| }, | ||
| ]; |
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.