dartlangeditorflutterflutter-appsflutter-examplesflutter-packageflutter-widgetquillquill-deltaquilljsreactquillrich-textrich-text-editorwysiwygwysiwyg-editor
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.0 KiB
46 lines
1.0 KiB
1 year ago
|
import 'dart:convert' show jsonDecode, jsonEncode;
|
||
2 years ago
|
|
||
1 year ago
|
import 'package:flutter/material.dart' show Icons;
|
||
|
import 'package:flutter/widgets.dart';
|
||
1 year ago
|
import 'package:flutter_quill/flutter_quill.dart';
|
||
2 years ago
|
|
||
|
class TimeStampEmbed extends Embeddable {
|
||
|
const TimeStampEmbed(
|
||
|
String value,
|
||
|
) : super(timeStampType, value);
|
||
|
|
||
|
static const String timeStampType = 'timeStamp';
|
||
|
|
||
|
static TimeStampEmbed fromDocument(Document document) =>
|
||
|
TimeStampEmbed(jsonEncode(document.toDelta().toJson()));
|
||
|
|
||
|
Document get document => Document.fromJson(jsonDecode(data));
|
||
|
}
|
||
|
|
||
|
class TimeStampEmbedBuilderWidget extends EmbedBuilder {
|
||
|
@override
|
||
|
String get key => 'timeStamp';
|
||
|
|
||
|
@override
|
||
1 year ago
|
String toPlainText(Embed node) {
|
||
|
return node.value.data;
|
||
2 years ago
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(
|
||
|
BuildContext context,
|
||
|
QuillController controller,
|
||
|
Embed node,
|
||
|
bool readOnly,
|
||
|
bool inline,
|
||
|
TextStyle textStyle,
|
||
|
) {
|
||
|
return Row(
|
||
|
children: [
|
||
|
const Icon(Icons.access_time_rounded),
|
||
|
Text(node.value.data as String),
|
||
|
],
|
||
|
);
|
||
|
}
|
||
|
}
|