mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2026-03-24 12:56:59 +00:00
[PR #3146] [CLOSED] feat: added import a page from notion feature #5599
Labels
No labels
2024
2025
2026
acct mgmt
AI
automation
bug
calendar
ci
CJK
cloud
code-block
collaboration
copy-paste
database
data migration
data sync
deploy
desktop
develop
develop
documentation
duplicate
editor
editor-plugin
emoji
export
files
flutter-only
follow-up
formula
good first issue for devs
good first issue for experienced devs
grid
hacktoberfest
HACKTOBERFEST-ACCEPTED
help wanted
i18n
icons
images
importer
improvements
infra
install
integrations
IR
kanban board
login
look and joy
mentorship
mobile
mobile
needs design
new feature
new feature
non-coding
notes
notifications
onboarding
organization
P0+
permission
platform-linux
platform-mac
platform-windows
plugins
program
pull-request
Q1 25
Q1 26
Q2 24
Q2 25
Q3 24
Q3 25
Q4 24
Q4 25
react
regression
rust
rust
Rust-only
Rust-only
Rust-starter
Rust-starter
self-hosted
shortcuts
side panel
slash-menu
sync v2
table
tablet
task
tauri
templates
tests
themes
translation
v0.5.6
v0.5.8
v0.5.9
v0.6.0
v0.6.1
v0.6.4
v0.6.7
v0.6.8
v0.7.1
v0.7.4
v0.7.4
v0.7.5
v0.7.6
v0.7.7
v0.7.8
v0.8.0
v0.8.4
v0.8.5
v0.8.9
web
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
AppFlowy-IO/AppFlowy#5599
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/AppFlowy-IO/AppFlowy/pull/3146
Author: @Mukund-Tandon
Created: 8/8/2023
Status: ❌ Closed
Base:
main← Head:import_notion_page_from_zip_file📝 Commits (10+)
1629a1efeat: added import a page from notion feature572142frefactor: use tuple instead of pair1476c0arefactor: fixed test file according to reviews on reviews0de1f4frefactor: use local keys for from markdown zip5868ef4fix: close import panel after importing2f51230refactor: refactored the code based on reviews4057f80chore: added commentsf24ae36refactor: fixed minor mistakes in codeee63731refactor: resolved merge conflictsbfda147fix: fixed merge conflicts📊 Changes
17 files changed (+1299 additions, -31 deletions)
View changed files
➕
frontend/appflowy_flutter/assets/images/external/notion-logo.svg(+6 -0)➕
frontend/appflowy_flutter/assets/test/workspaces/import_page_from_notion_test.zip(+0 -0)➕
frontend/appflowy_flutter/integration_test/import_page_from_notion_test.dart(+195 -0)📝
frontend/appflowy_flutter/lib/startup/deps_resolver.dart(+3 -0)➕
frontend/appflowy_flutter/lib/workspace/application/sidebar/background_task_notification/background_task_notification_bloc.dart(+208 -0)➕
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/background_task_notification/background_task_notifications.dart(+99 -0)➕
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/background_task_notification/tasknotification.dart(+133 -0)➕
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/import/import_from_notion_widget.dart(+166 -0)📝
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/import/import_panel.dart(+72 -28)📝
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/import/import_type.dart(+33 -0)➕
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/import/importer/custom_parsers/subpage_import_parser.dart(+18 -0)➕
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/import/importer/notion_importer.dart(+344 -0)📝
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/sidebar.dart(+13 -0)📝
frontend/appflowy_flutter/lib/workspace/presentation/home/menu/view/view_add_button.dart(+1 -1)📝
frontend/appflowy_flutter/pubspec.lock(+1 -1)📝
frontend/appflowy_flutter/pubspec.yaml(+2 -0)📝
frontend/resources/translations/en.json(+5 -1)📄 Description
Fixes: #2911
Feature Preview
https://github.com/AppFlowy-IO/AppFlowy/assets/71614009/89eca69a-81b3-449a-b162-8652c71f18ce
This PR is related to https://github.com/AppFlowy-IO/AppFlowy/pull/2981
How This feature is implemented -
What does a page look like when exported from Notion-
We get a zip file containing the the main page markdown and a folder containing assets of the main page and also markdown files of subpages of the main page and folders containing the assets of the subpages and the sub-sub pages markdown files and so on.
How our main page markdown file look
We can see on line 5,6 we have two images inside the round brackets is the path where images are located and on line 19 ,21,23 are subpages
Markdown file of subpage
Here we have to look at the image path it starts with AppFlowy Subpage 1 instead of instead of AppFlowy Test which is the parent folder. This is because it’s asset lies in AppFlowy Sub 1 folder which is at the same level where the subpage markdown file is . This fact will be used late while importing.
How is the Importing working
levelslistMentionBlockof the subpage it requires the SubPage viewID which can only be generated once it is imported so we import the lowest level sub page first and then go up storing each page viewID in a map (nameToID) which has key as the page name and value as the page viewID.This class contains details of each page to be imported and the parent of that page which will be used for moving the page under correct parent in later steps
This class contains details of each level of the files. Like For example the main page will be level one , if it has a subpage it will be level 2 and if that subpage will have another subpage that would belong to level 3
When we are importing a markdown page how are we dealing with images
_preProcessMarkdownFilefunction which returns us a string which is the contents of the markdown file but with changes. The changes this function performs are related to images . It will iterate through each line and if it finds something likethis is how a image is represented in markdown . When we get this line is detected we get the path from this this path is actually the file name of image from the above list of unzip images so with the help of path we will get the image file and save it locally and change the current path to the path where the image is saved locally_preProcessMarkdownFileit wont be able find the image file.So this issue was solve by only passing the assets of a particular level to the _preProcessMarkdownFile function instead of all the assets and also during the process of adding files/assets in the levels list if a file is not added in the particular level then the first part(parent) from it name would be removedHow does Subpages are handled while importing a page ?
We are imported from level 3 to level 1. This is done because to handle the subpages . We use
markdownToDocumentfunction of appflowy-editor package to chick we pass the markdown contents of our page and it return us a Document. We also pass a custom-parser to this function which handles our subpage. Whenever it detects a subpage it replace the part with aMentionBlock(It contains the pageID of the page that is being Mentioned) . This is reason we are importing the lower level page first . We will import them and store their viewID in a map where the key is pageName and value is the pageID. When above level are being imported and there contents are passed through_preProcessMarkdownFilefunction this map(nameToId) is also passed in the function , whenever it finds a subpage which looks like name to{{AppFlowy-Subpage}}{$subpageName}{$subPageID}, this pattern is used in custom parser to detect the subpage part and convert it to mention block. We have stored the pageIds with name as key so we can easily get the pageID of subpage by using name from name .PR Checklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.