@breakside/jskit 2024.22.0 → 2024.25.0
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/Frameworks/DOM.jsframework/Info.json +2 -2
- package/Frameworks/DOM.jsframework/io.breakside.JSKit.DOM-bundle.js +2 -2
- package/Frameworks/FontKit.jsframework/Info.json +2 -2
- package/Frameworks/FontKit.jsframework/io.breakside.JSKit.FontKit-bundle.js +2 -2
- package/Frameworks/Foundation.jsframework/Info.json +2 -2
- package/Frameworks/Foundation.jsframework/JS/JSAttributedString.js +32 -0
- package/Frameworks/Foundation.jsframework/JS/JSHTMLTextParser.js +584 -0
- package/Frameworks/Foundation.jsframework/io.breakside.JSKit.Foundation-bundle.js +2 -2
- package/Frameworks/Foundation.jsframework/sources.json +3 -0
- package/Frameworks/SecurityKit.jsframework/Info.json +2 -2
- package/Frameworks/SecurityKit.jsframework/io.breakside.JSKit.SecurityKit-bundle.js +2 -2
- package/Info.json +2 -2
- package/Node/io.breakside.jskit-bundle.js +2 -2
- package/Node/jskit +1 -0
- package/Root/Frameworks/APIKit/Info.yaml +1 -1
- package/Root/Frameworks/APIKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/AuthKit/Info.yaml +1 -1
- package/Root/Frameworks/CSSOM/Info.yaml +1 -1
- package/Root/Frameworks/ChartKit/Info.yaml +1 -1
- package/Root/Frameworks/ConferenceKit/Info.yaml +1 -1
- package/Root/Frameworks/DBKit/Info.yaml +1 -1
- package/Root/Frameworks/DOM/Info.yaml +1 -1
- package/Root/Frameworks/Dispatch/Info.yaml +1 -1
- package/Root/Frameworks/FontKit/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/Info.yaml +1 -1
- package/Root/Frameworks/Foundation/JSAttributedString.js +32 -0
- package/Root/Frameworks/Foundation/JSHTMLTextParser.js +584 -0
- package/Root/Frameworks/ImageKit/Info.yaml +1 -1
- package/Root/Frameworks/MediaKit/Info.yaml +1 -1
- package/Root/Frameworks/MediaKitUI/Info.yaml +1 -1
- package/Root/Frameworks/NotificationKit/Info.yaml +1 -1
- package/Root/Frameworks/PDFKit/Info.yaml +1 -1
- package/Root/Frameworks/QRKit/Info.yaml +1 -1
- package/Root/Frameworks/SearchKit/Info.yaml +1 -1
- package/Root/Frameworks/SecurityKit/Info.yaml +1 -1
- package/Root/Frameworks/ServerKit/Info.yaml +1 -1
- package/Root/Frameworks/ServerKitTesting/Info.yaml +1 -1
- package/Root/Frameworks/TestKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/Info.yaml +1 -1
- package/Root/Frameworks/UIKit/JSColor+UIKit.js +14 -9
- package/Root/Frameworks/UIKit/UINavigationBar.js +7 -0
- package/Root/Frameworks/UIKit/UIPopupButton.js +18 -0
- package/Root/Frameworks/UIKit/UIWindow.js +4 -0
- package/Root/Frameworks/UIKitTesting/Info.yaml +1 -1
- package/package.json +1 -1
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
// #import "JSTextAttachment.js"
|
|
19
19
|
// #import "JSFont.js"
|
|
20
20
|
// #import "JSColor.js"
|
|
21
|
+
// #import "JSHTMLTextParser.js"
|
|
21
22
|
'use strict';
|
|
22
23
|
|
|
23
24
|
(function(){
|
|
@@ -197,6 +198,37 @@ JSClass("JSAttributedString", JSObject, {
|
|
|
197
198
|
this.initWithAttachment(attachment);
|
|
198
199
|
},
|
|
199
200
|
|
|
201
|
+
initWithHTML: function(html, options){
|
|
202
|
+
if (options === undefined){
|
|
203
|
+
options = {};
|
|
204
|
+
}
|
|
205
|
+
var string = "";
|
|
206
|
+
var run = JSAttributedStringRun(JSRange.Zero, {});
|
|
207
|
+
var runs = [run];
|
|
208
|
+
if (html !== null && html !== undefined){
|
|
209
|
+
var parser = JSHTMLTextParser.initWithHTML(html);
|
|
210
|
+
parser.delegate = {
|
|
211
|
+
htmlTextParserDidFindAttributedText: function(parser, text, attributes){
|
|
212
|
+
if (run.range.length === 0){
|
|
213
|
+
run.attributes = JSCopy(attributes);
|
|
214
|
+
run.range.length += text.length;
|
|
215
|
+
}else if (run.onlyContainsEqualAttributes(attributes)){
|
|
216
|
+
run.range.length += text.length;
|
|
217
|
+
}else{
|
|
218
|
+
run = JSAttributedStringRun(JSRange(run.range.end, text.length), attributes);
|
|
219
|
+
runs.push(run);
|
|
220
|
+
}
|
|
221
|
+
string += text;
|
|
222
|
+
}
|
|
223
|
+
};
|
|
224
|
+
parser.state.preserveWhitespace = options.preserveWhitespace === true;
|
|
225
|
+
parser.state.baseURL = options.baseURL || null;
|
|
226
|
+
parser.parse();
|
|
227
|
+
}
|
|
228
|
+
this._string = string;
|
|
229
|
+
this._runs = runs;
|
|
230
|
+
},
|
|
231
|
+
|
|
200
232
|
// MARK: - Getting the unattributed string value
|
|
201
233
|
|
|
202
234
|
getString: function(){
|