lucamauri/paragraphlinks 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

lucamauri/paragraphlinks

Composer 安装命令:

composer require lucamauri/paragraphlinks

包简介

MediaWiki extension that adds hover link icons to paragraphs, enabling one-click paragraph link copying

README 文档

README

ParagraphLinks is a MediaWiki extension that adds a hover-activated copy-link icon (🔗) to every section heading in wiki page content. Clicking the icon copies the full URL — including the heading's anchor fragment — to the clipboard, letting users share deep links to specific sections without inspecting the page source.

Features

  • Hover link icons: Shows a 🔗 icon when hovering over section headings (h2h6)
  • One-click copy: Copies the full URL with anchor fragment to the clipboard
  • User notification: Displays a success or error message after the copy attempt
  • Accessible: Full aria-label support for screen readers; keyboard-navigable
  • Mobile friendly: Adapts to touch devices where hover is unavailable
  • Configurable: Can be enabled or disabled globally and per namespace
  • No database changes: Pure client-side implementation; no schema modifications required

Requirements

  • MediaWiki 1.35.0 or higher
  • PHP 7.4 or higher
  • JavaScript enabled in the browser

Installation

Manual installation

  1. Clone the repository into your extensions/ directory:
    cd /path/to/mediawiki/extensions/
    git clone https://github.com/lucamauri/ParagraphLinks.git ParagraphLinks
  2. Enable the extension in LocalSettings.php:
    wfLoadExtension( 'ParagraphLinks' );

Composer installation

  1. Add the package to your composer.local.json:
    {
        "require": {
            "lucamauri/paragraphlinks": "~1.0"
        }
    }
  2. Run Composer:
    composer update --no-dev
  3. Enable the extension in LocalSettings.php:
    wfLoadExtension( 'ParagraphLinks' );

Note: No database update is required. Do not run maintenance/update.php for this extension.

Configuration

Add any of the following to your LocalSettings.php after the wfLoadExtension call:

// Enable or disable the extension globally (default: true)
$wgParagraphLinksEnabled = true;

// Namespaces where heading links are active
// Default: [0, 4, 10, 12, 14] (Main, Project, Template, Help, Category)
$wgParagraphLinksNamespaces = [
    NS_MAIN,      // 0
    NS_PROJECT,   // 4
    NS_TEMPLATE,  // 10
    NS_HELP,      // 12
    NS_CATEGORY   // 14
];

How It Works

  1. On each page view, the PHP hook BeforePageDisplay checks whether the extension is enabled and whether the current namespace is in $wgParagraphLinksNamespaces.
  2. If both conditions are met, the ext.paragraphlinks ResourceLoader module is enqueued.
  3. The JavaScript module attaches a 🔗 icon to every h2h6 element inside #mw-content-text.
  4. Clicking the icon copies window.location.href — with the heading's id as the fragment — to the clipboard using the browser's native Clipboard API.
  5. A MediaWiki notification confirms success or reports an error.

File Structure

ParagraphLinks/
├── extension.json                        # Extension manifest
├── composer.json                         # Composer metadata
├── includes/
│   └── ParagraphLinksHooks.php           # PHP hook handler
├── resources/
│   ├── ext.paragraphlinks.js             # Client-side logic
│   └── ext.paragraphlinks.css           # Heading icon styles
├── i18n/
│   ├── en.json                           # English messages
│   ├── it.json                           # Italian messages
│   └── qqq.json                          # Message documentation for translators
├── tests/
│   └── phpunit/
│       └── ParagraphLinksHooksTest.php   # PHPUnit tests
├── CHANGELOG.md
├── CONTRIBUTING.md
├── README.md
└── LICENSE

Development

Running Tests

# Run PHPUnit tests
php tests/phpunit/phpunit.php extensions/ParagraphLinks/tests/phpunit/

# Run with HTML coverage report
php tests/phpunit/phpunit.php --coverage-html coverage extensions/ParagraphLinks/tests/phpunit/

Development Setup

  1. Clone into your MediaWiki extensions/ directory and enable the extension.
  2. Enable detailed error reporting in LocalSettings.php:
    $wgShowExceptionDetails = true;
    $wgDevelopmentWarnings = true;
    $wgShowDBErrorBacktrace = true;
  3. Disable caching to see changes immediately:
    $wgMainCacheType = CACHE_NONE;
    $wgCacheDirectory = false;

Contributing

  1. Fork the repository on GitHub.
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Make your changes and add or update tests.
  4. Verify all tests pass.
  5. Open a pull request against main.

Please follow MediaWiki coding conventions and add PHPDoc comments to all public methods.

Troubleshooting

Icons not appearing

  • Confirm the extension is enabled and $wgParagraphLinksEnabled is true.
  • Check that the current page's namespace is listed in $wgParagraphLinksNamespaces.
  • Verify JavaScript is enabled in your browser and there are no console errors.

Copy to clipboard not working

  • The browser Clipboard API requires the page to be served over HTTPS.
  • Check the browser console for permission errors.

Security Considerations

  • All processing happens client-side; no user input is sent to the server.
  • No database modifications are made.
  • The extension uses the browser's native Clipboard API when available.

Browser Support

Feature Modern browsers Older browsers
Clipboard copy Native Clipboard API document.execCommand fallback
Icon display Full CSS support Graceful degradation

License

This extension is licensed under the GPL-2.0-or-later license.

Links

lucamauri/paragraphlinks 适用场景与选型建议

lucamauri/paragraphlinks 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 09 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「extension」 「links」 「mediawiki」 「paragraphs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 lucamauri/paragraphlinks 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 lucamauri/paragraphlinks 我们能提供哪些服务?
定制开发 / 二次开发

基于 lucamauri/paragraphlinks 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 3
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 32
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-09-21