@papyrus-sdk/engine-native 0.2.22-beta.9.epub.1 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/PapyrusPdfDocumentView.m +42 -11
- package/package.json +3 -3
|
@@ -479,9 +479,6 @@ static NSString *PapyrusHexColorFromUIColor(UIColor *color, CGFloat *opacity) {
|
|
|
479
479
|
|
|
480
480
|
- (void)setSelectionActive:(BOOL)selectionActive {
|
|
481
481
|
_selectionActive = selectionActive;
|
|
482
|
-
if (!selectionActive) {
|
|
483
|
-
[self clearCurrentSelection];
|
|
484
|
-
}
|
|
485
482
|
}
|
|
486
483
|
|
|
487
484
|
- (void)layoutSubviews {
|
|
@@ -1761,9 +1758,21 @@ static NSString *PapyrusHexColorFromUIColor(UIColor *color, CGFloat *opacity) {
|
|
|
1761
1758
|
|
|
1762
1759
|
- (void)handlePdfSelectionChanged:(NSNotification *)notification {
|
|
1763
1760
|
if (notification.object != self.pdfView) return;
|
|
1761
|
+
[self applyTemporarySelectionColor];
|
|
1764
1762
|
[self emitCurrentSelectionIfNeeded];
|
|
1765
1763
|
}
|
|
1766
1764
|
|
|
1765
|
+
- (void)applyTemporarySelectionColor {
|
|
1766
|
+
PDFSelection *selection = self.pdfView.currentSelection;
|
|
1767
|
+
if (!selection.string.length) return;
|
|
1768
|
+
|
|
1769
|
+
// PDFKit owns selection geometry and its drag handles. Setting the color on
|
|
1770
|
+
// that same selection keeps the highlight attached to text through zoom,
|
|
1771
|
+
// page rotation, and scrolling without adding a screen-space overlay.
|
|
1772
|
+
selection.color = [UIColor.systemBlueColor colorWithAlphaComponent:0.30];
|
|
1773
|
+
[self.pdfView setNeedsDisplay];
|
|
1774
|
+
}
|
|
1775
|
+
|
|
1767
1776
|
- (void)emitCurrentSelectionIfNeeded {
|
|
1768
1777
|
PDFSelection *selection = self.pdfView.currentSelection;
|
|
1769
1778
|
NSString *text = selection.string ?: @"";
|
|
@@ -1933,7 +1942,18 @@ static NSString *PapyrusHexColorFromUIColor(UIColor *color, CGFloat *opacity) {
|
|
|
1933
1942
|
return [UIMenu menuWithChildren:@[deleteAction]];
|
|
1934
1943
|
}
|
|
1935
1944
|
|
|
1936
|
-
NSMutableArray<UIMenuElement *> *
|
|
1945
|
+
NSMutableArray<UIMenuElement *> *rootActions = [NSMutableArray array];
|
|
1946
|
+
NSArray<UIMenuElement *> *localizedSystemActions =
|
|
1947
|
+
PapyrusLocalizedSelectionActions(suggestedActions ?: @[], self.copyLabel, self.selectAllLabel);
|
|
1948
|
+
UIMenuElement *nativeCopyAction = nil;
|
|
1949
|
+
for (UIMenuElement *element in localizedSystemActions) {
|
|
1950
|
+
if ([element isKindOfClass:UICommand.class] &&
|
|
1951
|
+
((UICommand *)element).action == @selector(copy:)) {
|
|
1952
|
+
nativeCopyAction = element;
|
|
1953
|
+
[rootActions addObject:element];
|
|
1954
|
+
break;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1937
1957
|
|
|
1938
1958
|
if (self.onDefineSelection && self.defineLabel.length > 0 &&
|
|
1939
1959
|
self.pdfView.currentSelection.string.length > 0 &&
|
|
@@ -1947,13 +1967,14 @@ static NSString *PapyrusHexColorFromUIColor(UIColor *color, CGFloat *opacity) {
|
|
|
1947
1967
|
handler:^(__kindof UIAction *action) {
|
|
1948
1968
|
[weakSelf emitDefineSelection];
|
|
1949
1969
|
}];
|
|
1950
|
-
[
|
|
1970
|
+
[rootActions addObject:defineAction];
|
|
1951
1971
|
}
|
|
1952
1972
|
|
|
1973
|
+
UIAction *highlightAction = nil;
|
|
1953
1974
|
if (self.onAnnotationCreated && self.annotateLabel.length > 0 &&
|
|
1954
1975
|
self.pdfView.currentSelection.string.length > 0) {
|
|
1955
1976
|
__weak typeof(self) weakSelf = self;
|
|
1956
|
-
|
|
1977
|
+
highlightAction = [UIAction
|
|
1957
1978
|
actionWithTitle:self.annotationHighlightLabel
|
|
1958
1979
|
image:[UIImage systemImageNamed:@"highlighter"]
|
|
1959
1980
|
identifier:@"com.papyrus.annotation.highlight"
|
|
@@ -1988,15 +2009,25 @@ static NSString *PapyrusHexColorFromUIColor(UIColor *color, CGFloat *opacity) {
|
|
|
1988
2009
|
handler:^(__kindof UIAction *action) {
|
|
1989
2010
|
[weakSelf emitAnnotationFromCurrentSelectionWithType:@"comment"];
|
|
1990
2011
|
}];
|
|
2012
|
+
[rootActions addObject:highlightAction];
|
|
1991
2013
|
UIMenu *annotationMenu = [UIMenu menuWithTitle:self.annotateLabel
|
|
1992
|
-
children:@[
|
|
1993
|
-
|
|
1994
|
-
[
|
|
2014
|
+
children:@[underlineAction, strikeoutAction,
|
|
2015
|
+
squigglyAction, noteAction]];
|
|
2016
|
+
[rootActions addObject:annotationMenu];
|
|
1995
2017
|
}
|
|
1996
2018
|
|
|
1997
|
-
|
|
2019
|
+
NSMutableArray<UIMenuElement *> *remainingSystemActions = [NSMutableArray array];
|
|
2020
|
+
for (UIMenuElement *element in localizedSystemActions) {
|
|
2021
|
+
if (element != nativeCopyAction) [remainingSystemActions addObject:element];
|
|
2022
|
+
}
|
|
2023
|
+
[rootActions addObjectsFromArray:remainingSystemActions];
|
|
1998
2024
|
|
|
1999
|
-
|
|
2025
|
+
UIMenu *rootMenu = [UIMenu menuWithChildren:rootActions];
|
|
2026
|
+
if (@available(iOS 16.0, *)) {
|
|
2027
|
+
// UIKit may still choose a platform-specific layout for edit menus.
|
|
2028
|
+
rootMenu.preferredElementSize = UIMenuElementSizeMedium;
|
|
2029
|
+
}
|
|
2030
|
+
return rootMenu;
|
|
2000
2031
|
}
|
|
2001
2032
|
|
|
2002
2033
|
- (BOOL)isSingleWordSelection:(NSString *)text {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@papyrus-sdk/engine-native",
|
|
3
|
-
"version": "0.2.22
|
|
3
|
+
"version": "0.2.22",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"papyrus",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"url": "https://github.com/solrachix/Papyrus/issues"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@papyrus-sdk/core": "0.2.23
|
|
53
|
-
"@papyrus-sdk/types": "0.2.16
|
|
52
|
+
"@papyrus-sdk/core": "0.2.23",
|
|
53
|
+
"@papyrus-sdk/types": "0.2.16",
|
|
54
54
|
"react-native": ">=0.81.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|