mirror of https://github.com/halo-dev/halo
Merge branch 'main' into chore/remove-deprecated-code
commit
c27cbb5204
|
@ -63,13 +63,12 @@ class SystemConfigFirstExternalUrlSupplier implements ExternalUrlSupplier {
|
|||
@Override
|
||||
public URI get() {
|
||||
try {
|
||||
if (externalUrl != null) {
|
||||
return externalUrl.toURI();
|
||||
}
|
||||
if (!haloProperties.isUseAbsolutePermalink()) {
|
||||
return URI.create(getBasePath());
|
||||
}
|
||||
|
||||
if (externalUrl != null) {
|
||||
return externalUrl.toURI();
|
||||
}
|
||||
return haloProperties.getExternalUrl().toURI();
|
||||
} catch (URISyntaxException e) {
|
||||
throw Exceptions.propagate(e);
|
||||
|
|
|
@ -55,7 +55,7 @@ class SystemConfigFirstExternalUrlSupplierTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
void getURIWhenBasePathSetAndNotUsingAbsolutePermalink() throws MalformedURLException {
|
||||
void getURIWhenBasePathSetAndNotUsingAbsolutePermalink() {
|
||||
when(webFluxProperties.getBasePath()).thenReturn("/blog");
|
||||
when(haloProperties.isUseAbsolutePermalink()).thenReturn(false);
|
||||
|
||||
|
@ -137,10 +137,11 @@ class SystemConfigFirstExternalUrlSupplierTest {
|
|||
class SystemConfigSupplier {
|
||||
|
||||
@Test
|
||||
void shouldGetUrlCorrectly() throws Exception {
|
||||
void shouldGetUrlWhenUseAbsolutePermalink() throws Exception {
|
||||
var basic = new SystemSetting.Basic();
|
||||
basic.setExternalUrl("https://www.halo.run");
|
||||
when(systemConfigFetcher.getBasic()).thenReturn(Mono.just(basic));
|
||||
when(haloProperties.isUseAbsolutePermalink()).thenReturn(true);
|
||||
externalUrl.onExtensionInitialized(null);
|
||||
assertEquals(URI.create("https://www.halo.run").toURL(), externalUrl.getRaw());
|
||||
assertEquals(URI.create("https://www.halo.run"), externalUrl.get());
|
||||
|
@ -150,6 +151,22 @@ class SystemConfigFirstExternalUrlSupplierTest {
|
|||
externalUrl.getURL(mockRequest));
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldGetUrlWhenNotUsingAbsolutePermalink() throws MalformedURLException {
|
||||
var basic = new SystemSetting.Basic();
|
||||
basic.setExternalUrl("https://www.halo.run");
|
||||
when(systemConfigFetcher.getBasic()).thenReturn(Mono.just(basic));
|
||||
when(haloProperties.isUseAbsolutePermalink()).thenReturn(false);
|
||||
when(webFluxProperties.getBasePath()).thenReturn("/fake");
|
||||
externalUrl.onExtensionInitialized(null);
|
||||
|
||||
assertEquals(URI.create("https://www.halo.run").toURL(), externalUrl.getRaw());
|
||||
assertEquals(URI.create("/fake"), externalUrl.get());
|
||||
var mockRequest = mock(HttpRequest.class);
|
||||
assertEquals(URI.create("https://www.halo.run").toURL(),
|
||||
externalUrl.getURL(mockRequest));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -25,6 +25,7 @@ const href = computed({
|
|||
props.editor.commands.setLink({
|
||||
href: value,
|
||||
target: target.value ? "_blank" : "_self",
|
||||
rel: rel.value ? "nofollow" : "",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
@ -38,6 +39,21 @@ const target = computed({
|
|||
props.editor.commands.setLink({
|
||||
href: href.value,
|
||||
target: value ? "_blank" : "_self",
|
||||
rel: rel.value ? "nofollow" : "",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
const rel = computed({
|
||||
get() {
|
||||
const attrs = props.editor.getAttributes("link");
|
||||
return attrs?.rel === "nofollow";
|
||||
},
|
||||
set(value) {
|
||||
props.editor.commands.setLink({
|
||||
href: href.value,
|
||||
target: target.value ? "_blank" : "_self",
|
||||
rel: value ? "nofollow" : "",
|
||||
});
|
||||
},
|
||||
});
|
||||
|
@ -66,6 +82,7 @@ const handleLinkBubbleButton = () => {
|
|||
props.editor.commands.setLink({
|
||||
href: text,
|
||||
target: "_self",
|
||||
rel: "",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +117,7 @@ const handleLinkBubbleButton = () => {
|
|||
:placeholder="i18n.global.t('editor.extensions.link.placeholder')"
|
||||
class="bg-gray-50 rounded-md hover:bg-gray-100 block px-2 w-full py-1.5 text-sm text-gray-900 border border-gray-300 focus:ring-blue-500 focus:border-blue-500"
|
||||
/>
|
||||
<label class="inline-flex items-center mt-2">
|
||||
<label class="inline-flex items-center mt-2 mr-2">
|
||||
<input
|
||||
v-model="target"
|
||||
type="checkbox"
|
||||
|
@ -110,6 +127,17 @@ const handleLinkBubbleButton = () => {
|
|||
{{ i18n.global.t("editor.extensions.link.open_in_new_window") }}
|
||||
</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center mt-2">
|
||||
<!-- nofollow -->
|
||||
<input
|
||||
v-model="rel"
|
||||
type="checkbox"
|
||||
class="form-checkbox text-blue-600 focus:ring-blue-500 border-gray-300 rounded"
|
||||
/>
|
||||
<span class="ml-2 text-sm text-gray-500">
|
||||
{{ i18n.global.t("editor.extensions.link.nofollow") }}
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
</VDropdown>
|
||||
|
|
|
@ -14,6 +14,10 @@ const Link = TiptapLink.extend<ExtensionOptions & LinkOptions>({
|
|||
};
|
||||
},
|
||||
|
||||
renderHTML({ HTMLAttributes }) {
|
||||
return ["a", HTMLAttributes, 0];
|
||||
},
|
||||
|
||||
addPasteRules() {
|
||||
// Remove the function of pasted text parsing as a link
|
||||
return [];
|
||||
|
|
|
@ -33,6 +33,7 @@ editor:
|
|||
placeholder: 链接地址
|
||||
open_in_new_window: 在新窗口中打开
|
||||
cancel_link: 取消链接
|
||||
nofollow: 搜索引擎忽略链接关系
|
||||
audio:
|
||||
disable_autoplay: 关闭自动播放
|
||||
enable_autoplay: 开启自动播放
|
||||
|
|
Loading…
Reference in New Issue