-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for text highlight, link and image (#8)
* chore: update BarMenu styling to increase gap between items * chore: update CSS for formats * feat: add new icons for horizontal line, italic, inline code, code block, ordered list, unordered list, and block quote * chore: update @tiptap dependencies to version 2.4.0 * chore: Update @tiptap dependencies to version 2.4.0 * chore: Update Focus.configure in BlockEditor extension to include className option * chore: Add workaround to make the editor autofocus in BlockEditor component * chore: Update BlockEditor to autofocus on load * chore: Add Highlight extension * chore: Update link extension in BlockEditor * chore: Update BlockEditor to use lazy loading for images * chore: Update link extension in BlockEditor * feat: add support for image
- Loading branch information
1 parent
b8b1f33
commit 063abb0
Showing
22 changed files
with
542 additions
and
516 deletions.
There are no files selected for viewing
This file contains 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,20 @@ | ||
import Link from '@tiptap/extension-link'; | ||
|
||
export default Link.extend({ | ||
inclusive: false, | ||
addOptions() { | ||
return { | ||
openOnClick: false, | ||
linkOnPaste: true, | ||
autolink: true, | ||
protocols: [], | ||
defaultProtocol: 'http', | ||
HTMLAttributes: { | ||
target: '_blank', | ||
rel: 'noopener noreferrer nofollow', | ||
class: null, | ||
}, | ||
validate: (url) => !!url, | ||
}; | ||
}, | ||
}); |
28 changes: 28 additions & 0 deletions
28
lib/components/BlockEditor/extension/extension-selectedText.ts
This file contains 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,28 @@ | ||
import { Editor, Extension } from '@tiptap/core'; | ||
|
||
declare module '@tiptap/core' { | ||
interface Commands { | ||
selectedText: { | ||
getSelectedText: () => ({ editor }: { editor: Editor }) => string | null; | ||
}; | ||
} | ||
} | ||
|
||
export default Extension.create({ | ||
name: 'SelectedText', | ||
addCommands: () => { | ||
return { | ||
getSelectedText: | ||
() => | ||
({ editor }) => { | ||
const { from, to, empty } = editor.state.selection; | ||
|
||
if (empty) { | ||
return null; | ||
} | ||
|
||
return editor.state.doc.textBetween(from, to, ' '); | ||
}, | ||
}; | ||
}, | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains 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 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.