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

Change viewportTopOffset config. Make viewportTopOffset writable in runtime #10352

Merged
merged 19 commits into from
Sep 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
f117389
Change viewportTopOffset config. Make viewportTopOffset writable in r…
dawidurbanski Aug 12, 2021
d114b6b
Update tests to use the new viewport offset config
dawidurbanski Aug 13, 2021
077ac57
Make manual test to use the new top offset config
dawidurbanski Aug 13, 2021
39597fd
Moved the observable #viewportOffset property to EditorUI.
oleq Aug 13, 2021
83b130c
Update TODO items. Polishing. Updating tests
dawidurbanski Aug 15, 2021
2e76bce
Add tests for _viewportOffset() method
dawidurbanski Aug 15, 2021
c0b4db3
Fix typo
dawidurbanski Aug 15, 2021
e4429e5
Update all docs snippets to use new ui.viewportOffset.top config prop…
dawidurbanski Aug 16, 2021
be2339d
Add docs to the new config.ui property
dawidurbanski Aug 16, 2021
5337e21
Remove deprecated viewportTopOffset property from toolbar feature docs
dawidurbanski Aug 23, 2021
262f33d
Revert imports in editorui.js
dawidurbanski Aug 23, 2021
0a703ef
Update docs to cross-reference viewportOffset config to viewportTopOf…
dawidurbanski Aug 23, 2021
6fc7a2f
Rename _viewportOffset() to _readViewportOffsetFromConfig(). Update t…
dawidurbanski Aug 23, 2021
b609fcf
Update console spy to check calledWithMatch instead of calledOnce
dawidurbanski Aug 23, 2021
81e8e69
Update ui.viewportOffset config property docs
dawidurbanski Aug 23, 2021
a83db5f
Better EditorUI viewportOffset example docs
dawidurbanski Aug 23, 2021
f8d6c76
Update manual tests to add case for changing vieport offset without f…
dawidurbanski Aug 23, 2021
240083f
Update low level UiView api docs
dawidurbanski Aug 23, 2021
4dd24a3
Extract test to check if warning is raised on legacy viewportTopOffse…
dawidurbanski Aug 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions docs/_snippets/builds/saving-data/autosave.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ document.querySelector( '#snippet-autosave-lag' ).addEventListener( 'change', ev
ClassicEditor
.create( document.querySelector( '#snippet-autosave' ), {
cloudServices: CS_CONFIG,
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
autosave: {
save( editor ) {
Expand Down
6 changes: 4 additions & 2 deletions docs/_snippets/builds/saving-data/manualsave.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ document.querySelector( '#snippet-manualsave-lag' ).addEventListener( 'change',
ClassicEditor
.create( document.querySelector( '#snippet-manualsave' ), {
cloudServices: CS_CONFIG,
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
}
} )
.then( editor => {
Expand Down
6 changes: 4 additions & 2 deletions docs/_snippets/examples/classic-editor-short.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud
ClassicEditor
.create( document.querySelector( '#snippet-classic-editor-short' ), {
cloudServices: CS_CONFIG,
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
}
} )
.then( editor => {
Expand Down
6 changes: 4 additions & 2 deletions docs/_snippets/examples/classic-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud
ClassicEditor
.create( document.querySelector( '#snippet-classic-editor' ), {
cloudServices: CS_CONFIG,
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
}
} )
.then( editor => {
Expand Down
8 changes: 6 additions & 2 deletions docs/_snippets/examples/custom-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ ClassicEditor
CloudServices
],
toolbar: {
items: [ 'bold', 'italic', 'underline', 'strikethrough', 'code', '|', 'highlight', '|', 'undo', 'redo' ],
viewportTopOffset: window.getViewportTopOffsetConfig()
items: [ 'bold', 'italic', 'underline', 'strikethrough', 'code', '|', 'highlight', '|', 'undo', 'redo' ]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
cloudServices: CS_CONFIG
} )
Expand Down
6 changes: 4 additions & 2 deletions docs/_snippets/examples/inline-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ const inlineInjectElements = document.querySelectorAll( '#snippet-inline-editor

Array.from( inlineInjectElements ).forEach( inlineElement => {
const config = {
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
cloudServices: CS_CONFIG
};
Expand Down
6 changes: 4 additions & 2 deletions docs/_snippets/features/image-upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud
ClassicEditor
.create( document.querySelector( '#snippet-image-upload' ), {
cloudServices: CS_CONFIG,
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
}
} )
.then( editor => {
Expand Down
8 changes: 6 additions & 2 deletions docs/_snippets/features/mathtype.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ ClassicEditor
'|',
'undo',
'redo'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
image: {
toolbar: [
Expand Down
6 changes: 4 additions & 2 deletions docs/_snippets/features/read-only.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud
ClassicEditor
.create( document.querySelector( '#snippet-read-only' ), {
cloudServices: CS_CONFIG,
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
}
} )
.then( editor => {
Expand Down
8 changes: 6 additions & 2 deletions docs/_snippets/features/toolbar-breakpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ ClassicEditor
'uploadImage', 'blockQuote', '|',
'undo', 'redo'
],
shouldNotGroupWhenFull: true,
viewportTopOffset: window.getViewportTopOffsetConfig()
shouldNotGroupWhenFull: true
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
image: {
toolbar: [ 'imageStyle:inline', 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ]
Expand Down
8 changes: 6 additions & 2 deletions docs/_snippets/features/toolbar-grouping.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ ClassicEditor
'outdent', 'indent', '|',
'uploadImage', 'blockQuote', '|',
'undo', 'redo'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
image: {
toolbar: [ 'imageStyle:inline', 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ]
Expand Down
8 changes: 6 additions & 2 deletions docs/_snippets/features/toolbar-wrapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,12 @@ ClassicEditor
'uploadImage', 'blockQuote', '|',
'undo', 'redo'
],
shouldNotGroupWhenFull: true,
viewportTopOffset: window.getViewportTopOffsetConfig()
shouldNotGroupWhenFull: true
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
image: {
toolbar: [ 'imageStyle:inline', 'imageStyle:block', 'imageStyle:side', '|', 'toggleImageCaption', 'imageTextAlternative' ]
Expand Down
6 changes: 4 additions & 2 deletions docs/_snippets/features/ui-language-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ ClassicEditor
content: 'ar'
},
cloudServices: CS_CONFIG,
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
}
} )
.then( editor => {
Expand Down
6 changes: 4 additions & 2 deletions docs/_snippets/features/ui-language-rtl.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ ClassicEditor
.create( document.querySelector( '#snippet-ui-language-rtl' ), {
language: 'ar',
cloudServices: CS_CONFIG,
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
}
} )
.then( editor => {
Expand Down
6 changes: 4 additions & 2 deletions docs/_snippets/features/ui-language.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ ClassicEditor
.create( document.querySelector( '#snippet-ui-language' ), {
language: 'es',
cloudServices: CS_CONFIG,
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
}
} )
.then( editor => {
Expand Down
8 changes: 6 additions & 2 deletions docs/_snippets/features/wproofreader.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ ClassicEditor
'|',
'undo',
'redo'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
image: {
toolbar: [
Expand Down
6 changes: 4 additions & 2 deletions docs/_snippets/framework/development-tools/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import { CS_CONFIG } from '@ckeditor/ckeditor5-cloud-services/tests/_utils/cloud
ClassicEditor
.create( document.querySelector( '#snippet-classic-editor' ), {
cloudServices: CS_CONFIG,
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig()
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
}
} )
.then( editor => {
Expand Down
8 changes: 6 additions & 2 deletions docs/_snippets/framework/tutorials/block-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,12 @@ ClassicEditor
.create( document.querySelector( '#snippet-block-widget' ), {
plugins: [ Essentials, Bold, Italic, Heading, List, Paragraph, SimpleBox ],
toolbar: {
items: [ 'heading', '|', 'bold', 'italic', 'numberedList', 'bulletedList', 'simpleBox' ],
viewportTopOffset: window.getViewportTopOffsetConfig()
items: [ 'heading', '|', 'bold', 'italic', 'numberedList', 'bulletedList', 'simpleBox' ]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
}
} )
.then( editor => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ <h3>Products</h3>
ProductPreviewEditing
],
toolbar: {
viewportTopOffset: window.getViewportTopOffsetConfig(),
items: [
'heading',
'|',
Expand All @@ -243,6 +242,11 @@ <h3>Products</h3>
'undo', 'redo'
]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
table: {
contentToolbar: [
'tableColumn',
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/snippet-styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

:root {
/* This custom property is read by the JS and passed to editor configurations
as config.toolbar.viewportTopOffset. */
as config.ui.viewportOffset.top. */
--ck-snippet-viewport-top-offset: 100
}

Expand Down
2 changes: 1 addition & 1 deletion docs/assets/snippet.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ window.createNotification = function( title, message ) {
};

/**
* Returns the `config.toolbar.viewportTopOffset` config value for editors using floating toolbars that
* Returns the `config.ui.viewportOffset.top` config value for editors using floating toolbars that
* stick to the top of the viewport to remain visible to the user.
*
* The value is determined in styles by the `--ck-snippet-viewport-top-offset` custom property
Expand Down
3 changes: 0 additions & 3 deletions docs/features/toolbar.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ You can use the extended {@link module:core/editor/editorconfig~EditorConfig#too
```js
toolbar: {
items: [ 'bold', 'italic', '|', 'undo', 'redo', '-', 'numberedList', 'bulletedList' ],
viewportTopOffset: 30,
shouldNotGroupWhenFull: true
}
```
Expand All @@ -73,8 +72,6 @@ toolbar: {

* **`removeItems`** &ndash; An array of toolbar item names. With this setting you can modify the default toolbar configuration without the need of defining the entire list (you can specify a couple of buttons that you want to remove instead of specifying all the buttons you want to keep). If, after removing an item, toolbar will have two or more consecutive separators (`'|'`), the duplicates will be removed automatically.

* **`viewportTopOffset`** &ndash; The offset (in pixels) from the top of the viewport used when positioning a sticky toolbar. Useful when a page with which the editor is being integrated has some other sticky or fixed elements (e.g. the top menu). Thanks to setting the toolbar offset, the toolbar will not be positioned underneath or above the page's UI.

* **`shouldNotGroupWhenFull`** &ndash; When set to `true`, the toolbar will stop grouping items and let them wrap to the next line when there is not enough space to display them in a single row. This setting is `false` by default, which enables items grouping.

The demo below presents the "regular" toolbar look with `shouldNotGroupWhenFull` set to `false`. If there are excess toolbar items for the display width, the toolbar gets grouped and some of the items are accessible via the clickable "Show more items" (⋮) button.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ ClassicEditor
'alignment',
'undo',
'redo'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
alignment: {
options: [ 'left', 'right' ]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ ClassicEditor
toolbar: {
items: [
'heading', '|', 'alignment:left', 'alignment:right', 'alignment:center', 'alignment:justify'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
cloudServices: CS_CONFIG
} )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ ClassicEditor
'alignment',
'undo',
'redo'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
cloudServices: CS_CONFIG
} )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ ClassicEditor
'|',
'undo',
'redo'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
cloudServices: CS_CONFIG
} )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ ClassicEditor
toolbar: {
items: [
'bold', 'italic', 'underline', 'strikethrough', 'subscript', 'superscript', 'code', '|', 'removeFormat', '|', 'undo', 'redo'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
cloudServices: CS_CONFIG
} )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ ClassicEditor.defaultConfig = {
'|',
'undo',
'redo'
],
viewportTopOffset: window.getViewportTopOffsetConfig()
]
},
ui: {
viewportOffset: {
top: window.getViewportTopOffsetConfig()
}
},
image: {
toolbar: [ 'imageTextAlternative' ]
Expand Down
Loading