|
@@ -5,6 +5,7 @@ import 'dart:ui_web' as ui;
|
|
import 'dart:html' as html;
|
|
import 'dart:html' as html;
|
|
import 'augment.dart';
|
|
import 'augment.dart';
|
|
import 'dart:js' as js;
|
|
import 'dart:js' as js;
|
|
|
|
+// import 'package:flutter_web_plugins/flutter_web_plugins.dart';
|
|
|
|
|
|
class MailAddress {
|
|
class MailAddress {
|
|
final String? name;
|
|
final String? name;
|
|
@@ -341,47 +342,59 @@ class EmailView extends StatefulWidget {
|
|
|
|
|
|
class _EmailViewState extends State<EmailView> {
|
|
class _EmailViewState extends State<EmailView> {
|
|
late Key iframeKey;
|
|
late Key iframeKey;
|
|
|
|
+ late String currentContent;
|
|
|
|
+ late String viewTypeId;
|
|
|
|
|
|
@override
|
|
@override
|
|
void initState() {
|
|
void initState() {
|
|
super.initState();
|
|
super.initState();
|
|
- print(widget.id);
|
|
|
|
- iframeKey = Key("iframe-${widget.id}");
|
|
|
|
- ui.platformViewRegistry.registerViewFactory(
|
|
|
|
- // 'html-view33'
|
|
|
|
- iframeKey.toString(),
|
|
|
|
- (int viewId) => html.IFrameElement()
|
|
|
|
- ..width = '100%'
|
|
|
|
- ..height = '100%'
|
|
|
|
- ..srcdoc = widget.emailContent
|
|
|
|
- ..style.border = 'none',
|
|
|
|
- // ..style.width = '100%',
|
|
|
|
- // ..style.height = '100%'
|
|
|
|
- );
|
|
|
|
|
|
+ String currentContent = widget.emailContent;
|
|
|
|
+ viewTypeId = "iframe-${DateTime.now().millisecondsSinceEpoch}";
|
|
|
|
+ _registerViewFactory(currentContent);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void _registerViewFactory(String currentContent) {
|
|
|
|
+ setState(() {
|
|
|
|
+ viewTypeId = 'iframe-${DateTime.now().millisecondsSinceEpoch}';
|
|
|
|
+ ui.platformViewRegistry.registerViewFactory(
|
|
|
|
+ viewTypeId,
|
|
|
|
+ (int viewId) => html.IFrameElement()
|
|
|
|
+ ..width = '100%'
|
|
|
|
+ ..height = '100%'
|
|
|
|
+ ..srcdoc = currentContent
|
|
|
|
+ ..style.border = 'none');
|
|
|
|
+ });
|
|
}
|
|
}
|
|
|
|
|
|
@override
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
Widget build(BuildContext context) {
|
|
- void _handleNumbering() {
|
|
|
|
- // Check if the iframe content window is accessible
|
|
|
|
- try {
|
|
|
|
- js.context.callMethod('applyNumberingVisibility');
|
|
|
|
- } catch (e) {
|
|
|
|
- print('Error accessing iframe method: $e');
|
|
|
|
- // Optionally, use postMessage for cross-origin communication
|
|
|
|
- // js.context['iframeElement'].contentWindow.postMessage(jsify({'action': 'toggleNumbering'}), '*');
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
return Scaffold(
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
appBar: AppBar(
|
|
title: Text(widget.name),
|
|
title: Text(widget.name),
|
|
),
|
|
),
|
|
body: Column(
|
|
body: Column(
|
|
children: [
|
|
children: [
|
|
- EmailToolbar(onButtonPressed: _handleNumbering),
|
|
|
|
|
|
+ EmailToolbar(
|
|
|
|
+ onButtonPressed: () {
|
|
|
|
+ _registerViewFactory(r"""
|
|
|
|
+ <h1>Welcome to My Website</h1>
|
|
|
|
+ <p>This is a simple HTML page.</p>
|
|
|
|
+ <h2>What is HTML?</h2>
|
|
|
|
+ <p>HTML (HyperText Markup Language) is the most basic building block of the Web. It defines the meaning and structure of web content. Other technologies besides HTML are generally used to describe a web page's appearance/presentation (CSS) or functionality/behavior (JavaScript).</p>
|
|
|
|
+ <h3>Here's a simple list:</h3>
|
|
|
|
+ <ul>
|
|
|
|
+ <li>HTML elements are the building blocks of HTML pages</li>
|
|
|
|
+ <li>HTML uses tags like <code><tag></code> to organize and format content</li>
|
|
|
|
+ <li>CSS is used with HTML to style pages</li>
|
|
|
|
+ </ul>
|
|
|
|
+ <p>Copyright © 2023</p>
|
|
|
|
+ """);
|
|
|
|
+ print("change");
|
|
|
|
+ // widget.emailContent = r"
|
|
|
|
+
|
|
|
|
+// "
|
|
|
|
+ },
|
|
|
|
+ ),
|
|
Row(
|
|
Row(
|
|
// title of email
|
|
// title of email
|
|
children: [
|
|
children: [
|
|
@@ -420,9 +433,8 @@ class _EmailViewState extends State<EmailView> {
|
|
|
|
|
|
Expanded(
|
|
Expanded(
|
|
child: HtmlElementView(
|
|
child: HtmlElementView(
|
|
- key: iframeKey,
|
|
|
|
- viewType: iframeKey.toString(),
|
|
|
|
- // 'html-view33',
|
|
|
|
|
|
+ key: UniqueKey(),
|
|
|
|
+ viewType: viewTypeId,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
],
|