Skip to content

Commit

Permalink
fix tweet embed disappearing on save
Browse files Browse the repository at this point in the history
  • Loading branch information
GraemeFulton committed Jan 24, 2024
1 parent 68aade3 commit 13e469d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions components/Editor/CustomExtensions/Tweet/Tweet.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const Twitter = Node.create({
url: {
default: null,
parseHTML:(element) =>{

if(!element?.getAttribute('tweetid')){
//if no tweet id, check for legacy twitter blockquotes
let links = element?.querySelectorAll('a')
Expand All @@ -49,8 +50,10 @@ const Twitter = Node.create({
}
return url
}
}else{
return element.getAttribute('url')
}
else return null
// else return null
}
},
tweetId: {
Expand Down Expand Up @@ -161,7 +164,7 @@ const Twitter = Node.create({
rawHTML.innerHTML=HTMLAttributes.rawContent
return['div',
// ['blockquote', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)],
['blockquote', mergeAttributes(HTMLAttributes, { draggable: false, contenteditable: false, class:'twitter-tweet' }),rawHTML.firstChild],
['blockquote', mergeAttributes(HTMLAttributes, { draggable: false, contenteditable: false, class:'twitter-tweet', url:HTMLAttributes.url }),rawHTML.firstChild],
// ['figcaption', HTMLAttributes?.figcaption?HTMLAttributes.figcaption:'']
]
// return ['div', mergeAttributes({ 'data-twitter': '' }, HTMLAttributes)];
Expand Down
2 changes: 1 addition & 1 deletion components/Editor/editorHooks/libs/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const slugify = require("slugify");
const qs = require("qs");
// const qs = require("qs");

export const uid = function () {
return Date.now().toString(36) + Math.random().toString(36).substr(2);
Expand Down

0 comments on commit 13e469d

Please sign in to comment.