From 5b2455635746c6507e37b8fa8a3185be08f278b1 Mon Sep 17 00:00:00 2001 From: guqing <38999863+guqing@users.noreply.github.com> Date: Sat, 4 May 2024 12:17:28 +0800 Subject: [PATCH 1/5] chore: update workflows config (#96) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### What this PR does? 使用 [reusable workflows](https://github.com/halo-sigs/reusable-workflows) 替换原本的配置 ```release-note None ``` --- .github/workflows/build.yml | 127 ------------------------------------ .github/workflows/cd.yaml | 18 +++++ .github/workflows/ci.yaml | 15 +++++ build.gradle | 12 +++- 4 files changed, 42 insertions(+), 130 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/cd.yaml create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 5fecbd0..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,127 +0,0 @@ -name: Build Plugin JAR File - -on: - push: - branches: [ main ] - release: - types: - - created - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Set up JDK 17 - uses: actions/setup-java@v2 - with: - distribution: 'temurin' - cache: 'gradle' - java-version: 17 - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: 18 - - uses: pnpm/action-setup@v2.0.1 - name: Install pnpm - id: pnpm-install - with: - version: 8 - run_install: false - - name: Get pnpm store directory - id: pnpm-cache - run: | - echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/console/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - name: Install Frontend Dependencies - run: | - ./gradlew pnpmInstall - - name: Build with Gradle - run: | - # Set the version with tag name when releasing - version=${{ github.event.release.tag_name }} - version=${version#v} - sed -i "s/version=.*-SNAPSHOT$/version=$version/1" gradle.properties - ./gradlew clean build -x test - - name: Archive plugin-moments jar - uses: actions/upload-artifact@v2 - with: - name: plugin-moments - path: | - build/libs/*.jar - retention-days: 1 - - github-release: - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'release' - steps: - - name: Download plugin-moments jar - uses: actions/download-artifact@v2 - with: - name: plugin-moments - path: build/libs - - name: Get Name of Artifact - id: get_artifact - run: | - ARTIFACT_PATHNAME=$(ls build/libs/*.jar | head -n 1) - ARTIFACT_NAME=$(basename ${ARTIFACT_PATHNAME}) - echo "Artifact pathname: ${ARTIFACT_PATHNAME}" - echo "Artifact name: ${ARTIFACT_NAME}" - echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV - echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV - echo "RELEASE_ID=${{ github.event.release.id }}" >> $GITHUB_ENV - - name: Upload a Release Asset - uses: actions/github-script@v2 - if: github.event_name == 'release' - with: - github-token: ${{secrets.GITHUB_TOKEN}} - script: | - console.log('environment', process.versions); - - const fs = require('fs').promises; - - const { repo: { owner, repo }, sha } = context; - console.log({ owner, repo, sha }); - - const releaseId = process.env.RELEASE_ID - const artifactPathName = process.env.ARTIFACT_PATHNAME - const artifactName = process.env.ARTIFACT_NAME - console.log('Releasing', releaseId, artifactPathName, artifactName) - - await github.repos.uploadReleaseAsset({ - owner, repo, - release_id: releaseId, - name: artifactName, - data: await fs.readFile(artifactPathName) - }); - app-store-release: - runs-on: ubuntu-latest - needs: build - if: github.event_name == 'release' - steps: - - uses: actions/checkout@v2 - with: - submodules: true - - name: Download plugin-moments jar - uses: actions/download-artifact@v2 - with: - name: plugin-moments - path: build/libs - - name: Sync to Halo App Store - uses: halo-sigs/app-store-release-action@main - with: - github-token: ${{secrets.GITHUB_TOKEN}} - app-id: ${{secrets.APP_ID}} - release-id: ${{ github.event.release.id }} - assets-dir: "build/libs" - halo-username: ${{ secrets.HALO_USERNAME }} - halo-password: ${{ secrets.HALO_PASSWORD }} diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml new file mode 100644 index 0000000..edf7f67 --- /dev/null +++ b/.github/workflows/cd.yaml @@ -0,0 +1,18 @@ +name: CD + +on: + release: + types: + - published + +jobs: + cd: + uses: halo-sigs/reusable-workflows/.github/workflows/plugin-cd.yaml@v1 + secrets: + halo-username: ${{ secrets.HALO_USERNAME }} + halo-password: ${{ secrets.HALO_PASSWORD }} + permissions: + contents: write + with: + app-id: app-SnwWD + ui-path: "console" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..ce0d7f6 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,15 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + ci: + uses: halo-sigs/reusable-workflows/.github/workflows/plugin-ci.yaml@v1 + with: + ui-path: "console" diff --git a/build.gradle b/build.gradle index e0d67cf..131cb2e 100644 --- a/build.gradle +++ b/build.gradle @@ -29,13 +29,19 @@ node { nodeProjectDir = file("${project.projectDir}/console") } -task buildFrontend(type: PnpmTask) { +tasks.register('installDepsForUI', PnpmTask) { + args = ['install'] +} + +tasks.register('buildFrontend', PnpmTask) { args = ['build'] + dependsOn('installDepsForUI') } build { - // build frontend before build - tasks.getByName('compileJava').dependsOn('buildFrontend') + tasks.named('compileJava').configure { + dependsOn('buildFrontend') + } } halo { From a0436e346ed7f7e76c20b3bdee530a778214d93f Mon Sep 17 00:00:00 2001 From: Takagi <1103069291@qq.com> Date: Mon, 6 May 2024 14:29:02 +0800 Subject: [PATCH 2/5] fix: solve the problem of the tag input becoming a title after the # symbol (#75) * fix: solve the problem of the tag input becoming a title after the # symbol * fix: solve the problem of the tag input becoming a title after the # symbol * upgrade Halo dependency to 2.12.0 * optimize the import --- console/src/components/TextEditor.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/console/src/components/TextEditor.vue b/console/src/components/TextEditor.vue index cc0655e..e95f624 100644 --- a/console/src/components/TextEditor.vue +++ b/console/src/components/TextEditor.vue @@ -9,7 +9,6 @@ import { ExtensionDropcursor, ExtensionGapcursor, ExtensionHardBreak, - ExtensionHeading, ExtensionHistory, ExtensionHorizontalRule, ExtensionItalic, @@ -42,6 +41,7 @@ import { ExtensionTrailingNode, useEditor, ExtensionListKeymap, + ExtensionParagraph, } from "@halo-dev/richtext-editor"; import { watch } from "vue"; import { TagsExtension } from "@/extensions/tags"; @@ -69,6 +69,7 @@ const emit = defineEmits<{ const editor = useEditor({ content: props.raw, extensions: [ + ExtensionParagraph, ExtensionBlockquote, ExtensionBold, ExtensionBulletList, @@ -81,7 +82,6 @@ const editor = useEditor({ }), ExtensionGapcursor, ExtensionHardBreak, - ExtensionHeading, ExtensionHistory, ExtensionHorizontalRule, ExtensionItalic, From 52b86e6ef2a17a87042e552d031790394f7d1ff9 Mon Sep 17 00:00:00 2001 From: Takagi <1103069291@qq.com> Date: Mon, 6 May 2024 14:52:49 +0800 Subject: [PATCH 3/5] fix: unable to stop normally when the startup fails (#98) --- src/main/java/run/halo/moments/MomentsPlugin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/run/halo/moments/MomentsPlugin.java b/src/main/java/run/halo/moments/MomentsPlugin.java index ff7cf68..51b1939 100644 --- a/src/main/java/run/halo/moments/MomentsPlugin.java +++ b/src/main/java/run/halo/moments/MomentsPlugin.java @@ -7,6 +7,7 @@ import java.util.Set; import org.apache.commons.lang3.BooleanUtils; import org.springframework.stereotype.Component; +import run.halo.app.extension.Scheme; import run.halo.app.extension.SchemeManager; import run.halo.app.extension.index.IndexSpec; import run.halo.app.plugin.BasePlugin; @@ -68,6 +69,6 @@ public void start() { @Override public void stop() { - schemeManager.unregister(schemeManager.get(Moment.class)); + schemeManager.unregister(Scheme.buildFromType(Moment.class)); } } From db6dc166f4a2e3dba0f5b6edbf46815b00dff5f6 Mon Sep 17 00:00:00 2001 From: Takagi <1103069291@qq.com> Date: Mon, 6 May 2024 15:48:26 +0800 Subject: [PATCH 4/5] feat: the editor supports command to add pictures (#100) --- console/src/components/TextEditor.vue | 4 +-- console/src/extensions/images/index.ts | 41 ++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 console/src/extensions/images/index.ts diff --git a/console/src/components/TextEditor.vue b/console/src/components/TextEditor.vue index e95f624..efe62a1 100644 --- a/console/src/components/TextEditor.vue +++ b/console/src/components/TextEditor.vue @@ -15,7 +15,6 @@ import { ExtensionOrderedList, ExtensionStrike, ExtensionText, - ExtensionImage, ExtensionTaskList, ExtensionLink, ExtensionTextAlign, @@ -45,6 +44,7 @@ import { } from "@halo-dev/richtext-editor"; import { watch } from "vue"; import { TagsExtension } from "@/extensions/tags"; +import MomentExtensionImage from "@/extensions/images"; const props = withDefaults( defineProps<{ @@ -88,7 +88,7 @@ const editor = useEditor({ ExtensionOrderedList, ExtensionStrike, ExtensionText, - ExtensionImage.configure({ + MomentExtensionImage.configure({ inline: true, allowBase64: false, HTMLAttributes: { diff --git a/console/src/extensions/images/index.ts b/console/src/extensions/images/index.ts new file mode 100644 index 0000000..72fddd2 --- /dev/null +++ b/console/src/extensions/images/index.ts @@ -0,0 +1,41 @@ +import { Editor, ExtensionImage, type Range } from "@halo-dev/richtext-editor"; +import type { ExtensionOptions } from "@halo-dev/richtext-editor/dist/types"; +import { markRaw } from "vue"; +import MdiFileImageBox from "~icons/mdi/file-image-box"; + +export interface ImageOptions { + inline: boolean; + allowBase64: boolean; + HTMLAttributes: Record; +} + +const MomentExtensionImage = ExtensionImage.extend< + ExtensionOptions & ImageOptions +>({ + addOptions() { + return { + ...this.parent?.(), + getCommandMenuItems() { + return { + priority: 100, + icon: markRaw(MdiFileImageBox), + title: "图片", + keywords: ["image", "tupian"], + command: ({ editor, range }: { editor: Editor; range: Range }) => { + editor + .chain() + .focus() + .deleteRange(range) + .insertContent([ + { type: "image", attrs: { src: "" } }, + { type: "paragraph", content: "" }, + ]) + .run(); + }, + }; + }, + }; + }, +}); + +export default MomentExtensionImage; From e591d3d192b2cd8a25f299468112b3702c1f210b Mon Sep 17 00:00:00 2001 From: Takagi <1103069291@qq.com> Date: Mon, 6 May 2024 15:48:38 +0800 Subject: [PATCH 5/5] fix: the picture is cropped when previewing (#99) --- console/src/components/PreviewDetailModal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/console/src/components/PreviewDetailModal.vue b/console/src/components/PreviewDetailModal.vue index 3fd84ce..3652761 100644 --- a/console/src/components/PreviewDetailModal.vue +++ b/console/src/components/PreviewDetailModal.vue @@ -41,7 +41,7 @@ const onVisibleChange = (visible: boolean) => { class="overflow-hidden bg-white moments-flex moments-items-center moments-justify-center moments-h-full" >