-
Notifications
You must be signed in to change notification settings - Fork 50
feat: Inline editing - Rich text #1976
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dea396f
feat: Inline editing - Rich text
enjeck f632d8f
fix: Make inline editing rich text work
enjeck 8a27cb5
fix: Do not switch to edit mode if click on widget
enjeck da3c905
fix: Allow link previews without edit mode
enjeck 71705c7
fix: typo in function name
enjeck 594b45d
enh: Update saving check
enjeck 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| <!-- | ||
| - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| - SPDX-License-Identifier: AGPL-3.0-or-later | ||
| --> | ||
| <template> | ||
| <div ref="editingContainer" | ||
| class="rich-editor-edit-mode" | ||
| @keydown.escape.prevent="cancelEdit"> | ||
| <NcEditor | ||
| :can-edit="true" | ||
| :text.sync="localValue" | ||
| :show-border="false" | ||
| :show-readonly-bar="false" | ||
| :show-menu-bar="false" /> | ||
| <div v-if="loading" class="loading-indicator"> | ||
| <div class="icon-loading-small icon-loading-inline" /> | ||
| </div> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script> | ||
| import NcEditor from '../../ncEditor/NcEditor.vue' | ||
| import { translate as t } from '@nextcloud/l10n' | ||
|
|
||
| export default { | ||
| name: 'RichEditor', | ||
|
|
||
| components: { | ||
| NcEditor, | ||
| }, | ||
|
|
||
| props: { | ||
| value: { | ||
| type: String, | ||
| default: '', | ||
| }, | ||
| loading: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| }, | ||
|
|
||
| data() { | ||
| return { | ||
| localValue: this.value || '', | ||
| isInitialEditClick: false, | ||
| } | ||
| }, | ||
|
|
||
| watch: { | ||
| value(newValue) { | ||
| this.localValue = newValue || '' | ||
| }, | ||
| }, | ||
|
|
||
| mounted() { | ||
| // Add click outside listener after the current event loop | ||
| // to avoid the same click that triggered editing from closing the editor | ||
| this.$nextTick(() => { | ||
| document.addEventListener('click', this.handleClickOutside) | ||
| }) | ||
| }, | ||
|
|
||
| beforeDestroy() { | ||
| document.removeEventListener('click', this.handleClickOutside) | ||
| }, | ||
|
|
||
| methods: { | ||
| t, | ||
|
|
||
| notifyEditingStarted() { | ||
| this.isInitialEditClick = true | ||
| }, | ||
|
|
||
| handleClickOutside(event) { | ||
| // Ignore the initial click that started editing | ||
| if (this.isInitialEditClick) { | ||
| this.isInitialEditClick = false | ||
| return | ||
| } | ||
|
|
||
| // Check if the click is outside our editing container | ||
| if (this.$refs.editingContainer && !this.$refs.editingContainer.contains(event.target)) { | ||
|
|
||
| const isEditorRelated = event.target.closest('.text-editor__wrapper') | ||
| || event.target.closest('.text-menubar') | ||
| || event.target.closest('.ProseMirror') | ||
| || event.target.closest('[contenteditable]') | ||
| || event.target.closest('.text-editor') | ||
| || event.target.closest('.editor-wrapper') | ||
| || event.target.closest('.v-popper__popper') // For any tooltips/dropdowns | ||
| || event.target.closest('[role="dialog"]') // For any modal dialogs | ||
| || event.target.closest('.widgets--list') // For widgets like images, videos | ||
| || event.target.closest('.tippy-box') // For link preview | ||
| || event.target.closest('a') // For links | ||
| || event.target.closest('svg') // For icons | ||
|
|
||
| if (!isEditorRelated) { | ||
| this.$emit('save', this.localValue) | ||
| } | ||
| } | ||
| }, | ||
|
|
||
| getValue() { | ||
| return this.localValue | ||
| }, | ||
|
|
||
| cancelEdit() { | ||
| this.$emit('cancel') | ||
| }, | ||
| }, | ||
| } | ||
| </script> | ||
|
|
||
| <style lang="scss" scoped> | ||
| .rich-editor-edit-mode { | ||
| position: relative; | ||
| border: 1px solid var(--color-border-maxcontrast); | ||
| } | ||
|
|
||
| .loading-indicator { | ||
| position: absolute; | ||
| top: 4px; | ||
| right: 4px; | ||
| } | ||
|
|
||
| :deep(.text-editor__wrapper div.ProseMirror) { | ||
| padding: 8px; | ||
| min-height: 24px; | ||
| } | ||
| </style> | ||
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
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.