feat: infoq platform sync #1216
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Add support for InfoQ (InfoQ写作社区) platform in the COSE browser extension, enabling users to sync articles directly to InfoQ. This update includes a new modular platform configuration, API-based login detection with real user profile retrieval, proper draft creation workflow, and ProseMirror-based content filling.
Changes
Browser Extension (cose/)
Platform Configuration:
https://*.infoq.cn/*,https://account.infoq.cn/*) to manifest.json.Login Detection:
POST https://xie.infoq.cn/public/v1/user/get_user.nickname: Actual username (e.g., "timerring")avatar: User avatar URL from GeekBang CDNuid: Unique user identifier{ loggedIn: true, username, avatar, userId }when authenticated.{ loggedIn: false }.Draft Creation Workflow:
https://xie.infoq.cn/draft/writecauses editor failure.POST https://xie.infoq.cn/api/v1/draft/createto create a new draft{"code":0,"data":{"id":364728}}https://xie.infoq.cn/draft/{id}Content Filler:
__vue__instance from content scripts.editorAPI.editor.viewready) with polling mechanism (max 15 seconds).handleFileChange,readMarkdown) failed to render content. Clipboard paste triggers InfoQ's native Markdown processing pipeline.Web Application (apps/web/)
Login URL Integration:
https://account.infoq.cn/login) to PostInfo.vue for the "Login" link functionality.Technical Details
Editor Initialization Timing:
/draft/writeendpoint doesn't initialize the editor correctly.vm.editorAPI.editor.viewexistence andmountedstatus before attempting content fill.Isolated Worlds Problem:
__vue__).<script>tag into page's<head>to execute code in main world.ProseMirror Content Filling:
ClipboardEventwithDataTransfercontaining Markdown text.Modular Architecture:
Testing
Install/Reload the COSE extension.
Logged-Out Test:
Logged-In Test:
Sync Test:
https://xie.infoq.cn/draft/{id}(not/draft/write).<h2>,<h3>, etc.<ul><li>elementsError Handling Test: