mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Composer preview not caching inline onebox.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
export const INLINE_ONEBOX_LOADING_CSS_CLASS =
|
||||
"<%= CookedPostProcessor::INLINE_ONEBOX_LOADING_CSS_CLASS %>";
|
||||
|
||||
export const INLINE_ONEBOX_CSS_CLASS =
|
||||
"<%= CookedPostProcessor::INLINE_ONEBOX_CSS_CLASS %>";
|
||||
@@ -1,10 +1,10 @@
|
||||
import { lookupCache } from "pretty-text/oneboxer";
|
||||
import { cachedInlineOnebox } from "pretty-text/inline-oneboxer";
|
||||
|
||||
import {
|
||||
cachedInlineOnebox,
|
||||
INLINE_ONEBOX_LOADING_CSS_CLASS,
|
||||
INLINE_ONEBOX_CSS_CLASS
|
||||
} from "pretty-text/inline-oneboxer";
|
||||
} from "pretty-text/context/inline-onebox-css-classes";
|
||||
|
||||
const ONEBOX = 1;
|
||||
const INLINE = 2;
|
||||
@@ -105,7 +105,7 @@ function applyOnebox(state, silent) {
|
||||
if (onebox && onebox.title) {
|
||||
text.content = onebox.title;
|
||||
attrs.push(["class", INLINE_ONEBOX_CSS_CLASS]);
|
||||
} else {
|
||||
} else if (!onebox) {
|
||||
attrs.push(["class", INLINE_ONEBOX_LOADING_CSS_CLASS]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
let _cache = {};
|
||||
import {
|
||||
INLINE_ONEBOX_LOADING_CSS_CLASS,
|
||||
INLINE_ONEBOX_CSS_CLASS
|
||||
} from "pretty-text/context/inline-onebox-css-classes";
|
||||
|
||||
export const INLINE_ONEBOX_LOADING_CSS_CLASS =
|
||||
"<%= CookedPostProcessor::INLINE_ONEBOX_LOADING_CSS_CLASS %>";
|
||||
|
||||
export const INLINE_ONEBOX_CSS_CLASS =
|
||||
"<%= CookedPostProcessor::INLINE_ONEBOX_CSS_CLASS %>";
|
||||
const _cache = {};
|
||||
|
||||
export function applyInlineOneboxes(inline, ajax) {
|
||||
Object.keys(inline).forEach(url => {
|
||||
@@ -20,7 +19,8 @@ export function applyInlineOneboxes(inline, ajax) {
|
||||
_cache[onebox.url] = onebox;
|
||||
let links = inline[onebox.url] || [];
|
||||
links.forEach(link => {
|
||||
$(link).text(onebox.title)
|
||||
$(link)
|
||||
.text(onebox.title)
|
||||
.addClass(INLINE_ONEBOX_CSS_CLASS)
|
||||
.removeClass(INLINE_ONEBOX_LOADING_CSS_CLASS);
|
||||
});
|
||||
@@ -32,3 +32,11 @@ export function applyInlineOneboxes(inline, ajax) {
|
||||
export function cachedInlineOnebox(url) {
|
||||
return _cache[url];
|
||||
}
|
||||
|
||||
export function applyCachedInlineOnebox(url, onebox) {
|
||||
return (_cache[url] = onebox);
|
||||
}
|
||||
|
||||
export function deleteCachedInlineOnebox(url) {
|
||||
return delete _cache[url];
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
INLINE_ONEBOX_CSS_CLASS,
|
||||
INLINE_ONEBOX_LOADING_CSS_CLASS
|
||||
} from "pretty-text/inline-oneboxer";
|
||||
INLINE_ONEBOX_LOADING_CSS_CLASS,
|
||||
INLINE_ONEBOX_CSS_CLASS
|
||||
} from "pretty-text/context/inline-onebox-css-classes";
|
||||
|
||||
// to match:
|
||||
// abcd
|
||||
|
||||
Reference in New Issue
Block a user