Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Native Source Editor - Part 1 #4521

Merged
merged 22 commits into from Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
1bf8f76
Point package to source-editor-1 branch
tonisevener May 5, 2023
da6fe34
Add feature flag
tonisevener May 1, 2023
3faac3d
Make sectionID optional in SectionFetcher
tonisevener May 1, 2023
3fe594e
Add PageEditorViewController
tonisevener May 5, 2023
b364e66
Show new editor with feature flag
tonisevener May 1, 2023
917bef7
Update WKTheme when WMFTheme changes
tonisevener May 1, 2023
b3a9eca
Add full article edit button
tonisevener May 2, 2023
311f94b
Update package
tonisevener May 5, 2023
105df3b
Merge branch 'main' into source-editor-1
staykids May 8, 2023
d13d061
PR feedback
tonisevener May 9, 2023
49ee115
Merge branch 'main' into source-editor-1
staykids May 15, 2023
3bb41e4
Switch Components package back to main
tonisevener May 16, 2023
3cf9535
Merge branch 'main' into source-editor-1
tonisevener May 16, 2023
8958af0
Merge branch 'main' into source-editor-1
tonisevener Aug 14, 2023
50ea71c
Update packages to latest, strings changes from building
tonisevener Aug 14, 2023
4116f84
Merge branch 'main' into source-editor-1
tonisevener Aug 28, 2023
eda7dc3
Strings changes from building, remove extra import
tonisevener Aug 28, 2023
2ae55eb
Merge branch 'main' into source-editor-1
tonisevener Aug 31, 2023
9e8da2c
Strings changes from building
tonisevener Aug 31, 2023
188bdaf
Merge branch 'main' into source-editor-1
tonisevener Oct 24, 2023
91c23dc
String changes from building
tonisevener Oct 24, 2023
a64e7d6
Merge branch 'main' of https://github.com/wikimedia/wikipedia-ios int…
mazevedofs Oct 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions WMF Framework/FeatureFlags.swift
Expand Up @@ -6,4 +6,11 @@ public struct FeatureFlags {
return true
}

public static var needsNativeSourceEditor: Bool {
#if WMF_STAGING
return true
#else
return false
#endif
}
}
20 changes: 19 additions & 1 deletion Wikipedia.xcodeproj/project.pbxproj
Expand Up @@ -562,6 +562,10 @@
672D69AB273ACAA100B123B3 /* UITabBarAppearance+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 672D69A8273ACAA100B123B3 /* UITabBarAppearance+Extensions.swift */; };
672D69AC273ACAA200B123B3 /* UITabBarAppearance+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 672D69A8273ACAA100B123B3 /* UITabBarAppearance+Extensions.swift */; };
672F0558222F24FB00FB1084 /* IconBarButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 672F0557222F24FB00FB1084 /* IconBarButtonItem.swift */; };
6730D8DF2A05BFB50035255B /* PageEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6730D8DE2A05BFB50035255B /* PageEditorViewController.swift */; };
6730D8E02A05BFB50035255B /* PageEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6730D8DE2A05BFB50035255B /* PageEditorViewController.swift */; };
6730D8E12A05BFB50035255B /* PageEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6730D8DE2A05BFB50035255B /* PageEditorViewController.swift */; };
6730D8E22A05BFB50035255B /* PageEditorViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6730D8DE2A05BFB50035255B /* PageEditorViewController.swift */; };
6730FD0E28998EFD000E5F40 /* TalkPageReplyComposeContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6730FD0D28998EFD000E5F40 /* TalkPageReplyComposeContentView.swift */; };
6730FD0F28998EFD000E5F40 /* TalkPageReplyComposeContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6730FD0D28998EFD000E5F40 /* TalkPageReplyComposeContentView.swift */; };
6730FD1028998EFD000E5F40 /* TalkPageReplyComposeContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6730FD0D28998EFD000E5F40 /* TalkPageReplyComposeContentView.swift */; };
Expand Down Expand Up @@ -4153,6 +4157,7 @@
672D69A3273ABD3600B123B3 /* UINavigationBarAppearance+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UINavigationBarAppearance+Extensions.swift"; sourceTree = "<group>"; };
672D69A8273ACAA100B123B3 /* UITabBarAppearance+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UITabBarAppearance+Extensions.swift"; sourceTree = "<group>"; };
672F0557222F24FB00FB1084 /* IconBarButtonItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IconBarButtonItem.swift; sourceTree = "<group>"; };
6730D8DE2A05BFB50035255B /* PageEditorViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageEditorViewController.swift; sourceTree = "<group>"; };
6730FD0D28998EFD000E5F40 /* TalkPageReplyComposeContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TalkPageReplyComposeContentView.swift; sourceTree = "<group>"; };
6734114F22700A95005B31DA /* TalkPageControllerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TalkPageControllerTests.swift; sourceTree = "<group>"; };
6734115122700C47005B31DA /* TalkPageTestHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TalkPageTestHelpers.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -7138,6 +7143,14 @@
path = "Article Description Tests";
sourceTree = "<group>";
};
6730D8DD2A05BFA40035255B /* Page Editor */ = {
isa = PBXGroup;
children = (
6730D8DE2A05BFB50035255B /* PageEditorViewController.swift */,
);
name = "Page Editor";
sourceTree = "<group>";
};
676C864526D40AEB00A704C1 /* NotificationServiceExtension */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -8548,6 +8561,7 @@
BC45D58D1C32FD58007C72F3 /* Features */ = {
isa = PBXGroup;
children = (
6730D8DD2A05BFA40035255B /* Page Editor */,
6798035A24F94CAE00D765AA /* Article as a Living Document */,
67DC5BDB23A00DF500B03A84 /* Article */,
6782DB8F2343B691003FA21B /* Diff */,
Expand Down Expand Up @@ -11488,6 +11502,7 @@
00F5AED027C6C80C006390A8 /* PushNotificationsSettingsViewController.swift in Sources */,
B0B423611EF9D69C00D3DC4C /* OnThisDayViewController.swift in Sources */,
0042813125E6E841004945B3 /* NYTPhotosDataSource.m in Sources */,
6730D8DF2A05BFB50035255B /* PageEditorViewController.swift in Sources */,
B0CD9DDA1F70997300051843 /* WMFWelcomeExplorationAnimationView.swift in Sources */,
83CA612A20D1675800EF0C4A /* ExploreCardViewController.swift in Sources */,
D8FEECCD1DE3729400B883F0 /* WMFChange.m in Sources */,
Expand Down Expand Up @@ -12460,6 +12475,7 @@
B0FFFB2D21C9BED1001E787E /* TextFormattingButton.swift in Sources */,
00F5AED327C6C80C006390A8 /* PushNotificationsSettingsViewController.swift in Sources */,
7AF6F76922395BEC00949393 /* EditingWelcomeViewController.swift in Sources */,
6730D8E22A05BFB50035255B /* PageEditorViewController.swift in Sources */,
0042813425E6E841004945B3 /* NYTPhotosDataSource.m in Sources */,
672286282540DB330038E332 /* AppTabBarDelegate.swift in Sources */,
D8A42AA71E815A9C00D8E281 /* WMFArticleLanguagesSectionHeader.m in Sources */,
Expand Down Expand Up @@ -13002,6 +13018,7 @@
D8CE25221E698E2400DAE2E0 /* UIViewController+WMFStoryboardUtilities.m in Sources */,
00CF2EA227DABCA8006EFDDC /* NotificationsCenterOnboardingView.swift in Sources */,
B0524AF22144D7BE00D8FD8D /* DescriptionHelpViewController.swift in Sources */,
6730D8E12A05BFB50035255B /* PageEditorViewController.swift in Sources */,
7A715668226974D10066FEC4 /* InsertMediaImageSizeSettingsViewController.swift in Sources */,
D8CE25231E698E2400DAE2E0 /* UIVIewController+WMFCommonRotationSupport.swift in Sources */,
00E75B6427EB87DC00A45B78 /* NotificationsCenterDetailView.swift in Sources */,
Expand Down Expand Up @@ -13597,6 +13614,7 @@
D8EC3E101E9BDA35006712EB /* WMFSearchFetcher.m in Sources */,
00CF2EA127DABCA8006EFDDC /* NotificationsCenterOnboardingView.swift in Sources */,
B0524AF32144D7BE00D8FD8D /* DescriptionHelpViewController.swift in Sources */,
6730D8E02A05BFB50035255B /* PageEditorViewController.swift in Sources */,
7A715669226974D10066FEC4 /* InsertMediaImageSizeSettingsViewController.swift in Sources */,
D8EC3E121E9BDA35006712EB /* LoggingDefaults.swift in Sources */,
00E75B6327EB87DC00A45B78 /* NotificationsCenterDetailView.swift in Sources */,
Expand Down Expand Up @@ -20048,7 +20066,7 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/wikimedia/wikipedia-ios-components.git";
requirement = {
branch = main;
branch = "source-editor-1";
kind = branch;
};
};
Expand Down
Expand Up @@ -5,26 +5,26 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/CocoaLumberjack/CocoaLumberjack.git",
"state" : {
"revision" : "80ada1f753b0d53d9b57c465936a7c4169375002",
"version" : "3.7.4"
"revision" : "0188d31089b5881a269e01777be74c7316924346",
"version" : "3.8.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "5d66f7ba25daf4f94100e7022febf3c75e37a6c7",
"version" : "1.4.2"
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
"version" : "1.5.2"
}
},
{
"identity" : "wikipedia-ios-components",
"kind" : "remoteSourceControl",
"location" : "https://github.com/wikimedia/wikipedia-ios-components.git",
"state" : {
"branch" : "main",
"revision" : "e9d5031d5c75492be55b4143b397cd43227de7ed"
"branch" : "source-editor-1",
"revision" : "00611e7dad99b109ecda2937ffcc361da2190f54"
}
}
],
Expand Down
58 changes: 42 additions & 16 deletions Wikipedia/Code/ArticleViewController+Editing.swift
Expand Up @@ -10,26 +10,25 @@ extension ArticleViewController {
}
}

func showEditorForFullSource(selectedTextEditInfo: SelectedTextEditInfo? = nil) {
let pageEditorViewController = PageEditorViewController(pageURL: articleURL, sectionID: nil, dataStore: dataStore, delegate: self, theme: theme)

presentEditor(editorViewController: pageEditorViewController)
}

func showEditorForSection(with id: Int, selectedTextEditInfo: SelectedTextEditInfo? = nil) {
cancelWIconPopoverDisplay()
let sectionEditVC = SectionEditorViewController(articleURL: articleURL, sectionID: id, dataStore: dataStore, selectedTextEditInfo: selectedTextEditInfo, theme: theme)
sectionEditVC.delegate = self
let navigationController = WMFThemeableNavigationController(rootViewController: sectionEditVC, theme: theme)
navigationController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext

let needsIntro = !UserDefaults.standard.didShowEditingOnboarding
if needsIntro {
let editingWelcomeViewController = EditingWelcomeViewController(theme: theme) {
self.present(navigationController, animated: true)
}
editingWelcomeViewController.apply(theme: theme)
present(editingWelcomeViewController, animated: true) {
UserDefaults.standard.didShowEditingOnboarding = true
}

let editorViewController: UIViewController
if FeatureFlags.needsNativeSourceEditor {
let pageEditorViewController = PageEditorViewController(pageURL: articleURL, sectionID: id, dataStore: dataStore, delegate: self, theme: theme)
editorViewController = pageEditorViewController
} else {
present(navigationController, animated: true)
let sectionEditViewController = SectionEditorViewController(articleURL: articleURL, sectionID: id, dataStore: dataStore, selectedTextEditInfo: selectedTextEditInfo, theme: theme)
sectionEditViewController.delegate = self
editorViewController = sectionEditViewController
}

presentEditor(editorViewController: editorViewController)
}

func showTitleDescriptionEditor(with descriptionSource: ArticleDescriptionSource) {
Expand Down Expand Up @@ -68,6 +67,26 @@ extension ArticleViewController {
}
}

private func presentEditor(editorViewController: UIViewController) {

let navigationController = WMFThemeableNavigationController(rootViewController: editorViewController, theme: theme)
navigationController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext

let needsIntro = !UserDefaults.standard.didShowEditingOnboarding
if needsIntro {
let editingWelcomeViewController = EditingWelcomeViewController(theme: theme) {
self.present(navigationController, animated: true)
}
editingWelcomeViewController.apply(theme: theme)
present(editingWelcomeViewController, animated: true) {
UserDefaults.standard.didShowEditingOnboarding = true
}

} else {
present(navigationController, animated: true)
}
}

func showEditSectionOrTitleDescriptionDialogForSection(with id: Int, descriptionSource: ArticleDescriptionSource, selectedTextEditInfo: SelectedTextEditInfo? = nil) {
let sheet = UIAlertController(title: nil, message: nil, preferredStyle: .alert)

Expand Down Expand Up @@ -195,6 +214,13 @@ extension ArticleViewController: SectionEditorViewControllerDelegate {
}
}

extension ArticleViewController: PageEditorViewControllerDelegate {
func pageEditorDidCancelEditing(_ pageEditor: PageEditorViewController, navigateToURL: URL?) {
dismiss(animated: true) {
}
}
}

extension ArticleViewController: DescriptionEditViewControllerDelegate {
func descriptionEditViewControllerEditSucceeded(_ descriptionEditViewController: DescriptionEditViewController, result: ArticleDescriptionPublishResult) {
injectNewDescriptionIntoArticleContent(result.newDescription) { [weak self] injectResult in
Expand Down
16 changes: 13 additions & 3 deletions Wikipedia/Code/ArticleViewController.swift
Expand Up @@ -902,7 +902,7 @@ private extension ArticleViewController {

func setup() {
setupWButton()
setupSearchButton()
setupSearchAndEditButtons()
addNotificationHandlers()
setupWebView()
setupMessagingController()
Expand Down Expand Up @@ -945,8 +945,18 @@ private extension ArticleViewController {
surveyTimerController?.didBecomeActive(withState: state)
}

func setupSearchButton() {
navigationItem.rightBarButtonItem = AppSearchBarButtonItem.newAppSearchBarButtonItem
func setupSearchAndEditButtons() {
if FeatureFlags.needsNativeSourceEditor {
let editButton = UIBarButtonItem(title: WMFLocalizedString("article-nav-edit", value: "Edit", comment: "Edit button title. Takes user to editor to edit the full source of an article."), style: .plain, target: self, action: #selector(tappedEditArticle))
navigationItem.rightBarButtonItems = [AppSearchBarButtonItem.newAppSearchBarButtonItem, editButton]
} else {
navigationItem.rightBarButtonItem = AppSearchBarButtonItem.newAppSearchBarButtonItem
}

}

@objc func tappedEditArticle() {
showEditorForFullSource()
}

func setupMessagingController() {
Expand Down