### Minimal Super Editor Setup Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/getting-started/quickstart.md This example shows the basic setup for displaying a Super Editor widget. It initializes a default editor and disposes of it properly. ```dart class MyApp extends StatefulWidget { State createState() => _MyApp(); } class _MyApp extends State { late final Editor _editor; void initState() { super.initState(); _editor = createDefaultDocumentEditor( document: MutableDocument.empty(), composer: MutableDocumentComposer(), ); } void dispose() { _editor.dispose(); super.dispose(); } Widget build(BuildContext context) { return SuperEditor( editor: _editor, ); } } ``` -------------------------------- ### Installation Configuration Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/CMakeLists.txt Configures installation paths and ensures the 'install' step is part of the default build for Visual Studio. ```cmake set(BUILD_BUNDLE_DIR "$") set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Configure Installation Prefix and Bundle Directory Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_chat/linux/CMakeLists.txt Sets up the installation prefix and the build bundle directory. It ensures a clean build bundle directory is created for each installation. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") ``` -------------------------------- ### Install Application Target Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_perf/linux/CMakeLists.txt Installs the main application target to the root of the installation prefix, making it a relocatable bundle. This is part of the Runtime component. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Install Application Target Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/CMakeLists.txt Installs the main application executable to the runtime destination. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Bundle Directory Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/linux/CMakeLists.txt Sets the installation prefix to a local bundle directory within the build directory. This ensures that 'installing' creates a relocatable bundle. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() ``` -------------------------------- ### Flutter Library Setup Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_perf/windows/flutter/CMakeLists.txt Defines the Flutter library path and related files, including headers and ICU data. These are published to the parent scope for use in the install step. ```cmake # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) ``` -------------------------------- ### Install Bundled Libraries Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/linux/CMakeLists.txt Iterates through a list of bundled libraries and installs each one to the lib directory within the installation bundle. This ensures all necessary dynamic libraries are included. ```cmake foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_perf/linux/CMakeLists.txt Installs the main Flutter library file to the lib directory within the installation bundle. This is a core component for the application's runtime. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Define and Force Install Prefix for Bundle Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_perf/linux/CMakeLists.txt Sets the installation prefix to a bundle directory within the project's binary directory. It ensures a clean build bundle by removing the directory before installation. ```cmake set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() install( CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Library Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/CMakeLists.txt Installs the main Flutter library file to the root of the application bundle. ```cmake install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Run Super Editor Example App Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/README.md Navigate to the example directory and run the Flutter application on macOS to see Super Editor in action. ```bash cd example flutter run -d macos ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/CMakeLists.txt Initializes the CMake version and project name. Sets the binary name for the application. ```cmake cmake_minimum_required(VERSION 3.14) project(example_docs LANGUAGES CXX) set(BINARY_NAME "example_docs") ``` -------------------------------- ### Basic CMake Setup and Configuration Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/flutter/CMakeLists.txt Initializes CMake version and sets up the ephemeral directory. Includes generated configuration and defines fallback platforms if not set. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") # Set fallback configurations for older versions of the flutter tool. if (NOT DEFINED FLUTTER_TARGET_PLATFORM) set(FLUTTER_TARGET_PLATFORM "windows-x64") endif() ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/CMakeLists.txt Removes and then installs the Flutter assets directory to ensure it's up-to-date. ```cmake # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Executable and Runtime Files Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_chat/windows/CMakeLists.txt Installs the main executable, ICU data file, Flutter library, and any bundled plugin libraries to the specified runtime destination directory. ```cmake install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Bundled Plugin Libraries Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/CMakeLists.txt Installs any bundled libraries provided by plugins to the library directory. ```cmake if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Install Native Assets Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/CMakeLists.txt Installs native assets provided by build.dart to the library directory. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install Native Assets Directory Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/linux/CMakeLists.txt Copies the native assets directory from the build to the installation bundle. This ensures all necessary native files are included. ```cmake set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") install(DIRECTORY "${NATIVE_ASSETS_DIR}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Configure Installation Prefix for Bundled Executable Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/CMakeLists.txt Sets the installation prefix to be adjacent to the executable for in-place running, especially for Visual Studio. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") ``` -------------------------------- ### Project Setup and Basic Configuration Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_chat/windows/CMakeLists.txt Initializes the CMake project, sets the project name, and defines the minimum required CMake version. It also sets the binary name for the application. ```cmake cmake_minimum_required(VERSION 3.14) project(example_chat LANGUAGES CXX) set(BINARY_NAME "example_chat") ``` -------------------------------- ### Install AOT Library Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library on Profile and Release builds only. ```cmake install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Install Flutter Assets Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/CMakeLists.txt Installs the Flutter assets directory, ensuring it's re-copied on each build to prevent stale files. ```cmake set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Clean Build Bundle Directory on Install Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/linux/CMakeLists.txt Removes the build bundle directory before installation to ensure a clean state. This is executed as part of the installation process. ```cmake install( CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) ) ``` -------------------------------- ### Start Listening to Keyboard State Source: https://github.com/superlistapp/super_editor/blob/main/super_keyboard/doc/website/source/_includes/components/codeSampleDirectListening.md Call this method to begin receiving updates about the keyboard state. Ensure you have imported the necessary SuperKeyboard library. ```dart void startListeningToKeyboardState() { SuperKeyboard.instance.state.addListener(_onKeyboardStateChange); } ``` -------------------------------- ### Install ICU Data and Flutter Library Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/CMakeLists.txt Installs the ICU data file and the Flutter library to the data and library directories respectively. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_perf/linux/CMakeLists.txt Installs the ICU data file to the data directory within the installation bundle. This is required for internationalization and localization support. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Install ICU Data File Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/CMakeLists.txt Installs the ICU data file to the data directory of the application bundle. ```cmake install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) ``` -------------------------------- ### Modern CMake Policy and Installation Path Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/linux/CMakeLists.txt Explicitly opts into modern CMake behaviors and sets the installation path for bundled libraries. This ensures compatibility and proper library loading. ```cmake # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Basic CMake Configuration Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_perf/windows/flutter/CMakeLists.txt Sets the minimum CMake version and defines the ephemeral directory for generated files. This is a foundational setup for the build process. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Flutter Library Headers Setup Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/flutter/CMakeLists.txt Appends Flutter library header files to a list and prepends the ephemeral directory path to each. ```cmake list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Set Installation RPATH Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/CMakeLists.txt Configures the runtime search path for libraries relative to the executable. ```cmake set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") ``` -------------------------------- ### Install AOT Library Conditionally Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compilation library to the data directory, but only for Profile and Release builds. ```cmake # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Create a Custom Stylesheet Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/styling/style-a-document.md Define a custom stylesheet by copying the default and adding new rules. This example makes all level one headers green. ```dart const myStyleSheet = defaultStylesheet.copyWith( addRulesAfter: [ StyleRule( // Matches all level one headers. const BlockSelector("header1"), (document, node) { return { Styles.textStyle: const TextStyle(color: Colors.green), }; }, ), ], ); ``` -------------------------------- ### Implement StraightUnderlinePainter Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/styling/text-underlines.md Example implementation of `StraightUnderlinePainter`, a `CustomPainter` that draws a straight underline. It uses properties from `StraightUnderlineStyle` to configure the painting. ```dart class StraightUnderlinePainter extends CustomPainter { const StraightUnderlinePainter({ required List underlines, this.color = const Color(0xFF000000), this.thickness = 2, this.capType = StrokeCap.square, }) : _underlines = underlines; final List _underlines; final Color color; final double thickness; final StrokeCap capType; @override void paint(Canvas canvas, Size size) { if (_underlines.isEmpty) { return; } final linePaint = Paint() ..style = PaintingStyle.stroke ..color = color ..strokeWidth = thickness ..strokeCap = capType; for (final underline in _underlines) { canvas.drawLine(underline.start, underline.end, linePaint); } } @override bool shouldRepaint(StraightUnderlinePainter oldDelegate) { return color != oldDelegate.color || thickness != oldDelegate.thickness || capType != oldDelegate.capType || !const DeepCollectionEquality().equals(_underlines, oldDelegate._underlines); } } ``` -------------------------------- ### Basic SuperKeyboardBuilder Usage Source: https://github.com/superlistapp/super_editor/blob/main/super_keyboard/doc/website/source/_includes/components/codeSampleBuilder.md This snippet demonstrates the basic usage of SuperKeyboardBuilder. It displays the current keyboard state within a Text widget. No special setup is required beyond including the widget. ```dart import 'package:flutter/material.dart'; import 'package:super_editor/super_editor.dart'; // ... other imports and class definitions @override Widget build(BuildContext context) { return SuperKeyboardBuilder( builder: (builderContext, keyboardState) { return Center( child: Text("Keyboard state: $keyboardState"), ); } ); } ``` -------------------------------- ### Implement StraightUnderlineStyle Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/styling/text-underlines.md Example implementation of `StraightUnderlineStyle`, a subclass of `UnderlineStyle`. It defines properties like color, thickness, and cap type for a straight underline. ```dart class StraightUnderlineStyle implements UnderlineStyle { const StraightUnderlineStyle({ this.color = const Color(0xFF000000), this.thickness = 2, this.capType = StrokeCap.square, }); final Color color; final double thickness; final StrokeCap capType; @override CustomPainter createPainter(List underlines) { return StraightUnderlinePainter(underlines: underlines, color: color, thickness: thickness, capType: capType); } } ``` -------------------------------- ### Install AOT Library Conditionally Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_chat/linux/CMakeLists.txt Installs the Ahead-Of-Time (AOT) compiled library to the lib directory, but only for non-Debug build types. This optimizes release builds by including pre-compiled code. ```cmake # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Run all golden tests Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/README_TESTS.md Execute all golden tests within the project. Ensure Docker is installed and the golden_runner is activated. ```console goldens test ``` -------------------------------- ### Accessing SuperKeyboard Singleton Source: https://github.com/superlistapp/super_editor/blob/main/super_keyboard/doc/website/source/guides/unified-api.md Get the singleton instance of `SuperKeyboard` to access the unified API. ```dart final superKeyboard = SuperKeyboard.instance; ``` -------------------------------- ### Install AOT Library for Non-Debug Builds Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/linux/CMakeLists.txt Installs the AOT (Ahead-Of-Time) library only when the build type is not 'Debug'. This is typically for performance optimization in release builds. ```cmake if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Track Keyboard Animation and Height Source: https://github.com/superlistapp/super_editor/blob/main/super_keyboard/doc/website/source/guides/android.md Implement `WindowInsetsAnimationCompat.Callback` to track the keyboard's animation progress, determine when it's fully opened or closed, and get its height during animation. This is attached to a View. ```kotlin ViewCompat.setWindowInsetsAnimationCallback( mainView!!, object : WindowInsetsAnimationCompat.Callback(DISPATCH_MODE_STOP) { override fun onPrepare(animation: WindowInsetsAnimationCompat) {} override fun onStart( animation: WindowInsetsAnimationCompat, bounds: WindowInsetsAnimationCompat.BoundsCompat ): WindowInsetsAnimationCompat.BoundsCompat { return bounds; } override fun onProgress( insets: WindowInsetsCompat, runningAnimations: MutableList ): WindowInsetsCompat { val imeHeight = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom channel.invokeMethod("onProgress", mapOf( "keyboardHeight" to imeHeight, )) return insets } override fun onEnd( animation: WindowInsetsAnimationCompat ) { // Report whether the keyboard has fully opened or fully closed. if (keyboardState == KeyboardState.Opening) { channel.invokeMethod("keyboardOpened", null) } else if (keyboardState == KeyboardState.Closing) { channel.invokeMethod("keyboardClosed", null) } } } ) ``` -------------------------------- ### Handle Multiple Matching Rules (Color and Font Size) Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/styling/style-a-document.md Demonstrates how Super Editor merges styles when multiple rules match a node. This example applies green text color and a font size of 14px to level one headers. ```dart const myStyleSheet = defaultStylesheet.copyWith( addRulesAfter: [ StyleRule( // Matches all level one headers. const BlockSelector("header1"), (document, node) { return { Styles.textStyle: const TextStyle(color: Colors.green), }; }, ), StyleRule( // Matches all nodes. BlockSelector.all, (document, node) { return { Styles.textStyle: const TextStyle(fontSize: 14), }; }, ) ], ); ``` -------------------------------- ### Implementing a Custom Video Block Format Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/quill/import.md Implement `BlockDeltaFormat` to define how custom block operations, like a 'video' attribute, are handled during parsing. This example assumes an `InsertVideoRequest` is supported by the editor. ```dart class VideoBlockFormat implements BlockDeltaFormat { const VideoBlockFormat(); @override List? applyTo(Operation operation, Editor editor) { // Pull out the data based on your custom video Delta format... if (!operation.hasAttribute('video')) { return null; } final videoUrl = operation['video']; if (videoUrl is! String) { return null; } // This example assumes that your editor supports a `InsertVideoRequest`. editor.executeRequests([ InsertVideoRequest(videoUrl), ]); } } ``` -------------------------------- ### Setup Focus Sharing for Popover Toolbar Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/editing-ui/add-a-popover-toolbar.md Create a `FocusNode` for the popover and use `SuperEditorPopover` to manage focus sharing with the editor. Ensure the focus node is disposed of properly. ```dart class MyAppState extends State { // ... final FocusNode _popoverFocusNode = FocusNode(); @override void dispose() { _popoverFocusNode.dispose(); super.dispose(); } // ... Widget _buildToolbarContent() { return SuperEditorPopover( popoverFocusNode: _popoverFocusNode, editorFocusNode: _editorFocusNode, // The toolbar content. child: SizedBox(), ); } } ``` -------------------------------- ### Handle Multiple Matching Rules (Non-Conflicting Styles) Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/styling/style-a-document.md Shows how Super Editor merges styles when rules have non-conflicting properties. This example centers all nodes and applies green text color. ```dart const myStyleSheet = defaultStylesheet.copyWith( addRulesAfter: [ StyleRule( // Matches all nodes. BlockSelector.all, (document, node) { return { Styles.textAlign: TextAlign.center, }; }, ), StyleRule( // Matches all nodes. BlockSelector.all, (document, node) { return { Styles.textAlign: TextAlign.right, Styles.textStyle: const TextStyle(color: Colors.green), }; }, ) ], ); ``` -------------------------------- ### Implement Custom LinkAttribution Source: https://github.com/superlistapp/super_editor/blob/main/attributed_text/README.md This example defines a custom Attribution class, LinkAttribution, to represent hyperlinks. It includes a URL and implements canMergeWith and equality checks to manage how link attributions interact with others. Custom Attributions allow for richer metadata beyond just a name. ```dart /// Attribution to be used within [AttributedText] to /// represent a link. /// /// Every [LinkAttribution] is considered equivalent, so /// that [AttributedText] prevents multiple [LinkAttribution]s /// from overlapping. class LinkAttribution implements Attribution { LinkAttribution({ required this.url, }); @override String get id => 'link'; final Uri url; @override bool canMergeWith(Attribution other) { return this == other; } @override bool operator ==(Object other) => identical(this, other) || other is LinkAttribution && runtimeType == other.runtimeType && url == other.url; @override int get hashCode => url.hashCode; } ``` -------------------------------- ### Find and Check GTK, GLIB, and GIO Packages Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/linux/flutter/CMakeLists.txt Uses PkgConfig to find and check for the required GTK, GLIB, and GIO libraries, making their imported targets available. ```cmake find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) ``` -------------------------------- ### Example Quill Delta Document Source: https://github.com/superlistapp/super_editor/blob/main/super_editor_quill/README.md A small example of a Quill Delta document structure, used to represent text with formatting like bold and color. ```json { "ops": [ { "insert": "Gandalf", "attributes": { "bold": true } }, { "insert": " the " }, { "insert": "Grey", "attributes": { "color": "#cccccc" } } ] } ``` -------------------------------- ### Build SuperEditor with a Configurable Stylesheet Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/styling/dark-mode-and-light-mode.md Initialize `SuperEditor` with a stylesheet that can be changed later. This allows dynamic theme switching. ```dart class _MyAppState extends State { Stylesheet _stylesheet = _lightStylesheet; Widget build(BuildContext context) { return SuperEditor( stylesheet: _stylesheet, // ...other properties ); } } ``` -------------------------------- ### Build Docker Image Directly for Debugging Source: https://github.com/superlistapp/super_editor/blob/main/golden_runner/README.md Build the Docker image directly to view build logs, which can help diagnose hanging issues. Run this command from your project directory. ```console docker build -f [path_to]/golden_tester.Dockerfile -t supereditor_golden_tester . ``` -------------------------------- ### Configure FollowerAligner Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/editing-ui/add-a-popover-toolbar.md Instantiate `CupertinoPopoverToolbarAligner` to configure how the toolbar should be aligned with the selected content, typically placing it above the content by default. ```dart class MyAppState extends State { // ... late final FollowerAligner _toolbarAligner; // ... @override void initState() { super.initState(); // Place the toolbar above the content by default. _toolbarAligner = CupertinoPopoverToolbarAligner(_viewportKey); }; // ... } ``` -------------------------------- ### Export Flutter Library Path Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/linux/flutter/CMakeLists.txt Exports the FLUTTER_LIBRARY variable to the parent scope for use in the install step. ```cmake set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) ``` -------------------------------- ### Apply Standard C++ Build Settings Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/linux/CMakeLists.txt Configures C++ standard to C++14, enables all warnings, and sets optimization levels. Use this to ensure a consistent and safe build environment. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_14) target_compile_options(${TARGET} PRIVATE -Wall -Werror) target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") endfunction() ``` -------------------------------- ### Serialize Document to Quill Deltas Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/quill/export.md Call the `toQuillDeltas()` extension method on a `MutableDocument` to get its Quill Delta representation. ```dart final MutableDocument mySuperEditorDocument = getMySuperEditorDocument(); final quillDocument = mySuperEditorDocument.toQuillDeltas(); ``` -------------------------------- ### Add Dependency Libraries and Include Directories Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/runner/CMakeLists.txt Links necessary libraries (flutter, flutter_wrapper_app, dwmapi.lib) and adds the source directory to include paths for the application target. Custom application-specific dependencies should be added here. ```cmake # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/runner/CMakeLists.txt Applies a standard set of build settings to the executable target. This can be customized for applications requiring different build configurations. ```cmake # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Configure Flutter Tool Backend Command Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/flutter/CMakeLists.txt Sets up a custom command to execute the Flutter tool backend, which is responsible for assembling Flutter assets. A phony output file is used to ensure the command runs on every build. ```cmake # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Apply Standard Build Settings Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/quill/windows/runner/CMakeLists.txt Applies a standard set of build settings to the specified target. This can be removed if custom build settings are required. ```cmake apply_standard_settings(${BINARY_NAME}) ``` -------------------------------- ### Add Super Editor Dependency (Dev Preview) Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/getting-started/quickstart.md Add this dependency to use the latest dev preview build from Pub. Check pub.dev for the most recent version. ```yaml dependencies: super_editor: 0.3.0-dev.23 ``` -------------------------------- ### Project and Executable Configuration Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/linux/CMakeLists.txt Sets the minimum CMake version, project name, executable name, and application ID for the project. These are fundamental settings for any CMake project. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "example_docs") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.example_docs") ``` -------------------------------- ### Initialize SuperReader with FadeInStyler Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/ai/fade-in-content.md Set up a `SuperReader` widget with a `FadeInStyler` to manage the opacity of new content. This is typically used for non-editable LLM output. ```dart class MyState extends State { late final MutableDocument _document; late final MutableDocumentComposer _composer; late final Editor _editor; late final FadeInStyler _fadeInStylePhase; @override void initState() { super.initState(); _document = MutableDocument.empty(); _composer = MutableDocumentComposer( initialSelection: DocumentSelection.collapsed( position: DocumentPosition( nodeId: _document.first.id, nodePosition: TextNodePosition(offset: 0), ), ), ); _editor = createDefaultDocumentEditor(document: _document, composer: _composer); _fadeInStylePhase = FadeInStyler(this); } @override void dispose() { _fadeInStylePhase.dispose(); _composer.dispose(); _editor.dispose(); _document.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return SuperReader( editor: _editor, customStylePhases: [ _fadeInStylePhase, ], ); } } ``` -------------------------------- ### Flutter Library Configuration Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/flutter/CMakeLists.txt Defines the Flutter library path, ICU data file, project build directory, and AOT library. These are published to the parent scope for installation. ```cmake # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) ``` -------------------------------- ### Implementing a Custom User Tag Inline Attribute Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/quill/import.md Implement `InlineDeltaFormat` to parse custom inline attributes, such as a 'tag' attribute. This example assumes an `InsertUserTagRequest` is supported by the editor. ```dart class UserTagFormat implements InlineDeltaFormat { @override Attribution? from(Operation operation) { // Pull out the data based on your custom user tag Delta attribute format... if (!operation.hasAttribute('tag')) { return null; } final tag = operation['tag']; if (tag is! Map) { return null; } final userId = tag['userId']; final userName = tag['userName']; if (userId is! String || userName is! String) { return null; } // This hypothetical example assumes that your editor supports a // `InsertUserTagRequest`. editor.executeRequests([ InsertUserTagRequest( id: userId, name: userName, ), ]); return attribution; } } ``` -------------------------------- ### Implement Custom Block Serializer Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/quill/export.md Implement `DeltaSerializer` to define how a Super Editor `DocumentNode` is converted into a Quill Delta block. This example shows a hypothetical video block serializer. ```dart class VideoBlockSerializer implements DeltaSerializer { const VideoBlockSerializer(); @override bool serialize(DocumentNode node, Delta deltas) { if (node is! VideoNode) { return false; } deltas.operations.add( Operation.insert({ "video": node.url, }), ); return true; } } ``` -------------------------------- ### Cross-Building System Root Configuration Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_chat/linux/CMakeLists.txt Configures the system root and find root path for cross-building scenarios. This is used when building for a different target system than the host system. ```cmake if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() ``` -------------------------------- ### Configure Flutter Interface Library Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/flutter/CMakeLists.txt Creates an interface library for Flutter, specifying include directories and linking against the Flutter library. ```cmake add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Add follow_the_leader Dependency Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/editing-ui/add-a-popover-toolbar.md Add the `follow_the_leader` package to your `pubspec.yaml` file to enable toolbar alignment features. ```yaml dependencies: follow_the_leader: latest_version ``` -------------------------------- ### Detect Keyboard Opening/Closing with Window Insets Source: https://github.com/superlistapp/super_editor/blob/main/super_keyboard/doc/website/source/guides/android.md Use `onApplyWindowInsets` to detect when the keyboard starts opening or closing based on window inset visibility. This method is part of the Android View system. ```kotlin override fun onApplyWindowInsets(v: View, insets: WindowInsetsCompat): WindowInsetsCompat { val imeVisible = insets.isVisible(WindowInsetsCompat.Type.ime()) // Note: We only identify opening/closing here. The opened/closed completion // is identified by the window insets animation callback. if (imeVisible && keyboardState != KeyboardState.Opening && keyboardState != KeyboardState.Open) { channel.invokeMethod("keyboardOpening", null) keyboardState = KeyboardState.Opening } else if (!imeVisible && keyboardState != KeyboardState.Closing && keyboardState != KeyboardState.Closed) { channel.invokeMethod("keyboardClosing", null) keyboardState = KeyboardState.Closing } return insets } ``` -------------------------------- ### Create AttributedText with Bold Spans Source: https://github.com/superlistapp/super_editor/blob/main/attributed_text/README.md This example demonstrates how to create an AttributedText object and apply a 'bold' attribution to a specific range of characters within the text. It shows the basic structure for defining text and its associated metadata. ```dart final helloWorld = AttributedText( text: "Hello, world!", spans: AttributedSpans( attributions: [ const SpanMarker(attribution: bold, offset: 7, markerType: SpanMarkerType.start), const SpanMarker(attribution: bold, offset: 12, markerType: SpanMarkerType.end), ], ), ); ``` -------------------------------- ### Handle Multiple Matching Rules (Conflicting Text Alignment) Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/styling/style-a-document.md Illustrates how Super Editor resolves conflicts when multiple rules apply the same style property. The first rule's value is used if styles cannot be merged. This example centers all nodes. ```dart const myStyleSheet = defaultStylesheet.copyWith( addRulesAfter: [ StyleRule( // Matches all nodes. BlockSelector.all, (document, node) { return { Styles.textAlign: TextAlign.center, }; }, ), StyleRule( // Matches all nodes. BlockSelector.all, (document, node) { return { Styles.textAlign: TextAlign.right, }; }, ) ], ); ``` -------------------------------- ### Activate Keyboard Logging Source: https://github.com/superlistapp/super_editor/blob/main/super_keyboard/README.md Enable logging for keyboard-related events by calling SuperKeyboard.startLogging(). This can be helpful for debugging. ```dart import "package:super_keyboard/super_keyboard.dart"; SuperKeyboard.startLogging(); ``` -------------------------------- ### Link Libraries and Include Directories Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/quill/windows/runner/CMakeLists.txt Links necessary libraries (flutter, flutter_wrapper_app, dwmapi.lib) and adds include directories to the target. Application-specific dependencies should also be added here. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Flutter Wrapper Application Library Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/flutter/CMakeLists.txt Creates a static library for the Flutter wrapper application, linking against the Flutter library and setting include directories. ```cmake # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Define Windows Executable and Sources Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/runner/CMakeLists.txt Configures the main executable for the Windows runner, specifying source files and resource scripts. This is essential for building the application's entry point. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) ``` -------------------------------- ### Flutter Tool Backend Integration Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/flutter/CMakeLists.txt Configures a custom command to run the Flutter tool backend. It uses a phony output to ensure execution and defines outputs including the Flutter library and headers. ```cmake # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" ${FLUTTER_TARGET_PLATFORM} $ VERBATIM ) ``` -------------------------------- ### Simulate Software Keyboard in Widget Tests Source: https://github.com/superlistapp/super_editor/blob/main/super_keyboard/doc/website/source/guides/testing.md Wrap your test widget tree with `SoftwareKeyboardHeightSimulator` to simulate a software keyboard in widget tests. This widget intercepts platform channel messages and adjusts MediaQuery bottom insets to mimic keyboard appearance and disappearance. ```dart testWidgets("my widget test", (tester) async { await tester.pumpWidget( SoftwareKeyboardHeightSimulator( tester: tester, child: MaterialApp(...), ), ); }); ``` -------------------------------- ### Project and Executable Naming Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_perf/linux/CMakeLists.txt Sets the minimum CMake version, project name, and the on-disk name for the application executable. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) set(BINARY_NAME "example_perf") ``` -------------------------------- ### Apply Standard Settings and Compile Definitions Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/runner/CMakeLists.txt Applies standard build settings and defines NOMINMAX for the executable. NOMINMAX is often used to prevent Windows.h from defining min/max macros that can conflict with standard library functions. ```cmake apply_standard_settings(${BINARY_NAME}) target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") ``` -------------------------------- ### Create a Task Node Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/built-in-content/tasks.md Demonstrates how to create a `TaskNode` with an ID, text, and completion status. This is the fundamental building block for tasks in a `MutableDocument`. ```dart final document = MutableDocument(nodes: [ TaskNode( id: Editor.createNodeId(), text: AttributedText("Task 1"), isComplete: true, ), ]); ``` -------------------------------- ### Define Flutter library headers and include directories Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_chat/linux/flutter/CMakeLists.txt Lists the header files for the Flutter library and configures the 'flutter' interface library to include the ephemeral directory and link against the Flutter library and system dependencies. ```cmake list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Configure C++ Wrapper for Plugins Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/quill/windows/flutter/CMakeLists.txt Builds a static library for the C++ client wrapper used by Flutter plugins. Ensures position-independent code and hidden visibility. ```cmake # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### Apply Standard Compilation Settings Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/CMakeLists.txt A function to apply common compilation features, options, and definitions to a target. ```cmake function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$:_DEBUG") endfunction() ``` -------------------------------- ### Include Generated Plugins Source: https://github.com/superlistapp/super_editor/blob/main/super_clones/google_docs/windows/CMakeLists.txt Includes the CMake script that manages building and adding generated plugins to the application. ```cmake include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Set Include Directories Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_chat/linux/runner/CMakeLists.txt Specifies the include directories for the application target, allowing source files to find headers. ```cmake target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ``` -------------------------------- ### Configure Hint Component Builder Source: https://github.com/superlistapp/super_editor/blob/main/doc/website/source/super-editor/guides/basics/show-a-hint.md Add `HintComponentBuilder` to your `SuperEditor` widget's `componentBuilders` to display hint text in an empty document. Remember to include `defaultComponentBuilders` as well. ```dart Widget build(BuildContext context) { return SuperEditor( // ... componentBuilders: [ HintComponentBuilder( hint: "Start typing...", hintStyleBuilder: (context) => TextStyle( color: Colors.grey, ), ), ...defaultComponentBuilders, ], // ... ); } ``` -------------------------------- ### Initialize Super Editor Web App with Service Worker Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example_perf/web/index.html This snippet configures the service worker and initializes the Super Editor engine when the page loads. Ensure the service worker is correctly configured for optimal performance. ```javascript example_perf // The value below is injected by flutter build, do not touch. const serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, }, onEntrypointLoaded: function(engineInitializer) { engineInitializer.initializeEngine().then(function(appRunner) { appRunner.runApp(); }); } }); }); ``` -------------------------------- ### Link Libraries and Set Include Directories Source: https://github.com/superlistapp/super_editor/blob/main/super_editor/example/windows/runner/CMakeLists.txt Links the necessary Flutter and application wrapper libraries, and sets the source directory as an include directory for the executable. This ensures the application can find its dependencies and source files. ```cmake target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") ```